| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 5 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 8 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "content/browser/user_metrics.h" | 13 #include "content/public/browser/user_metrics.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 | 16 |
| 17 using content::UserMetricsAction; |
| 18 |
| 17 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( | 19 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( |
| 18 InfoBarTabHelper* infobar_helper, | 20 InfoBarTabHelper* infobar_helper, |
| 19 ProtocolHandlerRegistry* registry, | 21 ProtocolHandlerRegistry* registry, |
| 20 const ProtocolHandler& handler) | 22 const ProtocolHandler& handler) |
| 21 : ConfirmInfoBarDelegate(infobar_helper), | 23 : ConfirmInfoBarDelegate(infobar_helper), |
| 22 registry_(registry), | 24 registry_(registry), |
| 23 handler_(handler) { | 25 handler_(handler) { |
| 24 } | 26 } |
| 25 | 27 |
| 26 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire( | 28 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 handler_.title()) : | 65 handler_.title()) : |
| 64 l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); | 66 l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); |
| 65 } | 67 } |
| 66 | 68 |
| 67 bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation( | 69 bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation( |
| 68 InfoBarButton button) const { | 70 InfoBarButton button) const { |
| 69 return button == BUTTON_OK; | 71 return button == BUTTON_OK; |
| 70 } | 72 } |
| 71 | 73 |
| 72 bool RegisterProtocolHandlerInfoBarDelegate::Accept() { | 74 bool RegisterProtocolHandlerInfoBarDelegate::Accept() { |
| 73 UserMetrics::RecordAction( | 75 content::RecordAction( |
| 74 UserMetricsAction("RegisterProtocolHandler.Infobar_Accept")); | 76 UserMetricsAction("RegisterProtocolHandler.Infobar_Accept")); |
| 75 registry_->OnAcceptRegisterProtocolHandler(handler_); | 77 registry_->OnAcceptRegisterProtocolHandler(handler_); |
| 76 return true; | 78 return true; |
| 77 } | 79 } |
| 78 | 80 |
| 79 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() { | 81 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() { |
| 80 UserMetrics::RecordAction( | 82 content::RecordAction( |
| 81 UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny")); | 83 UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny")); |
| 82 registry_->OnIgnoreRegisterProtocolHandler(handler_); | 84 registry_->OnIgnoreRegisterProtocolHandler(handler_); |
| 83 return true; | 85 return true; |
| 84 } | 86 } |
| 85 | 87 |
| 86 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const { | 88 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const { |
| 87 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 89 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 88 } | 90 } |
| 89 | 91 |
| 90 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( | 92 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( |
| 91 WindowOpenDisposition disposition) { | 93 WindowOpenDisposition disposition) { |
| 92 UserMetrics::RecordAction( | 94 content::RecordAction( |
| 93 UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); | 95 UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); |
| 94 owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( | 96 owner()->tab_contents()->OpenURL(google_util::AppendGoogleLocaleParam(GURL( |
| 95 chrome::kLearnMoreRegisterProtocolHandlerURL)), GURL(), | 97 chrome::kLearnMoreRegisterProtocolHandlerURL)), GURL(), |
| 96 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 98 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 97 content::PAGE_TRANSITION_LINK); | 99 content::PAGE_TRANSITION_LINK); |
| 98 return false; | 100 return false; |
| 99 } | 101 } |
| OLD | NEW |