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" |
11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 11 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
12 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" | 12 #include "chrome/browser/api/infobars/simple_alert_infobar_delegate.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map.h" |
15 #include "chrome/browser/infobars/infobar_tab_helper.h" | 15 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 16 #include "chrome/browser/lifetime/application_lifetime.h" |
16 #include "chrome/browser/metrics/metrics_service.h" | 17 #include "chrome/browser/metrics/metrics_service.h" |
17 #include "chrome/browser/plugins/plugin_finder.h" | 18 #include "chrome/browser/plugins/plugin_finder.h" |
18 #include "chrome/browser/plugins/plugin_infobar_delegates.h" | 19 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
21 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 22 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
22 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
24 #include "content/public/browser/plugin_service.h" | 25 #include "content/public/browser/plugin_service.h" |
25 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 #if defined(ENABLE_PLUGIN_INSTALLATION) | 210 #if defined(ENABLE_PLUGIN_INSTALLATION) |
210 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin, | 211 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FindMissingPlugin, |
211 OnFindMissingPlugin) | 212 OnFindMissingPlugin) |
212 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, | 213 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RemovePluginPlaceholderHost, |
213 OnRemovePluginPlaceholderHost) | 214 OnRemovePluginPlaceholderHost) |
214 #endif | 215 #endif |
215 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins, | 216 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenAboutPlugins, |
216 OnOpenAboutPlugins) | 217 OnOpenAboutPlugins) |
217 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, | 218 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin, |
218 OnCouldNotLoadPlugin) | 219 OnCouldNotLoadPlugin) |
| 220 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NPAPINotSupported, |
| 221 OnNPAPINotSupported) |
219 | 222 |
220 IPC_MESSAGE_UNHANDLED(return false) | 223 IPC_MESSAGE_UNHANDLED(return false) |
221 IPC_END_MESSAGE_MAP() | 224 IPC_END_MESSAGE_MAP() |
222 | 225 |
223 return true; | 226 return true; |
224 } | 227 } |
225 | 228 |
226 void PluginObserver::OnBlockedUnauthorizedPlugin( | 229 void PluginObserver::OnBlockedUnauthorizedPlugin( |
227 const string16& name, | 230 const string16& name, |
228 const std::string& identifier) { | 231 const std::string& identifier) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 InfoBarTabHelper* infobar_helper = | 292 InfoBarTabHelper* infobar_helper = |
290 InfoBarTabHelper::FromWebContents(web_contents()); | 293 InfoBarTabHelper::FromWebContents(web_contents()); |
291 InfoBarDelegate* delegate; | 294 InfoBarDelegate* delegate; |
292 #if !defined(OS_WIN) | 295 #if !defined(OS_WIN) |
293 delegate = PluginInstallerInfoBarDelegate::Create( | 296 delegate = PluginInstallerInfoBarDelegate::Create( |
294 infobar_helper, installer, | 297 infobar_helper, installer, |
295 plugin_metadata.Pass(), | 298 plugin_metadata.Pass(), |
296 callback); | 299 callback); |
297 #else | 300 #else |
298 delegate = base::win::IsMetroProcess() ? | 301 delegate = base::win::IsMetroProcess() ? |
299 PluginMetroModeInfoBarDelegate::Create( | 302 new PluginMetroModeInfoBarDelegate( |
300 infobar_helper, plugin_metadata->name()) : | 303 infobar_helper, |
| 304 l10n_util::GetStringFUTF16(IDS_METRO_MISSING_PLUGIN_PROMPT, |
| 305 plugin_metadata->name()), |
| 306 l10n_util::GetStringUTF16(IDS_WIN8_DESKTOP_RESTART)) : |
301 PluginInstallerInfoBarDelegate::Create( | 307 PluginInstallerInfoBarDelegate::Create( |
302 infobar_helper, installer, | 308 infobar_helper, installer, |
303 plugin_metadata.Pass(), | 309 plugin_metadata.Pass(), |
304 callback); | 310 callback); |
305 #endif | 311 #endif |
306 infobar_helper->AddInfoBar(delegate); | 312 infobar_helper->AddInfoBar(delegate); |
307 } | 313 } |
308 | 314 |
309 void PluginObserver::InstallMissingPlugin( | 315 void PluginObserver::InstallMissingPlugin( |
310 PluginInstaller* installer, | 316 PluginInstaller* installer, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 InfoBarTabHelper::FromWebContents(web_contents()); | 353 InfoBarTabHelper::FromWebContents(web_contents()); |
348 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 354 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
349 infobar_helper, | 355 infobar_helper, |
350 &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 356 &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
351 IDR_INFOBAR_PLUGIN_CRASHED), | 357 IDR_INFOBAR_PLUGIN_CRASHED), |
352 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 358 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
353 plugin_name), | 359 plugin_name), |
354 true /* auto_expire */)); | 360 true /* auto_expire */)); |
355 } | 361 } |
356 | 362 |
| 363 void PluginObserver::OnNPAPINotSupported(const std::string& identifier) { |
| 364 #if defined(OS_WIN) && defined(ENABLE_PLUGIN_INSTALLATION) |
| 365 Profile* profile = |
| 366 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 367 if (profile->IsOffTheRecord()) |
| 368 return; |
| 369 |
| 370 scoped_ptr<PluginMetadata> plugin; |
| 371 if (!PluginFinder::GetInstance()->FindPluginWithIdentifier( |
| 372 identifier, NULL, &plugin)) { |
| 373 NOTREACHED(); |
| 374 return; |
| 375 } |
| 376 |
| 377 InfoBarTabHelper* infobar_helper = |
| 378 InfoBarTabHelper::FromWebContents(web_contents()); |
| 379 infobar_helper->AddInfoBar( |
| 380 new PluginMetroModeInfoBarDelegate( |
| 381 infobar_helper, |
| 382 l10n_util::GetStringFUTF16(IDS_METRO_NPAPI_PLUGIN_PROMPT, |
| 383 plugin->name()), |
| 384 l10n_util::GetStringUTF16(IDS_WIN8_RESTART))); |
| 385 #else |
| 386 NOTREACHED(); |
| 387 #endif |
| 388 } |
OLD | NEW |