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 #import "ios/chrome/browser/upgrade/upgrade_center.h" | 5 #import "ios/chrome/browser/upgrade/upgrade_center.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/mac/bundle_locations.h" | 11 #include "base/mac/bundle_locations.h" |
12 #include "base/mac/scoped_nsobject.h" | |
13 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
14 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
15 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
16 #include "base/version.h" | 15 #include "base/version.h" |
17 #include "components/infobars/core/confirm_infobar_delegate.h" | 16 #include "components/infobars/core/confirm_infobar_delegate.h" |
18 #include "components/infobars/core/infobar.h" | 17 #include "components/infobars/core/infobar.h" |
19 #include "components/infobars/core/infobar_manager.h" | 18 #include "components/infobars/core/infobar_manager.h" |
20 #include "components/version_info/version_info.h" | 19 #include "components/version_info/version_info.h" |
21 #import "ios/chrome/browser/open_url_util.h" | 20 #import "ios/chrome/browser/open_url_util.h" |
22 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 21 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
23 #import "ios/chrome/browser/ui/commands/open_url_command.h" | 22 #import "ios/chrome/browser/ui/commands/open_url_command.h" |
24 #include "ios/chrome/grit/ios_chromium_strings.h" | 23 #include "ios/chrome/grit/ios_chromium_strings.h" |
25 #include "ios/chrome/grit/ios_strings.h" | 24 #include "ios/chrome/grit/ios_strings.h" |
26 #import "ios/web/public/url_scheme_util.h" | 25 #import "ios/web/public/url_scheme_util.h" |
27 #import "net/base/mac/url_conversions.h" | 26 #import "net/base/mac/url_conversions.h" |
28 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
29 #include "ui/gfx/image/image.h" | 28 #include "ui/gfx/image/image.h" |
30 #include "url/gurl.h" | 29 #include "url/gurl.h" |
31 | 30 |
31 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
32 #error "This file requires ARC support." | |
33 #endif | |
34 | |
32 @interface UpgradeCenter () | 35 @interface UpgradeCenter () |
33 // Creates infobars on all tabs. | 36 // Creates infobars on all tabs. |
34 - (void)showUpgradeInfoBars; | 37 - (void)showUpgradeInfoBars; |
35 // Removes all the infobars. | 38 // Removes all the infobars. |
36 - (void)hideUpgradeInfoBars; | 39 - (void)hideUpgradeInfoBars; |
37 // Callback when an infobar is closed, for any reason. Perform upgrade is set to | 40 // Callback when an infobar is closed, for any reason. Perform upgrade is set to |
38 // YES if the user choose to upgrade. | 41 // YES if the user choose to upgrade. |
39 - (void)dismissedInfoBar:(NSString*)tabId performUpgrade:(BOOL)shouldUpgrade; | 42 - (void)dismissedInfoBar:(NSString*)tabId performUpgrade:(BOOL)shouldUpgrade; |
40 // Returns YES if the infobar should be shown. | 43 // Returns YES if the infobar should be shown. |
41 - (BOOL)shouldShowInfoBar; | 44 - (BOOL)shouldShowInfoBar; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 | 137 |
135 ~UpgradeInfoBarDismissObserver() override {} | 138 ~UpgradeInfoBarDismissObserver() override {} |
136 | 139 |
137 void RegisterObserver(infobars::InfoBarManager* infobar_manager, | 140 void RegisterObserver(infobars::InfoBarManager* infobar_manager, |
138 UpgradeInfoBarDelegate* infobar_delegate, | 141 UpgradeInfoBarDelegate* infobar_delegate, |
139 NSString* tab_id, | 142 NSString* tab_id, |
140 UpgradeCenter* dismiss_delegate) { | 143 UpgradeCenter* dismiss_delegate) { |
141 scoped_observer_.Add(infobar_manager); | 144 scoped_observer_.Add(infobar_manager); |
142 infobar_delegate_ = infobar_delegate; | 145 infobar_delegate_ = infobar_delegate; |
143 dismiss_delegate_ = dismiss_delegate; | 146 dismiss_delegate_ = dismiss_delegate; |
144 tab_id_.reset([tab_id copy]); | 147 tab_id_ = [tab_id copy]; |
145 } | 148 } |
146 | 149 |
147 UpgradeInfoBarDelegate* infobar_delegate() { return infobar_delegate_; } | 150 UpgradeInfoBarDelegate* infobar_delegate() { return infobar_delegate_; } |
148 | 151 |
149 private: | 152 private: |
150 // infobars::InfoBarManager::Observer implementation. | 153 // infobars::InfoBarManager::Observer implementation. |
151 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override { | 154 void OnInfoBarRemoved(infobars::InfoBar* infobar, bool animate) override { |
152 if (infobar->delegate() == infobar_delegate_) { | 155 if (infobar->delegate() == infobar_delegate_) { |
153 [dismiss_delegate_ dismissedInfoBar:tab_id_.get() | 156 [dismiss_delegate_ dismissedInfoBar:tab_id_ |
154 performUpgrade:infobar_delegate_->AcceptPressed()]; | 157 performUpgrade:infobar_delegate_->AcceptPressed()]; |
155 } | 158 } |
156 } | 159 } |
157 | 160 |
158 void OnManagerShuttingDown( | 161 void OnManagerShuttingDown( |
159 infobars::InfoBarManager* infobar_manager) override { | 162 infobars::InfoBarManager* infobar_manager) override { |
160 scoped_observer_.Remove(infobar_manager); | 163 scoped_observer_.Remove(infobar_manager); |
161 } | 164 } |
162 | 165 |
163 UpgradeInfoBarDelegate* infobar_delegate_; | 166 UpgradeInfoBarDelegate* infobar_delegate_; |
164 UpgradeCenter* dismiss_delegate_; | 167 __weak UpgradeCenter* dismiss_delegate_; |
165 base::scoped_nsobject<NSString> tab_id_; | 168 NSString* tab_id_; |
sdefresne
2017/06/15 16:34:30
nit: __strong NSString* tab_id_;
liaoyuke
2017/06/15 19:08:48
Done.
| |
166 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> | 169 ScopedObserver<infobars::InfoBarManager, infobars::InfoBarManager::Observer> |
167 scoped_observer_; | 170 scoped_observer_; |
168 | 171 |
169 DISALLOW_COPY_AND_ASSIGN(UpgradeInfoBarDismissObserver); | 172 DISALLOW_COPY_AND_ASSIGN(UpgradeInfoBarDismissObserver); |
170 }; | 173 }; |
171 | 174 |
172 } // namespace | 175 } // namespace |
173 | 176 |
174 // The delegateHolder is a simple wrapper to be able to store all the | 177 // The delegateHolder is a simple wrapper to be able to store all the |
175 // infoBarDelegate related information in an object that can be put in | 178 // infoBarDelegate related information in an object that can be put in |
(...skipping 27 matching lines...) Expand all Loading... | |
203 - (UpgradeInfoBarDelegate*)infoBarDelegate { | 206 - (UpgradeInfoBarDelegate*)infoBarDelegate { |
204 return observer_.infobar_delegate(); | 207 return observer_.infobar_delegate(); |
205 } | 208 } |
206 | 209 |
207 @end | 210 @end |
208 | 211 |
209 @implementation UpgradeCenter { | 212 @implementation UpgradeCenter { |
210 // YES if the infobars are currently visible. | 213 // YES if the infobars are currently visible. |
211 BOOL upgradeInfoBarIsVisible_; | 214 BOOL upgradeInfoBarIsVisible_; |
212 // Used to store the visible upgrade infobars, indexed by tabId. | 215 // Used to store the visible upgrade infobars, indexed by tabId. |
213 base::scoped_nsobject<NSMutableDictionary> upgradeInfoBarDelegates_; | 216 NSMutableDictionary<NSString*, DelegateHolder*>* upgradeInfoBarDelegates_; |
sdefresne
2017/06/15 16:34:30
nit: __strong NSMutableDictionary<NSString*, Deleg
liaoyuke
2017/06/15 19:08:47
Done.
| |
214 // Stores the clients of the upgrade center. These objectiveC objects are not | 217 // Stores the clients of the upgrade center. These objectiveC objects are not |
215 // retained. | 218 // retained. |
216 std::set<id<UpgradeCenterClientProtocol>> clients_; | 219 NSHashTable<id<UpgradeCenterClientProtocol>>* clients_; |
sdefresne
2017/06/15 16:34:30
nit: __strong NSHashTable<id<UpgradeCenterClientPr
liaoyuke
2017/06/15 19:08:47
Done.
| |
217 #ifndef NDEBUG | 220 #ifndef NDEBUG |
218 bool inCallback_; | 221 BOOL inCallback_; |
219 #endif | 222 #endif |
220 } | 223 } |
221 | 224 |
222 + (UpgradeCenter*)sharedInstance { | 225 + (UpgradeCenter*)sharedInstance { |
223 static UpgradeCenter* obj; | 226 static UpgradeCenter* obj; |
224 static dispatch_once_t onceToken; | 227 static dispatch_once_t onceToken; |
225 dispatch_once(&onceToken, ^{ | 228 dispatch_once(&onceToken, ^{ |
226 obj = [[self alloc] init]; | 229 obj = [[self alloc] init]; |
227 }); | 230 }); |
228 return obj; | 231 return obj; |
229 } | 232 } |
230 | 233 |
231 - (instancetype)init { | 234 - (instancetype)init { |
232 self = [super init]; | 235 self = [super init]; |
233 if (self) { | 236 if (self) { |
234 upgradeInfoBarDelegates_.reset([[NSMutableDictionary alloc] init]); | 237 upgradeInfoBarDelegates_ = [[NSMutableDictionary alloc] init]; |
235 | 238 |
236 // There is no dealloc and no unregister as this class is a never | 239 // There is no dealloc and no unregister as this class is a never |
237 // deallocated singleton. | 240 // deallocated singleton. |
238 [[NSNotificationCenter defaultCenter] | 241 [[NSNotificationCenter defaultCenter] |
239 addObserver:self | 242 addObserver:self |
240 selector:@selector(applicationWillEnterForeground:) | 243 selector:@selector(applicationWillEnterForeground:) |
241 name:UIApplicationWillEnterForegroundNotification | 244 name:UIApplicationWillEnterForegroundNotification |
242 object:nil]; | 245 object:nil]; |
243 | 246 |
244 upgradeInfoBarIsVisible_ = [self shouldShowInfoBar]; | 247 upgradeInfoBarIsVisible_ = [self shouldShowInfoBar]; |
248 clients_ = [NSHashTable weakObjectsHashTable]; | |
245 } | 249 } |
246 return self; | 250 return self; |
247 } | 251 } |
248 | 252 |
249 - (BOOL)shouldShowInfoBar { | 253 - (BOOL)shouldShowInfoBar { |
250 return [self isCurrentVersionObsolete] && ![self infoBarShownRecently]; | 254 return [self isCurrentVersionObsolete] && ![self infoBarShownRecently]; |
251 } | 255 } |
252 | 256 |
253 - (BOOL)isCurrentVersionObsolete { | 257 - (BOOL)isCurrentVersionObsolete { |
254 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 258 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
(...skipping 22 matching lines...) Expand all Loading... | |
277 if (upgradeInfoBarIsVisible_) | 281 if (upgradeInfoBarIsVisible_) |
278 return; | 282 return; |
279 | 283 |
280 // When returning to active if the upgrade notification has been dismissed, | 284 // When returning to active if the upgrade notification has been dismissed, |
281 // bring it back. | 285 // bring it back. |
282 if ([self shouldShowInfoBar]) | 286 if ([self shouldShowInfoBar]) |
283 [self showUpgradeInfoBars]; | 287 [self showUpgradeInfoBars]; |
284 } | 288 } |
285 | 289 |
286 - (void)registerClient:(id<UpgradeCenterClientProtocol>)client { | 290 - (void)registerClient:(id<UpgradeCenterClientProtocol>)client { |
287 clients_.insert(client); | 291 [clients_ addObject:client]; |
288 if (upgradeInfoBarIsVisible_) | 292 if (upgradeInfoBarIsVisible_) |
289 [client showUpgrade:self]; | 293 [client showUpgrade:self]; |
290 } | 294 } |
291 | 295 |
292 - (void)unregisterClient:(id<UpgradeCenterClientProtocol>)client { | 296 - (void)unregisterClient:(id<UpgradeCenterClientProtocol>)client { |
293 #ifndef NDEBUG | 297 #ifndef NDEBUG |
294 DCHECK(!inCallback_); | 298 DCHECK(!inCallback_); |
295 #endif | 299 #endif |
296 clients_.erase(client); | 300 [clients_ removeObject:client]; |
297 } | 301 } |
298 | 302 |
299 - (void)addInfoBarToManager:(infobars::InfoBarManager*)infoBarManager | 303 - (void)addInfoBarToManager:(infobars::InfoBarManager*)infoBarManager |
300 forTabId:(NSString*)tabId { | 304 forTabId:(NSString*)tabId { |
301 DCHECK(tabId); | 305 DCHECK(tabId); |
302 DCHECK(infoBarManager); | 306 DCHECK(infoBarManager); |
303 | 307 |
304 // Nothing to do if the infobar are not visible at this point in time. | 308 // Nothing to do if the infobar are not visible at this point in time. |
305 if (!upgradeInfoBarIsVisible_) | 309 if (!upgradeInfoBarIsVisible_) |
306 return; | 310 return; |
307 | 311 |
308 // Nothing to do if the infobar is already there. | 312 // Nothing to do if the infobar is already there. |
309 if ([upgradeInfoBarDelegates_ objectForKey:tabId]) | 313 if ([upgradeInfoBarDelegates_ objectForKey:tabId]) |
310 return; | 314 return; |
311 | 315 |
312 auto infobarDelegate = base::MakeUnique<UpgradeInfoBarDelegate>(); | 316 auto infobarDelegate = base::MakeUnique<UpgradeInfoBarDelegate>(); |
313 base::scoped_nsobject<DelegateHolder> delegateHolder([[DelegateHolder alloc] | 317 DelegateHolder* delegateHolder = |
314 initWithInfoBarManager:infoBarManager | 318 [[DelegateHolder alloc] initWithInfoBarManager:infoBarManager |
315 infoBarDelegate:infobarDelegate.get() | 319 infoBarDelegate:infobarDelegate.get() |
316 upgradeCenter:self | 320 upgradeCenter:self |
317 tabId:tabId]); | 321 tabId:tabId]; |
318 | 322 |
319 [upgradeInfoBarDelegates_ setObject:delegateHolder forKey:tabId]; | 323 [upgradeInfoBarDelegates_ setObject:delegateHolder forKey:tabId]; |
320 infoBarManager->AddInfoBar( | 324 infoBarManager->AddInfoBar( |
321 infoBarManager->CreateConfirmInfoBar(std::move(infobarDelegate))); | 325 infoBarManager->CreateConfirmInfoBar(std::move(infobarDelegate))); |
322 } | 326 } |
323 | 327 |
324 - (void)tabWillClose:(NSString*)tabId { | 328 - (void)tabWillClose:(NSString*)tabId { |
325 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; | 329 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; |
326 } | 330 } |
327 | 331 |
328 - (void)dismissedInfoBar:(NSString*)tabId performUpgrade:(BOOL)shouldUpgrade { | 332 - (void)dismissedInfoBar:(NSString*)tabId performUpgrade:(BOOL)shouldUpgrade { |
329 // If the tabId is not in the upgradeInfoBarDelegates_ just ignore the | 333 // If the tabId is not in the upgradeInfoBarDelegates_ just ignore the |
330 // notification. In all likelyhood it was trigerred by calling | 334 // notification. In all likelyhood it was trigerred by calling |
331 // -hideUpgradeInfoBars. Or because a tab was closed without dismissing the | 335 // -hideUpgradeInfoBars. Or because a tab was closed without dismissing the |
332 // infobar. | 336 // infobar. |
333 base::scoped_nsobject<DelegateHolder> delegateHolder( | 337 DelegateHolder* delegateHolder = |
334 [[upgradeInfoBarDelegates_ objectForKey:tabId] retain]); | 338 [upgradeInfoBarDelegates_ objectForKey:tabId]; |
335 if (!delegateHolder.get()) | 339 if (!delegateHolder) |
336 return; | 340 return; |
337 | 341 |
338 // Forget about this dismissed infobar. | 342 // Forget about this dismissed infobar. |
339 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; | 343 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; |
340 | 344 |
341 // Get rid of all the infobars on the other tabs. | 345 // Get rid of all the infobars on the other tabs. |
342 [self hideUpgradeInfoBars]; | 346 [self hideUpgradeInfoBars]; |
343 | 347 |
344 if (shouldUpgrade) { | 348 if (shouldUpgrade) { |
345 NSString* urlString = | 349 NSString* urlString = |
346 [[NSUserDefaults standardUserDefaults] valueForKey:kUpgradeURLKey]; | 350 [[NSUserDefaults standardUserDefaults] valueForKey:kUpgradeURLKey]; |
347 if (!urlString) | 351 if (!urlString) |
348 return; // Missing URL, no upgrade possible. | 352 return; // Missing URL, no upgrade possible. |
349 | 353 |
350 GURL url = GURL(base::SysNSStringToUTF8(urlString)); | 354 GURL url = GURL(base::SysNSStringToUTF8(urlString)); |
351 if (!url.is_valid()) | 355 if (!url.is_valid()) |
352 return; | 356 return; |
353 | 357 |
354 if (web::UrlHasWebScheme(url)) { | 358 if (web::UrlHasWebScheme(url)) { |
355 // This URL can be opened in the application, just open in a new tab. | 359 // This URL can be opened in the application, just open in a new tab. |
356 base::scoped_nsobject<OpenUrlCommand> command( | 360 OpenUrlCommand* command = |
357 [[OpenUrlCommand alloc] initWithURLFromChrome:url]); | 361 [[OpenUrlCommand alloc] initWithURLFromChrome:url]; |
358 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; | 362 UIWindow* main_window = [[UIApplication sharedApplication] keyWindow]; |
359 DCHECK(main_window); | 363 DCHECK(main_window); |
360 [main_window chromeExecuteCommand:command]; | 364 [main_window chromeExecuteCommand:command]; |
361 } else { | 365 } else { |
362 // This URL scheme is not understood, ask the system to open it. | 366 // This URL scheme is not understood, ask the system to open it. |
363 NSURL* nsurl = [NSURL URLWithString:urlString]; | 367 NSURL* nsurl = [NSURL URLWithString:urlString]; |
364 if (nsurl) { | 368 if (nsurl) { |
365 OpenUrlWithCompletionHandler(nsurl, nil); | 369 OpenUrlWithCompletionHandler(nsurl, nil); |
366 } | 370 } |
367 } | 371 } |
368 } | 372 } |
369 } | 373 } |
370 | 374 |
371 - (void)showUpgradeInfoBars { | 375 - (void)showUpgradeInfoBars { |
372 // Add an infobar on all the open tabs. | 376 // Add an infobar on all the open tabs. |
373 #ifndef NDEBUG | 377 #ifndef NDEBUG |
374 inCallback_ = YES; | 378 inCallback_ = YES; |
375 #endif | 379 #endif |
376 upgradeInfoBarIsVisible_ = YES; | 380 upgradeInfoBarIsVisible_ = YES; |
377 std::set<id<UpgradeCenterClientProtocol>>::iterator it; | 381 NSEnumerator* enumerator = [clients_ objectEnumerator]; |
sdefresne
2017/06/15 16:34:30
NSHashTable supports NSFastEnumeration, so you can
liaoyuke
2017/06/15 19:08:48
Done.
| |
378 for (it = clients_.begin(); it != clients_.end(); ++it) | 382 while (id value = [enumerator nextObject]) |
379 [*it showUpgrade:self]; | 383 [value showUpgrade:self]; |
380 #ifndef NDEBUG | 384 #ifndef NDEBUG |
381 inCallback_ = NO; | 385 inCallback_ = NO; |
382 #endif | 386 #endif |
383 | 387 |
384 [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] | 388 [[NSUserDefaults standardUserDefaults] setObject:[NSDate date] |
385 forKey:kLastInfobarDisplayTimeKey]; | 389 forKey:kLastInfobarDisplayTimeKey]; |
386 } | 390 } |
387 | 391 |
388 - (void)hideUpgradeInfoBars { | 392 - (void)hideUpgradeInfoBars { |
389 upgradeInfoBarIsVisible_ = NO; | 393 upgradeInfoBarIsVisible_ = NO; |
390 // It is important to call -allKeys here and not using a fast iteration on the | 394 // It is important to call -allKeys here and not using a fast iteration on the |
391 // dictionary directly: the dictionary is modified as we go... | 395 // dictionary directly: the dictionary is modified as we go... |
392 for (NSString* tabId in [upgradeInfoBarDelegates_ allKeys]) { | 396 for (NSString* tabId in [upgradeInfoBarDelegates_ allKeys]) { |
393 // It is important to retain the delegateHolder as otherwise it is | 397 // It is important to retain the delegateHolder as otherwise it is |
394 // deallocated as soon as it is removed from the dictionary. | 398 // deallocated as soon as it is removed from the dictionary. |
395 base::scoped_nsobject<DelegateHolder> delegateHolder( | 399 DelegateHolder* delegateHolder = |
396 [[upgradeInfoBarDelegates_ objectForKey:tabId] retain]); | 400 [upgradeInfoBarDelegates_ objectForKey:tabId]; |
397 if (delegateHolder.get()) { | 401 if (delegateHolder) { |
398 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; | 402 [upgradeInfoBarDelegates_ removeObjectForKey:tabId]; |
399 UpgradeInfoBarDelegate* delegate = [delegateHolder infoBarDelegate]; | 403 UpgradeInfoBarDelegate* delegate = [delegateHolder infoBarDelegate]; |
400 DCHECK(delegate); | 404 DCHECK(delegate); |
401 delegate->RemoveSelf(); | 405 delegate->RemoveSelf(); |
402 } | 406 } |
403 } | 407 } |
404 } | 408 } |
405 | 409 |
406 - (void)upgradeNotificationDidOccur:(const UpgradeRecommendedDetails&)details { | 410 - (void)upgradeNotificationDidOccur:(const UpgradeRecommendedDetails&)details { |
407 const GURL& upgradeUrl = details.upgrade_url; | 411 const GURL& upgradeUrl = details.upgrade_url; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 if ([self shouldShowInfoBar]) | 443 if ([self shouldShowInfoBar]) |
440 [self showUpgradeInfoBars]; | 444 [self showUpgradeInfoBars]; |
441 } | 445 } |
442 | 446 |
443 - (void)resetForTests { | 447 - (void)resetForTests { |
444 [[UpgradeCenter sharedInstance] hideUpgradeInfoBars]; | 448 [[UpgradeCenter sharedInstance] hideUpgradeInfoBars]; |
445 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; | 449 NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; |
446 [defaults removeObjectForKey:kNextVersionKey]; | 450 [defaults removeObjectForKey:kNextVersionKey]; |
447 [defaults removeObjectForKey:kUpgradeURLKey]; | 451 [defaults removeObjectForKey:kUpgradeURLKey]; |
448 [defaults removeObjectForKey:kLastInfobarDisplayTimeKey]; | 452 [defaults removeObjectForKey:kLastInfobarDisplayTimeKey]; |
449 clients_.clear(); | 453 [clients_ removeAllObjects]; |
450 } | 454 } |
451 | 455 |
452 - (void)setLastDisplayToPast { | 456 - (void)setLastDisplayToPast { |
453 NSDate* pastDate = | 457 NSDate* pastDate = |
454 [NSDate dateWithTimeIntervalSinceNow:-(kInfobarDisplayInterval + 1)]; | 458 [NSDate dateWithTimeIntervalSinceNow:-(kInfobarDisplayInterval + 1)]; |
455 [[NSUserDefaults standardUserDefaults] setObject:pastDate | 459 [[NSUserDefaults standardUserDefaults] setObject:pastDate |
456 forKey:kLastInfobarDisplayTimeKey]; | 460 forKey:kLastInfobarDisplayTimeKey]; |
457 } | 461 } |
458 | 462 |
459 @end | 463 @end |
OLD | NEW |