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

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

Issue 6312121: Add initial device policy infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup/compile fixes. Created 9 years, 10 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_CONTROLLER_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/observer_list.h"
13
14 namespace policy {
15
16 // Manages a device management token, i.e. an identifier that represents a
danno 2011/02/04 16:01:33 It does more than that... better comment?
Jakob Kummerow 2011/02/14 13:50:34 Done.
17 // registration with the device management service.
18 class CloudPolicyController {
danno 2011/02/04 16:01:33 CloudPolicyIdentityStrategy?
Jakob Kummerow 2011/02/14 13:50:34 Done.
19 public:
20 class Observer {
21 public:
22 virtual ~Observer() {}
23
24 // Notifies observers that the effective token for fetching policy has
25 // changed. The token can be queried by calling GetDeviceToken().
26 virtual void OnTokenChanged() = 0;
danno 2011/02/04 16:01:33 s/OnTokenChanged/OnDeviceTokenChanged/
Jakob Kummerow 2011/02/14 13:50:34 Done.
27
28 // Authentication credentials for talking to the device management service
29 // changed. New auth data is available through GetCredentials().
30 virtual void OnCredentialsChanged() = 0;
31 };
32
33 CloudPolicyController() {}
34 virtual ~CloudPolicyController() {}
35
36 void AddObserver(Observer* obs) {
37 observer_list_.AddObserver(obs);
38 }
39
40 void RemoveObserver(Observer* obs) {
41 observer_list_.RemoveObserver(obs);
42 }
43
44 // Returns the device management token, if available. Returns the empty string
45 // if the device token is currently unavailable.
46 virtual std::string GetDeviceToken() = 0;
47
48 // Returns the device ID for this device.
49 virtual std::string GetDeviceID() = 0;
50
51 // Retrieves authentication credentials to use when talking to the device
52 // management service. Returns true if the data is available and writes the
53 // values to the provided pointers.
54 virtual bool GetCredentials(std::string* username,
55 std::string* auth_token) = 0;
56
57 // Notifies the provider that a new token has been fetched. It is up to the
danno 2011/02/04 16:01:33 I don't think you mean provider, you mean controll
Jakob Kummerow 2011/02/14 13:50:34 Done. (s/provider/identity strategy/, to be precis
58 // provider to decide that token is going to be used, in which case it should
danno 2011/02/04 16:01:33 provider -> controller
Jakob Kummerow 2011/02/14 13:50:34 Done.
59 // send a OnTokenChanged() notification an return the new token in
danno 2011/02/04 16:01:33 s/an/and
danno 2011/02/04 16:01:33 Couldn't you also have OnTokenChanged return a boo
Jakob Kummerow 2011/02/14 13:50:34 Done.
Jakob Kummerow 2011/02/14 13:50:34 I don't currently see a use case for that...
60 // GetDeviceToken() calls.
61 virtual void OnTokenAvailable(const std::string& token) = 0;
danno 2011/02/04 16:01:33 s/OnTokenAvailable/OnDeviceTokenAvailable/ to disa
Jakob Kummerow 2011/02/14 13:50:34 Done.
62
63 protected:
64 // Notify observers that the effective token has changed.
65 void NotifyTokenChanged() {
danno 2011/02/04 16:01:33 s/NotifyTokenChanged/NotifyDeviceTokenChanged/
Jakob Kummerow 2011/02/14 13:50:34 Done.
66 FOR_EACH_OBSERVER(Observer, observer_list_, OnTokenChanged());
67 }
68
69 // Notify observers about authentication data change.
70 void NotifyAuthChanged() {
71 FOR_EACH_OBSERVER(Observer, observer_list_, OnCredentialsChanged());
72 }
73
74 private:
75 ObserverList<Observer, true> observer_list_;
76
77 DISALLOW_COPY_AND_ASSIGN(CloudPolicyController);
78 };
79
80 } // namespace policy
81
82 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698