Chromium Code Reviews| Index: chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h |
| diff --git a/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h b/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..266decd81075ae1e32d3832e8bc908ad4f3da139 |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/chromeos/login/shutdown_policy_observer.h |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_ |
| +#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/chromeos/settings/cros_settings.h" |
| + |
| +namespace chromeos { |
| + |
| +// This class observes the device setting "DeviceShutdownIsReboot". Changes to |
| +// this policy are communicated to the ShutdownPolicyObserver::Delegate by |
| +// calling its OnShutdownPolicyChanged method with the new state of the policy. |
| +class ShutdownPolicyObserver { |
| + public: |
| + using ShutdownIsRebootCallback = base::Callback<void(bool)>; |
|
bartfab (slow)
2014/12/08 16:49:45
Nit 1: #include "base/callback_forward.h"
Nit 2: D
cschuet (SLOW)
2014/12/08 18:57:04
Done.
|
| + |
| + // This delegate is called when the "DeviceShutdownIsReboot" policy changes. |
| + class Delegate { |
| + public: |
| + virtual void OnShutdownPolicyChanged(bool shutdown_allowed) = 0; |
|
bartfab (slow)
2014/12/08 16:49:45
s/shutdown_allowed/shutdown_is_reboot/
cschuet (SLOW)
2014/12/08 18:57:04
Done.
|
| + protected: |
|
bartfab (slow)
2014/12/08 16:49:45
Nit: Add a blank line above.
cschuet (SLOW)
2014/12/08 18:57:04
Done.
|
| + virtual ~Delegate() {} |
| + }; |
| + |
| + ShutdownPolicyObserver(CrosSettings* cros_settings, Delegate* delegate); |
| + ~ShutdownPolicyObserver(); |
| + |
| + void CheckIfShutdownIsReboot(const ShutdownIsRebootCallback& callback); |
|
bartfab (slow)
2014/12/08 16:49:45
Nit: Add a comment that explains what this method
cschuet (SLOW)
2014/12/08 18:57:04
Done.
|
| + |
| + // Resets the policy subscription and clears the delegate. |
| + void Shutdown(); |
| + private: |
|
bartfab (slow)
2014/12/08 16:49:45
Niz: Add a blank line above.
cschuet (SLOW)
2014/12/08 18:57:04
Done.
|
| + void OnShutdownPolicyChanged(); |
| + |
| + CrosSettings* cros_settings_; |
| + |
| + Delegate* delegate_; |
| + |
| + scoped_ptr<CrosSettings::ObserverSubscription> shutdown_policy_subscription_; |
| + |
| + base::WeakPtrFactory<ShutdownPolicyObserver> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyObserver); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_ |