| 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" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 source_map->RegisterSource("webViewExperimental", | 255 source_map->RegisterSource("webViewExperimental", |
| 256 IDR_WEB_VIEW_EXPERIMENTAL_JS); | 256 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
| 257 source_map->RegisterSource("webViewRequest", | 257 source_map->RegisterSource("webViewRequest", |
| 258 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS); | 258 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS); |
| 259 source_map->RegisterSource("denyAppView", IDR_APP_VIEW_DENY_JS); | 259 source_map->RegisterSource("denyAppView", IDR_APP_VIEW_DENY_JS); |
| 260 source_map->RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); | 260 source_map->RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); |
| 261 source_map->RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 261 source_map->RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
| 262 } | 262 } |
| 263 | 263 |
| 264 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( | 264 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( |
| 265 extensions::ModuleSystem* module_system, | 265 extensions::ScriptContext* context, |
| 266 const extensions::Extension* extension, | |
| 267 extensions::Feature::Context context_type, | |
| 268 bool is_within_platform_app) { | 266 bool is_within_platform_app) { |
| 267 extensions::ModuleSystem* module_system = context->module_system(); |
| 268 extensions::Feature::Context context_type = context->context_type(); |
| 269 |
| 269 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is | 270 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is |
| 270 // expensive. It would be better if there were a light way of detecting when | 271 // expensive. It would be better if there were a light way of detecting when |
| 271 // a webview or appview is created and only then set up the infrastructure. | 272 // a webview or appview is created and only then set up the infrastructure. |
| 272 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | 273 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && |
| 273 is_within_platform_app && | 274 is_within_platform_app && |
| 274 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 275 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
| 275 CommandLine::ForCurrentProcess()->HasSwitch( | 276 CommandLine::ForCurrentProcess()->HasSwitch( |
| 276 ::switches::kEnableAppWindowControls)) { | 277 ::switches::kEnableAppWindowControls)) { |
| 277 module_system->Require("windowControls"); | 278 module_system->Require("windowControls"); |
| 278 } | 279 } |
| 279 | 280 |
| 281 const extensions::Extension* extension = context->extension(); |
| 282 |
| 280 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform | 283 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform |
| 281 // apps. An ext/app runs in a blessed extension context, if it is the active | 284 // apps. An ext/app runs in a blessed extension context, if it is the active |
| 282 // extension in the current process, in other words, if it is loaded in a top | 285 // extension in the current process, in other words, if it is loaded in a top |
| 283 // frame. To support webview in a non-frame extension, we have to allow | 286 // frame. To support webview in a non-frame extension, we have to allow |
| 284 // unblessed extension context as well. | 287 // unblessed extension context as well. |
| 285 // Note: setting up the WebView class here, not the chrome.webview API. | 288 // Note: setting up the WebView class here, not the chrome.webview API. |
| 286 // The API will be automatically set up when first used. | 289 // The API will be automatically set up when first used. |
| 287 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || | 290 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || |
| 288 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { | 291 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { |
| 289 if (extension->permissions_data()->HasAPIPermission( | 292 if (extension->permissions_data()->HasAPIPermission( |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 new extensions::PermissionSet(extensions::APIPermissionSet(), | 383 new extensions::PermissionSet(extensions::APIPermissionSet(), |
| 381 extensions::ManifestPermissionSet(), | 384 extensions::ManifestPermissionSet(), |
| 382 origin_set, | 385 origin_set, |
| 383 extensions::URLPatternSet())); | 386 extensions::URLPatternSet())); |
| 384 } | 387 } |
| 385 | 388 |
| 386 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 389 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
| 387 bool webrequest_used) { | 390 bool webrequest_used) { |
| 388 webrequest_used_ = webrequest_used; | 391 webrequest_used_ = webrequest_used; |
| 389 } | 392 } |
| OLD | NEW |