summaryrefslogtreecommitdiffstats
path: root/extensions/common/user_script.cc
diff options
context:
space:
mode:
authorhanxi <hanxi@chromium.org>2015-01-27 15:38:46 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-27 23:40:18 +0000
commitb88fe3dc1072501bdd105fd95a8b3bc453fd2aa7 (patch)
treee4f8aecf3319c52d1b5e32d56ffe28191b45faf9 /extensions/common/user_script.cc
parent86b7486d902f7e1389f8a3dad9ff42ee68134076 (diff)
downloadchromium_src-b88fe3dc1072501bdd105fd95a8b3bc453fd2aa7.zip
chromium_src-b88fe3dc1072501bdd105fd95a8b3bc453fd2aa7.tar.gz
chromium_src-b88fe3dc1072501bdd105fd95a8b3bc453fd2aa7.tar.bz2
Introduce HostID and de-couple Extensions from "script injection System" [browser side]
The major refactor includes: - Introduce HostID (a pair of |id, type|) to replace extension_id in browser side. - Abstract UserScriptLoader to be a base class, and introduces a derived class ExtensionUserScriptLoader which is responsible for loading user scripts for extensions. - In DeclarativeUserScriptManager, a master is created per extension/webUI. - DeclarativeUserScriptManager becomes an ExtensionRegistryObserver and is responsible for clearing scripts for master objects when receive OnExensionUnloaded event. BUG=437566 Review URL: https://codereview.chromium.org/822453002 Cr-Commit-Position: refs/heads/master@{#313402}
Diffstat (limited to 'extensions/common/user_script.cc')
-rw-r--r--extensions/common/user_script.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc
index 4410290..b8ba22e 100644
--- a/extensions/common/user_script.cc
+++ b/extensions/common/user_script.cc
@@ -138,13 +138,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());
+ PickleHostID(pickle, host_id_);
PickleGlobs(pickle, globs_);
PickleGlobs(pickle, exclude_globs_);
PickleURLPatternSet(pickle, url_set_);
@@ -162,6 +162,11 @@ void UserScript::PickleGlobs(::Pickle* pickle,
}
}
+void UserScript::PickleHostID(::Pickle* pickle, const HostID& host_id) const {
+ pickle->WriteInt(host_id.type());
+ pickle->WriteString(host_id.id());
+}
+
void UserScript::PickleURLPatternSet(::Pickle* pickle,
const URLPatternSet& pattern_list) const {
pickle->WriteSizeT(pattern_list.patterns().size());
@@ -188,13 +193,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_));
+ UnpickleHostID(pickle, iter, &host_id_);
UnpickleGlobs(pickle, iter, &globs_);
UnpickleGlobs(pickle, iter, &exclude_globs_);
UnpickleURLPatternSet(pickle, iter, &url_set_);
@@ -215,6 +220,16 @@ void UserScript::UnpickleGlobs(const ::Pickle& pickle, PickleIterator* iter,
}
}
+void UserScript::UnpickleHostID(const ::Pickle& pickle,
+ PickleIterator* iter,
+ HostID* host_id) {
+ int type = 0;
+ std::string id;
+ CHECK(iter->ReadInt(&type));
+ CHECK(iter->ReadString(&id));
+ *host_id = HostID(static_cast<HostID::HostType>(type), id);
+}
+
void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle,
PickleIterator* iter,
URLPatternSet* pattern_list) {