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

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

Issue 2001233002: Cherry-picking hangouts.google.com whitelisting change into M51 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 (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 <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/crash_logging.h" 10 #include "base/debug/crash_logging.h"
(...skipping 13 matching lines...) Expand all
24 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/crash_keys.h" 26 #include "chrome/common/crash_keys.h"
27 #include "chrome/common/pepper_permission_util.h" 27 #include "chrome/common/pepper_permission_util.h"
28 #include "chrome/common/render_messages.h" 28 #include "chrome/common/render_messages.h"
29 #include "chrome/common/secure_origin_whitelist.h" 29 #include "chrome/common/secure_origin_whitelist.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "chrome/grit/generated_resources.h" 31 #include "chrome/grit/generated_resources.h"
32 #include "chrome/grit/locale_settings.h" 32 #include "chrome/grit/locale_settings.h"
33 #include "chrome/grit/renderer_resources.h" 33 #include "chrome/grit/renderer_resources.h"
34 #include "chrome/renderer/app_categorizer.h"
34 #include "chrome/renderer/banners/app_banner_client.h" 35 #include "chrome/renderer/banners/app_banner_client.h"
35 #include "chrome/renderer/benchmarking_extension.h" 36 #include "chrome/renderer/benchmarking_extension.h"
36 #include "chrome/renderer/chrome_render_frame_observer.h" 37 #include "chrome/renderer/chrome_render_frame_observer.h"
37 #include "chrome/renderer/chrome_render_process_observer.h" 38 #include "chrome/renderer/chrome_render_process_observer.h"
38 #include "chrome/renderer/chrome_render_view_observer.h" 39 #include "chrome/renderer/chrome_render_view_observer.h"
39 #include "chrome/renderer/content_settings_observer.h" 40 #include "chrome/renderer/content_settings_observer.h"
40 #include "chrome/renderer/external_extension.h" 41 #include "chrome/renderer/external_extension.h"
41 #include "chrome/renderer/loadtimes_extension_bindings.h" 42 #include "chrome/renderer/loadtimes_extension_bindings.h"
42 #include "chrome/renderer/media/chrome_key_systems.h" 43 #include "chrome/renderer/media/chrome_key_systems.h"
43 #include "chrome/renderer/net/net_error_helper.h" 44 #include "chrome/renderer/net/net_error_helper.h"
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 884
884 #if !defined(DISABLE_NACL) 885 #if !defined(DISABLE_NACL)
885 // static 886 // static
886 bool ChromeContentRendererClient::IsNaClAllowed( 887 bool ChromeContentRendererClient::IsNaClAllowed(
887 const GURL& manifest_url, 888 const GURL& manifest_url,
888 const GURL& app_url, 889 const GURL& app_url,
889 bool is_nacl_unrestricted, 890 bool is_nacl_unrestricted,
890 const Extension* extension, 891 const Extension* extension,
891 WebPluginParams* params) { 892 WebPluginParams* params) {
892 // Temporarily allow these whitelisted apps and WebUIs to use NaCl. 893 // Temporarily allow these whitelisted apps and WebUIs to use NaCl.
893 std::string app_url_host = app_url.host();
894 std::string manifest_url_path = manifest_url.path();
895
896 bool is_whitelisted_web_ui = 894 bool is_whitelisted_web_ui =
897 app_url.spec() == chrome::kChromeUIAppListStartPageURL; 895 app_url.spec() == chrome::kChromeUIAppListStartPageURL;
898 896
899 bool is_photo_app =
900 // Whitelisted apps must be served over https.
901 app_url.SchemeIsCryptographic() && manifest_url.SchemeIsCryptographic() &&
902 (base::EndsWith(app_url_host, "plus.google.com",
903 base::CompareCase::INSENSITIVE_ASCII) ||
904 base::EndsWith(app_url_host, "plus.sandbox.google.com",
905 base::CompareCase::INSENSITIVE_ASCII)) &&
906 manifest_url.DomainIs("ssl.gstatic.com") &&
907 (manifest_url_path.find("s2/oz/nacl/") == 1 ||
908 manifest_url_path.find("photos/nacl/") == 1);
909
910 std::string manifest_fs_host;
911 if (manifest_url.SchemeIsFileSystem() && manifest_url.inner_url()) {
912 manifest_fs_host = manifest_url.inner_url()->host();
913 }
914 bool is_hangouts_app =
915 // Whitelisted apps must be served over secure scheme.
916 app_url.SchemeIsCryptographic() && manifest_url.SchemeIsFileSystem() &&
917 manifest_url.inner_url()->SchemeIsCryptographic() &&
918 (base::EndsWith(app_url_host, "talkgadget.google.com",
919 base::CompareCase::INSENSITIVE_ASCII) ||
920 base::EndsWith(app_url_host, "plus.google.com",
921 base::CompareCase::INSENSITIVE_ASCII) ||
922 base::EndsWith(app_url_host, "plus.sandbox.google.com",
923 base::CompareCase::INSENSITIVE_ASCII) ||
924 base::EndsWith(app_url_host, "hangouts.google.com",
925 base::CompareCase::INSENSITIVE_ASCII)) &&
926 // The manifest must be loaded from the host's FileSystem.
927 (manifest_fs_host == app_url_host);
928
929 bool is_whitelisted_app = is_photo_app || is_hangouts_app;
930
931 bool is_invoked_by_webstore_installed_extension = false; 897 bool is_invoked_by_webstore_installed_extension = false;
932 bool is_extension_unrestricted = false; 898 bool is_extension_unrestricted = false;
933 bool is_extension_force_installed = false; 899 bool is_extension_force_installed = false;
934 #if defined(ENABLE_EXTENSIONS) 900 #if defined(ENABLE_EXTENSIONS)
935 bool is_extension_from_webstore = extension && extension->from_webstore(); 901 bool is_extension_from_webstore = extension && extension->from_webstore();
936 902
937 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension"); 903 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension");
938 bool is_invoked_by_hosted_app = extension && 904 bool is_invoked_by_hosted_app = extension &&
939 extension->is_hosted_app() && 905 extension->is_hosted_app() &&
940 extension->web_extent().MatchesURL(app_url); 906 extension->web_extent().MatchesURL(app_url);
(...skipping 12 matching lines...) Expand all
953 919
954 // Allow NaCl under any of the following circumstances: 920 // Allow NaCl under any of the following circumstances:
955 // 1) An app or URL is explictly whitelisted above. 921 // 1) An app or URL is explictly whitelisted above.
956 // 2) An extension is loaded unpacked or built-in (component) to Chrome. 922 // 2) An extension is loaded unpacked or built-in (component) to Chrome.
957 // 3) An extension is force installed by policy. 923 // 3) An extension is force installed by policy.
958 // 4) An extension is installed from the webstore, and invoked in that 924 // 4) An extension is installed from the webstore, and invoked in that
959 // context (hosted app URL or chrome-extension:// scheme). 925 // context (hosted app URL or chrome-extension:// scheme).
960 // 5) --enable-nacl is set. 926 // 5) --enable-nacl is set.
961 bool is_nacl_allowed_by_location = 927 bool is_nacl_allowed_by_location =
962 is_whitelisted_web_ui || 928 is_whitelisted_web_ui ||
963 is_whitelisted_app || 929 AppCategorizer::IsWhitelistedApp(manifest_url, app_url) ||
964 is_extension_unrestricted || 930 is_extension_unrestricted ||
965 is_extension_force_installed || 931 is_extension_force_installed ||
966 is_invoked_by_webstore_installed_extension; 932 is_invoked_by_webstore_installed_extension;
967 bool is_nacl_allowed = is_nacl_allowed_by_location || is_nacl_unrestricted; 933 bool is_nacl_allowed = is_nacl_allowed_by_location || is_nacl_unrestricted;
968 if (is_nacl_allowed) { 934 if (is_nacl_allowed) {
969 // Make sure that PPAPI 'dev' interfaces are only available for unpacked 935 // Make sure that PPAPI 'dev' interfaces are only available for unpacked
970 // and component extensions. Also allow dev interfaces when --enable-nacl 936 // and component extensions. Also allow dev interfaces when --enable-nacl
971 // is set, but do not allow --enable-nacl to provide dev interfaces to 937 // is set, but do not allow --enable-nacl to provide dev interfaces to
972 // webstore installed and other normally allowed URLs. 938 // webstore installed and other normally allowed URLs.
973 WebString dev_attribute = WebString::fromUTF8("@dev"); 939 WebString dev_attribute = WebString::fromUTF8("@dev");
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 #endif 1175 #endif
1210 1176
1211 blink::WebSpeechSynthesizer* 1177 blink::WebSpeechSynthesizer*
1212 ChromeContentRendererClient::OverrideSpeechSynthesizer( 1178 ChromeContentRendererClient::OverrideSpeechSynthesizer(
1213 blink::WebSpeechSynthesizerClient* client) { 1179 blink::WebSpeechSynthesizerClient* client) {
1214 return new TtsDispatcher(client); 1180 return new TtsDispatcher(client);
1215 } 1181 }
1216 1182
1217 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI( 1183 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI(
1218 const GURL& url) { 1184 const GURL& url) {
1219 #if !defined(OS_ANDROID) 1185 #if defined(OS_ANDROID)
1220 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check 1186 return false;
1221 // the whitelist in the renderer, since we're only preventing access until 1187 #else
1222 // these APIs are public and stable.
1223 std::string url_host = url.host();
1224 if (url.SchemeIs("https") &&
1225 (base::EndsWith(url_host, "talkgadget.google.com",
1226 base::CompareCase::INSENSITIVE_ASCII) ||
1227 base::EndsWith(url_host, "plus.google.com",
1228 base::CompareCase::INSENSITIVE_ASCII) ||
1229 base::EndsWith(url_host, "plus.sandbox.google.com",
1230 base::CompareCase::INSENSITIVE_ASCII)) &&
1231 base::StartsWith(url.path(), "/hangouts/",
1232 base::CompareCase::INSENSITIVE_ASCII)) {
1233 return true;
1234 }
1235 // Allow access for tests. 1188 // Allow access for tests.
1236 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1189 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1237 switches::kEnablePepperTesting)) { 1190 switches::kEnablePepperTesting)) {
1238 return true; 1191 return true;
1239 } 1192 }
1193
1194 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check
1195 // the whitelist in the renderer, since we're only preventing access until
1196 // these APIs are public and stable.
1197 return (AppCategorizer::IsHangoutsUrl(url));
1240 #endif // !defined(OS_ANDROID) 1198 #endif // !defined(OS_ANDROID)
1241 return false;
1242 } 1199 }
1243 1200
1244 void ChromeContentRendererClient::AddKeySystems( 1201 void ChromeContentRendererClient::AddKeySystems(
1245 std::vector<media::KeySystemInfo>* key_systems) { 1202 std::vector<media::KeySystemInfo>* key_systems) {
1246 AddChromeKeySystems(key_systems); 1203 AddChromeKeySystems(key_systems);
1247 } 1204 }
1248 1205
1249 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource( 1206 bool ChromeContentRendererClient::ShouldReportDetailedMessageForSource(
1250 const base::string16& source) const { 1207 const base::string16& source) const {
1251 #if defined(ENABLE_EXTENSIONS) 1208 #if defined(ENABLE_EXTENSIONS)
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 // chrome.system.network.getNetworkInterfaces provides the same 1367 // chrome.system.network.getNetworkInterfaces provides the same
1411 // information. Also, the enforcement of sending and binding UDP is already done 1368 // information. Also, the enforcement of sending and binding UDP is already done
1412 // by chrome extension permission model. 1369 // by chrome extension permission model.
1413 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { 1370 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() {
1414 #if defined(ENABLE_EXTENSIONS) 1371 #if defined(ENABLE_EXTENSIONS)
1415 return !IsStandaloneExtensionProcess(); 1372 return !IsStandaloneExtensionProcess();
1416 #else 1373 #else
1417 return true; 1374 return true;
1418 #endif 1375 #endif
1419 } 1376 }
OLDNEW
« no previous file with comments | « chrome/renderer/app_categorizer_unittest.cc ('k') | chrome/renderer/chrome_content_renderer_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698