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