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

Side by Side Diff: chrome/browser/policy/cloud_policy_identity_strategy.h

Issue 7298012: Consolidate data storage and notifications in the cloud policy subsystem (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/observer_list.h"
12 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
13
14 namespace policy {
15
16 namespace em = enterprise_management;
17
18 // Manages a device management token, i.e. an identifier that represents a
19 // registration with the device management service, and the associated
20 // credentials. Responsibilities include storing and loading the token from
21 // disk, observing and triggering relevant notifications.
22 class CloudPolicyIdentityStrategy {
23 public:
24 class Observer {
25 public:
26 virtual ~Observer() {}
27
28 // Notifies observers that the effective token for fetching policy has
29 // changed. The token can be queried by calling GetDeviceToken().
30 virtual void OnDeviceTokenChanged() = 0;
31
32 // Authentication credentials for talking to the device management service
33 // changed. New auth data is available through GetCredentials().
34 virtual void OnCredentialsChanged() = 0;
35 };
36
37 CloudPolicyIdentityStrategy();
38 virtual ~CloudPolicyIdentityStrategy();
39
40 void AddObserver(Observer* obs);
41 void RemoveObserver(Observer* obs);
42
43 // Returns the device management token, if available. Returns the empty string
44 // if the device token is currently unavailable.
45 virtual std::string GetDeviceToken() = 0;
46
47 // Returns the device ID for this device. This is a unique identifier that is
48 // randomly generated at registration time on the client side. It always has
49 // to be sent along with the device token to the server.
50 virtual std::string GetDeviceID() = 0;
51
52 // Returns physical machine ID for this device.
53 virtual std::string GetMachineID() = 0;
54
55 // Returns physical machine model for this device.
56 virtual std::string GetMachineModel() = 0;
57
58 // Returns the policy type to be used for registering at the device management
59 // server.
60 virtual em::DeviceRegisterRequest_Type GetPolicyRegisterType() = 0;
61
62 // Returns the policy type to be used for requesting policies from the device
63 // management server.
64 virtual std::string GetPolicyType() = 0;
65
66 // Retrieves authentication credentials to use when talking to the device
67 // management service. Returns true if the data is available and writes the
68 // values to the provided pointers.
69 virtual bool GetCredentials(std::string* username,
70 std::string* auth_token) = 0;
71
72 // Notifies the identity strategy that a new token has been fetched. It is up
73 // to the identity strategy to store the token, decide whether it is going
74 // to be used, send out an appropriate OnDeviceTokenChanged() notification
75 // and return the new token in GetDeviceToken() calls.
76 virtual void OnDeviceTokenAvailable(const std::string& token) = 0;
77
78 protected:
79 // Notify observers that the effective token has changed.
80 void NotifyDeviceTokenChanged();
81
82 // Notify observers about authentication data change.
83 void NotifyAuthChanged();
84
85 private:
86 ObserverList<Observer, true> observer_list_;
87
88 DISALLOW_COPY_AND_ASSIGN(CloudPolicyIdentityStrategy);
89 };
90
91 } // namespace policy
92
93 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_data_store.cc ('k') | chrome/browser/policy/cloud_policy_identity_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698