hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 5 | #ifndef EXTENSIONS_RENDERER_INJECTION_HOST_H_ |
| 6 | #define EXTENSIONS_RENDERER_INJECTION_HOST_H_ |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 7 | |
avi | 2d124c0 | 2015-12-23 06:36:42 | [diff] [blame] | 8 | #include "base/macros.h" |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 9 | #include "extensions/common/host_id.h" |
| 10 | #include "extensions/common/permissions/permissions_data.h" |
| 11 | #include "url/gurl.h" |
| 12 | |
rdevlin.cronin | f994d1e | 2015-06-03 22:28:19 | [diff] [blame] | 13 | namespace content { |
| 14 | class RenderFrame; |
| 15 | } |
| 16 | |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 17 | // An interface for all kinds of hosts who own user scripts. |
| 18 | class InjectionHost { |
| 19 | public: |
| 20 | InjectionHost(const HostID& host_id); |
| 21 | virtual ~InjectionHost(); |
| 22 | |
hanxi | 9b84166 | 2015-03-04 14:36:41 | [diff] [blame] | 23 | virtual std::string GetContentSecurityPolicy() const = 0; |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 24 | |
| 25 | // The base url for the host. |
| 26 | virtual const GURL& url() const = 0; |
| 27 | |
| 28 | // The human-readable name of the host. |
| 29 | virtual const std::string& name() const = 0; |
| 30 | |
| 31 | // Returns true if the script should execute. |
Devlin Cronin | 3e532b8 | 2018-05-03 21:27:19 | [diff] [blame] | 32 | virtual extensions::PermissionsData::PageAccess CanExecuteOnFrame( |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 33 | const GURL& document_url, |
rdevlin.cronin | f994d1e | 2015-06-03 22:28:19 | [diff] [blame] | 34 | content::RenderFrame* render_frame, |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 35 | int tab_id, |
| 36 | bool is_declarative) const = 0; |
| 37 | |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 38 | const HostID& id() const { return id_; } |
hanxi | 9b84166 | 2015-03-04 14:36:41 | [diff] [blame] | 39 | |
hanxi | a5c856cf | 2015-02-13 20:51:58 | [diff] [blame] | 40 | private: |
| 41 | // The ID of the host. |
| 42 | HostID id_; |
| 43 | |
| 44 | DISALLOW_COPY_AND_ASSIGN(InjectionHost); |
| 45 | }; |
| 46 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 47 | #endif // EXTENSIONS_RENDERER_INJECTION_HOST_H_ |