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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 } | 226 } |
227 | 227 |
228 ExtensionDispatcher::ExtensionDispatcher() | 228 ExtensionDispatcher::ExtensionDispatcher() |
229 : is_webkit_initialized_(false), | 229 : is_webkit_initialized_(false), |
230 webrequest_adblock_(false), | 230 webrequest_adblock_(false), |
231 webrequest_adblock_plus_(false), | 231 webrequest_adblock_plus_(false), |
232 webrequest_other_(false), | 232 webrequest_other_(false), |
233 source_map_(&ResourceBundle::GetSharedInstance()), | 233 source_map_(&ResourceBundle::GetSharedInstance()), |
234 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { | 234 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), |
| 235 event_filter_(new extensions::EventFilter) { |
235 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 236 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
236 is_extension_process_ = | 237 is_extension_process_ = |
237 command_line.HasSwitch(switches::kExtensionProcess) || | 238 command_line.HasSwitch(switches::kExtensionProcess) || |
238 command_line.HasSwitch(switches::kSingleProcess); | 239 command_line.HasSwitch(switches::kSingleProcess); |
239 | 240 |
240 if (is_extension_process_) { | 241 if (is_extension_process_) { |
241 RenderThread::Get()->SetIdleNotificationDelayInMs( | 242 RenderThread::Get()->SetIdleNotificationDelayInMs( |
242 kInitialExtensionIdleHandlerDelayMs); | 243 kInitialExtensionIdleHandlerDelayMs); |
243 } | 244 } |
244 | 245 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 const std::string& v8_extension_name, | 482 const std::string& v8_extension_name, |
482 int extension_group, | 483 int extension_group, |
483 int world_id) { | 484 int world_id) { |
484 g_hack_extension_group = extension_group; | 485 g_hack_extension_group = extension_group; |
485 return true; | 486 return true; |
486 } | 487 } |
487 | 488 |
488 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, | 489 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
489 ChromeV8Context* context) { | 490 ChromeV8Context* context) { |
490 module_system->RegisterNativeHandler("event_bindings", | 491 module_system->RegisterNativeHandler("event_bindings", |
491 scoped_ptr<NativeHandler>(EventBindings::Get(this))); | 492 scoped_ptr<NativeHandler>(EventBindings::Get(this, event_filter_.get()))); |
492 module_system->RegisterNativeHandler("miscellaneous_bindings", | 493 module_system->RegisterNativeHandler("miscellaneous_bindings", |
493 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); | 494 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); |
494 module_system->RegisterNativeHandler("apiDefinitions", | 495 module_system->RegisterNativeHandler("apiDefinitions", |
495 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); | 496 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); |
496 module_system->RegisterNativeHandler("sendRequest", | 497 module_system->RegisterNativeHandler("sendRequest", |
497 scoped_ptr<NativeHandler>( | 498 scoped_ptr<NativeHandler>( |
498 new SendRequestNatives(this, request_sender_.get()))); | 499 new SendRequestNatives(this, request_sender_.get()))); |
499 module_system->RegisterNativeHandler("setIcon", | 500 module_system->RegisterNativeHandler("setIcon", |
500 scoped_ptr<NativeHandler>( | 501 scoped_ptr<NativeHandler>( |
501 new SetIconNatives(this, request_sender_.get()))); | 502 new SetIconNatives(this, request_sender_.get()))); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 // APIs, they don't get extension bindings injected. If we end up here it | 1007 // APIs, they don't get extension bindings injected. If we end up here it |
1007 // means that a sandboxed page somehow managed to invoke an API anyway, so | 1008 // means that a sandboxed page somehow managed to invoke an API anyway, so |
1008 // we should abort. | 1009 // we should abort. |
1009 WebKit::WebFrame* frame = context->web_frame(); | 1010 WebKit::WebFrame* frame = context->web_frame(); |
1010 ExtensionURLInfo url_info(frame->document().securityOrigin(), | 1011 ExtensionURLInfo url_info(frame->document().securityOrigin(), |
1011 UserScriptSlave::GetDataSourceURLForFrame(frame)); | 1012 UserScriptSlave::GetDataSourceURLForFrame(frame)); |
1012 CHECK(!extensions_.IsSandboxedPage(url_info)); | 1013 CHECK(!extensions_.IsSandboxedPage(url_info)); |
1013 | 1014 |
1014 return true; | 1015 return true; |
1015 } | 1016 } |
OLD | NEW |