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

Side by Side Diff: chrome/browser/policy/cloud_policy_subsystem.cc

Issue 7147015: Move user cloud policy to BrowserProcess (was 6979011) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + address comments Created 9 years, 6 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.
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 #include "chrome/browser/policy/cloud_policy_subsystem.h" 5 #include "chrome/browser/policy/cloud_policy_subsystem.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/policy/cloud_policy_cache_base.h" 12 #include "chrome/browser/policy/cloud_policy_cache_base.h"
13 #include "chrome/browser/policy/cloud_policy_controller.h" 13 #include "chrome/browser/policy/cloud_policy_controller.h"
14 #include "chrome/browser/policy/cloud_policy_identity_strategy.h" 14 #include "chrome/browser/policy/cloud_policy_identity_strategy.h"
15 #include "chrome/browser/policy/configuration_policy_provider.h" 15 #include "chrome/browser/policy/configuration_policy_provider.h"
Joao da Silva 2011/06/29 11:36:17 Nit: configuration_policy_provider.h not needed.
gfeher 2011/06/29 12:53:07 Done.
16 #include "chrome/browser/policy/device_management_service.h" 16 #include "chrome/browser/policy/device_management_service.h"
17 #include "chrome/browser/policy/device_token_fetcher.h" 17 #include "chrome/browser/policy/device_token_fetcher.h"
18 #include "chrome/browser/policy/policy_notifier.h" 18 #include "chrome/browser/policy/policy_notifier.h"
19 #include "chrome/browser/prefs/pref_service.h" 19 #include "chrome/browser/prefs/pref_service.h"
20 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "content/common/notification_details.h" 22 #include "content/common/notification_details.h"
23 #include "content/common/notification_source.h" 23 #include "content/common/notification_source.h"
24 #include "content/common/notification_type.h" 24 #include "content/common/notification_type.h"
25 25
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 CloudPolicySubsystem::ErrorDetails CloudPolicySubsystem::error_details() { 130 CloudPolicySubsystem::ErrorDetails CloudPolicySubsystem::error_details() {
131 return notifier_->error_details(); 131 return notifier_->error_details();
132 } 132 }
133 133
134 void CloudPolicySubsystem::StopAutoRetry() { 134 void CloudPolicySubsystem::StopAutoRetry() {
135 cloud_policy_controller_->StopAutoRetry(); 135 cloud_policy_controller_->StopAutoRetry();
136 device_token_fetcher_->StopAutoRetry(); 136 device_token_fetcher_->StopAutoRetry();
137 } 137 }
138 138
139 ConfigurationPolicyProvider* CloudPolicySubsystem::GetManagedPolicyProvider() {
140 if (cloud_policy_cache_.get())
141 return cloud_policy_cache_->GetManagedPolicyProvider();
142
143 return NULL;
144 }
145
146 ConfigurationPolicyProvider*
147 CloudPolicySubsystem::GetRecommendedPolicyProvider() {
148 if (cloud_policy_cache_.get())
149 return cloud_policy_cache_->GetRecommendedPolicyProvider();
150
151 return NULL;
152 }
153
154 // static 139 // static
155 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) { 140 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) {
156 pref_service->RegisterIntegerPref(prefs::kDevicePolicyRefreshRate, 141 pref_service->RegisterIntegerPref(prefs::kDevicePolicyRefreshRate,
157 kDefaultPolicyRefreshRateMs, 142 kDefaultPolicyRefreshRateMs,
158 PrefService::UNSYNCABLE_PREF); 143 PrefService::UNSYNCABLE_PREF);
159 pref_service->RegisterIntegerPref(prefs::kUserPolicyRefreshRate, 144 pref_service->RegisterIntegerPref(prefs::kUserPolicyRefreshRate,
160 kDefaultPolicyRefreshRateMs, 145 kDefaultPolicyRefreshRateMs,
161 PrefService::UNSYNCABLE_PREF); 146 PrefService::UNSYNCABLE_PREF);
162 } 147 }
163 148
164 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { 149 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) {
165 if (cloud_policy_controller_.get()) { 150 if (cloud_policy_controller_.get()) {
166 // Clamp to sane values. 151 // Clamp to sane values.
167 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); 152 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate);
168 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); 153 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate);
169 cloud_policy_controller_->SetRefreshRate(refresh_rate); 154 cloud_policy_controller_->SetRefreshRate(refresh_rate);
170 } 155 }
171 } 156 }
172 157
173 void CloudPolicySubsystem::Observe(NotificationType type, 158 void CloudPolicySubsystem::Observe(NotificationType type,
174 const NotificationSource& source, 159 const NotificationSource& source,
175 const NotificationDetails& details) { 160 const NotificationDetails& details) {
176 if (type == NotificationType::PREF_CHANGED) { 161 if (type == NotificationType::PREF_CHANGED) {
177 DCHECK_EQ(*(Details<std::string>(details).ptr()), 162 DCHECK_EQ(*(Details<std::string>(details).ptr()),
178 std::string(refresh_pref_name_)); 163 std::string(refresh_pref_name_));
179 PrefService* pref_service = Source<PrefService>(source).ptr(); 164 PrefService* local_state = g_browser_process->local_state();
180 // Temporarily also consider the profile preference service as a valid 165 DCHECK_EQ(Source<PrefService>(source).ptr(), local_state);
181 // source, since we cannot yet push user cloud policy to |local_state|. 166 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_));
182 UpdatePolicyRefreshRate(pref_service->GetInteger(refresh_pref_name_));
183 } else { 167 } else {
184 NOTREACHED(); 168 NOTREACHED();
185 } 169 }
186 } 170 }
187 171
188 void CloudPolicySubsystem::ScheduleServiceInitialization( 172 void CloudPolicySubsystem::ScheduleServiceInitialization(
189 int64 delay_milliseconds) { 173 int64 delay_milliseconds) {
190 if (device_management_service_.get()) 174 if (device_management_service_.get())
191 device_management_service_->ScheduleInitialization(delay_milliseconds); 175 device_management_service_->ScheduleInitialization(delay_milliseconds);
192 } 176 }
(...skipping 15 matching lines...) Expand all
208 identity_strategy_, 192 identity_strategy_,
209 notifier_.get())); 193 notifier_.get()));
210 } 194 }
211 195
212 CloudPolicySubsystem::CloudPolicySubsystem() 196 CloudPolicySubsystem::CloudPolicySubsystem()
213 : refresh_pref_name_(NULL), 197 : refresh_pref_name_(NULL),
214 identity_strategy_(NULL) { 198 identity_strategy_(NULL) {
215 } 199 }
216 200
217 } // namespace policy 201 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698