Index: extensions/common/host_id.h |
diff --git a/extensions/common/host_id.h b/extensions/common/host_id.h |
index 004480704f07766662006c7c3c570883c7e9a296..08d1b14d22b43b9a0860faa52cff35479231a43a 100644 |
--- a/extensions/common/host_id.h |
+++ b/extensions/common/host_id.h |
@@ -7,6 +7,9 @@ |
#include <string> |
+#include "base/macros.h" |
+#include "url/gurl.h" |
+ |
// IDs of hosts who own user scripts. |
// A HostID is immutable after creation. |
struct HostID { |
@@ -15,6 +18,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()) |
@@ -36,4 +42,35 @@ struct HostID { |
std::string id_; |
}; |
+// An interface for all kinds of hosts who own user scripts. |
+class Host { |
+ 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(); |
+ |
+ // Returns if the Host owns a non-empty pointer to the real host object |
+ // (extension, or WebUI). |
Devlin
2015/02/06 00:28:41
The idea of a Host being non-null but "empty" is w
Xi Han
2015/02/06 17:21:45
My initial thoughts was we may have a WebUIConsume
Devlin
2015/02/06 18:48:36
Well, all interactions from the script injection s
Xi Han
2015/02/06 19:45:33
That is fair. We can create a Host object for webU
|
+ virtual bool IsEmpty() const = 0; |
+ |
+ 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; |
+ |
+ 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_ |