Index: extensions/common/user_script.cc |
diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc |
index 4410290a55dfa5514f69f2afa71bd025a406ef54..f5036d4b41216de4c1e2d5d69ec2e63e366c4eca 100644 |
--- a/extensions/common/user_script.cc |
+++ b/extensions/common/user_script.cc |
@@ -85,11 +85,16 @@ UserScript::UserScript() |
emulate_greasemonkey_(false), |
match_all_frames_(false), |
match_about_blank_(false), |
- incognito_enabled_(false) {} |
+ incognito_enabled_(false) { |
+} |
UserScript::~UserScript() { |
} |
+const std::string& UserScript::GetExtensionID() const { |
+ return consumer_id_.host_id(); |
+} |
+ |
void UserScript::add_url_pattern(const URLPattern& pattern) { |
url_set_.AddPattern(pattern); |
} |
@@ -138,13 +143,13 @@ void UserScript::File::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { |
void UserScript::Pickle(::Pickle* pickle) const { |
// Write the simple types to the pickle. |
pickle->WriteInt(run_location()); |
- pickle->WriteString(extension_id()); |
pickle->WriteInt(user_script_id_); |
pickle->WriteBool(emulate_greasemonkey()); |
pickle->WriteBool(match_all_frames()); |
pickle->WriteBool(match_about_blank()); |
pickle->WriteBool(is_incognito_enabled()); |
+ PickleConsumerID(pickle, consumer_id_); |
PickleGlobs(pickle, globs_); |
PickleGlobs(pickle, exclude_globs_); |
PickleURLPatternSet(pickle, url_set_); |
@@ -162,6 +167,14 @@ void UserScript::PickleGlobs(::Pickle* pickle, |
} |
} |
+void UserScript::PickleConsumerID(::Pickle* pickle, |
+ const ConsumerID& consumer_id) const { |
+ pickle->WriteInt(consumer_id.host_type()); |
+ pickle->WriteString(consumer_id.host_id()); |
+ pickle->WriteInt(consumer_id.instance_type()); |
+ pickle->WriteInt(consumer_id.instance_id()); |
+} |
+ |
void UserScript::PickleURLPatternSet(::Pickle* pickle, |
const URLPatternSet& pattern_list) const { |
pickle->WriteSizeT(pattern_list.patterns().size()); |
@@ -188,13 +201,13 @@ void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) { |
CHECK(run_location >= 0 && run_location < RUN_LOCATION_LAST); |
run_location_ = static_cast<RunLocation>(run_location); |
- CHECK(iter->ReadString(&extension_id_)); |
CHECK(iter->ReadInt(&user_script_id_)); |
CHECK(iter->ReadBool(&emulate_greasemonkey_)); |
CHECK(iter->ReadBool(&match_all_frames_)); |
CHECK(iter->ReadBool(&match_about_blank_)); |
CHECK(iter->ReadBool(&incognito_enabled_)); |
+ UnpickleConsumerID(pickle, iter, &consumer_id_); |
UnpickleGlobs(pickle, iter, &globs_); |
UnpickleGlobs(pickle, iter, &exclude_globs_); |
UnpickleURLPatternSet(pickle, iter, &url_set_); |
@@ -215,6 +228,22 @@ void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter, |
} |
} |
+void UserScript::UnpickleConsumerID(const ::Pickle& pickle, |
+ PickleIterator* iter, |
+ ConsumerID* consumer_id) { |
+ int host_type; |
Devlin
2015/01/20 17:51:06
nit: initialize the ints to something reasonable (
Xi Han
2015/01/21 21:30:17
Done.
|
+ std::string host_id; |
+ int instance_type; |
+ int instance_id; |
+ CHECK(iter->ReadInt(&host_type)); |
+ CHECK(iter->ReadString(&host_id)); |
+ CHECK(iter->ReadInt(&instance_type)); |
+ CHECK(iter->ReadInt(&instance_id)); |
+ *consumer_id = ConsumerID( |
+ static_cast<ConsumerID::HostType>(host_type), host_id, |
+ static_cast<ConsumerID::InstanceType>(instance_type), instance_id); |
+} |
+ |
void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle, |
PickleIterator* iter, |
URLPatternSet* pattern_list) { |