Chromium Code Reviews| OLD | NEW |
|---|---|
| (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/macros.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
| 12 | |
| 13 namespace chromeos { | |
| 14 | |
| 15 // This class observes the device setting "DeviceShutdownIsReboot". Changes to | |
| 16 // this policy are communicated to the ShutdownPolicyObserver::Delegate by | |
| 17 // calling its OnShutdownPolicyChanged method with the new state of the policy. | |
| 18 class ShutdownPolicyObserver { | |
| 19 public: | |
| 20 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.
| |
| 21 | |
| 22 // This delegate is called when the "DeviceShutdownIsReboot" policy changes. | |
| 23 class Delegate { | |
| 24 public: | |
| 25 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.
| |
| 26 protected: | |
|
bartfab (slow)
2014/12/08 16:49:45
Nit: Add a blank line above.
cschuet (SLOW)
2014/12/08 18:57:04
Done.
| |
| 27 virtual ~Delegate() {} | |
| 28 }; | |
| 29 | |
| 30 ShutdownPolicyObserver(CrosSettings* cros_settings, Delegate* delegate); | |
| 31 ~ShutdownPolicyObserver(); | |
| 32 | |
| 33 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.
| |
| 34 | |
| 35 // Resets the policy subscription and clears the delegate. | |
| 36 void Shutdown(); | |
| 37 private: | |
|
bartfab (slow)
2014/12/08 16:49:45
Niz: Add a blank line above.
cschuet (SLOW)
2014/12/08 18:57:04
Done.
| |
| 38 void OnShutdownPolicyChanged(); | |
| 39 | |
| 40 CrosSettings* cros_settings_; | |
| 41 | |
| 42 Delegate* delegate_; | |
| 43 | |
| 44 scoped_ptr<CrosSettings::ObserverSubscription> shutdown_policy_subscription_; | |
| 45 | |
| 46 base::WeakPtrFactory<ShutdownPolicyObserver> weak_factory_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(ShutdownPolicyObserver); | |
| 49 }; | |
| 50 | |
| 51 } // namespace chromeos | |
| 52 | |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SHUTDOWN_POLICY_OBSERVER_H_ | |
| OLD | NEW |