| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 304 |
| 305 std::string ChromeContentRendererClient::GetDefaultEncoding() { | 305 std::string ChromeContentRendererClient::GetDefaultEncoding() { |
| 306 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); | 306 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); |
| 307 } | 307 } |
| 308 | 308 |
| 309 bool ChromeContentRendererClient::OverrideCreatePlugin( | 309 bool ChromeContentRendererClient::OverrideCreatePlugin( |
| 310 content::RenderView* render_view, | 310 content::RenderView* render_view, |
| 311 WebFrame* frame, | 311 WebFrame* frame, |
| 312 const WebPluginParams& params, | 312 const WebPluginParams& params, |
| 313 WebPlugin** plugin) { | 313 WebPlugin** plugin) { |
| 314 ChromeViewHostMsg_GetPluginInfo_Status status; | |
| 315 webkit::WebPluginInfo plugin_info; | |
| 316 std::string actual_mime_type; | |
| 317 std::string orig_mime_type = params.mimeType.utf8(); | 314 std::string orig_mime_type = params.mimeType.utf8(); |
| 318 | |
| 319 if (orig_mime_type == content::kBrowserPluginNewMimeType || | 315 if (orig_mime_type == content::kBrowserPluginNewMimeType || |
| 320 ((orig_mime_type == content::kBrowserPluginMimeType) && | 316 ((orig_mime_type == content::kBrowserPluginMimeType) && |
| 321 extensions::ExtensionHelper::Get(render_view)->view_type() == | 317 extensions::ExtensionHelper::Get(render_view)->view_type() == |
| 322 VIEW_TYPE_APP_SHELL)) { | 318 VIEW_TYPE_APP_SHELL)) { |
| 323 return false; | 319 return false; |
| 324 } | 320 } |
| 325 | 321 |
| 322 ChromeViewHostMsg_GetPluginInfo_Output output; |
| 326 render_view->Send(new ChromeViewHostMsg_GetPluginInfo( | 323 render_view->Send(new ChromeViewHostMsg_GetPluginInfo( |
| 327 render_view->GetRoutingID(), GURL(params.url), | 324 render_view->GetRoutingID(), GURL(params.url), |
| 328 frame->top()->document().url(), orig_mime_type, | 325 frame->top()->document().url(), orig_mime_type, &output)); |
| 329 &status, &plugin_info, &actual_mime_type)); | 326 *plugin = CreatePlugin(render_view, frame, params, output); |
| 330 *plugin = CreatePlugin(render_view, frame, params, | |
| 331 status, plugin_info, actual_mime_type); | |
| 332 return true; | 327 return true; |
| 333 } | 328 } |
| 334 | 329 |
| 335 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( | 330 WebPlugin* ChromeContentRendererClient::CreatePluginReplacement( |
| 336 content::RenderView* render_view, | 331 content::RenderView* render_view, |
| 337 const FilePath& plugin_path) { | 332 const FilePath& plugin_path) { |
| 338 PluginPlaceholder* placeholder = | 333 PluginPlaceholder* placeholder = |
| 339 PluginPlaceholder::CreateErrorPlugin(render_view, plugin_path); | 334 PluginPlaceholder::CreateErrorPlugin(render_view, plugin_path); |
| 340 return placeholder->plugin(); | 335 return placeholder->plugin(); |
| 341 } | 336 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 362 return new prerender::PrerenderWebMediaPlayer(render_view, frame, client, | 357 return new prerender::PrerenderWebMediaPlayer(render_view, frame, client, |
| 363 delegate, collection, audio_source_provider, audio_renderer_sink, | 358 delegate, collection, audio_source_provider, audio_renderer_sink, |
| 364 message_loop_factory, media_stream_client, media_log); | 359 message_loop_factory, media_stream_client, media_log); |
| 365 #endif | 360 #endif |
| 366 } | 361 } |
| 367 | 362 |
| 368 WebPlugin* ChromeContentRendererClient::CreatePlugin( | 363 WebPlugin* ChromeContentRendererClient::CreatePlugin( |
| 369 content::RenderView* render_view, | 364 content::RenderView* render_view, |
| 370 WebFrame* frame, | 365 WebFrame* frame, |
| 371 const WebPluginParams& original_params, | 366 const WebPluginParams& original_params, |
| 372 const ChromeViewHostMsg_GetPluginInfo_Status& status, | 367 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
| 373 const webkit::WebPluginInfo& plugin, | 368 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; |
| 374 const std::string& actual_mime_type) { | 369 const webkit::WebPluginInfo& plugin = output.plugin; |
| 370 const std::string& actual_mime_type = output.actual_mime_type; |
| 371 const string16& group_name = output.group_name; |
| 372 const std::string& identifier = output.group_identifier; |
| 375 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; | 373 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; |
| 376 GURL url(original_params.url); | 374 GURL url(original_params.url); |
| 377 std::string orig_mime_type = original_params.mimeType.utf8(); | 375 std::string orig_mime_type = original_params.mimeType.utf8(); |
| 378 PluginPlaceholder* placeholder = NULL; | 376 PluginPlaceholder* placeholder = NULL; |
| 379 | 377 |
| 380 // If the browser plugin is to be enabled, this should be handled by the | 378 // If the browser plugin is to be enabled, this should be handled by the |
| 381 // renderer, so the code won't reach here due to the early exit in | 379 // renderer, so the code won't reach here due to the early exit in |
| 382 // OverrideCreatePlugin. | 380 // OverrideCreatePlugin. |
| 383 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || | 381 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || |
| 384 orig_mime_type == content::kBrowserPluginMimeType) { | 382 orig_mime_type == content::kBrowserPluginMimeType) { |
| 385 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) | 383 #if defined(ENABLE_MOBILE_YOUTUBE_PLUGIN) |
| 386 if (PluginPlaceholder::IsYouTubeURL(url, orig_mime_type)) | 384 if (PluginPlaceholder::IsYouTubeURL(url, orig_mime_type)) |
| 387 return PluginPlaceholder::CreateMobileYoutubePlugin(render_view, frame, | 385 return PluginPlaceholder::CreateMobileYoutubePlugin(render_view, frame, |
| 388 original_params)->plugin(); | 386 original_params)->plugin(); |
| 389 #endif | 387 #endif |
| 390 MissingPluginReporter::GetInstance()->ReportPluginMissing( | 388 MissingPluginReporter::GetInstance()->ReportPluginMissing( |
| 391 orig_mime_type, url); | 389 orig_mime_type, url); |
| 392 placeholder = PluginPlaceholder::CreateMissingPlugin( | 390 placeholder = PluginPlaceholder::CreateMissingPlugin( |
| 393 render_view, frame, original_params); | 391 render_view, frame, original_params); |
| 394 } else { | 392 } else { |
| 395 scoped_ptr<webkit::npapi::PluginGroup> group( | |
| 396 webkit::npapi::PluginList::Singleton()->GetPluginGroup(plugin)); | |
| 397 string16 name = group->GetGroupName(); | |
| 398 | |
| 399 // TODO(bauerb): This should be in content/. | 393 // TODO(bauerb): This should be in content/. |
| 400 WebPluginParams params(original_params); | 394 WebPluginParams params(original_params); |
| 401 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 395 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
| 402 if (plugin.mime_types[i].mime_type == actual_mime_type) { | 396 if (plugin.mime_types[i].mime_type == actual_mime_type) { |
| 403 AppendParams(plugin.mime_types[i].additional_param_names, | 397 AppendParams(plugin.mime_types[i].additional_param_names, |
| 404 plugin.mime_types[i].additional_param_values, | 398 plugin.mime_types[i].additional_param_values, |
| 405 ¶ms.attributeNames, | 399 ¶ms.attributeNames, |
| 406 ¶ms.attributeValues); | 400 ¶ms.attributeValues); |
| 407 break; | 401 break; |
| 408 } | 402 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 422 plugin.name == | 416 plugin.name == |
| 423 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); | 417 ASCIIToUTF16(chrome::ChromeContentClient::kNaClPluginName); |
| 424 ContentSettingsType content_type = | 418 ContentSettingsType content_type = |
| 425 is_nacl_plugin ? CONTENT_SETTINGS_TYPE_JAVASCRIPT : | 419 is_nacl_plugin ? CONTENT_SETTINGS_TYPE_JAVASCRIPT : |
| 426 CONTENT_SETTINGS_TYPE_PLUGINS; | 420 CONTENT_SETTINGS_TYPE_PLUGINS; |
| 427 | 421 |
| 428 if ((status_value == | 422 if ((status_value == |
| 429 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || | 423 ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized || |
| 430 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || | 424 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay || |
| 431 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && | 425 status_value == ChromeViewHostMsg_GetPluginInfo_Status::kBlocked) && |
| 432 observer->IsPluginTemporarilyAllowed(group->identifier())) { | 426 observer->IsPluginTemporarilyAllowed(identifier)) { |
| 433 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; | 427 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; |
| 434 } | 428 } |
| 435 | 429 |
| 436 // Allow full-page plug-ins for click-to-play. | 430 // Allow full-page plug-ins for click-to-play. |
| 437 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay && | 431 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay && |
| 438 !frame->parent() && | 432 !frame->parent() && |
| 439 !frame->opener() && | 433 !frame->opener() && |
| 440 frame->document().isPluginDocument()) { | 434 frame->document().isPluginDocument()) { |
| 441 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; | 435 status_value = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; |
| 442 } | 436 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 is_extension_unrestricted, | 471 is_extension_unrestricted, |
| 478 is_extension_from_webstore, | 472 is_extension_from_webstore, |
| 479 ¶ms)) { | 473 ¶ms)) { |
| 480 frame->addMessageToConsole( | 474 frame->addMessageToConsole( |
| 481 WebConsoleMessage( | 475 WebConsoleMessage( |
| 482 WebConsoleMessage::LevelError, | 476 WebConsoleMessage::LevelError, |
| 483 "Only unpacked extensions and apps installed from the " | 477 "Only unpacked extensions and apps installed from the " |
| 484 "Chrome Web Store can load NaCl modules without enabling " | 478 "Chrome Web Store can load NaCl modules without enabling " |
| 485 "Native Client in about:flags.")); | 479 "Native Client in about:flags.")); |
| 486 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 480 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 487 render_view, frame, params, plugin, group->identifier(), name, | 481 render_view, frame, params, plugin, identifier, group_name, |
| 488 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); | 482 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); |
| 489 break; | 483 break; |
| 490 } | 484 } |
| 491 } | 485 } |
| 492 | 486 |
| 493 // Delay loading plugins if prerendering. | 487 // Delay loading plugins if prerendering. |
| 494 // TODO(mmenke): In the case of prerendering, feed into | 488 // TODO(mmenke): In the case of prerendering, feed into |
| 495 // ChromeContentRendererClient::CreatePlugin instead, to | 489 // ChromeContentRendererClient::CreatePlugin instead, to |
| 496 // reduce the chance of future regressions. | 490 // reduce the chance of future regressions. |
| 497 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { | 491 if (prerender::PrerenderHelper::IsPrerendering(render_view)) { |
| 498 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 492 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 499 render_view, frame, params, plugin, group->identifier(), name, | 493 render_view, frame, params, plugin, identifier, group_name, |
| 500 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); | 494 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); |
| 501 placeholder->set_blocked_for_prerendering(true); | 495 placeholder->set_blocked_for_prerendering(true); |
| 502 placeholder->set_allow_loading(true); | 496 placeholder->set_allow_loading(true); |
| 503 break; | 497 break; |
| 504 } | 498 } |
| 505 | 499 |
| 506 return render_view->CreatePlugin(frame, plugin, params); | 500 return render_view->CreatePlugin(frame, plugin, params); |
| 507 } | 501 } |
| 508 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { | 502 case ChromeViewHostMsg_GetPluginInfo_Status::kDisabled: { |
| 509 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 503 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 510 render_view, frame, params, plugin, group->identifier(), name, | 504 render_view, frame, params, plugin, identifier, group_name, |
| 511 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED); | 505 IDR_DISABLED_PLUGIN_HTML, IDS_PLUGIN_DISABLED); |
| 512 break; | 506 break; |
| 513 } | 507 } |
| 514 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { | 508 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { |
| 515 #if defined(ENABLE_PLUGIN_INSTALLATION) | 509 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 516 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 510 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 517 render_view, frame, params, plugin, group->identifier(), name, | 511 render_view, frame, params, plugin, identifier, group_name, |
| 518 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); | 512 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); |
| 519 placeholder->set_allow_loading(true); | 513 placeholder->set_allow_loading(true); |
| 520 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( | 514 render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( |
| 521 render_view->GetRoutingID(), placeholder->CreateRoutingId(), | 515 render_view->GetRoutingID(), placeholder->CreateRoutingId(), |
| 522 group->identifier())); | 516 identifier)); |
| 523 #else | 517 #else |
| 524 NOTREACHED(); | 518 NOTREACHED(); |
| 525 #endif | 519 #endif |
| 526 break; | 520 break; |
| 527 } | 521 } |
| 528 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { | 522 case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { |
| 529 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 523 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 530 render_view, frame, params, plugin, group->identifier(), name, | 524 render_view, frame, params, plugin, identifier, group_name, |
| 531 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); | 525 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); |
| 532 break; | 526 break; |
| 533 } | 527 } |
| 534 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { | 528 case ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized: { |
| 535 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 529 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 536 render_view, frame, params, plugin, group->identifier(), name, | 530 render_view, frame, params, plugin, identifier, group_name, |
| 537 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED); | 531 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_NOT_AUTHORIZED); |
| 538 placeholder->set_allow_loading(true); | 532 placeholder->set_allow_loading(true); |
| 539 render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( | 533 render_view->Send(new ChromeViewHostMsg_BlockedUnauthorizedPlugin( |
| 540 render_view->GetRoutingID(), | 534 render_view->GetRoutingID(), |
| 541 group->GetGroupName(), | 535 group_name, |
| 542 group->identifier())); | 536 identifier)); |
| 543 break; | 537 break; |
| 544 } | 538 } |
| 545 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { | 539 case ChromeViewHostMsg_GetPluginInfo_Status::kClickToPlay: { |
| 546 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 540 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 547 render_view, frame, params, plugin, group->identifier(), name, | 541 render_view, frame, params, plugin, identifier, group_name, |
| 548 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); | 542 IDR_CLICK_TO_PLAY_PLUGIN_HTML, IDS_PLUGIN_LOAD); |
| 549 placeholder->set_allow_loading(true); | 543 placeholder->set_allow_loading(true); |
| 550 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); | 544 RenderThread::Get()->RecordUserMetrics("Plugin_ClickToPlay"); |
| 551 observer->DidBlockContentType(content_type, group->identifier()); | 545 observer->DidBlockContentType(content_type, identifier); |
| 552 break; | 546 break; |
| 553 } | 547 } |
| 554 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { | 548 case ChromeViewHostMsg_GetPluginInfo_Status::kBlocked: { |
| 555 placeholder = PluginPlaceholder::CreateBlockedPlugin( | 549 placeholder = PluginPlaceholder::CreateBlockedPlugin( |
| 556 render_view, frame, params, plugin, group->identifier(), name, | 550 render_view, frame, params, plugin, identifier, group_name, |
| 557 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); | 551 IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_BLOCKED); |
| 558 placeholder->set_allow_loading(true); | 552 placeholder->set_allow_loading(true); |
| 559 RenderThread::Get()->RecordUserMetrics("Plugin_Blocked"); | 553 RenderThread::Get()->RecordUserMetrics("Plugin_Blocked"); |
| 560 observer->DidBlockContentType(content_type, group->identifier()); | 554 observer->DidBlockContentType(content_type, identifier); |
| 561 break; | 555 break; |
| 562 } | 556 } |
| 563 } | 557 } |
| 564 } | 558 } |
| 565 placeholder->SetStatus(status); | 559 placeholder->SetStatus(status); |
| 566 return placeholder->plugin(); | 560 return placeholder->plugin(); |
| 567 } | 561 } |
| 568 | 562 |
| 569 // For NaCl content handling plugins, the NaCl manifest is stored in an | 563 // For NaCl content handling plugins, the NaCl manifest is stored in an |
| 570 // additonal 'nacl' param associated with the MIME type. | 564 // additonal 'nacl' param associated with the MIME type. |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { | 959 bool ChromeContentRendererClient::IsOtherExtensionWithWebRequestInstalled() { |
| 966 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); | 960 return extension_dispatcher_->IsOtherExtensionWithWebRequestInstalled(); |
| 967 } | 961 } |
| 968 | 962 |
| 969 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( | 963 void ChromeContentRendererClient::RegisterPPAPIInterfaceFactories( |
| 970 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { | 964 webkit::ppapi::PpapiInterfaceFactoryManager* factory_manager) { |
| 971 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); | 965 factory_manager->RegisterFactory(ChromePPAPIInterfaceFactory); |
| 972 } | 966 } |
| 973 | 967 |
| 974 } // namespace chrome | 968 } // namespace chrome |
| OLD | NEW |