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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; | 551 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; |
552 } | 552 } |
553 #endif | 553 #endif |
554 | 554 |
555 switch (status_value) { | 555 switch (status_value) { |
556 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { | 556 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { |
557 NOTREACHED(); | 557 NOTREACHED(); |
558 break; | 558 break; |
559 } | 559 } |
560 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: { | 560 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: { |
561 const char* kPnaclMimeType = "application/x-pnacl"; | 561 const char* kNaClMimeType = "application/x-nacl"; |
562 if (actual_mime_type == kPnaclMimeType) { | 562 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType; |
563 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 563 const bool is_nacl_plugin = |
564 switches::kEnablePnacl)) { | 564 plugin.name == |
| 565 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); |
| 566 bool is_nacl_unrestricted; |
| 567 if (is_nacl_plugin) { |
| 568 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch( |
| 569 switches::kEnableNaCl); |
| 570 } else { |
| 571 // If this is an external plugin that handles the NaCl mime type, we |
| 572 // allow Native Client, so Native Client's integration tests work. |
| 573 is_nacl_unrestricted = true; |
| 574 } |
| 575 if (is_nacl_plugin || is_nacl_mime_type) { |
| 576 GURL manifest_url; |
| 577 GURL app_url; |
| 578 if (is_nacl_mime_type) { |
| 579 // Normal NaCl embed. The app URL is the page URL. |
| 580 manifest_url = url; |
| 581 app_url = frame->top()->document().url(); |
| 582 } else { |
| 583 // NaCl is being invoked as a content handler. Look up the NaCl |
| 584 // module using the MIME type. The app URL is the manifest URL. |
| 585 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); |
| 586 app_url = manifest_url; |
| 587 } |
| 588 const Extension* extension = |
| 589 g_current_client->extension_dispatcher_->extensions()-> |
| 590 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url)); |
| 591 if (!IsNaClAllowed(manifest_url, |
| 592 app_url, |
| 593 is_nacl_unrestricted, |
| 594 extension, |
| 595 ¶ms)) { |
565 frame->addMessageToConsole( | 596 frame->addMessageToConsole( |
566 WebConsoleMessage( | 597 WebConsoleMessage( |
567 WebConsoleMessage::LevelError, | 598 WebConsoleMessage::LevelError, |
568 "Portable Native Client must be enabled in about:flags.")); | 599 "Only unpacked extensions and apps installed from the " |
| 600 "Chrome Web Store can load NaCl modules without enabling " |
| 601 "Native Client in about:flags.")); |
569 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 602 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
570 render_view, frame, params, plugin, identifier, group_name, | 603 render_view, frame, params, plugin, identifier, group_name, |
571 IDR_BLOCKED_PLUGIN_HTML, | 604 IDR_BLOCKED_PLUGIN_HTML, |
572 #if defined(OS_CHROMEOS) | 605 #if defined(OS_CHROMEOS) |
573 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | 606 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); |
574 #else | 607 #else |
575 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 608 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
576 #endif | 609 #endif |
577 break; | 610 break; |
578 } | |
579 } else { | |
580 const char* kNaClMimeType = "application/x-nacl"; | |
581 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType; | |
582 const bool is_nacl_plugin = | |
583 plugin.name == | |
584 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); | |
585 bool is_nacl_unrestricted; | |
586 if (is_nacl_plugin) { | |
587 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch( | |
588 switches::kEnableNaCl); | |
589 } else { | |
590 // If this is an external plugin that handles the NaCl mime type, we | |
591 // allow Native Client, so Native Client's integration tests work. | |
592 is_nacl_unrestricted = true; | |
593 } | |
594 if (is_nacl_plugin || is_nacl_mime_type) { | |
595 GURL manifest_url; | |
596 GURL app_url; | |
597 if (is_nacl_mime_type) { | |
598 // Normal NaCl embed. The app URL is the page URL. | |
599 manifest_url = url; | |
600 app_url = frame->top()->document().url(); | |
601 } else { | |
602 // NaCl is being invoked as a content handler. Look up the NaCl | |
603 // module using the MIME type. The app URL is the manifest URL. | |
604 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); | |
605 app_url = manifest_url; | |
606 } | |
607 const Extension* extension = | |
608 g_current_client->extension_dispatcher_->extensions()-> | |
609 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url)); | |
610 if (!IsNaClAllowed(manifest_url, | |
611 app_url, | |
612 is_nacl_unrestricted, | |
613 extension, | |
614 ¶ms)) { | |
615 frame->addMessageToConsole( | |
616 WebConsoleMessage( | |
617 WebConsoleMessage::LevelError, | |
618 "Only unpacked extensions and apps installed from the " | |
619 "Chrome Web Store can load NaCl modules without enabling " | |
620 "Native Client in about:flags.")); | |
621 placeholder = PluginPlaceholder::CreateBlockedPlugin( | |
622 render_view, frame, params, plugin, identifier, group_name, | |
623 IDR_BLOCKED_PLUGIN_HTML, | |
624 #if defined(OS_CHROMEOS) | |
625 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | |
626 #else | |
627 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | |
628 #endif | |
629 break; | |
630 } | |
631 } | 611 } |
632 } | 612 } |
633 | 613 |
634 // Delay loading plugins if prerendering. | 614 // Delay loading plugins if prerendering. |
635 // TODO(mmenke): In the case of prerendering, feed into | 615 // TODO(mmenke): In the case of prerendering, feed into |
636 // ChromeContentRendererClient::CreatePlugin instead, to | 616 // ChromeContentRendererClient::CreatePlugin instead, to |
637 // reduce the chance of future regressions. | 617 // reduce the chance of future regressions. |
638 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { | 618 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { |
639 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 619 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
640 render_view, frame, params, plugin, identifier, group_name, | 620 render_view, frame, params, plugin, identifier, group_name, |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 | 1205 |
1226 if (container->element().shadowHost().isNull()) | 1206 if (container->element().shadowHost().isNull()) |
1227 return false; | 1207 return false; |
1228 | 1208 |
1229 WebString tag_name = container->element().shadowHost().tagName(); | 1209 WebString tag_name = container->element().shadowHost().tagName(); |
1230 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1210 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1231 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1211 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1232 } | 1212 } |
1233 | 1213 |
1234 } // namespace chrome | 1214 } // namespace chrome |
OLD | NEW |