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

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: cut a circular startup dependency 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"
(...skipping 118 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 13 matching lines...) Expand all
206 cloud_policy_cache_.get(), 190 cloud_policy_cache_.get(),
207 device_token_fetcher_.get(), 191 device_token_fetcher_.get(),
208 identity_strategy_, 192 identity_strategy_,
209 notifier_.get())); 193 notifier_.get()));
210 } 194 }
211 195
212 CloudPolicySubsystem::CloudPolicySubsystem() { 196 CloudPolicySubsystem::CloudPolicySubsystem() {
213 } 197 }
214 198
215 } // namespace policy 199 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698