Chromium Code Reviews| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | 267 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && |
| 268 is_within_platform_app && | 268 is_within_platform_app && |
| 269 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && | 269 extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV && |
| 270 CommandLine::ForCurrentProcess()->HasSwitch( | 270 CommandLine::ForCurrentProcess()->HasSwitch( |
| 271 ::switches::kEnableAppWindowControls)) { | 271 ::switches::kEnableAppWindowControls)) { |
| 272 module_system->Require("windowControls"); | 272 module_system->Require("windowControls"); |
| 273 } | 273 } |
| 274 | 274 |
| 275 const extensions::Extension* extension = context->extension(); | 275 const extensions::Extension* extension = context->extension(); |
| 276 | 276 |
| 277 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform | |
| 278 // apps. An ext/app runs in a blessed extension context, if it is the active | |
| 279 // extension in the current process, in other words, if it is loaded in a top | |
| 280 // frame. To support webview in a non-frame extension, we have to allow | |
| 281 // unblessed extension context as well. | |
| 282 // Note: setting up the WebView class here, not the chrome.webview API. | 277 // Note: setting up the WebView class here, not the chrome.webview API. |
| 283 // The API will be automatically set up when first used. | 278 // The API will be automatically set up when first used. |
| 284 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || | 279 if (context->GetAvailability("webViewInternal").is_available()) { |
| 285 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { | 280 module_system->Require("webView"); |
| 286 // TODO(fsamuel): Use context->GetAvailability("webViewInternal"). | 281 // TODO(asargent) We need a whitelist for webview experimental. |
| 287 if (extension->permissions_data()->HasAPIPermission( | 282 // crbug.com/264852 |
| 288 extensions::APIPermission::kWebView)) { | 283 std::string id_hash = base::SHA1HashString(extension->id()); |
| 289 module_system->Require("webView"); | 284 std::string hexencoded_id_hash = |
| 290 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { | 285 base::HexEncode(id_hash.c_str(), id_hash.length()); |
| 291 module_system->Require("webViewExperimental"); | 286 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV || |
|
not at google - send to devlin
2014/08/26 22:23:26
You could clean this up by adding a vacuous webVie
Fady Samuel
2014/08/26 23:30:35
Done.
| |
| 292 } else { | 287 hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || |
| 293 // TODO(asargent) We need a whitelist for webview experimental. | 288 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || |
| 294 // crbug.com/264852 | 289 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || |
| 295 std::string id_hash = base::SHA1HashString(extension->id()); | 290 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") { |
| 296 std::string hexencoded_id_hash = | 291 module_system->Require("webViewExperimental"); |
| 297 base::HexEncode(id_hash.c_str(), id_hash.length()); | |
| 298 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || | |
| 299 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || | |
| 300 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || | |
| 301 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") { | |
| 302 module_system->Require("webViewExperimental"); | |
| 303 } | |
| 304 } | |
| 305 } else { | |
| 306 module_system->Require("denyWebView"); | |
| 307 } | 292 } |
| 293 } else { | |
|
not at google - send to devlin
2014/08/26 22:23:26
I think you should have else-if BLESSED or UNBLESS
Fady Samuel
2014/08/26 23:30:35
Done.
| |
| 294 module_system->Require("denyWebView"); | |
| 308 } | 295 } |
| 309 | 296 |
| 310 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 297 if (extensions::FeatureSwitch::app_view()->IsEnabled() && |
| 311 // TODO(fsamuel): Use context->GetAvailability("appViewInternal"). | 298 context->GetAvailability("appViewEmbedderInternal").is_available()) { |
| 312 if (CommandLine::ForCurrentProcess()->HasSwitch( | 299 module_system->Require("appView"); |
| 313 extensions::switches::kEnableAppView) && | 300 } else { |
|
not at google - send to devlin
2014/08/26 22:23:26
ditto (though just BLESSED in this case).
Fady Samuel
2014/08/26 23:30:35
Done.
| |
| 314 extension->permissions_data()->HasAPIPermission( | 301 module_system->Require("denyAppView"); |
| 315 extensions::APIPermission::kAppView)) { | |
| 316 module_system->Require("appView"); | |
| 317 } else { | |
| 318 module_system->Require("denyAppView"); | |
| 319 } | |
| 320 } | 302 } |
| 321 | 303 |
| 322 if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && | 304 if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && |
| 323 context->GetAvailability("extensionOptionsInternal").is_available()) { | 305 context->GetAvailability("extensionOptionsInternal").is_available()) { |
| 324 module_system->Require("extensionOptions"); | 306 module_system->Require("extensionOptions"); |
| 325 } | 307 } |
| 326 } | 308 } |
| 327 | 309 |
| 328 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( | 310 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( |
| 329 const std::set<std::string>& extension_ids) { | 311 const std::set<std::string>& extension_ids) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 new extensions::PermissionSet(extensions::APIPermissionSet(), | 360 new extensions::PermissionSet(extensions::APIPermissionSet(), |
| 379 extensions::ManifestPermissionSet(), | 361 extensions::ManifestPermissionSet(), |
| 380 origin_set, | 362 origin_set, |
| 381 extensions::URLPatternSet())); | 363 extensions::URLPatternSet())); |
| 382 } | 364 } |
| 383 | 365 |
| 384 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 366 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
| 385 bool webrequest_used) { | 367 bool webrequest_used) { |
| 386 webrequest_used_ = webrequest_used; | 368 webrequest_used_ = webrequest_used; |
| 387 } | 369 } |
| OLD | NEW |