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 30 matching lines...) Expand all Loading... |
41 const std::string& welcome_notification_id, | 41 const std::string& welcome_notification_id, |
42 ExtensionWelcomeNotification::Delegate* delegate) | 42 ExtensionWelcomeNotification::Delegate* delegate) |
43 : profile_(profile), | 43 : profile_(profile), |
44 notifier_id_(notifier_id.type, notifier_id.id), | 44 notifier_id_(notifier_id.type, notifier_id.id), |
45 welcome_notification_id_(welcome_notification_id), | 45 welcome_notification_id_(welcome_notification_id), |
46 delegate_(delegate) { | 46 delegate_(delegate) { |
47 } | 47 } |
48 | 48 |
49 // Overridden from NotificationDelegate: | 49 // Overridden from NotificationDelegate: |
50 void Display() override {} | 50 void Display() override {} |
51 void Error() override {} | |
52 | 51 |
53 void Close(bool by_user) override { | 52 void Close(bool by_user) override { |
54 if (by_user) { | 53 if (by_user) { |
55 // Setting the preference here may cause the notification erasing | 54 // Setting the preference here may cause the notification erasing |
56 // to reenter. Posting a task avoids this issue. | 55 // to reenter. Posting a task avoids this issue. |
57 delegate_->PostTask( | 56 delegate_->PostTask( |
58 FROM_HERE, | 57 FROM_HERE, |
59 base::Bind(&NotificationCallbacks::MarkAsDismissed, this)); | 58 base::Bind(&NotificationCallbacks::MarkAsDismissed, this)); |
60 } | 59 } |
61 } | 60 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 prefs::kWelcomeNotificationExpirationTimestamp, | 354 prefs::kWelcomeNotificationExpirationTimestamp, |
356 (delegate_->GetCurrentTime() + | 355 (delegate_->GetCurrentTime() + |
357 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); | 356 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); |
358 } | 357 } |
359 | 358 |
360 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { | 359 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { |
361 const base::Time expiration_timestamp = GetExpirationTimestamp(); | 360 const base::Time expiration_timestamp = GetExpirationTimestamp(); |
362 return !expiration_timestamp.is_null() && | 361 return !expiration_timestamp.is_null() && |
363 (expiration_timestamp <= delegate_->GetCurrentTime()); | 362 (expiration_timestamp <= delegate_->GetCurrentTime()); |
364 } | 363 } |
OLD | NEW |