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

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

Issue 8301006: Packaged (CRX) extensions shouldn't be able to get 'dev' interfaces in NaCl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
« no previous file with comments | « no previous file | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (plugin_setting == CONTENT_SETTING_ALLOW || 410 if (plugin_setting == CONTENT_SETTING_ALLOW ||
411 host_setting == CONTENT_SETTING_ALLOW || 411 host_setting == CONTENT_SETTING_ALLOW ||
412 plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) { 412 plugin.path.value() == webkit::npapi::kDefaultPluginLibraryName) {
413 // Delay loading plugins if prerendering. 413 // Delay loading plugins if prerendering.
414 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { 414 if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
415 return CreatePluginPlaceholder( 415 return CreatePluginPlaceholder(
416 render_view, frame, plugin, params, group.get(), 416 render_view, frame, plugin, params, group.get(),
417 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, true, true); 417 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD, true, true);
418 } 418 }
419 419
420 // Enforce the Chrome WebStore restriction on the Native Client plugin. 420 // If this is the NaCl plugin, get the manifest URL for the app so we can
jam 2011/10/14 22:51:09 this function is already too big, can we move the
bbudge 2011/10/14 23:40:14 Done. It's true, it was turning into a monster.
421 // determine if it's OK to run.
421 if (is_nacl_plugin) { 422 if (is_nacl_plugin) {
422 bool allow_nacl = cmd->HasSwitch(switches::kEnableNaCl); 423 const char* kNaClPluginMimeType = "application/x-nacl";
423 if (!allow_nacl) { 424 const char* kNaClPluginManifestAttribute = "nacl";
424 const char* kNaClPluginMimeType = "application/x-nacl";
425 const char* kNaClPluginManifestAttribute = "nacl";
426 425
427 GURL nexe_url; 426 GURL manifest_url;
428 if (actual_mime_type == kNaClPluginMimeType) { 427 if (actual_mime_type == kNaClPluginMimeType) {
429 nexe_url = url; // Normal embedded NaCl plugin. 428 manifest_url = url; // Normal embedded NaCl plugin.
430 } else { 429 } else {
431 // Content type handling NaCl plugin; the "nacl" param on the 430 // Content type handling NaCl plugin; the "nacl" param on the
432 // MIME type holds the nexe URL. 431 // MIME type holds the nexe URL.
433 string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); 432 string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute);
434 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { 433 for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
435 if (plugin.mime_types[i].mime_type == actual_mime_type) { 434 if (plugin.mime_types[i].mime_type == actual_mime_type) {
436 const webkit::WebPluginMimeType& content_type = 435 const webkit::WebPluginMimeType& content_type =
437 plugin.mime_types[i]; 436 plugin.mime_types[i];
438 for (size_t i = 0; 437 for (size_t i = 0;
439 i < content_type.additional_param_names.size(); ++i) { 438 i < content_type.additional_param_names.size(); ++i) {
440 if (content_type.additional_param_names[i] == nacl_attr) { 439 if (content_type.additional_param_names[i] == nacl_attr) {
441 nexe_url = GURL(content_type.additional_param_values[i]); 440 manifest_url = GURL(content_type.additional_param_values[i]);
442 break; 441 break;
443 }
444 } 442 }
445 break;
446 } 443 }
444 break;
447 } 445 }
448 } 446 }
449
450 // Create the NaCl plugin only if the .nexe is part of an extension
451 // that was installed from the Chrome Web Store, or part of a component
452 // extension, or part of an unpacked extension.
453 const Extension* extension =
454 extension_dispatcher_->extensions()->GetByURL(nexe_url);
455 allow_nacl = extension &&
456 (extension->from_webstore() ||
457 extension->location() == Extension::COMPONENT ||
458 extension->location() == Extension::LOAD);
459 } 447 }
460 448
461 if (!allow_nacl) { 449 // Determine if the manifest URL is part of an extension.
450 const Extension* extension =
451 extension_dispatcher_->extensions()->GetByURL(manifest_url);
452 // Only component, unpacked, and Chrome Web Store extensions are allowed.
453 bool allowed_extension = extension &&
454 (extension->from_webstore() ||
455 extension->location() == Extension::COMPONENT ||
456 extension->location() == Extension::LOAD);
457
458 // Block any other use of NaCl plugin, unless --enable-nacl is set.
459 if (!allowed_extension && !cmd->HasSwitch(switches::kEnableNaCl)) {
462 // TODO(bbudge) Webkit will crash if this is a full-frame plug-in and 460 // TODO(bbudge) Webkit will crash if this is a full-frame plug-in and
463 // we return NULL. Prepare a patch to fix that, and return NULL here. 461 // we return NULL. Prepare a patch to fix that, and return NULL here.
464 return CreatePluginPlaceholder( 462 return CreatePluginPlaceholder(
465 render_view, frame, plugin, params, group.get(), 463 render_view, frame, plugin, params, group.get(),
466 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED, false, false); 464 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED, false, false);
467 } 465 }
466
467 // Allow dev interfaces for non-extension apps.
468 bool allow_dev_interfaces = true;
469 if (allowed_extension) {
470 // Allow dev interfaces for component and unpacked extensions.
471 if (extension->location() != Extension::COMPONENT &&
472 extension->location() != Extension::LOAD) {
473 // Whitelist all other allowed extensions.
474 allow_dev_interfaces =
475 // PDF Viewer plugin
476 (manifest_url.scheme() == "chrome-extension" &&
477 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh");
478 }
479 }
480 WebString dev_attribute = WebString::fromUTF8("@dev");
481 if (allow_dev_interfaces) {
482 std::vector<string16> param_names;
483 std::vector<string16> param_values;
484 param_names.push_back(dev_attribute);
485 param_values.push_back(WebString());
486 AppendParams(
487 param_names,
488 param_values,
489 &params.attributeNames,
490 &params.attributeValues);
491 } else {
492 // If the params somehow contain this special attribute, remove it.
493 size_t attribute_count = params.attributeNames.size();
494 for (size_t i = 0; i < attribute_count; ++i) {
495 if (params.attributeNames[i].equals(dev_attribute))
496 params.attributeNames[i] = WebString();
497 }
498 }
468 } 499 }
469 500
470 return render_view->CreatePlugin(frame, plugin, params); 501 return render_view->CreatePlugin(frame, plugin, params);
471 } 502 }
472 503
473 observer->DidBlockContentType(content_type, resource); 504 observer->DidBlockContentType(content_type, resource);
474 if (plugin_setting == CONTENT_SETTING_ASK) { 505 if (plugin_setting == CONTENT_SETTING_ASK) {
475 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); 506 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay");
476 return CreatePluginPlaceholder( 507 return CreatePluginPlaceholder(
477 render_view, frame, plugin, params, group.get(), 508 render_view, frame, plugin, params, group.get(),
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 if (spellcheck_.get()) 810 if (spellcheck_.get())
780 thread->RemoveObserver(spellcheck_.get()); 811 thread->RemoveObserver(spellcheck_.get());
781 SpellCheck* new_spellcheck = new SpellCheck(); 812 SpellCheck* new_spellcheck = new SpellCheck();
782 if (spellcheck_provider_) 813 if (spellcheck_provider_)
783 spellcheck_provider_->SetSpellCheck(new_spellcheck); 814 spellcheck_provider_->SetSpellCheck(new_spellcheck);
784 spellcheck_.reset(new_spellcheck); 815 spellcheck_.reset(new_spellcheck);
785 thread->AddObserver(new_spellcheck); 816 thread->AddObserver(new_spellcheck);
786 } 817 }
787 818
788 } // namespace chrome 819 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | ppapi/native_client/src/shared/ppapi_proxy/browser_globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698