OLD | NEW |
---|---|
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/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 return GURL(); | 767 return GURL(); |
768 } | 768 } |
769 | 769 |
770 // static | 770 // static |
771 bool ChromeContentRendererClient::IsNaClAllowed( | 771 bool ChromeContentRendererClient::IsNaClAllowed( |
772 const GURL& manifest_url, | 772 const GURL& manifest_url, |
773 const GURL& app_url, | 773 const GURL& app_url, |
774 bool is_nacl_unrestricted, | 774 bool is_nacl_unrestricted, |
775 const Extension* extension, | 775 const Extension* extension, |
776 WebPluginParams* params) { | 776 WebPluginParams* params) { |
777 // Temporarily allow these URLs to run NaCl apps, as long as the manifest is | 777 // Temporarily allow these whitelisted apps to use NaCl. |
778 // also whitelisted. We should remove this code when PNaCl ships. | 778 std::string manifest_url_path = manifest_url.path(); |
779 bool is_whitelisted_url = | 779 bool is_whitelisted_app = |
780 // Whitelisted apps must be served over https. | |
780 app_url.SchemeIs("https") && | 781 app_url.SchemeIs("https") && |
781 (app_url.host() == "plus.google.com" || | |
782 app_url.host() == "plus.sandbox.google.com") && | |
783 manifest_url.SchemeIs("https") && | 782 manifest_url.SchemeIs("https") && |
784 manifest_url.host() == "ssl.gstatic.com" && | 783 // Photos app. |
785 ((manifest_url.path().find("s2/oz/nacl/") == 1) || | 784 (((app_url.DomainIs("plus.google.com") || |
786 (manifest_url.path().find("photos/nacl/") == 1)); | 785 app_url.DomainIs("plus.sandbox.google.com")) && |
786 manifest_url.DomainIs("ssl.gstatic.com") && | |
787 (manifest_url_path.find("s2/oz/nacl/") == 1 || | |
788 manifest_url_path.find("photos/nacl/") == 1)) || | |
789 // Hangouts app. | |
darin (slow to review)
2013/09/16 19:37:44
nit: "Hangouts" -> "Chat" since the URLs don't men
bbudge
2013/09/16 19:47:51
Done.
| |
790 (EndsWith(app_url.host(), "talkgadget.google.com", false) && | |
791 manifest_url.DomainIs("ssl.gstatic.com") && | |
792 manifest_url_path.find("chat/apps/fx") == 1)); | |
787 | 793 |
788 bool is_extension_from_webstore = | 794 bool is_extension_from_webstore = |
789 extension && extension->from_webstore(); | 795 extension && extension->from_webstore(); |
790 | 796 |
791 bool is_invoked_by_hosted_app = extension && | 797 bool is_invoked_by_hosted_app = extension && |
792 extension->is_hosted_app() && | 798 extension->is_hosted_app() && |
793 extension->web_extent().MatchesURL(app_url); | 799 extension->web_extent().MatchesURL(app_url); |
794 | 800 |
795 // Allow built-in extensions and extensions under development. | 801 // Allow built-in extensions and extensions under development. |
796 bool is_extension_unrestricted = extension && | 802 bool is_extension_unrestricted = extension && |
797 (extension->location() == extensions::Manifest::COMPONENT || | 803 (extension->location() == extensions::Manifest::COMPONENT || |
798 extensions::Manifest::IsUnpackedLocation(extension->location())); | 804 extensions::Manifest::IsUnpackedLocation(extension->location())); |
799 | 805 |
800 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension"); | 806 bool is_invoked_by_extension = app_url.SchemeIs("chrome-extension"); |
801 | 807 |
802 // The NaCl PDF viewer is always allowed and can use 'Dev' interfaces. | 808 // The NaCl PDF viewer is always allowed and can use 'Dev' interfaces. |
803 bool is_nacl_pdf_viewer = | 809 bool is_nacl_pdf_viewer = |
804 (is_extension_from_webstore && | 810 (is_extension_from_webstore && |
805 manifest_url.SchemeIs("chrome-extension") && | 811 manifest_url.SchemeIs("chrome-extension") && |
806 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); | 812 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); |
807 | 813 |
808 // Allow Chrome Web Store extensions, built-in extensions and extensions | 814 // Allow Chrome Web Store extensions, built-in extensions and extensions |
809 // under development if the invocation comes from a URL with an extension | 815 // under development if the invocation comes from a URL with an extension |
810 // scheme. Also allow invocations if they are from whitelisted URLs or | 816 // scheme. Also allow invocations if they are from whitelisted URLs or |
811 // if --enable-nacl is set. | 817 // if --enable-nacl is set. |
812 bool is_nacl_allowed = is_nacl_unrestricted || | 818 bool is_nacl_allowed = is_nacl_unrestricted || |
813 is_whitelisted_url || | 819 is_whitelisted_app || |
814 is_nacl_pdf_viewer || | 820 is_nacl_pdf_viewer || |
815 is_invoked_by_hosted_app || | 821 is_invoked_by_hosted_app || |
816 (is_invoked_by_extension && | 822 (is_invoked_by_extension && |
817 (is_extension_from_webstore || | 823 (is_extension_from_webstore || |
818 is_extension_unrestricted)); | 824 is_extension_unrestricted)); |
819 if (is_nacl_allowed) { | 825 if (is_nacl_allowed) { |
820 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; | 826 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; |
821 // Make sure that PPAPI 'dev' interfaces aren't available for production | 827 // Make sure that PPAPI 'dev' interfaces aren't available for production |
822 // apps unless they're whitelisted. | 828 // apps unless they're whitelisted. |
823 WebString dev_attribute = WebString::fromUTF8("@dev"); | 829 WebString dev_attribute = WebString::fromUTF8("@dev"); |
824 if ((!is_whitelisted_url && !is_extension_from_webstore) || | 830 if ((!is_whitelisted_app && !is_extension_from_webstore) || |
825 app_can_use_dev_interfaces) { | 831 app_can_use_dev_interfaces) { |
826 // Add the special '@dev' attribute. | 832 // Add the special '@dev' attribute. |
827 std::vector<string16> param_names; | 833 std::vector<string16> param_names; |
828 std::vector<string16> param_values; | 834 std::vector<string16> param_values; |
829 param_names.push_back(dev_attribute); | 835 param_names.push_back(dev_attribute); |
830 param_values.push_back(WebString()); | 836 param_values.push_back(WebString()); |
831 AppendParams( | 837 AppendParams( |
832 param_names, | 838 param_names, |
833 param_values, | 839 param_values, |
834 ¶ms->attributeNames, | 840 ¶ms->attributeNames, |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 return false; | 1285 return false; |
1280 | 1286 |
1281 WebString tag_name = container->element().shadowHost().tagName(); | 1287 WebString tag_name = container->element().shadowHost().tagName(); |
1282 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1288 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1283 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1289 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1284 } | 1290 } |
1285 | 1291 |
1286 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI( | 1292 bool ChromeContentRendererClient::AllowPepperMediaStreamAPI( |
1287 const GURL& url) { | 1293 const GURL& url) { |
1288 #if !defined(OS_ANDROID) | 1294 #if !defined(OS_ANDROID) |
1289 std::string host = url.host(); | |
1290 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check | 1295 // Allow only the Hangouts app to use the MediaStream APIs. It's OK to check |
1291 // the whitelist in the renderer, since we're only preventing access until | 1296 // the whitelist in the renderer, since we're only preventing access until |
1292 // these APIs are public and stable. | 1297 // these APIs are public and stable. |
1293 if (url.SchemeIs(extensions::kExtensionScheme) && | 1298 if (url.SchemeIs("https") && |
1294 !host.compare("hpcogiolnobbkijnnkdahioejpdcdoph")) { | 1299 url.DomainIs("talkgadget.google.com")) { |
juberti2
2013/09/16 19:41:52
I think this needs the EndsWith treatment too.
bbudge
2013/09/16 19:47:51
Yep, good catch. Done.
| |
1295 return true; | 1300 return true; |
1296 } | 1301 } |
1297 // Allow access for tests. | 1302 // Allow access for tests. |
1298 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1303 if (CommandLine::ForCurrentProcess()->HasSwitch( |
1299 switches::kEnablePepperTesting)) { | 1304 switches::kEnablePepperTesting)) { |
1300 return true; | 1305 return true; |
1301 } | 1306 } |
1302 #endif // !defined(OS_ANDROID) | 1307 #endif // !defined(OS_ANDROID) |
1303 return false; | 1308 return false; |
1304 } | 1309 } |
(...skipping 12 matching lines...) Expand all Loading... | |
1317 // SiteIsolationPolicy is off by default. We would like to activate cross-site | 1322 // SiteIsolationPolicy is off by default. We would like to activate cross-site |
1318 // document blocking (for UMA data collection) for normal renderer processes | 1323 // document blocking (for UMA data collection) for normal renderer processes |
1319 // running a normal web page from the Internet. We only turn on | 1324 // running a normal web page from the Internet. We only turn on |
1320 // SiteIsolationPolicy for a renderer process that does not have the extension | 1325 // SiteIsolationPolicy for a renderer process that does not have the extension |
1321 // flag on. | 1326 // flag on. |
1322 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1327 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1323 return !command_line->HasSwitch(switches::kExtensionProcess); | 1328 return !command_line->HasSwitch(switches::kExtensionProcess); |
1324 } | 1329 } |
1325 | 1330 |
1326 } // namespace chrome | 1331 } // namespace chrome |
OLD | NEW |