| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 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 std::string GetIdentifier() const override; |
| 54 int GetIconId() const override; | 55 int GetIconId() const override; |
| 55 bool ShouldExpire(const NavigationDetails& details) const override; | 56 bool ShouldExpire(const NavigationDetails& details) const override; |
| 56 base::string16 GetMessageText() const override; | 57 base::string16 GetMessageText() const override; |
| 57 base::string16 GetButtonLabel(InfoBarButton button) const override; | 58 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 58 bool Accept() override; | 59 bool Accept() override; |
| 59 bool Cancel() override; | 60 bool Cancel() override; |
| 60 | 61 |
| 61 // The prefs to use. | 62 // The prefs to use. |
| 62 PrefService* prefs_; // weak | 63 PrefService* prefs_; // weak |
| 63 | 64 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 base::TimeDelta::FromSeconds(8); | 98 base::TimeDelta::FromSeconds(8); |
| 98 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 99 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 99 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, | 100 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, |
| 100 weak_ptr_factory_.GetWeakPtr()), | 101 weak_ptr_factory_.GetWeakPtr()), |
| 101 kCanExpireOnNavigationAfterDelay); | 102 kCanExpireOnNavigationAfterDelay); |
| 102 } | 103 } |
| 103 | 104 |
| 104 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { | 105 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { |
| 105 } | 106 } |
| 106 | 107 |
| 108 std::string KeystonePromotionInfoBarDelegate::GetIdentifier() const { |
| 109 return "KeystonePromotionInfoBarDelegate"; |
| 110 } |
| 111 |
| 107 int KeystonePromotionInfoBarDelegate::GetIconId() const { | 112 int KeystonePromotionInfoBarDelegate::GetIconId() const { |
| 108 return IDR_PRODUCT_LOGO_32; | 113 return IDR_PRODUCT_LOGO_32; |
| 109 } | 114 } |
| 110 | 115 |
| 111 bool KeystonePromotionInfoBarDelegate::ShouldExpire( | 116 bool KeystonePromotionInfoBarDelegate::ShouldExpire( |
| 112 const NavigationDetails& details) const { | 117 const NavigationDetails& details) const { |
| 113 return can_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); | 118 return can_expire_ && ConfirmInfoBarDelegate::ShouldExpire(details); |
| 114 } | 119 } |
| 115 | 120 |
| 116 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { | 121 base::string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 222 |
| 218 @end // @implementation KeystonePromotionInfoBar | 223 @end // @implementation KeystonePromotionInfoBar |
| 219 | 224 |
| 220 // static | 225 // static |
| 221 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 226 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 222 KeystonePromotionInfoBar* promotionInfoBar = | 227 KeystonePromotionInfoBar* promotionInfoBar = |
| 223 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 228 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 224 | 229 |
| 225 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 230 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 226 } | 231 } |
| OLD | NEW |