Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: chrome/browser/ui/cocoa/keystone_infobar_delegate.mm

Issue 922953002: Minor infobar cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 base::string16 GetMessageText() const override; 56 base::string16 GetMessageText() const override;
56 base::string16 GetButtonLabel(InfoBarButton button) const override; 57 base::string16 GetButtonLabel(InfoBarButton button) const override;
57 bool Accept() override; 58 bool Accept() override;
58 bool Cancel() override; 59 bool Cancel() override;
59 bool ShouldExpireInternal(const NavigationDetails& details) const 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_;
66 66
67 // Used to delay the expiration of the info bar. 67 // Used to delay the expiration of the info bar.
68 base::WeakPtrFactory<KeystonePromotionInfoBarDelegate> weak_ptr_factory_; 68 base::WeakPtrFactory<KeystonePromotionInfoBarDelegate> weak_ptr_factory_;
69 69
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
112 const NavigationDetails& details) const {
113 return can_expire_;
114 }
115
111 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { 116 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const {
112 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, 117 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT,
113 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); 118 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
114 } 119 }
115 120
116 base::string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( 121 base::string16 KeystonePromotionInfoBarDelegate::GetButtonLabel(
117 InfoBarButton button) const { 122 InfoBarButton button) const {
118 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 123 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
119 IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON : IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON); 124 IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON : IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON);
120 } 125 }
121 126
122 bool KeystonePromotionInfoBarDelegate::Accept() { 127 bool KeystonePromotionInfoBarDelegate::Accept() {
123 [[KeystoneGlue defaultKeystoneGlue] promoteTicket]; 128 [[KeystoneGlue defaultKeystoneGlue] promoteTicket];
124 return true; 129 return true;
125 } 130 }
126 131
127 bool KeystonePromotionInfoBarDelegate::Cancel() { 132 bool KeystonePromotionInfoBarDelegate::Cancel() {
128 prefs_->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false); 133 prefs_->SetBoolean(prefs::kShowUpdatePromotionInfoBar, false);
129 return true; 134 return true;
130 } 135 }
131 136
132 bool KeystonePromotionInfoBarDelegate::ShouldExpireInternal(
133 const NavigationDetails& details) const {
134 return can_expire_;
135 }
136
137 } // namespace 137 } // namespace
138 138
139 139
140 // KeystonePromotionInfoBar --------------------------------------------------- 140 // KeystonePromotionInfoBar ---------------------------------------------------
141 141
142 @interface KeystonePromotionInfoBar : NSObject 142 @interface KeystonePromotionInfoBar : NSObject
143 - (void)checkAndShowInfoBarForProfile:(Profile*)profile; 143 - (void)checkAndShowInfoBarForProfile:(Profile*)profile;
144 - (void)updateStatus:(NSNotification*)notification; 144 - (void)updateStatus:(NSNotification*)notification;
145 - (void)removeObserver; 145 - (void)removeObserver;
146 @end // @interface KeystonePromotionInfoBar 146 @end // @interface KeystonePromotionInfoBar
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/auto_login_infobar_delegate.cc ('k') | chrome/browser/ui/collected_cookies_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698