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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 the params somehow contain '@dev', remove it. |
jvoung (off chromium)
2013/06/04 22:27:25
Where do the @dev params come from?
Should we add
sehr
2013/06/06 22:03:45
The @dev parameters are added for nacl content han
| |
563 plugin.name == | 563 WebString dev_attribute = WebString::fromUTF8("@dev"); |
564 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); | 564 size_t attribute_count = params.attributeNames.size(); |
565 bool is_nacl_unrestricted; | 565 for (size_t i = 0; i < attribute_count; ++i) { |
jvoung (off chromium)
2013/06/07 16:14:46
Also, if you want to allow PNaCl without --enable-
| |
566 if (is_nacl_plugin) { | 566 if (params.attributeNames[i].equals(dev_attribute)) |
567 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch( | 567 params.attributeNames[i] = WebString(); |
568 switches::kEnableNaCl); | 568 } |
569 } else { | 569 } else { |
570 // If this is an external plugin that handles the NaCl mime type, we | 570 const char* kNaClMimeType = "application/x-nacl"; |
571 // allow Native Client, so Native Client's integration tests work. | 571 const bool is_nacl_mime_type = actual_mime_type == kNaClMimeType; |
572 is_nacl_unrestricted = true; | 572 const bool is_nacl_plugin = |
573 } | 573 plugin.name == |
574 if (is_nacl_plugin || is_nacl_mime_type) { | 574 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); |
575 GURL manifest_url; | 575 bool is_nacl_unrestricted; |
576 GURL app_url; | 576 if (is_nacl_plugin) { |
577 if (is_nacl_mime_type) { | 577 is_nacl_unrestricted = CommandLine::ForCurrentProcess()->HasSwitch( |
578 // Normal NaCl embed. The app URL is the page URL. | 578 switches::kEnableNaCl); |
579 manifest_url = url; | |
580 app_url = frame->top()->document().url(); | |
581 } else { | 579 } else { |
582 // NaCl is being invoked as a content handler. Look up the NaCl | 580 // If this is an external plugin that handles the NaCl mime type, we |
583 // module using the MIME type. The app URL is the manifest URL. | 581 // allow Native Client, so Native Client's integration tests work. |
584 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); | 582 is_nacl_unrestricted = true; |
585 app_url = manifest_url; | |
586 } | 583 } |
587 const Extension* extension = | 584 if (is_nacl_plugin || is_nacl_mime_type) { |
588 g_current_client->extension_dispatcher_->extensions()-> | 585 GURL manifest_url; |
589 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url)); | 586 GURL app_url; |
590 if (!IsNaClAllowed(manifest_url, | 587 if (is_nacl_mime_type) { |
591 app_url, | 588 // Normal NaCl embed. The app URL is the page URL. |
592 is_nacl_unrestricted, | 589 manifest_url = url; |
593 extension, | 590 app_url = frame->top()->document().url(); |
594 ¶ms)) { | 591 } else { |
595 frame->addMessageToConsole( | 592 // NaCl is being invoked as a content handler. Look up the NaCl |
596 WebConsoleMessage( | 593 // module using the MIME type. The app URL is the manifest URL. |
597 WebConsoleMessage::LevelError, | 594 manifest_url = GetNaClContentHandlerURL(actual_mime_type, plugin); |
598 "Only unpacked extensions and apps installed from the " | 595 app_url = manifest_url; |
599 "Chrome Web Store can load NaCl modules without enabling " | 596 } |
600 "Native Client in about:flags.")); | 597 const Extension* extension = |
601 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 598 g_current_client->extension_dispatcher_->extensions()-> |
602 render_view, frame, params, plugin, identifier, group_name, | 599 GetExtensionOrAppByURL(ExtensionURLInfo(manifest_url)); |
603 IDR_BLOCKED_PLUGIN_HTML, | 600 if (!IsNaClAllowed(manifest_url, |
601 app_url, | |
602 is_nacl_unrestricted, | |
603 extension, | |
604 ¶ms)) { | |
605 frame->addMessageToConsole( | |
606 WebConsoleMessage( | |
607 WebConsoleMessage::LevelError, | |
608 "Only unpacked extensions and apps installed from the " | |
609 "Chrome Web Store can load NaCl modules without enabling " | |
610 "Native Client in about:flags.")); | |
611 placeholder = PluginPlaceholder::CreateBlockedPlugin( | |
612 render_view, frame, params, plugin, identifier, group_name, | |
613 IDR_BLOCKED_PLUGIN_HTML, | |
604 #if defined(OS_CHROMEOS) | 614 #if defined(OS_CHROMEOS) |
605 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); | 615 l10n_util::GetStringUTF16(IDS_NACL_PLUGIN_BLOCKED)); |
606 #else | 616 #else |
607 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); | 617 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name)); |
608 #endif | 618 #endif |
609 break; | 619 break; |
620 } | |
610 } | 621 } |
611 } | 622 } |
612 | 623 |
613 // Delay loading plugins if prerendering. | 624 // Delay loading plugins if prerendering. |
614 // TODO(mmenke): In the case of prerendering, feed into | 625 // TODO(mmenke): In the case of prerendering, feed into |
615 // ChromeContentRendererClient::CreatePlugin instead, to | 626 // ChromeContentRendererClient::CreatePlugin instead, to |
616 // reduce the chance of future regressions. | 627 // reduce the chance of future regressions. |
617 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { | 628 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { |
618 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 629 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
619 render_view, frame, params, plugin, identifier, group_name, | 630 render_view, frame, params, plugin, identifier, group_name, |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 | 1205 |
1195 if (container->element().shadowHost().isNull()) | 1206 if (container->element().shadowHost().isNull()) |
1196 return false; | 1207 return false; |
1197 | 1208 |
1198 WebString tag_name = container->element().shadowHost().tagName(); | 1209 WebString tag_name = container->element().shadowHost().tagName(); |
1199 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || | 1210 return tag_name.equals(WebString::fromUTF8(kWebViewTagName)) || |
1200 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); | 1211 tag_name.equals(WebString::fromUTF8(kAdViewTagName)); |
1201 } | 1212 } |
1202 | 1213 |
1203 } // namespace chrome | 1214 } // namespace chrome |
OLD | NEW |