Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / settings / shutdown_policy_handler.h
blob2104b9aa1f605cbf9a66f12c840e327f8c062d9b
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_SHUTDOWN_POLICY_HANDLER_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_SHUTDOWN_POLICY_HANDLER_H_
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"
14 namespace chromeos {
16 // This class observes the device setting |DeviceRebootOnShutdown|. Changes to
17 // this policy are communicated to the ShutdownPolicyHandler::Delegate by
18 // calling its OnShutdownPolicyChanged method with the new state of the policy.
19 class ShutdownPolicyHandler {
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)>;
26 // This delegate is called when the |DeviceRebootOnShutdown| policy changes.
27 class Delegate {
28 public:
29 virtual void OnShutdownPolicyChanged(bool reboot_on_shutdown) = 0;
31 protected:
32 virtual ~Delegate() {}
35 ShutdownPolicyHandler(CrosSettings* cros_settings, Delegate* delegate);
36 ~ShutdownPolicyHandler();
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);
42 // Resets the policy subscription and clears the delegate.
43 void Shutdown();
45 private:
46 void CallDelegate(bool reboot_on_shutdown);
48 void OnShutdownPolicyChanged();
50 CrosSettings* cros_settings_;
52 Delegate* delegate_;
54 scoped_ptr<CrosSettings::ObserverSubscription> shutdown_policy_subscription_;
56 base::WeakPtrFactory<ShutdownPolicyHandler> weak_factory_;
58 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyHandler);
61 } // namespace chromeos
63 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_SHUTDOWN_POLICY_HANDLER_H_