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