| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 51 virtual void InfoBarClosed(); | 51 virtual void InfoBarClosed(); |
| 52 virtual SkBitmap* GetIcon() const; | 52 virtual SkBitmap* GetIcon() const; |
| 53 virtual string16 GetMessageText() const; | 53 virtual string16 GetMessageText() const; |
| 54 virtual int GetButtons() const; | |
| 55 virtual string16 GetButtonLabel(InfoBarButton button) const; | 54 virtual string16 GetButtonLabel(InfoBarButton button) const; |
| 56 virtual bool Accept(); | 55 virtual bool Accept(); |
| 57 virtual bool Cancel(); | 56 virtual bool Cancel(); |
| 58 | 57 |
| 59 // The TabContents' profile. | 58 // The TabContents' profile. |
| 60 Profile* profile_; // weak | 59 Profile* profile_; // weak |
| 61 | 60 |
| 62 // Whether the info bar should be dismissed on the next navigation. | 61 // Whether the info bar should be dismissed on the next navigation. |
| 63 bool can_expire_; | 62 bool can_expire_; |
| 64 | 63 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 SkBitmap* KeystonePromotionInfoBarDelegate::GetIcon() const { | 95 SkBitmap* KeystonePromotionInfoBarDelegate::GetIcon() const { |
| 97 return ResourceBundle::GetSharedInstance().GetBitmapNamed( | 96 return ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 98 IDR_PRODUCT_ICON_32); | 97 IDR_PRODUCT_ICON_32); |
| 99 } | 98 } |
| 100 | 99 |
| 101 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { | 100 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { |
| 102 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, | 101 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, |
| 103 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 102 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 104 } | 103 } |
| 105 | 104 |
| 106 int KeystonePromotionInfoBarDelegate::GetButtons() const { | |
| 107 return BUTTON_OK | BUTTON_CANCEL; | |
| 108 } | |
| 109 | |
| 110 string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( | 105 string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( |
| 111 InfoBarButton button) const { | 106 InfoBarButton button) const { |
| 112 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 107 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 113 IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON : IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON); | 108 IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON : IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON); |
| 114 } | 109 } |
| 115 | 110 |
| 116 bool KeystonePromotionInfoBarDelegate::Accept() { | 111 bool KeystonePromotionInfoBarDelegate::Accept() { |
| 117 [[KeystoneGlue defaultKeystoneGlue] promoteTicket]; | 112 [[KeystoneGlue defaultKeystoneGlue] promoteTicket]; |
| 118 return true; | 113 return true; |
| 119 } | 114 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 211 |
| 217 @end // @implementation KeystonePromotionInfoBar | 212 @end // @implementation KeystonePromotionInfoBar |
| 218 | 213 |
| 219 // static | 214 // static |
| 220 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 215 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 221 KeystonePromotionInfoBar* promotionInfoBar = | 216 KeystonePromotionInfoBar* promotionInfoBar = |
| 222 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 217 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 223 | 218 |
| 224 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 219 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 225 } | 220 } |
| OLD | NEW |