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

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: Finish integration test fixes. 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported; 550 ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
551 } 551 }
552 #endif 552 #endif
553 553
554 switch (status_value) { 554 switch (status_value) {
555 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: { 555 case ChromeViewHostMsg_GetPluginInfo_Status::kNotFound: {
556 NOTREACHED(); 556 NOTREACHED();
557 break; 557 break;
558 } 558 }
559 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: { 559 case ChromeViewHostMsg_GetPluginInfo_Status::kAllowed: {
560 const char* kNaClMimeType = "application/x-nacl"; 560 const char* kPnaclMimeType = "application/x-pnacl";
561 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType; 561 if (actual_mime_type == kPnaclMimeType) {
562 const bool is_nacl_plugin = 562 if (!CommandLine::ForCurrentProcess()->HasSwitch(
563 plugin.name == 563 switches::kEnablePnacl)) {
564 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName);
565 bool is_nacl_unrestricted;
566 if (is_nacl_plugin) {
567 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch(
568 switches::kEnableNaCl);
569 } else {
570 // If this is an external plugin that handles the NaCl mime type, we
571 // allow Native Client, so Native Client's integration tests work.
572 is_nacl_unrestricted = true;
573 }
574 if (is_nacl_plugin || is_nacl_mime_type) {
575 GURL manifest_url;
576 GURL app_url;
577 if (is_nacl_mime_type) {
578 // Normal NaCl embed. The app URL is the page URL.
579 manifest_url = url;
580 app_url = frame->top()->document().url();
581 } else {
582 // NaCl is being invoked as a content handler. Look up the NaCl
583 // module using the MIME type. The app URL is the manifest URL.
584 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin);
585 app_url = manifest_url;
586 }
587 const Extension* extension =
588 g_current_client->extension_dispatcher_->extensions()->
589 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url));
590 if (!IsNaClAllowed(manifest_url,
591 app_url,
592 is_nacl_unrestricted,
593 extension,
594 &params)) {
595 frame->addMessageToConsole( 564 frame->addMessageToConsole(
596 WebConsoleMessage( 565 WebConsoleMessage(
597 WebConsoleMessage::LevelError, 566 WebConsoleMessage::LevelError,
598 "Only unpacked extensions and apps installed from the " 567 "Portable Native Client must be enabled in about:flags."));
599 "Chrome Web Store can load NaCl modules without enabling "
600 "Native Client in about:flags."));
601 placeholder = PluginPlaceholder::CreateBlockedPlugin( 568 placeholder = PluginPlaceholder::CreateBlockedPlugin(
602 render_view, frame, params, plugin, identifier, group_name, 569 render_view, frame, params, plugin, identifier, group_name,
603 IDR_BLOCKED_PLUGIN_HTML, 570 IDR_BLOCKED_PLUGIN_HTML,
604 #if defined(OS_CHROMEOS) 571 #if defined(OS_CHROMEOS)
605 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); 572 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
jvoung (off chromium) 2013/06/06 22:41:25 Hmm, I guess the message is pretty generic (doesn'
sehr 2013/06/07 23:34:47 I was hoping you'd say that :-). I will change it
606 #else 573 #else
607 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); 574 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
608 #endif 575 #endif
609 break; 576 break;
577 }
578 } else {
579 const char* kNaClMimeType = "application/x-nacl";
580 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType;
581 const bool is_nacl_plugin =
582 plugin.name ==
583 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName);
584 bool is_nacl_unrestricted;
585 if (is_nacl_plugin) {
586 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch(
587 switches::kEnableNaCl);
588 } else {
589 // If this is an external plugin that handles the NaCl mime type, we
590 // allow Native Client, so Native Client's integration tests work.
591 is_nacl_unrestricted = true;
592 }
593 if (is_nacl_plugin || is_nacl_mime_type) {
594 GURL manifest_url;
595 GURL app_url;
596 if (is_nacl_mime_type) {
597 // Normal NaCl embed. The app URL is the page URL.
598 manifest_url = url;
599 app_url = frame->top()->document().url();
600 } else {
601 // NaCl is being invoked as a content handler. Look up the NaCl
602 // module using the MIME type. The app URL is the manifest URL.
603 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin);
604 app_url = manifest_url;
605 }
606 const Extension* extension =
607 g_current_client->extension_dispatcher_->extensions()->
608 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url));
609 if (!IsNaClAllowed(manifest_url,
610 app_url,
611 is_nacl_unrestricted,
612 extension,
613 &params)) {
614 frame->addMessageToConsole(
615 WebConsoleMessage(
616 WebConsoleMessage::LevelError,
617 "Only unpacked extensions and apps installed from the "
618 "Chrome Web Store can load NaCl modules without enabling "
619 "Native Client in about:flags."));
620 placeholder = PluginPlaceholder::CreateBlockedPlugin(
621 render_view, frame, params, plugin, identifier, group_name,
622 IDR_BLOCKED_PLUGIN_HTML,
623 #if defined(OS_CHROMEOS)
624 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED));
625 #else
626 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
627 #endif
628 break;
629 }
610 } 630 }
611 } 631 }
612 632
613 // Delay loading plugins if prerendering. 633 // Delay loading plugins if prerendering.
614 // TODO(mmenke): In the case of prerendering, feed into 634 // TODO(mmenke): In the case of prerendering, feed into
615 // ChromeContentRendererClient::CreatePlugin instead, to 635 // ChromeContentRendererClient::CreatePlugin instead, to
616 // reduce the chance of future regressions. 636 // reduce the chance of future regressions.
617 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { 637 if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
618 placeholder = PluginPlaceholder::CreateBlockedPlugin( 638 placeholder = PluginPlaceholder::CreateBlockedPlugin(
619 render_view, frame, params, plugin, identifier, group_name, 639 render_view, frame, params, plugin, identifier, group_name,
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 1214
1195 if (container->element().shadowHost().isNull()) 1215 if (container->element().shadowHost().isNull())
1196 return false; 1216 return false;
1197 1217
1198 WebString tag_name = container->element().shadowHost().tagName(); 1218 WebString tag_name = container->element().shadowHost().tagName();
1199 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || 1219 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) ||
1200 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); 1220 tag_name.equals(WebString::fromUTF8(kAdViewTagName));
1201 } 1221 }
1202 1222
1203 } // namespace chrome 1223 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698