| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/notifications/extension_welcome_notification.h" | 5 #include "chrome/browser/notifications/extension_welcome_notification.h" |
| 6 | 6 |
| 7 #include "base/guid.h" | 7 #include "base/guid.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 } | 301 } |
| 302 | 302 |
| 303 void ExtensionWelcomeNotification::StartExpirationTimer() { | 303 void ExtensionWelcomeNotification::StartExpirationTimer() { |
| 304 if (!expiration_timer_ && !IsWelcomeNotificationExpired()) { | 304 if (!expiration_timer_ && !IsWelcomeNotificationExpired()) { |
| 305 base::Time expiration_timestamp = GetExpirationTimestamp(); | 305 base::Time expiration_timestamp = GetExpirationTimestamp(); |
| 306 if (expiration_timestamp.is_null()) { | 306 if (expiration_timestamp.is_null()) { |
| 307 SetExpirationTimestampFromNow(); | 307 SetExpirationTimestampFromNow(); |
| 308 expiration_timestamp = GetExpirationTimestamp(); | 308 expiration_timestamp = GetExpirationTimestamp(); |
| 309 DCHECK(!expiration_timestamp.is_null()); | 309 DCHECK(!expiration_timestamp.is_null()); |
| 310 } | 310 } |
| 311 expiration_timer_.reset( | 311 expiration_timer_.reset(new base::OneShotTimer()); |
| 312 new base::OneShotTimer<ExtensionWelcomeNotification>()); | |
| 313 expiration_timer_->Start( | 312 expiration_timer_->Start( |
| 314 FROM_HERE, | 313 FROM_HERE, |
| 315 expiration_timestamp - delegate_->GetCurrentTime(), | 314 expiration_timestamp - delegate_->GetCurrentTime(), |
| 316 this, | 315 this, |
| 317 &ExtensionWelcomeNotification::ExpireWelcomeNotification); | 316 &ExtensionWelcomeNotification::ExpireWelcomeNotification); |
| 318 } | 317 } |
| 319 } | 318 } |
| 320 | 319 |
| 321 void ExtensionWelcomeNotification::StopExpirationTimer() { | 320 void ExtensionWelcomeNotification::StopExpirationTimer() { |
| 322 if (expiration_timer_) { | 321 if (expiration_timer_) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 347 prefs::kWelcomeNotificationExpirationTimestamp, | 346 prefs::kWelcomeNotificationExpirationTimestamp, |
| 348 (delegate_->GetCurrentTime() + | 347 (delegate_->GetCurrentTime() + |
| 349 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); | 348 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); |
| 350 } | 349 } |
| 351 | 350 |
| 352 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { | 351 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { |
| 353 const base::Time expiration_timestamp = GetExpirationTimestamp(); | 352 const base::Time expiration_timestamp = GetExpirationTimestamp(); |
| 354 return !expiration_timestamp.is_null() && | 353 return !expiration_timestamp.is_null() && |
| 355 (expiration_timestamp <= delegate_->GetCurrentTime()); | 354 (expiration_timestamp <= delegate_->GetCurrentTime()); |
| 356 } | 355 } |
| OLD | NEW |