summaryrefslogtreecommitdiffstats
path: root/extensions/common/user_script.cc
diff options
context:
space:
mode:
authorhanxi <hanxi@chromium.org>2015-02-05 06:27:32 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-05 14:28:16 +0000
commitc0503d76ca4216349132b8a2ca1db5a15a11292a (patch)
treeb2ecec27ca4f450e98017caf744d744cf8d490ab /extensions/common/user_script.cc
parent159604379ff8ef8d3db4577f44d3d6438092ccf0 (diff)
downloadchromium_src-c0503d76ca4216349132b8a2ca1db5a15a11292a.zip
chromium_src-c0503d76ca4216349132b8a2ca1db5a15a11292a.tar.gz
chromium_src-c0503d76ca4216349132b8a2ca1db5a15a11292a.tar.bz2
Revert of Revert of Introduce HostID and de-couple Extensions from "script injection System" [browser side] (patchset #2 id:270001 of https://codereview.chromium.org/899983002/)
Reason for revert: It turns out that the crash wasn't caused by this CL. Original issue's description: > Revert of Introduce HostID and de-couple Extensions from "script injection System" [browser side] (patchset #20 id:760001 of https://codereview.chromium.org/822453002/) > > Reason for revert: > It might cause the crash https://code.google.com/p/chromium/issues/detail?id=454917. > > Original issue's description: > > 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 > > > > Committed: https://crrev.com/b88fe3dc1072501bdd105fd95a8b3bc453fd2aa7 > > Cr-Commit-Position: refs/heads/master@{#313402} > > TBR=fsamuel@chromium.org,rdevlin.cronin@chromium.org > NOPRESUBMIT=true > NOTREECHECKS=true > NOTRY=true > BUG=437566 > > Committed: https://crrev.com/5eb894ea21637241e9a78fb9c2737d40d6dbf575 > Cr-Commit-Position: refs/heads/master@{#314631} TBR=fsamuel@chromium.org,rdevlin.cronin@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=437566 Review URL: https://codereview.chromium.org/903743002 Cr-Commit-Position: refs/heads/master@{#314807}
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) {