diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 11:24:51 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-30 11:24:51 +0000 |
commit | 57b66d09c510ff03605c9dddc289a17dc79f17e7 (patch) | |
tree | c8dd27f47eb1ea5f00ead6cc1898ec997597228f | |
parent | e6437b5b5aef788023788991840e2de227480da1 (diff) | |
download | chromium_src-57b66d09c510ff03605c9dddc289a17dc79f17e7.zip chromium_src-57b66d09c510ff03605c9dddc289a17dc79f17e7.tar.gz chromium_src-57b66d09c510ff03605c9dddc289a17dc79f17e7.tar.bz2 |
Move disabling outdated plugins to labs and update UI to Glen's mocks.
BUG=47731
TEST=Disabling outdated plugins should show up in about:labs
Review URL: http://codereview.chromium.org/3386033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61055 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 9 | ||||
-rw-r--r-- | chrome/browser/labs.cc | 7 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/blocked_plugin.cc | 49 | ||||
-rw-r--r-- | chrome/renderer/blocked_plugin.h | 11 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 48 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 7 | ||||
-rw-r--r-- | chrome/renderer/renderer_resources.grd | 1 | ||||
-rw-r--r-- | chrome/renderer/resources/blocked_plugin.html | 14 | ||||
-rw-r--r-- | chrome/renderer/resources/outdated_plugin.html | 63 | ||||
-rw-r--r-- | webkit/glue/plugins/webview_plugin.cc | 20 | ||||
-rw-r--r-- | webkit/glue/plugins/webview_plugin.h | 10 |
12 files changed, 167 insertions, 76 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 9ae0746..2e90870 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -3882,6 +3882,12 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_LABS_PAGE_INFO_BUBBLE_DESCRIPTION" desc="Description of the 'Page Info Bubble' lab."> Shows the Page Information as an info bubble instead of a dialog window. </message> + <message name="IDS_LABS_DISABLE_OUTDATED_PLUGINS_NAME" desc="Name of the 'Disable outdated plug-ins' lab"> + Disable outdated plug-ins + </message> + <message name="IDS_LABS_DISABLE_OUTDATED_PLUGINS_DESCRIPTION" desc="Description of the 'Disable outdated plug-ins' lab"> + Automatically disables plug-ins with known security vulnerabilities and offers update links for them. + </message> <!-- Click-to-load --> <message name="IDS_PLUGIN_LOAD" desc="The link for loading a blocked plug-in, displayed in the click-to-play UI."> @@ -3893,6 +3899,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_PLUGIN_UPDATE" desc="The link for updating an outdated plug-in."> Update plug-in... </message> + <message name="IDS_PLUGIN_OUTDATED" desc="The placeholder text for an outdated disabled plug-in."> + The <ph name="PLUGIN_NAME">$1<ex>Flash</ex></ph> plug-in is out of date. + </message> <!-- Session Crashed Info Bar--> <message name="IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON" desc="Title of the restore button in the session crashed view."> diff --git a/chrome/browser/labs.cc b/chrome/browser/labs.cc index f1500a7..a765601 100644 --- a/chrome/browser/labs.cc +++ b/chrome/browser/labs.cc @@ -104,6 +104,13 @@ const Experiment kExperiments[] = { kOsWin | kOsLinux, switches::kEnableNewPageInfoBubble } + { + "disable-outdated-plugins", // Do not change; see above. + IDS_LABS_DISABLE_OUTDATED_PLUGINS_NAME, + IDS_LABS_DISABLE_OUTDATED_PLUGINS_DESCRIPTION, + kOsAll, + switches::kDisableOutdatedPlugins + }, }; // Extracts the list of enabled lab experiments from a profile and stores them diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index a4592c1..02035f0 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -286,13 +286,13 @@ class DisabledPluginInfoBar : public ConfirmInfoBarDelegate { virtual bool Accept() { tab_contents_->OpenURL(update_url_, GURL(), - CURRENT_TAB, PageTransition::LINK); + NEW_FOREGROUND_TAB, PageTransition::LINK); return false; } virtual bool Cancel() { tab_contents_->OpenURL(GURL(chrome::kChromeUIPluginsURL), GURL(), - CURRENT_TAB, PageTransition::LINK); + NEW_FOREGROUND_TAB, PageTransition::LINK); return false; } diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc index 57d342b..07ff93c 100644 --- a/chrome/renderer/blocked_plugin.cc +++ b/chrome/renderer/blocked_plugin.cc @@ -18,32 +18,25 @@ #include "third_party/WebKit/WebKit/chromium/public/WebData.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" -#include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" #include "webkit/glue/plugins/webview_plugin.h" +#include "webkit/glue/webpreferences.h" -using WebKit::WebCursorInfo; using WebKit::WebFrame; using WebKit::WebPlugin; using WebKit::WebPluginContainer; using WebKit::WebPluginParams; -using WebKit::WebURL; -using WebKit::WebView; static const char* const kBlockedPluginDataURL = "chrome://blockedplugindata/"; BlockedPlugin::BlockedPlugin(RenderView* render_view, WebFrame* frame, const WebPluginParams& params, + const WebPreferences& preferences, PluginGroup* group) : render_view_(render_view), frame_(frame), plugin_params_(params) { - plugin_ = new WebViewPlugin(this); - - WebView* web_view = plugin_->web_view(); - web_view->mainFrame()->setCanHaveScrollbars(false); - int resource_id = IDR_BLOCKED_PLUGIN_HTML; const base::StringPiece template_html( ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); @@ -52,31 +45,28 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view, << resource_id; DictionaryValue values; - values.SetString("loadPlugin", - l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD)); - values.SetString("updatePlugin", - l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE)); - values.SetString("message", - l10n_util::GetStringUTF16(IDS_BLOCKED_PLUGINS_MESSAGE)); - if (group) - values.Set("pluginGroup", group->GetDataForUI()); + values.SetString("loadPlugin", l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD)); + values.Set("pluginGroup", group->GetDataForUI()); // "t" is the id of the templates root node. - std::string htmlData = jstemplate_builder::GetTemplatesHtml( + std::string html_data = jstemplate_builder::GetTemplatesHtml( template_html, &values, "t"); - web_view->mainFrame()->loadHTMLString(htmlData, - GURL(kBlockedPluginDataURL)); + plugin_ = WebViewPlugin::Create(this, + preferences, + html_data, + GURL(kBlockedPluginDataURL)); registrar_.Add(this, NotificationType::SHOULD_LOAD_PLUGINS, NotificationService::AllSources()); } +BlockedPlugin::~BlockedPlugin() {} + void BlockedPlugin::BindWebFrame(WebFrame* frame) { BindToJavascript(frame, L"plugin"); BindMethod("load", &BlockedPlugin::Load); - BindMethod("update", &BlockedPlugin::Update); } void BlockedPlugin::WillDestroyPlugin() { @@ -97,23 +87,6 @@ void BlockedPlugin::Load(const CppArgumentList& args, CppVariant* result) { LoadPlugin(); } -void BlockedPlugin::Update(const CppArgumentList& args, CppVariant* result) { - if (args.size() > 0) { - CppVariant arg(args[0]); - if (arg.isString()) { - GURL url(arg.ToString()); - OpenURL(url); - } - } -} - -void BlockedPlugin::OpenURL(GURL& url) { - render_view_->Send(new ViewHostMsg_OpenURL(render_view_->routing_id(), - url, - GURL(), - CURRENT_TAB)); -} - void BlockedPlugin::LoadPlugin() { CHECK(plugin_); WebPluginContainer* container = plugin_->container(); diff --git a/chrome/renderer/blocked_plugin.h b/chrome/renderer/blocked_plugin.h index fa3eaee..e32028a 100644 --- a/chrome/renderer/blocked_plugin.h +++ b/chrome/renderer/blocked_plugin.h @@ -23,6 +23,7 @@ class BlockedPlugin : public CppBoundClass, BlockedPlugin(RenderView* render_view, WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, + const WebPreferences& settings, PluginGroup* group); WebViewPlugin* plugin() { return plugin_; } @@ -37,21 +38,13 @@ class BlockedPlugin : public CppBoundClass, const NotificationDetails& details); private: - virtual ~BlockedPlugin() { } + virtual ~BlockedPlugin(); // Javascript callbacks: // Load the blocked plugin by calling LoadPlugin() below. // Takes no arguments, and returns nothing. void Load(const CppArgumentList& args, CppVariant* result); - // Update an outdated plugin. Takes one argument, the URL to download the - // latest version, and returns nothing. - void Update(const CppArgumentList& args, CppVariant* result); - - // Tells the browser to navigate to |url| (to download the latest version of - // the plugin there). - void OpenURL(GURL& url); - // Load the blocked plugin. void LoadPlugin(); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 02e67ea..29a27d9 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -9,6 +9,7 @@ #include <vector> #include "app/message_box_flags.h" +#include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/callback.h" #include "base/command_line.h" @@ -2372,7 +2373,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, Send(new ViewHostMsg_DisabledOutdatedPlugin(routing_id_, group->GetGroupName(), GURL(group->GetUpdateURL()))); - return CreatePluginPlaceholder(frame, params, group.get()); + return CreateOutdatedPluginPlaceholder(frame, params, group.get()); } return NULL; } @@ -2384,7 +2385,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, if (setting == CONTENT_SETTING_BLOCK) { DCHECK(!cmd->HasSwitch(switches::kDisableClickToPlay)); DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, resource); - return CreatePluginPlaceholder(frame, params, NULL); + return CreateBlockedPluginPlaceholder(frame, params, group.get()); } scoped_refptr<pepper::PluginModule> pepper_module = PepperPluginRegistry::GetInstance()->GetModule(info.path); @@ -2395,7 +2396,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, Send(new ViewHostMsg_NonSandboxedPluginBlocked(routing_id_, resource, group->GetGroupName())); - return CreatePluginPlaceholder(frame, params, NULL); + return CreateBlockedPluginPlaceholder(frame, params, group.get()); } } return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type); @@ -4023,15 +4024,40 @@ WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame, actual_mime_type, AsWeakPtr()); } -WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, - const WebPluginParams& params, - PluginGroup* group) { +WebPlugin* RenderView::CreateOutdatedPluginPlaceholder( + WebFrame* frame, + const WebPluginParams& params, + PluginGroup* group) { + int resource_id = IDR_OUTDATED_PLUGIN_HTML; + const base::StringPiece template_html( + ResourceBundle::GetSharedInstance().GetRawDataResource(resource_id)); + + DCHECK(!template_html.empty()) << "unable to load template. ID: " + << resource_id; + + DictionaryValue values; + values.SetString("pluginOutdated", + l10n_util::GetStringFUTF8(IDS_PLUGIN_OUTDATED, group->GetGroupName())); + values.Set("pluginGroup", group->GetDataForUI()); + + // "t" is the id of the templates root node. + std::string htmlData = jstemplate_builder::GetTemplatesHtml( + template_html, &values, "t"); + + return WebViewPlugin::Create(NULL, + webkit_preferences_, + htmlData, + GURL("chrome://outdatedplugin/")); +} + +WebPlugin* RenderView::CreateBlockedPluginPlaceholder( + WebFrame* frame, + const WebPluginParams& params, + PluginGroup* group) { // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. - BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params, group); - WebViewPlugin* plugin = blocked_plugin->plugin(); - WebView* web_view = plugin->web_view(); - webkit_preferences_.Apply(web_view); - return plugin; + BlockedPlugin* blocked_plugin = + new BlockedPlugin(this, frame, params, webkit_preferences_, group); + return blocked_plugin->plugin(); } void RenderView::OnZoom(PageZoom::Function function) { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 4fe4c3b..55fe218 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -911,7 +911,12 @@ class RenderView : public RenderWidget, pepper::PluginModule* pepper_module); // Create a new placeholder for a blocked plugin. - WebKit::WebPlugin* CreatePluginPlaceholder( + WebKit::WebPlugin* CreateBlockedPluginPlaceholder( + WebKit::WebFrame* frame, + const WebKit::WebPluginParams& params, + PluginGroup* group); + + WebKit::WebPlugin* CreateOutdatedPluginPlaceholder( WebKit::WebFrame* frame, const WebKit::WebPluginParams& params, PluginGroup* group); diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd index 8d1432c..9fddc4b 100644 --- a/chrome/renderer/renderer_resources.grd +++ b/chrome/renderer/renderer_resources.grd @@ -21,6 +21,7 @@ without changes to the corresponding grd file. fb9 --> <include name="IDR_GREASEMONKEY_API_JS" file="resources\greasemonkey_api.js" type="BINDATA" /> <include name="IDR_JSON_SCHEMA_JS" file="resources\json_schema.js" type="BINDATA" /> <include name="IDR_NET_ERROR_HTML" file="resources\neterror.html" flattenhtml="true" type="BINDATA" /> + <include name="IDR_OUTDATED_PLUGIN_HTML" file="resources\outdated_plugin.html" flattenhtml="true" type="BINDATA" /> <include name="IDR_RENDERER_EXTENSION_BINDINGS_JS" file="resources\renderer_extension_bindings.js" type="BINDATA" /> <include name="IDR_SAD_PLUGIN" file="resources\sadplugin.png" type="BINDATA" /> <include name="IDR_ERROR_APP_HTML" file="resources\error_app.html" flattenhtml="true" type="BINDATA" /> diff --git a/chrome/renderer/resources/blocked_plugin.html b/chrome/renderer/resources/blocked_plugin.html index 6534889..ff94e01 100644 --- a/chrome/renderer/resources/blocked_plugin.html +++ b/chrome/renderer/resources/blocked_plugin.html @@ -5,15 +5,6 @@ function debug(msg) { document.getElementById('debug').textContent = msg; } - -function bodyClicked() { - var group = templateData.pluginGroup; - if (group) { - plugin.update(group.update_url); - } else { - plugin.load(); - } -} </script> <style> body { @@ -81,11 +72,10 @@ FIXME: This causes flickering on hover. </head> <body id="t" onSelectStart="return false;"> -<div id="outer" onclick="bodyClicked()"> +<div id="outer" onclick="plugin.load()"> <div id="inner"> <div><img id="plugin_icon" src="plugin_blocked.png" /></div> -<h1 jsdisplay="!hasOwnProperty('pluginGroup') || !pluginGroup.critical" i18n-content="loadPlugin">PLUGIN_LOAD</h1> -<h1 jsdisplay="hasOwnProperty('pluginGroup')" i18n-content="updatePlugin">UPDATE_PLUGIN</h1> +<h1 i18n-content="loadPlugin">PLUGIN_LOAD</h1> <p id="debug"> </p> </div> </div> diff --git a/chrome/renderer/resources/outdated_plugin.html b/chrome/renderer/resources/outdated_plugin.html new file mode 100644 index 0000000..bf55ae4 --- /dev/null +++ b/chrome/renderer/resources/outdated_plugin.html @@ -0,0 +1,63 @@ +<!DOCTYPE html> +<html> +<head> +<script> +function debug(msg) { + document.getElementById('debug').textContent = msg; +} +</script> +<style> +body { + background-color: rgb(187, 187, 187); + margin: 0; + text-align: center; + font-family: sans-serif; + overflow: hidden; +} + +h1 { + padding: 0pt 10pt; + font-size: 10pt; + font-weight: normal; + visibility: hidden; +} + +#outer:hover h1 { + visibility: visible; +} + +#plugin_icon { + opacity: .6; +} + +p { + padding: 0pt 14pt; + font-size: 8pt; +} + +#outer { + width: 100%; + height: 100%; + position: absolute; + border: 1px black solid; + -webkit-box-sizing: border-box; +} + +#inner { + position: relative; + top: 50%; + margin-top: -50px; +} +</style> +</head> + +<body id="t" onSelectStart="return false;"> +<div id="outer"> +<div id="inner"> +<div><img id="plugin_icon" src="plugin_blocked.png" /></div> +<h1 i18n-content="pluginOutdated">PLUGIN_OUTDATED</h1> +<p id="debug"> </p> +</div> +</div> +</body> +</html> diff --git a/webkit/glue/plugins/webview_plugin.cc b/webkit/glue/plugins/webview_plugin.cc index 231bd37..9287028 100644 --- a/webkit/glue/plugins/webview_plugin.cc +++ b/webkit/glue/plugins/webview_plugin.cc @@ -9,12 +9,12 @@ #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" -#include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebView.h" +#include "webkit/glue/webpreferences.h" #if WEBKIT_USING_CG #include <CoreGraphics/CGContext.h> @@ -48,6 +48,18 @@ WebViewPlugin::WebViewPlugin(WebViewPlugin::Delegate* delegate) web_view_->initializeMainFrame(this); } +// static +WebViewPlugin* WebViewPlugin::Create(WebViewPlugin::Delegate* delegate, + const WebPreferences& preferences, + const std::string& html_data, + const GURL& url) { + WebViewPlugin* plugin = new WebViewPlugin(delegate); + WebView* web_view = plugin->web_view(); + preferences.Apply(web_view); + web_view->mainFrame()->loadHTMLString(html_data, url); + return plugin; +} + WebViewPlugin::~WebViewPlugin() { web_view_->close(); } @@ -78,8 +90,10 @@ bool WebViewPlugin::initialize(WebPluginContainer* container) { } void WebViewPlugin::destroy() { - delegate_->WillDestroyPlugin(); - delegate_ = NULL; + if (delegate_) { + delegate_->WillDestroyPlugin(); + delegate_ = NULL; + } container_ = NULL; MessageLoop::current()->DeleteSoon(FROM_HERE, this); } diff --git a/webkit/glue/plugins/webview_plugin.h b/webkit/glue/plugins/webview_plugin.h index 757a012..9695aa2 100644 --- a/webkit/glue/plugins/webview_plugin.h +++ b/webkit/glue/plugins/webview_plugin.h @@ -15,6 +15,8 @@ #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" #include "third_party/WebKit/WebKit/chromium/public/WebViewClient.h" +struct WebPreferences; + // This class implements the WebPlugin interface by forwarding drawing and // handling input events to a WebView. // It can be used as a placeholder for an actual plugin, using HTML for the UI. @@ -39,6 +41,14 @@ class WebViewPlugin: public WebKit::WebPlugin, public WebKit::WebViewClient, explicit WebViewPlugin(Delegate* delegate); + // Convenience method to set up a new WebViewPlugin using |preferences| + // and displaying |html_data|. |url| should be a (fake) chrome:// URL; it is + // only used for navigation and never actually resolved. + static WebViewPlugin* Create(Delegate* delegate, + const WebPreferences& preferences, + const std::string& html_data, + const GURL& url); + WebKit::WebView* web_view() { return web_view_; } WebKit::WebPluginContainer* container() { return container_; } |