| OLD | NEW | 
|---|
| 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" | 
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" | 
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 312     global->Set(chrome_string, chrome_object); | 312     global->Set(chrome_string, chrome_object); | 
| 313     return chrome_object; | 313     return chrome_object; | 
| 314   } | 314   } | 
| 315   CHECK(chrome->IsObject()); | 315   CHECK(chrome->IsObject()); | 
| 316   return chrome->ToObject(); | 316   return chrome->ToObject(); | 
| 317 } | 317 } | 
| 318 | 318 | 
| 319 }  // namespace | 319 }  // namespace | 
| 320 | 320 | 
| 321 Dispatcher::Dispatcher() | 321 Dispatcher::Dispatcher() | 
| 322     : content_watcher_(new ContentWatcher(this)), | 322     : content_watcher_(new ContentWatcher(this)),  // TODO(jyasskin): | 
|  | 323                                                    // Move this to | 
|  | 324                                                    // ExtensionHelper | 
|  | 325                                                    // if possible. | 
| 323       is_webkit_initialized_(false), | 326       is_webkit_initialized_(false), | 
| 324       webrequest_adblock_(false), | 327       webrequest_adblock_(false), | 
| 325       webrequest_adblock_plus_(false), | 328       webrequest_adblock_plus_(false), | 
| 326       webrequest_other_(false), | 329       webrequest_other_(false), | 
| 327       source_map_(&ResourceBundle::GetSharedInstance()) { | 330       source_map_(&ResourceBundle::GetSharedInstance()) { | 
| 328   const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 331   const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 
| 329   is_extension_process_ = | 332   is_extension_process_ = | 
| 330       command_line.HasSwitch(switches::kExtensionProcess) || | 333       command_line.HasSwitch(switches::kExtensionProcess) || | 
| 331       command_line.HasSwitch(switches::kSingleProcess); | 334       command_line.HasSwitch(switches::kSingleProcess); | 
| 332 | 335 | 
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 567   module_system->RegisterNativeHandler("miscellaneous_bindings", | 570   module_system->RegisterNativeHandler("miscellaneous_bindings", | 
| 568       scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); | 571       scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); | 
| 569   module_system->RegisterNativeHandler("apiDefinitions", | 572   module_system->RegisterNativeHandler("apiDefinitions", | 
| 570       scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); | 573       scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); | 
| 571   module_system->RegisterNativeHandler("sendRequest", | 574   module_system->RegisterNativeHandler("sendRequest", | 
| 572       scoped_ptr<NativeHandler>( | 575       scoped_ptr<NativeHandler>( | 
| 573           new SendRequestNatives(this, request_sender_.get()))); | 576           new SendRequestNatives(this, request_sender_.get()))); | 
| 574   module_system->RegisterNativeHandler("setIcon", | 577   module_system->RegisterNativeHandler("setIcon", | 
| 575       scoped_ptr<NativeHandler>( | 578       scoped_ptr<NativeHandler>( | 
| 576           new SetIconNatives(this, request_sender_.get()))); | 579           new SetIconNatives(this, request_sender_.get()))); | 
| 577   module_system->RegisterNativeHandler("contentWatcherNative", |  | 
| 578                                        content_watcher_->MakeNatives()); |  | 
| 579 | 580 | 
| 580   // Natives used by multiple APIs. | 581   // Natives used by multiple APIs. | 
| 581   module_system->RegisterNativeHandler("file_system_natives", | 582   module_system->RegisterNativeHandler("file_system_natives", | 
| 582       scoped_ptr<NativeHandler>(new FileSystemNatives())); | 583       scoped_ptr<NativeHandler>(new FileSystemNatives())); | 
| 583 | 584 | 
| 584   // Custom bindings. | 585   // Custom bindings. | 
| 585   module_system->RegisterNativeHandler("app", | 586   module_system->RegisterNativeHandler("app", | 
| 586       scoped_ptr<NativeHandler>(new AppBindings(this, context))); | 587       scoped_ptr<NativeHandler>(new AppBindings(this, context))); | 
| 587   module_system->RegisterNativeHandler("app_runtime", | 588   module_system->RegisterNativeHandler("app_runtime", | 
| 588       scoped_ptr<NativeHandler>(new AppRuntimeCustomBindings())); | 589       scoped_ptr<NativeHandler>(new AppRuntimeCustomBindings())); | 
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 882     // loaded in each app. | 883     // loaded in each app. | 
| 883     frame->document().insertUserStyleSheet( | 884     frame->document().insertUserStyleSheet( | 
| 884         WebString::fromUTF8(ResourceBundle::GetSharedInstance(). | 885         WebString::fromUTF8(ResourceBundle::GetSharedInstance(). | 
| 885             GetRawDataResource(IDR_PLATFORM_APP_CSS)), | 886             GetRawDataResource(IDR_PLATFORM_APP_CSS)), | 
| 886         WebDocument::UserStyleUserLevel); | 887         WebDocument::UserStyleUserLevel); | 
| 887   } | 888   } | 
| 888 | 889 | 
| 889   content_watcher_->DidCreateDocumentElement(frame); | 890   content_watcher_->DidCreateDocumentElement(frame); | 
| 890 } | 891 } | 
| 891 | 892 | 
|  | 893 void Dispatcher::CssMatches( | 
|  | 894     WebKit::WebFrame* frame, | 
|  | 895     const WebKit::WebVector<WebKit::WebString>& newlyMatchingSelectors, | 
|  | 896     const WebKit::WebVector<WebKit::WebString>& stoppedMatchingSelectors) { | 
|  | 897   content_watcher_->CssMatches(frame, newlyMatchingSelectors, | 
|  | 898                                stoppedMatchingSelectors); | 
|  | 899 } | 
|  | 900 | 
|  | 901 | 
| 892 void Dispatcher::OnActivateExtension(const std::string& extension_id) { | 902 void Dispatcher::OnActivateExtension(const std::string& extension_id) { | 
| 893   active_extension_ids_.insert(extension_id); | 903   active_extension_ids_.insert(extension_id); | 
| 894   const Extension* extension = extensions_.GetByID(extension_id); | 904   const Extension* extension = extensions_.GetByID(extension_id); | 
| 895   CHECK(extension); | 905   CHECK(extension); | 
| 896 | 906 | 
| 897   // This is called when starting a new extension page, so start the idle | 907   // This is called when starting a new extension page, so start the idle | 
| 898   // handler ticking. | 908   // handler ticking. | 
| 899   RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayMs); | 909   RenderThread::Get()->ScheduleIdleHandler(kInitialExtensionIdleHandlerDelayMs); | 
| 900 | 910 | 
| 901   UpdateActiveExtensions(); | 911   UpdateActiveExtensions(); | 
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1151     std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 1161     std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 
| 1152     v8::ThrowException( | 1162     v8::ThrowException( | 
| 1153         v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 1163         v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 
| 1154     return false; | 1164     return false; | 
| 1155   } | 1165   } | 
| 1156 | 1166 | 
| 1157   return true; | 1167   return true; | 
| 1158 } | 1168 } | 
| 1159 | 1169 | 
| 1160 }  // namespace extensions | 1170 }  // namespace extensions | 
| OLD | NEW | 
|---|