| 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/extension_dispatcher.h" | 5 #include "chrome/renderer/extensions/extension_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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 } | 223 } |
| 224 | 224 |
| 225 ExtensionDispatcher::ExtensionDispatcher() | 225 ExtensionDispatcher::ExtensionDispatcher() |
| 226 : is_webkit_initialized_(false), | 226 : is_webkit_initialized_(false), |
| 227 webrequest_adblock_(false), | 227 webrequest_adblock_(false), |
| 228 webrequest_adblock_plus_(false), | 228 webrequest_adblock_plus_(false), |
| 229 webrequest_other_(false), | 229 webrequest_other_(false), |
| 230 source_map_(&ResourceBundle::GetSharedInstance()), | 230 source_map_(&ResourceBundle::GetSharedInstance()), |
| 231 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { | 231 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), |
| 232 event_filter_(new extensions::EventFilter) { |
| 232 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 233 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
| 233 is_extension_process_ = | 234 is_extension_process_ = |
| 234 command_line.HasSwitch(switches::kExtensionProcess) || | 235 command_line.HasSwitch(switches::kExtensionProcess) || |
| 235 command_line.HasSwitch(switches::kSingleProcess); | 236 command_line.HasSwitch(switches::kSingleProcess); |
| 236 | 237 |
| 237 if (is_extension_process_) { | 238 if (is_extension_process_) { |
| 238 RenderThread::Get()->SetIdleNotificationDelayInMs( | 239 RenderThread::Get()->SetIdleNotificationDelayInMs( |
| 239 kInitialExtensionIdleHandlerDelayMs); | 240 kInitialExtensionIdleHandlerDelayMs); |
| 240 } | 241 } |
| 241 | 242 |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 const std::string& v8_extension_name, | 475 const std::string& v8_extension_name, |
| 475 int extension_group, | 476 int extension_group, |
| 476 int world_id) { | 477 int world_id) { |
| 477 g_hack_extension_group = extension_group; | 478 g_hack_extension_group = extension_group; |
| 478 return true; | 479 return true; |
| 479 } | 480 } |
| 480 | 481 |
| 481 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, | 482 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
| 482 ChromeV8Context* context) { | 483 ChromeV8Context* context) { |
| 483 module_system->RegisterNativeHandler("event_bindings", | 484 module_system->RegisterNativeHandler("event_bindings", |
| 484 scoped_ptr<NativeHandler>(EventBindings::Get(this))); | 485 scoped_ptr<NativeHandler>(EventBindings::Get(this, event_filter_.get()))); |
| 485 module_system->RegisterNativeHandler("miscellaneous_bindings", | 486 module_system->RegisterNativeHandler("miscellaneous_bindings", |
| 486 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); | 487 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); |
| 487 module_system->RegisterNativeHandler("apiDefinitions", | 488 module_system->RegisterNativeHandler("apiDefinitions", |
| 488 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); | 489 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); |
| 489 module_system->RegisterNativeHandler("sendRequest", | 490 module_system->RegisterNativeHandler("sendRequest", |
| 490 scoped_ptr<NativeHandler>( | 491 scoped_ptr<NativeHandler>( |
| 491 new SendRequestNatives(this, request_sender_.get()))); | 492 new SendRequestNatives(this, request_sender_.get()))); |
| 492 module_system->RegisterNativeHandler("setIcon", | 493 module_system->RegisterNativeHandler("setIcon", |
| 493 scoped_ptr<NativeHandler>( | 494 scoped_ptr<NativeHandler>( |
| 494 new SetIconNatives(this, request_sender_.get()))); | 495 new SetIconNatives(this, request_sender_.get()))); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 958 // APIs, they don't get extension bindings injected. If we end up here it | 959 // APIs, they don't get extension bindings injected. If we end up here it |
| 959 // means that a sandboxed page somehow managed to invoke an API anyway, so | 960 // means that a sandboxed page somehow managed to invoke an API anyway, so |
| 960 // we should abort. | 961 // we should abort. |
| 961 WebKit::WebFrame* frame = context->web_frame(); | 962 WebKit::WebFrame* frame = context->web_frame(); |
| 962 ExtensionURLInfo url_info(frame->document().securityOrigin(), | 963 ExtensionURLInfo url_info(frame->document().securityOrigin(), |
| 963 UserScriptSlave::GetDataSourceURLForFrame(frame)); | 964 UserScriptSlave::GetDataSourceURLForFrame(frame)); |
| 964 CHECK(!extensions_.IsSandboxedPage(url_info)); | 965 CHECK(!extensions_.IsSandboxedPage(url_info)); |
| 965 | 966 |
| 966 return true; | 967 return true; |
| 967 } | 968 } |
| OLD | NEW |