| 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/memory/weak_ptr.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "chrome/browser/notifications/notification.h" | 11 #include "chrome/browser/notifications/notification.h" |
| 12 #include "chrome/browser/notifications/notification_delegate.h" | 12 #include "chrome/browser/notifications/notification_delegate.h" |
| 13 #include "chromeos/network/portal_detector/network_portal_detector.h" | 13 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 class NetworkState; | 17 class NetworkState; |
| 18 | 18 |
| 19 namespace gfx { | 19 namespace gfx { |
| 20 class Image; | 20 class Image; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace image_fetcher { | 23 namespace image_fetcher { |
| 24 class ImageFetcher; | 24 class ImageFetcher; |
| 25 struct RequestMetadata; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace chromeos { | 28 namespace chromeos { |
| 28 | 29 |
| 29 // Happiness tracking survey (HaTS) notification controller is responsible for | 30 // Happiness tracking survey (HaTS) notification controller is responsible for |
| 30 // managing the HaTS notification that is displayed to the user. | 31 // managing the HaTS notification that is displayed to the user. |
| 31 class HatsNotificationController : public NotificationDelegate, | 32 class HatsNotificationController : public NotificationDelegate, |
| 32 public NetworkPortalDetector::Observer { | 33 public NetworkPortalDetector::Observer { |
| 33 public: | 34 public: |
| 34 static const char kDelegateId[]; | 35 static const char kDelegateId[]; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 ~HatsNotificationController() override; | 62 ~HatsNotificationController() override; |
| 62 | 63 |
| 63 // NotificationDelegate overrides: | 64 // NotificationDelegate overrides: |
| 64 void Initialize(bool is_new_device); | 65 void Initialize(bool is_new_device); |
| 65 void ButtonClick(int button_index) override; | 66 void ButtonClick(int button_index) override; |
| 66 void Close(bool by_user) override; | 67 void Close(bool by_user) override; |
| 67 void Click() override; | 68 void Click() override; |
| 68 std::string id() const override; | 69 std::string id() const override; |
| 69 | 70 |
| 70 void OnImageFetched(const std::string& id, const gfx::Image& image); | 71 void OnImageFetched(const std::string& id, |
| 72 const gfx::Image& image, |
| 73 const image_fetcher::RequestMetadata& metadata); |
| 71 | 74 |
| 72 // NetworkPortalDetector::Observer override: | 75 // NetworkPortalDetector::Observer override: |
| 73 void OnPortalDetectionCompleted( | 76 void OnPortalDetectionCompleted( |
| 74 const NetworkState* network, | 77 const NetworkState* network, |
| 75 const NetworkPortalDetector::CaptivePortalState& state) override; | 78 const NetworkPortalDetector::CaptivePortalState& state) override; |
| 76 | 79 |
| 77 Notification* CreateNotification(); | 80 Notification* CreateNotification(); |
| 78 void UpdateLastInteractionTime(); | 81 void UpdateLastInteractionTime(); |
| 79 | 82 |
| 80 Profile* profile_; | 83 Profile* profile_; |
| 81 // A count of requests that have been completed so far. This includes requests | 84 // A count of requests that have been completed so far. This includes requests |
| 82 // that may have failed as well. | 85 // that may have failed as well. |
| 83 int completed_requests_; | 86 int completed_requests_; |
| 84 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; | 87 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; |
| 85 gfx::ImageSkia icon_; | 88 gfx::ImageSkia icon_; |
| 86 base::WeakPtrFactory<HatsNotificationController> weak_pointer_factory_; | 89 base::WeakPtrFactory<HatsNotificationController> weak_pointer_factory_; |
| 87 | 90 |
| 88 DISALLOW_COPY_AND_ASSIGN(HatsNotificationController); | 91 DISALLOW_COPY_AND_ASSIGN(HatsNotificationController); |
| 89 }; | 92 }; |
| 90 | 93 |
| 91 } // namespace chromeos | 94 } // namespace chromeos |
| 92 | 95 |
| 93 #endif // CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ | 96 #endif // CHROME_BROWSER_CHROMEOS_HATS_HATS_NOTIFICATION_CONTROLLER_H_ |
| OLD | NEW |