| 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 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 22 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "content/public/browser/navigation_details.h" | 26 #include "content/public/browser/navigation_details.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | |
| 33 | 32 |
| 34 class SkBitmap; | 33 class SkBitmap; |
| 35 | 34 |
| 36 namespace { | 35 namespace { |
| 37 | 36 |
| 38 // KeystonePromotionInfoBarDelegate ------------------------------------------- | 37 // KeystonePromotionInfoBarDelegate ------------------------------------------- |
| 39 | 38 |
| 40 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { | 39 class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 41 public: | 40 public: |
| 42 // 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 |
| 43 // to the InfoBarService associated with that tab. | 42 // to the InfoBarService associated with that tab. |
| 44 static void Create(); | 43 static void Create(); |
| 45 | 44 |
| 46 private: | 45 private: |
| 47 KeystonePromotionInfoBarDelegate(InfoBarService* infobar_service, | 46 KeystonePromotionInfoBarDelegate(InfoBarService* infobar_service, |
| 48 PrefService* prefs); | 47 PrefService* prefs); |
| 49 virtual ~KeystonePromotionInfoBarDelegate(); | 48 virtual ~KeystonePromotionInfoBarDelegate(); |
| 50 | 49 |
| 51 // Sets this info bar to be able to expire. Called a predetermined amount | 50 // Sets this info bar to be able to expire. Called a predetermined amount |
| 52 // of time after this object is created. | 51 // of time after this object is created. |
| 53 void SetCanExpire() { can_expire_ = true; } | 52 void SetCanExpire() { can_expire_ = true; } |
| 54 | 53 |
| 55 // ConfirmInfoBarDelegate | 54 // ConfirmInfoBarDelegate |
| 56 virtual gfx::Image* GetIcon() const OVERRIDE; | 55 virtual int GetIconID() const OVERRIDE; |
| 57 virtual string16 GetMessageText() const OVERRIDE; | 56 virtual string16 GetMessageText() const OVERRIDE; |
| 58 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 57 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 59 virtual bool Accept() OVERRIDE; | 58 virtual bool Accept() OVERRIDE; |
| 60 virtual bool Cancel() OVERRIDE; | 59 virtual bool Cancel() OVERRIDE; |
| 61 virtual bool ShouldExpireInternal( | 60 virtual bool ShouldExpireInternal( |
| 62 const content::LoadCommittedDetails& details) const OVERRIDE; | 61 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 63 | 62 |
| 64 // The prefs to use. | 63 // The prefs to use. |
| 65 PrefService* prefs_; // weak | 64 PrefService* prefs_; // weak |
| 66 | 65 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 base::TimeDelta::FromSeconds(8); | 102 base::TimeDelta::FromSeconds(8); |
| 104 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 103 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 105 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, | 104 base::Bind(&KeystonePromotionInfoBarDelegate::SetCanExpire, |
| 106 weak_ptr_factory_.GetWeakPtr()), | 105 weak_ptr_factory_.GetWeakPtr()), |
| 107 kCanExpireOnNavigationAfterDelay); | 106 kCanExpireOnNavigationAfterDelay); |
| 108 } | 107 } |
| 109 | 108 |
| 110 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { | 109 KeystonePromotionInfoBarDelegate::~KeystonePromotionInfoBarDelegate() { |
| 111 } | 110 } |
| 112 | 111 |
| 113 gfx::Image* KeystonePromotionInfoBarDelegate::GetIcon() const { | 112 int KeystonePromotionInfoBarDelegate::GetIconID() const { |
| 114 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 113 return IDR_PRODUCT_LOGO_32; |
| 115 IDR_PRODUCT_LOGO_32); | |
| 116 } | 114 } |
| 117 | 115 |
| 118 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { | 116 string16 KeystonePromotionInfoBarDelegate::GetMessageText() const { |
| 119 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, | 117 return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, |
| 120 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 118 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 121 } | 119 } |
| 122 | 120 |
| 123 string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( | 121 string16 KeystonePromotionInfoBarDelegate::GetButtonLabel( |
| 124 InfoBarButton button) const { | 122 InfoBarButton button) const { |
| 125 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 123 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 222 |
| 225 @end // @implementation KeystonePromotionInfoBar | 223 @end // @implementation KeystonePromotionInfoBar |
| 226 | 224 |
| 227 // static | 225 // static |
| 228 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 226 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 229 KeystonePromotionInfoBar* promotionInfoBar = | 227 KeystonePromotionInfoBar* promotionInfoBar = |
| 230 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 228 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 231 | 229 |
| 232 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 230 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 233 } | 231 } |
| OLD | NEW |