Chromium Code Reviews| Index: extensions/renderer/dispatcher.cc |
| diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc |
| index 5870ae513eff65e655abe6b9866baaaeac53714e..73711bf3e9a7e4f3004b7dc4c737741631d14b8a 100644 |
| --- a/extensions/renderer/dispatcher.cc |
| +++ b/extensions/renderer/dispatcher.cc |
| @@ -36,6 +36,7 @@ |
| #include "extensions/common/permissions/permissions_data.h" |
| #include "extensions/common/switches.h" |
| #include "extensions/common/view_type.h" |
| +#include "extensions/common/watched_pages_recipient.h" |
| #include "extensions/renderer/api_activity_logger.h" |
| #include "extensions/renderer/api_definitions_natives.h" |
| #include "extensions/renderer/app_runtime_custom_bindings.h" |
| @@ -174,7 +175,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) { |
| @@ -329,15 +329,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, |
| @@ -468,9 +474,8 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) { |
| OnUpdateTabSpecificPermissions) |
| IPC_MESSAGE_HANDLER(ExtensionMsg_UpdateUserScripts, OnUpdateUserScripts) |
| 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() |
| @@ -792,6 +797,20 @@ void Dispatcher::OnUsingWebRequestAPI(bool webrequest_used) { |
| delegate_->HandleWebRequestAPIUsage(webrequest_used); |
| } |
| +void Dispatcher::OnWatchPages( |
| + const std::string& event_name, |
| + const WatchedPagesRecipient& watched_pages_recipient, |
| + const std::vector<std::string>& css_selectors) { |
| + ContentWatcherMap::iterator it = content_watchers_.find(event_name); |
| + if (it == content_watchers_.end()) { |
| + content_watchers_.insert(std::make_pair(event_name, |
|
Fady Samuel
2014/06/23 18:56:28
Array notation preferred.
Mark Dittmer
2014/06/24 14:14:19
Done.
|
| + new ContentWatcher( |
| + event_name, |
| + watched_pages_recipient))); |
| + } |
| + content_watchers_[event_name]->OnWatchPages(css_selectors); |
| +} |
| + |
| void Dispatcher::UpdateActiveExtensions() { |
| std::set<std::string> active_extensions = active_extension_ids_; |
| user_script_slave_->GetActiveExtensions(&active_extensions); |