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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "chrome/browser/first_run/first_run.h" | 15 #include "chrome/browser/first_run/first_run.h" |
16 #include "chrome/browser/infobars/infobar_tab_helper.h" | 16 #include "chrome/browser/infobars/infobar_tab_helper.h" |
17 #import "chrome/browser/mac/keystone_glue.h" | 17 #import "chrome/browser/mac/keystone_glue.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 18 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 20 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_tabstrip.h" |
22 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 23 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 24 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "content/public/browser/navigation_details.h" | 27 #include "content/public/browser/navigation_details.h" |
27 #include "grit/chromium_strings.h" | 28 #include "grit/chromium_strings.h" |
28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (status == kAutoupdateNone || status == kAutoupdateRegistering) { | 185 if (status == kAutoupdateNone || status == kAutoupdateRegistering) { |
185 return; | 186 return; |
186 } | 187 } |
187 | 188 |
188 [self removeObserver]; | 189 [self removeObserver]; |
189 | 190 |
190 if (status != kAutoupdateRegisterFailed && | 191 if (status != kAutoupdateRegisterFailed && |
191 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { | 192 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { |
192 Browser* browser = browser::GetLastActiveBrowser(); | 193 Browser* browser = browser::GetLastActiveBrowser(); |
193 if (browser) { | 194 if (browser) { |
194 TabContents* tabContents = browser->GetActiveTabContents(); | 195 TabContents* tabContents = chrome::GetActiveTabContents(browser); |
195 | 196 |
196 // Only show if no other info bars are showing, because that's how the | 197 // Only show if no other info bars are showing, because that's how the |
197 // default browser info bar works. | 198 // default browser info bar works. |
198 if (tabContents) { | 199 if (tabContents) { |
199 InfoBarTabHelper* infobar_helper = tabContents->infobar_tab_helper(); | 200 InfoBarTabHelper* infobar_helper = tabContents->infobar_tab_helper(); |
200 if (infobar_helper->infobar_count() == 0) { | 201 if (infobar_helper->infobar_count() == 0) { |
201 infobar_helper->AddInfoBar( | 202 infobar_helper->AddInfoBar( |
202 new KeystonePromotionInfoBarDelegate( | 203 new KeystonePromotionInfoBarDelegate( |
203 infobar_helper, | 204 infobar_helper, |
204 tabContents->profile()->GetPrefs())); | 205 tabContents->profile()->GetPrefs())); |
(...skipping 11 matching lines...) Expand all Loading... |
216 | 217 |
217 @end // @implementation KeystonePromotionInfoBar | 218 @end // @implementation KeystonePromotionInfoBar |
218 | 219 |
219 // static | 220 // static |
220 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 221 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
221 KeystonePromotionInfoBar* promotionInfoBar = | 222 KeystonePromotionInfoBar* promotionInfoBar = |
222 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 223 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
223 | 224 |
224 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 225 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
225 } | 226 } |
OLD | NEW |