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

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

Issue 6979011: Move user cloud policy to BrowserProcess. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments by mnissler. 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 CloudPolicySubsystem::ErrorDetails CloudPolicySubsystem::error_details() { 128 CloudPolicySubsystem::ErrorDetails CloudPolicySubsystem::error_details() {
129 return notifier_->error_details(); 129 return notifier_->error_details();
130 } 130 }
131 131
132 void CloudPolicySubsystem::StopAutoRetry() { 132 void CloudPolicySubsystem::StopAutoRetry() {
133 cloud_policy_controller_->StopAutoRetry(); 133 cloud_policy_controller_->StopAutoRetry();
134 device_token_fetcher_->StopAutoRetry(); 134 device_token_fetcher_->StopAutoRetry();
135 } 135 }
136 136
137 ConfigurationPolicyProvider* CloudPolicySubsystem::GetManagedPolicyProvider() {
138 if (cloud_policy_cache_.get())
139 return cloud_policy_cache_->GetManagedPolicyProvider();
140
141 return NULL;
142 }
143
144 ConfigurationPolicyProvider*
145 CloudPolicySubsystem::GetRecommendedPolicyProvider() {
146 if (cloud_policy_cache_.get())
147 return cloud_policy_cache_->GetRecommendedPolicyProvider();
148
149 return NULL;
150 }
151
152 // static 137 // static
153 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) { 138 void CloudPolicySubsystem::RegisterPrefs(PrefService* pref_service) {
154 pref_service->RegisterIntegerPref(prefs::kDevicePolicyRefreshRate, 139 pref_service->RegisterIntegerPref(prefs::kDevicePolicyRefreshRate,
155 kDefaultPolicyRefreshRateMs, 140 kDefaultPolicyRefreshRateMs,
156 PrefService::UNSYNCABLE_PREF); 141 PrefService::UNSYNCABLE_PREF);
157 pref_service->RegisterIntegerPref(prefs::kUserPolicyRefreshRate, 142 pref_service->RegisterIntegerPref(prefs::kUserPolicyRefreshRate,
158 kDefaultPolicyRefreshRateMs, 143 kDefaultPolicyRefreshRateMs,
159 PrefService::UNSYNCABLE_PREF); 144 PrefService::UNSYNCABLE_PREF);
160 } 145 }
161 146
162 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) { 147 void CloudPolicySubsystem::UpdatePolicyRefreshRate(int64 refresh_rate) {
163 if (cloud_policy_controller_.get()) { 148 if (cloud_policy_controller_.get()) {
164 // Clamp to sane values. 149 // Clamp to sane values.
165 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate); 150 refresh_rate = std::max(kPolicyRefreshRateMinMs, refresh_rate);
166 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate); 151 refresh_rate = std::min(kPolicyRefreshRateMaxMs, refresh_rate);
167 cloud_policy_controller_->SetRefreshRate(refresh_rate); 152 cloud_policy_controller_->SetRefreshRate(refresh_rate);
168 } 153 }
169 } 154 }
170 155
171 void CloudPolicySubsystem::Observe(NotificationType type, 156 void CloudPolicySubsystem::Observe(NotificationType type,
172 const NotificationSource& source, 157 const NotificationSource& source,
173 const NotificationDetails& details) { 158 const NotificationDetails& details) {
174 if (type == NotificationType::PREF_CHANGED) { 159 if (type == NotificationType::PREF_CHANGED) {
175 DCHECK_EQ(*(Details<std::string>(details).ptr()), 160 DCHECK_EQ(*(Details<std::string>(details).ptr()),
176 std::string(refresh_pref_name_)); 161 std::string(refresh_pref_name_));
177 PrefService* pref_service = Source<PrefService>(source).ptr(); 162 PrefService* local_state = g_browser_process->local_state();
178 // Temporarily also consider the profile preference service as a valid 163 DCHECK_EQ(Source<PrefService>(source).ptr(), local_state);
179 // source, since we cannot yet push user cloud policy to |local_state|. 164 UpdatePolicyRefreshRate(local_state->GetInteger(refresh_pref_name_));
180 UpdatePolicyRefreshRate(pref_service->GetInteger(refresh_pref_name_));
181 } else { 165 } else {
182 NOTREACHED(); 166 NOTREACHED();
183 } 167 }
184 } 168 }
185 169
186 void CloudPolicySubsystem::ScheduleServiceInitialization( 170 void CloudPolicySubsystem::ScheduleServiceInitialization(
187 int64 delay_milliseconds) { 171 int64 delay_milliseconds) {
188 if (device_management_service_.get()) 172 if (device_management_service_.get())
189 device_management_service_->ScheduleInitialization(delay_milliseconds); 173 device_management_service_->ScheduleInitialization(delay_milliseconds);
190 } 174 }
191 175
192 } // namespace policy 176 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud_policy_subsystem.h ('k') | chrome/browser/policy/configuration_policy_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698