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

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 673663004: Android: Do not build any extensions code except for extensions_constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@zoom_controller
Patch Set: Created 6 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chrome_content_renderer_client.h" 5 #include "chrome/renderer/chrome_content_renderer_client.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/metrics/user_metrics_action.h" 12 #include "base/metrics/user_metrics_action.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chrome/common/chrome_paths.h" 18 #include "chrome/common/chrome_paths.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
21 #include "chrome/common/crash_keys.h" 21 #include "chrome/common/crash_keys.h"
22 #include "chrome/common/extensions/chrome_extensions_client.h"
23 #include "chrome/common/extensions/extension_constants.h" 22 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_process_policy.h"
25 #include "chrome/common/localized_error.h" 23 #include "chrome/common/localized_error.h"
26 #include "chrome/common/pepper_permission_util.h" 24 #include "chrome/common/pepper_permission_util.h"
27 #include "chrome/common/render_messages.h" 25 #include "chrome/common/render_messages.h"
28 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
29 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
30 #include "chrome/grit/locale_settings.h" 28 #include "chrome/grit/locale_settings.h"
31 #include "chrome/grit/renderer_resources.h" 29 #include "chrome/grit/renderer_resources.h"
32 #include "chrome/renderer/benchmarking_extension.h" 30 #include "chrome/renderer/benchmarking_extension.h"
33 #include "chrome/renderer/chrome_render_frame_observer.h" 31 #include "chrome/renderer/chrome_render_frame_observer.h"
34 #include "chrome/renderer/chrome_render_process_observer.h" 32 #include "chrome/renderer/chrome_render_process_observer.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "components/plugins/renderer/mobile_youtube_plugin.h" 70 #include "components/plugins/renderer/mobile_youtube_plugin.h"
73 #include "components/signin/core/common/profile_management_switches.h" 71 #include "components/signin/core/common/profile_management_switches.h"
74 #include "components/visitedlink/renderer/visitedlink_slave.h" 72 #include "components/visitedlink/renderer/visitedlink_slave.h"
75 #include "components/web_cache/renderer/web_cache_render_process_observer.h" 73 #include "components/web_cache/renderer/web_cache_render_process_observer.h"
76 #include "content/public/common/content_constants.h" 74 #include "content/public/common/content_constants.h"
77 #include "content/public/renderer/render_frame.h" 75 #include "content/public/renderer/render_frame.h"
78 #include "content/public/renderer/render_thread.h" 76 #include "content/public/renderer/render_thread.h"
79 #include "content/public/renderer/render_view.h" 77 #include "content/public/renderer/render_view.h"
80 #include "content/public/renderer/render_view_visitor.h" 78 #include "content/public/renderer/render_view_visitor.h"
81 #include "extensions/common/constants.h" 79 #include "extensions/common/constants.h"
82 #include "extensions/common/extension.h"
83 #include "extensions/common/extension_set.h"
84 #include "extensions/common/extension_urls.h"
85 #include "extensions/common/switches.h"
86 #include "ipc/ipc_sync_channel.h" 80 #include "ipc/ipc_sync_channel.h"
87 #include "net/base/net_errors.h" 81 #include "net/base/net_errors.h"
88 #include "ppapi/c/private/ppb_nacl_private.h" 82 #include "ppapi/c/private/ppb_nacl_private.h"
89 #include "ppapi/c/private/ppb_pdf.h" 83 #include "ppapi/c/private/ppb_pdf.h"
90 #include "ppapi/shared_impl/ppapi_switches.h" 84 #include "ppapi/shared_impl/ppapi_switches.h"
91 #include "third_party/WebKit/public/platform/WebURL.h" 85 #include "third_party/WebKit/public/platform/WebURL.h"
92 #include "third_party/WebKit/public/platform/WebURLError.h" 86 #include "third_party/WebKit/public/platform/WebURLError.h"
93 #include "third_party/WebKit/public/platform/WebURLRequest.h" 87 #include "third_party/WebKit/public/platform/WebURLRequest.h"
94 #include "third_party/WebKit/public/web/WebCache.h" 88 #include "third_party/WebKit/public/web/WebCache.h"
95 #include "third_party/WebKit/public/web/WebDataSource.h" 89 #include "third_party/WebKit/public/web/WebDataSource.h"
96 #include "third_party/WebKit/public/web/WebDocument.h" 90 #include "third_party/WebKit/public/web/WebDocument.h"
97 #include "third_party/WebKit/public/web/WebElement.h" 91 #include "third_party/WebKit/public/web/WebElement.h"
98 #include "third_party/WebKit/public/web/WebLocalFrame.h" 92 #include "third_party/WebKit/public/web/WebLocalFrame.h"
99 #include "third_party/WebKit/public/web/WebPluginContainer.h" 93 #include "third_party/WebKit/public/web/WebPluginContainer.h"
100 #include "third_party/WebKit/public/web/WebPluginParams.h" 94 #include "third_party/WebKit/public/web/WebPluginParams.h"
101 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 95 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
102 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" 96 #include "third_party/WebKit/public/web/WebSecurityPolicy.h"
103 #include "ui/base/l10n/l10n_util.h" 97 #include "ui/base/l10n/l10n_util.h"
104 #include "ui/base/layout.h" 98 #include "ui/base/layout.h"
105 #include "ui/base/resource/resource_bundle.h" 99 #include "ui/base/resource/resource_bundle.h"
106 #include "ui/base/webui/jstemplate_builder.h" 100 #include "ui/base/webui/jstemplate_builder.h"
107 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 101 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
108 102
109 #if !defined(DISABLE_NACL) 103 #if !defined(DISABLE_NACL)
110 #include "components/nacl/common/nacl_constants.h" 104 #include "components/nacl/common/nacl_constants.h"
111 #include "components/nacl/renderer/nacl_helper.h" 105 #include "components/nacl/renderer/nacl_helper.h"
112 #endif 106 #endif
113 107
114 #if defined(ENABLE_EXTENSIONS) 108 #if defined(ENABLE_EXTENSIONS)
109 #include "chrome/common/extensions/chrome_extensions_client.h"
110 #include "chrome/common/extensions/extension_process_policy.h"
115 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h" 111 #include "chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.h"
116 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h" 112 #include "chrome/renderer/extensions/chrome_extensions_renderer_client.h"
117 #include "chrome/renderer/extensions/extension_frame_helper.h" 113 #include "chrome/renderer/extensions/extension_frame_helper.h"
118 #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h" 114 #include "chrome/renderer/extensions/renderer_permissions_policy_delegate.h"
119 #include "chrome/renderer/extensions/resource_request_policy.h" 115 #include "chrome/renderer/extensions/resource_request_policy.h"
116 #include "extensions/common/extension.h"
117 #include "extensions/common/extension_set.h"
118 #include "extensions/common/extension_urls.h"
119 #include "extensions/common/switches.h"
120 #include "extensions/renderer/dispatcher.h" 120 #include "extensions/renderer/dispatcher.h"
121 #include "extensions/renderer/extension_helper.h" 121 #include "extensions/renderer/extension_helper.h"
122 #include "extensions/renderer/extensions_render_frame_observer.h" 122 #include "extensions/renderer/extensions_render_frame_observer.h"
123 #include "extensions/renderer/guest_view/guest_view_container.h" 123 #include "extensions/renderer/guest_view/guest_view_container.h"
124 #include "extensions/renderer/script_context.h" 124 #include "extensions/renderer/script_context.h"
125 #endif 125 #endif
126 126
127 #if defined(ENABLE_FULL_PRINTING) 127 #if defined(ENABLE_FULL_PRINTING)
128 #include "chrome/renderer/pepper/chrome_pdf_print_client.h" 128 #include "chrome/renderer/pepper/chrome_pdf_print_client.h"
129 #endif 129 #endif
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 *api_is_available = true; 261 *api_is_available = true;
262 } 262 }
263 } 263 }
264 #endif 264 #endif
265 265
266 } // namespace 266 } // namespace
267 267
268 ChromeContentRendererClient::ChromeContentRendererClient() { 268 ChromeContentRendererClient::ChromeContentRendererClient() {
269 g_current_client = this; 269 g_current_client = this;
270 270
271 #if defined(ENABLE_EXTENSIONS)
271 extensions::ExtensionsClient::Set( 272 extensions::ExtensionsClient::Set(
272 extensions::ChromeExtensionsClient::GetInstance()); 273 extensions::ChromeExtensionsClient::GetInstance());
273 #if defined(ENABLE_EXTENSIONS)
274 extensions::ExtensionsRendererClient::Set( 274 extensions::ExtensionsRendererClient::Set(
275 ChromeExtensionsRendererClient::GetInstance()); 275 ChromeExtensionsRendererClient::GetInstance());
276 #endif 276 #endif
277 #if defined(ENABLE_PLUGINS) 277 #if defined(ENABLE_PLUGINS)
278 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i) 278 for (size_t i = 0; i < arraysize(kPredefinedAllowedCompositorOrigins); ++i)
279 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]); 279 allowed_compositor_origins_.insert(kPredefinedAllowedCompositorOrigins[i]);
280 for (size_t i = 0; i < arraysize(kPredefinedAllowedVideoDecodeOrigins); ++i) 280 for (size_t i = 0; i < arraysize(kPredefinedAllowedVideoDecodeOrigins); ++i)
281 allowed_video_decode_origins_.insert( 281 allowed_video_decode_origins_.insert(
282 kPredefinedAllowedVideoDecodeOrigins[i]); 282 kPredefinedAllowedVideoDecodeOrigins[i]);
283 #endif 283 #endif
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 for (size_t i = 0; i < content_type.additional_param_names.size(); ++i) { 948 for (size_t i = 0; i < content_type.additional_param_names.size(); ++i) {
949 if (content_type.additional_param_names[i] == nacl_attr) 949 if (content_type.additional_param_names[i] == nacl_attr)
950 return GURL(content_type.additional_param_values[i]); 950 return GURL(content_type.additional_param_values[i]);
951 } 951 }
952 break; 952 break;
953 } 953 }
954 } 954 }
955 return GURL(); 955 return GURL();
956 } 956 }
957 957
958 #if !defined(DISABLE_NACL)
958 // static 959 // static
959 bool ChromeContentRendererClient::IsNaClAllowed( 960 bool ChromeContentRendererClient::IsNaClAllowed(
960 const GURL& manifest_url, 961 const GURL& manifest_url,
961 const GURL& app_url, 962 const GURL& app_url,
962 bool is_nacl_unrestricted, 963 bool is_nacl_unrestricted,
963 const Extension* extension, 964 const Extension* extension,
964 WebPluginParams* params) { 965 WebPluginParams* params) {
965 // Temporarily allow these whitelisted apps and WebUIs to use NaCl. 966 // Temporarily allow these whitelisted apps and WebUIs to use NaCl.
966 std::string app_url_host = app_url.host(); 967 std::string app_url_host = app_url.host();
967 std::string manifest_url_path = manifest_url.path(); 968 std::string manifest_url_path = manifest_url.path();
(...skipping 21 matching lines...) Expand all
989 manifest_url.SchemeIsSecure() && 990 manifest_url.SchemeIsSecure() &&
990 manifest_url.SchemeIsFileSystem() && 991 manifest_url.SchemeIsFileSystem() &&
991 (EndsWith(app_url_host, "talkgadget.google.com", false) || 992 (EndsWith(app_url_host, "talkgadget.google.com", false) ||
992 EndsWith(app_url_host, "plus.google.com", false) || 993 EndsWith(app_url_host, "plus.google.com", false) ||
993 EndsWith(app_url_host, "plus.sandbox.google.com", false)) && 994 EndsWith(app_url_host, "plus.sandbox.google.com", false)) &&
994 // The manifest must be loaded from the host's FileSystem. 995 // The manifest must be loaded from the host's FileSystem.
995 (manifest_fs_host == app_url_host); 996 (manifest_fs_host == app_url_host);
996 997
997 bool is_whitelisted_app = is_photo_app || is_hangouts_app; 998 bool is_whitelisted_app = is_photo_app || is_hangouts_app;
998 999
999 bool is_extension_from_webstore = extension && 1000 bool is_extension_from_webstore = false;
1000 extension->from_webstore(); 1001 bool is_invoked_by_hosted_app = false;
1002 bool is_extension_unrestricted = false;
1003 #if defined(ENABLE_EXTENSIONS)
1004 is_extension_from_webstore = extension && extension->from_webstore();
1001 1005
1002 bool is_invoked_by_hosted_app = extension && 1006 is_invoked_by_hosted_app = extension &&
1003 extension->is_hosted_app() && 1007 extension->is_hosted_app() &&
1004 extension->web_extent().MatchesURL(app_url); 1008 extension->web_extent().MatchesURL(app_url);
1005 1009
1006 // Allow built-in extensions and extensions under development. 1010 // Allow built-in extensions and extensions under development.
1007 bool is_extension_unrestricted = extension && 1011 is_extension_unrestricted = extension &&
1008 (extension->location() == extensions::Manifest::COMPONENT || 1012 (extension->location() == extensions::Manifest::COMPONENT ||
1009 extensions::Manifest::IsUnpackedLocation(extension->location())); 1013 extensions::Manifest::IsUnpackedLocation(extension->location()));
1014 #endif
Yoyo Zhou 2014/10/23 00:03:59 This endif and the one below should have a comment
Lei Zhang 2014/10/23 00:30:46 Done.
1010 1015
1011 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension"); 1016 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension");
1012 1017
1013 // The NaCl PDF viewer is always allowed and can use 'Dev' interfaces. 1018 // The NaCl PDF viewer is always allowed and can use 'Dev' interfaces.
1014 bool is_nacl_pdf_viewer = 1019 bool is_nacl_pdf_viewer =
1015 (is_extension_from_webstore && 1020 (is_extension_from_webstore &&
1016 manifest_url.SchemeIs("chrome-extension") && 1021 manifest_url.SchemeIs("chrome-extension") &&
1017 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); 1022 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh");
1018 1023
1019 // Allow Chrome Web Store extensions, built-in extensions and extensions 1024 // Allow Chrome Web Store extensions, built-in extensions and extensions
(...skipping 29 matching lines...) Expand all
1049 // If the params somehow contain '@dev', remove it. 1054 // If the params somehow contain '@dev', remove it.
1050 size_t attribute_count = params->attributeNames.size(); 1055 size_t attribute_count = params->attributeNames.size();
1051 for (size_t i = 0; i < attribute_count; ++i) { 1056 for (size_t i = 0; i < attribute_count; ++i) {
1052 if (params->attributeNames[i].equals(dev_attribute)) 1057 if (params->attributeNames[i].equals(dev_attribute))
1053 params->attributeNames[i] = WebString(); 1058 params->attributeNames[i] = WebString();
1054 } 1059 }
1055 } 1060 }
1056 } 1061 }
1057 return is_nacl_allowed; 1062 return is_nacl_allowed;
1058 } 1063 }
1064 #endif
1059 1065
1060 bool ChromeContentRendererClient::HasErrorPage(int http_status_code, 1066 bool ChromeContentRendererClient::HasErrorPage(int http_status_code,
1061 std::string* error_domain) { 1067 std::string* error_domain) {
1062 // Use an internal error page, if we have one for the status code. 1068 // Use an internal error page, if we have one for the status code.
1063 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain, 1069 if (!LocalizedError::HasStrings(LocalizedError::kHttpErrorDomain,
1064 http_status_code)) { 1070 http_status_code)) {
1065 return false; 1071 return false;
1066 } 1072 }
1067 1073
1068 *error_domain = LocalizedError::kHttpErrorDomain; 1074 *error_domain = LocalizedError::kHttpErrorDomain;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 return false; 1496 return false;
1491 } 1497 }
1492 1498
1493 void ChromeContentRendererClient::AddKeySystems( 1499 void ChromeContentRendererClient::AddKeySystems(
1494 std::vector<content::KeySystemInfo>* key_systems) { 1500 std::vector<content::KeySystemInfo>* key_systems) {
1495 AddChromeKeySystems(key_systems); 1501 AddChromeKeySystems(key_systems);
1496 } 1502 }
1497 1503
1498 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource( 1504 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource(
1499 const base::string16& source) const { 1505 const base::string16& source) const {
1506 #if defined(ENABLE_EXTENSIONS)
1500 return extensions::IsSourceFromAnExtension(source); 1507 return extensions::IsSourceFromAnExtension(source);
1508 #else
1509 return false;
1510 #endif
1501 } 1511 }
1502 1512
1503 bool ChromeContentRendererClient::ShouldEnableSiteIsolationPolicy() const { 1513 bool ChromeContentRendererClient::ShouldEnableSiteIsolationPolicy() const {
1504 // SiteIsolationPolicy is off by default. We would like to activate cross-site 1514 // SiteIsolationPolicy is off by default. We would like to activate cross-site
1505 // document blocking (for UMA data collection) for normal renderer processes 1515 // document blocking (for UMA data collection) for normal renderer processes
1506 // running a normal web page from the Internet. We only turn on 1516 // running a normal web page from the Internet. We only turn on
1507 // SiteIsolationPolicy for a renderer process that does not have the extension 1517 // SiteIsolationPolicy for a renderer process that does not have the extension
1508 // flag on. 1518 // flag on.
1519 #if defined(ENABLE_EXTENSIONS)
1509 CommandLine* command_line = CommandLine::ForCurrentProcess(); 1520 CommandLine* command_line = CommandLine::ForCurrentProcess();
1510 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); 1521 return !command_line->HasSwitch(extensions::switches::kExtensionProcess);
1522 #else
1523 return true;
1524 #endif
1511 } 1525 }
1512 1526
1513 blink::WebWorkerPermissionClientProxy* 1527 blink::WebWorkerPermissionClientProxy*
1514 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( 1528 ChromeContentRendererClient::CreateWorkerPermissionClientProxy(
1515 content::RenderFrame* render_frame, 1529 content::RenderFrame* render_frame,
1516 blink::WebFrame* frame) { 1530 blink::WebFrame* frame) {
1517 return new WorkerPermissionClientProxy(render_frame, frame); 1531 return new WorkerPermissionClientProxy(render_frame, frame);
1518 } 1532 }
1519 1533
1520 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { 1534 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 content::BrowserPluginDelegate* 1585 content::BrowserPluginDelegate*
1572 ChromeContentRendererClient::CreateBrowserPluginDelegate( 1586 ChromeContentRendererClient::CreateBrowserPluginDelegate(
1573 content::RenderFrame* render_frame, 1587 content::RenderFrame* render_frame,
1574 const std::string& mime_type) { 1588 const std::string& mime_type) {
1575 #if defined(ENABLE_EXTENSIONS) 1589 #if defined(ENABLE_EXTENSIONS)
1576 return new extensions::GuestViewContainer(render_frame, mime_type); 1590 return new extensions::GuestViewContainer(render_frame, mime_type);
1577 #else 1591 #else
1578 return NULL; 1592 return NULL;
1579 #endif 1593 #endif
1580 } 1594 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698