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_
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"
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
{
29 ConsumerManagementNotifier(
31 ConsumerManagementService
* consumer_management_service
);
32 ~ConsumerManagementNotifier() override
;
34 void Shutdown() override
;
36 // ConsumerManagementService::Observer:
37 void OnConsumerManagementStatusChanged() override
;
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
,
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;
59 ConsumerManagementService
* consumer_management_service_
;
61 base::WeakPtrFactory
<ConsumerManagementNotifier
> weak_ptr_factory_
;
63 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementNotifier
);
68 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_NOTIFIER_H_