summaryrefslogtreecommitdiffstats
path: root/extensions/common/user_script.cc
diff options
context:
space:
mode:
authorhanxi <hanxi@chromium.org>2015-03-03 15:14:06 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-03 23:14:33 +0000
commitccff496a48cdf435d59ef79f3fe9ae1e6914ed22 (patch)
tree5cee1a4e178905c2e02372c112c4e39f282d74e5 /extensions/common/user_script.cc
parentdb73faeca6f1a3a6cb2923afc2e0bc3ea995aee7 (diff)
downloadchromium_src-ccff496a48cdf435d59ef79f3fe9ae1e6914ed22.zip
chromium_src-ccff496a48cdf435d59ef79f3fe9ae1e6914ed22.tar.gz
chromium_src-ccff496a48cdf435d59ef79f3fe9ae1e6914ed22.tar.bz2
This CL adds routing info for content scripts from <webview>.
To support dynamically added/removed content scripts in <webview>, we store these content scripts in the same shared memory where user scripts from declarative content API are stored, but the decision for injection will be made in the render once the url pattern is matched. Since render doesn't need to send IPCs to ask a decision from browser, it makes a precise time injection possible. Special to <webview>, once the content scripts are updated (added/removed), browser will only notify the render process of the given <webview>, rather than all of the renders (which is the case for user scripts). BUG=437566 Committed: https://crrev.com/f853287c95cf818d0b5b02d7f4a6588761096d1c Cr-Commit-Position: refs/heads/master@{#318774} Review URL: https://codereview.chromium.org/906493004 Cr-Commit-Position: refs/heads/master@{#318959}
Diffstat (limited to 'extensions/common/user_script.cc')
-rw-r--r--extensions/common/user_script.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/extensions/common/user_script.cc b/extensions/common/user_script.cc
index b8ba22e..7859e75 100644
--- a/extensions/common/user_script.cc
+++ b/extensions/common/user_script.cc
@@ -145,6 +145,8 @@ void UserScript::Pickle(::Pickle* pickle) const {
pickle->WriteBool(is_incognito_enabled());
PickleHostID(pickle, host_id_);
+ pickle->WriteInt(consumer_instance_type());
+ PickleRoutingInfo(pickle, routing_info_);
PickleGlobs(pickle, globs_);
PickleGlobs(pickle, exclude_globs_);
PickleURLPatternSet(pickle, url_set_);
@@ -167,6 +169,12 @@ void UserScript::PickleHostID(::Pickle* pickle, const HostID& host_id) const {
pickle->WriteString(host_id.id());
}
+void UserScript::PickleRoutingInfo(::Pickle* pickle,
+ const RoutingInfo& routing_info) const {
+ pickle->WriteInt(routing_info.render_process_id);
+ pickle->WriteInt(routing_info.render_view_id);
+}
+
void UserScript::PickleURLPatternSet(::Pickle* pickle,
const URLPatternSet& pattern_list) const {
pickle->WriteSizeT(pattern_list.patterns().size());
@@ -200,6 +208,13 @@ void UserScript::Unpickle(const ::Pickle& pickle, PickleIterator* iter) {
CHECK(iter->ReadBool(&incognito_enabled_));
UnpickleHostID(pickle, iter, &host_id_);
+
+ int consumer_instance_type = 0;
+ CHECK(iter->ReadInt(&consumer_instance_type));
+ consumer_instance_type_ =
+ static_cast<ConsumerInstanceType>(consumer_instance_type);
+
+ UnpickleRoutingInfo(pickle, iter, &routing_info_);
UnpickleGlobs(pickle, iter, &globs_);
UnpickleGlobs(pickle, iter, &exclude_globs_);
UnpickleURLPatternSet(pickle, iter, &url_set_);
@@ -230,6 +245,13 @@ void UserScript::UnpickleHostID(const ::Pickle& pickle,
*host_id = HostID(static_cast<HostID::HostType>(type), id);
}
+void UserScript::UnpickleRoutingInfo(const ::Pickle& pickle,
+ PickleIterator* iter,
+ RoutingInfo* routing_info) {
+ CHECK(iter->ReadInt(&routing_info->render_process_id));
+ CHECK(iter->ReadInt(&routing_info->render_view_id));
+}
+
void UserScript::UnpickleURLPatternSet(const ::Pickle& pickle,
PickleIterator* iter,
URLPatternSet* pattern_list) {