Chromium Code Reviews| Index: extensions/common/user_script.cc |
| diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc |
| index 4410290a55dfa5514f69f2afa71bd025a406ef54..8108b6904e9c3c5c99496edf54da4898f9a9c2e2 100644 |
| --- a/extensions/common/user_script.cc |
| +++ b/extensions/common/user_script.cc |
| @@ -85,11 +85,17 @@ 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::extension_id() const { |
| + DCHECK(consumer_id_.get()); |
| + return consumer_id_->host_id(); |
| +} |
| + |
| void UserScript::add_url_pattern(const URLPattern& pattern) { |
| url_set_.AddPattern(pattern); |
| } |
| @@ -138,13 +144,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 +168,14 @@ void UserScript::PickleGlobs(::Pickle* pickle, |
| } |
| } |
| +void UserScript::PickleConsumerID(::Pickle* pickle, |
| + linked_ptr<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 +202,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_)); |
| + consumer_id_.reset(UnpickleConsumerID(pickle, iter)); |
| UnpickleGlobs(pickle, iter, &globs_); |
| UnpickleGlobs(pickle, iter, &exclude_globs_); |
| UnpickleURLPatternSet(pickle, iter, &url_set_); |
| @@ -215,6 +229,21 @@ void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter, |
| } |
| } |
| +ConsumerID* UserScript::UnpickleConsumerID(const ::Pickle& pickle, |
|
Fady Samuel
2015/01/07 19:19:40
Return a scoped_ptr
Xi Han
2015/01/07 20:28:42
Change it to linked_ptr, due to the type of the me
|
| + PickleIterator* iter) { |
| + int host_type; |
| + 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)); |
| + return new 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) { |