diff options
author | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 06:53:25 +0000 |
---|---|---|
committer | cevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 06:53:25 +0000 |
commit | d12dcdd649f0f1181ecae1f0f567c6a453a5a96d (patch) | |
tree | 5631de8aaf766884b3aae73327f2f94d9c26461b /chrome | |
parent | 5a53b62b3e52202f530447f4fdf3637e39a56c35 (diff) | |
download | chromium_src-d12dcdd649f0f1181ecae1f0f567c6a453a5a96d.zip chromium_src-d12dcdd649f0f1181ecae1f0f567c6a453a5a96d.tar.gz chromium_src-d12dcdd649f0f1181ecae1f0f567c6a453a5a96d.tar.bz2 |
Put some plug-ins behind an infobar, where they have:
- Been targeted by mass malware.
- Do not yet have a good sandboxing story.
BUG=60458
TEST=http://java.sun.com/products/plugin/1.4/demos/applets/Blink/example1.html with default plug-in settings.
Review URL: http://codereview.chromium.org/6350010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72766 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/content_settings/host_content_settings_map.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/browser_render_process_host.cc | 1 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 185 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 17 | ||||
-rw-r--r-- | chrome/test/plugin/plugin_test.cpp | 1 | ||||
-rw-r--r-- | chrome/tools/chromeactions.txt | 5 |
9 files changed, 192 insertions, 31 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 06b22c9..47de99f 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4165,6 +4165,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <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> + <message name="IDS_PLUGIN_NOT_AUTHORIZED" desc="The placeholder text for a plug-in that requires user permission to run."> + The <ph name="PLUGIN_NAME">$1<ex>Java</ex></ph> plug-in needs your permission to run. + </message> <!-- Session Crashed Info Bar--> <message name="IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON" desc="Title of the restore button in the session crashed view."> @@ -7648,6 +7651,9 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_PLUGIN_ENABLE_TEMPORARILY" desc="Info Bar button to run a blocked outdated plugin"> Run this time </message> + <message name="IDS_PLUGIN_ENABLE_ALWAYS" desc="Info Bar button to always run blocked plugins for this web site"> + Always run on this site + </message> <message name="IDS_PLUGIN_CRASHED_PROMPT" desc="Info Bar message to notify about a crashed plugin"> The following plug-in has crashed: <ph name="PLUGIN_NAME">$1<ex>Shockwave</ex></ph> </message> diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc index 0345e81..241ca3e 100644 --- a/chrome/browser/content_settings/host_content_settings_map.cc +++ b/chrome/browser/content_settings/host_content_settings_map.cc @@ -296,7 +296,8 @@ ContentSettings HostContentSettingsMap::GetContentSettings( } else { // A managed default content setting has the highest priority and hence // will overwrite any previously set value. - if ((output.settings[j] == CONTENT_SETTING_DEFAULT) || + if ((output.settings[j] == CONTENT_SETTING_DEFAULT && + j != CONTENT_SETTINGS_TYPE_PLUGINS) || IsDefaultContentSettingManaged(ContentSettingsType(j))) { output.settings[j] = GetDefaultContentSetting(ContentSettingsType(j)); } diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 437e61f..5db9e5a 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -637,6 +637,7 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer( static const char* const kSwitchNames[] = { switches::kAllowOutdatedPlugins, switches::kAllowScriptingGallery, + switches::kAlwaysAuthorizePlugins, switches::kAppsGalleryURL, // We propagate the Chrome Frame command line here as well in case the // renderer is not run in the sandbox. diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 4b1b340..2554daa 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -249,57 +249,179 @@ void MakeNavigateParams(const NavigationEntry& entry, params->request_time = base::Time::Now(); } +// PluginInfoBar -------------------------------------------------------------- + +class PluginInfoBar : public ConfirmInfoBarDelegate { + public: + PluginInfoBar(TabContents* tab_contents, const string16& name); + + // ConfirmInfoBarDelegate: + virtual void InfoBarClosed() = 0; + virtual SkBitmap* GetIcon() const; + virtual string16 GetMessageText() const = 0; + virtual int GetButtons() const; + virtual string16 GetButtonLabel(InfoBarButton button) const = 0; + virtual bool Accept() = 0; + virtual bool Cancel() = 0; + virtual string16 GetLinkText(); + virtual bool LinkClicked(WindowOpenDisposition disposition) = 0; + + protected: + virtual ~PluginInfoBar(); + + void CommonCancel(); + void CommonClose(); + void CommonLearnMore(WindowOpenDisposition disposition); + + string16 name_; + TabContents* tab_contents_; + + private: + DISALLOW_COPY_AND_ASSIGN(PluginInfoBar); +}; + +PluginInfoBar::PluginInfoBar(TabContents* tab_contents, const string16& name) + : ConfirmInfoBarDelegate(tab_contents), + name_(name), + tab_contents_(tab_contents) { +} + +PluginInfoBar::~PluginInfoBar() { +} + +void PluginInfoBar::CommonClose() { + delete this; +} + +SkBitmap* PluginInfoBar::GetIcon() const { + return ResourceBundle::GetSharedInstance().GetBitmapNamed( + IDR_INFOBAR_PLUGIN_INSTALL); +} + +int PluginInfoBar::GetButtons() const { + return BUTTON_OK | BUTTON_CANCEL; +} + +void PluginInfoBar::CommonCancel() { + tab_contents_->render_view_host()->LoadBlockedPlugins(); +} + +string16 PluginInfoBar::GetLinkText() { + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); +} + +void PluginInfoBar::CommonLearnMore(WindowOpenDisposition disposition) { + // TODO(bauerb): Navigate to a help page explaining why we disabled + // or blocked the plugin, once we have one. +} + + +// BlockedPluginInfoBar ------------------------------------------------------- + +class BlockedPluginInfoBar : public PluginInfoBar { + public: + BlockedPluginInfoBar(TabContents* tab_contents, + const string16& name); + + // ConfirmInfoBarDelegate: + virtual string16 GetMessageText() const; + virtual string16 GetButtonLabel(InfoBarButton button) const; + virtual bool Accept(); + virtual bool Cancel(); + virtual void InfoBarClosed(); + virtual bool LinkClicked(WindowOpenDisposition disposition); + + protected: + virtual ~BlockedPluginInfoBar(); + + private: + DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBar); +}; + +BlockedPluginInfoBar::BlockedPluginInfoBar(TabContents* tab_contents, + const string16& name) + : PluginInfoBar(tab_contents, name) { + tab_contents->AddInfoBar(this); + UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); +} + +BlockedPluginInfoBar::~BlockedPluginInfoBar() { +} + +string16 BlockedPluginInfoBar::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); +} + +string16 BlockedPluginInfoBar::GetButtonLabel(InfoBarButton button) const { + return l10n_util::GetStringUTF16((button == BUTTON_OK) ? + IDS_PLUGIN_ENABLE_ALWAYS : IDS_PLUGIN_ENABLE_TEMPORARILY); +} + +bool BlockedPluginInfoBar::Accept() { + UserMetrics::RecordAction( + UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); + tab_contents_->profile()->GetHostContentSettingsMap()->AddExceptionForURL( + tab_contents_->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), + CONTENT_SETTING_ALLOW); + tab_contents_->render_view_host()->LoadBlockedPlugins(); + return false; +} + +bool BlockedPluginInfoBar::Cancel() { + UserMetrics::RecordAction( + UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); + CommonCancel(); + return false; +} + +void BlockedPluginInfoBar::InfoBarClosed() { + UserMetrics::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed")); + CommonClose(); +} + +bool BlockedPluginInfoBar::LinkClicked(WindowOpenDisposition disposition) { + UserMetrics::RecordAction( + UserMetricsAction("BlockedPluginInfobar.LearnMore")); + CommonLearnMore(disposition); + return false; +} // OutdatedPluginInfoBar ------------------------------------------------------ -class OutdatedPluginInfoBar : public ConfirmInfoBarDelegate { +class OutdatedPluginInfoBar : public PluginInfoBar { public: OutdatedPluginInfoBar(TabContents* tab_contents, const string16& name, const GURL& update_url); - private: - virtual ~OutdatedPluginInfoBar(); - // ConfirmInfoBarDelegate: - virtual void InfoBarClosed(); - virtual SkBitmap* GetIcon() const; virtual string16 GetMessageText() const; virtual string16 GetButtonLabel(InfoBarButton button) const; virtual bool Accept(); virtual bool Cancel(); - virtual string16 GetLinkText(); + virtual void InfoBarClosed(); virtual bool LinkClicked(WindowOpenDisposition disposition); - TabContents* tab_contents_; - string16 name_; + protected: + virtual ~OutdatedPluginInfoBar(); + + private: GURL update_url_; + + DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBar); }; OutdatedPluginInfoBar::OutdatedPluginInfoBar(TabContents* tab_contents, const string16& name, const GURL& update_url) - : ConfirmInfoBarDelegate(tab_contents), - tab_contents_(tab_contents), - name_(name), - update_url_(update_url) { - UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); + : PluginInfoBar(tab_contents, name), update_url_(update_url) { tab_contents->AddInfoBar(this); + UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); } OutdatedPluginInfoBar::~OutdatedPluginInfoBar() { } -void OutdatedPluginInfoBar::InfoBarClosed() { - UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed")); - delete this; -} - -SkBitmap* OutdatedPluginInfoBar::GetIcon() const { - return ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_INFOBAR_PLUGIN_INSTALL); -} - string16 OutdatedPluginInfoBar::GetMessageText() const { return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); } @@ -319,19 +441,19 @@ bool OutdatedPluginInfoBar::Accept() { bool OutdatedPluginInfoBar::Cancel() { UserMetrics::RecordAction( UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); - tab_contents_->render_view_host()->LoadBlockedPlugins(); + CommonCancel(); return false; } -string16 OutdatedPluginInfoBar::GetLinkText() { - return l10n_util::GetStringUTF16(IDS_LEARN_MORE); +void OutdatedPluginInfoBar::InfoBarClosed() { + UserMetrics::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed")); + CommonClose(); } bool OutdatedPluginInfoBar::LinkClicked(WindowOpenDisposition disposition) { UserMetrics::RecordAction( UserMetricsAction("OutdatedPluginInfobar.LearnMore")); - // TODO(bauerb): Navigate to a help page explaining why we disabled - // the plugin, once we have one. + CommonLearnMore(disposition); return false; } @@ -2365,7 +2487,10 @@ void TabContents::OnInstallApplication(const WebApplicationInfo& info) { void TabContents::OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url) { - new OutdatedPluginInfoBar(this, name, update_url); + if (!update_url.is_empty()) + new OutdatedPluginInfoBar(this, name, update_url); + else + new BlockedPluginInfoBar(this, name); } void TabContents::OnPageContents(const GURL& url, diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 3733b4b..6ad6356 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -43,6 +43,10 @@ const char kAllowSandboxDebugging[] = "allow-sandbox-debugging"; // useful for automation testing of the gallery. const char kAllowScriptingGallery[] = "allow-scripting-gallery"; +// This prevents Chrome from requiring authorization to run certain widely +// installed but less commonly used plug-ins. +const char kAlwaysAuthorizePlugins[] = "always-authorize-plugins"; + // Enable web inspector for all windows, even if they're part of the browser. // Allows us to use our dev tools to debug browser windows itself. const char kAlwaysEnableDevTools[] = "always-enable-dev-tools"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index fc91edf..789c8fa 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -27,6 +27,7 @@ extern const char kAllowOutdatedPlugins[]; extern const char kAllowSSLMITMProxies[]; extern const char kAllowSandboxDebugging[]; extern const char kAllowScriptingGallery[]; +extern const char kAlwaysAuthorizePlugins[]; extern const char kAlwaysEnableDevTools[]; extern const char kApp[]; extern const char kAppId[]; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 7cd7ece..1e2be18 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -2728,6 +2728,23 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame, ContentSetting host_setting = current_content_settings_.settings[CONTENT_SETTINGS_TYPE_PLUGINS]; + + if (group->RequiresAuthorization() && + !cmd->HasSwitch(switches::kAlwaysAuthorizePlugins) && + (plugin_setting == CONTENT_SETTING_ALLOW || + plugin_setting == CONTENT_SETTING_ASK) && + host_setting == CONTENT_SETTING_DEFAULT) { + Send(new ViewHostMsg_BlockedOutdatedPlugin(routing_id_, + group->GetGroupName(), + GURL())); + return CreatePluginPlaceholder(frame, + params, + *group, + IDR_BLOCKED_PLUGIN_HTML, + IDS_PLUGIN_NOT_AUTHORIZED, + false); + } + if (info.path.value() == webkit::npapi::kDefaultPluginLibraryName || plugin_setting == CONTENT_SETTING_ALLOW || host_setting == CONTENT_SETTING_ALLOW) { diff --git a/chrome/test/plugin/plugin_test.cpp b/chrome/test/plugin/plugin_test.cpp index 31b8d53..ace16bc 100644 --- a/chrome/test/plugin/plugin_test.cpp +++ b/chrome/test/plugin/plugin_test.cpp @@ -100,6 +100,7 @@ class PluginTest : public UITest { #endif // defined(OS_WIN) launch_arguments_.AppendSwitch(switches::kAllowOutdatedPlugins); + launch_arguments_.AppendSwitch(switches::kAlwaysAuthorizePlugins); UITest::SetUp(); } diff --git a/chrome/tools/chromeactions.txt b/chrome/tools/chromeactions.txt index d58c665..63ee8d0 100644 --- a/chrome/tools/chromeactions.txt +++ b/chrome/tools/chromeactions.txt @@ -114,6 +114,11 @@ 0xc4874f0e8e8b60aa BadMessageTerminate_WPH 0x1d145f0af708242c BlockNonsandboxedPlugins_Disable 0xd80cc9291c9c82a9 BlockNonsandboxedPlugins_Enable +0xe0daa169d443430e BlockedPluginInfobar.AllowThisTime +0xbc5f7815d41f0a0a BlockedPluginInfobar.AlwaysAllow +0xa6092c47f7cd698b BlockedPluginInfobar.Closed +0x4937bd47014fb3e0 BlockedPluginInfobar.LearnMore +0x127e30ad4cde6b00 BlockedPluginInfobar.Shown 0x114c3050111d8b8d Bold 0x02f476e54c6d58bd BookmarkBarFolder_CtxMenu 0x3012b56b98c28823 BookmarkBarFolder_DragEnd |