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

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: " 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
pastarmovj 2011/07/06 12:11:57 Consider removing as discussed offline.
gfeher 2011/07/06 15:14:20 Sorry about this, it somehow sneaked in.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/policy/cloud_policy_data.h"
12 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
13 14
14 namespace policy { 15 namespace policy {
15 16
16 namespace em = enterprise_management; 17 namespace em = enterprise_management;
17 18
18 // Manages a device management token, i.e. an identifier that represents a 19 // Manages a device management token, i.e. an identifier that represents a
19 // registration with the device management service, and the associated 20 // registration with the device management service, and the associated
20 // credentials. Responsibilities include storing and loading the token from 21 // credentials. Responsibilities include storing and loading the token from
21 // disk, observing and triggering relevant notifications. 22 // disk, observing and triggering relevant notifications.
22 class CloudPolicyIdentityStrategy { 23 class CloudPolicyIdentityStrategy : public CloudPolicyData::Observer {
23 public: 24 public:
24 class Observer { 25 explicit CloudPolicyIdentityStrategy(CloudPolicyData* data);
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(); 26 virtual ~CloudPolicyIdentityStrategy();
39 27
40 void AddObserver(Observer* obs); 28 // CloudPolicyData::Observer implementation:
41 void RemoveObserver(Observer* obs); 29 virtual void OnDeviceTokenChanged() OVERRIDE;
42 30 virtual void OnCredentialsChanged() OVERRIDE;
43 // Returns the device management token, if available. Returns the empty string 31 virtual void OnPolicyHolderGoingAway() OVERRIDE {}
pastarmovj 2011/07/06 12:11:57 Consider removing this.
gfeher 2011/07/06 15:14:20 Done.
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 32
78 protected: 33 protected:
79 // Notify observers that the effective token has changed. 34 CloudPolicyData* data();
80 void NotifyDeviceTokenChanged();
81
82 // Notify observers about authentication data change.
83 void NotifyAuthChanged();
84 35
85 private: 36 private:
86 ObserverList<Observer, true> observer_list_; 37 CloudPolicyData* data_;
87 38
88 DISALLOW_COPY_AND_ASSIGN(CloudPolicyIdentityStrategy); 39 DISALLOW_COPY_AND_ASSIGN(CloudPolicyIdentityStrategy);
89 }; 40 };
90 41
91 } // namespace policy 42 } // namespace policy
92 43
93 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_ 44 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_IDENTITY_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698