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

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

Issue 16296005: Split pnacl and nacl mime types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: After (hopefully) last rebase. Created 7 years, 6 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 | Annotate | Revision Log
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/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
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* kNaClMimeType = "application/x-nacl"; 561 const char* kPnaclMimeType = "application/x-pnacl";
562 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType; 562 if (actual_mime_type == kPnaclMimeType) {
563 const bool is_nacl_plugin = 563 if (!CommandLine::ForCurrentProcess()->HasSwitch(
564 plugin.name == 564 switches::kEnablePnacl)) {
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 &params)) {
596 frame->addMessageToConsole( 565 frame->addMessageToConsole(
597 WebConsoleMessage( 566 WebConsoleMessage(
598 WebConsoleMessage::LevelError, 567 WebConsoleMessage::LevelError,
599 "Only unpacked extensions and apps installed from the " 568 "Portable Native Client must be enabled in about:flags."));
600 "Chrome Web Store can load NaCl modules without enabling "
601 "Native Client in about:flags."));
602 placeholder = PluginPlaceholder::CreateBlockedPlugin( 569 placeholder = PluginPlaceholder::CreateBlockedPlugin(
603 render_view, frame, params, plugin, identifier, group_name, 570 render_view, frame, params, plugin, identifier, group_name,
604 IDR_BLOCKED_PLUGIN_HTML, 571 IDR_BLOCKED_PLUGIN_HTML,
605 #if defined(OS_CHROMEOS) 572 #if defined(OS_CHROMEOS)
606 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); 573 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
607 #else 574 #else
608 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 575 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
609 #endif 576 #endif
610 break; 577 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 &params)) {
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 }
611 } 631 }
612 } 632 }
613 633
614 // Delay loading plugins if prerendering. 634 // Delay loading plugins if prerendering.
615 // TODO(mmenke): In the case of prerendering, feed into 635 // TODO(mmenke): In the case of prerendering, feed into
616 // ChromeContentRendererClient::CreatePlugin instead, to 636 // ChromeContentRendererClient::CreatePlugin instead, to
617 // reduce the chance of future regressions. 637 // reduce the chance of future regressions.
618 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { 638 if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
619 placeholder = PluginPlaceholder::CreateBlockedPlugin( 639 placeholder = PluginPlaceholder::CreateBlockedPlugin(
620 render_view, frame, params, plugin, identifier, group_name, 640 render_view, frame, params, plugin, identifier, group_name,
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1225
1206 if (container->element().shadowHost().isNull()) 1226 if (container->element().shadowHost().isNull())
1207 return false; 1227 return false;
1208 1228
1209 WebString tag_name = container->element().shadowHost().tagName(); 1229 WebString tag_name = container->element().shadowHost().tagName();
1210 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || 1230 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) ||
1211 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); 1231 tag_name.equals(WebString::fromUTF8(kAdViewTagName));
1212 } 1232 }
1213 1233
1214 } // namespace chrome 1234 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_content_client.cc ('k') | chrome/test/data/nacl/exit_status/pm_exit_status_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698