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); | |
122 switch (installer->state()) { | 121 switch (installer->state()) { |
123 case PluginInstaller::kStateIdle: { | 122 case PluginInstaller::kStateIdle: { |
124 observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_, | 123 observer->Send(new ChromeViewMsg_FoundMissingPlugin(routing_id_, |
125 installer->name())); | 124 installer->name())); |
126 break; | 125 break; |
127 } | 126 } |
128 case PluginInstaller::kStateDownloading: { | 127 case PluginInstaller::kStateDownloading: { |
129 DownloadStarted(); | 128 DownloadStarted(); |
130 break; | 129 break; |
131 } | 130 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 infobar_helper->AddInfoBar( | 194 infobar_helper->AddInfoBar( |
196 new UnauthorizedPluginInfoBarDelegate( | 195 new UnauthorizedPluginInfoBarDelegate( |
197 infobar_helper, | 196 infobar_helper, |
198 tab_contents_->profile()->GetHostContentSettingsMap(), | 197 tab_contents_->profile()->GetHostContentSettingsMap(), |
199 name)); | 198 name)); |
200 } | 199 } |
201 | 200 |
202 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, | 201 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, |
203 const std::string& identifier) { | 202 const std::string& identifier) { |
204 #if defined(ENABLE_PLUGIN_INSTALLATION) | 203 #if defined(ENABLE_PLUGIN_INSTALLATION) |
205 PluginFinder::Get(base::Bind(&PluginObserver::FindPluginToUpdate, | 204 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
206 weak_ptr_factory_.GetWeakPtr(), | 205 plugin_finder->FindPluginWithIdentifier( |
207 placeholder_id, identifier)); | 206 identifier, |
| 207 base::Bind(&PluginObserver::FoundPluginToUpdate, |
| 208 weak_ptr_factory_.GetWeakPtr(), placeholder_id)); |
208 #else | 209 #else |
209 // If we don't support third-party plug-in installation, we shouldn't have | 210 // If we don't support third-party plug-in installation, we shouldn't have |
210 // outdated plug-ins. | 211 // outdated plug-ins. |
211 NOTREACHED(); | 212 NOTREACHED(); |
212 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 213 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
213 } | 214 } |
214 | 215 |
215 #if defined(ENABLE_PLUGIN_INSTALLATION) | 216 #if defined(ENABLE_PLUGIN_INSTALLATION) |
216 void PluginObserver::FindPluginToUpdate(int placeholder_id, | 217 void PluginObserver::FoundPluginToUpdate(int placeholder_id, |
217 const std::string& identifier, | 218 PluginInstaller* installer) { |
218 PluginFinder* plugin_finder) { | |
219 PluginInstaller* installer = | |
220 plugin_finder->FindPluginWithIdentifier(identifier); | |
221 plugin_placeholders_[placeholder_id] = | 219 plugin_placeholders_[placeholder_id] = |
222 new PluginPlaceholderHost(this, placeholder_id, installer); | 220 new PluginPlaceholderHost(this, placeholder_id, installer); |
223 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 221 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
224 infobar_helper->AddInfoBar( | 222 infobar_helper->AddInfoBar( |
225 OutdatedPluginInfoBarDelegate::Create(this, installer)); | 223 OutdatedPluginInfoBarDelegate::Create(this, installer)); |
226 } | 224 } |
227 | 225 |
228 void PluginObserver::OnFindMissingPlugin(int placeholder_id, | 226 void PluginObserver::OnFindMissingPlugin(int placeholder_id, |
229 const std::string& mime_type) { | 227 const std::string& mime_type) { |
230 PluginFinder::Get(base::Bind(&PluginObserver::FindMissingPlugin, | 228 PluginFinder* plugin_finder = PluginFinder::GetInstance(); |
231 weak_ptr_factory_.GetWeakPtr(), | 229 std::string lang = "en-US"; // Oh yes. |
232 placeholder_id, mime_type)); | 230 plugin_finder->FindPlugin( |
| 231 mime_type, lang, |
| 232 base::Bind(&PluginObserver::FoundMissingPlugin, |
| 233 weak_ptr_factory_.GetWeakPtr(), placeholder_id, mime_type)); |
233 } | 234 } |
234 | 235 |
235 void PluginObserver::FindMissingPlugin(int placeholder_id, | 236 void PluginObserver::FoundMissingPlugin(int placeholder_id, |
236 const std::string& mime_type, | 237 const std::string& mime_type, |
237 PluginFinder* plugin_finder) { | 238 PluginInstaller* installer) { |
238 std::string lang = "en-US"; // Oh yes. | |
239 PluginInstaller* installer = plugin_finder->FindPlugin(mime_type, lang); | |
240 if (!installer) { | 239 if (!installer) { |
241 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | 240 Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); |
242 return; | 241 return; |
243 } | 242 } |
244 | 243 |
245 plugin_placeholders_[placeholder_id] = | 244 plugin_placeholders_[placeholder_id] = |
246 new PluginPlaceholderHost(this, placeholder_id, installer); | 245 new PluginPlaceholderHost(this, placeholder_id, installer); |
247 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); | 246 InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
248 InfoBarDelegate* delegate = PluginInstallerInfoBarDelegate::Create( | 247 InfoBarDelegate* delegate = PluginInstallerInfoBarDelegate::Create( |
249 infobar_helper, installer, | 248 infobar_helper, installer, |
(...skipping 24 matching lines...) Expand all Loading... |
274 } | 273 } |
275 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 274 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
276 | 275 |
277 void PluginObserver::OnOpenAboutPlugins() { | 276 void PluginObserver::OnOpenAboutPlugins() { |
278 web_contents()->OpenURL(OpenURLParams( | 277 web_contents()->OpenURL(OpenURLParams( |
279 GURL(chrome::kAboutPluginsURL), | 278 GURL(chrome::kAboutPluginsURL), |
280 content::Referrer(web_contents()->GetURL(), | 279 content::Referrer(web_contents()->GetURL(), |
281 WebKit::WebReferrerPolicyDefault), | 280 WebKit::WebReferrerPolicyDefault), |
282 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); | 281 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_TYPED, false)); |
283 } | 282 } |
OLD | NEW |