Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / consumer_management_notifier.h
blobe107b7f0cfcd5d0b38d47e2ee5ae1cc20605002b
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_
8 #include <string>
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"
16 class Profile;
18 namespace policy {
20 class ConsumerManagementStage;
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;
34 void Shutdown() override;
36 // ConsumerManagementService::Observer:
37 void OnConsumerManagementStatusChanged() override;
39 private:
40 // Shows a notification based on |stage|.
41 void ShowNotification(const ConsumerManagementStage& stage);
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);
52 // Opens the settings page.
53 void OpenSettingsPage() const;
55 // Opens the enrollment/unenrollment confirmation dialog in the settings page.
56 void TryAgain() const;
58 Profile* profile_;
59 ConsumerManagementService* consumer_management_service_;
61 base::WeakPtrFactory<ConsumerManagementNotifier> weak_ptr_factory_;
63 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementNotifier);
66 } // namespace policy
68 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_