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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 } | 232 } |
233 | 233 |
234 ExtensionDispatcher::ExtensionDispatcher() | 234 ExtensionDispatcher::ExtensionDispatcher() |
235 : is_webkit_initialized_(false), | 235 : is_webkit_initialized_(false), |
236 webrequest_adblock_(false), | 236 webrequest_adblock_(false), |
237 webrequest_adblock_plus_(false), | 237 webrequest_adblock_plus_(false), |
238 webrequest_other_(false), | 238 webrequest_other_(false), |
239 source_map_(&ResourceBundle::GetSharedInstance()), | 239 source_map_(&ResourceBundle::GetSharedInstance()), |
240 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), | 240 chrome_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) { |
241 event_filter_(new extensions::EventFilter) { | |
242 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); | 241 const CommandLine& command_line = *(CommandLine::ForCurrentProcess()); |
243 is_extension_process_ = | 242 is_extension_process_ = |
244 command_line.HasSwitch(switches::kExtensionProcess) || | 243 command_line.HasSwitch(switches::kExtensionProcess) || |
245 command_line.HasSwitch(switches::kSingleProcess); | 244 command_line.HasSwitch(switches::kSingleProcess); |
246 | 245 |
247 if (is_extension_process_) { | 246 if (is_extension_process_) { |
248 RenderThread::Get()->SetIdleNotificationDelayInMs( | 247 RenderThread::Get()->SetIdleNotificationDelayInMs( |
249 kInitialExtensionIdleHandlerDelayMs); | 248 kInitialExtensionIdleHandlerDelayMs); |
250 } | 249 } |
251 | 250 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 const std::string& v8_extension_name, | 487 const std::string& v8_extension_name, |
489 int extension_group, | 488 int extension_group, |
490 int world_id) { | 489 int world_id) { |
491 g_hack_extension_group = extension_group; | 490 g_hack_extension_group = extension_group; |
492 return true; | 491 return true; |
493 } | 492 } |
494 | 493 |
495 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, | 494 void ExtensionDispatcher::RegisterNativeHandlers(ModuleSystem* module_system, |
496 ChromeV8Context* context) { | 495 ChromeV8Context* context) { |
497 module_system->RegisterNativeHandler("event_bindings", | 496 module_system->RegisterNativeHandler("event_bindings", |
498 scoped_ptr<NativeHandler>(EventBindings::Get(this, event_filter_.get()))); | 497 scoped_ptr<NativeHandler>(EventBindings::Get(this))); |
499 module_system->RegisterNativeHandler("miscellaneous_bindings", | 498 module_system->RegisterNativeHandler("miscellaneous_bindings", |
500 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); | 499 scoped_ptr<NativeHandler>(MiscellaneousBindings::Get(this))); |
501 module_system->RegisterNativeHandler("apiDefinitions", | 500 module_system->RegisterNativeHandler("apiDefinitions", |
502 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); | 501 scoped_ptr<NativeHandler>(new ApiDefinitionsNatives(this))); |
503 module_system->RegisterNativeHandler("sendRequest", | 502 module_system->RegisterNativeHandler("sendRequest", |
504 scoped_ptr<NativeHandler>( | 503 scoped_ptr<NativeHandler>( |
505 new SendRequestNatives(this, request_sender_.get()))); | 504 new SendRequestNatives(this, request_sender_.get()))); |
506 module_system->RegisterNativeHandler("setIcon", | 505 module_system->RegisterNativeHandler("setIcon", |
507 scoped_ptr<NativeHandler>( | 506 scoped_ptr<NativeHandler>( |
508 new SetIconNatives(this, request_sender_.get()))); | 507 new SetIconNatives(this, request_sender_.get()))); |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1031 // APIs, they don't get extension bindings injected. If we end up here it | 1030 // APIs, they don't get extension bindings injected. If we end up here it |
1032 // means that a sandboxed page somehow managed to invoke an API anyway, so | 1031 // means that a sandboxed page somehow managed to invoke an API anyway, so |
1033 // we should abort. | 1032 // we should abort. |
1034 WebKit::WebFrame* frame = context->web_frame(); | 1033 WebKit::WebFrame* frame = context->web_frame(); |
1035 ExtensionURLInfo url_info(frame->document().securityOrigin(), | 1034 ExtensionURLInfo url_info(frame->document().securityOrigin(), |
1036 UserScriptSlave::GetDataSourceURLForFrame(frame)); | 1035 UserScriptSlave::GetDataSourceURLForFrame(frame)); |
1037 CHECK(!extensions_.IsSandboxedPage(url_info)); | 1036 CHECK(!extensions_.IsSandboxedPage(url_info)); |
1038 | 1037 |
1039 return true; | 1038 return true; |
1040 } | 1039 } |
OLD | NEW |