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

Side by Side Diff: chrome/browser/chromeos/policy/consumer_enrollment_handler.cc

Issue 769703003: SetManagementSettings() is moved to OwnerSettingsServiceChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Failing test fixed. Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/policy/consumer_enrollment_handler.h" 5 #include "chrome/browser/chromeos/policy/consumer_enrollment_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/browser_process_platform_part.h" 12 #include "chrome/browser/browser_process_platform_part.h"
13 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
13 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
14 #include "chrome/browser/chromeos/policy/consumer_management_service.h" 15 #include "chrome/browser/chromeos/policy/consumer_management_service.h"
15 #include "chrome/browser/chromeos/policy/consumer_management_stage.h" 16 #include "chrome/browser/chromeos/policy/consumer_management_stage.h"
16 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h" 17 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
17 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 18 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
19 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" 22 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
21 #include "components/signin/core/browser/profile_oauth2_token_service.h" 23 #include "components/signin/core/browser/profile_oauth2_token_service.h"
22 #include "components/signin/core/browser/signin_manager_base.h" 24 #include "components/signin/core/browser/signin_manager_base.h"
23 #include "google_apis/gaia/gaia_constants.h" 25 #include "google_apis/gaia/gaia_constants.h"
24 #include "google_apis/gaia/google_service_auth_error.h" 26 #include "google_apis/gaia/google_service_auth_error.h"
25 27
26 namespace policy { 28 namespace policy {
27 29
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 BrowserPolicyConnectorChromeOS* connector = 105 BrowserPolicyConnectorChromeOS* connector =
104 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 106 g_browser_process->platform_part()->browser_policy_connector_chromeos();
105 DeviceCloudPolicyInitializer* initializer = 107 DeviceCloudPolicyInitializer* initializer =
106 connector->GetDeviceCloudPolicyInitializer(); 108 connector->GetDeviceCloudPolicyInitializer();
107 CHECK(initializer); 109 CHECK(initializer);
108 110
109 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes; 111 policy::DeviceCloudPolicyInitializer::AllowedDeviceModes device_modes;
110 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true; 112 device_modes[policy::DEVICE_MODE_ENTERPRISE] = true;
111 113
112 initializer->StartEnrollment( 114 initializer->StartEnrollment(
113 MANAGEMENT_MODE_CONSUMER_MANAGED, 115 MANAGEMENT_MODE_CONSUMER_MANAGED, device_management_service_,
114 device_management_service_, 116 chromeos::OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(
117 profile_),
115 access_token, 118 access_token,
116 device_modes, 119 device_modes,
117 base::Bind(&ConsumerEnrollmentHandler::OnEnrollmentCompleted, 120 base::Bind(&ConsumerEnrollmentHandler::OnEnrollmentCompleted,
118 weak_ptr_factory_.GetWeakPtr())); 121 weak_ptr_factory_.GetWeakPtr()));
119 } 122 }
120 123
121 void ConsumerEnrollmentHandler::OnEnrollmentCompleted(EnrollmentStatus status) { 124 void ConsumerEnrollmentHandler::OnEnrollmentCompleted(EnrollmentStatus status) {
122 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) { 125 if (status.status() != EnrollmentStatus::STATUS_SUCCESS) {
123 LOG(ERROR) << "Failed to enroll the device." 126 LOG(ERROR) << "Failed to enroll the device."
124 << " status=" << status.status() 127 << " status=" << status.status()
125 << " client_status=" << status.client_status() 128 << " client_status=" << status.client_status()
126 << " http_status=" << status.http_status() 129 << " http_status=" << status.http_status()
127 << " store_status=" << status.store_status() 130 << " store_status=" << status.store_status()
128 << " validation_status=" << status.validation_status(); 131 << " validation_status=" << status.validation_status();
129 EndEnrollment(ConsumerManagementStage::EnrollmentDMServerFailed()); 132 EndEnrollment(ConsumerManagementStage::EnrollmentDMServerFailed());
130 return; 133 return;
131 } 134 }
132 135
133 EndEnrollment(ConsumerManagementStage::EnrollmentSuccess()); 136 EndEnrollment(ConsumerManagementStage::EnrollmentSuccess());
134 } 137 }
135 138
136 void ConsumerEnrollmentHandler::EndEnrollment( 139 void ConsumerEnrollmentHandler::EndEnrollment(
137 const ConsumerManagementStage& stage) { 140 const ConsumerManagementStage& stage) {
138 consumer_management_service_->SetStage(stage); 141 consumer_management_service_->SetStage(stage);
139 } 142 }
140 143
141 } // namespace policy 144 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698