OLD | NEW |
---|---|
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 Loading... | |
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 |
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 allow_dev_interfaces = true; | |
sehr
2011/10/14 21:38:32
You initialized allow_dev_interfaces to true, so t
bbudge
2011/10/14 22:03:27
Done.
| |
474 } else { | |
475 // Whitelist extensions from the Chrome Web Store. | |
476 allow_dev_interfaces = | |
477 // PDF Viewer plugin | |
478 (manifest_url.scheme() == "chrome-extension" && | |
479 manifest_url.host() == "acadkphlmlegjaadjagenfimbpphcgnh"); | |
480 } | |
481 } | |
482 if (allow_dev_interfaces) { | |
483 std::vector<string16> param_names; | |
484 std::vector<string16> param_values; | |
485 param_names.push_back(ASCIIToUTF16("@dev")); | |
486 param_values.push_back(ASCIIToUTF16("")); | |
487 AppendParams( | |
488 param_names, | |
489 param_values, | |
490 ¶ms.attributeNames, | |
491 ¶ms.attributeValues); | |
492 } | |
468 } | 493 } |
469 | 494 |
470 return render_view->CreatePlugin(frame, plugin, params); | 495 return render_view->CreatePlugin(frame, plugin, params); |
471 } | 496 } |
472 | 497 |
473 observer->DidBlockContentType(content_type, resource); | 498 observer->DidBlockContentType(content_type, resource); |
474 if (plugin_setting == CONTENT_SETTING_ASK) { | 499 if (plugin_setting == CONTENT_SETTING_ASK) { |
475 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); | 500 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); |
476 return CreatePluginPlaceholder( | 501 return CreatePluginPlaceholder( |
477 render_view, frame, plugin, params, group.get(), | 502 render_view, frame, plugin, params, group.get(), |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
779 if (spellcheck_.get()) | 804 if (spellcheck_.get()) |
780 thread->RemoveObserver(spellcheck_.get()); | 805 thread->RemoveObserver(spellcheck_.get()); |
781 SpellCheck* new_spellcheck = new SpellCheck(); | 806 SpellCheck* new_spellcheck = new SpellCheck(); |
782 if (spellcheck_provider_) | 807 if (spellcheck_provider_) |
783 spellcheck_provider_->SetSpellCheck(new_spellcheck); | 808 spellcheck_provider_->SetSpellCheck(new_spellcheck); |
784 spellcheck_.reset(new_spellcheck); | 809 spellcheck_.reset(new_spellcheck); |
785 thread->AddObserver(new_spellcheck); | 810 thread->AddObserver(new_spellcheck); |
786 } | 811 } |
787 | 812 |
788 } // namespace chrome | 813 } // namespace chrome |
OLD | NEW |