| 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 26 matching lines...) Expand all Loading... |
| 37 // KeystonePromotionInfoBarDelegate ------------------------------------------- | 37 // KeystonePromotionInfoBarDelegate ------------------------------------------- |
| 38 | 38 |
| 39 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { | 39 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 40 public: | 40 public: |
| 41 // If there's an active tab, creates a keystone promotion delegate and adds it | 41 // If there's an active tab, creates a keystone promotion delegate and adds it |
| 42 // to the InfoBarService associated with that tab. | 42 // to the InfoBarService associated with that tab. |
| 43 static void Create(); | 43 static void Create(); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 explicit KeystonePromotionInfoBarDelegate(PrefService* prefs); | 46 explicit KeystonePromotionInfoBarDelegate(PrefService* prefs); |
| 47 virtual ~KeystonePromotionInfoBarDelegate(); | 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 virtual int GetIconID() const override; | 54 int GetIconID() const override; |
| 55 virtual base::string16 GetMessageText() const override; | 55 base::string16 GetMessageText() const override; |
| 56 virtual base::string16 GetButtonLabel(InfoBarButton button) const override; | 56 base::string16 GetButtonLabel(InfoBarButton button) const override; |
| 57 virtual bool Accept() override; | 57 bool Accept() override; |
| 58 virtual bool Cancel() override; | 58 bool Cancel() override; |
| 59 virtual bool ShouldExpireInternal( | 59 bool ShouldExpireInternal(const NavigationDetails& details) const override; |
| 60 const NavigationDetails& details) const override; | |
| 61 | 60 |
| 62 // The prefs to use. | 61 // The prefs to use. |
| 63 PrefService* prefs_; // weak | 62 PrefService* prefs_; // weak |
| 64 | 63 |
| 65 // Whether the info bar should be dismissed on the next navigation. | 64 // Whether the info bar should be dismissed on the next navigation. |
| 66 bool can_expire_; | 65 bool can_expire_; |
| 67 | 66 |
| 68 // Used to delay the expiration of the info bar. | 67 // Used to delay the expiration of the info bar. |
| 69 base::WeakPtrFactory<KeystonePromotionInfoBarDelegate> weak_ptr_factory_; | 68 base::WeakPtrFactory<KeystonePromotionInfoBarDelegate> weak_ptr_factory_; |
| 70 | 69 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 217 |
| 219 @end // @implementation KeystonePromotionInfoBar | 218 @end // @implementation KeystonePromotionInfoBar |
| 220 | 219 |
| 221 // static | 220 // static |
| 222 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 221 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 223 KeystonePromotionInfoBar* promotionInfoBar = | 222 KeystonePromotionInfoBar* promotionInfoBar = |
| 224 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 223 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 225 | 224 |
| 226 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 225 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 227 } | 226 } |
| OLD | NEW |