| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 254 |
| 255 // Custom types sources. | 255 // Custom types sources. |
| 256 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); | 256 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); |
| 257 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); | 257 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); |
| 258 source_map->RegisterSource("ChromeDirectSetting", | 258 source_map->RegisterSource("ChromeDirectSetting", |
| 259 IDR_CHROME_DIRECT_SETTING_JS); | 259 IDR_CHROME_DIRECT_SETTING_JS); |
| 260 | 260 |
| 261 // Platform app sources that are not API-specific.. | 261 // Platform app sources that are not API-specific.. |
| 262 source_map->RegisterSource("fileEntryBindingUtil", | 262 source_map->RegisterSource("fileEntryBindingUtil", |
| 263 IDR_FILE_ENTRY_BINDING_UTIL_JS); | 263 IDR_FILE_ENTRY_BINDING_UTIL_JS); |
| 264 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | |
| 265 source_map->RegisterSource("chromeWebViewInternal", | 264 source_map->RegisterSource("chromeWebViewInternal", |
| 266 IDR_CHROME_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); | 265 IDR_CHROME_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); |
| 267 source_map->RegisterSource("chromeWebView", IDR_CHROME_WEB_VIEW_JS); | 266 source_map->RegisterSource("chromeWebView", IDR_CHROME_WEB_VIEW_JS); |
| 268 } | 267 } |
| 269 | 268 |
| 270 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( | 269 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( |
| 271 extensions::ScriptContext* context, | 270 extensions::ScriptContext* context) { |
| 272 bool is_within_platform_app) { | |
| 273 extensions::ModuleSystem* module_system = context->module_system(); | |
| 274 extensions::Feature::Context context_type = context->context_type(); | |
| 275 | |
| 276 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is | |
| 277 // expensive. It would be better if there were a light way of detecting when | |
| 278 // a webview or appview is created and only then set up the infrastructure. | |
| 279 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | |
| 280 is_within_platform_app && | |
| 281 extensions::GetCurrentChannel() <= version_info::Channel::DEV && | |
| 282 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 283 extensions::switches::kEnableAppWindowControls)) { | |
| 284 module_system->Require("windowControls"); | |
| 285 } | |
| 286 | |
| 287 // Note: setting up the WebView class here, not the chrome.webview API. | 271 // Note: setting up the WebView class here, not the chrome.webview API. |
| 288 // The API will be automatically set up when first used. | 272 // The API will be automatically set up when first used. |
| 289 if (context->GetAvailability("webViewInternal").is_available()) { | 273 if (context->GetAvailability("webViewInternal").is_available()) { |
| 290 module_system->Require("chromeWebView"); | 274 // TODO(fsamuel): Eagerly calling Require on context startup is expensive. |
| 275 // It would be better if there were a light way of detecting when a webview |
| 276 // or appview is created and only then set up the infrastructure. |
| 277 context->module_system()->Require("chromeWebView"); |
| 291 } | 278 } |
| 292 } | 279 } |
| 293 | 280 |
| 294 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( | 281 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( |
| 295 const std::set<std::string>& extension_ids) { | 282 const std::set<std::string>& extension_ids) { |
| 296 // In single-process mode, the browser process reports the active extensions. | 283 // In single-process mode, the browser process reports the active extensions. |
| 297 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 284 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 298 ::switches::kSingleProcess)) | 285 ::switches::kSingleProcess)) |
| 299 return; | 286 return; |
| 300 crash_keys::SetActiveExtensions(extension_ids); | 287 crash_keys::SetActiveExtensions(extension_ids); |
| 301 } | 288 } |
| OLD | NEW |