| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "chrome/browser/ui/cocoa/keystone_infobar.h" |
| 6 | 6 |
| 7 #import <AppKit/AppKit.h> | 7 #import <AppKit/AppKit.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 virtual ~KeystonePromotionInfoBarDelegate(); | 42 virtual ~KeystonePromotionInfoBarDelegate(); |
| 43 | 43 |
| 44 // Sets this info bar to be able to expire. Called a predetermined amount | 44 // Sets this info bar to be able to expire. Called a predetermined amount |
| 45 // of time after this object is created. | 45 // of time after this object is created. |
| 46 void SetCanExpire() { can_expire_ = true; } | 46 void SetCanExpire() { can_expire_ = true; } |
| 47 | 47 |
| 48 // ConfirmInfoBarDelegate | 48 // ConfirmInfoBarDelegate |
| 49 virtual bool ShouldExpire( | 49 virtual bool ShouldExpire( |
| 50 const NavigationController::LoadCommittedDetails& details) const; | 50 const NavigationController::LoadCommittedDetails& details) const OVERRIDE; |
| 51 virtual void InfoBarClosed(); | 51 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 52 virtual gfx::Image* GetIcon() const; | 52 virtual string16 GetMessageText() const OVERRIDE; |
| 53 virtual string16 GetMessageText() const; | 53 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 54 virtual string16 GetButtonLabel(InfoBarButton button) const; | 54 virtual bool Accept() OVERRIDE; |
| 55 virtual bool Accept(); | 55 virtual bool Cancel() OVERRIDE; |
| 56 virtual bool Cancel(); | |
| 57 | 56 |
| 58 // The TabContents' profile. | 57 // The TabContents' profile. |
| 59 Profile* profile_; // weak | 58 Profile* profile_; // weak |
| 60 | 59 |
| 61 // Whether the info bar should be dismissed on the next navigation. | 60 // Whether the info bar should be dismissed on the next navigation. |
| 62 bool can_expire_; | 61 bool can_expire_; |
| 63 | 62 |
| 64 // Used to delay the expiration of the info bar. | 63 // Used to delay the expiration of the info bar. |
| 65 ScopedRunnableMethodFactory<KeystonePromotionInfoBarDelegate> method_factory_; | 64 ScopedRunnableMethodFactory<KeystonePromotionInfoBarDelegate> method_factory_; |
| 66 | 65 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 } | 80 } |
| 82 | 81 |
| 83 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { | 82 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { |
| 84 } | 83 } |
| 85 | 84 |
| 86 bool KeystonePromotionInfoBarDelegate::ShouldExpire( | 85 bool KeystonePromotionInfoBarDelegate::ShouldExpire( |
| 87 const NavigationController::LoadCommittedDetails& details) const { | 86 const NavigationController::LoadCommittedDetails& details) const { |
| 88 return can_expire_; | 87 return can_expire_; |
| 89 } | 88 } |
| 90 | 89 |
| 91 void KeystonePromotionInfoBarDelegate::InfoBarClosed() { | |
| 92 delete this; | |
| 93 } | |
| 94 | |
| 95 gfx::Image* KeystonePromotionInfoBarDelegate::GetIcon() const { | 90 gfx::Image* KeystonePromotionInfoBarDelegate::GetIcon() const { |
| 96 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 91 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( |
| 97 IDR_PRODUCT_ICON_32); | 92 IDR_PRODUCT_ICON_32); |
| 98 } | 93 } |
| 99 | 94 |
| 100 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { | 95 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { |
| 101 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, | 96 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, |
| 102 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 97 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 103 } | 98 } |
| 104 | 99 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 206 |
| 212 @end // @implementation KeystonePromotionInfoBar | 207 @end // @implementation KeystonePromotionInfoBar |
| 213 | 208 |
| 214 // static | 209 // static |
| 215 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 210 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 216 KeystonePromotionInfoBar* promotionInfoBar = | 211 KeystonePromotionInfoBar* promotionInfoBar = |
| 217 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 212 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 218 | 213 |
| 219 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 214 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 220 } | 215 } |
| OLD | NEW |