Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: extensions/renderer/dispatcher.cc

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up declarative_content.json and store RequestContentScript data in action object Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« extensions/renderer/content_watcher.h ('K') | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/dispatcher.cc
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index 44b2fd0f96e818a1bf056574ab16224c2ad99ab8..cef6c94f11ab0e24be788b3b8d025d93b93323dc 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -176,7 +176,6 @@ class ChromeNativeHandler : public ObjectBackedNativeHandler {
Dispatcher::Dispatcher(DispatcherDelegate* delegate)
: delegate_(delegate),
- content_watcher_(new ContentWatcher()),
source_map_(&ResourceBundle::GetSharedInstance()),
v8_schema_registry_(new V8SchemaRegistry),
is_webkit_initialized_(false),
@@ -339,15 +338,21 @@ void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) {
frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet));
}
- content_watcher_->DidCreateDocumentElement(frame);
+ for (ContentWatcherMap::iterator it = content_watchers_.begin();
+ it != content_watchers_.end(); ++it) {
+ it->second->DidCreateDocumentElement(frame);
+ }
}
void Dispatcher::DidMatchCSS(
blink::WebFrame* frame,
const blink::WebVector<blink::WebString>& newly_matching_selectors,
const blink::WebVector<blink::WebString>& stopped_matching_selectors) {
- content_watcher_->DidMatchCSS(
- frame, newly_matching_selectors, stopped_matching_selectors);
+ for (ContentWatcherMap::iterator it = content_watchers_.begin();
+ it != content_watchers_.end(); ++it) {
+ it->second->DidMatchCSS(
+ frame, newly_matching_selectors, stopped_matching_selectors);
+ }
}
void Dispatcher::OnExtensionResponse(int request_id,
@@ -477,9 +482,8 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateTabSpecificPermissions,
OnUpdateTabSpecificPermissions)
IPC_MESSAGE_HANDLER(ExtensionMsg_UsingWebRequestAPI, OnUsingWebRequestAPI)
- IPC_MESSAGE_FORWARD(ExtensionMsg_WatchPages,
- content_watcher_.get(),
- ContentWatcher::OnWatchPages)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_WatchPages,
+ OnWatchPages)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -786,6 +790,17 @@ void Dispatcher::OnUserScriptsUpdated(
UpdateActiveExtensions();
}
+void Dispatcher::OnWatchPages(
+ const std::string& event_name,
+ const std::vector<std::string>& css_selectors) {
+ ContentWatcherMap::iterator it = content_watchers_.find(event_name);
+ if (it == content_watchers_.end()) {
+ content_watchers_[event_name] = make_linked_ptr(
+ new ContentWatcher(event_name));
+ }
+ content_watchers_[event_name]->OnWatchPages(css_selectors);
+}
+
void Dispatcher::UpdateActiveExtensions() {
std::set<std::string> active_extensions = active_extension_ids_;
user_script_set_->GetActiveExtensionIds(&active_extensions);
« extensions/renderer/content_watcher.h ('K') | « extensions/renderer/dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698