diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 6 | ||||
-rw-r--r-- | chrome/browser/browser_resources.grd | 3 | ||||
-rw-r--r-- | chrome/browser/plugin_finder.cc | 138 | ||||
-rw-r--r-- | chrome/browser/plugin_finder.h | 17 | ||||
-rw-r--r-- | chrome/browser/plugin_infobar_delegates.cc | 387 | ||||
-rw-r--r-- | chrome/browser/plugin_infobar_delegates.h | 164 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.cc | 14 | ||||
-rw-r--r-- | chrome/browser/plugin_installer.h | 15 | ||||
-rw-r--r-- | chrome/browser/plugin_installer_infobar_delegate.cc | 128 | ||||
-rw-r--r-- | chrome/browser/plugin_installer_infobar_delegate.h | 63 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.cc | 314 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.h | 16 | ||||
-rw-r--r-- | chrome/browser/resources/plugins_linux.json | 66 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 6 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 4 | ||||
-rw-r--r-- | chrome/renderer/chrome_content_renderer_client.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/plugins/plugin_placeholder.cc | 5 |
17 files changed, 549 insertions, 805 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d2889d9..1a9170b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5312,9 +5312,6 @@ Because search results are requested even while you're typing your query, your d <message name="IDS_PLUGIN_INSTALLING" desc="The placeholder text when installing a missing plug-in."> After installing the plug-in, reload the page. </message> - <message name="IDS_PLUGIN_UPDATING" desc="The placeholder text when updating an out-of-date plug-in."> - After updating the plug-in, reload the page. - </message> <message name="IDS_PLUGIN_FOUND" desc="The placeholder text for a known plug-in that is not installed."> The <ph name="PLUGIN_NAME">$1<ex>Quicktime</ex></ph> plug-in is required to display this content. </message> @@ -9573,9 +9570,6 @@ experiment id: "<ph name="EXPERIMENT_ID">$5<ex>ar1</ex></ph>" <message name="IDS_PLUGININSTALLER_PROBLEMSINSTALLING" desc="Infobar text for link to help center"> Problems installing? </message> - <message name="IDS_PLUGININSTALLER_PROBLEMSUPDATING" desc="Infobar text for link to help center"> - Problems updating? - </message> <message name="IDS_PLUGIN_OUTDATED_PROMPT" desc="Info Bar message when an outdated plugin was disabled"> The <ph name="PLUGIN_NAME">$1<ex>Flash</ex></ph> plug-in was blocked because it is out of date. </message> diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 7571a7d..4084b92 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -98,9 +98,6 @@ <if expr="is_macosx"> <include name="IDR_PLUGIN_DB_JSON" file="resources\plugins_mac.json" type="BINDATA" /> </if> - <if expr="is_linux"> - <include name="IDR_PLUGIN_DB_JSON" file="resources\plugins_linux.json" type="BINDATA" /> - </if> <include name="IDR_POLICY_CSS" file="resources\policy.css" type="BINDATA"/> <include name="IDR_POLICY_HTML" file="resources\policy.html" flattenhtml="true" allowexternalscript="true" type="BINDATA"/> <include name="IDR_POLICY_JS" file="resources\policy.js" type="BINDATA"/> diff --git a/chrome/browser/plugin_finder.cc b/chrome/browser/plugin_finder.cc index 2e90b54..f33253b 100644 --- a/chrome/browser/plugin_finder.cc +++ b/chrome/browser/plugin_finder.cc @@ -36,7 +36,7 @@ scoped_ptr<base::ListValue> PluginFinder::LoadPluginList() { } base::ListValue* PluginFinder::LoadPluginListInternal() { -#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_LINUX) +#if defined(OS_WIN) || defined(OS_MACOSX) base::StringPiece json_resource( ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_PLUGIN_DB_JSON)); @@ -70,100 +70,60 @@ PluginFinder::~PluginFinder() { void PluginFinder::FindPlugin( const std::string& mime_type, const std::string& language, - const FindPluginCallback& callback) { - PluginInstaller* installer = FindPluginInternal(mime_type, language); - MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, installer)); -} - -void PluginFinder::FindPluginWithIdentifier( - const std::string& identifier, - const FindPluginCallback& found_callback) { - PluginInstaller* installer = NULL; - std::map<std::string, PluginInstaller*>::const_iterator it = - installers_.find(identifier); - if (it != installers_.end()) { - installer = it->second; - } else { - for (ListValue::const_iterator plugin_it = plugin_list_->begin(); - plugin_it != plugin_list_->end(); ++plugin_it) { - const base::DictionaryValue* plugin = NULL; - if (!(*plugin_it)->GetAsDictionary(&plugin)) { - NOTREACHED(); - continue; - } - std::string id; - bool success = plugin->GetString("identifier", &id); - DCHECK(success); - if (id == identifier) { - installer = CreateInstaller(identifier, plugin); - break; - } - } - } - MessageLoop::current()->PostTask(FROM_HERE, - base::Bind(found_callback, installer)); -} - -PluginInstaller* PluginFinder::CreateInstaller( - const std::string& identifier, - const base::DictionaryValue* plugin_dict) { - DCHECK(!installers_[identifier]); - std::string url; - bool success = plugin_dict->GetString("url", &url); - DCHECK(success); - std::string help_url; - plugin_dict->GetString("help_url", &help_url); - string16 name; - success = plugin_dict->GetString("name", &name); - DCHECK(success); - bool display_url = false; - plugin_dict->GetBoolean("displayurl", &display_url); - PluginInstaller*installer = new PluginInstaller(identifier, - GURL(url), - GURL(help_url), - name, - display_url); - installers_[identifier] = installer; - return installer; -} - -PluginInstaller* PluginFinder::FindPluginInternal( - const std::string& mime_type, - const std::string& language) { - if (!g_browser_process->local_state()->GetBoolean( + const FindPluginCallback& found_callback, + const base::Closure& not_found_callback) { + if (g_browser_process->local_state()->GetBoolean( prefs::kDisablePluginFinder)) { - for (ListValue::const_iterator plugin_it = plugin_list_->begin(); - plugin_it != plugin_list_->end(); ++plugin_it) { - const base::DictionaryValue* plugin = NULL; - if (!(*plugin_it)->GetAsDictionary(&plugin)) { - NOTREACHED(); - continue; - } - std::string language_str; - bool success = plugin->GetString("lang", &language_str); - DCHECK(success); - if (language_str != language) - continue; - ListValue* mime_types = NULL; - success = plugin->GetList("mime_types", &mime_types); + MessageLoop::current()->PostTask(FROM_HERE, not_found_callback); + return; + } + for (ListValue::const_iterator plugin_it = plugin_list_->begin(); + plugin_it != plugin_list_->end(); ++plugin_it) { + const base::DictionaryValue* plugin = NULL; + if (!(*plugin_it)->GetAsDictionary(&plugin)) { + NOTREACHED(); + continue; + } + std::string language_str; + bool success = plugin->GetString("lang", &language_str); + DCHECK(success); + if (language_str != language) + continue; + ListValue* mime_types = NULL; + success = plugin->GetList("mime_types", &mime_types); + DCHECK(success); + for (ListValue::const_iterator mime_type_it = mime_types->begin(); + mime_type_it != mime_types->end(); ++mime_type_it) { + std::string mime_type_str; + success = (*mime_type_it)->GetAsString(&mime_type_str); DCHECK(success); - for (ListValue::const_iterator mime_type_it = mime_types->begin(); - mime_type_it != mime_types->end(); ++mime_type_it) { - std::string mime_type_str; - success = (*mime_type_it)->GetAsString(&mime_type_str); + if (mime_type_str == mime_type) { + std::string identifier; + success = plugin->GetString("identifier", &identifier); DCHECK(success); - if (mime_type_str == mime_type) { - std::string identifier; - bool success = plugin->GetString("identifier", &identifier); + PluginInstaller* installer = installers_[identifier]; + if (!installer) { + std::string url; + success = plugin->GetString("url", &url); + DCHECK(success); + std::string help_url; + plugin->GetString("help_url", &help_url); + string16 name; + success = plugin->GetString("name", &name); DCHECK(success); - std::map<std::string, PluginInstaller*>::const_iterator it = - installers_.find(identifier); - if (it != installers_.end()) - return it->second; - return CreateInstaller(identifier, plugin); + bool display_url = false; + plugin->GetBoolean("displayurl", &display_url); + installer = new PluginInstaller(identifier, + GURL(url), GURL(help_url), name, + display_url); + installers_[identifier] = installer; } + MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(found_callback, installer)); + return; } } } - return NULL; + MessageLoop::current()->PostTask(FROM_HERE, not_found_callback); } diff --git a/chrome/browser/plugin_finder.h b/chrome/browser/plugin_finder.h index 2b1bd49..a0e88b7 100644 --- a/chrome/browser/plugin_finder.h +++ b/chrome/browser/plugin_finder.h @@ -15,7 +15,6 @@ #include "base/string16.h" namespace base { -class DictionaryValue; class ListValue; } @@ -33,15 +32,12 @@ class PluginFinder { static scoped_ptr<base::ListValue> LoadPluginList(); // Finds a plug-in for the given MIME type and language (specified as an IETF - // language tag, i.e. en-US) and calls the callback with the PluginInstaller - // for the plug-in, or NULL if no plug-in is found. + // language tag, i.e. en-US) and calls one of the two passed in callbacks, + // depending on whether a plug-in is found. void FindPlugin(const std::string& mime_type, const std::string& language, - const FindPluginCallback& callback); - - // Finds the plug-in with the given identifier and calls the callback. - void FindPluginWithIdentifier(const std::string& identifier, - const FindPluginCallback& callback); + const FindPluginCallback& found_callback, + const base::Closure& not_found_callback); private: friend struct DefaultSingletonTraits<PluginFinder>; @@ -51,11 +47,6 @@ class PluginFinder { static base::ListValue* LoadPluginListInternal(); - PluginInstaller* CreateInstaller(const std::string& identifier, - const base::DictionaryValue* plugin_dict); - PluginInstaller* FindPluginInternal(const std::string& mime_type, - const std::string& language); - scoped_ptr<base::ListValue> plugin_list_; std::map<std::string, PluginInstaller*> installers_; diff --git a/chrome/browser/plugin_infobar_delegates.cc b/chrome/browser/plugin_infobar_delegates.cc deleted file mode 100644 index 9d0b0ef2..0000000 --- a/chrome/browser/plugin_infobar_delegates.cc +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/plugin_infobar_delegates.h" - -#include "base/utf_string_conversions.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/google/google_util.h" -#include "chrome/browser/infobars/infobar_tab_helper.h" -#include "chrome/browser/plugin_installer.h" -#include "chrome/browser/plugin_observer.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/url_constants.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/public/browser/user_metrics.h" -#include "content/public/browser/web_contents.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources_standard.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "webkit/plugins/npapi/plugin_group.h" - -using content::OpenURLParams; -using content::Referrer; -using content::UserMetricsAction; - -PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, - const string16& name) - : ConfirmInfoBarDelegate(infobar_helper), - name_(name) { -} - -PluginInfoBarDelegate::~PluginInfoBarDelegate() { -} - -bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { - OpenURLParams params( - GURL(GetLearnMoreURL()), Referrer(), - (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, - content::PAGE_TRANSITION_LINK, - false); - owner()->web_contents()->OpenURL(params); - return false; -} - -void PluginInfoBarDelegate::LoadBlockedPlugins() { - owner()->Send(new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id())); -} - -gfx::Image* PluginInfoBarDelegate::GetIcon() const { - return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( - IDR_INFOBAR_PLUGIN_INSTALL); -} - -string16 PluginInfoBarDelegate::GetLinkText() const { - return l10n_util::GetStringUTF16(IDS_LEARN_MORE); -} - -// UnauthorizedPluginInfoBarDelegate ------------------------------------------ - -UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( - InfoBarTabHelper* infobar_helper, - HostContentSettingsMap* content_settings, - const string16& utf16_name) - : PluginInfoBarDelegate(infobar_helper, utf16_name), - content_settings_(content_settings) { - content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); - std::string name = UTF16ToUTF8(utf16_name); - if (name == webkit::npapi::PluginGroup::kJavaGroupName) - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Shown.Java")); - else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime")); - else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave")); - else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName) - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer")); - else if (name == webkit::npapi::PluginGroup::kWindowsMediaPlayerGroupName) - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Shown.WindowsMediaPlayer")); -} - -UnauthorizedPluginInfoBarDelegate::~UnauthorizedPluginInfoBarDelegate() { - content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed")); -} - -std::string UnauthorizedPluginInfoBarDelegate::GetLearnMoreURL() const { - return chrome::kBlockedPluginLearnMoreURL; -} - -string16 UnauthorizedPluginInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); -} - -string16 UnauthorizedPluginInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - return l10n_util::GetStringUTF16((button == BUTTON_OK) ? - IDS_PLUGIN_ENABLE_TEMPORARILY : IDS_PLUGIN_ENABLE_ALWAYS); -} - -bool UnauthorizedPluginInfoBarDelegate::Accept() { - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); - LoadBlockedPlugins(); - return true; -} - -bool UnauthorizedPluginInfoBarDelegate::Cancel() { - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); - content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(), - owner()->web_contents()->GetURL(), - CONTENT_SETTINGS_TYPE_PLUGINS, - std::string(), - CONTENT_SETTING_ALLOW); - LoadBlockedPlugins(); - return true; -} - -void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.Dismissed")); -} - -bool UnauthorizedPluginInfoBarDelegate::LinkClicked( - WindowOpenDisposition disposition) { - content::RecordAction( - UserMetricsAction("BlockedPluginInfobar.LearnMore")); - return PluginInfoBarDelegate::LinkClicked(disposition); -} - -// OutdatedPluginInfoBarDelegate ---------------------------------------------- - -InfoBarDelegate* OutdatedPluginInfoBarDelegate::Create( - PluginObserver* observer, - PluginInstaller* installer) { - string16 message; - switch (installer->state()) { - case PluginInstaller::kStateIdle: - message = l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, - installer->name()); - break; - case PluginInstaller::kStateDownloading: - message = l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING); - break; - } - return new OutdatedPluginInfoBarDelegate( - observer, installer, message); -} - -OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( - PluginObserver* observer, - PluginInstaller* installer, - const string16& message) - : PluginInfoBarDelegate( - observer->tab_contents_wrapper()->infobar_tab_helper(), - installer->name()), - WeakPluginInstallerObserver(installer), - observer_(observer), - message_(message) { - content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); - std::string name = UTF16ToUTF8(installer->name()); - if (name == webkit::npapi::PluginGroup::kJavaGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); - else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime")); - else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.Shockwave")); - else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer")); - else if (name == webkit::npapi::PluginGroup::kSilverlightGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight")); - else if (name == webkit::npapi::PluginGroup::kAdobeReaderGroupName) - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Shown.Reader")); -} - -OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() { - content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed")); -} - -std::string OutdatedPluginInfoBarDelegate::GetLearnMoreURL() const { - return chrome::kOutdatedPluginLearnMoreURL; -} - -string16 OutdatedPluginInfoBarDelegate::GetMessageText() const { - return message_; -} - -string16 OutdatedPluginInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - return l10n_util::GetStringUTF16((button == BUTTON_OK) ? - IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); -} - -bool OutdatedPluginInfoBarDelegate::Accept() { - content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); - if (installer()->state() != PluginInstaller::kStateIdle) { - NOTREACHED(); - return false; - } - - content::WebContents* web_contents = owner()->web_contents(); - if (installer()->url_for_display()) { - installer()->OpenDownloadURL(web_contents); - } else { - installer()->StartInstalling(web_contents); - } - return false; -} - -bool OutdatedPluginInfoBarDelegate::Cancel() { - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); - LoadBlockedPlugins(); - return true; -} - -void OutdatedPluginInfoBarDelegate::InfoBarDismissed() { - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.Dismissed")); -} - -bool OutdatedPluginInfoBarDelegate::LinkClicked( - WindowOpenDisposition disposition) { - content::RecordAction( - UserMetricsAction("OutdatedPluginInfobar.LearnMore")); - return PluginInfoBarDelegate::LinkClicked(disposition); -} - -void OutdatedPluginInfoBarDelegate::DidStartDownload() { - ReplaceWithInfoBar(l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING)); -} - -void OutdatedPluginInfoBarDelegate::DidFinishDownload() { - ReplaceWithInfoBar(l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATING)); -} - -void OutdatedPluginInfoBarDelegate::DownloadError(const std::string& message) { - ReplaceWithInfoBar( - l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT)); -} - -void OutdatedPluginInfoBarDelegate::OnlyWeakObserversLeft() { - if (owner()) - owner()->RemoveInfoBar(this); -} - -void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar( - const string16& message) { - // Return early if the message doesn't change. This is important in case the - // PluginInstaller is still iterating over its observers (otherwise we would - // keep replacing infobar delegates infinitely). - if (message_ == message) - return; - if (!owner()) - return; - InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( - owner(), installer(), base::Closure(), false, message); - owner()->ReplaceInfoBar(this, delegate); -} - -// PluginInstallerInfoBarDelegate --------------------------------------------- - -PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( - InfoBarTabHelper* infobar_helper, - PluginInstaller* installer, - const base::Closure& callback, - bool new_install, - const string16& message) - : ConfirmInfoBarDelegate(infobar_helper), - WeakPluginInstallerObserver(installer), - callback_(callback), - new_install_(new_install), - message_(message) { -} - -PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { -} - -InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( - InfoBarTabHelper* infobar_helper, - PluginInstaller* installer, - const base::Closure& callback) { - string16 message; - switch (installer->state()) { - case PluginInstaller::kStateIdle: - message = l10n_util::GetStringFUTF16( - IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, installer->name()); - break; - case PluginInstaller::kStateDownloading: - message = l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING); - break; - } - return new PluginInstallerInfoBarDelegate( - infobar_helper, installer, callback, true, message); -} - -gfx::Image* PluginInstallerInfoBarDelegate::GetIcon() const { - return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( - IDR_INFOBAR_PLUGIN_INSTALL); -} - -string16 PluginInstallerInfoBarDelegate::GetMessageText() const { - return message_; -} - -int PluginInstallerInfoBarDelegate::GetButtons() const { - return callback_.is_null() ? BUTTON_NONE : BUTTON_OK; -} - -string16 PluginInstallerInfoBarDelegate::GetButtonLabel( - InfoBarButton button) const { - DCHECK_EQ(BUTTON_OK, button); - return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); -} - -bool PluginInstallerInfoBarDelegate::Accept() { - callback_.Run(); - return false; -} - -string16 PluginInstallerInfoBarDelegate::GetLinkText() const { - return l10n_util::GetStringUTF16( - new_install_ ? IDS_PLUGININSTALLER_PROBLEMSINSTALLING - : IDS_PLUGININSTALLER_PROBLEMSUPDATING); -} - -bool PluginInstallerInfoBarDelegate::LinkClicked( - WindowOpenDisposition disposition) { - GURL url(installer()->help_url()); - if (url.is_empty()) { - url = google_util::AppendGoogleLocaleParam(GURL( - "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); - } - - OpenURLParams params( - url, Referrer(), - (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, - content::PAGE_TRANSITION_LINK, false); - owner()->web_contents()->OpenURL(params); - return false; -} - -void PluginInstallerInfoBarDelegate::DidStartDownload() { - ReplaceWithInfoBar(l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING)); -} - -void PluginInstallerInfoBarDelegate::DidFinishDownload() { - ReplaceWithInfoBar(l10n_util::GetStringUTF16( - new_install_ ? IDS_PLUGIN_INSTALLING : IDS_PLUGIN_UPDATING)); -} - -void PluginInstallerInfoBarDelegate::DownloadError(const std::string& message) { - ReplaceWithInfoBar( - l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT)); -} - -void PluginInstallerInfoBarDelegate::OnlyWeakObserversLeft() { - if (owner()) - owner()->RemoveInfoBar(this); -} - -void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar( - const string16& message) { - // Return early if the message doesn't change. This is important in case the - // PluginInstaller is still iterating over its observers (otherwise we would - // keep replacing infobar delegates infinitely). - if (message_ == message) - return; - if (!owner()) - return; - InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( - owner(), installer(), base::Closure(), new_install_, message); - owner()->ReplaceInfoBar(this, delegate); -} diff --git a/chrome/browser/plugin_infobar_delegates.h b/chrome/browser/plugin_infobar_delegates.h deleted file mode 100644 index f4e9096..0000000 --- a/chrome/browser/plugin_infobar_delegates.h +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ -#define CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ -#pragma once - -#include "base/callback.h" -#include "chrome/browser/plugin_installer_observer.h" -#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/link_infobar_delegate.h" -#include "googleurl/src/gurl.h" - -class HostContentSettingsMap; -class PluginObserver; - -// Base class for blocked plug-in infobars. -class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { - public: - PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name); - - protected: - virtual ~PluginInfoBarDelegate(); - - // ConfirmInfoBarDelegate: - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - - virtual std::string GetLearnMoreURL() const = 0; - - void LoadBlockedPlugins(); - - string16 name_; - - private: - // ConfirmInfoBarDelegate: - virtual gfx::Image* GetIcon() const OVERRIDE; - virtual string16 GetLinkText() const OVERRIDE; - - DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); -}; - -// Infobar that's shown when a plug-in requires user authorization to run. -class UnauthorizedPluginInfoBarDelegate : public PluginInfoBarDelegate { - public: - UnauthorizedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, - HostContentSettingsMap* content_settings, - const string16& name); - - private: - virtual ~UnauthorizedPluginInfoBarDelegate(); - - // PluginInfoBarDelegate: - virtual string16 GetMessageText() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual bool Cancel() OVERRIDE; - virtual void InfoBarDismissed() OVERRIDE; - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - virtual std::string GetLearnMoreURL() const OVERRIDE; - - HostContentSettingsMap* content_settings_; - - DISALLOW_COPY_AND_ASSIGN(UnauthorizedPluginInfoBarDelegate); -}; - -// Infobar that's shown when a plug-in is out of date. -class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, - public WeakPluginInstallerObserver { - public: - static InfoBarDelegate* Create(PluginObserver* observer, - PluginInstaller* installer); - - private: - OutdatedPluginInfoBarDelegate(PluginObserver* observer, - PluginInstaller* installer, - const string16& message); - virtual ~OutdatedPluginInfoBarDelegate(); - - // PluginInfoBarDelegate: - virtual string16 GetMessageText() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual bool Cancel() OVERRIDE; - virtual void InfoBarDismissed() OVERRIDE; - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - virtual std::string GetLearnMoreURL() const OVERRIDE; - - // PluginInstallerObserver: - virtual void DidStartDownload() OVERRIDE; - virtual void DidFinishDownload() OVERRIDE; - virtual void DownloadError(const std::string& message) OVERRIDE; - - // WeakPluginInstallerObserver: - virtual void OnlyWeakObserversLeft() OVERRIDE; - - // Replaces this infobar with one showing |message|. The new infobar will - // not have any buttons (and not call the callback). - void ReplaceWithInfoBar(const string16& message); - - // Has the same lifetime as TabContentsWrapper, which owns us - // (transitively via InfoBarTabHelper). - PluginObserver* observer_; - - string16 message_; - - DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); -}; - -// The main purpose for this class is to popup/close the infobar when there is -// a missing plugin. -class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, - public WeakPluginInstallerObserver { - public: - // Shows an infobar asking whether to install the plugin represented by - // |installer|. When the user accepts, |callback| is called. - // During installation of the plug-in, the infobar will change to reflect the - // installation state. - static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, - PluginInstaller* installer, - const base::Closure& callback); - - private: - friend class OutdatedPluginInfoBarDelegate; - - PluginInstallerInfoBarDelegate(InfoBarTabHelper* infobar_helper, - PluginInstaller* installer, - const base::Closure& callback, - bool new_install, - const string16& message); - virtual ~PluginInstallerInfoBarDelegate(); - - // ConfirmInfoBarDelegate: - virtual gfx::Image* GetIcon() const OVERRIDE; - virtual string16 GetMessageText() const OVERRIDE; - virtual int GetButtons() const OVERRIDE; - virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; - virtual bool Accept() OVERRIDE; - virtual string16 GetLinkText() const OVERRIDE; - virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; - - // PluginInstallerObserver: - virtual void DidStartDownload() OVERRIDE; - virtual void DidFinishDownload() OVERRIDE; - virtual void DownloadError(const std::string& message) OVERRIDE; - - // WeakPluginInstallerObserver: - virtual void OnlyWeakObserversLeft() OVERRIDE; - - // Replaces this infobar with one showing |message|. The new infobar will - // not have any buttons (and not call the callback). - void ReplaceWithInfoBar(const string16& message); - - base::Closure callback_; - - // True iff the plug-in isn't installed yet. - bool new_install_; - - string16 message_; - - DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); -}; - -#endif // CHROME_BROWSER_PLUGIN_INFOBAR_DELEGATES_H_ diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc index a69b06c..e812282 100644 --- a/chrome/browser/plugin_installer.cc +++ b/chrome/browser/plugin_installer.cc @@ -10,8 +10,6 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/plugin_download_helper.h" #include "chrome/browser/plugin_installer_observer.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/web_contents.h" PluginInstaller::~PluginInstaller() { } @@ -50,7 +48,8 @@ void PluginInstaller::RemoveWeakObserver( weak_observers_.RemoveObserver(observer); } -void PluginInstaller::StartInstalling(content::WebContents* web_contents) { +void PluginInstaller::StartInstalling( + net::URLRequestContextGetter* request_context) { DCHECK(state_ == kStateIdle); DCHECK(!url_for_display_); state_ = kStateDownloading; @@ -59,19 +58,14 @@ void PluginInstaller::StartInstalling(content::WebContents* web_contents) { PluginDownloadUrlHelper* downloader = new PluginDownloadUrlHelper(); downloader->InitiateDownload( plugin_url_, - web_contents->GetBrowserContext()->GetRequestContext(), + request_context, base::Bind(&PluginInstaller::DidFinishDownload, base::Unretained(this)), base::Bind(&PluginInstaller::DownloadError, base::Unretained(this))); } -void PluginInstaller::OpenDownloadURL(content::WebContents* web_contents) { +void PluginInstaller::DidOpenDownloadURL() { DCHECK(state_ == kStateIdle); DCHECK(url_for_display_); - web_contents->OpenURL(content::OpenURLParams( - plugin_url_, - content::Referrer(web_contents->GetURL(), - WebKit::WebReferrerPolicyDefault), - NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DidFinishDownload()); } diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer.h index a405354..6f76967 100644 --- a/chrome/browser/plugin_installer.h +++ b/chrome/browser/plugin_installer.h @@ -14,8 +14,8 @@ class FilePath; class PluginInstallerObserver; class WeakPluginInstallerObserver; -namespace content { -class WebContents; +namespace net { +class URLRequestContextGetter; } class PluginInstaller { @@ -57,14 +57,11 @@ class PluginInstaller { // URL to open when the user clicks on the "Problems installing?" link. const GURL& help_url() const { return help_url_; } - // Opens the download URL in a new tab. This method should only be called if - // |url_for_display| returns true. - void OpenDownloadURL(content::WebContents* web_contents); + void StartInstalling(net::URLRequestContextGetter* request_context); - // Starts downloading the download URL and opens the downloaded file - // when finished. This method should only be called if |url_for_display| - // returns false. - void StartInstalling(content::WebContents* web_contents); + // Called when the browser opened the download URL in a new tab, to notify + // observers. + void DidOpenDownloadURL(); private: void DidFinishDownload(const FilePath& downloaded_file); diff --git a/chrome/browser/plugin_installer_infobar_delegate.cc b/chrome/browser/plugin_installer_infobar_delegate.cc new file mode 100644 index 0000000..4716e40 --- /dev/null +++ b/chrome/browser/plugin_installer_infobar_delegate.cc @@ -0,0 +1,128 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/plugin_installer_infobar_delegate.h" + +#include "base/utf_string_conversions.h" +#include "chrome/browser/google/google_util.h" +#include "chrome/browser/infobars/infobar_tab_helper.h" +#include "chrome/browser/plugin_installer.h" +#include "content/browser/renderer_host/render_view_host.h" +#include "content/public/browser/web_contents.h" +#include "grit/generated_resources.h" +#include "grit/locale_settings.h" +#include "grit/theme_resources_standard.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" + +using content::OpenURLParams; +using content::Referrer; + +PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( + InfoBarTabHelper* infobar_helper, + PluginInstaller* installer, + const base::Closure& callback, + const string16& message) + : ConfirmInfoBarDelegate(infobar_helper), + WeakPluginInstallerObserver(installer), + callback_(callback), + message_(message) { +} + +PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { +} + +InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( + InfoBarTabHelper* infobar_helper, + PluginInstaller* installer, + const base::Closure& callback) { + string16 message; + switch (installer->state()) { + case PluginInstaller::kStateIdle: + message = l10n_util::GetStringFUTF16( + IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, installer->name()); + break; + case PluginInstaller::kStateDownloading: + message = l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING); + break; + } + return new PluginInstallerInfoBarDelegate( + infobar_helper, installer, callback, message); +} + +gfx::Image* PluginInstallerInfoBarDelegate::GetIcon() const { + return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( + IDR_INFOBAR_PLUGIN_INSTALL); +} + +string16 PluginInstallerInfoBarDelegate::GetMessageText() const { + return message_; +} + +int PluginInstallerInfoBarDelegate::GetButtons() const { + return callback_.is_null() ? BUTTON_NONE : BUTTON_OK; +} + +string16 PluginInstallerInfoBarDelegate::GetButtonLabel( + InfoBarButton button) const { + DCHECK_EQ(BUTTON_OK, button); + return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); +} + +bool PluginInstallerInfoBarDelegate::Accept() { + callback_.Run(); + return false; +} + +string16 PluginInstallerInfoBarDelegate::GetLinkText() const { + return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING); +} + +bool PluginInstallerInfoBarDelegate::LinkClicked( + WindowOpenDisposition disposition) { + GURL url(installer()->help_url()); + if (url.is_empty()) { + url = google_util::AppendGoogleLocaleParam(GURL( + "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); + } + + OpenURLParams params( + url, Referrer(), + (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, + content::PAGE_TRANSITION_LINK, false); + owner()->web_contents()->OpenURL(params); + return false; +} + +void PluginInstallerInfoBarDelegate::DidStartDownload() { + ReplaceWithInfoBar(l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOADING)); +} + +void PluginInstallerInfoBarDelegate::DidFinishDownload() { + ReplaceWithInfoBar(l10n_util::GetStringUTF16(IDS_PLUGIN_INSTALLING)); +} + +void PluginInstallerInfoBarDelegate::DownloadError(const std::string& message) { + ReplaceWithInfoBar( + l10n_util::GetStringUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT)); +} + +void PluginInstallerInfoBarDelegate::OnlyWeakObserversLeft() { + if (owner()) + owner()->RemoveInfoBar(this); +} + +void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar( + const string16& message) { + // Return early if the message doesn't change. This is important in case the + // PluginInstaller is still iterating over its observers (otherwise we would + // keep replacing infobar delegates infinitely). + if (message_ == message) + return; + if (!owner()) + return; + InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( + owner(), installer(), base::Closure(), message); + owner()->ReplaceInfoBar(this, delegate); +} diff --git a/chrome/browser/plugin_installer_infobar_delegate.h b/chrome/browser/plugin_installer_infobar_delegate.h new file mode 100644 index 0000000..5dad51e --- /dev/null +++ b/chrome/browser/plugin_installer_infobar_delegate.h @@ -0,0 +1,63 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_ +#define CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_ +#pragma once + +#include "base/callback.h" +#include "chrome/browser/plugin_installer_observer.h" +#include "chrome/browser/tab_contents/confirm_infobar_delegate.h" +#include "chrome/browser/tab_contents/link_infobar_delegate.h" +#include "googleurl/src/gurl.h" + +// The main purpose for this class is to popup/close the infobar when there is +// a missing plugin. +class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, + public WeakPluginInstallerObserver { + public: + // Shows an infobar asking whether to install the plugin represented by + // |installer|. When the user accepts, |callback| is called. + // During installation of the plug-in, the infobar will change to reflect the + // installation state. + static InfoBarDelegate* Create(InfoBarTabHelper* infobar_helper, + PluginInstaller* installer, + const base::Closure& callback); + + private: + PluginInstallerInfoBarDelegate(InfoBarTabHelper* infobar_helper, + PluginInstaller* installer, + const base::Closure& callback, + const string16& message); + virtual ~PluginInstallerInfoBarDelegate(); + + // ConfirmInfoBarDelegate: + virtual gfx::Image* GetIcon() const OVERRIDE; + virtual string16 GetMessageText() const OVERRIDE; + virtual int GetButtons() const OVERRIDE; + virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; + virtual bool Accept() OVERRIDE; + virtual string16 GetLinkText() const OVERRIDE; + virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; + + // PluginInstallerObserver: + virtual void DidStartDownload() OVERRIDE; + virtual void DidFinishDownload() OVERRIDE; + virtual void DownloadError(const std::string& message) OVERRIDE; + + // WeakPluginInstallerObserver: + virtual void OnlyWeakObserversLeft() OVERRIDE; + + // Replaces this infobar with one showing |message|. The new infobar will + // not have any buttons (and not call the callback). + void ReplaceWithInfoBar(const string16& message); + + base::Closure callback_; + + string16 message_; + + DISALLOW_COPY_AND_ASSIGN(PluginInstallerInfoBarDelegate); +}; + +#endif // CHROME_BROWSER_PLUGIN_INSTALLER_INFOBAR_DELEGATE_H_ diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index a221c85..39afcd5 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -19,6 +19,7 @@ #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" #include "content/browser/renderer_host/render_view_host.h" +#include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_delegate.h" #include "grit/generated_resources.h" @@ -26,25 +27,278 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" +#include "webkit/plugins/npapi/plugin_group.h" #include "webkit/plugins/webplugininfo.h" #if defined(ENABLE_PLUGIN_INSTALLATION) -#include "chrome/browser/plugin_infobar_delegates.h" #include "chrome/browser/plugin_installer.h" +#include "chrome/browser/plugin_installer_infobar_delegate.h" #include "chrome/browser/plugin_installer_observer.h" #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" #endif // defined(ENABLE_PLUGIN_INSTALLATION) using content::OpenURLParams; using content::Referrer; +using content::UserMetricsAction; using content::WebContents; namespace { -#if defined(ENABLE_PLUGIN_INSTALLATION) +// PluginInfoBarDelegate ------------------------------------------------------ + +class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { + public: + PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, const string16& name); + + protected: + virtual ~PluginInfoBarDelegate(); + + // ConfirmInfoBarDelegate: + virtual bool Cancel() OVERRIDE; + virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; + + virtual std::string GetLearnMoreURL() const = 0; + + string16 name_; + + private: + // ConfirmInfoBarDelegate: + virtual gfx::Image* GetIcon() const OVERRIDE; + virtual string16 GetLinkText() const OVERRIDE; + + DISALLOW_COPY_AND_ASSIGN(PluginInfoBarDelegate); +}; + +PluginInfoBarDelegate::PluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + const string16& name) + : ConfirmInfoBarDelegate(infobar_helper), + name_(name) { +} + +PluginInfoBarDelegate::~PluginInfoBarDelegate() { +} + +bool PluginInfoBarDelegate::Cancel() { + owner()->Send(new ChromeViewMsg_LoadBlockedPlugins(owner()->routing_id())); + return true; +} + +bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { + OpenURLParams params( + GURL(GetLearnMoreURL()), Referrer(), + (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, + content::PAGE_TRANSITION_LINK, + false); + owner()->web_contents()->OpenURL(params); + return false; +} + +gfx::Image* PluginInfoBarDelegate::GetIcon() const { + return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( + IDR_INFOBAR_PLUGIN_INSTALL); +} + +string16 PluginInfoBarDelegate::GetLinkText() const { + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); +} + + +// BlockedPluginInfoBarDelegate ----------------------------------------------- + +class BlockedPluginInfoBarDelegate : public PluginInfoBarDelegate { + public: + BlockedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + HostContentSettingsMap* content_settings, + const string16& name); + + private: + virtual ~BlockedPluginInfoBarDelegate(); + + // PluginInfoBarDelegate: + virtual string16 GetMessageText() const OVERRIDE; + virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; + virtual bool Accept() OVERRIDE; + virtual bool Cancel() OVERRIDE; + virtual void InfoBarDismissed() OVERRIDE; + virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; + virtual std::string GetLearnMoreURL() const OVERRIDE; + + HostContentSettingsMap* content_settings_; + + DISALLOW_COPY_AND_ASSIGN(BlockedPluginInfoBarDelegate); +}; + +BlockedPluginInfoBarDelegate::BlockedPluginInfoBarDelegate( + InfoBarTabHelper* infobar_helper, + HostContentSettingsMap* content_settings, + const string16& utf16_name) + : PluginInfoBarDelegate(infobar_helper, utf16_name), + content_settings_(content_settings) { + content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); + std::string name = UTF16ToUTF8(utf16_name); + if (name == webkit::npapi::PluginGroup::kJavaGroupName) + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Shown.Java")); + else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime")); + else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave")); + else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName) + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer")); + else if (name == webkit::npapi::PluginGroup::kWindowsMediaPlayerGroupName) + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Shown.WindowsMediaPlayer")); +} + +BlockedPluginInfoBarDelegate::~BlockedPluginInfoBarDelegate() { + content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed")); +} + +std::string BlockedPluginInfoBarDelegate::GetLearnMoreURL() const { + return chrome::kBlockedPluginLearnMoreURL; +} + +string16 BlockedPluginInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); +} + +string16 BlockedPluginInfoBarDelegate::GetButtonLabel( + InfoBarButton button) const { + return l10n_util::GetStringUTF16((button == BUTTON_OK) ? + IDS_PLUGIN_ENABLE_TEMPORARILY : IDS_PLUGIN_ENABLE_ALWAYS); +} + +bool BlockedPluginInfoBarDelegate::Accept() { + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); + return PluginInfoBarDelegate::Cancel(); +} + +bool BlockedPluginInfoBarDelegate::Cancel() { + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); + content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(), + owner()->web_contents()->GetURL(), + CONTENT_SETTINGS_TYPE_PLUGINS, + std::string(), + CONTENT_SETTING_ALLOW); + return PluginInfoBarDelegate::Cancel(); +} + +void BlockedPluginInfoBarDelegate::InfoBarDismissed() { + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.Dismissed")); +} + +bool BlockedPluginInfoBarDelegate::LinkClicked( + WindowOpenDisposition disposition) { + content::RecordAction( + UserMetricsAction("BlockedPluginInfobar.LearnMore")); + return PluginInfoBarDelegate::LinkClicked(disposition); +} + +// OutdatedPluginInfoBarDelegate ---------------------------------------------- -// ConfirmInstallDialogDelegate ------------------------------------------------ +class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate { + public: + OutdatedPluginInfoBarDelegate(InfoBarTabHelper* infobar_helper, + const string16& name, + const GURL& update_url); + + private: + virtual ~OutdatedPluginInfoBarDelegate(); + + // PluginInfoBarDelegate: + virtual string16 GetMessageText() const OVERRIDE; + virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; + virtual bool Accept() OVERRIDE; + virtual bool Cancel() OVERRIDE; + virtual void InfoBarDismissed() OVERRIDE; + virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; + virtual std::string GetLearnMoreURL() const OVERRIDE; + + GURL update_url_; + + DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); +}; + +OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( + InfoBarTabHelper* infobar_helper, + const string16& utf16_name, + const GURL& update_url) + : PluginInfoBarDelegate(infobar_helper, utf16_name), + update_url_(update_url) { + content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); + std::string name = UTF16ToUTF8(utf16_name); + if (name == webkit::npapi::PluginGroup::kJavaGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); + else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime")); + else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.Shockwave")); + else if (name == webkit::npapi::PluginGroup::kRealPlayerGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.RealPlayer")); + else if (name == webkit::npapi::PluginGroup::kSilverlightGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.Silverlight")); + else if (name == webkit::npapi::PluginGroup::kAdobeReaderGroupName) + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Shown.Reader")); +} + +OutdatedPluginInfoBarDelegate::~OutdatedPluginInfoBarDelegate() { + content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Closed")); +} + +std::string OutdatedPluginInfoBarDelegate::GetLearnMoreURL() const { + return chrome::kOutdatedPluginLearnMoreURL; +} + +string16 OutdatedPluginInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); +} + +string16 OutdatedPluginInfoBarDelegate::GetButtonLabel( + InfoBarButton button) const { + return l10n_util::GetStringUTF16((button == BUTTON_OK) ? + IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); +} + +bool OutdatedPluginInfoBarDelegate::Accept() { + content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); + OpenURLParams params( + update_url_, Referrer(), NEW_FOREGROUND_TAB, + content::PAGE_TRANSITION_LINK, false); + owner()->web_contents()->OpenURL(params); + return false; +} + +bool OutdatedPluginInfoBarDelegate::Cancel() { + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); + return PluginInfoBarDelegate::Cancel(); +} +void OutdatedPluginInfoBarDelegate::InfoBarDismissed() { + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.Dismissed")); +} + +bool OutdatedPluginInfoBarDelegate::LinkClicked( + WindowOpenDisposition disposition) { + content::RecordAction( + UserMetricsAction("OutdatedPluginInfobar.LearnMore")); + return PluginInfoBarDelegate::LinkClicked(disposition); +} + +#if defined(ENABLE_PLUGIN_INSTALLATION) class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, public WeakPluginInstallerObserver { public: @@ -63,7 +317,7 @@ class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, virtual void OnlyWeakObserversLeft() OVERRIDE; private: - content::WebContents* web_contents_; + net::URLRequestContextGetter* request_context_; }; ConfirmInstallDialogDelegate::ConfirmInstallDialogDelegate( @@ -71,7 +325,7 @@ ConfirmInstallDialogDelegate::ConfirmInstallDialogDelegate( PluginInstaller* installer) : TabModalConfirmDialogDelegate(web_contents), WeakPluginInstallerObserver(installer), - web_contents_(web_contents) { + request_context_(web_contents->GetBrowserContext()->GetRequestContext()) { } string16 ConfirmInstallDialogDelegate::GetTitle() { @@ -90,7 +344,7 @@ string16 ConfirmInstallDialogDelegate::GetAcceptButtonTitle() { } void ConfirmInstallDialogDelegate::OnAccepted() { - installer()->StartInstalling(web_contents_); + installer()->StartInstalling(request_context_); } void ConfirmInstallDialogDelegate::OnCanceled() { @@ -185,31 +439,19 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { return true; } -void PluginObserver::OnBlockedUnauthorizedPlugin(const string16& name) { +void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, + const GURL& update_url) { InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); infobar_helper->AddInfoBar( - new UnauthorizedPluginInfoBarDelegate( - infobar_helper, - tab_contents_->profile()->GetHostContentSettingsMap(), - name)); + new OutdatedPluginInfoBarDelegate(infobar_helper, name, update_url)); } -void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, - const std::string& identifier) { - PluginFinder* plugin_finder = PluginFinder::GetInstance(); - plugin_finder->FindPluginWithIdentifier( - identifier, - base::Bind(&PluginObserver::FoundPluginToUpdate, - weak_ptr_factory_.GetWeakPtr(), placeholder_id)); -} - -void PluginObserver::FoundPluginToUpdate(int placeholder_id, - PluginInstaller* installer) { - plugin_placeholders_[placeholder_id] = - new PluginPlaceholderHost(this, placeholder_id, installer); +void PluginObserver::OnBlockedUnauthorizedPlugin(const string16& name) { InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); - infobar_helper->AddInfoBar( - OutdatedPluginInfoBarDelegate::Create(this, installer)); + infobar_helper->AddInfoBar(new BlockedPluginInfoBarDelegate( + infobar_helper, + tab_contents_->profile()->GetHostContentSettingsMap(), + name)); } #if defined(ENABLE_PLUGIN_INSTALLATION) @@ -220,17 +462,14 @@ void PluginObserver::OnFindMissingPlugin(int placeholder_id, plugin_finder->FindPlugin( mime_type, lang, base::Bind(&PluginObserver::FoundMissingPlugin, - weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type)); + weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type), + base::Bind(&PluginObserver::DidNotFindMissingPlugin, + weak_ptr_factory_.GetWeakPtr(), placeholder_id)); } void PluginObserver::FoundMissingPlugin(int placeholder_id, const std::string& mime_type, PluginInstaller* installer) { - if (!installer) { - Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); - return; - } - plugin_placeholders_[placeholder_id] = new PluginPlaceholderHost(this, placeholder_id, installer); InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); @@ -241,9 +480,18 @@ void PluginObserver::FoundMissingPlugin(int placeholder_id, infobar_helper->AddInfoBar(delegate); } +void PluginObserver::DidNotFindMissingPlugin(int placeholder_id) { + Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); +} + void PluginObserver::InstallMissingPlugin(PluginInstaller* installer) { if (installer->url_for_display()) { - installer->OpenDownloadURL(web_contents()); + web_contents()->OpenURL(OpenURLParams( + installer->plugin_url(), + content::Referrer(web_contents()->GetURL(), + WebKit::WebReferrerPolicyDefault), + NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); + installer->DidOpenDownloadURL(); } else { browser::ShowTabModalConfirmDialog( new ConfirmInstallDialogDelegate(web_contents(), installer), diff --git a/chrome/browser/plugin_observer.h b/chrome/browser/plugin_observer.h index 36e039f..4000fce 100644 --- a/chrome/browser/plugin_observer.h +++ b/chrome/browser/plugin_observer.h @@ -20,7 +20,6 @@ class TabContentsWrapper; #if defined(ENABLE_PLUGIN_INSTALLATION) class PluginInstaller; -class PluginPlaceholderHost; #endif class PluginObserver : public content::WebContentsObserver { @@ -31,26 +30,21 @@ class PluginObserver : public content::WebContentsObserver { // content::WebContentsObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; -#if defined(ENABLE_PLUGIN_INSTALLATION) - void InstallMissingPlugin(PluginInstaller* installer); -#endif - - TabContentsWrapper* tab_contents_wrapper() { return tab_contents_; } - private: +#if defined(ENABLE_PLUGIN_INSTALLATION) class PluginPlaceholderHost; +#endif + void OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url); void OnBlockedUnauthorizedPlugin(const string16& name); - void OnBlockedOutdatedPlugin(int placeholder_id, - const std::string& identifier); #if defined(ENABLE_PLUGIN_INSTALLATION) void OnFindMissingPlugin(int placeholder_id, const std::string& mime_type); void FoundMissingPlugin(int placeholder_id, const std::string& mime_type, PluginInstaller* installer); - void FoundPluginToUpdate(int placeholder_id, - PluginInstaller* installer); + void DidNotFindMissingPlugin(int placeholder_id); + void InstallMissingPlugin(PluginInstaller* installer); #endif void OnOpenAboutPlugins(); void OnRemovePluginPlaceholderHost(int placeholder_id); diff --git a/chrome/browser/resources/plugins_linux.json b/chrome/browser/resources/plugins_linux.json deleted file mode 100644 index d410de0..0000000 --- a/chrome/browser/resources/plugins_linux.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "plugins": [ - { - "mime_types": [ - "application/x-java-applet", - "application/x-java-applet,version=1.1", - "application/x-java-applet,version=1.1.1", - "application/x-java-applet,version=1.1.2", - "application/x-java-applet,version=1.1.3", - "application/x-java-applet,version=1.2", - "application/x-java-applet,version=1.2.1", - "application/x-java-applet,version=1.2.2", - "application/x-java-applet,version=1.3", - "application/x-java-applet,version=1.3.1", - "application/x-java-applet,version=1.4", - "application/x-java-applet,version=1.4.1", - "application/x-java-applet,version=1.4.2", - "application/x-java-applet,version=1.5", - "application/x-java-applet,version=1.6", - "application/x-java-bean", - "application/x-java-bean,version=1.1", - "application/x-java-bean,version=1.1.1", - "application/x-java-bean,version=1.1.2", - "application/x-java-bean,version=1.1.3", - "application/x-java-bean,version=1.2", - "application/x-java-bean,version=1.2.1", - "application/x-java-bean,version=1.2.2", - "application/x-java-bean,version=1.3", - "application/x-java-bean,version=1.3.1", - "application/x-java-bean,version=1.4", - "application/x-java-bean,version=1.4.1", - "application/x-java-bean,version=1.4.2", - "application/x-java-bean,version=1.5", - "application/x-java-bean,version=1.6", - "application/x-java-vm" - ], - "lang": "en-US", - "name": "Java(TM)", - "identifier": "java-runtime-environment", - "help_url": "https://support.google.com/chrome/?p=plugin_java", - "url": "http://java.com/download", - "displayurl": true - }, - { - "mime_types": [ - "application/futuresplash", - "application/x-shockwave-flash" - ], - "lang": "en-US", - "name": "Adobe Flash Player", - "identifier": "adobe-flash-player", - "help_url": "https://support.google.com/chrome/?p=plugin_flash", - "url": "http://get.adobe.com/flashplayer/", - "displayurl": true - }, - { - "mime_types": [ - ], - "lang": "en-US", - "name": "IcedTea", - "identifier": "redhat-icetea-java", - "url": "http://icedtea.classpath.org/", - "displayurl": true - } - ] -} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 0ed88b7..5786125 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1804,8 +1804,8 @@ 'browser/plugin_finder.h', 'browser/plugin_installer.cc', 'browser/plugin_installer.h', - 'browser/plugin_infobar_delegates.cc', - 'browser/plugin_infobar_delegates.h', + 'browser/plugin_installer_infobar_delegate.cc', + 'browser/plugin_installer_infobar_delegate.h', 'browser/plugin_installer_observer.cc', 'browser/plugin_installer_observer.h', 'browser/plugin_observer.cc', @@ -5422,6 +5422,8 @@ 'browser/plugin_finder.h', 'browser/plugin_installer.cc', 'browser/plugin_installer.h', + 'browser/plugin_installer_infobar_delegate.cc', + 'browser/plugin_installer_infobar_delegate.h', 'browser/plugin_installer_observer.cc', 'browser/plugin_installer_observer.h', ], diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 1649487..327f2f5 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -534,8 +534,8 @@ IPC_MESSAGE_CONTROL1(ChromeViewHostMsg_DnsPrefetch, // Notifies when a plugin couldn't be loaded because it's outdated. IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_BlockedOutdatedPlugin, - int /* placeholder ID */, - std::string /* plug-in group identifier */) + string16, /* name */ + GURL /* update_url */) // Notifies when a plugin couldn't be loaded because it requires // user authorization. diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc index 66a7744..e565ee4 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc @@ -432,17 +432,13 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( break; } case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedBlocked: { -#if defined(ENABLE_PLUGIN_INSTALLATION) placeholder = PluginPlaceholder::CreateBlockedPlugin( render_view, frame, params, plugin, name, IDR_BLOCKED_PLUGIN_HTML, IDS_PLUGIN_OUTDATED); placeholder->set_allow_loading(true); render_view->Send(new ChromeViewHostMsg_BlockedOutdatedPlugin( - render_view->GetRoutingId(), placeholder->CreateRoutingId(), - group->identifier())); -#else - NOTREACHED(); -#endif + render_view->GetRoutingId(), group->GetGroupName(), + GURL(group->GetUpdateURL()))); break; } case ChromeViewHostMsg_GetPluginInfo_Status::kOutdatedDisallowed: { diff --git a/chrome/renderer/plugins/plugin_placeholder.cc b/chrome/renderer/plugins/plugin_placeholder.cc index f49fc72..651dd75 100644 --- a/chrome/renderer/plugins/plugin_placeholder.cc +++ b/chrome/renderer/plugins/plugin_placeholder.cc @@ -310,10 +310,7 @@ void PluginPlaceholder::OnStartedDownloadingPlugin() { } void PluginPlaceholder::OnFinishedDownloadingPlugin() { - bool is_installing = - status_->value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; - SetMessage(l10n_util::GetStringUTF16( - is_installing ? IDS_PLUGIN_INSTALLING : IDS_PLUGIN_UPDATING)); + SetMessage(l10n_util::GetStringUTF16(IDS_PLUGIN_INSTALLING)); } void PluginPlaceholder::OnErrorDownloadingPlugin(const std::string& error) { |