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

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

Issue 378783002: Initial implementation of the <extensionoptions> GuestView tag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Devlin's comments, modify tests Created 6 years, 5 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 12 matching lines...) Expand all
23 #include "chrome/renderer/extensions/notifications_native_handler.h" 23 #include "chrome/renderer/extensions/notifications_native_handler.h"
24 #include "chrome/renderer/extensions/page_actions_custom_bindings.h" 24 #include "chrome/renderer/extensions/page_actions_custom_bindings.h"
25 #include "chrome/renderer/extensions/page_capture_custom_bindings.h" 25 #include "chrome/renderer/extensions/page_capture_custom_bindings.h"
26 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h" 26 #include "chrome/renderer/extensions/sync_file_system_custom_bindings.h"
27 #include "chrome/renderer/extensions/tab_finder.h" 27 #include "chrome/renderer/extensions/tab_finder.h"
28 #include "chrome/renderer/extensions/tabs_custom_bindings.h" 28 #include "chrome/renderer/extensions/tabs_custom_bindings.h"
29 #include "chrome/renderer/extensions/webstore_bindings.h" 29 #include "chrome/renderer/extensions/webstore_bindings.h"
30 #include "content/public/renderer/render_thread.h" 30 #include "content/public/renderer/render_thread.h"
31 #include "content/public/renderer/render_view.h" 31 #include "content/public/renderer/render_view.h"
32 #include "extensions/common/extension.h" 32 #include "extensions/common/extension.h"
33 #include "extensions/common/feature_switch.h"
33 #include "extensions/common/permissions/api_permission_set.h" 34 #include "extensions/common/permissions/api_permission_set.h"
34 #include "extensions/common/permissions/manifest_permission_set.h" 35 #include "extensions/common/permissions/manifest_permission_set.h"
35 #include "extensions/common/permissions/permission_set.h" 36 #include "extensions/common/permissions/permission_set.h"
36 #include "extensions/common/permissions/permissions_data.h" 37 #include "extensions/common/permissions/permissions_data.h"
38 #include "extensions/common/switches.h"
37 #include "extensions/common/url_pattern_set.h" 39 #include "extensions/common/url_pattern_set.h"
38 #include "extensions/renderer/dispatcher.h" 40 #include "extensions/renderer/dispatcher.h"
39 #include "extensions/renderer/native_handler.h" 41 #include "extensions/renderer/native_handler.h"
40 #include "extensions/renderer/resource_bundle_source_map.h" 42 #include "extensions/renderer/resource_bundle_source_map.h"
41 #include "extensions/renderer/script_context.h" 43 #include "extensions/renderer/script_context.h"
42 #include "grit/renderer_resources.h" 44 #include "grit/renderer_resources.h"
43 #include "third_party/WebKit/public/platform/WebString.h" 45 #include "third_party/WebKit/public/platform/WebString.h"
44 #include "third_party/WebKit/public/web/WebDocument.h" 46 #include "third_party/WebKit/public/web/WebDocument.h"
45 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 47 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
46 #include "third_party/WebKit/public/web/WebView.h" 48 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS); 233 source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS);
232 234
233 // Custom types sources. 235 // Custom types sources.
234 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); 236 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS);
235 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); 237 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS);
236 source_map->RegisterSource("ChromeDirectSetting", 238 source_map->RegisterSource("ChromeDirectSetting",
237 IDR_CHROME_DIRECT_SETTING_JS); 239 IDR_CHROME_DIRECT_SETTING_JS);
238 240
239 // Platform app sources that are not API-specific.. 241 // Platform app sources that are not API-specific..
240 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); 242 source_map->RegisterSource("appView", IDR_APP_VIEW_JS);
243 source_map->RegisterSource("extensionOptions", IDR_EXTENSION_OPTIONS_JS);
241 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); 244 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS);
242 source_map->RegisterSource("webViewInternal", 245 source_map->RegisterSource("webViewInternal",
243 IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); 246 IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS);
244 // Note: webView not webview so that this doesn't interfere with the 247 // Note: webView not webview so that this doesn't interfere with the
245 // chrome.webview API bindings. 248 // chrome.webview API bindings.
246 source_map->RegisterSource("webView", IDR_WEB_VIEW_JS); 249 source_map->RegisterSource("webView", IDR_WEB_VIEW_JS);
247 source_map->RegisterSource("webViewEvents", IDR_WEB_VIEW_EVENTS_JS); 250 source_map->RegisterSource("webViewEvents", IDR_WEB_VIEW_EVENTS_JS);
248 source_map->RegisterSource("webViewExperimental", 251 source_map->RegisterSource("webViewExperimental",
249 IDR_WEB_VIEW_EXPERIMENTAL_JS); 252 IDR_WEB_VIEW_EXPERIMENTAL_JS);
250 source_map->RegisterSource("webViewRequest", 253 source_map->RegisterSource("webViewRequest",
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 307
305 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { 308 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) {
306 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && 309 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) &&
307 extension->permissions_data()->HasAPIPermission( 310 extension->permissions_data()->HasAPIPermission(
308 extensions::APIPermission::kAppView)) { 311 extensions::APIPermission::kAppView)) {
309 module_system->Require("appView"); 312 module_system->Require("appView");
310 } else { 313 } else {
311 module_system->Require("denyAppView"); 314 module_system->Require("denyAppView");
312 } 315 }
313 } 316 }
317
318 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT ||
319 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) {
not at google - send to devlin 2014/07/15 21:08:55 why unblessed? It can't hurt, but I also don't rea
ericzeng 2014/07/16 01:52:01 Done.
320 if (extensions::FeatureSwitch::embedded_extension_options()->IsEnabled() &&
321 extension->permissions_data()->HasAPIPermission(
322 extensions::APIPermission::kEmbeddedExtensionOptions)) {
323 module_system->Require("extensionOptions");
324 }
325 }
314 } 326 }
315 327
316 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated( 328 void ChromeExtensionsDispatcherDelegate::OnActiveExtensionsUpdated(
317 const std::set<std::string>& extension_ids) { 329 const std::set<std::string>& extension_ids) {
318 // In single-process mode, the browser process reports the active extensions. 330 // In single-process mode, the browser process reports the active extensions.
319 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess)) 331 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kSingleProcess))
320 return; 332 return;
321 crash_keys::SetActiveExtensions(extension_ids); 333 crash_keys::SetActiveExtensions(extension_ids);
322 } 334 }
323 335
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 new extensions::PermissionSet(extensions::APIPermissionSet(), 378 new extensions::PermissionSet(extensions::APIPermissionSet(),
367 extensions::ManifestPermissionSet(), 379 extensions::ManifestPermissionSet(),
368 origin_set, 380 origin_set,
369 extensions::URLPatternSet())); 381 extensions::URLPatternSet()));
370 } 382 }
371 383
372 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage( 384 void ChromeExtensionsDispatcherDelegate::HandleWebRequestAPIUsage(
373 bool webrequest_used) { 385 bool webrequest_used) {
374 webrequest_used_ = webrequest_used; 386 webrequest_used_ = webrequest_used;
375 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698