Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Unified Diff: extensions/common/host_id.h

Issue 822453002: Introduce HostID and de-couple Extensions from "script injection System" [browser side] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/BUILD.gn ('k') | extensions/common/user_script.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/host_id.h
diff --git a/extensions/common/host_id.h b/extensions/common/host_id.h
new file mode 100644
index 0000000000000000000000000000000000000000..004480704f07766662006c7c3c570883c7e9a296
--- /dev/null
+++ b/extensions/common/host_id.h
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_COMMON_HOST_ID_H_
+#define EXTENSIONS_COMMON_HOST_ID_H_
+
+#include <string>
+
+// IDs of hosts who own user scripts.
+// A HostID is immutable after creation.
+struct HostID {
+ enum HostType { EXTENSIONS, WEBUI };
+
+ HostID() {}
+ HostID(HostType type, const std::string& id)
+ : type_(type), id_(id) {}
+
+ bool operator<(const HostID& host_id) const {
+ if (type_ != host_id.type())
+ return type_ < host_id.type();
+ else if (id_ != host_id.id())
+ return id_ < host_id.id();
+ return false;
+ }
+
+ HostType type() const { return type_; }
+ const std::string& id() const { return id_; }
+
+ private:
+ // The type of the host.
+ HostType type_;
+
+ // Similar to extension_id, host_id is a unique indentifier for a host,
+ // e.g., an Extension or WebUI.
+ std::string id_;
+};
+
+#endif // EXTENSIONS_COMMON_HOST_ID_H_
« no previous file with comments | « extensions/common/BUILD.gn ('k') | extensions/common/user_script.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698