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

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

Issue 6974013: Recover policy subsystem correctly after enrollment attempt with a gmail acccount (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_controller.h" 5 #include "chrome/browser/policy/cloud_policy_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 161
162 void CloudPolicyController::OnDeviceTokenChanged() { 162 void CloudPolicyController::OnDeviceTokenChanged() {
163 if (identity_strategy_->GetDeviceToken().empty()) 163 if (identity_strategy_->GetDeviceToken().empty())
164 SetState(STATE_TOKEN_UNAVAILABLE); 164 SetState(STATE_TOKEN_UNAVAILABLE);
165 else 165 else
166 SetState(STATE_TOKEN_VALID); 166 SetState(STATE_TOKEN_VALID);
167 } 167 }
168 168
169 void CloudPolicyController::OnCredentialsChanged() { 169 void CloudPolicyController::OnCredentialsChanged() {
170 notifier_->Inform(CloudPolicySubsystem::UNENROLLED,
171 CloudPolicySubsystem::NO_DETAILS,
172 PolicyNotifier::POLICY_CONTROLLER);
170 effective_policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms_; 173 effective_policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms_;
171 SetState(STATE_TOKEN_UNAVAILABLE); 174 SetState(STATE_TOKEN_UNAVAILABLE);
172 } 175 }
173 176
174 CloudPolicyController::CloudPolicyController( 177 CloudPolicyController::CloudPolicyController(
175 DeviceManagementService* service, 178 DeviceManagementService* service,
176 CloudPolicyCacheBase* cache, 179 CloudPolicyCacheBase* cache,
177 DeviceTokenFetcher* token_fetcher, 180 DeviceTokenFetcher* token_fetcher,
178 CloudPolicyIdentityStrategy* identity_strategy, 181 CloudPolicyIdentityStrategy* identity_strategy,
179 PolicyNotifier* notifier, 182 PolicyNotifier* notifier,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 231 }
229 232
230 void CloudPolicyController::FetchToken() { 233 void CloudPolicyController::FetchToken() {
231 std::string username; 234 std::string username;
232 std::string auth_token; 235 std::string auth_token;
233 std::string device_id = identity_strategy_->GetDeviceID(); 236 std::string device_id = identity_strategy_->GetDeviceID();
234 std::string machine_id = identity_strategy_->GetMachineID(); 237 std::string machine_id = identity_strategy_->GetMachineID();
235 std::string machine_model = identity_strategy_->GetMachineModel(); 238 std::string machine_model = identity_strategy_->GetMachineModel();
236 em::DeviceRegisterRequest_Type policy_type = 239 em::DeviceRegisterRequest_Type policy_type =
237 identity_strategy_->GetPolicyRegisterType(); 240 identity_strategy_->GetPolicyRegisterType();
238 if (identity_strategy_->GetCredentials(&username, &auth_token) && 241 if (identity_strategy_->GetCredentials(&username, &auth_token)) {
239 CanBeInManagedDomain(username)) { 242 if (CanBeInManagedDomain(username)) {
240 token_fetcher_->FetchToken(auth_token, device_id, policy_type, 243 token_fetcher_->FetchToken(auth_token, device_id, policy_type,
241 machine_id, machine_model); 244 machine_id, machine_model);
245 } else {
246 SetState(STATE_TOKEN_UNMANAGED);
247 }
242 } 248 }
243 } 249 }
244 250
245 void CloudPolicyController::SendPolicyRequest() { 251 void CloudPolicyController::SendPolicyRequest() {
246 backend_.reset(service_->CreateBackend()); 252 backend_.reset(service_->CreateBackend());
247 DCHECK(!identity_strategy_->GetDeviceToken().empty()); 253 DCHECK(!identity_strategy_->GetDeviceToken().empty());
248 em::DevicePolicyRequest policy_request; 254 em::DevicePolicyRequest policy_request;
249 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); 255 em::PolicyFetchRequest* fetch_request = policy_request.add_request();
250 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); 256 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA);
251 fetch_request->set_policy_type(identity_strategy_->GetPolicyType()); 257 fetch_request->set_policy_type(identity_strategy_->GetPolicyType());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 } 381 }
376 382
377 int64 CloudPolicyController::GetRefreshDelay() { 383 int64 CloudPolicyController::GetRefreshDelay() {
378 int64 deviation = (policy_refresh_deviation_factor_percent_ * 384 int64 deviation = (policy_refresh_deviation_factor_percent_ *
379 policy_refresh_rate_ms_) / 100; 385 policy_refresh_rate_ms_) / 100;
380 deviation = std::min(deviation, policy_refresh_deviation_max_ms_); 386 deviation = std::min(deviation, policy_refresh_deviation_max_ms_);
381 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); 387 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1);
382 } 388 }
383 389
384 } // namespace policy 390 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698