Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h

Issue 811033002: Add device policy to disallow shutdown - ash UI modifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reduced scope of CL (ash only now, removed webui changes) Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 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_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
7
8 #include "base/callback_forward.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/settings/cros_settings.h"
13
14 namespace chromeos {
15
16 // This class observes the device setting |DeviceRebootOnShutdown|. Changes to
17 // this policy are communicated to the ShutdownPolicyObserver::Delegate by
18 // calling its OnShutdownPolicyChanged method with the new state of the policy.
19 class ShutdownPolicyObserver {
20 public:
21 // This callback is passed to CheckIfRebootOnShutdown, which invokes it with
22 // the current state of the |DeviceRebootOnShutdown| policy once a trusted of
23 // policies is established.
24 using RebootOnShutdownCallback = base::Callback<void(bool)>;
25
26 // This delegate is called when the |DeviceRebootOnShutdown| policy changes.
27 class Delegate {
28 public:
29 virtual void OnShutdownPolicyChanged(bool reboot_on_shutdown) = 0;
30
31 protected:
32 virtual ~Delegate() {}
33 };
34
35 ShutdownPolicyObserver(CrosSettings* cros_settings, Delegate* delegate);
36 ~ShutdownPolicyObserver();
37
38 // Once a trusted set of policies is established, this function calls
39 // |callback| with the trusted state of the |DeviceRebootOnShutdown| policy.
40 void CheckIfRebootOnShutdown(const RebootOnShutdownCallback& callback);
41
42 // Resets the policy subscription and clears the delegate.
43 void Shutdown();
44
45 private:
46 void CallDelegate(bool reboot_on_shutdown);
47
48 void OnShutdownPolicyChanged();
49
50 CrosSettings* cros_settings_;
51
52 Delegate* delegate_;
53
54 scoped_ptr<CrosSettings::ObserverSubscription> shutdown_policy_subscription_;
55
56 base::WeakPtrFactory<ShutdownPolicyObserver> weak_factory_;
57
58 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyObserver);
59 };
60
61 } // namespace chromeos
62
63 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698