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 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2747 &actual_mime_type)); | 2747 &actual_mime_type)); |
2748 | 2748 |
2749 if (!found) | 2749 if (!found) |
2750 return NULL; | 2750 return NULL; |
2751 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); | 2751 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); |
2752 | 2752 |
2753 const PluginGroup* group = | 2753 const PluginGroup* group = |
2754 NPAPI::PluginList::Singleton()->GetPluginGroup(info); | 2754 NPAPI::PluginList::Singleton()->GetPluginGroup(info); |
2755 DCHECK(group != NULL); | 2755 DCHECK(group != NULL); |
2756 | 2756 |
2757 if (!info.enabled) { | 2757 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && |
darin (slow to review)
2010/12/16 17:39:25
i think you should rename the command line switch
Bernhard Bauer
2010/12/16 18:23:04
Done.
| |
2758 if (cmd->HasSwitch(switches::kDisableOutdatedPlugins) && | 2758 group->IsVulnerable()) { |
2759 group->IsVulnerable()) { | 2759 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, |
darin (slow to review)
2010/12/16 17:39:25
nit: change the IPC to BlockedOutdatedPlugin
Bernhard Bauer
2010/12/16 18:23:04
Done.
| |
2760 Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, | 2760 group->GetGroupName(), |
2761 group->GetGroupName(), | 2761 GURL(group->GetUpdateURL()))); |
2762 GURL(group->GetUpdateURL()))); | 2762 return CreatePluginPlaceholder(frame, |
2763 return CreateOutdatedPluginPlaceholder(frame, params, *group); | 2763 params, |
2764 } | 2764 *group, |
2765 IDR_OUTDATED_PLUGIN_HTML, | |
2766 IDS_PLUGIN_OUTDATED); | |
2767 } | |
2768 if (!info.enabled) | |
2765 return NULL; | 2769 return NULL; |
2766 } | |
2767 | 2770 |
2768 ContentSetting host_setting = | 2771 ContentSetting host_setting = |
2769 current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS]; | 2772 current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS]; |
2770 if (info.path.value() == kDefaultPluginLibraryName || | 2773 if (info.path.value() == kDefaultPluginLibraryName || |
2771 plugin_setting == CONTENT_SETTING_ALLOW || | 2774 plugin_setting == CONTENT_SETTING_ALLOW || |
2772 host_setting == CONTENT_SETTING_ALLOW) { | 2775 host_setting == CONTENT_SETTING_ALLOW) { |
2773 scoped_refptr<pepper::PluginModule> pepper_module( | 2776 scoped_refptr<pepper::PluginModule> pepper_module( |
2774 pepper_delegate_.CreatePepperPlugin(info.path)); | 2777 pepper_delegate_.CreatePepperPlugin(info.path)); |
2775 if (pepper_module) | 2778 if (pepper_module) |
2776 return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); | 2779 return CreatePepperPlugin(frame, params, info.path, pepper_module.get()); |
2777 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); | 2780 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); |
2778 } | 2781 } |
2779 std::string resource; | 2782 std::string resource; |
2780 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) | 2783 if (cmd->HasSwitch(switches::kEnableResourceContentSettings)) |
2781 resource = group->identifier(); | 2784 resource = group->identifier(); |
2782 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); | 2785 DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); |
2783 int resource_id; | |
2784 int message_id; | |
2785 if (plugin_setting == CONTENT_SETTING_ASK) { | 2786 if (plugin_setting == CONTENT_SETTING_ASK) { |
2786 resource_id = IDR_BLOCKED_PLUGIN_HTML; | 2787 return CreatePluginPlaceholder(frame, |
2787 message_id = IDS_PLUGIN_LOAD; | 2788 params, |
2789 *group, | |
2790 IDR_BLOCKED_PLUGIN_HTML, | |
2791 IDS_PLUGIN_LOAD); | |
2788 } else { | 2792 } else { |
2789 resource_id = IDR_OUTDATED_PLUGIN_HTML; | 2793 return CreatePluginPlaceholder(frame, |
2790 message_id = IDS_PLUGIN_BLOCKED; | 2794 params, |
2795 *group, | |
2796 IDR_OUTDATED_PLUGIN_HTML, | |
2797 IDS_PLUGIN_BLOCKED); | |
2791 } | 2798 } |
2792 // |blocked_plugin| will delete itself when the WebViewPlugin | |
2793 // is destroyed. | |
2794 BlockedPlugin* blocked_plugin = | |
2795 new BlockedPlugin(this, | |
2796 frame, | |
2797 *group, | |
2798 params, | |
2799 webkit_preferences_, | |
2800 resource_id, | |
2801 l10n_util::GetStringUTF16(message_id)); | |
2802 return blocked_plugin->plugin(); | |
2803 } | 2799 } |
2804 | 2800 |
2805 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 2801 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { |
2806 WebApplicationCacheHostImpl* appcache_host = | 2802 WebApplicationCacheHostImpl* appcache_host = |
2807 WebApplicationCacheHostImpl::FromFrame(frame); | 2803 WebApplicationCacheHostImpl::FromFrame(frame); |
2808 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 2804 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
2809 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, | 2805 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, |
2810 appcache_host_id); | 2806 appcache_host_id); |
2811 } | 2807 } |
2812 | 2808 |
(...skipping 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4424 } | 4420 } |
4425 | 4421 |
4426 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, | 4422 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, |
4427 const WebPluginParams& params, | 4423 const WebPluginParams& params, |
4428 const FilePath& path, | 4424 const FilePath& path, |
4429 const std::string& mime_type) { | 4425 const std::string& mime_type) { |
4430 return new webkit_glue::WebPluginImpl( | 4426 return new webkit_glue::WebPluginImpl( |
4431 frame, params, path, mime_type, AsWeakPtr()); | 4427 frame, params, path, mime_type, AsWeakPtr()); |
4432 } | 4428 } |
4433 | 4429 |
4434 WebPlugin* RenderView::CreateOutdatedPluginPlaceholder( | 4430 WebPlugin* RenderView::CreatePluginPlaceholder( |
4435 WebFrame* frame, | 4431 WebFrame* frame, |
4436 const WebPluginParams& params, | 4432 const WebPluginParams& params, |
4437 const PluginGroup& group) { | 4433 const PluginGroup& group, |
4438 int resource_id = IDR_OUTDATED_PLUGIN_HTML; | 4434 int resource_id, |
4439 const base::StringPiece template_html( | 4435 int message_id) { |
4440 ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); | 4436 // |blocked_plugin| will delete itself when the WebViewPlugin |
4441 | 4437 // is destroyed. |
4442 DCHECK(!template_html.empty()) << "unable to load template. ID: " | 4438 BlockedPlugin* blocked_plugin = |
4443 << resource_id; | 4439 new BlockedPlugin(this, |
4444 | 4440 frame, |
4445 DictionaryValue values; | 4441 group, |
4446 values.SetString("message", | 4442 params, |
4447 l10n_util::GetStringFUTF8(IDS_PLUGIN_OUTDATED, group.GetGroupName())); | 4443 webkit_preferences_, |
4448 values.Set("pluginGroup", group.GetDataForUI()); | 4444 resource_id, |
4449 | 4445 l10n_util::GetStringUTF16(message_id)); |
4450 // "t" is the id of the templates root node. | 4446 return blocked_plugin->plugin(); |
4451 std::string htmlData = jstemplate_builder::GetTemplatesHtml( | |
4452 template_html, &values, "t"); | |
4453 | |
4454 return WebViewPlugin::Create(NULL, | |
4455 webkit_preferences_, | |
4456 htmlData, | |
4457 GURL("chrome://outdatedplugin/")); | |
4458 } | 4447 } |
4459 | 4448 |
4460 void RenderView::OnZoom(PageZoom::Function function) { | 4449 void RenderView::OnZoom(PageZoom::Function function) { |
4461 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 4450 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
4462 return; | 4451 return; |
4463 | 4452 |
4464 webview()->hidePopups(); | 4453 webview()->hidePopups(); |
4465 | 4454 |
4466 double old_zoom_level = webview()->zoomLevel(); | 4455 double old_zoom_level = webview()->zoomLevel(); |
4467 double zoom_level; | 4456 double zoom_level; |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5746 external_popup_menu_.reset(); | 5735 external_popup_menu_.reset(); |
5747 } | 5736 } |
5748 #endif | 5737 #endif |
5749 | 5738 |
5750 void RenderView::AddErrorToRootConsole(const string16& message) { | 5739 void RenderView::AddErrorToRootConsole(const string16& message) { |
5751 if (webview() && webview()->mainFrame()) { | 5740 if (webview() && webview()->mainFrame()) { |
5752 webview()->mainFrame()->addMessageToConsole( | 5741 webview()->mainFrame()->addMessageToConsole( |
5753 WebConsoleMessage(WebConsoleMessage::LevelError, message)); | 5742 WebConsoleMessage(WebConsoleMessage::LevelError, message)); |
5754 } | 5743 } |
5755 } | 5744 } |
OLD | NEW |