| 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 PluginInfoBarDelegate::~PluginInfoBarDelegate() { | 51 PluginInfoBarDelegate::~PluginInfoBarDelegate() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { | 54 bool PluginInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { |
| 55 OpenURLParams params( | 55 OpenURLParams params( |
| 56 GURL(GetLearnMoreURL()), Referrer(), | 56 GURL(GetLearnMoreURL()), Referrer(), |
| 57 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 57 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 58 content::PAGE_TRANSITION_LINK, | 58 content::PAGE_TRANSITION_LINK, |
| 59 false); | 59 false); |
| 60 owner()->GetWebContents()->OpenURL(params); | 60 owner()->web_contents()->OpenURL(params); |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void PluginInfoBarDelegate::LoadBlockedPlugins() { | 64 void PluginInfoBarDelegate::LoadBlockedPlugins() { |
| 65 content::WebContents* web_contents = owner()->GetWebContents(); | 65 content::WebContents* web_contents = owner()->web_contents(); |
| 66 if (web_contents) { | 66 if (web_contents) { |
| 67 content::RenderViewHost* host = web_contents->GetRenderViewHost(); | 67 content::RenderViewHost* host = web_contents->GetRenderViewHost(); |
| 68 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( | 68 ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins( |
| 69 host->GetProcess()->GetID()); | 69 host->GetProcess()->GetID()); |
| 70 host->Send(new ChromeViewMsg_LoadBlockedPlugins( | 70 host->Send(new ChromeViewMsg_LoadBlockedPlugins( |
| 71 host->GetRoutingID(), identifier_)); | 71 host->GetRoutingID(), identifier_)); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 gfx::Image* PluginInfoBarDelegate::GetIcon() const { | 75 gfx::Image* PluginInfoBarDelegate::GetIcon() const { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 bool UnauthorizedPluginInfoBarDelegate::Accept() { | 142 bool UnauthorizedPluginInfoBarDelegate::Accept() { |
| 143 content::RecordAction( | 143 content::RecordAction( |
| 144 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); | 144 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); |
| 145 LoadBlockedPlugins(); | 145 LoadBlockedPlugins(); |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool UnauthorizedPluginInfoBarDelegate::Cancel() { | 149 bool UnauthorizedPluginInfoBarDelegate::Cancel() { |
| 150 content::RecordAction( | 150 content::RecordAction( |
| 151 UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); | 151 UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); |
| 152 content_settings_->AddExceptionForURL(owner()->GetWebContents()->GetURL(), | 152 content_settings_->AddExceptionForURL(owner()->web_contents()->GetURL(), |
| 153 owner()->GetWebContents()->GetURL(), | 153 owner()->web_contents()->GetURL(), |
| 154 CONTENT_SETTINGS_TYPE_PLUGINS, | 154 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 155 std::string(), | 155 std::string(), |
| 156 CONTENT_SETTING_ALLOW); | 156 CONTENT_SETTING_ALLOW); |
| 157 LoadBlockedPlugins(); | 157 LoadBlockedPlugins(); |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { | 161 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { |
| 162 content::RecordAction( | 162 content::RecordAction( |
| 163 UserMetricsAction("BlockedPluginInfobar.Dismissed")); | 163 UserMetricsAction("BlockedPluginInfobar.Dismissed")); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); | 245 IDS_PLUGIN_UPDATE : IDS_PLUGIN_ENABLE_TEMPORARILY); |
| 246 } | 246 } |
| 247 | 247 |
| 248 bool OutdatedPluginInfoBarDelegate::Accept() { | 248 bool OutdatedPluginInfoBarDelegate::Accept() { |
| 249 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); | 249 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Update")); |
| 250 if (installer()->state() != PluginInstaller::INSTALLER_STATE_IDLE) { | 250 if (installer()->state() != PluginInstaller::INSTALLER_STATE_IDLE) { |
| 251 NOTREACHED(); | 251 NOTREACHED(); |
| 252 return false; | 252 return false; |
| 253 } | 253 } |
| 254 | 254 |
| 255 content::WebContents* web_contents = owner()->GetWebContents(); | 255 content::WebContents* web_contents = owner()->web_contents(); |
| 256 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will | 256 // A call to any of |OpenDownloadURL()| or |StartInstalling()| will |
| 257 // result in deleting ourselves. Accordingly, we make sure to | 257 // result in deleting ourselves. Accordingly, we make sure to |
| 258 // not pass a reference to an object that can go away. | 258 // not pass a reference to an object that can go away. |
| 259 // http://crbug.com/54167 | 259 // http://crbug.com/54167 |
| 260 GURL plugin_url(plugin_metadata_->plugin_url()); | 260 GURL plugin_url(plugin_metadata_->plugin_url()); |
| 261 if (plugin_metadata_->url_for_display()) { | 261 if (plugin_metadata_->url_for_display()) { |
| 262 installer()->OpenDownloadURL(plugin_url, web_contents); | 262 installer()->OpenDownloadURL(plugin_url, web_contents); |
| 263 } else { | 263 } else { |
| 264 installer()->StartInstalling(plugin_url, web_contents); | 264 installer()->StartInstalling(plugin_url, web_contents); |
| 265 } | 265 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 GURL url(plugin_metadata_->help_url()); | 422 GURL url(plugin_metadata_->help_url()); |
| 423 if (url.is_empty()) { | 423 if (url.is_empty()) { |
| 424 url = google_util::AppendGoogleLocaleParam(GURL( | 424 url = google_util::AppendGoogleLocaleParam(GURL( |
| 425 "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); | 425 "https://www.google.com/support/chrome/bin/answer.py?answer=142064")); |
| 426 } | 426 } |
| 427 | 427 |
| 428 OpenURLParams params( | 428 OpenURLParams params( |
| 429 url, Referrer(), | 429 url, Referrer(), |
| 430 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 430 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 431 content::PAGE_TRANSITION_LINK, false); | 431 content::PAGE_TRANSITION_LINK, false); |
| 432 owner()->GetWebContents()->OpenURL(params); | 432 owner()->web_contents()->OpenURL(params); |
| 433 return false; | 433 return false; |
| 434 } | 434 } |
| 435 | 435 |
| 436 void PluginInstallerInfoBarDelegate::DownloadStarted() { | 436 void PluginInstallerInfoBarDelegate::DownloadStarted() { |
| 437 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, | 437 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, |
| 438 plugin_metadata_->name())); | 438 plugin_metadata_->name())); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void PluginInstallerInfoBarDelegate::DownloadCancelled() { | 441 void PluginInstallerInfoBarDelegate::DownloadCancelled() { |
| 442 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, | 442 ReplaceWithInfoBar(l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOAD_CANCELLED, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 IDS_WIN8_DESKTOP_RESTART : IDS_WIN8_RESTART); | 517 IDS_WIN8_DESKTOP_RESTART : IDS_WIN8_RESTART); |
| 518 } | 518 } |
| 519 | 519 |
| 520 bool PluginMetroModeInfoBarDelegate::Accept() { | 520 bool PluginMetroModeInfoBarDelegate::Accept() { |
| 521 chrome::AttemptRestartWithModeSwitch(); | 521 chrome::AttemptRestartWithModeSwitch(); |
| 522 return true; | 522 return true; |
| 523 } | 523 } |
| 524 | 524 |
| 525 bool PluginMetroModeInfoBarDelegate::Cancel() { | 525 bool PluginMetroModeInfoBarDelegate::Cancel() { |
| 526 DCHECK_EQ(DESKTOP_MODE_REQUIRED, mode_); | 526 DCHECK_EQ(DESKTOP_MODE_REQUIRED, mode_); |
| 527 content::WebContents* web_contents = owner()->GetWebContents(); | 527 content::WebContents* web_contents = owner()->web_contents(); |
| 528 Profile* profile = | 528 Profile* profile = |
| 529 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 529 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 530 HostContentSettingsMap* content_settings = | 530 HostContentSettingsMap* content_settings = |
| 531 profile->GetHostContentSettingsMap(); | 531 profile->GetHostContentSettingsMap(); |
| 532 GURL url = web_contents->GetURL(); | 532 GURL url = web_contents->GetURL(); |
| 533 content_settings->SetContentSetting( | 533 content_settings->SetContentSetting( |
| 534 ContentSettingsPattern::FromURL(url), | 534 ContentSettingsPattern::FromURL(url), |
| 535 ContentSettingsPattern::Wildcard(), | 535 ContentSettingsPattern::Wildcard(), |
| 536 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, | 536 CONTENT_SETTINGS_TYPE_METRO_SWITCH_TO_DESKTOP, |
| 537 std::string(), | 537 std::string(), |
| 538 CONTENT_SETTING_BLOCK); | 538 CONTENT_SETTING_BLOCK); |
| 539 return true; | 539 return true; |
| 540 } | 540 } |
| 541 | 541 |
| 542 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { | 542 string16 PluginMetroModeInfoBarDelegate::GetLinkText() const { |
| 543 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 543 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool PluginMetroModeInfoBarDelegate::LinkClicked( | 546 bool PluginMetroModeInfoBarDelegate::LinkClicked( |
| 547 WindowOpenDisposition disposition) { | 547 WindowOpenDisposition disposition) { |
| 548 OpenURLParams params( | 548 OpenURLParams params( |
| 549 GURL((mode_ == MISSING_PLUGIN) ? | 549 GURL((mode_ == MISSING_PLUGIN) ? |
| 550 "https://support.google.com/chrome/?p=ib_display_in_desktop" : | 550 "https://support.google.com/chrome/?p=ib_display_in_desktop" : |
| 551 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), | 551 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), |
| 552 Referrer(), | 552 Referrer(), |
| 553 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 553 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 554 content::PAGE_TRANSITION_LINK, false); | 554 content::PAGE_TRANSITION_LINK, false); |
| 555 owner()->GetWebContents()->OpenURL(params); | 555 owner()->web_contents()->OpenURL(params); |
| 556 return false; | 556 return false; |
| 557 } | 557 } |
| 558 #endif // defined(OS_WIN) | 558 #endif // defined(OS_WIN) |
| 559 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 559 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
| OLD | NEW |