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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 // Platform app sources that are not API-specific.. | 235 // Platform app sources that are not API-specific.. |
236 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); | 236 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); |
237 source_map->RegisterSource("fileEntryBindingUtil", | 237 source_map->RegisterSource("fileEntryBindingUtil", |
238 IDR_FILE_ENTRY_BINDING_UTIL_JS); | 238 IDR_FILE_ENTRY_BINDING_UTIL_JS); |
239 source_map->RegisterSource("extensionOptions", IDR_EXTENSION_OPTIONS_JS); | 239 source_map->RegisterSource("extensionOptions", IDR_EXTENSION_OPTIONS_JS); |
240 source_map->RegisterSource("extensionOptionsEvents", | 240 source_map->RegisterSource("extensionOptionsEvents", |
241 IDR_EXTENSION_OPTIONS_EVENTS_JS); | 241 IDR_EXTENSION_OPTIONS_EVENTS_JS); |
242 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 242 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
243 source_map->RegisterSource("chromeWebViewInternal", | 243 source_map->RegisterSource("chromeWebViewInternal", |
244 IDR_CHROME_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); | 244 IDR_CHROME_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); |
245 // Note: webView not webview so that this doesn't interfere with the | 245 source_map->RegisterSource("chromeWebView", IDR_CHROME_WEB_VIEW_JS); |
246 // chrome.webview API bindings. | 246 source_map->RegisterSource("chromeWebViewExperimental", |
247 source_map->RegisterSource("webView", IDR_WEB_VIEW_JS); | 247 IDR_CHROME_WEB_VIEW_EXPERIMENTAL_JS); |
248 source_map->RegisterSource("webViewEvents", IDR_WEB_VIEW_EVENTS_JS); | |
249 source_map->RegisterSource("webViewExperimental", | |
250 IDR_WEB_VIEW_EXPERIMENTAL_JS); | |
251 source_map->RegisterSource("webViewRequest", | 248 source_map->RegisterSource("webViewRequest", |
252 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS); | 249 IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS); |
253 source_map->RegisterSource("denyAppView", IDR_APP_VIEW_DENY_JS); | 250 source_map->RegisterSource("denyAppView", IDR_APP_VIEW_DENY_JS); |
254 source_map->RegisterSource("denyWebView", IDR_WEB_VIEW_DENY_JS); | |
255 source_map->RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); | 251 source_map->RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS); |
256 } | 252 } |
257 | 253 |
258 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( | 254 void ChromeExtensionsDispatcherDelegate::RequireAdditionalModules( |
259 extensions::ScriptContext* context, | 255 extensions::ScriptContext* context, |
260 bool is_within_platform_app) { | 256 bool is_within_platform_app) { |
261 extensions::ModuleSystem* module_system = context->module_system(); | 257 extensions::ModuleSystem* module_system = context->module_system(); |
262 extensions::Feature::Context context_type = context->context_type(); | 258 extensions::Feature::Context context_type = context->context_type(); |
263 | 259 |
264 // TODO(kalman, fsamuel): Eagerly calling Require on context startup is | 260 // 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 | 261 // 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. | 262 // a webview or appview is created and only then set up the infrastructure. |
267 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | 263 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && |
268 is_within_platform_app && | 264 is_within_platform_app && |
269 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 265 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
270 CommandLine::ForCurrentProcess()->HasSwitch( | 266 CommandLine::ForCurrentProcess()->HasSwitch( |
271 extensions::switches::kEnableAppWindowControls)) { | 267 extensions::switches::kEnableAppWindowControls)) { |
272 module_system->Require("windowControls"); | 268 module_system->Require("windowControls"); |
273 } | 269 } |
274 | 270 |
275 // 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. |
276 // The API will be automatically set up when first used. | 272 // The API will be automatically set up when first used. |
277 if (context->GetAvailability("webViewInternal").is_available()) { | 273 if (context->GetAvailability("webViewInternal").is_available()) { |
Fady Samuel
2014/09/11 19:24:03
This check should be done in extensions as well.
lfg
2014/09/11 19:27:59
I'll do it in a future patch. This patch only move
Fady Samuel
2014/09/11 19:31:39
I'm surprised/confused that webview works at all t
| |
278 module_system->Require("webView"); | 274 module_system->Require("chromeWebView"); |
279 if (context->GetAvailability("webViewExperimentalInternal").is_available()) | 275 if (context->GetAvailability("webViewExperimentalInternal") |
280 module_system->Require("webViewExperimental"); | 276 .is_available()) { |
277 module_system->Require("chromeWebViewExperimental"); | |
278 } | |
281 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 279 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
282 module_system->Require("denyWebView"); | 280 module_system->Require("denyWebView"); |
283 } | 281 } |
284 | 282 |
285 if (extensions::FeatureSwitch::app_view()->IsEnabled() && | 283 if (extensions::FeatureSwitch::app_view()->IsEnabled() && |
286 context->GetAvailability("appViewEmbedderInternal").is_available()) { | 284 context->GetAvailability("appViewEmbedderInternal").is_available()) { |
287 module_system->Require("appView"); | 285 module_system->Require("appView"); |
288 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 286 } else if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
289 module_system->Require("denyAppView"); | 287 module_system->Require("denyAppView"); |
290 } | 288 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 new extensions::PermissionSet(extensions::APIPermissionSet(), | 346 new extensions::PermissionSet(extensions::APIPermissionSet(), |
349 extensions::ManifestPermissionSet(), | 347 extensions::ManifestPermissionSet(), |
350 origin_set, | 348 origin_set, |
351 extensions::URLPatternSet())); | 349 extensions::URLPatternSet())); |
352 } | 350 } |
353 | 351 |
354 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 352 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
355 bool webrequest_used) { | 353 bool webrequest_used) { |
356 webrequest_used_ = webrequest_used; | 354 webrequest_used_ = webrequest_used; |
357 } | 355 } |
OLD | NEW |