OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 #ifndef CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "chrome/browser/notifications/notification.h" | 11 #include "chrome/browser/notifications/notification.h" |
11 #include "chrome/browser/notifications/notification_delegate.h" | 12 #include "chrome/browser/notifications/notification_delegate.h" |
12 #include "chromeos/network/portal_detector/network_portal_detector.h" | 13 #include "chromeos/network/portal_detector/network_portal_detector.h" |
13 | 14 |
14 class Profile; | 15 class Profile; |
15 class NetworkState; | 16 class NetworkState; |
16 | 17 |
17 namespace chromeos { | 18 namespace chromeos { |
18 | 19 |
19 // Happiness tracking survey (HaTS) notification controller is responsible for | 20 // Happiness tracking survey (HaTS) notification controller is responsible for |
20 // managing the HaTS notification that is displayed to the user. | 21 // managing the HaTS notification that is displayed to the user. |
21 class HatsNotificationController : public NotificationDelegate, | 22 class HatsNotificationController : public NotificationDelegate, |
22 public NetworkPortalDetector::Observer { | 23 public NetworkPortalDetector::Observer { |
23 public: | 24 public: |
24 // Minimum amount of time before the notification is displayed again after a | 25 // Minimum amount of time before the notification is displayed again after a |
25 // user has interacted with it. | 26 // user has interacted with it. |
26 static const base::TimeDelta kHatsThresholdTime; | 27 static const int kHatsThresholdDays; |
| 28 // Minimum amount of time after initial login or oobe after which we can show |
| 29 // the HaTS notification. |
| 30 static const int kHatsNewDeviceThresholdDays; |
27 static const char kDelegateId[]; | 31 static const char kDelegateId[]; |
28 static const char kNotificationId[]; | 32 static const char kNotificationId[]; |
29 | 33 |
30 explicit HatsNotificationController(Profile* profile); | 34 explicit HatsNotificationController(Profile* profile); |
31 | 35 |
32 // Returns true if the survey needs to be displayed for the given |profile|. | 36 // Returns true if the survey needs to be displayed for the given |profile|. |
33 static bool ShouldShowSurveyToProfile(Profile* profile); | 37 static bool ShouldShowSurveyToProfile(Profile* profile); |
34 | 38 |
35 private: | 39 private: |
36 ~HatsNotificationController() override; | 40 ~HatsNotificationController() override; |
37 | 41 |
38 // NotificationDelegate overrides: | 42 // NotificationDelegate overrides: |
| 43 void Initialize(bool is_new_device); |
39 void ButtonClick(int button_index) override; | 44 void ButtonClick(int button_index) override; |
40 void Close(bool by_user) override; | 45 void Close(bool by_user) override; |
41 std::string id() const override; | 46 std::string id() const override; |
42 | 47 |
43 // NetworkPortalDetector::Observer override: | 48 // NetworkPortalDetector::Observer override: |
44 void OnPortalDetectionCompleted( | 49 void OnPortalDetectionCompleted( |
45 const NetworkState* network, | 50 const NetworkState* network, |
46 const NetworkPortalDetector::CaptivePortalState& state) override; | 51 const NetworkPortalDetector::CaptivePortalState& state) override; |
47 | 52 |
48 Notification* CreateNotification(); | 53 Notification* CreateNotification(); |
49 void UpdateLastInteractionTime(); | 54 void UpdateLastInteractionTime(); |
50 | 55 |
51 Profile* profile_; | 56 Profile* profile_; |
| 57 base::WeakPtrFactory<HatsNotificationController> weak_pointer_factory_; |
52 | 58 |
53 DISALLOW_COPY_AND_ASSIGN(HatsNotificationController); | 59 DISALLOW_COPY_AND_ASSIGN(HatsNotificationController); |
54 }; | 60 }; |
55 | 61 |
56 } // namespace chromeos | 62 } // namespace chromeos |
57 | 63 |
58 #endif // CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ | 64 #endif // CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ |
OLD | NEW |