| 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 21 matching lines...) Expand all Loading... |
| 32 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 33 | 33 |
| 34 class SkBitmap; | 34 class SkBitmap; |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // KeystonePromotionInfoBarDelegate ------------------------------------------- | 38 // KeystonePromotionInfoBarDelegate ------------------------------------------- |
| 39 | 39 |
| 40 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { | 40 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 41 public: | 41 public: |
| 42 KeystonePromotionInfoBarDelegate(InfoBarTabService* infobar_service, | 42 KeystonePromotionInfoBarDelegate(InfoBarService* infobar_service, |
| 43 PrefService* prefs); | 43 PrefService* prefs); |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 virtual ~KeystonePromotionInfoBarDelegate(); | 46 virtual ~KeystonePromotionInfoBarDelegate(); |
| 47 | 47 |
| 48 // Sets this info bar to be able to expire. Called a predetermined amount | 48 // Sets this info bar to be able to expire. Called a predetermined amount |
| 49 // of time after this object is created. | 49 // of time after this object is created. |
| 50 void SetCanExpire() { can_expire_ = true; } | 50 void SetCanExpire() { can_expire_ = true; } |
| 51 | 51 |
| 52 // ConfirmInfoBarDelegate | 52 // ConfirmInfoBarDelegate |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 |
| 70 DISALLOW_COPY_AND_ASSIGN(KeystonePromotionInfoBarDelegate); | 70 DISALLOW_COPY_AND_ASSIGN(KeystonePromotionInfoBarDelegate); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate( | 73 KeystonePromotionInfoBarDelegate::KeystonePromotionInfoBarDelegate( |
| 74 InfoBarTabService* infobar_service, | 74 InfoBarService* infobar_service, |
| 75 PrefService* prefs) | 75 PrefService* prefs) |
| 76 : ConfirmInfoBarDelegate(infobar_service), | 76 : ConfirmInfoBarDelegate(infobar_service), |
| 77 prefs_(prefs), | 77 prefs_(prefs), |
| 78 can_expire_(false), | 78 can_expire_(false), |
| 79 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { | 79 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| 80 const base::TimeDelta kCanExpireOnNavigationAfterDelay = | 80 const base::TimeDelta kCanExpireOnNavigationAfterDelay = |
| 81 base::TimeDelta::FromSeconds(8); | 81 base::TimeDelta::FromSeconds(8); |
| 82 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 82 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 83 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, | 83 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, |
| 84 weak_ptr_factory_.GetWeakPtr()), | 84 weak_ptr_factory_.GetWeakPtr()), |
| (...skipping 132 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 |