OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg ate.h" | |
6 | |
7 #include "base/metrics/histogram.h" | |
8 #include "base/utf_string_conversions.h" | |
9 #include "chrome/browser/autofill/autofill_cc_infobar.h" | |
10 #include "chrome/browser/autofill/autofill_manager.h" | |
11 #include "chrome/browser/browser_list.h" | |
12 #include "chrome/browser/prefs/pref_service.h" | |
13 #include "chrome/browser/profiles/profile.h" | |
14 #include "chrome/browser/tab_contents/tab_contents.h" | |
15 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | |
16 #include "chrome/common/pref_names.h" | |
17 #include "grit/chromium_strings.h" | |
18 #include "grit/generated_resources.h" | |
19 #include "grit/theme_resources.h" | |
20 #include "third_party/skia/include/core/SkBitmap.h" | |
21 #include "ui/base/l10n/l10n_util.h" | |
22 #include "ui/base/resource/resource_bundle.h" | |
23 | |
24 RegisterProtocolHandlerInfoBarDelegate::RegisterProtocolHandlerInfoBarDelegate( | |
25 TabContents* tab_contents, ProtocolHandlerRegistry* registry, | |
26 ProtocolHandler* handler) | |
27 : ConfirmInfoBarDelegate(tab_contents), | |
28 registry_(registry), | |
29 handler_(handler) { | |
30 } | |
31 | |
32 bool RegisterProtocolHandlerInfoBarDelegate::ShouldExpire( | |
33 const NavigationController::LoadCommittedDetails& details) const { | |
34 // The user has submitted a form, causing the page to navigate elsewhere. We | |
35 // don't want the infobar to be expired at this point, because the user won't | |
36 // get a chance to answer the question. | |
37 return false; | |
38 } | |
39 | |
40 void RegisterProtocolHandlerInfoBarDelegate::InfoBarClosed() { | |
41 delete this; | |
42 } | |
43 | |
44 string16 RegisterProtocolHandlerInfoBarDelegate::GetMessageText() const { | |
45 ProtocolHandler* old_handler = registry_->GetHandlerFor(handler_->protocol()); | |
46 if (old_handler) { | |
47 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPL ACE, | |
48 handler_->title(), UTF8ToUTF16(handler_->protocol()), old_handler->title ()); | |
49 } | |
50 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM, | |
51 handler_->title(), UTF8ToUTF16(handler_->protocol())); | |
52 } | |
53 | |
54 SkBitmap* RegisterProtocolHandlerInfoBarDelegate::GetIcon() const { | |
55 return NULL; | |
56 } | |
57 | |
58 int RegisterProtocolHandlerInfoBarDelegate::GetButtons() const { | |
59 return BUTTON_OK | BUTTON_CANCEL; | |
60 } | |
61 | |
62 string16 RegisterProtocolHandlerInfoBarDelegate::GetButtonLabel( | |
63 ConfirmInfoBarDelegate::InfoBarButton button) const { | |
64 if (button == BUTTON_OK) | |
65 return l10n_util::GetStringFUTF16(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT, | |
66 handler_->title()); | |
67 else if (button == BUTTON_CANCEL) | |
68 return l10n_util::GetStringUTF16(IDS_REGISTER_PROTOCOL_HANDLER_DENY); | |
69 else | |
70 NOTREACHED(); | |
71 | |
72 return string16(); | |
73 } | |
74 | |
75 bool RegisterProtocolHandlerInfoBarDelegate::Accept() { | |
76 registry_->OnAcceptRegisterProtocolHandler(handler_); | |
77 return true; | |
78 } | |
79 | |
80 bool RegisterProtocolHandlerInfoBarDelegate::Cancel() { | |
81 registry_->OnDenyRegisterProtocolHandler(handler_); | |
82 return true; | |
83 } | |
84 | |
85 string16 RegisterProtocolHandlerInfoBarDelegate::GetLinkText() { | |
86 return string16(); | |
tony
2011/02/14 23:40:07
We'll probably want a "Learn more" link for this f
koz (OOO until 15th September)
2011/02/15 03:37:27
Yep, true.
Done.
| |
87 } | |
88 | |
89 bool RegisterProtocolHandlerInfoBarDelegate::LinkClicked(WindowOpenDisposition d isposition) { | |
90 return false; | |
91 } | |
92 | |
93 InfoBarDelegate::Type RegisterProtocolHandlerInfoBarDelegate::GetInfoBarType() { | |
94 return PAGE_ACTION_TYPE; | |
95 } | |
OLD | NEW |