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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (pop_up_request == POP_UP_HIDDEN) | 282 if (pop_up_request == POP_UP_HIDDEN) |
283 message_center_notification->set_shown_as_popup(true); | 283 message_center_notification->set_shown_as_popup(true); |
284 | 284 |
285 GetMessageCenter()->AddNotification(message_center_notification.Pass()); | 285 GetMessageCenter()->AddNotification(message_center_notification.Pass()); |
286 StartExpirationTimer(); | 286 StartExpirationTimer(); |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
290 void ExtensionWelcomeNotification::HideWelcomeNotification() { | 290 void ExtensionWelcomeNotification::HideWelcomeNotification() { |
291 if (!welcome_notification_id_.empty() && | 291 if (!welcome_notification_id_.empty() && |
292 GetMessageCenter()->HasNotification(welcome_notification_id_)) { | 292 GetMessageCenter()->FindVisibleNotificationById( |
| 293 welcome_notification_id_) != NULL) { |
293 GetMessageCenter()->RemoveNotification(welcome_notification_id_, false); | 294 GetMessageCenter()->RemoveNotification(welcome_notification_id_, false); |
294 StopExpirationTimer(); | 295 StopExpirationTimer(); |
295 } | 296 } |
296 } | 297 } |
297 | 298 |
298 bool ExtensionWelcomeNotification::UserHasDismissedWelcomeNotification() const { | 299 bool ExtensionWelcomeNotification::UserHasDismissedWelcomeNotification() const { |
299 // This was previously a syncable preference; now it's per-machine. | 300 // This was previously a syncable preference; now it's per-machine. |
300 // Only the local pref will be written moving forward, but check for both so | 301 // Only the local pref will be written moving forward, but check for both so |
301 // users won't be double-toasted. | 302 // users won't be double-toasted. |
302 bool shown_synced = profile_->GetPrefs()->GetBoolean( | 303 bool shown_synced = profile_->GetPrefs()->GetBoolean( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 prefs::kWelcomeNotificationExpirationTimestamp, | 360 prefs::kWelcomeNotificationExpirationTimestamp, |
360 (delegate_->GetCurrentTime() + | 361 (delegate_->GetCurrentTime() + |
361 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); | 362 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); |
362 } | 363 } |
363 | 364 |
364 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { | 365 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { |
365 const base::Time expiration_timestamp = GetExpirationTimestamp(); | 366 const base::Time expiration_timestamp = GetExpirationTimestamp(); |
366 return !expiration_timestamp.is_null() && | 367 return !expiration_timestamp.is_null() && |
367 (expiration_timestamp <= delegate_->GetCurrentTime()); | 368 (expiration_timestamp <= delegate_->GetCurrentTime()); |
368 } | 369 } |
OLD | NEW |