[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / chromeos / dbus / session_manager_client.h
blobd7b91d4de99d99d26dabf6137242f4e492bea775
1 // Copyright (c) 2012 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 CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
6 #define CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_
8 #include "base/callback.h"
9 #include "base/observer_list.h"
10 #include "chromeos/chromeos_export.h"
11 #include "chromeos/dbus/dbus_client_implementation_type.h"
13 #include <string>
15 namespace dbus {
16 class Bus;
17 } // namespace
19 namespace chromeos {
21 // SessionManagerClient is used to communicate with the session manager.
22 class CHROMEOS_EXPORT SessionManagerClient {
23 public:
24 // Interface for observing changes from the session manager.
25 class Observer {
26 public:
27 // Called when the owner key is set.
28 virtual void OwnerKeySet(bool success) {}
30 // Called when the property change is complete.
31 virtual void PropertyChangeComplete(bool success) {}
33 // Called when the screen is locked.
34 virtual void LockScreen() {}
36 // Called when the screen is unlocked.
37 virtual void UnlockScreen() {}
41 // Adds and removes the observer.
42 virtual void AddObserver(Observer* observer) = 0;
43 virtual void RemoveObserver(Observer* observer) = 0;
44 virtual bool HasObserver(Observer* observer) = 0;
46 // Kicks off an attempt to emit the "login-prompt-ready" upstart signal.
47 virtual void EmitLoginPromptReady() = 0;
49 // Kicks off an attempt to emit the "login-prompt-visible" upstart signal.
50 virtual void EmitLoginPromptVisible() = 0;
52 // Restarts a job referenced by |pid| with the provided command line.
53 virtual void RestartJob(int pid, const std::string& command_line) = 0;
55 // Restarts entd (the enterprise daemon).
56 // DEPRECATED: will be deleted soon.
57 virtual void RestartEntd() = 0;
59 // Starts the session for the user.
60 virtual void StartSession(const std::string& user_email) = 0;
62 // Stops the current session.
63 virtual void StopSession() = 0;
65 // Starts the factory reset.
66 virtual void StartDeviceWipe() = 0;
68 // Locks the screen.
69 virtual void RequestLockScreen() = 0;
71 // Notifies that the lock screen is shown.
72 virtual void NotifyLockScreenShown() = 0;
74 // Unlocks the screen.
75 virtual void RequestUnlockScreen() = 0;
77 // Notifies that the lock screen is dismissed.
78 virtual void NotifyLockScreenDismissed() = 0;
80 // Returns whether or not the screen is locked. Implementation should cache
81 // this state so that it can return immediately. Useful for observers that
82 // need to know the current screen lock state when they are added.
83 virtual bool GetIsScreenLocked() = 0;
85 // Used for RetrieveDevicePolicy, RetrieveUserPolicy and
86 // RetrieveDeviceLocalAccountPolicy. Takes a serialized protocol buffer as
87 // string. Upon success, we will pass a protobuf to the callback. On
88 // failure, we will pass "".
89 typedef base::Callback<void(const std::string&)> RetrievePolicyCallback;
91 // Fetches the device policy blob stored by the session manager. Upon
92 // completion of the retrieve attempt, we will call the provided callback.
93 virtual void RetrieveDevicePolicy(const RetrievePolicyCallback& callback) = 0;
95 // Fetches the user policy blob stored by the session manager for the
96 // currently signed-in user. Upon completion of the retrieve attempt, we will
97 // call the provided callback.
98 virtual void RetrieveUserPolicy(const RetrievePolicyCallback& callback) = 0;
100 // Fetches the policy blob associated with the specified device-local account
101 // from session manager. |callback| is invoked up on completion.
102 virtual void RetrieveDeviceLocalAccountPolicy(
103 const std::string& account_id,
104 const RetrievePolicyCallback& callback) = 0;
106 // Used for StoreDevicePolicy, StoreUserPolicy and
107 // StoreDeviceLocalAccountPolicy. Takes a boolean indicating whether the
108 // operation was successful or not.
109 typedef base::Callback<void(bool)> StorePolicyCallback;
111 // Attempts to asynchronously store |policy_blob| as device policy. Upon
112 // completion of the store attempt, we will call callback.
113 virtual void StoreDevicePolicy(const std::string& policy_blob,
114 const StorePolicyCallback& callback) = 0;
116 // Attempts to asynchronously store |policy_blob| as user policy for the
117 // currently signed-in user. Upon completion of the store attempt, we will
118 // call callback.
119 virtual void StoreUserPolicy(const std::string& policy_blob,
120 const StorePolicyCallback& callback) = 0;
122 // Sends a request to store a policy blob for the specified device-local
123 // account. The result of the operation is reported through |callback|.
124 virtual void StoreDeviceLocalAccountPolicy(
125 const std::string& account_id,
126 const std::string& policy_blob,
127 const StorePolicyCallback& callback) = 0;
129 // Creates the instance.
130 static SessionManagerClient* Create(DBusClientImplementationType type,
131 dbus::Bus* bus);
133 virtual ~SessionManagerClient();
135 protected:
136 // Create() should be used instead.
137 SessionManagerClient();
139 private:
140 DISALLOW_COPY_AND_ASSIGN(SessionManagerClient);
143 } // namespace chromeos
145 #endif // CHROMEOS_DBUS_SESSION_MANAGER_CLIENT_H_