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

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

Issue 5331008: Persist 'this device is not managed' information (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build on Windows Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 // DeviceTokenFetcher::Observer implementation: 50 // DeviceTokenFetcher::Observer implementation:
51 void OnTokenSuccess(); 51 void OnTokenSuccess();
52 void OnTokenError(); 52 void OnTokenError();
53 void OnNotManaged(); 53 void OnNotManaged();
54 54
55 // True if a policy request has been sent to the device management backend 55 // True if a policy request has been sent to the device management backend
56 // server and no response or error has yet been received. 56 // server and no response or error has yet been received.
57 bool IsPolicyRequestPending() const { return policy_request_pending_; } 57 bool IsPolicyRequestPending() const { return policy_request_pending_; }
58 58
59 bool waiting_for_initial_policies() const {
60 return waiting_for_initial_policies_;
61 }
62
59 // Tells the provider that the passed in token service reference is about to 63 // Tells the provider that the passed in token service reference is about to
60 // become invalid. 64 // become invalid.
61 void Shutdown(); 65 void Shutdown();
62 66
63 private: 67 private:
64 class InitializeAfterIOThreadExistsTask; 68 class InitializeAfterIOThreadExistsTask;
65 class RefreshTask; 69 class RefreshTask;
66 70
67 friend class DeviceManagementPolicyProviderTest; 71 friend class DeviceManagementPolicyProviderTest;
68 72
73 // More configurable constructor for use by test cases.
74 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list,
75 DeviceManagementBackend* backend,
76 Profile* profile,
77 int64 policy_refresh_rate_ms,
78 int64 policy_refresh_max_earlier_ms,
79 int64 policy_refresh_error_delay_ms,
80 int64 token_fetch_error_delay_ms,
81 int64 unmanaged_device_refresh_rate_ms);
82
69 // Called by constructors to perform shared initialization. Initialization 83 // Called by constructors to perform shared initialization. Initialization
70 // requiring the IOThread must not be performed directly in this method, 84 // requiring the IOThread must not be performed directly in this method,
71 // rather must be deferred until the IOThread is fully initialized. This is 85 // rather must be deferred until the IOThread is fully initialized. This is
72 // the case in InitializeAfterIOThreadExists. 86 // the case in InitializeAfterIOThreadExists.
73 void Initialize(); 87 void Initialize(DeviceManagementBackend* backend,
88 Profile* profile,
89 int64 policy_refresh_rate_ms,
90 int64 policy_refresh_max_earlier_ms,
91 int64 policy_refresh_error_delay_ms,
92 int64 token_fetch_error_delay_ms,
93 int64 unmanaged_device_refresh_rate_ms);
74 94
75 // Called by a deferred task posted to the UI thread to complete the portion 95 // Called by a deferred task posted to the UI thread to complete the portion
76 // of initialization that requires the IOThread. 96 // of initialization that requires the IOThread.
77 void InitializeAfterIOThreadExists(); 97 void InitializeAfterIOThreadExists();
78 98
79 // Sends a request to the device manager backend to fetch policy if one isn't 99 // Sends a request to the device manager backend to fetch policy if one isn't
80 // already outstanding. 100 // already outstanding.
81 void SendPolicyRequest(); 101 void SendPolicyRequest();
82 102
83 // Triggers policy refresh, re-requesting device token and policy information 103 // Triggers policy refresh, re-requesting device token and policy information
84 // as necessary. 104 // as necessary.
85 void RefreshTaskExecute(); 105 void RefreshTaskExecute();
86 106
87 // Schedules a new RefreshTask. 107 // Schedules a new RefreshTask.
88 void ScheduleRefreshTask(int64 delay_in_milliseconds); 108 void ScheduleRefreshTask(int64 delay_in_milliseconds);
89 109
90 // Calculates when the next RefreshTask shall be executed. 110 // Calculates when the next RefreshTask shall be executed.
91 int64 GetRefreshTaskDelay(); 111 int64 GetRefreshTaskDelay();
92 112
113 void StopWaitingForInitialPolicies();
114
115 // Send a CLOUD_POLICY_UPDATE notification.
116 void NotifyCloudPolicyUpdate() const;
117
93 // The path of the device token file. 118 // The path of the device token file.
94 FilePath GetTokenPath(); 119 FilePath GetTokenPath();
95 120
96 // Used only by tests. 121 // Used only by tests.
97 void SetDeviceTokenFetcher(DeviceTokenFetcher* token_fetcher); 122 void SetDeviceTokenFetcher(DeviceTokenFetcher* token_fetcher);
98 123
99 // Provides the URL at which requests are sent to from the device management 124 // Provides the URL at which requests are sent to from the device management
100 // backend. 125 // backend.
101 static std::string GetDeviceManagementURL(); 126 static std::string GetDeviceManagementURL();
102 127
103 // Returns the path to the sub-directory in the user data directory 128 // Returns the path to the sub-directory in the user data directory
104 // in which device management persistent state is stored. 129 // in which device management persistent state is stored.
105 static FilePath GetOrCreateDeviceManagementDir( 130 static FilePath GetOrCreateDeviceManagementDir(
106 const FilePath& user_data_dir); 131 const FilePath& user_data_dir);
107 132
108 // Give unit tests the ability to override timeout settings.
109 void set_policy_refresh_rate_ms(int64 policy_refresh_rate_ms) {
110 policy_refresh_rate_ms_ = policy_refresh_rate_ms;
111 }
112 void set_policy_refresh_max_earlier_ms(int64 policy_refresh_max_earlier_ms) {
113 policy_refresh_max_earlier_ms_ = policy_refresh_max_earlier_ms;
114 }
115 void set_policy_refresh_error_delay_ms(int64 policy_refresh_error_delay_ms) {
116 policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms;
117 }
118 void set_token_fetch_error_delay_ms(int64 token_fetch_error_delay_ms) {
119 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms;
120 }
121
122 scoped_ptr<DeviceManagementBackend> backend_; 133 scoped_ptr<DeviceManagementBackend> backend_;
123 Profile* profile_; // weak 134 Profile* profile_; // weak
124 scoped_ptr<DeviceManagementPolicyCache> cache_; 135 scoped_ptr<DeviceManagementPolicyCache> cache_;
125 scoped_refptr<DeviceTokenFetcher> token_fetcher_; 136 scoped_refptr<DeviceTokenFetcher> token_fetcher_;
126 DeviceTokenFetcher::ObserverRegistrar registrar_; 137 DeviceTokenFetcher::ObserverRegistrar registrar_;
127 FilePath storage_dir_; 138 FilePath storage_dir_;
128 bool policy_request_pending_; 139 bool policy_request_pending_;
129 bool refresh_task_pending_; 140 bool refresh_task_pending_;
141 bool waiting_for_initial_policies_;
130 int64 policy_refresh_rate_ms_; 142 int64 policy_refresh_rate_ms_;
131 int64 policy_refresh_max_earlier_ms_; 143 int64 policy_refresh_max_earlier_ms_;
132 int64 policy_refresh_error_delay_ms_; 144 int64 policy_refresh_error_delay_ms_;
133 int64 token_fetch_error_delay_ms_; 145 int64 token_fetch_error_delay_ms_;
146 int64 unmanaged_device_refresh_rate_ms_;
134 147
135 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); 148 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider);
136 }; 149 };
137 150
138 } // namespace policy 151 } // namespace policy
139 152
140 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 153 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_policy_cache.cc ('k') | chrome/browser/policy/device_management_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698