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