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 16 matching lines...) Expand all Loading... | |
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/permissions/api_permission_set.h" | 33 #include "extensions/common/permissions/api_permission_set.h" |
34 #include "extensions/common/permissions/manifest_permission_set.h" | 34 #include "extensions/common/permissions/manifest_permission_set.h" |
35 #include "extensions/common/permissions/permission_set.h" | 35 #include "extensions/common/permissions/permission_set.h" |
36 #include "extensions/common/permissions/permissions_data.h" | 36 #include "extensions/common/permissions/permissions_data.h" |
37 #include "extensions/common/switches.h" | |
37 #include "extensions/common/url_pattern_set.h" | 38 #include "extensions/common/url_pattern_set.h" |
38 #include "extensions/renderer/dispatcher.h" | 39 #include "extensions/renderer/dispatcher.h" |
39 #include "extensions/renderer/native_handler.h" | 40 #include "extensions/renderer/native_handler.h" |
40 #include "extensions/renderer/resource_bundle_source_map.h" | 41 #include "extensions/renderer/resource_bundle_source_map.h" |
41 #include "extensions/renderer/script_context.h" | 42 #include "extensions/renderer/script_context.h" |
42 #include "grit/renderer_resources.h" | 43 #include "grit/renderer_resources.h" |
43 #include "third_party/WebKit/public/platform/WebString.h" | 44 #include "third_party/WebKit/public/platform/WebString.h" |
44 #include "third_party/WebKit/public/web/WebDocument.h" | 45 #include "third_party/WebKit/public/web/WebDocument.h" |
45 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 46 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
46 #include "third_party/WebKit/public/web/WebView.h" | 47 #include "third_party/WebKit/public/web/WebView.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS); | 232 source_map->RegisterSource("windowControls", IDR_WINDOW_CONTROLS_JS); |
232 | 233 |
233 // Custom types sources. | 234 // Custom types sources. |
234 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); | 235 source_map->RegisterSource("ChromeSetting", IDR_CHROME_SETTING_JS); |
235 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); | 236 source_map->RegisterSource("ContentSetting", IDR_CONTENT_SETTING_JS); |
236 source_map->RegisterSource("ChromeDirectSetting", | 237 source_map->RegisterSource("ChromeDirectSetting", |
237 IDR_CHROME_DIRECT_SETTING_JS); | 238 IDR_CHROME_DIRECT_SETTING_JS); |
238 | 239 |
239 // Platform app sources that are not API-specific.. | 240 // Platform app sources that are not API-specific.. |
240 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); | 241 source_map->RegisterSource("appView", IDR_APP_VIEW_JS); |
242 source_map->RegisterSource("extensionOptions", IDR_EXTENSION_OPTIONS_JS); | |
241 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); | 243 source_map->RegisterSource("tagWatcher", IDR_TAG_WATCHER_JS); |
242 source_map->RegisterSource("webViewInternal", | 244 source_map->RegisterSource("webViewInternal", |
243 IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); | 245 IDR_WEB_VIEW_INTERNAL_CUSTOM_BINDINGS_JS); |
244 // Note: webView not webview so that this doesn't interfere with the | 246 // Note: webView not webview so that this doesn't interfere with the |
245 // chrome.webview API bindings. | 247 // chrome.webview API bindings. |
246 source_map->RegisterSource("webView", IDR_WEB_VIEW_JS); | 248 source_map->RegisterSource("webView", IDR_WEB_VIEW_JS); |
247 source_map->RegisterSource("webViewEvents", IDR_WEB_VIEW_EVENTS_JS); | 249 source_map->RegisterSource("webViewEvents", IDR_WEB_VIEW_EVENTS_JS); |
248 source_map->RegisterSource("webViewExperimental", | 250 source_map->RegisterSource("webViewExperimental", |
249 IDR_WEB_VIEW_EXPERIMENTAL_JS); | 251 IDR_WEB_VIEW_EXPERIMENTAL_JS); |
250 source_map->RegisterSource("webViewRequest", | 252 source_map->RegisterSource("webViewRequest", |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 | 306 |
305 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { | 307 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT) { |
306 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && | 308 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppView) && |
307 extension->permissions_data()->HasAPIPermission( | 309 extension->permissions_data()->HasAPIPermission( |
308 extensions::APIPermission::kAppView)) { | 310 extensions::APIPermission::kAppView)) { |
309 module_system->Require("appView"); | 311 module_system->Require("appView"); |
310 } else { | 312 } else { |
311 module_system->Require("denyAppView"); | 313 module_system->Require("denyAppView"); |
312 } | 314 } |
313 } | 315 } |
316 | |
317 if (context_type == extensions::Feature::BLESSED_EXTENSION_CONTEXT || | |
318 context_type == extensions::Feature::UNBLESSED_EXTENSION_CONTEXT) { | |
319 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
Devlin
2014/07/15 18:07:35
nit: This should probably use FeatureSwitch (other
ericzeng
2014/07/15 20:23:55
Done.
| |
320 extensions::switches::kEnableEmbeddedExtensionOptions) && | |
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 Loading... | |
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 } |
OLD | NEW |