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

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

Issue 11444029: Added UserPolicySigninService::FetchPolicyForSignedInUser(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_SERVICE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 }; 34 };
35 35
36 // |client| and |store| must remain valid for the object life time. 36 // |client| and |store| must remain valid for the object life time.
37 CloudPolicyService(CloudPolicyClient* client, CloudPolicyStore* store); 37 CloudPolicyService(CloudPolicyClient* client, CloudPolicyStore* store);
38 virtual ~CloudPolicyService(); 38 virtual ~CloudPolicyService();
39 39
40 // Returns the domain that manages this user/device, according to the current 40 // Returns the domain that manages this user/device, according to the current
41 // policy blob. Empty if not managed/not available. 41 // policy blob. Empty if not managed/not available.
42 std::string ManagedBy() const; 42 std::string ManagedBy() const;
43 43
44 // Callback invoked once the policy refresh attempt has completed. Passed
45 // bool parameter is true if the refresh was successful (no error).
46 typedef base::Callback<void(bool)> RefreshPolicyCallback;
Mattias Nissler (ping if slow) 2012/12/07 15:20:45 typedefs should go right after public: per the sty
Andrew T Wilson (Slow) 2012/12/07 17:34:29 Done.
47
44 // Refreshes policy. |callback| will be invoked after the operation completes 48 // Refreshes policy. |callback| will be invoked after the operation completes
45 // or aborts because of errors. 49 // or aborts because of errors.
46 void RefreshPolicy(const base::Closure& callback); 50 void RefreshPolicy(const RefreshPolicyCallback& callback);
47 51
48 // Adds/Removes an Observer for this object. 52 // Adds/Removes an Observer for this object.
49 void AddObserver(Observer* observer); 53 void AddObserver(Observer* observer);
50 void RemoveObserver(Observer* observer); 54 void RemoveObserver(Observer* observer);
51 55
52 // CloudPolicyClient::Observer: 56 // CloudPolicyClient::Observer:
53 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; 57 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
54 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; 58 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
55 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; 59 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
56 60
57 // CloudPolicyStore::Observer: 61 // CloudPolicyStore::Observer:
58 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; 62 virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE;
59 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; 63 virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE;
60 64
61 bool IsInitializationComplete() const { return initialization_complete_; } 65 bool IsInitializationComplete() const { return initialization_complete_; }
62 66
63 private: 67 private:
64 // Helper function that is called when initialization may be complete, and 68 // Helper function that is called when initialization may be complete, and
65 // which is responsible for notifying observers. 69 // which is responsible for notifying observers.
66 void CheckInitializationCompleted(); 70 void CheckInitializationCompleted();
67 71
68 // Invokes the refresh callbacks and clears refresh state. 72 // Invokes the refresh callbacks and clears refresh state. The |success| flag
69 void RefreshCompleted(); 73 // is passed through to the refresh callbacks.
74 void RefreshCompleted(bool success);
70 75
71 // The client used to talk to the cloud. 76 // The client used to talk to the cloud.
72 CloudPolicyClient* client_; 77 CloudPolicyClient* client_;
73 78
74 // Takes care of persisting and decoding cloud policy. 79 // Takes care of persisting and decoding cloud policy.
75 CloudPolicyStore* store_; 80 CloudPolicyStore* store_;
76 81
77 // Tracks the state of a pending refresh operation, if any. 82 // Tracks the state of a pending refresh operation, if any.
78 enum { 83 enum {
79 // No refresh pending. 84 // No refresh pending.
80 REFRESH_NONE, 85 REFRESH_NONE,
81 // Policy fetch is pending. 86 // Policy fetch is pending.
82 REFRESH_POLICY_FETCH, 87 REFRESH_POLICY_FETCH,
83 // Policy store is pending. 88 // Policy store is pending.
84 REFRESH_POLICY_STORE, 89 REFRESH_POLICY_STORE,
85 } refresh_state_; 90 } refresh_state_;
86 91
87 // Callbacks to invoke upon policy refresh. 92 // Callbacks to invoke upon policy refresh.
88 std::vector<base::Closure> refresh_callbacks_; 93 std::vector<RefreshPolicyCallback> refresh_callbacks_;
89 94
90 // Set to true once the service is initialized (initial policy load/refresh 95 // Set to true once the service is initialized (initial policy load/refresh
91 // is complete). 96 // is complete).
92 bool initialization_complete_; 97 bool initialization_complete_;
93 98
94 // Observers who will receive notifications when the service has finished 99 // Observers who will receive notifications when the service has finished
95 // initializing. 100 // initializing.
96 ObserverList<Observer, true> observers_; 101 ObserverList<Observer, true> observers_;
97 102
98 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService); 103 DISALLOW_COPY_AND_ASSIGN(CloudPolicyService);
99 }; 104 };
100 105
101 } // namespace policy 106 } // namespace policy
102 107
103 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_ 108 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698