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

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

Issue 4960003: Don't register gmail users at the device management server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/scoped_ptr.h" 12 #include "base/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/weak_ptr.h" 14 #include "base/weak_ptr.h"
15 #include "chrome/browser/policy/configuration_policy_provider.h" 15 #include "chrome/browser/policy/configuration_policy_provider.h"
16 #include "chrome/browser/policy/device_management_backend.h" 16 #include "chrome/browser/policy/device_management_backend.h"
17 #include "chrome/browser/policy/device_token_fetcher.h" 17 #include "chrome/browser/policy/device_token_fetcher.h"
18 18
19 class Profile;
19 class TokenService; 20 class TokenService;
20 21
21 namespace policy { 22 namespace policy {
22 23
23 class DeviceManagementBackend; 24 class DeviceManagementBackend;
24 class DeviceManagementPolicyCache; 25 class DeviceManagementPolicyCache;
25 26
26 // Provides policy fetched from the device management server. With the exception 27 // Provides policy fetched from the device management server. With the exception
27 // of the Provide method, which can be called on the FILE thread, all public 28 // of the Provide method, which can be called on the FILE thread, all public
28 // methods must be called on the UI thread. 29 // methods must be called on the UI thread.
29 class DeviceManagementPolicyProvider 30 class DeviceManagementPolicyProvider
30 : public ConfigurationPolicyProvider, 31 : public ConfigurationPolicyProvider,
31 public DeviceManagementBackend::DevicePolicyResponseDelegate, 32 public DeviceManagementBackend::DevicePolicyResponseDelegate,
32 public base::SupportsWeakPtr<DeviceManagementPolicyProvider>, 33 public base::SupportsWeakPtr<DeviceManagementPolicyProvider>,
33 public DeviceTokenFetcher::Observer { 34 public DeviceTokenFetcher::Observer {
34 public: 35 public:
35 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, 36 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list,
36 DeviceManagementBackend* backend, 37 DeviceManagementBackend* backend,
37 TokenService* token_service, 38 Profile* profile);
38 const FilePath& storage_dir);
39 39
40 virtual ~DeviceManagementPolicyProvider(); 40 virtual ~DeviceManagementPolicyProvider();
41 41
42 // ConfigurationPolicyProvider implementation: 42 // ConfigurationPolicyProvider implementation:
43 virtual bool Provide(ConfigurationPolicyStoreInterface* store); 43 virtual bool Provide(ConfigurationPolicyStoreInterface* store);
44 44
45 // DevicePolicyResponseDelegate implementation: 45 // DevicePolicyResponseDelegate implementation:
46 virtual void HandlePolicyResponse( 46 virtual void HandlePolicyResponse(
47 const em::DevicePolicyResponse& response); 47 const em::DevicePolicyResponse& response);
48 virtual void OnError(DeviceManagementBackend::ErrorCode code); 48 virtual void OnError(DeviceManagementBackend::ErrorCode code);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // Triggers policy refresh, re-requesting device token and policy information 83 // Triggers policy refresh, re-requesting device token and policy information
84 // as necessary. 84 // as necessary.
85 void RefreshTaskExecute(); 85 void RefreshTaskExecute();
86 86
87 // Schedules a new RefreshTask. 87 // Schedules a new RefreshTask.
88 void ScheduleRefreshTask(int64 delay_in_milliseconds); 88 void ScheduleRefreshTask(int64 delay_in_milliseconds);
89 89
90 // Calculates when the next RefreshTask shall be executed. 90 // Calculates when the next RefreshTask shall be executed.
91 int64 GetRefreshTaskDelay(); 91 int64 GetRefreshTaskDelay();
92 92
93 // The path of the device token file.
94 FilePath GetTokenPath();
95
96 // Used only by tests.
97 void SetDeviceTokenFetcher(DeviceTokenFetcher* token_fetcher);
98
93 // Provides the URL at which requests are sent to from the device management 99 // Provides the URL at which requests are sent to from the device management
94 // backend. 100 // backend.
95 static std::string GetDeviceManagementURL(); 101 static std::string GetDeviceManagementURL();
96 102
97 // Returns the path to the sub-directory in the user data directory 103 // Returns the path to the sub-directory in the user data directory
98 // in which device management persistent state is stored. 104 // in which device management persistent state is stored.
99 static FilePath GetOrCreateDeviceManagementDir( 105 static FilePath GetOrCreateDeviceManagementDir(
100 const FilePath& user_data_dir); 106 const FilePath& user_data_dir);
101 107
102 // Give unit tests the ability to override timeout settings. 108 // Give unit tests the ability to override timeout settings.
103 void set_policy_refresh_rate_ms(int64 policy_refresh_rate_ms) { 109 void set_policy_refresh_rate_ms(int64 policy_refresh_rate_ms) {
104 policy_refresh_rate_ms_ = policy_refresh_rate_ms; 110 policy_refresh_rate_ms_ = policy_refresh_rate_ms;
105 } 111 }
106 void set_policy_refresh_max_earlier_ms(int64 policy_refresh_max_earlier_ms) { 112 void set_policy_refresh_max_earlier_ms(int64 policy_refresh_max_earlier_ms) {
107 policy_refresh_max_earlier_ms_ = policy_refresh_max_earlier_ms; 113 policy_refresh_max_earlier_ms_ = policy_refresh_max_earlier_ms;
108 } 114 }
109 void set_policy_refresh_error_delay_ms(int64 policy_refresh_error_delay_ms) { 115 void set_policy_refresh_error_delay_ms(int64 policy_refresh_error_delay_ms) {
110 policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms; 116 policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms;
111 } 117 }
112 void set_token_fetch_error_delay_ms(int64 token_fetch_error_delay_ms) { 118 void set_token_fetch_error_delay_ms(int64 token_fetch_error_delay_ms) {
113 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms; 119 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms;
114 } 120 }
115 121
116 scoped_ptr<DeviceManagementBackend> backend_; 122 scoped_ptr<DeviceManagementBackend> backend_;
117 TokenService* token_service_; // weak 123 Profile* profile_; // weak
118 scoped_ptr<DeviceManagementPolicyCache> cache_; 124 scoped_ptr<DeviceManagementPolicyCache> cache_;
119 scoped_refptr<DeviceTokenFetcher> token_fetcher_; 125 scoped_refptr<DeviceTokenFetcher> token_fetcher_;
120 DeviceTokenFetcher::ObserverRegistrar registrar_; 126 DeviceTokenFetcher::ObserverRegistrar registrar_;
121 FilePath storage_dir_; 127 FilePath storage_dir_;
122 bool policy_request_pending_; 128 bool policy_request_pending_;
123 bool refresh_task_pending_; 129 bool refresh_task_pending_;
124 int64 policy_refresh_rate_ms_; 130 int64 policy_refresh_rate_ms_;
125 int64 policy_refresh_max_earlier_ms_; 131 int64 policy_refresh_max_earlier_ms_;
126 int64 policy_refresh_error_delay_ms_; 132 int64 policy_refresh_error_delay_ms_;
127 int64 token_fetch_error_delay_ms_; 133 int64 token_fetch_error_delay_ms_;
128 134
129 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); 135 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider);
130 }; 136 };
131 137
132 } // namespace policy 138 } // namespace policy
133 139
134 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ 140 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698