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 29 matching lines...) Expand all Loading... |
40 const message_center::NotifierId notifier_id, | 40 const message_center::NotifierId notifier_id, |
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 {} | |
51 void Error() override {} | |
52 | |
53 void Close(bool by_user) override { | 50 void Close(bool by_user) override { |
54 if (by_user) { | 51 if (by_user) { |
55 // Setting the preference here may cause the notification erasing | 52 // Setting the preference here may cause the notification erasing |
56 // to reenter. Posting a task avoids this issue. | 53 // to reenter. Posting a task avoids this issue. |
57 delegate_->PostTask( | 54 delegate_->PostTask( |
58 FROM_HERE, | 55 FROM_HERE, |
59 base::Bind(&NotificationCallbacks::MarkAsDismissed, this)); | 56 base::Bind(&NotificationCallbacks::MarkAsDismissed, this)); |
60 } | 57 } |
61 } | 58 } |
62 | 59 |
63 void Click() override {} | |
64 void ButtonClick(int index) override { | 60 void ButtonClick(int index) override { |
65 if (index == 0) { | 61 if (index == 0) { |
66 OpenNotificationLearnMoreTab(); | 62 OpenNotificationLearnMoreTab(); |
67 } else if (index == 1) { | 63 } else if (index == 1) { |
68 DisableNotificationProvider(); | 64 DisableNotificationProvider(); |
69 Close(true); | 65 Close(true); |
70 } else { | 66 } else { |
71 NOTREACHED(); | 67 NOTREACHED(); |
72 } | 68 } |
73 } | 69 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 prefs::kWelcomeNotificationExpirationTimestamp, | 351 prefs::kWelcomeNotificationExpirationTimestamp, |
356 (delegate_->GetCurrentTime() + | 352 (delegate_->GetCurrentTime() + |
357 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); | 353 base::TimeDelta::FromDays(kRequestedShowTimeDays)).ToInternalValue()); |
358 } | 354 } |
359 | 355 |
360 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { | 356 bool ExtensionWelcomeNotification::IsWelcomeNotificationExpired() const { |
361 const base::Time expiration_timestamp = GetExpirationTimestamp(); | 357 const base::Time expiration_timestamp = GetExpirationTimestamp(); |
362 return !expiration_timestamp.is_null() && | 358 return !expiration_timestamp.is_null() && |
363 (expiration_timestamp <= delegate_->GetCurrentTime()); | 359 (expiration_timestamp <= delegate_->GetCurrentTime()); |
364 } | 360 } |
OLD | NEW |