| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
| 15 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 15 #import "chrome/browser/mac/keystone_glue.h" | 16 #import "chrome/browser/mac/keystone_glue.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 19 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "content/browser/tab_contents/navigation_details.h" | 25 #include "content/browser/tab_contents/navigation_details.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 [self removeObserver]; | 184 [self removeObserver]; |
| 184 | 185 |
| 185 if (status != kAutoupdateRegisterFailed && | 186 if (status != kAutoupdateRegisterFailed && |
| 186 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { | 187 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { |
| 187 Browser* browser = BrowserList::GetLastActive(); | 188 Browser* browser = BrowserList::GetLastActive(); |
| 188 if (browser) { | 189 if (browser) { |
| 189 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); | 190 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); |
| 190 | 191 |
| 191 // Only show if no other info bars are showing, because that's how the | 192 // Only show if no other info bars are showing, because that's how the |
| 192 // default browser info bar works. | 193 // default browser info bar works. |
| 193 if (wrapper && wrapper->infobar_count() == 0) { | 194 if (wrapper && wrapper->infobar_tab_helper()->infobar_count() == 0) { |
| 194 wrapper->AddInfoBar(new KeystonePromotionInfoBarDelegate( | 195 wrapper->infobar_tab_helper()->AddInfoBar( |
| 195 wrapper->tab_contents())); | 196 new KeystonePromotionInfoBarDelegate(wrapper->tab_contents())); |
| 196 } | 197 } |
| 197 } | 198 } |
| 198 } | 199 } |
| 199 | 200 |
| 200 [self release]; | 201 [self release]; |
| 201 } | 202 } |
| 202 | 203 |
| 203 - (void)removeObserver { | 204 - (void)removeObserver { |
| 204 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 205 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 205 } | 206 } |
| 206 | 207 |
| 207 @end // @implementation KeystonePromotionInfoBar | 208 @end // @implementation KeystonePromotionInfoBar |
| 208 | 209 |
| 209 // static | 210 // static |
| 210 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 211 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
| 211 KeystonePromotionInfoBar* promotionInfoBar = | 212 KeystonePromotionInfoBar* promotionInfoBar = |
| 212 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 213 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
| 213 | 214 |
| 214 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 215 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
| 215 } | 216 } |
| OLD | NEW |