Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc

Issue 453613002: Implement support for <extensionoptions> embedding in WebUI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (again) Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 if (extension->permissions_data()->HasAPIPermission( 292 if (extension->permissions_data()->HasAPIPermission(
not at google - send to devlin 2014/08/12 00:08:23 Add TODO(fsamuel): Use context->GetAvailability("w
ericzeng 2014/08/12 00:32:27 Done.
293 extensions::APIPermission::kWebView)) { 293 extensions::APIPermission::kWebView)) {
294 module_system->Require("webView"); 294 module_system->Require("webView");
295 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) { 295 if (extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV) {
296 module_system->Require("webViewExperimental"); 296 module_system->Require("webViewExperimental");
297 } else { 297 } else {
298 // TODO(asargent) We need a whitelist for webview experimental. 298 // TODO(asargent) We need a whitelist for webview experimental.
299 // crbug.com/264852 299 // crbug.com/264852
300 std::string id_hash = base::SHA1HashString(extension->id()); 300 std::string id_hash = base::SHA1HashString(extension->id());
301 std::string hexencoded_id_hash = 301 std::string hexencoded_id_hash =
302 base::HexEncode(id_hash.c_str(), id_hash.length()); 302 base::HexEncode(id_hash.c_str(), id_hash.length());
303 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" || 303 if (hexencoded_id_hash == "8C3741E3AF0B93B6E8E0DDD499BB0B74839EA578" ||
304 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" || 304 hexencoded_id_hash == "E703483CEF33DEC18B4B6DD84B5C776FB9182BDB" ||
305 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" || 305 hexencoded_id_hash == "1A26E32DE447A17CBE5E9750CDBA78F58539B39C" ||
306 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") { 306 hexencoded_id_hash == "59048028102D7B4C681DBC7BC6CD980C3DC66DA3") {
307 module_system->Require("webViewExperimental"); 307 module_system->Require("webViewExperimental");
308 } 308 }
309 } 309 }
310 } else { 310 } else {
311 module_system->Require("denyWebView"); 311 module_system->Require("denyWebView");
312 } 312 }
313 } 313 }
314 314
315 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { 315 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) {
316 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && 316 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) &&
not at google - send to devlin 2014/08/12 00:08:24 Add TODO(fsamuel): Use context->GetAvailability("a
ericzeng 2014/08/12 00:32:27 Done.
317 extension->permissions_data()->HasAPIPermission( 317 extension->permissions_data()->HasAPIPermission(
318 extensions::APIPermission::kAppView)) { 318 extensions::APIPermission::kAppView)) {
319 module_system->Require("appView"); 319 module_system->Require("appView");
320 } else { 320 } else {
321 module_system->Require("denyAppView"); 321 module_system->Require("denyAppView");
322 } 322 }
323 } 323 }
324 324
325 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT && 325 if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() &&
326 extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() && 326 context->GetAvailability("extensionOptionsInternal").is_available()) {
327 extension->permissions_data()->HasAPIPermission(
328 extensions::APIPermission::kEmbeddedExtensionOptions)) {
329 module_system->Require("extensionOptions"); 327 module_system->Require("extensionOptions");
330 } 328 }
331 } 329 }
332 330
333 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( 331 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated(
334 const std::set<std::string>& extension_ids) { 332 const std::set<std::string>& extension_ids) {
335 // In single-process mode, the browser process reports the active extensions. 333 // In single-process mode, the browser process reports the active extensions.
336 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) 334 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess))
337 return; 335 return;
338 crash_keys::SetActiveExtensions(extension_ids); 336 crash_keys::SetActiveExtensions(extension_ids);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 new extensions::PermissionSet(extensions::APIPermissionSet(), 381 new extensions::PermissionSet(extensions::APIPermissionSet(),
384 extensions::ManifestPermissionSet(), 382 extensions::ManifestPermissionSet(),
385 origin_set, 383 origin_set,
386 extensions::URLPatternSet())); 384 extensions::URLPatternSet()));
387 } 385 }
388 386
389 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( 387 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage(
390 bool webrequest_used) { 388 bool webrequest_used) {
391 webrequest_used_ = webrequest_used; 389 webrequest_used_ = webrequest_used;
392 } 390 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698