| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 void RenderView::UserMetricsRecordAction(const std::string& action) { | 558 void RenderView::UserMetricsRecordAction(const std::string& action) { |
| 559 Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action)); | 559 Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action)); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void RenderView::PluginCrashed(const FilePath& plugin_path) { | 562 void RenderView::PluginCrashed(const FilePath& plugin_path) { |
| 563 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 563 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
| 564 } | 564 } |
| 565 | 565 |
| 566 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, | 566 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame, |
| 567 const WebPluginParams& params) { | 567 const WebPluginParams& params) { |
| 568 WebPluginInfo info; | 568 std::vector<WebPluginInfo> info; |
| 569 bool found; | 569 std::vector<ContentSetting> settings; |
| 570 ContentSetting setting; | 570 std::vector<std::string> mime_types; |
| 571 std::string mime_type; | 571 Send(new ViewHostMsg_GetPluginInfoArray( |
| 572 Send(new ViewHostMsg_GetPluginInfo( | 572 params.url, frame->top()->url(), params.mimeType.utf8(), |
| 573 params.url, frame->top()->url(), params.mimeType.utf8(), &found, | 573 &info, &settings, &mime_types)); |
| 574 &info, &setting, &mime_type)); | 574 |
| 575 if (!found || !info.enabled) | 575 // Select the first plugin returned, but only if it's enabled. |
| 576 if (info.empty() || !info[0].enabled) |
| 576 return NULL; | 577 return NULL; |
| 577 scoped_refptr<pepper::PluginModule> pepper_module = | 578 scoped_refptr<pepper::PluginModule> pepper_module = |
| 578 PepperPluginRegistry::GetInstance()->GetModule(info.path); | 579 PepperPluginRegistry::GetInstance()->GetModule(info[0].path); |
| 579 if (pepper_module) | 580 if (pepper_module) |
| 580 return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); | 581 return CreatePepperPlugin(frame, params, info[0].path, pepper_module.get()); |
| 581 else | 582 else |
| 582 return CreateNPAPIPlugin(frame, params, info.path, mime_type); | 583 return CreateNPAPIPlugin(frame, params, info[0].path, mime_types[0]); |
| 583 } | 584 } |
| 584 | 585 |
| 585 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 586 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
| 586 plugin_delegates_.insert(delegate); | 587 plugin_delegates_.insert(delegate); |
| 587 // If the renderer is visible, set initial visibility and focus state. | 588 // If the renderer is visible, set initial visibility and focus state. |
| 588 if (!is_hidden()) { | 589 if (!is_hidden()) { |
| 589 #if defined(OS_MACOSX) | 590 #if defined(OS_MACOSX) |
| 590 delegate->SetContainerVisibility(true); | 591 delegate->SetContainerVisibility(true); |
| 591 if (webview() && webview()->isActive()) | 592 if (webview() && webview()->isActive()) |
| 592 delegate->SetWindowFocus(true); | 593 delegate->SetWindowFocus(true); |
| (...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2357 if (RenderThread::current()) // Will be NULL during unit tests. | 2358 if (RenderThread::current()) // Will be NULL during unit tests. |
| 2358 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); | 2359 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); |
| 2359 | 2360 |
| 2360 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 2361 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
| 2361 } | 2362 } |
| 2362 | 2363 |
| 2363 // WebKit::WebFrameClient ----------------------------------------------------- | 2364 // WebKit::WebFrameClient ----------------------------------------------------- |
| 2364 | 2365 |
| 2365 WebPlugin* RenderView::createPlugin(WebFrame* frame, | 2366 WebPlugin* RenderView::createPlugin(WebFrame* frame, |
| 2366 const WebPluginParams& params) { | 2367 const WebPluginParams& params) { |
| 2367 bool found = false; | 2368 std::vector<ContentSetting> settings; |
| 2368 ContentSetting setting = CONTENT_SETTING_DEFAULT; | |
| 2369 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 2369 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 2370 WebPluginInfo info; | 2370 std::vector<WebPluginInfo> info; |
| 2371 GURL url(params.url); | 2371 GURL url(params.url); |
| 2372 std::string actual_mime_type; | 2372 std::vector<std::string> actual_mime_types; |
| 2373 Send(new ViewHostMsg_GetPluginInfo(url, | 2373 Send(new ViewHostMsg_GetPluginInfoArray(url, |
| 2374 frame->top()->url(), | 2374 frame->top()->url(), |
| 2375 params.mimeType.utf8(), | 2375 params.mimeType.utf8(), |
| 2376 &found, | 2376 &info, |
| 2377 &info, | 2377 &settings, |
| 2378 &setting, | 2378 &actual_mime_types)); |
| 2379 &actual_mime_type)); | |
| 2380 | 2379 |
| 2381 if (!found) | 2380 if (info.empty()) |
| 2382 return NULL; | 2381 return NULL; |
| 2383 DCHECK(setting != CONTENT_SETTING_DEFAULT); | |
| 2384 | 2382 |
| 2385 scoped_ptr<PluginGroup> group(PluginGroup::CopyOrCreatePluginGroup(info)); | 2383 DCHECK(settings[0] != CONTENT_SETTING_DEFAULT); |
| 2386 group->AddPlugin(info, 0); | |
| 2387 | 2384 |
| 2388 if (!info.enabled) { | 2385 scoped_ptr<PluginGroup> group(PluginGroup::CopyOrCreatePluginGroup(info[0])); |
| 2386 group->AddPlugin(info[0], 0); |
| 2387 |
| 2388 if (!info[0].enabled) { |
| 2389 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && | 2389 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && |
| 2390 group->IsVulnerable()) { | 2390 group->IsVulnerable()) { |
| 2391 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, | 2391 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, |
| 2392 group->GetGroupName(), | 2392 group->GetGroupName(), |
| 2393 GURL(group->GetUpdateURL()))); | 2393 GURL(group->GetUpdateURL()))); |
| 2394 return CreateOutdatedPluginPlaceholder(frame, params, group.get()); | 2394 return CreateOutdatedPluginPlaceholder(frame, params, group.get()); |
| 2395 } | 2395 } |
| 2396 return NULL; | 2396 return NULL; |
| 2397 } | 2397 } |
| 2398 | 2398 |
| 2399 if (info.path.value() == kDefaultPluginLibraryName || | 2399 if (info[0].path.value() == kDefaultPluginLibraryName || |
| 2400 setting == CONTENT_SETTING_ALLOW) { | 2400 settings[0] == CONTENT_SETTING_ALLOW) { |
| 2401 scoped_refptr<pepper::PluginModule> pepper_module = | 2401 scoped_refptr<pepper::PluginModule> pepper_module = |
| 2402 PepperPluginRegistry::GetInstance()->GetModule(info.path); | 2402 PepperPluginRegistry::GetInstance()->GetModule(info[0].path); |
| 2403 if (pepper_module) { | 2403 if (pepper_module) { |
| 2404 return CreatePepperPlugin(frame, | 2404 return CreatePepperPlugin(frame, |
| 2405 params, | 2405 params, |
| 2406 info.path, | 2406 info[0].path, |
| 2407 pepper_module.get()); | 2407 pepper_module.get()); |
| 2408 } | 2408 } |
| 2409 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); | 2409 return CreateNPAPIPlugin(frame, params, info[0].path, actual_mime_types[0]); |
| 2410 } | 2410 } |
| 2411 std::string resource; | 2411 std::string resource; |
| 2412 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) | 2412 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) |
| 2413 resource = group->identifier(); | 2413 resource = group->identifier(); |
| 2414 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); | 2414 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); |
| 2415 int resource_id; | 2415 int resource_id; |
| 2416 int message_id; | 2416 int message_id; |
| 2417 if (setting == CONTENT_SETTING_ASK) { | 2417 if (settings[0] == CONTENT_SETTING_ASK) { |
| 2418 resource_id = IDR_BLOCKED_PLUGIN_HTML; | 2418 resource_id = IDR_BLOCKED_PLUGIN_HTML; |
| 2419 message_id = IDS_PLUGIN_LOAD; | 2419 message_id = IDS_PLUGIN_LOAD; |
| 2420 } else { | 2420 } else { |
| 2421 resource_id = IDR_OUTDATED_PLUGIN_HTML; | 2421 resource_id = IDR_OUTDATED_PLUGIN_HTML; |
| 2422 message_id = IDS_PLUGIN_BLOCKED; | 2422 message_id = IDS_PLUGIN_BLOCKED; |
| 2423 } | 2423 } |
| 2424 |
| 2424 // |blocked_plugin| will delete itself when the WebViewPlugin | 2425 // |blocked_plugin| will delete itself when the WebViewPlugin |
| 2425 // is destroyed. | 2426 // is destroyed. |
| 2426 BlockedPlugin* blocked_plugin = | 2427 BlockedPlugin* blocked_plugin = |
| 2427 new BlockedPlugin(this, | 2428 new BlockedPlugin(this, |
| 2428 frame, | 2429 frame, |
| 2429 params, | 2430 params, |
| 2430 webkit_preferences_, | 2431 webkit_preferences_, |
| 2431 resource_id, | 2432 resource_id, |
| 2432 l10n_util::GetStringUTF16(message_id)); | 2433 l10n_util::GetStringUTF16(message_id)); |
| 2433 return blocked_plugin->plugin(); | 2434 return blocked_plugin->plugin(); |
| (...skipping 1609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4043 const FilePath& path, | 4044 const FilePath& path, |
| 4044 pepper::PluginModule* pepper_module) { | 4045 pepper::PluginModule* pepper_module) { |
| 4045 return new pepper::WebPluginImpl( | 4046 return new pepper::WebPluginImpl( |
| 4046 pepper_module, params, pepper_delegate_.AsWeakPtr()); | 4047 pepper_module, params, pepper_delegate_.AsWeakPtr()); |
| 4047 } | 4048 } |
| 4048 | 4049 |
| 4049 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, | 4050 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, |
| 4050 const WebPluginParams& params, | 4051 const WebPluginParams& params, |
| 4051 const FilePath& path, | 4052 const FilePath& path, |
| 4052 const std::string& mime_type) { | 4053 const std::string& mime_type) { |
| 4053 std::string actual_mime_type(mime_type); | 4054 return new webkit_glue::WebPluginImpl( |
| 4054 if (actual_mime_type.empty()) | 4055 frame, params, path, mime_type, AsWeakPtr()); |
| 4055 actual_mime_type = params.mimeType.utf8(); | |
| 4056 | |
| 4057 return new webkit_glue::WebPluginImpl(frame, params, path, | |
| 4058 actual_mime_type, AsWeakPtr()); | |
| 4059 } | 4056 } |
| 4060 | 4057 |
| 4061 WebPlugin* RenderView::CreateOutdatedPluginPlaceholder( | 4058 WebPlugin* RenderView::CreateOutdatedPluginPlaceholder( |
| 4062 WebFrame* frame, | 4059 WebFrame* frame, |
| 4063 const WebPluginParams& params, | 4060 const WebPluginParams& params, |
| 4064 PluginGroup* group) { | 4061 PluginGroup* group) { |
| 4065 int resource_id = IDR_OUTDATED_PLUGIN_HTML; | 4062 int resource_id = IDR_OUTDATED_PLUGIN_HTML; |
| 4066 const base::StringPiece template_html( | 4063 const base::StringPiece template_html( |
| 4067 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); | 4064 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); |
| 4068 | 4065 |
| (...skipping 1882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5951 } | 5948 } |
| 5952 | 5949 |
| 5953 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, | 5950 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, |
| 5954 IPC::PlatformFileForTransit file_for_transit, | 5951 IPC::PlatformFileForTransit file_for_transit, |
| 5955 int message_id) { | 5952 int message_id) { |
| 5956 pepper_delegate_.OnAsyncFileOpened( | 5953 pepper_delegate_.OnAsyncFileOpened( |
| 5957 error_code, | 5954 error_code, |
| 5958 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), | 5955 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| 5959 message_id); | 5956 message_id); |
| 5960 } | 5957 } |
| OLD | NEW |