| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // If this is an external plugin that handles the NaCl mime type, we | 532 // If this is an external plugin that handles the NaCl mime type, we |
| 533 // allow Native Client, so Native Client's integration tests work. | 533 // allow Native Client, so Native Client's integration tests work. |
| 534 is_nacl_unrestricted = true; | 534 is_nacl_unrestricted = true; |
| 535 } | 535 } |
| 536 if (is_nacl_plugin || is_nacl_mime_type) { | 536 if (is_nacl_plugin || is_nacl_mime_type) { |
| 537 GURL manifest_url = is_nacl_mime_type ? | 537 GURL manifest_url = is_nacl_mime_type ? |
| 538 url : GetNaClContentHandlerURL(actual_mime_type, plugin); | 538 url : GetNaClContentHandlerURL(actual_mime_type, plugin); |
| 539 const Extension* extension = | 539 const Extension* extension = |
| 540 extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 540 extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
| 541 ExtensionURLInfo(manifest_url)); | 541 ExtensionURLInfo(manifest_url)); |
| 542 bool is_extension_from_webstore = | |
| 543 extension && extension->from_webstore(); | |
| 544 // Allow built-in extensions and extensions under development. | |
| 545 bool is_extension_unrestricted = extension && | |
| 546 (extension->location() == extensions::Manifest::COMPONENT || | |
| 547 extensions::Manifest::IsUnpackedLocation(extension->location())); | |
| 548 GURL top_url = frame->top()->document().url(); | 542 GURL top_url = frame->top()->document().url(); |
| 549 if (!IsNaClAllowed(manifest_url, | 543 if (!IsNaClAllowed(manifest_url, |
| 550 top_url, | 544 top_url, |
| 551 is_nacl_unrestricted, | 545 is_nacl_unrestricted, |
| 552 is_extension_unrestricted, | 546 extension, |
| 553 is_extension_from_webstore, | |
| 554 ¶ms)) { | 547 ¶ms)) { |
| 555 frame->addMessageToConsole( | 548 frame->addMessageToConsole( |
| 556 WebConsoleMessage( | 549 WebConsoleMessage( |
| 557 WebConsoleMessage::LevelError, | 550 WebConsoleMessage::LevelError, |
| 558 "Only unpacked extensions and apps installed from the " | 551 "Only unpacked extensions and apps installed from the " |
| 559 "Chrome Web Store can load NaCl modules without enabling " | 552 "Chrome Web Store can load NaCl modules without enabling " |
| 560 "Native Client in about:flags.")); | 553 "Native Client in about:flags.")); |
| 561 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 554 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 562 render_view, frame, params, plugin, identifier, group_name, | 555 render_view, frame, params, plugin, identifier, group_name, |
| 563 IDR_BLOCKED_PLUGIN_HTML, | 556 IDR_BLOCKED_PLUGIN_HTML, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 } | 676 } |
| 684 } | 677 } |
| 685 return GURL(); | 678 return GURL(); |
| 686 } | 679 } |
| 687 | 680 |
| 688 // static | 681 // static |
| 689 bool ChromeContentRendererClient::IsNaClAllowed( | 682 bool ChromeContentRendererClient::IsNaClAllowed( |
| 690 const GURL& manifest_url, | 683 const GURL& manifest_url, |
| 691 const GURL& top_url, | 684 const GURL& top_url, |
| 692 bool is_nacl_unrestricted, | 685 bool is_nacl_unrestricted, |
| 693 bool is_extension_unrestricted, | 686 const Extension* extension, |
| 694 bool is_extension_from_webstore, | |
| 695 WebPluginParams* params) { | 687 WebPluginParams* params) { |
| 696 // Temporarily allow these URLs to run NaCl apps. We should remove this | 688 // Temporarily allow these URLs to run NaCl apps. We should remove this |
| 697 // code when PNaCl ships. | 689 // code when PNaCl ships. |
| 698 bool is_whitelisted_url = | 690 bool is_whitelisted_url = |
| 699 top_url.SchemeIs("https") && | 691 top_url.SchemeIs("https") && |
| 700 (top_url.host() == "plus.google.com" || | 692 (top_url.host() == "plus.google.com" || |
| 701 top_url.host() == "plus.sandbox.google.com") && | 693 top_url.host() == "plus.sandbox.google.com") && |
| 702 top_url.path().find("/games") == 0; | 694 top_url.path().find("/games") == 0; |
| 703 | 695 |
| 696 bool is_extension_from_webstore = |
| 697 extension && extension->from_webstore(); |
| 698 |
| 699 bool is_invoked_by_hosted_app = extension && |
| 700 extension->is_hosted_app() && |
| 701 extension->web_extent().MatchesURL(top_url); |
| 702 |
| 703 // Allow built-in extensions and extensions under development. |
| 704 bool is_extension_unrestricted = extension && |
| 705 (extension->location() == extensions::Manifest::COMPONENT || |
| 706 extensions::Manifest::IsUnpackedLocation(extension->location())); |
| 707 |
| 704 bool is_invoked_by_extension = top_url.SchemeIs("chrome-extension"); | 708 bool is_invoked_by_extension = top_url.SchemeIs("chrome-extension"); |
| 705 | 709 |
| 706 // NaCl PDF viewer can be loaded from all URLs. | 710 // NaCl PDF viewer can be loaded from all URLs. |
| 707 bool is_nacl_pdf_viewer = | 711 bool is_nacl_pdf_viewer = |
| 708 (is_extension_from_webstore && | 712 (is_extension_from_webstore && |
| 709 manifest_url.SchemeIs("chrome-extension") && | 713 manifest_url.SchemeIs("chrome-extension") && |
| 710 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); | 714 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); |
| 711 | 715 |
| 712 // Allow Chrome Web Store extensions, built-in extensions and extensions | 716 // Allow Chrome Web Store extensions, built-in extensions and extensions |
| 713 // under development if the invocation comes from a URL with an extension | 717 // under development if the invocation comes from a URL with an extension |
| 714 // scheme. Also allow invocations if they are from whitelisted URLs or | 718 // scheme. Also allow invocations if they are from whitelisted URLs or |
| 715 // if --enable-nacl is set. | 719 // if --enable-nacl is set. |
| 716 bool is_nacl_allowed = is_nacl_unrestricted || | 720 bool is_nacl_allowed = is_nacl_unrestricted || |
| 717 is_whitelisted_url || | 721 is_whitelisted_url || |
| 718 is_nacl_pdf_viewer || | 722 is_nacl_pdf_viewer || |
| 723 is_invoked_by_hosted_app || |
| 719 (is_invoked_by_extension && | 724 (is_invoked_by_extension && |
| 720 (is_extension_from_webstore || | 725 (is_extension_from_webstore || |
| 721 is_extension_unrestricted)); | 726 is_extension_unrestricted)); |
| 722 if (is_nacl_allowed) { | 727 if (is_nacl_allowed) { |
| 723 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; | 728 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; |
| 724 // Make sure that PPAPI 'dev' interfaces aren't available for production | 729 // Make sure that PPAPI 'dev' interfaces aren't available for production |
| 725 // apps unless they're whitelisted. | 730 // apps unless they're whitelisted. |
| 726 WebString dev_attribute = WebString::fromUTF8("@dev"); | 731 WebString dev_attribute = WebString::fromUTF8("@dev"); |
| 727 if ((!is_whitelisted_url && !is_extension_from_webstore) || | 732 if ((!is_whitelisted_url && !is_extension_from_webstore) || |
| 728 app_can_use_dev_interfaces) { | 733 app_can_use_dev_interfaces) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 if (container->element().shadowHost().tagName().equals( | 1127 if (container->element().shadowHost().tagName().equals( |
| 1123 WebKit::WebString::fromUTF8(kWebViewTagName))) { | 1128 WebKit::WebString::fromUTF8(kWebViewTagName))) { |
| 1124 return true; | 1129 return true; |
| 1125 } else { | 1130 } else { |
| 1126 return CommandLine::ForCurrentProcess()->HasSwitch( | 1131 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 1127 switches::kEnableBrowserPluginForAllViewTypes); | 1132 switches::kEnableBrowserPluginForAllViewTypes); |
| 1128 } | 1133 } |
| 1129 } | 1134 } |
| 1130 | 1135 |
| 1131 } // namespace chrome | 1136 } // namespace chrome |
| OLD | NEW |