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_infobar_delegates.h" | 5 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 PluginInfoBarDelegate::PluginInfoBarDelegate(const std::string& identifier) | 51 PluginInfoBarDelegate::PluginInfoBarDelegate(const std::string& identifier) |
52 : ConfirmInfoBarDelegate(), | 52 : ConfirmInfoBarDelegate(), |
53 identifier_(identifier) { | 53 identifier_(identifier) { |
54 } | 54 } |
55 | 55 |
56 PluginInfoBarDelegate::~PluginInfoBarDelegate() { | 56 PluginInfoBarDelegate::~PluginInfoBarDelegate() { |
57 } | 57 } |
58 | 58 |
59 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 59 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
60 web_contents()->OpenURL(content::OpenURLParams( | 60 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
61 GURL(GetLearnMoreURL()), content::Referrer(), | 61 content::OpenURLParams( |
62 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 62 GURL(GetLearnMoreURL()), content::Referrer(), |
63 content::PAGE_TRANSITION_LINK, false)); | 63 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 64 content::PAGE_TRANSITION_LINK, false)); |
64 return false; | 65 return false; |
65 } | 66 } |
66 | 67 |
67 void PluginInfoBarDelegate::LoadBlockedPlugins() { | 68 void PluginInfoBarDelegate::LoadBlockedPlugins() { |
| 69 content::WebContents* web_contents = |
| 70 InfoBarService::WebContentsFromInfoBar(infobar()); |
68 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 71 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
69 web_contents(), true, identifier_); | 72 web_contents, true, identifier_); |
70 } | 73 } |
71 | 74 |
72 int PluginInfoBarDelegate::GetIconID() const { | 75 int PluginInfoBarDelegate::GetIconID() const { |
73 return IDR_INFOBAR_PLUGIN_INSTALL; | 76 return IDR_INFOBAR_PLUGIN_INSTALL; |
74 } | 77 } |
75 | 78 |
76 base::string16 PluginInfoBarDelegate::GetLinkText() const { | 79 base::string16 PluginInfoBarDelegate::GetLinkText() const { |
77 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 80 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
78 } | 81 } |
79 | 82 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 141 |
139 bool UnauthorizedPluginInfoBarDelegate::Accept() { | 142 bool UnauthorizedPluginInfoBarDelegate::Accept() { |
140 content::RecordAction( | 143 content::RecordAction( |
141 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); | 144 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); |
142 LoadBlockedPlugins(); | 145 LoadBlockedPlugins(); |
143 return true; | 146 return true; |
144 } | 147 } |
145 | 148 |
146 bool UnauthorizedPluginInfoBarDelegate::Cancel() { | 149 bool UnauthorizedPluginInfoBarDelegate::Cancel() { |
147 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); | 150 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); |
148 const GURL& url = web_contents()->GetURL(); | 151 const GURL& url = InfoBarService::WebContentsFromInfoBar(infobar())->GetURL(); |
149 content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS, | 152 content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS, |
150 CONTENT_SETTING_ALLOW); | 153 CONTENT_SETTING_ALLOW); |
151 LoadBlockedPlugins(); | 154 LoadBlockedPlugins(); |
152 return true; | 155 return true; |
153 } | 156 } |
154 | 157 |
155 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { | 158 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { |
156 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Dismissed")); | 159 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Dismissed")); |
157 } | 160 } |
158 | 161 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); | 234 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); |
232 } | 235 } |
233 | 236 |
234 bool OutdatedPluginInfoBarDelegate::Accept() { | 237 bool OutdatedPluginInfoBarDelegate::Accept() { |
235 DCHECK_EQ(PluginInstaller::INSTALLER_STATE_IDLE, installer()->state()); | 238 DCHECK_EQ(PluginInstaller::INSTALLER_STATE_IDLE, installer()->state()); |
236 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); | 239 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); |
237 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will | 240 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will |
238 // result in deleting ourselves. Accordingly, we make sure to | 241 // result in deleting ourselves. Accordingly, we make sure to |
239 // not pass a reference to an object that can go away. | 242 // not pass a reference to an object that can go away. |
240 GURL plugin_url(plugin_metadata_->plugin_url()); | 243 GURL plugin_url(plugin_metadata_->plugin_url()); |
| 244 content::WebContents* web_contents = |
| 245 InfoBarService::WebContentsFromInfoBar(infobar()); |
241 if (plugin_metadata_->url_for_display()) | 246 if (plugin_metadata_->url_for_display()) |
242 installer()->OpenDownloadURL(plugin_url, web_contents()); | 247 installer()->OpenDownloadURL(plugin_url, web_contents); |
243 else | 248 else |
244 installer()->StartInstalling(plugin_url, web_contents()); | 249 installer()->StartInstalling(plugin_url, web_contents); |
245 return false; | 250 return false; |
246 } | 251 } |
247 | 252 |
248 bool OutdatedPluginInfoBarDelegate::Cancel() { | 253 bool OutdatedPluginInfoBarDelegate::Cancel() { |
249 content::RecordAction( | 254 content::RecordAction( |
250 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); | 255 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); |
251 LoadBlockedPlugins(); | 256 LoadBlockedPlugins(); |
252 return true; | 257 return true; |
253 } | 258 } |
254 | 259 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 IDS_PLUGININSTALLER_PROBLEMSUPDATING); | 390 IDS_PLUGININSTALLER_PROBLEMSUPDATING); |
386 } | 391 } |
387 | 392 |
388 bool PluginInstallerInfoBarDelegate::LinkClicked( | 393 bool PluginInstallerInfoBarDelegate::LinkClicked( |
389 WindowOpenDisposition disposition) { | 394 WindowOpenDisposition disposition) { |
390 GURL url(plugin_metadata_->help_url()); | 395 GURL url(plugin_metadata_->help_url()); |
391 if (url.is_empty()) { | 396 if (url.is_empty()) { |
392 url = google_util::AppendGoogleLocaleParam(GURL( | 397 url = google_util::AppendGoogleLocaleParam(GURL( |
393 "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); | 398 "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); |
394 } | 399 } |
395 web_contents()->OpenURL(content::OpenURLParams( | 400 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
396 url, content::Referrer(), | 401 content::OpenURLParams( |
397 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 402 url, content::Referrer(), |
398 content::PAGE_TRANSITION_LINK, false)); | 403 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 404 content::PAGE_TRANSITION_LINK, false)); |
399 return false; | 405 return false; |
400 } | 406 } |
401 | 407 |
402 void PluginInstallerInfoBarDelegate::DownloadStarted() { | 408 void PluginInstallerInfoBarDelegate::DownloadStarted() { |
403 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, | 409 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, |
404 plugin_metadata_->name())); | 410 plugin_metadata_->name())); |
405 } | 411 } |
406 | 412 |
407 void PluginInstallerInfoBarDelegate::DownloadCancelled() { | 413 void PluginInstallerInfoBarDelegate::DownloadCancelled() { |
408 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, | 414 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 514 |
509 base::string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { | 515 base::string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { |
510 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 516 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
511 } | 517 } |
512 | 518 |
513 bool PluginMetroModeInfoBarDelegate::LinkClicked( | 519 bool PluginMetroModeInfoBarDelegate::LinkClicked( |
514 WindowOpenDisposition disposition) { | 520 WindowOpenDisposition disposition) { |
515 // TODO(shrikant): We may need to change language a little at following | 521 // TODO(shrikant): We may need to change language a little at following |
516 // support URLs. With new approach we will just restart for both missing | 522 // support URLs. With new approach we will just restart for both missing |
517 // and not missing mode. | 523 // and not missing mode. |
518 web_contents()->OpenURL(content::OpenURLParams( | 524 InfoBarService::WebContentsFromInfoBar(infobar())->OpenURL( |
519 GURL((mode_ == MISSING_PLUGIN) ? | 525 content::OpenURLParams( |
520 "https://support.google.com/chrome/?p=ib_display_in_desktop" : | 526 GURL((mode_ == MISSING_PLUGIN) ? |
521 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), | 527 "https://support.google.com/chrome/?p=ib_display_in_desktop" : |
522 content::Referrer(), | 528 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), |
523 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 529 content::Referrer(), |
524 content::PAGE_TRANSITION_LINK, false)); | 530 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 531 content::PAGE_TRANSITION_LINK, false)); |
525 return false; | 532 return false; |
526 } | 533 } |
527 | 534 |
528 #endif // defined(OS_WIN) | 535 #endif // defined(OS_WIN) |
529 | 536 |
530 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 537 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
OLD | NEW |