| 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 "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| 11 | 11 |
| 12 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( | 12 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( |
| 13 TabContents* tab_contents, | 13 TabContents* tab_contents, |
| 14 ProtocolHandlerRegistry* registry, | 14 ProtocolHandlerRegistry* registry, |
| 15 ProtocolHandler handler) | 15 ProtocolHandler handler) |
| 16 : ConfirmInfoBarDelegate(tab_contents), | 16 : ConfirmInfoBarDelegate(tab_contents), |
| 17 tab_contents_(tab_contents), | 17 tab_contents_(tab_contents), |
| 18 registry_(registry), | 18 registry_(registry), |
| 19 handler_(handler) { | 19 handler_(handler) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire( | 22 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire( |
| 23 const NavigationController::LoadCommittedDetails& details) const { | 23 const NavigationController::LoadCommittedDetails& details) const { |
| 24 // The user has submitted a form, causing the page to navigate elsewhere. We | 24 // The user has submitted a form, causing the page to navigate elsewhere. We |
| 25 // don't want the infobar to be expired at this point, because the user won't | 25 // don't want the infobar to be expired at this point, because the user won't |
| 26 // get a chance to answer the question. | 26 // get a chance to answer the question. |
| 27 return false; | 27 return false; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void RegisterProtocolHandlerInfoBarDelegate::InfoBarClosed() { | |
| 31 delete this; | |
| 32 } | |
| 33 | |
| 34 InfoBarDelegate::Type | 30 InfoBarDelegate::Type |
| 35 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const { | 31 RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() const { |
| 36 return PAGE_ACTION_TYPE; | 32 return PAGE_ACTION_TYPE; |
| 37 } | 33 } |
| 38 | 34 |
| 39 string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { | 35 string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { |
| 40 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); | 36 ProtocolHandler old_handler = registry_->GetHandlerFor(handler_.protocol()); |
| 41 return !old_handler.IsEmpty() ? | 37 return !old_handler.IsEmpty() ? |
| 42 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, | 38 l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE, |
| 43 handler_.title(), UTF8ToUTF16(handler_.url().host()), | 39 handler_.title(), UTF8ToUTF16(handler_.url().host()), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 | 63 |
| 68 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() { | 64 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() { |
| 69 // TODO(koz): Make this a 'learn more' link. | 65 // TODO(koz): Make this a 'learn more' link. |
| 70 return string16(); | 66 return string16(); |
| 71 } | 67 } |
| 72 | 68 |
| 73 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( | 69 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked( |
| 74 WindowOpenDisposition disposition) { | 70 WindowOpenDisposition disposition) { |
| 75 return false; | 71 return false; |
| 76 } | 72 } |
| OLD | NEW |