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

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

Issue 776093004: Add device policy to disallow shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
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..1f882c290644c9dd35b6e7d1985c07e42de4f61d
--- /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 "DeviceShutdownAllowed". 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 ShutdownAllowedCallback = base::Callback<void(bool)>;
+
+ // This delegate is called when the "DeviceShutdownAllowed" policy changes.
+ class Delegate {
+ public:
+ virtual void OnShutdownPolicyChanged(bool shutdown_allowed) = 0;
+ protected:
+ virtual ~Delegate() {}
+ };
+
+ ShutdownPolicyObserver(CrosSettings* cros_settings, Delegate* delegate);
+ ~ShutdownPolicyObserver();
+
+ void CheckIfShutdownAllowed(const ShutdownAllowedCallback& callback);
+
+ // Resets the policy subscription and clears the delegate.
+ void Shutdown();
+ private:
+ 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_

Powered by Google App Engine
This is Rietveld 408576698