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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 | 282 |
283 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform | 283 // We used to limit WebView to |BLESSED_EXTENSION_CONTEXT| within platform |
284 // 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 |
285 // 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 |
286 // 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 |
287 // unblessed extension context as well. | 287 // unblessed extension context as well. |
288 // 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. |
289 // The API will be automatically set up when first used. | 289 // The API will be automatically set up when first used. |
290 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || | 290 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || |
291 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { | 291 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { |
292 // TODO(fsamuel): Use context->GetAvailability("webViewInternal"). | |
292 if (extension->permissions_data()->HasAPIPermission( | 293 if (extension->permissions_data()->HasAPIPermission( |
293 extensions::APIPermission::kWebView)) { | 294 extensions::APIPermission::kWebView)) { |
294 module_system->Require("webView"); | 295 module_system->Require("webView"); |
295 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { | 296 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { |
296 module_system->Require("webViewExperimental"); | 297 module_system->Require("webViewExperimental"); |
297 } else { | 298 } else { |
298 // TODO(asargent) We need a whitelist for webview experimental. | 299 // TODO(asargent) We need a whitelist for webview experimental. |
299 // crbug.com/264852 | 300 // crbug.com/264852 |
300 std::string id_hash = base::SHA1HashString(extension->id()); | 301 std::string id_hash = base::SHA1HashString(extension->id()); |
301 std::string hexencoded_id_hash = | 302 std::string hexencoded_id_hash = |
302 base::HexEncode(id_hash.c_str(), id_hash.length()); | 303 base::HexEncode(id_hash.c_str(), id_hash.length()); |
303 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || | 304 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || |
304 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || | 305 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || |
305 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || | 306 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || |
306 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") { | 307 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") { |
307 module_system->Require("webViewExperimental"); | 308 module_system->Require("webViewExperimental"); |
308 } | 309 } |
309 } | 310 } |
310 } else { | 311 } else { |
311 module_system->Require("denyWebView"); | 312 module_system->Require("denyWebView"); |
312 } | 313 } |
313 } | 314 } |
314 | 315 |
315 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 316 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
317 // Add TODO(fsamuel): Use context->GetAvailability("appViewInternal"). | |
Lei Zhang
2014/08/12 20:00:47
s/Add // ?
ericzeng
2014/08/12 22:07:17
Done.
| |
316 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && | 318 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && |
317 extension->permissions_data()->HasAPIPermission( | 319 extension->permissions_data()->HasAPIPermission( |
318 extensions::APIPermission::kAppView)) { | 320 extensions::APIPermission::kAppView)) { |
319 module_system->Require("appView"); | 321 module_system->Require("appView"); |
320 } else { | 322 } else { |
321 module_system->Require("denyAppView"); | 323 module_system->Require("denyAppView"); |
322 } | 324 } |
323 } | 325 } |
324 | 326 |
325 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && | 327 if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && |
326 extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && | 328 context->GetAvailability("extensionOptionsInternal").is_available()) { |
327 extension->permissions_data()->HasAPIPermission( | |
328 extensions::APIPermission::kEmbeddedExtensionOptions)) { | |
329 module_system->Require("extensionOptions"); | 329 module_system->Require("extensionOptions"); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
333 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( | 333 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( |
334 const std::set<std::string>& extension_ids) { | 334 const std::set<std::string>& extension_ids) { |
335 // In single-process mode, the browser process reports the active extensions. | 335 // In single-process mode, the browser process reports the active extensions. |
336 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) | 336 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) |
337 return; | 337 return; |
338 crash_keys::SetActiveExtensions(extension_ids); | 338 crash_keys::SetActiveExtensions(extension_ids); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 new extensions::PermissionSet(extensions::APIPermissionSet(), | 383 new extensions::PermissionSet(extensions::APIPermissionSet(), |
384 extensions::ManifestPermissionSet(), | 384 extensions::ManifestPermissionSet(), |
385 origin_set, | 385 origin_set, |
386 extensions::URLPatternSet())); | 386 extensions::URLPatternSet())); |
387 } | 387 } |
388 | 388 |
389 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( | 389 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( |
390 bool webrequest_used) { | 390 bool webrequest_used) { |
391 webrequest_used_ = webrequest_used; | 391 webrequest_used_ = webrequest_used; |
392 } | 392 } |
OLD | NEW |