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

Side by Side Diff: chrome/renderer/extensions/dispatcher.cc

Issue 19045002: Use Blink support to watch CSS selectors directly instead of using a MutationObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unCamelCase in Chrome code. Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/extensions/dispatcher.h ('k') | chrome/renderer/extensions/extension_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/extensions/dispatcher.h" 5 #include "chrome/renderer/extensions/dispatcher.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 arguments.push_back(converter->ToV8Value(*it, context->v8_context())); 389 arguments.push_back(converter->ToV8Value(*it, context->v8_context()));
390 } 390 }
391 391
392 context->module_system()->CallModuleMethod( 392 context->module_system()->CallModuleMethod(
393 module_name, method_name, &arguments); 393 module_name, method_name, &arguments);
394 } 394 }
395 395
396 } // namespace 396 } // namespace
397 397
398 Dispatcher::Dispatcher() 398 Dispatcher::Dispatcher()
399 : content_watcher_(new ContentWatcher(this)), 399 : content_watcher_(new ContentWatcher()),
400 is_webkit_initialized_(false), 400 is_webkit_initialized_(false),
401 webrequest_adblock_(false), 401 webrequest_adblock_(false),
402 webrequest_adblock_plus_(false), 402 webrequest_adblock_plus_(false),
403 webrequest_other_(false), 403 webrequest_other_(false),
404 source_map_(&ResourceBundle::GetSharedInstance()), 404 source_map_(&ResourceBundle::GetSharedInstance()),
405 v8_schema_registry_(new V8SchemaRegistry) { 405 v8_schema_registry_(new V8SchemaRegistry) {
406 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); 406 const CommandLine& command_line = *(CommandLine::ForCurrentProcess());
407 is_extension_process_ = 407 is_extension_process_ =
408 command_line.HasSwitch(switches::kExtensionProcess) || 408 command_line.HasSwitch(switches::kExtensionProcess) ||
409 command_line.HasSwitch(switches::kSingleProcess); 409 command_line.HasSwitch(switches::kSingleProcess);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 module_system->RegisterNativeHandler("messaging_natives", 822 module_system->RegisterNativeHandler("messaging_natives",
823 scoped_ptr<NativeHandler>(MessagingBindings::Get(this, context))); 823 scoped_ptr<NativeHandler>(MessagingBindings::Get(this, context)));
824 module_system->RegisterNativeHandler("apiDefinitions", 824 module_system->RegisterNativeHandler("apiDefinitions",
825 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context))); 825 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this, context)));
826 module_system->RegisterNativeHandler("sendRequest", 826 module_system->RegisterNativeHandler("sendRequest",
827 scoped_ptr<NativeHandler>( 827 scoped_ptr<NativeHandler>(
828 new SendRequestNatives(this, request_sender_.get(), context))); 828 new SendRequestNatives(this, request_sender_.get(), context)));
829 module_system->RegisterNativeHandler("setIcon", 829 module_system->RegisterNativeHandler("setIcon",
830 scoped_ptr<NativeHandler>( 830 scoped_ptr<NativeHandler>(
831 new SetIconNatives(this, request_sender_.get(), context))); 831 new SetIconNatives(this, request_sender_.get(), context)));
832 module_system->RegisterNativeHandler(
833 "contentWatcherNative",
834 content_watcher_->MakeNatives(context));
835 module_system->RegisterNativeHandler("activityLogger", 832 module_system->RegisterNativeHandler("activityLogger",
836 scoped_ptr<NativeHandler>(new APIActivityLogger(this, context))); 833 scoped_ptr<NativeHandler>(new APIActivityLogger(this, context)));
837 module_system->RegisterNativeHandler("renderViewObserverNatives", 834 module_system->RegisterNativeHandler("renderViewObserverNatives",
838 scoped_ptr<NativeHandler>(new RenderViewObserverNatives(this, context))); 835 scoped_ptr<NativeHandler>(new RenderViewObserverNatives(this, context)));
839 836
840 // Natives used by multiple APIs. 837 // Natives used by multiple APIs.
841 module_system->RegisterNativeHandler("file_system_natives", 838 module_system->RegisterNativeHandler("file_system_natives",
842 scoped_ptr<NativeHandler>(new FileSystemNatives(context))); 839 scoped_ptr<NativeHandler>(new FileSystemNatives(context)));
843 840
844 // Custom bindings. 841 // Custom bindings.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
891 module_system->RegisterNativeHandler("runtime", 888 module_system->RegisterNativeHandler("runtime",
892 scoped_ptr<NativeHandler>(new RuntimeCustomBindings(this, context))); 889 scoped_ptr<NativeHandler>(new RuntimeCustomBindings(this, context)));
893 module_system->RegisterNativeHandler("tabs", 890 module_system->RegisterNativeHandler("tabs",
894 scoped_ptr<NativeHandler>(new TabsCustomBindings(this, context))); 891 scoped_ptr<NativeHandler>(new TabsCustomBindings(this, context)));
895 module_system->RegisterNativeHandler("webstore", 892 module_system->RegisterNativeHandler("webstore",
896 scoped_ptr<NativeHandler>(new WebstoreBindings(this, context))); 893 scoped_ptr<NativeHandler>(new WebstoreBindings(this, context)));
897 } 894 }
898 895
899 void Dispatcher::PopulateSourceMap() { 896 void Dispatcher::PopulateSourceMap() {
900 // Libraries. 897 // Libraries.
901 source_map_.RegisterSource("contentWatcher", IDR_CONTENT_WATCHER_JS);
902 source_map_.RegisterSource("entryIdManager", IDR_ENTRY_ID_MANAGER); 898 source_map_.RegisterSource("entryIdManager", IDR_ENTRY_ID_MANAGER);
903 source_map_.RegisterSource(kEventBindings, IDR_EVENT_BINDINGS_JS); 899 source_map_.RegisterSource(kEventBindings, IDR_EVENT_BINDINGS_JS);
904 source_map_.RegisterSource("imageUtil", IDR_IMAGE_UTIL_JS); 900 source_map_.RegisterSource("imageUtil", IDR_IMAGE_UTIL_JS);
905 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS); 901 source_map_.RegisterSource("json_schema", IDR_JSON_SCHEMA_JS);
906 source_map_.RegisterSource("lastError", IDR_LAST_ERROR_JS); 902 source_map_.RegisterSource("lastError", IDR_LAST_ERROR_JS);
907 source_map_.RegisterSource("messaging", IDR_MESSAGING_JS); 903 source_map_.RegisterSource("messaging", IDR_MESSAGING_JS);
908 source_map_.RegisterSource("messaging_utils", IDR_MESSAGING_UTILS_JS); 904 source_map_.RegisterSource("messaging_utils", IDR_MESSAGING_UTILS_JS);
909 source_map_.RegisterSource(kSchemaUtils, IDR_SCHEMA_UTILS_JS); 905 source_map_.RegisterSource(kSchemaUtils, IDR_SCHEMA_UTILS_JS);
910 source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS); 906 source_map_.RegisterSource("sendRequest", IDR_SEND_REQUEST_JS);
911 source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS); 907 source_map_.RegisterSource("setIcon", IDR_SET_ICON_JS);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 "$FONTFAMILY", system_font_family_); 1207 "$FONTFAMILY", system_font_family_);
1212 ReplaceFirstSubstringAfterOffset(&stylesheet, 0, 1208 ReplaceFirstSubstringAfterOffset(&stylesheet, 0,
1213 "$FONTSIZE", system_font_size_); 1209 "$FONTSIZE", system_font_size_);
1214 frame->document().insertUserStyleSheet( 1210 frame->document().insertUserStyleSheet(
1215 WebString::fromUTF8(stylesheet), WebDocument::UserStyleUserLevel); 1211 WebString::fromUTF8(stylesheet), WebDocument::UserStyleUserLevel);
1216 } 1212 }
1217 1213
1218 content_watcher_->DidCreateDocumentElement(frame); 1214 content_watcher_->DidCreateDocumentElement(frame);
1219 } 1215 }
1220 1216
1217 void Dispatcher::DidMatchCSS(
1218 WebKit::WebFrame* frame,
1219 const WebKit::WebVector<WebKit::WebString>& newly_matching_selectors,
1220 const WebKit::WebVector<WebKit::WebString>& stopped_matching_selectors) {
1221 content_watcher_->DidMatchCSS(
1222 frame, newly_matching_selectors, stopped_matching_selectors);
1223 }
1224
1225
1221 void Dispatcher::OnActivateExtension(const std::string& extension_id) { 1226 void Dispatcher::OnActivateExtension(const std::string& extension_id) {
1222 const Extension* extension = extensions_.GetByID(extension_id); 1227 const Extension* extension = extensions_.GetByID(extension_id);
1223 if (!extension) { 1228 if (!extension) {
1224 // Extension was activated but was never loaded. This probably means that 1229 // Extension was activated but was never loaded. This probably means that
1225 // the renderer failed to load it (or the browser failed to tell us when it 1230 // the renderer failed to load it (or the browser failed to tell us when it
1226 // did). Failures shouldn't happen, but instead of crashing there (which 1231 // did). Failures shouldn't happen, but instead of crashing there (which
1227 // executes on all renderers) be conservative and only crash in the renderer 1232 // executes on all renderers) be conservative and only crash in the renderer
1228 // of the extension which failed to load; this one. 1233 // of the extension which failed to load; this one.
1229 std::string& error = extension_load_errors_[extension_id]; 1234 std::string& error = extension_load_errors_[extension_id];
1230 char minidump[256]; 1235 char minidump[256];
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 RenderView* background_view = 1566 RenderView* background_view =
1562 ExtensionHelper::GetBackgroundPage(extension_id); 1567 ExtensionHelper::GetBackgroundPage(extension_id);
1563 if (background_view) { 1568 if (background_view) {
1564 background_view->Send(new ExtensionHostMsg_EventAck( 1569 background_view->Send(new ExtensionHostMsg_EventAck(
1565 background_view->GetRoutingID())); 1570 background_view->GetRoutingID()));
1566 } 1571 }
1567 } 1572 }
1568 } 1573 }
1569 1574
1570 } // namespace extensions 1575 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/dispatcher.h ('k') | chrome/renderer/extensions/extension_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698