| 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/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/strings/utf_string_conversions.h" | 7 #include "base/strings/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/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const { | 61 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const { |
| 62 return PAGE_ACTION_TYPE; | 62 return PAGE_ACTION_TYPE; |
| 63 } | 63 } |
| 64 | 64 |
| 65 RegisterProtocolHandlerInfoBarDelegate* | 65 RegisterProtocolHandlerInfoBarDelegate* |
| 66 RegisterProtocolHandlerInfoBarDelegate:: | 66 RegisterProtocolHandlerInfoBarDelegate:: |
| 67 AsRegisterProtocolHandlerInfoBarDelegate() { | 67 AsRegisterProtocolHandlerInfoBarDelegate() { |
| 68 return this; | 68 return this; |
| 69 } | 69 } |
| 70 | 70 |
| 71 string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { | 71 base::string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { |
| 72 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); | 72 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); |
| 73 return old_handler.IsEmpty() ? | 73 return old_handler.IsEmpty() ? |
| 74 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, | 74 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, |
| 75 handler_.title(), UTF8ToUTF16(handler_.url().host()), | 75 handler_.title(), UTF8ToUTF16(handler_.url().host()), |
| 76 GetProtocolName(handler_)) : | 76 GetProtocolName(handler_)) : |
| 77 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, | 77 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, |
| 78 handler_.title(), UTF8ToUTF16(handler_.url().host()), | 78 handler_.title(), UTF8ToUTF16(handler_.url().host()), |
| 79 GetProtocolName(handler_), old_handler.title()); | 79 GetProtocolName(handler_), old_handler.title()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel( | 82 base::string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel( |
| 83 InfoBarButton button) const { | 83 InfoBarButton button) const { |
| 84 return (button == BUTTON_OK) ? | 84 return (button == BUTTON_OK) ? |
| 85 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, | 85 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, |
| 86 handler_.title()) : | 86 handler_.title()) : |
| 87 l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); | 87 l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation( | 90 bool RegisterProtocolHandlerInfoBarDelegate::NeedElevation( |
| 91 InfoBarButton button) const { | 91 InfoBarButton button) const { |
| 92 return button == BUTTON_OK; | 92 return button == BUTTON_OK; |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool RegisterProtocolHandlerInfoBarDelegate::Accept() { | 95 bool RegisterProtocolHandlerInfoBarDelegate::Accept() { |
| 96 content::RecordAction( | 96 content::RecordAction( |
| 97 content::UserMetricsAction("RegisterProtocolHandler.Infobar_Accept")); | 97 content::UserMetricsAction("RegisterProtocolHandler.Infobar_Accept")); |
| 98 registry_->OnAcceptRegisterProtocolHandler(handler_); | 98 registry_->OnAcceptRegisterProtocolHandler(handler_); |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() { | 102 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() { |
| 103 content::RecordAction( | 103 content::RecordAction( |
| 104 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny")); | 104 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_Deny")); |
| 105 registry_->OnIgnoreRegisterProtocolHandler(handler_); | 105 registry_->OnIgnoreRegisterProtocolHandler(handler_); |
| 106 return true; | 106 return true; |
| 107 } | 107 } |
| 108 | 108 |
| 109 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const { | 109 base::string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() const { |
| 110 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 110 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( | 113 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( |
| 114 WindowOpenDisposition disposition) { | 114 WindowOpenDisposition disposition) { |
| 115 content::RecordAction( | 115 content::RecordAction( |
| 116 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); | 116 content::UserMetricsAction("RegisterProtocolHandler.InfoBar_LearnMore")); |
| 117 web_contents()->OpenURL(content::OpenURLParams( | 117 web_contents()->OpenURL(content::OpenURLParams( |
| 118 GURL(chrome::kLearnMoreRegisterProtocolHandlerURL), content::Referrer(), | 118 GURL(chrome::kLearnMoreRegisterProtocolHandlerURL), content::Referrer(), |
| 119 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 119 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
| 120 content::PAGE_TRANSITION_LINK, false)); | 120 content::PAGE_TRANSITION_LINK, false)); |
| 121 return false; | 121 return false; |
| 122 } | 122 } |
| 123 | 123 |
| 124 string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName( | 124 base::string16 RegisterProtocolHandlerInfoBarDelegate::GetProtocolName( |
| 125 const ProtocolHandler& handler) const { | 125 const ProtocolHandler& handler) const { |
| 126 if (handler.protocol() == "mailto") | 126 if (handler.protocol() == "mailto") |
| 127 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); | 127 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_MAILTO_NAME); |
| 128 if (handler.protocol() == "webcal") | 128 if (handler.protocol() == "webcal") |
| 129 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); | 129 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_WEBCAL_NAME); |
| 130 return UTF8ToUTF16(handler.protocol()); | 130 return UTF8ToUTF16(handler.protocol()); |
| 131 } | 131 } |
| OLD | NEW |