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 #if defined(OS_WIN) |
| 221 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RestartInDesktopMode, |
| 222 OnRestartInDesktopMode) |
| 223 #endif |
219 | 224 |
220 IPC_MESSAGE_UNHANDLED(return false) | 225 IPC_MESSAGE_UNHANDLED(return false) |
221 IPC_END_MESSAGE_MAP() | 226 IPC_END_MESSAGE_MAP() |
222 | 227 |
223 return true; | 228 return true; |
224 } | 229 } |
225 | 230 |
226 void PluginObserver::OnBlockedUnauthorizedPlugin( | 231 void PluginObserver::OnBlockedUnauthorizedPlugin( |
227 const string16& name, | 232 const string16& name, |
228 const std::string& identifier) { | 233 const std::string& identifier) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 plugin_placeholders_[placeholder_id] = | 286 plugin_placeholders_[placeholder_id] = |
282 new PluginPlaceholderHost(this, placeholder_id, | 287 new PluginPlaceholderHost(this, placeholder_id, |
283 plugin_metadata->name(), | 288 plugin_metadata->name(), |
284 installer); | 289 installer); |
285 base::Closure callback = base::Bind(&PluginObserver::InstallMissingPlugin, | 290 base::Closure callback = base::Bind(&PluginObserver::InstallMissingPlugin, |
286 weak_ptr_factory_.GetWeakPtr(), | 291 weak_ptr_factory_.GetWeakPtr(), |
287 installer, | 292 installer, |
288 base::Passed(plugin_metadata->Clone())); | 293 base::Passed(plugin_metadata->Clone())); |
289 InfoBarTabHelper* infobar_helper = | 294 InfoBarTabHelper* infobar_helper = |
290 InfoBarTabHelper::FromWebContents(web_contents()); | 295 InfoBarTabHelper::FromWebContents(web_contents()); |
291 InfoBarDelegate* delegate; | 296 InfoBarDelegate* delegate = PluginInstallerInfoBarDelegate::Create( |
292 #if !defined(OS_WIN) | |
293 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 | |
298 delegate = base::win::IsMetroProcess() ? | |
299 PluginMetroModeInfoBarDelegate::Create( | |
300 infobar_helper, plugin_metadata->name()) : | |
301 PluginInstallerInfoBarDelegate::Create( | |
302 infobar_helper, installer, | |
303 plugin_metadata.Pass(), | |
304 callback); | |
305 #endif | |
306 infobar_helper->AddInfoBar(delegate); | 300 infobar_helper->AddInfoBar(delegate); |
307 } | 301 } |
308 | 302 |
309 void PluginObserver::InstallMissingPlugin( | 303 void PluginObserver::InstallMissingPlugin( |
310 PluginInstaller* installer, | 304 PluginInstaller* installer, |
311 scoped_ptr<PluginMetadata> plugin_metadata) { | 305 scoped_ptr<PluginMetadata> plugin_metadata) { |
312 if (plugin_metadata->url_for_display()) { | 306 if (plugin_metadata->url_for_display()) { |
313 installer->OpenDownloadURL(plugin_metadata->plugin_url(), web_contents()); | 307 installer->OpenDownloadURL(plugin_metadata->plugin_url(), web_contents()); |
314 } else { | 308 } else { |
315 TabModalConfirmDialog::Create( | 309 TabModalConfirmDialog::Create( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 InfoBarTabHelper::FromWebContents(web_contents()); | 341 InfoBarTabHelper::FromWebContents(web_contents()); |
348 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 342 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
349 infobar_helper, | 343 infobar_helper, |
350 &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 344 &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
351 IDR_INFOBAR_PLUGIN_CRASHED), | 345 IDR_INFOBAR_PLUGIN_CRASHED), |
352 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, | 346 l10n_util::GetStringFUTF16(IDS_PLUGIN_INITIALIZATION_ERROR_PROMPT, |
353 plugin_name), | 347 plugin_name), |
354 true /* auto_expire */)); | 348 true /* auto_expire */)); |
355 } | 349 } |
356 | 350 |
| 351 #if defined(OS_WIN) |
| 352 void PluginObserver::OnRestartInDesktopMode() { |
| 353 DCHECK(base::win::IsMetroProcess()); |
| 354 browser::AttemptRestartWithModeSwitch(); |
| 355 } |
| 356 #endif |
OLD | NEW |