| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome_extensions_dispatcher_delegate.h" | 5 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/chrome_version_info.h" | 11 #include "chrome/common/chrome_version_info.h" |
| 12 #include "chrome/common/crash_keys.h" | 12 #include "chrome/common/crash_keys.h" |
| 13 #include "chrome/common/extensions/features/feature_channel.h" | 13 #include "chrome/common/extensions/features/feature_channel.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "chrome/grit/renderer_resources.h" | 15 #include "chrome/grit/renderer_resources.h" |
| 16 #include "chrome/renderer/extensions/app_bindings.h" | 16 #include "chrome/renderer/extensions/app_bindings.h" |
| 17 #include "chrome/renderer/extensions/app_window_custom_bindings.h" | |
| 18 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" | 17 #include "chrome/renderer/extensions/automation_internal_custom_bindings.h" |
| 19 #include "chrome/renderer/extensions/chrome_v8_context.h" | 18 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| 20 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h" | 19 #include "chrome/renderer/extensions/enterprise_platform_keys_natives.h" |
| 21 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h" | 20 #include "chrome/renderer/extensions/file_browser_handler_custom_bindings.h" |
| 22 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h" | 21 #include "chrome/renderer/extensions/file_browser_private_custom_bindings.h" |
| 23 #include "chrome/renderer/extensions/media_galleries_custom_bindings.h" | 22 #include "chrome/renderer/extensions/media_galleries_custom_bindings.h" |
| 24 #include "chrome/renderer/extensions/notifications_native_handler.h" | 23 #include "chrome/renderer/extensions/notifications_native_handler.h" |
| 25 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" | 24 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" |
| 26 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" | 25 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" |
| 27 #include "chrome/renderer/extensions/tab_finder.h" | 26 #include "chrome/renderer/extensions/tab_finder.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 extensions::ModuleSystem* module_system, | 90 extensions::ModuleSystem* module_system, |
| 92 extensions::ScriptContext* context) { | 91 extensions::ScriptContext* context) { |
| 93 #if !defined(ENABLE_EXTENSIONS) | 92 #if !defined(ENABLE_EXTENSIONS) |
| 94 return; | 93 return; |
| 95 #endif | 94 #endif |
| 96 module_system->RegisterNativeHandler( | 95 module_system->RegisterNativeHandler( |
| 97 "app", | 96 "app", |
| 98 scoped_ptr<NativeHandler>( | 97 scoped_ptr<NativeHandler>( |
| 99 new extensions::AppBindings(dispatcher, context))); | 98 new extensions::AppBindings(dispatcher, context))); |
| 100 module_system->RegisterNativeHandler( | 99 module_system->RegisterNativeHandler( |
| 101 "app_window_natives", | |
| 102 scoped_ptr<NativeHandler>( | |
| 103 new extensions::AppWindowCustomBindings(dispatcher, context))); | |
| 104 module_system->RegisterNativeHandler( | |
| 105 "sync_file_system", | 100 "sync_file_system", |
| 106 scoped_ptr<NativeHandler>( | 101 scoped_ptr<NativeHandler>( |
| 107 new extensions::SyncFileSystemCustomBindings(context))); | 102 new extensions::SyncFileSystemCustomBindings(context))); |
| 108 module_system->RegisterNativeHandler( | 103 module_system->RegisterNativeHandler( |
| 109 "enterprise_platform_keys_natives", | 104 "enterprise_platform_keys_natives", |
| 110 scoped_ptr<NativeHandler>( | 105 scoped_ptr<NativeHandler>( |
| 111 new extensions::EnterprisePlatformKeysNatives(context))); | 106 new extensions::EnterprisePlatformKeysNatives(context))); |
| 112 module_system->RegisterNativeHandler( | 107 module_system->RegisterNativeHandler( |
| 113 "file_browser_handler", | 108 "file_browser_handler", |
| 114 scoped_ptr<NativeHandler>( | 109 scoped_ptr<NativeHandler>( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 144 module_system->RegisterNativeHandler( | 139 module_system->RegisterNativeHandler( |
| 145 "automationInternal", | 140 "automationInternal", |
| 146 scoped_ptr<NativeHandler>( | 141 scoped_ptr<NativeHandler>( |
| 147 new extensions::AutomationInternalCustomBindings(context))); | 142 new extensions::AutomationInternalCustomBindings(context))); |
| 148 } | 143 } |
| 149 | 144 |
| 150 void ChromeExtensionsDispatcherDelegate::PopulateSourceMap( | 145 void ChromeExtensionsDispatcherDelegate::PopulateSourceMap( |
| 151 extensions::ResourceBundleSourceMap* source_map) { | 146 extensions::ResourceBundleSourceMap* source_map) { |
| 152 // Custom bindings. | 147 // Custom bindings. |
| 153 source_map->RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS); | 148 source_map->RegisterSource("app", IDR_APP_CUSTOM_BINDINGS_JS); |
| 154 source_map->RegisterSource("app.window", IDR_APP_WINDOW_CUSTOM_BINDINGS_JS); | |
| 155 source_map->RegisterSource("automation", IDR_AUTOMATION_CUSTOM_BINDINGS_JS); | 149 source_map->RegisterSource("automation", IDR_AUTOMATION_CUSTOM_BINDINGS_JS); |
| 156 source_map->RegisterSource("automationEvent", IDR_AUTOMATION_EVENT_JS); | 150 source_map->RegisterSource("automationEvent", IDR_AUTOMATION_EVENT_JS); |
| 157 source_map->RegisterSource("automationNode", IDR_AUTOMATION_NODE_JS); | 151 source_map->RegisterSource("automationNode", IDR_AUTOMATION_NODE_JS); |
| 158 source_map->RegisterSource("browserAction", | 152 source_map->RegisterSource("browserAction", |
| 159 IDR_BROWSER_ACTION_CUSTOM_BINDINGS_JS); | 153 IDR_BROWSER_ACTION_CUSTOM_BINDINGS_JS); |
| 160 source_map->RegisterSource("declarativeContent", | 154 source_map->RegisterSource("declarativeContent", |
| 161 IDR_DECLARATIVE_CONTENT_CUSTOM_BINDINGS_JS); | 155 IDR_DECLARATIVE_CONTENT_CUSTOM_BINDINGS_JS); |
| 162 source_map->RegisterSource("declarativeWebRequest", | 156 source_map->RegisterSource("declarativeWebRequest", |
| 163 IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS); | 157 IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS); |
| 164 source_map->RegisterSource("desktopCapture", | 158 source_map->RegisterSource("desktopCapture", |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 #if defined(ENABLE_WEBRTC) | 211 #if defined(ENABLE_WEBRTC) |
| 218 source_map->RegisterSource("cast.streaming.rtpStream", | 212 source_map->RegisterSource("cast.streaming.rtpStream", |
| 219 IDR_CAST_STREAMING_RTP_STREAM_CUSTOM_BINDINGS_JS); | 213 IDR_CAST_STREAMING_RTP_STREAM_CUSTOM_BINDINGS_JS); |
| 220 source_map->RegisterSource("cast.streaming.session", | 214 source_map->RegisterSource("cast.streaming.session", |
| 221 IDR_CAST_STREAMING_SESSION_CUSTOM_BINDINGS_JS); | 215 IDR_CAST_STREAMING_SESSION_CUSTOM_BINDINGS_JS); |
| 222 source_map->RegisterSource( | 216 source_map->RegisterSource( |
| 223 "cast.streaming.udpTransport", | 217 "cast.streaming.udpTransport", |
| 224 IDR_CAST_STREAMING_UDP_TRANSPORT_CUSTOM_BINDINGS_JS); | 218 IDR_CAST_STREAMING_UDP_TRANSPORT_CUSTOM_BINDINGS_JS); |
| 225 #endif | 219 #endif |
| 226 source_map->RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); | 220 source_map->RegisterSource("webstore", IDR_WEBSTORE_CUSTOM_BINDINGS_JS); |
| 227 source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS); | |
| 228 | 221 |
| 229 // Custom types sources. | 222 // Custom types sources. |
| 230 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); | 223 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); |
| 231 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); | 224 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); |
| 232 source_map->RegisterSource("ChromeDirectSetting", | 225 source_map->RegisterSource("ChromeDirectSetting", |
| 233 IDR_CHROME_DIRECT_SETTING_JS); | 226 IDR_CHROME_DIRECT_SETTING_JS); |
| 234 | 227 |
| 235 // Platform app sources that are not API-specific.. | 228 // Platform app sources that are not API-specific.. |
| 236 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); | 229 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); |
| 237 source_map->RegisterSource("fileEntryBindingUtil", | 230 source_map->RegisterSource("fileEntryBindingUtil", |
| (...skipping 23 matching lines...) Expand all Loading... |
| 261 extensions::ModuleSystem* module_system = context->module_system(); | 254 extensions::ModuleSystem* module_system = context->module_system(); |
| 262 extensions::Feature::Context context_type = context->context_type(); | 255 extensions::Feature::Context context_type = context->context_type(); |
| 263 | 256 |
| 264 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is | 257 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is |
| 265 // expensive. It would be better if there were a light way of detecting when | 258 // expensive. It would be better if there were a light way of detecting when |
| 266 // a webview or appview is created and only then set up the infrastructure. | 259 // a webview or appview is created and only then set up the infrastructure. |
| 267 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | 260 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && |
| 268 is_within_platform_app && | 261 is_within_platform_app && |
| 269 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 262 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
| 270 CommandLine::ForCurrentProcess()->HasSwitch( | 263 CommandLine::ForCurrentProcess()->HasSwitch( |
| 271 ::switches::kEnableAppWindowControls)) { | 264 extensions::switches::kEnableAppWindowControls)) { |
| 272 module_system->Require("windowControls"); | 265 module_system->Require("windowControls"); |
| 273 } | 266 } |
| 274 | 267 |
| 275 // Note: setting up the WebView class here, not the chrome.webview API. | 268 // Note: setting up the WebView class here, not the chrome.webview API. |
| 276 // The API will be automatically set up when first used. | 269 // The API will be automatically set up when first used. |
| 277 if (context->GetAvailability("webViewInternal").is_available()) { | 270 if (context->GetAvailability("webViewInternal").is_available()) { |
| 278 module_system->Require("webView"); | 271 module_system->Require("webView"); |
| 279 if (context->GetAvailability("webViewExperimentalInternal").is_available()) | 272 if (context->GetAvailability("webViewExperimentalInternal").is_available()) |
| 280 module_system->Require("webViewExperimental"); | 273 module_system->Require("webViewExperimental"); |
| 281 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 274 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 new extensions::PermissionSet(extensions::APIPermissionSet(), | 341 new extensions::PermissionSet(extensions::APIPermissionSet(), |
| 349 extensions::ManifestPermissionSet(), | 342 extensions::ManifestPermissionSet(), |
| 350 origin_set, | 343 origin_set, |
| 351 extensions::URLPatternSet())); | 344 extensions::URLPatternSet())); |
| 352 } | 345 } |
| 353 | 346 |
| 354 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 347 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
| 355 bool webrequest_used) { | 348 bool webrequest_used) { |
| 356 webrequest_used_ = webrequest_used; | 349 webrequest_used_ = webrequest_used; |
| 357 } | 350 } |
| OLD | NEW |