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

Unified Diff: extensions/common/user_script.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: Introduce ConsumerIDFactory 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
Index: extensions/common/user_script.h
diff --git a/extensions/common/user_script.h b/extensions/common/user_script.h
index 5a2731536b2237699a1c76f54aa778d2af9643e8..fd086e3651ef103547912a2e4639a4c3ff3f5ed1 100644
--- a/extensions/common/user_script.h
+++ b/extensions/common/user_script.h
@@ -10,7 +10,9 @@
#include "base/basictypes.h"
#include "base/files/file_path.h"
+#include "base/memory/linked_ptr.h"
#include "base/strings/string_piece.h"
+#include "extensions/common/consumer.h"
#include "extensions/common/url_pattern.h"
#include "extensions/common/url_pattern_set.h"
#include "url/gurl.h"
@@ -194,8 +196,10 @@ class UserScript {
FileList& css_scripts() { return css_scripts_; }
const FileList& css_scripts() const { return css_scripts_; }
- const std::string& extension_id() const { return extension_id_; }
- void set_extension_id(const std::string& id) { extension_id_ = id; }
+ ConsumerID* consumer_id() const { return consumer_id_.get(); }
Fady Samuel 2015/01/08 21:03:08 nit: const ConsumerID*
Xi Han 2015/01/08 22:46:46 Done.
+ void set_consumer_id(const ConsumerID& consumer_id) {
+ consumer_id_.reset(new ConsumerID(consumer_id));
+ }
int id() const { return user_script_id_; }
void set_id(int id) { user_script_id_ = id; }
@@ -203,7 +207,9 @@ class UserScript {
bool is_incognito_enabled() const { return incognito_enabled_; }
void set_incognito_enabled(bool enabled) { incognito_enabled_ = enabled; }
- bool is_standalone() const { return extension_id_.empty(); }
+ bool is_standalone() const { return GetExtensionID().empty(); }
+
+ const std::string& GetExtensionID() const;
// Returns true if the script should be applied to the specified URL, false
// otherwise.
@@ -222,6 +228,8 @@ class UserScript {
// Pickle helper functions used to pickle the individual types of components.
void PickleGlobs(::Pickle* pickle,
const std::vector<std::string>& globs) const;
+ void PickleConsumerID(::Pickle* pickle,
+ linked_ptr<ConsumerID> consumer_id) const;
void PickleURLPatternSet(::Pickle* pickle,
const URLPatternSet& pattern_list) const;
void PickleScripts(::Pickle* pickle, const FileList& scripts) const;
@@ -229,6 +237,8 @@ class UserScript {
// Unpickle helper functions used to unpickle individual types of components.
void UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter,
std::vector<std::string>* globs);
+ linked_ptr<ConsumerID> UnpickleConsumerID(const ::Pickle& pickle,
+ PickleIterator* iter);
void UnpickleURLPatternSet(const ::Pickle& pickle, PickleIterator* iter,
URLPatternSet* pattern_list);
void UnpickleScripts(const ::Pickle& pickle, PickleIterator* iter,
@@ -267,9 +277,9 @@ class UserScript {
// List of css scripts defined in content_scripts
FileList css_scripts_;
- // The ID of the extension this script is a part of, if any. Can be empty if
- // the script is a "standlone" user script.
- std::string extension_id_;
+ // The ID of the consumer this script is a part of. The host_id of the
+ // consumer_id can be empty if the script is a "standlone" user script.
+ linked_ptr<ConsumerID> consumer_id_;
// The globally-unique id associated with this user script. Defaults to
// -1 for invalid.

Powered by Google App Engine
This is Rietveld 408576698