diff options
author | dharani@google.com <dharani@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-28 17:03:14 +0000 |
---|---|---|
committer | dharani@google.com <dharani@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-28 17:03:14 +0000 |
commit | 2860a1f4a8fffd36b47eaace3b86cf06cc3faa2e (patch) | |
tree | 43a94f35afd6a54bafae9e4ea4386e0080c5084f /chrome | |
parent | 3cbe721a3d66e2f755d9fb1379298bfc73e291e0 (diff) | |
download | chromium_src-2860a1f4a8fffd36b47eaace3b86cf06cc3faa2e.zip chromium_src-2860a1f4a8fffd36b47eaace3b86cf06cc3faa2e.tar.gz chromium_src-2860a1f4a8fffd36b47eaace3b86cf06cc3faa2e.tar.bz2 |
Revert 159068 - PluginFinder returns copies of PluginMetadata and PluginInstaller no more aggregate PluginMetadata
Reverted due to bug 152950
BUG=124396
Review URL: https://chromiumcodereview.appspot.com/10958071
TBR=ibraaaa@google.com
Review URL: https://codereview.chromium.org/10981069
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/api/content_settings/content_settings_api.cc | 3 | ||||
-rw-r--r-- | chrome/browser/pepper_broker_observer.cc | 5 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_finder.cc | 51 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_finder.h | 24 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_infobar_delegates.cc | 61 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_infobar_delegates.h | 11 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_installer.cc | 22 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_installer.h | 29 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_metadata.cc | 11 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_metadata.h | 5 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_observer.cc | 77 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_observer.h | 5 | ||||
-rw-r--r-- | chrome/browser/plugins/plugin_prefs.cc | 21 | ||||
-rw-r--r-- | chrome/browser/renderer_host/plugin_info_message_filter.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/pdf/pdf_unsupported_feature.cc | 9 | ||||
-rw-r--r-- | chrome/browser/ui/webui/plugins_ui.cc | 8 |
16 files changed, 129 insertions, 218 deletions
diff --git a/chrome/browser/extensions/api/content_settings/content_settings_api.cc b/chrome/browser/extensions/api/content_settings/content_settings_api.cc index ce001ca..5c6e02f 100644 --- a/chrome/browser/extensions/api/content_settings/content_settings_api.cc +++ b/chrome/browser/extensions/api/content_settings/content_settings_api.cc @@ -9,7 +9,6 @@ #include "base/bind.h" #include "base/command_line.h" -#include "base/memory/scoped_ptr.h" #include "base/values.h" #include "chrome/browser/content_settings/cookie_settings.h" #include "chrome/browser/content_settings/host_content_settings_map.h" @@ -274,7 +273,7 @@ void GetResourceIdentifiersFunction::OnGotPlugins( ListValue* list = new ListValue(); for (std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin(); it != plugins.end(); ++it) { - scoped_ptr<PluginMetadata> plugin_metadata(finder->GetPluginMetadata(*it)); + PluginMetadata* plugin_metadata = finder->GetPluginMetadata(*it); const std::string& group_identifier = plugin_metadata->identifier(); if (group_identifiers.find(group_identifier) != group_identifiers.end()) continue; diff --git a/chrome/browser/pepper_broker_observer.cc b/chrome/browser/pepper_broker_observer.cc index 614c06b..0f84010 100644 --- a/chrome/browser/pepper_broker_observer.cc +++ b/chrome/browser/pepper_broker_observer.cc @@ -4,7 +4,6 @@ #include "chrome/browser/pepper_broker_observer.h" -#include "base/memory/scoped_ptr.h" #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/infobars/infobar_tab_helper.h" @@ -102,8 +101,8 @@ string16 PepperBrokerInfoBarDelegate::GetMessageText() const { webkit::WebPluginInfo plugin; bool success = plugin_service->GetPluginInfoByPath(plugin_path_, &plugin); DCHECK(success); - scoped_ptr<PluginMetadata> plugin_metadata( - PluginFinder::GetInstance()->GetPluginMetadata(plugin)); + PluginMetadata* plugin_metadata = + PluginFinder::GetInstance()->GetPluginMetadata(plugin); return l10n_util::GetStringFUTF16(IDS_PEPPER_BROKER_MESSAGE, plugin_metadata->name(), net::FormatUrl(url_.GetOrigin(), diff --git a/chrome/browser/plugins/plugin_finder.cc b/chrome/browser/plugins/plugin_finder.cc index aded8b6..be73b16 100644 --- a/chrome/browser/plugins/plugin_finder.cc +++ b/chrome/browser/plugins/plugin_finder.cc @@ -84,7 +84,7 @@ void PluginFinder::Init() { identifier_plugin_[identifier] = metadata; #if defined(ENABLE_PLUGIN_INSTALLATION) - installers_[identifier] = new PluginInstaller(); + installers_[identifier] = new PluginInstaller(metadata); #endif } } @@ -122,13 +122,10 @@ PluginFinder::~PluginFinder() { } #if defined(ENABLE_PLUGIN_INSTALLATION) -bool PluginFinder::FindPlugin( - const std::string& mime_type, - const std::string& language, - PluginInstaller** installer, - scoped_ptr<PluginMetadata>* plugin_metadata) { +PluginInstaller* PluginFinder::FindPlugin(const std::string& mime_type, + const std::string& language) { if (g_browser_process->local_state()->GetBoolean(prefs::kDisablePluginFinder)) - return false; + return NULL; for (DictionaryValue::Iterator plugin_it(*plugin_list_); plugin_it.HasNext(); plugin_it.Advance()) { const DictionaryValue* plugin = NULL; @@ -152,40 +149,26 @@ bool PluginFinder::FindPlugin( std::string identifier = plugin_it.key(); { base::AutoLock lock(mutex_); - std::map<std::string, PluginMetadata*>::const_iterator metadata_it = - identifier_plugin_.find(identifier); - DCHECK(metadata_it != identifier_plugin_.end()); - *plugin_metadata = metadata_it->second->Clone(); - - std::map<std::string, PluginInstaller*>::const_iterator installer_it = + std::map<std::string, PluginInstaller*>::const_iterator installer = installers_.find(identifier); - DCHECK(installer_it != installers_.end()); - *installer = installer_it->second; - return true; + DCHECK(installer != installers_.end()); + return installer->second; } } } } - return false; + return NULL; } -bool PluginFinder::FindPluginWithIdentifier( - const std::string& identifier, - PluginInstaller** installer, - scoped_ptr<PluginMetadata>* plugin_metadata) { +PluginInstaller* PluginFinder::FindPluginWithIdentifier( + const std::string& identifier) { base::AutoLock lock(mutex_); std::map<std::string, PluginInstaller*>::const_iterator it = installers_.find(identifier); - if (it != installers_.end()) { - *installer = it->second; - std::map<std::string, PluginMetadata*>::const_iterator metadata_it = - identifier_plugin_.find(identifier); - DCHECK(metadata_it != identifier_plugin_.end()); - *plugin_metadata = metadata_it->second->Clone(); - return true; - } + if (it != installers_.end()) + return it->second; - return false; + return NULL; } #endif @@ -250,11 +233,11 @@ PluginMetadata* PluginFinder::CreatePluginMetadata( return plugin; } -scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata( +PluginMetadata* PluginFinder::GetPluginMetadata( const webkit::WebPluginInfo& plugin) { base::AutoLock lock(mutex_); if (name_plugin_.find(plugin.name) != name_plugin_.end()) - return name_plugin_[plugin.name]->Clone(); + return name_plugin_[plugin.name]; // Use the group name matcher to find the plug-in metadata we want. for (std::map<std::string, PluginMetadata*>::const_iterator it = @@ -263,7 +246,7 @@ scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata( continue; name_plugin_[plugin.name] = it->second; - return it->second->Clone(); + return it->second; } // The plug-in metadata was not found, create a dummy one holding @@ -276,5 +259,5 @@ scoped_ptr<PluginMetadata> PluginFinder::GetPluginMetadata( name_plugin_[plugin.name] = metadata; identifier_plugin_[identifier] = metadata; - return metadata->Clone(); + return metadata; } diff --git a/chrome/browser/plugins/plugin_finder.h b/chrome/browser/plugins/plugin_finder.h index dacecb4..b681e50 100644 --- a/chrome/browser/plugins/plugin_finder.h +++ b/chrome/browser/plugins/plugin_finder.h @@ -39,28 +39,20 @@ class PluginFinder { #if defined(ENABLE_PLUGIN_INSTALLATION) // Finds a plug-in for the given MIME type and language (specified as an IETF - // language tag, i.e. en-US). If found, sets |installer| to the - // corresponding PluginInstaller and |plugin_metadata| to a copy of the - // corresponding PluginMetadata. - bool FindPlugin(const std::string& mime_type, - const std::string& language, - PluginInstaller** installer, - scoped_ptr<PluginMetadata>* plugin_metadata); - - // Finds the plug-in with the given identifier. If found, sets |installer| - // to the corresponding PluginInstaller and |plugin_metadata| to a copy - // of the corresponding PluginMetadata. - bool FindPluginWithIdentifier(const std::string& identifier, - PluginInstaller** installer, - scoped_ptr<PluginMetadata>* plugin_metadata); + // language tag, i.e. en-US) and returns the PluginInstaller for the plug-in, + // or NULL if no plug-in is found. + PluginInstaller* FindPlugin(const std::string& mime_type, + const std::string& language); + + // Returns the plug-in with the given identifier. + PluginInstaller* FindPluginWithIdentifier(const std::string& identifier); #endif // Returns the plug-in name with the given identifier. string16 FindPluginNameWithIdentifier(const std::string& identifier); // Gets plug-in metadata using |plugin|. - scoped_ptr<PluginMetadata> GetPluginMetadata( - const webkit::WebPluginInfo& plugin); + PluginMetadata* GetPluginMetadata(const webkit::WebPluginInfo& plugin); private: friend struct DefaultSingletonTraits<PluginFinder>; diff --git a/chrome/browser/plugins/plugin_infobar_delegates.cc b/chrome/browser/plugins/plugin_infobar_delegates.cc index 78607fc..0d5e7fd 100644 --- a/chrome/browser/plugins/plugin_infobar_delegates.cc +++ b/chrome/browser/plugins/plugin_infobar_delegates.cc @@ -155,38 +155,35 @@ bool UnauthorizedPluginInfoBarDelegate::LinkClicked( InfoBarDelegate* OutdatedPluginInfoBarDelegate::Create( content::WebContents* web_contents, - PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata) { + PluginInstaller* installer) { string16 message; switch (installer->state()) { case PluginInstaller::INSTALLER_STATE_IDLE: message = l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, - plugin_metadata->name()); + installer->name()); break; case PluginInstaller::INSTALLER_STATE_DOWNLOADING: message = l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, - plugin_metadata->name()); + installer->name()); break; } return new OutdatedPluginInfoBarDelegate( - web_contents, installer, plugin_metadata.Pass(), message); + web_contents, installer, message); } OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( content::WebContents* web_contents, PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata, const string16& message) : PluginInfoBarDelegate( InfoBarService::FromTabContents( TabContents::FromWebContents(web_contents)), - plugin_metadata->name(), - plugin_metadata->identifier()), + installer->name(), + installer->identifier()), WeakPluginInstallerObserver(installer), - plugin_metadata_(plugin_metadata.Pass()), message_(message) { content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); - std::string name = UTF16ToUTF8(plugin_metadata_->name()); + std::string name = UTF16ToUTF8(installer->name()); if (name == PluginMetadata::kJavaGroupName) content::RecordAction( UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); @@ -233,14 +230,10 @@ bool OutdatedPluginInfoBarDelegate::Accept() { } content::WebContents* web_contents = owner()->GetWebContents(); - if (plugin_metadata_->url_for_display()) { - installer()->OpenDownloadURL(plugin_metadata_->url_for_display(), - plugin_metadata_->plugin_url(), - web_contents); + if (installer()->url_for_display()) { + installer()->OpenDownloadURL(web_contents); } else { installer()->StartInstalling( - plugin_metadata_->url_for_display(), - plugin_metadata_->plugin_url(), TabContents::FromWebContents(web_contents)); } return false; @@ -267,23 +260,23 @@ bool OutdatedPluginInfoBarDelegate::LinkClicked( void OutdatedPluginInfoBarDelegate::DownloadStarted() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, - plugin_metadata_->name())); + installer()->name())); } void OutdatedPluginInfoBarDelegate::DownloadError(const std::string& message) { ReplaceWithInfoBar( l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT, - plugin_metadata_->name())); + installer()->name())); } void OutdatedPluginInfoBarDelegate::DownloadCancelled() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, - plugin_metadata_->name())); + installer()->name())); } void OutdatedPluginInfoBarDelegate::DownloadFinished() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_UPDATING, - plugin_metadata_->name())); + installer()->name())); } void OutdatedPluginInfoBarDelegate::OnlyWeakObserversLeft() { @@ -301,8 +294,7 @@ void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar( if (!owner()) return; InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( - owner(), installer(), plugin_metadata_->Clone(), - base::Closure(), false, message); + owner(), installer(), base::Closure(), false, message); owner()->ReplaceInfoBar(this, delegate); } @@ -311,13 +303,11 @@ void OutdatedPluginInfoBarDelegate::ReplaceWithInfoBar( PluginInstallerInfoBarDelegate::PluginInstallerInfoBarDelegate( InfoBarService* infobar_service, PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata, const base::Closure& callback, bool new_install, const string16& message) : ConfirmInfoBarDelegate(infobar_service), WeakPluginInstallerObserver(installer), - plugin_metadata_(plugin_metadata.Pass()), callback_(callback), new_install_(new_install), message_(message) { @@ -329,22 +319,20 @@ PluginInstallerInfoBarDelegate::~PluginInstallerInfoBarDelegate() { InfoBarDelegate* PluginInstallerInfoBarDelegate::Create( InfoBarService* infobar_service, PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata, const base::Closure& callback) { string16 message; + const string16& plugin_name = installer->name(); switch (installer->state()) { case PluginInstaller::INSTALLER_STATE_IDLE: message = l10n_util::GetStringFUTF16( - IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, plugin_metadata->name()); + IDS_PLUGININSTALLER_INSTALLPLUGIN_PROMPT, plugin_name); break; case PluginInstaller::INSTALLER_STATE_DOWNLOADING: - message = l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, - plugin_metadata->name()); + message = l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, plugin_name); break; } return new PluginInstallerInfoBarDelegate( - infobar_service, installer, plugin_metadata.Pass(), - callback, true, message); + infobar_service, installer, callback, true, message); } gfx::Image* PluginInstallerInfoBarDelegate::GetIcon() const { @@ -379,7 +367,7 @@ string16 PluginInstallerInfoBarDelegate::GetLinkText() const { bool PluginInstallerInfoBarDelegate::LinkClicked( WindowOpenDisposition disposition) { - GURL url(plugin_metadata_->help_url()); + 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")); @@ -395,24 +383,24 @@ bool PluginInstallerInfoBarDelegate::LinkClicked( void PluginInstallerInfoBarDelegate::DownloadStarted() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, - plugin_metadata_->name())); + installer()->name())); } void PluginInstallerInfoBarDelegate::DownloadCancelled() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, - plugin_metadata_->name())); + installer()->name())); } void PluginInstallerInfoBarDelegate::DownloadError(const std::string& message) { ReplaceWithInfoBar( l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_ERROR_SHORT, - plugin_metadata_->name())); + installer()->name())); } void PluginInstallerInfoBarDelegate::DownloadFinished() { ReplaceWithInfoBar(l10n_util::GetStringFUTF16( new_install_ ? IDS_PLUGIN_INSTALLING : IDS_PLUGIN_UPDATING, - plugin_metadata_->name())); + installer()->name())); } void PluginInstallerInfoBarDelegate::OnlyWeakObserversLeft() { @@ -430,8 +418,7 @@ void PluginInstallerInfoBarDelegate::ReplaceWithInfoBar( if (!owner()) return; InfoBarDelegate* delegate = new PluginInstallerInfoBarDelegate( - owner(), installer(), plugin_metadata_->Clone(), - base::Closure(), new_install_, message); + owner(), installer(), base::Closure(), new_install_, message); owner()->ReplaceInfoBar(this, delegate); } diff --git a/chrome/browser/plugins/plugin_infobar_delegates.h b/chrome/browser/plugins/plugin_infobar_delegates.h index 85fa159..08937d7 100644 --- a/chrome/browser/plugins/plugin_infobar_delegates.h +++ b/chrome/browser/plugins/plugin_infobar_delegates.h @@ -15,7 +15,6 @@ class InfoBarService; class HostContentSettingsMap; -class PluginMetadata; namespace content { class WebContents; @@ -81,13 +80,11 @@ class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, public WeakPluginInstallerObserver { public: static InfoBarDelegate* Create(content::WebContents* web_contents, - PluginInstaller* installer, - scoped_ptr<PluginMetadata> metadata); + PluginInstaller* installer); private: OutdatedPluginInfoBarDelegate(content::WebContents* web_contents, PluginInstaller* installer, - scoped_ptr<PluginMetadata> metadata, const string16& message); virtual ~OutdatedPluginInfoBarDelegate(); @@ -113,8 +110,6 @@ class OutdatedPluginInfoBarDelegate : public PluginInfoBarDelegate, // not have any buttons (and not call the callback). void ReplaceWithInfoBar(const string16& message); - scoped_ptr<PluginMetadata> plugin_metadata_; - string16 message_; DISALLOW_COPY_AND_ASSIGN(OutdatedPluginInfoBarDelegate); @@ -131,7 +126,6 @@ class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, // installation state. static InfoBarDelegate* Create(InfoBarService* infobar_service, PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata, const base::Closure& callback); private: @@ -139,7 +133,6 @@ class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, PluginInstallerInfoBarDelegate(InfoBarService* infobar_service, PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata, const base::Closure& callback, bool new_install, const string16& message); @@ -167,8 +160,6 @@ class PluginInstallerInfoBarDelegate : public ConfirmInfoBarDelegate, // not have any buttons (and not call the callback). void ReplaceWithInfoBar(const string16& message); - scoped_ptr<PluginMetadata> plugin_metadata_; - base::Closure callback_; // True iff the plug-in isn't installed yet. diff --git a/chrome/browser/plugins/plugin_installer.cc b/chrome/browser/plugins/plugin_installer.cc index 678addd..2c5a582 100644 --- a/chrome/browser/plugins/plugin_installer.cc +++ b/chrome/browser/plugins/plugin_installer.cc @@ -66,8 +66,10 @@ void BeginDownload( } // namespace -PluginInstaller::PluginInstaller() - : state_(INSTALLER_STATE_IDLE) { +PluginInstaller::PluginInstaller(PluginMetadata* plugin) + : plugin_(plugin), + state_(INSTALLER_STATE_IDLE) { + DCHECK(plugin_); } PluginInstaller::~PluginInstaller() { @@ -129,11 +131,9 @@ void PluginInstaller::RemoveWeakObserver( weak_observers_.RemoveObserver(observer); } -void PluginInstaller::StartInstalling(bool url_for_display, - const GURL& plugin_url, - TabContents* tab_contents) { +void PluginInstaller::StartInstalling(TabContents* tab_contents) { DCHECK_EQ(INSTALLER_STATE_IDLE, state_); - DCHECK(url_for_display); + DCHECK(!plugin_->url_for_display()); state_ = INSTALLER_STATE_DOWNLOADING; FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadStarted()); content::WebContents* web_contents = tab_contents->web_contents(); @@ -144,7 +144,7 @@ void PluginInstaller::StartInstalling(bool url_for_display, BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&BeginDownload, - plugin_url, + plugin_->plugin_url(), tab_contents->profile()->GetResourceContext(), web_contents->GetRenderProcessHost()->GetID(), web_contents->GetRenderViewHost()->GetRoutingID(), @@ -174,13 +174,11 @@ void PluginInstaller::DownloadStarted( download_item->AddObserver(this); } -void PluginInstaller::OpenDownloadURL(bool url_for_display, - const GURL& plugin_url, - content::WebContents* web_contents) { +void PluginInstaller::OpenDownloadURL(content::WebContents* web_contents) { DCHECK_EQ(INSTALLER_STATE_IDLE, state_); - DCHECK(url_for_display); + DCHECK(plugin_->url_for_display()); web_contents->OpenURL(content::OpenURLParams( - plugin_url, + plugin_->plugin_url(), content::Referrer(web_contents->GetURL(), WebKit::WebReferrerPolicyDefault), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); diff --git a/chrome/browser/plugins/plugin_installer.h b/chrome/browser/plugins/plugin_installer.h index 8dca3fd..322ef06 100644 --- a/chrome/browser/plugins/plugin_installer.h +++ b/chrome/browser/plugins/plugin_installer.h @@ -34,7 +34,7 @@ class PluginInstaller : public content::DownloadItem::Observer { INSTALLER_STATE_DOWNLOADING, }; - PluginInstaller(); + explicit PluginInstaller(PluginMetadata* plugin); virtual ~PluginInstaller(); virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; @@ -46,20 +46,32 @@ class PluginInstaller : public content::DownloadItem::Observer { void AddWeakObserver(WeakPluginInstallerObserver* observer); void RemoveWeakObserver(WeakPluginInstallerObserver* observer); + // Unique identifier for the plug-in. + const std::string& identifier() const { return plugin_->identifier(); } + + // Human-readable name of the plug-in. + const string16& name() const { return plugin_->name(); } + + // If |url_for_display| is false, |plugin_url| is the URL of the download page + // for the plug-in, which should be opened in a new tab. If it is true, + // |plugin_url| is the URL of the plug-in installer binary, which can be + // directly downloaded. + bool url_for_display() const { return plugin_->url_for_display(); } + const GURL& plugin_url() const { return plugin_->plugin_url(); } + + // URL to open when the user clicks on the "Problems installing?" link. + const GURL& help_url() const { return plugin_->help_url(); } + InstallerState state() const { return state_; } // Opens the download URL in a new tab. This method should only be called if // |url_for_display| returns true. - void OpenDownloadURL(bool url_for_display, - const GURL& plugin_url, - content::WebContents* web_contents); + void OpenDownloadURL(content::WebContents* web_contents); // 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(bool url_for_display, - const GURL& plugin_url, - TabContents* tab_contents); + void StartInstalling(TabContents* tab_contents); private: void DownloadStarted(scoped_refptr<content::DownloadManager> dlm, @@ -68,6 +80,9 @@ class PluginInstaller : public content::DownloadItem::Observer { void DownloadError(const std::string& msg); void DownloadCancelled(); + // Can't be NULL. It is owned by PluginFinder. + PluginMetadata* plugin_; + InstallerState state_; ObserverList<PluginInstallerObserver> observers_; ObserverList<WeakPluginInstallerObserver> weak_observers_; diff --git a/chrome/browser/plugins/plugin_metadata.cc b/chrome/browser/plugins/plugin_metadata.cc index 5013c7f..3062f6f 100644 --- a/chrome/browser/plugins/plugin_metadata.cc +++ b/chrome/browser/plugins/plugin_metadata.cc @@ -93,14 +93,3 @@ bool PluginMetadata::VersionComparator::operator() (const Version& lhs, // Keep versions ordered by newest (biggest) first. return lhs.CompareTo(rhs) > 0; } - -scoped_ptr<PluginMetadata> PluginMetadata::Clone() const { - PluginMetadata* copy = new PluginMetadata(identifier_, - name_, - url_for_display_, - plugin_url_, - help_url_, - group_name_matcher_); - copy->versions_ = versions_; - return make_scoped_ptr(copy); -} diff --git a/chrome/browser/plugins/plugin_metadata.h b/chrome/browser/plugins/plugin_metadata.h index b8ca5e0..0f63ac4 100644 --- a/chrome/browser/plugins/plugin_metadata.h +++ b/chrome/browser/plugins/plugin_metadata.h @@ -7,7 +7,6 @@ #include <map> -#include "base/memory/scoped_ptr.h" #include "base/string16.h" #include "base/version.h" #include "googleurl/src/gurl.h" @@ -74,8 +73,6 @@ class PluginMetadata { // considered out-of-date, etc.) SecurityStatus GetSecurityStatus(const webkit::WebPluginInfo& plugin) const; - scoped_ptr<PluginMetadata> Clone() const; - private: struct VersionComparator { bool operator() (const Version& lhs, const Version& rhs) const; @@ -88,8 +85,6 @@ class PluginMetadata { GURL plugin_url_; GURL help_url_; std::map<Version, SecurityStatus, VersionComparator> versions_; - - DISALLOW_COPY_AND_ASSIGN(PluginMetadata); }; #endif // CHROME_BROWSER_PLUGINS_PLUGIN_METADATA_H_ diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc index 955735d..763e622 100644 --- a/chrome/browser/plugins/plugin_observer.cc +++ b/chrome/browser/plugins/plugin_observer.cc @@ -58,8 +58,7 @@ class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, public WeakPluginInstallerObserver { public: ConfirmInstallDialogDelegate(content::WebContents* web_contents, - PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata); + PluginInstaller* installer); // TabModalConfirmDialogDelegate methods: virtual string16 GetTitle() OVERRIDE; @@ -74,27 +73,24 @@ class ConfirmInstallDialogDelegate : public TabModalConfirmDialogDelegate, private: content::WebContents* web_contents_; - scoped_ptr<PluginMetadata> plugin_metadata_; }; ConfirmInstallDialogDelegate::ConfirmInstallDialogDelegate( content::WebContents* web_contents, - PluginInstaller* installer, - scoped_ptr<PluginMetadata> plugin_metadata) + PluginInstaller* installer) : TabModalConfirmDialogDelegate(web_contents), WeakPluginInstallerObserver(installer), - web_contents_(web_contents), - plugin_metadata_(plugin_metadata.Pass()) { + web_contents_(web_contents) { } string16 ConfirmInstallDialogDelegate::GetTitle() { return l10n_util::GetStringFUTF16( - IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_TITLE, plugin_metadata_->name()); + IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_TITLE, installer()->name()); } string16 ConfirmInstallDialogDelegate::GetMessage() { return l10n_util::GetStringFUTF16(IDS_PLUGIN_CONFIRM_INSTALL_DIALOG_MSG, - plugin_metadata_->name()); + installer()->name()); } string16 ConfirmInstallDialogDelegate::GetAcceptButtonTitle() { @@ -103,9 +99,7 @@ string16 ConfirmInstallDialogDelegate::GetAcceptButtonTitle() { } void ConfirmInstallDialogDelegate::OnAccepted() { - installer()->StartInstalling(plugin_metadata_->url_for_display(), - plugin_metadata_->plugin_url(), - TabContents::FromWebContents(web_contents_)); + installer()->StartInstalling(TabContents::FromWebContents(web_contents_)); } void ConfirmInstallDialogDelegate::OnCanceled() { @@ -129,7 +123,6 @@ class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver { public: PluginPlaceholderHost(PluginObserver* observer, int routing_id, - string16 plugin_name, PluginInstaller* installer) : PluginInstallerObserver(installer), observer_(observer), @@ -138,7 +131,7 @@ class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver { switch (installer->state()) { case PluginInstaller::INSTALLER_STATE_IDLE: { observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_, - plugin_name)); + installer->name())); break; } case PluginInstaller::INSTALLER_STATE_DOWNLOADING: { @@ -239,22 +232,17 @@ void PluginObserver::OnBlockedUnauthorizedPlugin( void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, const std::string& identifier) { #if defined(ENABLE_PLUGIN_INSTALLATION) - PluginFinder* finder = PluginFinder::GetInstance(); // Find plugin to update. - PluginInstaller* installer = NULL; - scoped_ptr<PluginMetadata> plugin; - DCHECK(finder->FindPluginWithIdentifier(identifier, &installer, &plugin)) - << "Couldn't find PluginInstaller for identifier " - << identifier; - + PluginInstaller* installer = + PluginFinder::GetInstance()->FindPluginWithIdentifier(identifier); + DCHECK(installer) << "Couldn't find PluginInstaller for identifier " + << identifier; plugin_placeholders_[placeholder_id] = - new PluginPlaceholderHost(this, placeholder_id, - plugin->name(), installer); + new PluginPlaceholderHost(this, placeholder_id, installer); TabContents* tab_contents = TabContents::FromWebContents(web_contents()); InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); infobar_helper->AddInfoBar( - OutdatedPluginInfoBarDelegate::Create(web_contents(), - installer, plugin.Pass())); + OutdatedPluginInfoBarDelegate::Create(web_contents(), installer)); #else // If we don't support third-party plug-in installation, we shouldn't have // outdated plug-ins. @@ -266,57 +254,42 @@ void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, void PluginObserver::OnFindMissingPlugin(int placeholder_id, const std::string& mime_type) { std::string lang = "en-US"; // Oh yes. - scoped_ptr<PluginMetadata> plugin_metadata; - PluginInstaller* installer = NULL; - bool found_plugin = PluginFinder::GetInstance()->FindPlugin( - mime_type, lang, &installer, &plugin_metadata); - if (!found_plugin) { + PluginInstaller* installer = + PluginFinder::GetInstance()->FindPlugin(mime_type, lang); + if (!installer) { Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); return; } - DCHECK(installer); - DCHECK(plugin_metadata.get()); plugin_placeholders_[placeholder_id] = - new PluginPlaceholderHost(this, placeholder_id, - plugin_metadata->name(), - installer); + new PluginPlaceholderHost(this, placeholder_id, installer); TabContents* tab_contents = TabContents::FromWebContents(web_contents()); InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); InfoBarDelegate* delegate; #if !defined(OS_WIN) delegate = PluginInstallerInfoBarDelegate::Create( infobar_helper, installer, - plugin_metadata->Clone(), base::Bind(&PluginObserver::InstallMissingPlugin, - weak_ptr_factory_.GetWeakPtr(), - installer, plugin_metadata.release())); + weak_ptr_factory_.GetWeakPtr(), installer)); #else delegate = base::win::IsMetroProcess() ? PluginMetroModeInfoBarDelegate::Create( - infobar_helper, plugin_metadata->name()) : + infobar_helper, installer->name()) : PluginInstallerInfoBarDelegate::Create( infobar_helper, installer, - plugin_metadata->Clone(), base::Bind(&PluginObserver::InstallMissingPlugin, - weak_ptr_factory_.GetWeakPtr(), - installer, plugin_metadata.release())); + weak_ptr_factory_.GetWeakPtr(), installer)); #endif infobar_helper->AddInfoBar(delegate); } -void PluginObserver::InstallMissingPlugin(PluginInstaller* installer, - PluginMetadata* plugin_metadata) { - scoped_ptr<PluginMetadata> scoped_plugin(plugin_metadata); - if (scoped_plugin->url_for_display()) { - installer->OpenDownloadURL(scoped_plugin->url_for_display(), - scoped_plugin->plugin_url(), - web_contents()); +void PluginObserver::InstallMissingPlugin(PluginInstaller* installer) { + if (installer->url_for_display()) { + installer->OpenDownloadURL(web_contents()); } else { TabModalConfirmDialog::Create( - new ConfirmInstallDialogDelegate( - web_contents(), installer, scoped_plugin.Pass()), - TabContents::FromWebContents(web_contents())); + new ConfirmInstallDialogDelegate(web_contents(), installer), + TabContents::FromWebContents(web_contents())); } } diff --git a/chrome/browser/plugins/plugin_observer.h b/chrome/browser/plugins/plugin_observer.h index a0ae687..65a1dd7 100644 --- a/chrome/browser/plugins/plugin_observer.h +++ b/chrome/browser/plugins/plugin_observer.h @@ -16,8 +16,6 @@ class GURL; class InfoBarDelegate; class PluginFinder; -class PluginMetadata; -class TabContents; #if defined(ENABLE_PLUGIN_INSTALLATION) class PluginInstaller; @@ -45,8 +43,7 @@ class PluginObserver : public content::WebContentsObserver, class PluginPlaceholderHost; #if defined(ENABLE_PLUGIN_INSTALLATION) - void InstallMissingPlugin(PluginInstaller* installer, - PluginMetadata* plugin_metadata); + void InstallMissingPlugin(PluginInstaller* installer); #endif // Message handlers: diff --git a/chrome/browser/plugins/plugin_prefs.cc b/chrome/browser/plugins/plugin_prefs.cc index 9cbd125..986b315 100644 --- a/chrome/browser/plugins/plugin_prefs.cc +++ b/chrome/browser/plugins/plugin_prefs.cc @@ -129,7 +129,7 @@ void PluginPrefs::EnablePluginGroupInternal( // Update the state for all plug-ins in the group. for (size_t i = 0; i < plugins.size(); ++i) { - scoped_ptr<PluginMetadata> plugin(finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin = finder->GetPluginMetadata(plugins[i]); if (group_name != plugin->name()) continue; plugin_state_.Set(plugins[i].path, enabled); @@ -148,8 +148,7 @@ void PluginPrefs::EnablePlugin( webkit::WebPluginInfo plugin; bool can_enable = true; if (PluginService::GetInstance()->GetPluginInfoByPath(path, &plugin)) { - scoped_ptr<PluginMetadata> plugin_metadata( - finder->GetPluginMetadata(plugin)); + PluginMetadata* plugin_metadata = finder->GetPluginMetadata(plugin); PolicyStatus plugin_status = PolicyStatusForPlugin(plugin.name); PolicyStatus group_status = PolicyStatusForPlugin(plugin_metadata->name()); @@ -198,8 +197,8 @@ void PluginPrefs::EnablePluginInternal( string16 group_name; for (size_t i = 0; i < plugins.size(); ++i) { if (plugins[i].path == path) { - scoped_ptr<PluginMetadata> plugin_metadata( - plugin_finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin_metadata = + plugin_finder->GetPluginMetadata(plugins[i]); // set the group name for this plug-in. group_name = plugin_metadata->name(); DCHECK_EQ(enabled, IsPluginEnabled(plugins[i])); @@ -209,8 +208,8 @@ void PluginPrefs::EnablePluginInternal( bool all_disabled = true; for (size_t i = 0; i < plugins.size(); ++i) { - scoped_ptr<PluginMetadata> plugin_metadata( - plugin_finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin_metadata = + plugin_finder->GetPluginMetadata(plugins[i]); DCHECK(!plugin_metadata->name().empty()); if (group_name == plugin_metadata->name()) { all_disabled = all_disabled && !IsPluginEnabled(plugins[i]); @@ -268,9 +267,8 @@ PluginPrefs::PolicyStatus PluginPrefs::PolicyStatusForPluginByVersion( } bool PluginPrefs::IsPluginEnabled(const webkit::WebPluginInfo& plugin) const { - scoped_ptr<PluginMetadata> plugin_metadata( - PluginFinder::GetInstance()->GetPluginMetadata(plugin)); - string16 group_name = plugin_metadata->name(); + PluginFinder* finder = PluginFinder::GetInstance(); + string16 group_name = finder->GetPluginMetadata(plugin)->name(); // Check if the specific version of this plug-in is disabled by policy. PolicyStatus plugin_status_by_version = @@ -701,8 +699,7 @@ void PluginPrefs::OnUpdatePreferences( summary->SetBoolean("enabled", enabled); plugins_list->Append(summary); - scoped_ptr<PluginMetadata> plugin_metadata( - finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin_metadata = finder->GetPluginMetadata(plugins[i]); // Insert into a set of all group names. group_names.insert(plugin_metadata->name()); } diff --git a/chrome/browser/renderer_host/plugin_info_message_filter.cc b/chrome/browser/renderer_host/plugin_info_message_filter.cc index 3054e49..70893da 100644 --- a/chrome/browser/renderer_host/plugin_info_message_filter.cc +++ b/chrome/browser/renderer_host/plugin_info_message_filter.cc @@ -5,7 +5,6 @@ #include "chrome/browser/renderer_host/plugin_info_message_filter.h" #include "base/bind.h" -#include "base/memory/scoped_ptr.h" #include "base/metrics/histogram.h" #include "base/utf_string_conversions.h" #include "chrome/browser/content_settings/content_settings_utils.h" @@ -130,8 +129,8 @@ void PluginInfoMessageFilter::Context::DecidePluginStatus( ChromeViewHostMsg_GetPluginInfo_Status* status, std::string* group_identifier, string16* group_name) const { - scoped_ptr<PluginMetadata> plugin_metadata( - PluginFinder::GetInstance()->GetPluginMetadata(plugin)); + PluginMetadata* plugin_metadata = + PluginFinder::GetInstance()->GetPluginMetadata(plugin); *group_name = plugin_metadata->name(); *group_identifier = plugin_metadata->identifier(); diff --git a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc index b38fed0..02675b3 100644 --- a/chrome/browser/ui/pdf/pdf_unsupported_feature.cc +++ b/chrome/browser/ui/pdf/pdf_unsupported_feature.cc @@ -5,7 +5,6 @@ #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" #include "base/bind.h" -#include "base/memory/scoped_ptr.h" #include "base/utf_string_conversions.h" #include "base/values.h" #include "base/version.h" @@ -293,8 +292,8 @@ PDFUnsupportedFeaturePromptDelegate::PDFUnsupportedFeaturePromptDelegate( reader_webplugininfo_ = *reader; #if defined(ENABLE_PLUGIN_INSTALLATION) - scoped_ptr<PluginMetadata> plugin_metadata( - plugin_finder->GetPluginMetadata(reader_webplugininfo_)); + PluginMetadata* plugin_metadata = + plugin_finder->GetPluginMetadata(reader_webplugininfo_); reader_vulnerable_ = plugin_metadata->GetSecurityStatus(*reader) != PluginMetadata::SECURITY_STATUS_UP_TO_DATE; @@ -379,8 +378,8 @@ void GotPluginsCallback(int process_id, const webkit::WebPluginInfo* reader = NULL; PluginFinder* plugin_finder = PluginFinder::GetInstance(); for (size_t i = 0; i < plugins.size(); ++i) { - scoped_ptr<PluginMetadata> plugin_metadata( - plugin_finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin_metadata = + plugin_finder->GetPluginMetadata(plugins[i]); if (plugin_metadata->identifier() != kAdobeReaderIdentifier) continue; diff --git a/chrome/browser/ui/webui/plugins_ui.cc b/chrome/browser/ui/webui/plugins_ui.cc index 44dd64f..a21d87a 100644 --- a/chrome/browser/ui/webui/plugins_ui.cc +++ b/chrome/browser/ui/webui/plugins_ui.cc @@ -11,7 +11,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/memory/ref_counted_memory.h" -#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/memory/weak_ptr.h" #include "base/message_loop.h" @@ -340,8 +339,7 @@ void PluginsDOMHandler::PluginsLoaded( // the plug-ins in UI in a grouped fashion. PluginGroups groups; for (size_t i = 0; i < plugins.size(); ++i) { - scoped_ptr<PluginMetadata> plugin( - plugin_finder->GetPluginMetadata(plugins[i])); + PluginMetadata* plugin = plugin_finder->GetPluginMetadata(plugins[i]); groups[plugin->identifier()].push_back(&plugins[i]); } @@ -351,8 +349,8 @@ void PluginsDOMHandler::PluginsLoaded( it != groups.end(); ++it) { const std::vector<const WebPluginInfo*>& group_plugins = it->second; ListValue* plugin_files = new ListValue(); - scoped_ptr<PluginMetadata> plugin_metadata( - plugin_finder->GetPluginMetadata(*group_plugins[0])); + PluginMetadata* plugin_metadata = + plugin_finder->GetPluginMetadata(*group_plugins[0]); string16 group_name = plugin_metadata->name(); std::string group_identifier = plugin_metadata->identifier(); bool group_enabled = false; |