| 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/plugins/plugin_observer.h" | 5 #include "chrome/browser/plugins/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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 225   infobar_helper->AddInfoBar( | 225   infobar_helper->AddInfoBar( | 
| 226       new UnauthorizedPluginInfoBarDelegate( | 226       new UnauthorizedPluginInfoBarDelegate( | 
| 227           infobar_helper, | 227           infobar_helper, | 
| 228           tab_contents->profile()->GetHostContentSettingsMap(), | 228           tab_contents->profile()->GetHostContentSettingsMap(), | 
| 229           name, identifier)); | 229           name, identifier)); | 
| 230 } | 230 } | 
| 231 | 231 | 
| 232 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, | 232 void PluginObserver::OnBlockedOutdatedPlugin(int placeholder_id, | 
| 233                                              const std::string& identifier) { | 233                                              const std::string& identifier) { | 
| 234 #if defined(ENABLE_PLUGIN_INSTALLATION) | 234 #if defined(ENABLE_PLUGIN_INSTALLATION) | 
| 235   PluginFinder::Get(base::Bind(&PluginObserver::FindPluginToUpdate, | 235   // Find plugin to update. | 
| 236                                weak_ptr_factory_.GetWeakPtr(), |  | 
| 237                                placeholder_id, identifier)); |  | 
| 238 #else |  | 
| 239   // If we don't support third-party plug-in installation, we shouldn't have |  | 
| 240   // outdated plug-ins. |  | 
| 241   NOTREACHED(); |  | 
| 242 #endif  // defined(ENABLE_PLUGIN_INSTALLATION) |  | 
| 243 } |  | 
| 244 |  | 
| 245 #if defined(ENABLE_PLUGIN_INSTALLATION) |  | 
| 246 void PluginObserver::FindPluginToUpdate(int placeholder_id, |  | 
| 247                                         const std::string& identifier, |  | 
| 248                                         PluginFinder* plugin_finder) { |  | 
| 249   PluginInstaller* installer = | 236   PluginInstaller* installer = | 
| 250       plugin_finder->FindPluginWithIdentifier(identifier); | 237       PluginFinder::GetInstance()->FindPluginWithIdentifier(identifier); | 
| 251   DCHECK(installer) << "Couldn't find PluginInstaller for identifier " | 238   DCHECK(installer) << "Couldn't find PluginInstaller for identifier " | 
| 252                     << identifier; | 239                     << identifier; | 
| 253   plugin_placeholders_[placeholder_id] = | 240   plugin_placeholders_[placeholder_id] = | 
| 254       new PluginPlaceholderHost(this, placeholder_id, installer); | 241       new PluginPlaceholderHost(this, placeholder_id, installer); | 
| 255   TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 242   TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 
| 256   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 243   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 
| 257   infobar_helper->AddInfoBar( | 244   infobar_helper->AddInfoBar( | 
| 258       OutdatedPluginInfoBarDelegate::Create(web_contents(), installer)); | 245       OutdatedPluginInfoBarDelegate::Create(web_contents(), installer)); | 
|  | 246 #else | 
|  | 247   // If we don't support third-party plug-in installation, we shouldn't have | 
|  | 248   // outdated plug-ins. | 
|  | 249   NOTREACHED(); | 
|  | 250 #endif  // defined(ENABLE_PLUGIN_INSTALLATION) | 
| 259 } | 251 } | 
| 260 | 252 | 
|  | 253 #if defined(ENABLE_PLUGIN_INSTALLATION) | 
| 261 void PluginObserver::OnFindMissingPlugin(int placeholder_id, | 254 void PluginObserver::OnFindMissingPlugin(int placeholder_id, | 
| 262                                          const std::string& mime_type) { | 255                                          const std::string& mime_type) { | 
| 263 PluginFinder::Get(base::Bind(&PluginObserver::FindMissingPlugin, |  | 
| 264                              weak_ptr_factory_.GetWeakPtr(), |  | 
| 265                              placeholder_id, mime_type)); |  | 
| 266 } |  | 
| 267 |  | 
| 268 void PluginObserver::FindMissingPlugin(int placeholder_id, |  | 
| 269                                        const std::string& mime_type, |  | 
| 270                                        PluginFinder* plugin_finder) { |  | 
| 271   std::string lang = "en-US";  // Oh yes. | 256   std::string lang = "en-US";  // Oh yes. | 
| 272   PluginInstaller* installer = plugin_finder->FindPlugin(mime_type, lang); | 257   PluginInstaller* installer = | 
|  | 258       PluginFinder::GetInstance()->FindPlugin(mime_type, lang); | 
| 273   if (!installer) { | 259   if (!installer) { | 
| 274     Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | 260     Send(new ChromeViewMsg_DidNotFindMissingPlugin(placeholder_id)); | 
| 275     return; | 261     return; | 
| 276   } | 262   } | 
| 277 | 263 | 
| 278   plugin_placeholders_[placeholder_id] = | 264   plugin_placeholders_[placeholder_id] = | 
| 279       new PluginPlaceholderHost(this, placeholder_id, installer); | 265       new PluginPlaceholderHost(this, placeholder_id, installer); | 
| 280   TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 266   TabContents* tab_contents = TabContents::FromWebContents(web_contents()); | 
| 281   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 267   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 
| 282   InfoBarDelegate* delegate; | 268   InfoBarDelegate* delegate; | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 335   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 321   InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 
| 336   infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 322   infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 
| 337       infobar_helper, | 323       infobar_helper, | 
| 338       &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 324       &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 
| 339           IDR_INFOBAR_PLUGIN_CRASHED), | 325           IDR_INFOBAR_PLUGIN_CRASHED), | 
| 340       l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 326       l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 
| 341                                  plugin_name), | 327                                  plugin_name), | 
| 342       true  /* auto_expire */)); | 328       true  /* auto_expire */)); | 
| 343 } | 329 } | 
| 344 | 330 | 
| OLD | NEW | 
|---|