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

Side by Side Diff: chrome/browser/chromeos/login/screens/controller_pairing_screen.cc

Issue 491943004: Update the pairing API to include configuration and enrollment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment some TODOs Created 6 years, 3 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 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/login/screens/controller_pairing_screen.h" 5 #include "chrome/browser/chromeos/login/screens/controller_pairing_screen.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/login/wizard_controller.h" 9 #include "chrome/browser/chromeos/login/wizard_controller.h"
10 #include "chromeos/chromeos_switches.h" 10 #include "chromeos/chromeos_switches.h"
11 #include "chromeos/login/auth/user_context.h"
12 #include "components/pairing/fake_controller_pairing_controller.h" 11 #include "components/pairing/fake_controller_pairing_controller.h"
13 #include "google_apis/gaia/gaia_auth_util.h" 12 #include "google_apis/gaia/gaia_auth_util.h"
14 13
15 using namespace chromeos::controller_pairing; 14 using namespace chromeos::controller_pairing;
16 using namespace pairing_chromeos; 15 using namespace pairing_chromeos;
17 16
17 namespace {
18 const char* kTestAuthToken = "TestAuthToken";
19 };
20
18 namespace chromeos { 21 namespace chromeos {
19 22
20 ControllerPairingScreen::ControllerPairingScreen( 23 ControllerPairingScreen::ControllerPairingScreen(
21 ScreenObserver* observer, 24 ScreenObserver* observer,
22 ControllerPairingScreenActor* actor) 25 ControllerPairingScreenActor* actor)
23 : WizardScreen(observer), 26 : WizardScreen(observer),
24 actor_(actor), 27 actor_(actor),
25 current_stage_(ControllerPairingController::STAGE_NONE), 28 current_stage_(ControllerPairingController::STAGE_NONE),
26 device_preselected_(false) { 29 device_preselected_(false) {
27 actor_->SetDelegate(this); 30 actor_->SetDelegate(this);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } else if (action == kActionRepeatDiscovery) { 193 } else if (action == kActionRepeatDiscovery) {
191 controller_->RepeatDiscovery(); 194 controller_->RepeatDiscovery();
192 } else if (action == kActionAcceptCode) { 195 } else if (action == kActionAcceptCode) {
193 controller_->SetConfirmationCodeIsCorrect(true); 196 controller_->SetConfirmationCodeIsCorrect(true);
194 } else if (action == kActionRejectCode) { 197 } else if (action == kActionRejectCode) {
195 controller_->SetConfirmationCodeIsCorrect(false); 198 controller_->SetConfirmationCodeIsCorrect(false);
196 } else if (action == kActionProceedToAuthentication) { 199 } else if (action == kActionProceedToAuthentication) {
197 context_.SetString(kContextKeyPage, kPageAuthentication); 200 context_.SetString(kContextKeyPage, kPageAuthentication);
198 disable_controls = false; 201 disable_controls = false;
199 } else if (action == kActionEnroll) { 202 } else if (action == kActionEnroll) {
200 std::string account_id = 203 std::string account_id =
achuithb 2014/08/27 21:41:36 make this const
Zachary Kuznia 2014/08/27 22:01:49 Done.
201 gaia::SanitizeEmail(context_.GetString(kContextKeyAccountId)); 204 gaia::SanitizeEmail(context_.GetString(kContextKeyAccountId));
202 context_.SetString(kContextKeyEnrollmentDomain, 205 std::string domain(gaia::ExtractDomainName(account_id));
achuithb 2014/08/27 21:41:36 make this const
Zachary Kuznia 2014/08/27 22:01:49 Done.
203 gaia::ExtractDomainName(account_id)); 206 context_.SetString(kContextKeyEnrollmentDomain, domain);
204 UserContext user_context(account_id); 207 // TODO(zork): Get proper credentials. (http://crbug.com/405744)
205 controller_->OnAuthenticationDone(user_context, 208 controller_->OnAuthenticationDone(domain, kTestAuthToken);
206 actor_->GetBrowserContext());
207 } else if (action == kActionStartSession) { 209 } else if (action == kActionStartSession) {
208 controller_->StartSession(); 210 controller_->StartSession();
209 } 211 }
210 context_.SetBoolean(kContextKeyControlsDisabled, disable_controls); 212 context_.SetBoolean(kContextKeyControlsDisabled, disable_controls);
211 CommitContextChanges(); 213 CommitContextChanges();
212 } 214 }
213 215
214 void ControllerPairingScreen::OnScreenContextChanged( 216 void ControllerPairingScreen::OnScreenContextChanged(
215 const base::DictionaryValue& diff) { 217 const base::DictionaryValue& diff) {
216 std::vector<std::string> changedKeys; 218 std::vector<std::string> changedKeys;
217 context_.ApplyChanges(diff, &changedKeys); 219 context_.ApplyChanges(diff, &changedKeys);
218 for (std::vector<std::string>::const_iterator key = changedKeys.begin(); 220 for (std::vector<std::string>::const_iterator key = changedKeys.begin();
219 key != changedKeys.end(); 221 key != changedKeys.end();
220 ++key) { 222 ++key) {
221 if (*key == kContextKeySelectedDevice) { 223 if (*key == kContextKeySelectedDevice) {
222 context_.SetBoolean(kContextKeyControlsDisabled, 224 context_.SetBoolean(kContextKeyControlsDisabled,
223 context_.GetString(*key).empty()); 225 context_.GetString(*key).empty());
224 CommitContextChanges(); 226 CommitContextChanges();
225 } 227 }
226 } 228 }
227 } 229 }
228 230
229 } // namespace chromeos 231 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698