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

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

Issue 10823434: [6] Moves CreateVersionFromString to plugin_utils and updates the callers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 2nd CL in series to delete PluginGroup. Created 8 years, 4 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
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_tokenizer.h" 14 #include "base/string_tokenizer.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/plugin_installer.h"
ibraaaa 2012/08/21 17:27:12 Presubmit checks won't pass because of this includ
Bernhard Bauer 2012/08/21 19:14:52 The issue isn't chrome, it's that you're depending
17 #include "chrome/common/child_process_logging.h" 18 #include "chrome/common/child_process_logging.h"
18 #include "chrome/common/chrome_content_client.h" 19 #include "chrome/common/chrome_content_client.h"
19 #include "chrome/common/chrome_paths.h" 20 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/content_settings_pattern.h" 22 #include "chrome/common/content_settings_pattern.h"
22 #include "chrome/common/extensions/extension.h" 23 #include "chrome/common/extensions/extension.h"
23 #include "chrome/common/extensions/extension_constants.h" 24 #include "chrome/common/extensions/extension_constants.h"
24 #include "chrome/common/extensions/extension_process_policy.h" 25 #include "chrome/common/extensions/extension_process_policy.h"
25 #include "chrome/common/extensions/extension_set.h" 26 #include "chrome/common/extensions/extension_set.h"
26 #include "chrome/common/external_ipc_fuzzer.h" 27 #include "chrome/common/external_ipc_fuzzer.h"
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) 384 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN)
384 if (PluginPlaceholder::IsYouTubeURL(url, orig_mime_type)) 385 if (PluginPlaceholder::IsYouTubeURL(url, orig_mime_type))
385 return PluginPlaceholder::CreateMobileYoutubePlugin(render_view, frame, 386 return PluginPlaceholder::CreateMobileYoutubePlugin(render_view, frame,
386 original_params)->plugin(); 387 original_params)->plugin();
387 #endif 388 #endif
388 MissingPluginReporter::GetInstance()->ReportPluginMissing( 389 MissingPluginReporter::GetInstance()->ReportPluginMissing(
389 orig_mime_type, url); 390 orig_mime_type, url);
390 placeholder = PluginPlaceholder::CreateMissingPlugin( 391 placeholder = PluginPlaceholder::CreateMissingPlugin(
391 render_view, frame, original_params); 392 render_view, frame, original_params);
392 } else { 393 } else {
393 scoped_ptr<webkit::npapi::PluginGroup> group( 394 string16 name = PluginInstaller::GetGroupName(plugin);
394 webkit::npapi::PluginList::Singleton()->GetPluginGroup(plugin));
395 string16 name = group->GetGroupName();
396 395
397 // TODO(bauerb): This should be in content/. 396 // TODO(bauerb): This should be in content/.
398 WebPluginParams params(original_params); 397 WebPluginParams params(original_params);
399 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { 398 for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
400 if (plugin.mime_types[i].mime_type == actual_mime_type) { 399 if (plugin.mime_types[i].mime_type == actual_mime_type) {
401 AppendParams(plugin.mime_types[i].additional_param_names, 400 AppendParams(plugin.mime_types[i].additional_param_names,
402 plugin.mime_types[i].additional_param_values, 401 plugin.mime_types[i].additional_param_values,
403 &params.attributeNames, 402 &params.attributeNames,
404 &params.attributeValues); 403 &params.attributeValues);
405 break; 404 break;
(...skipping 10 matching lines...) Expand all
416 ContentSettingsObserver* observer = 415 ContentSettingsObserver* observer =
417 ContentSettingsObserver::Get(render_view); 416 ContentSettingsObserver::Get(render_view);
418 417
419 bool is_nacl_plugin = 418 bool is_nacl_plugin =
420 plugin.name == 419 plugin.name ==
421 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); 420 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName);
422 ContentSettingsType content_type = 421 ContentSettingsType content_type =
423 is_nacl_plugin ? CONTENT_SETTINGS_TYPE_JAVASCRIPT : 422 is_nacl_plugin ? CONTENT_SETTINGS_TYPE_JAVASCRIPT :
424 CONTENT_SETTINGS_TYPE_PLUGINS; 423 CONTENT_SETTINGS_TYPE_PLUGINS;
425 424
425 std::string identifier = PluginInstaller::GetIdentifier(plugin);
426 if ((status_value == 426 if ((status_value ==
427 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || 427 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized ||
428 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || 428 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay ||
429 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && 429 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) &&
430 observer->IsPluginTemporarilyAllowed(group->identifier())) { 430 observer->IsPluginTemporarilyAllowed(identifier)) {
431 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 431 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
432 } 432 }
433 433
434 // Allow full-page plug-ins for click-to-play. 434 // Allow full-page plug-ins for click-to-play.
435 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay && 435 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay &&
436 !frame->parent() && 436 !frame->parent() &&
437 !frame->opener() && 437 !frame->opener() &&
438 frame->document().isPluginDocument()) { 438 frame->document().isPluginDocument()) {
439 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 439 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
440 } 440 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 is_extension_unrestricted, 475 is_extension_unrestricted,
476 is_extension_from_webstore, 476 is_extension_from_webstore,
477 &params)) { 477 &params)) {
478 frame->addMessageToConsole( 478 frame->addMessageToConsole(
479 WebConsoleMessage( 479 WebConsoleMessage(
480 WebConsoleMessage::LevelError, 480 WebConsoleMessage::LevelError,
481 "Only unpacked extensions and apps installed from the " 481 "Only unpacked extensions and apps installed from the "
482 "Chrome Web Store can load NaCl modules without enabling " 482 "Chrome Web Store can load NaCl modules without enabling "
483 "Native Client in about:flags.")); 483 "Native Client in about:flags."));
484 placeholder = PluginPlaceholder::CreateBlockedPlugin( 484 placeholder = PluginPlaceholder::CreateBlockedPlugin(
485 render_view, frame, params, plugin, group->identifier(), name, 485 render_view, frame, params, plugin, identifier, name,
486 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); 486 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED);
487 break; 487 break;
488 } 488 }
489 } 489 }
490 490
491 // Delay loading plugins if prerendering. 491 // Delay loading plugins if prerendering.
492 // TODO(mmenke): In the case of prerendering, feed into 492 // TODO(mmenke): In the case of prerendering, feed into
493 // ChromeContentRendererClient::CreatePlugin instead, to 493 // ChromeContentRendererClient::CreatePlugin instead, to
494 // reduce the chance of future regressions. 494 // reduce the chance of future regressions.
495 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { 495 if (prerender::PrerenderHelper::IsPrerendering(render_view)) {
496 placeholder = PluginPlaceholder::CreateBlockedPlugin( 496 placeholder = PluginPlaceholder::CreateBlockedPlugin(
497 render_view, frame, params, plugin, group->identifier(), name, 497 render_view, frame, params, plugin, identifier, name,
498 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); 498 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD);
499 placeholder->set_blocked_for_prerendering(true); 499 placeholder->set_blocked_for_prerendering(true);
500 placeholder->set_allow_loading(true); 500 placeholder->set_allow_loading(true);
501 break; 501 break;
502 } 502 }
503 503
504 return render_view->CreatePlugin(frame, plugin, params); 504 return render_view->CreatePlugin(frame, plugin, params);
505 } 505 }
506 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { 506 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: {
507 placeholder = PluginPlaceholder::CreateBlockedPlugin( 507 placeholder = PluginPlaceholder::CreateBlockedPlugin(
508 render_view, frame, params, plugin, group->identifier(), name, 508 render_view, frame, params, plugin, identifier, name,
509 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED); 509 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED);
510 break; 510 break;
511 } 511 }
512 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { 512 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: {
513 #if defined(ENABLE_PLUGIN_INSTALLATION) 513 #if defined(ENABLE_PLUGIN_INSTALLATION)
514 placeholder = PluginPlaceholder::CreateBlockedPlugin( 514 placeholder = PluginPlaceholder::CreateBlockedPlugin(
515 render_view, frame, params, plugin, group->identifier(), name, 515 render_view, frame, params, plugin, identifier, name,
516 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); 516 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED);
517 placeholder->set_allow_loading(true); 517 placeholder->set_allow_loading(true);
518 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( 518 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin(
519 render_view->GetRoutingID(), placeholder->CreateRoutingId(), 519 render_view->GetRoutingID(), placeholder->CreateRoutingId(),
520 group->identifier())); 520 identifier));
521 #else 521 #else
522 NOTREACHED(); 522 NOTREACHED();
523 #endif 523 #endif
524 break; 524 break;
525 } 525 }
526 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { 526 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: {
527 placeholder = PluginPlaceholder::CreateBlockedPlugin( 527 placeholder = PluginPlaceholder::CreateBlockedPlugin(
528 render_view, frame, params, plugin, group->identifier(), name, 528 render_view, frame, params, plugin, identifier, name,
529 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); 529 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED);
530 break; 530 break;
531 } 531 }
532 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { 532 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: {
533 placeholder = PluginPlaceholder::CreateBlockedPlugin( 533 placeholder = PluginPlaceholder::CreateBlockedPlugin(
534 render_view, frame, params, plugin, group->identifier(), name, 534 render_view, frame, params, plugin, identifier, name,
535 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED); 535 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED);
536 placeholder->set_allow_loading(true); 536 placeholder->set_allow_loading(true);
537 render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( 537 render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin(
538 render_view->GetRoutingID(), 538 render_view->GetRoutingID(), name, identifier));
539 group->GetGroupName(),
540 group->identifier()));
541 break; 539 break;
542 } 540 }
543 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { 541 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: {
544 placeholder = PluginPlaceholder::CreateBlockedPlugin( 542 placeholder = PluginPlaceholder::CreateBlockedPlugin(
545 render_view, frame, params, plugin, group->identifier(), name, 543 render_view, frame, params, plugin, identifier, name,
546 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); 544 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD);
547 placeholder->set_allow_loading(true); 545 placeholder->set_allow_loading(true);
548 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); 546 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay");
549 observer->DidBlockContentType(content_type, group->identifier()); 547 observer->DidBlockContentType(content_type, identifier);
550 break; 548 break;
551 } 549 }
552 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { 550 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: {
553 placeholder = PluginPlaceholder::CreateBlockedPlugin( 551 placeholder = PluginPlaceholder::CreateBlockedPlugin(
554 render_view, frame, params, plugin, group->identifier(), name, 552 render_view, frame, params, plugin, identifier, name,
555 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); 553 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED);
556 placeholder->set_allow_loading(true); 554 placeholder->set_allow_loading(true);
557 RenderThread::Get()->RecordUserMetrics("Plugin_Blocked"); 555 RenderThread::Get()->RecordUserMetrics("Plugin_Blocked");
558 observer->DidBlockContentType(content_type, group->identifier()); 556 observer->DidBlockContentType(content_type, identifier);
559 break; 557 break;
560 } 558 }
561 } 559 }
562 } 560 }
563 placeholder->SetStatus(status); 561 placeholder->SetStatus(status);
564 return placeholder->plugin(); 562 return placeholder->plugin();
565 } 563 }
566 564
567 // For NaCl content handling plugins, the NaCl manifest is stored in an 565 // For NaCl content handling plugins, the NaCl manifest is stored in an
568 // additonal 'nacl' param associated with the MIME type. 566 // additonal 'nacl' param associated with the MIME type.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { 950 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() {
953 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); 951 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled();
954 } 952 }
955 953
956 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( 954 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories(
957 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { 955 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) {
958 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); 956 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory);
959 } 957 }
960 958
961 } // namespace chrome 959 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698