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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // doing anything related to auto-update is pointless. Bail out. | 173 // doing anything related to auto-update is pointless. Bail out. |
174 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; | 174 KeystoneGlue* keystoneGlue = [KeystoneGlue defaultKeystoneGlue]; |
175 if (!keystoneGlue || [keystoneGlue isOnReadOnlyFilesystem]) { | 175 if (!keystoneGlue || [keystoneGlue isOnReadOnlyFilesystem]) { |
176 return; | 176 return; |
177 } | 177 } |
178 | 178 |
179 // Stay alive as long as needed. This is balanced by a release in | 179 // Stay alive as long as needed. This is balanced by a release in |
180 // -updateStatus:. | 180 // -updateStatus:. |
181 [self retain]; | 181 [self retain]; |
182 | 182 |
183 AutoupdateStatus recentStatus = [keystoneGlue recentStatus]; | 183 keystone_glue::AutoupdateStatus recentStatus = [keystoneGlue recentStatus]; |
184 if (recentStatus == kAutoupdateNone || | 184 if (recentStatus == keystone_glue::kAutoupdateNone || |
185 recentStatus == kAutoupdateRegistering) { | 185 recentStatus == keystone_glue::kAutoupdateRegistering) { |
186 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | 186 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; |
187 [center addObserver:self | 187 [center addObserver:self |
188 selector:@selector(updateStatus:) | 188 selector:@selector(updateStatus:) |
189 name:kAutoupdateStatusNotification | 189 name:kAutoupdateStatusNotification |
190 object:nil]; | 190 object:nil]; |
191 } else { | 191 } else { |
192 [self updateStatus:[keystoneGlue recentNotification]]; | 192 [self updateStatus:[keystoneGlue recentNotification]]; |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 - (void)updateStatus:(NSNotification*)notification { | 196 - (void)updateStatus:(NSNotification*)notification { |
197 NSDictionary* dictionary = [notification userInfo]; | 197 NSDictionary* dictionary = [notification userInfo]; |
198 AutoupdateStatus status = static_cast<AutoupdateStatus>( | 198 keystone_glue::AutoupdateStatus status = |
199 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); | 199 static_cast<keystone_glue::AutoupdateStatus>( |
| 200 [[dictionary objectForKey:kAutoupdateStatusStatus] intValue]); |
200 | 201 |
201 if (status == kAutoupdateNone || status == kAutoupdateRegistering) { | 202 if (status == keystone_glue::kAutoupdateNone || |
| 203 status == keystone_glue::kAutoupdateRegistering) { |
202 return; | 204 return; |
203 } | 205 } |
204 | 206 |
205 [self removeObserver]; | 207 [self removeObserver]; |
206 | 208 |
207 if (status != kAutoupdateRegisterFailed && | 209 if (status != keystone_glue::kAutoupdateRegisterFailed && |
208 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { | 210 [[KeystoneGlue defaultKeystoneGlue] needsPromotion]) { |
209 KeystonePromotionInfoBarDelegate::Create(); | 211 KeystonePromotionInfoBarDelegate::Create(); |
210 } | 212 } |
211 | 213 |
212 [self release]; | 214 [self release]; |
213 } | 215 } |
214 | 216 |
215 - (void)removeObserver { | 217 - (void)removeObserver { |
216 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 218 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
217 } | 219 } |
218 | 220 |
219 @end // @implementation KeystonePromotionInfoBar | 221 @end // @implementation KeystonePromotionInfoBar |
220 | 222 |
221 // static | 223 // static |
222 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { | 224 void KeystoneInfoBar::PromotionInfoBar(Profile* profile) { |
223 KeystonePromotionInfoBar* promotionInfoBar = | 225 KeystonePromotionInfoBar* promotionInfoBar = |
224 [[[KeystonePromotionInfoBar alloc] init] autorelease]; | 226 [[[KeystonePromotionInfoBar alloc] init] autorelease]; |
225 | 227 |
226 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; | 228 [promotionInfoBar checkAndShowInfoBarForProfile:profile]; |
227 } | 229 } |
OLD | NEW |