Index: extensions/common/host_id.h |
diff --git a/extensions/common/host_id.h b/extensions/common/host_id.h |
index 004480704f07766662006c7c3c570883c7e9a296..cb26c8686aea2459be7dbafd9c57f8282a25250a 100644 |
--- a/extensions/common/host_id.h |
+++ b/extensions/common/host_id.h |
@@ -7,6 +7,10 @@ |
#include <string> |
+#include "base/macros.h" |
+#include "extensions/common/permissions/permissions_data.h" |
+#include "url/gurl.h" |
+ |
// IDs of hosts who own user scripts. |
// A HostID is immutable after creation. |
struct HostID { |
@@ -15,6 +19,9 @@ struct HostID { |
HostID() {} |
HostID(HostType type, const std::string& id) |
: type_(type), id_(id) {} |
+ HostID(const HostID& host_id) |
+ : type_(host_id.type()), |
+ id_(host_id.id()) {} |
bool operator<(const HostID& host_id) const { |
if (type_ != host_id.type()) |
@@ -24,6 +31,10 @@ struct HostID { |
return false; |
} |
+ bool operator==(const HostID& host_id) const { |
+ return type_ == host_id.type() && id_ == host_id.id(); |
+ } |
+ |
HostType type() const { return type_; } |
const std::string& id() const { return id_; } |
@@ -36,4 +47,38 @@ struct HostID { |
std::string id_; |
}; |
+// An interface for all kinds of hosts who own user scripts. |
+class Host { |
Devlin
2015/02/09 17:40:24
Can't this also be moved to renderer? And just pu
Devlin
2015/02/09 17:40:24
Having a class named "Host" in the global namespac
Xi Han
2015/02/09 23:28:11
That is true, I will rename it as InjectionHost.
I
Xi Han
2015/02/09 23:28:11
Moved to renderer. Just put kDefaultInstanceId in
|
+ public: |
+ // The default id of the instance that host will inject the script. |
+ // If the instance is a regular tab, the |instance_id| is 0; if the instance |
+ // is <webview>, the |instance_id| is a unique number that is bigger than 0. |
+ static const int kDefaultInstanceId; |
+ |
+ Host(const HostID& host_id); |
+ virtual ~Host(); |
+ |
+ virtual const std::string& GetContentSecurityPolicy() const = 0; |
+ |
+ // The base url for the host. |
+ virtual const GURL& url() const = 0; |
+ |
+ // The human-readable name of the host. |
+ virtual const std::string name() const = 0; |
+ |
+ // Returns true if the script should execute. |
+ virtual extensions::PermissionsData::AccessType CanExecuteOnFrame( |
+ const GURL& document_url, |
+ const GURL& top_frame_url, |
+ int tab_id, |
+ bool is_declarative) const = 0; |
+ |
+ const HostID& id() const { return id_; } |
+ private: |
+ // The ID of the host. |
+ HostID id_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(Host); |
+}; |
+ |
#endif // EXTENSIONS_COMMON_HOST_ID_H_ |