| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/plugin_observer.h" | 5 #include "chrome/browser/plugin_observer.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 #if defined(ENABLE_PLUGIN_INSTALLATION) | 112 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 113 class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver { | 113 class PluginObserver::PluginPlaceholderHost : public PluginInstallerObserver { |
| 114 public: | 114 public: |
| 115 PluginPlaceholderHost(PluginObserver* observer, | 115 PluginPlaceholderHost(PluginObserver* observer, |
| 116 int routing_id, | 116 int routing_id, |
| 117 PluginInstaller* installer) | 117 PluginInstaller* installer) |
| 118 : PluginInstallerObserver(installer), | 118 : PluginInstallerObserver(installer), |
| 119 observer_(observer), | 119 observer_(observer), |
| 120 routing_id_(routing_id) { | 120 routing_id_(routing_id) { |
| 121 DCHECK(installer); |
| 121 switch (installer->state()) { | 122 switch (installer->state()) { |
| 122 case PluginInstaller::kStateIdle: { | 123 case PluginInstaller::kStateIdle: { |
| 123 observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_, | 124 observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_, |
| 124 installer->name())); | 125 installer->name())); |
| 125 break; | 126 break; |
| 126 } | 127 } |
| 127 case PluginInstaller::kStateDownloading: { | 128 case PluginInstaller::kStateDownloading: { |
| 128 DownloadStarted(); | 129 DownloadStarted(); |
| 129 break; | 130 break; |
| 130 } | 131 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 infobar_helper->AddInfoBar( | 195 infobar_helper->AddInfoBar( |
| 195 new UnauthorizedPluginInfoBarDelegate( | 196 new UnauthorizedPluginInfoBarDelegate( |
| 196 infobar_helper, | 197 infobar_helper, |
| 197 tab_contents_->profile()->GetHostContentSettingsMap(), | 198 tab_contents_->profile()->GetHostContentSettingsMap(), |
| 198 name)); | 199 name)); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, | 202 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, |
| 202 const std::string& identifier) { | 203 const std::string& identifier) { |
| 203 #if defined(ENABLE_PLUGIN_INSTALLATION) | 204 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 204 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 205 PluginFinder::Get(base::Bind(&PluginObserver::FindPluginToUpdate, |
| 205 plugin_finder->FindPluginWithIdentifier( | 206 weak_ptr_factory_.GetWeakPtr(), |
| 206 identifier, | 207 placeholder_id, identifier)); |
| 207 base::Bind(&PluginObserver::FoundPluginToUpdate, | |
| 208 weak_ptr_factory_.GetWeakPtr(), placeholder_id)); | |
| 209 #else | 208 #else |
| 210 // If we don't support third-party plug-in installation, we shouldn't have | 209 // If we don't support third-party plug-in installation, we shouldn't have |
| 211 // outdated plug-ins. | 210 // outdated plug-ins. |
| 212 NOTREACHED(); | 211 NOTREACHED(); |
| 213 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 212 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| 214 } | 213 } |
| 215 | 214 |
| 216 #if defined(ENABLE_PLUGIN_INSTALLATION) | 215 #if defined(ENABLE_PLUGIN_INSTALLATION) |
| 217 void PluginObserver::FoundPluginToUpdate(int placeholder_id, | 216 void PluginObserver::FindPluginToUpdate(int placeholder_id, |
| 218 PluginInstaller* installer) { | 217 const std::string& identifier, |
| 218 PluginFinder* plugin_finder) { |
| 219 PluginInstaller* installer = |
| 220 plugin_finder->FindPluginWithIdentifier(identifier); |
| 219 plugin_placeholders_[placeholder_id] = | 221 plugin_placeholders_[placeholder_id] = |
| 220 new PluginPlaceholderHost(this, placeholder_id, installer); | 222 new PluginPlaceholderHost(this, placeholder_id, installer); |
| 221 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 223 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
| 222 infobar_helper->AddInfoBar( | 224 infobar_helper->AddInfoBar( |
| 223 OutdatedPluginInfoBarDelegate::Create(this, installer)); | 225 OutdatedPluginInfoBarDelegate::Create(this, installer)); |
| 224 } | 226 } |
| 225 | 227 |
| 226 void PluginObserver::OnFindMissingPlugin(int placeholder_id, | 228 void PluginObserver::OnFindMissingPlugin(int placeholder_id, |
| 227 const std::string& mime_type) { | 229 const std::string& mime_type) { |
| 228 PluginFinder* plugin_finder = PluginFinder::GetInstance(); | 230 PluginFinder::Get(base::Bind(&PluginObserver::FindMissingPlugin, |
| 229 std::string lang = "en-US"; // Oh yes. | 231 weak_ptr_factory_.GetWeakPtr(), |
| 230 plugin_finder->FindPlugin( | 232 placeholder_id, mime_type)); |
| 231 mime_type, lang, | |
| 232 base::Bind(&PluginObserver::FoundMissingPlugin, | |
| 233 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type)); | |
| 234 } | 233 } |
| 235 | 234 |
| 236 void PluginObserver::FoundMissingPlugin(int placeholder_id, | 235 void PluginObserver::FindMissingPlugin(int placeholder_id, |
| 237 const std::string& mime_type, | 236 const std::string& mime_type, |
| 238 PluginInstaller* installer) { | 237 PluginFinder* plugin_finder) { |
| 238 std::string lang = "en-US"; // Oh yes. |
| 239 PluginInstaller* installer = plugin_finder->FindPlugin(mime_type, lang); |
| 239 if (!installer) { | 240 if (!installer) { |
| 240 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | 241 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); |
| 241 return; | 242 return; |
| 242 } | 243 } |
| 243 | 244 |
| 244 plugin_placeholders_[placeholder_id] = | 245 plugin_placeholders_[placeholder_id] = |
| 245 new PluginPlaceholderHost(this, placeholder_id, installer); | 246 new PluginPlaceholderHost(this, placeholder_id, installer); |
| 246 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 247 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
| 247 InfoBarDelegate* delegate = PluginInstallerInfoBarDelegate::Create( | 248 InfoBarDelegate* delegate = PluginInstallerInfoBarDelegate::Create( |
| 248 infobar_helper, installer, | 249 infobar_helper, installer, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 273 } | 274 } |
| 274 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 275 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| 275 | 276 |
| 276 void PluginObserver::OnOpenAboutPlugins() { | 277 void PluginObserver::OnOpenAboutPlugins() { |
| 277 web_contents()->OpenURL(OpenURLParams( | 278 web_contents()->OpenURL(OpenURLParams( |
| 278 GURL(chrome::kAboutPluginsURL), | 279 GURL(chrome::kAboutPluginsURL), |
| 279 content::Referrer(web_contents()->GetURL(), | 280 content::Referrer(web_contents()->GetURL(), |
| 280 WebKit::WebReferrerPolicyDefault), | 281 WebKit::WebReferrerPolicyDefault), |
| 281 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); | 282 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); |
| 282 } | 283 } |
| OLD | NEW |