| 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/macros.h" | 8 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 10 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 14 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 15 | 12 |
| 16 class Profile; | 13 class Profile; |
| 17 | 14 |
| 18 namespace policy { | 15 namespace policy { |
| 19 | 16 |
| 20 class ConsumerManagementStage; | 17 class ConsumerManagementStage; |
| 21 | 18 |
| 22 // ConsumerManagementNotifier observes ConsumerManagementService and shows | 19 // ConsumerManagementNotifier observes ConsumerManagementService and shows |
| 23 // a desktop notification to the device owner if consumer enrollment or | 20 // a desktop notification to the device owner if consumer enrollment or |
| 24 // unenrollment suceeds or fails. | 21 // unenrollment suceeds or fails. |
| 25 class ConsumerManagementNotifier | 22 class ConsumerManagementNotifier |
| 26 : public KeyedService, | 23 : public KeyedService, |
| 27 public ConsumerManagementService::Observer { | 24 public ConsumerManagementService::Observer { |
| 28 public: | 25 public: |
| 29 ConsumerManagementNotifier( | 26 ConsumerManagementNotifier( |
| 30 Profile* profile, | 27 Profile* profile, |
| 31 ConsumerManagementService* consumer_management_service); | 28 ConsumerManagementService* consumer_management_service); |
| 32 ~ConsumerManagementNotifier() override; | 29 ~ConsumerManagementNotifier() override; |
| 33 | 30 |
| 34 void Shutdown() override; | 31 void Shutdown() override; |
| 35 | 32 |
| 36 // ConsumerManagementService::Observer: | 33 // ConsumerManagementService::Observer: |
| 37 void OnConsumerManagementStatusChanged() override; | 34 void OnConsumerManagementStatusChanged() override; |
| 38 | 35 |
| 39 private: | 36 private: |
| 40 // Shows a notification based on |stage|. | |
| 41 void ShowNotification(const ConsumerManagementStage& stage); | |
| 42 | |
| 43 // Shows a desktop notification. | 37 // Shows a desktop notification. |
| 44 void ShowDesktopNotification( | 38 void ShowDesktopNotification(const ConsumerManagementStage& stage); |
| 45 const std::string& notification_id, | |
| 46 const std::string& notification_url, | |
| 47 int title_message_id, | |
| 48 int body_message_id, | |
| 49 int button_label_message_id, | |
| 50 const base::Closure& button_click_callback); | |
| 51 | 39 |
| 52 // Opens the settings page. | 40 // Opens the settings page. |
| 53 void OpenSettingsPage() const; | 41 void OpenSettingsPage() const; |
| 54 | 42 |
| 55 // Opens the enrollment/unenrollment confirmation dialog in the settings page. | 43 // Opens the enrollment confirmation dialog in the settings page. |
| 56 void TryAgain() const; | 44 void TryEnrollmentAgain() const; |
| 57 | 45 |
| 58 Profile* profile_; | 46 Profile* profile_; |
| 59 ConsumerManagementService* consumer_management_service_; | 47 ConsumerManagementService* consumer_management_service_; |
| 60 | 48 |
| 61 base::WeakPtrFactory<ConsumerManagementNotifier> weak_ptr_factory_; | 49 base::WeakPtrFactory<ConsumerManagementNotifier> weak_ptr_factory_; |
| 62 | 50 |
| 63 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementNotifier); | 51 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementNotifier); |
| 64 }; | 52 }; |
| 65 | 53 |
| 66 } // namespace policy | 54 } // namespace policy |
| 67 | 55 |
| 68 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ | 56 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_ |
| OLD | NEW |