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/ui/cocoa/keystone_infobar_delegate.h" | 5 #include "chrome/browser/ui/cocoa/keystone_infobar_delegate.h" |
6 | 6 |
7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 private: | 45 private: |
46 explicit KeystonePromotionInfoBarDelegate(PrefService* prefs); | 46 explicit KeystonePromotionInfoBarDelegate(PrefService* prefs); |
47 ~KeystonePromotionInfoBarDelegate() override; | 47 ~KeystonePromotionInfoBarDelegate() override; |
48 | 48 |
49 // Sets this info bar to be able to expire. Called a predetermined amount | 49 // Sets this info bar to be able to expire. Called a predetermined amount |
50 // of time after this object is created. | 50 // of time after this object is created. |
51 void SetCanExpire() { can_expire_ = true; } | 51 void SetCanExpire() { can_expire_ = true; } |
52 | 52 |
53 // ConfirmInfoBarDelegate | 53 // ConfirmInfoBarDelegate |
54 int GetIconID() const override; | 54 int GetIconID() const override; |
55 bool ShouldExpireInternal(const NavigationDetails& details) const override; | 55 bool ShouldExpire(const NavigationDetails& details) const override; |
56 base::string16 GetMessageText() const override; | 56 base::string16 GetMessageText() const override; |
57 base::string16 GetButtonLabel(InfoBarButton button) const override; | 57 base::string16 GetButtonLabel(InfoBarButton button) const override; |
58 bool Accept() override; | 58 bool Accept() override; |
59 bool Cancel() override; | 59 bool Cancel() override; |
60 | 60 |
61 // The prefs to use. | 61 // The prefs to use. |
62 PrefService* prefs_; // weak | 62 PrefService* prefs_; // weak |
63 | 63 |
64 // Whether the info bar should be dismissed on the next navigation. | 64 // Whether the info bar should be dismissed on the next navigation. |
65 bool can_expire_; | 65 bool can_expire_; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 kCanExpireOnNavigationAfterDelay); | 101 kCanExpireOnNavigationAfterDelay); |
102 } | 102 } |
103 | 103 |
104 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { | 104 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { |
105 } | 105 } |
106 | 106 |
107 int KeystonePromotionInfoBarDelegate::GetIconID() const { | 107 int KeystonePromotionInfoBarDelegate::GetIconID() const { |
108 return IDR_PRODUCT_LOGO_32; | 108 return IDR_PRODUCT_LOGO_32; |
109 } | 109 } |
110 | 110 |
111 bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal( | 111 bool KeystonePromotionInfoBarDelegate::ShouldExpire( |
112 const NavigationDetails& details) const { | 112 const NavigationDetails& details) const { |
113 return can_expire_; | 113 return can_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); |
114 } | 114 } |
115 | 115 |
116 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { | 116 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { |
117 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, | 117 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, |
118 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 118 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
119 } | 119 } |
120 | 120 |
121 base::string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( | 121 base::string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( |
122 InfoBarButton button) const { | 122 InfoBarButton button) const { |
123 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 123 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 | 217 |
218 @end // @implementation KeystonePromotionInfoBar | 218 @end // @implementation KeystonePromotionInfoBar |
219 | 219 |
220 // static | 220 // static |
221 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 221 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
222 KeystonePromotionInfoBar* promotionInfoBar = | 222 KeystonePromotionInfoBar* promotionInfoBar = |
223 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 223 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
224 | 224 |
225 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 225 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
226 } | 226 } |
OLD | NEW |