OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/sync_setup_flow.h" | 5 #include "chrome/browser/sync/sync_setup_flow.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | |
16 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/signin/signin_manager.h" | 17 #include "chrome/browser/signin/signin_manager.h" |
19 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 19 #include "chrome/browser/sync/profile_sync_service_factory.h" |
21 #include "chrome/browser/sync/sync_setup_flow_handler.h" | 20 #include "chrome/browser/sync/sync_setup_flow_handler.h" |
22 #include "chrome/browser/sync/syncable/model_type.h" | 21 #include "chrome/browser/sync/syncable/model_type.h" |
23 #include "chrome/browser/sync/user_selectable_sync_type.h" | 22 #include "chrome/browser/sync/user_selectable_sync_type.h" |
24 #include "chrome/browser/sync/util/oauth.h" | 23 #include "chrome/browser/sync/util/oauth.h" |
25 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
26 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/net/gaia/gaia_constants.h" | 26 #include "chrome/common/net/gaia/gaia_constants.h" |
28 #include "chrome/common/net/gaia/google_service_auth_error.h" | 27 #include "chrome/common/net/gaia/google_service_auth_error.h" |
29 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
31 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 // Helper function to disable password sync. | 34 // Helper function to disable password sync. |
36 void DisablePasswordSync(ProfileSyncService* service) { | 35 void DisablePasswordSync(ProfileSyncService* service) { |
37 syncable::ModelTypeSet types = service->GetPreferredDataTypes(); | 36 syncable::ModelTypeSet types = service->GetPreferredDataTypes(); |
38 types.Remove(syncable::PASSWORDS); | 37 types.Remove(syncable::PASSWORDS); |
39 service->OnUserChoseDatatypes(false, types); | 38 service->OnUserChoseDatatypes(false, types); |
40 } | 39 } |
41 | 40 |
42 // Returns the next step for the non-fatal error case. | |
43 SyncSetupWizard::State GetStepForNonFatalError(ProfileSyncService* service) { | |
44 // TODO(sync): Update this error handling to allow different platforms to | |
45 // display the error appropriately (http://crbug.com/92722) instead of | |
46 // navigating to a LOGIN state that is not supported on every platform. | |
47 if (service->IsPassphraseRequired()) { | |
48 #if defined(OS_CHROMEOS) | |
49 // On ChromeOS, we never want to request login information; this state | |
50 // always represents an invalid secondary passphrase. | |
51 // TODO(sync): correctly handle auth errors on ChromeOS: crosbug.com/24647. | |
52 return SyncSetupWizard::ENTER_PASSPHRASE; | |
53 #else | |
54 if (service->IsUsingSecondaryPassphrase()) | |
55 return SyncSetupWizard::ENTER_PASSPHRASE; | |
56 return SyncSetupWizard::GetLoginState(); | |
57 #endif | |
58 } | |
59 | |
60 const GoogleServiceAuthError& error = service->GetAuthError(); | |
61 if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || | |
62 error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED || | |
63 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED || | |
64 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED || | |
65 error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { | |
66 return SyncSetupWizard::GetLoginState(); | |
67 } | |
68 | |
69 NOTREACHED(); | |
70 return SyncSetupWizard::FATAL_ERROR; | |
71 } | |
72 | |
73 bool HasConfigurationChanged(const SyncConfiguration& configuration, | 41 bool HasConfigurationChanged(const SyncConfiguration& configuration, |
74 Profile* profile) { | 42 Profile* profile) { |
75 CHECK(profile); | 43 CHECK(profile); |
76 | 44 |
77 // This function must be updated every time a new sync datatype is added to | 45 // This function must be updated every time a new sync datatype is added to |
78 // the sync preferences page. | 46 // the sync preferences page. |
79 COMPILE_ASSERT(17 == syncable::MODEL_TYPE_COUNT, | 47 COMPILE_ASSERT(17 == syncable::MODEL_TYPE_COUNT, |
80 UpdateCustomConfigHistogram); | 48 UpdateCustomConfigHistogram); |
81 | 49 |
82 // If service is null or if this is a first time configuration, return true. | 50 // If service is null or if this is a first time configuration, return true. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 187 |
220 SyncSetupFlow::~SyncSetupFlow() { | 188 SyncSetupFlow::~SyncSetupFlow() { |
221 flow_handler_->SetFlow(NULL); | 189 flow_handler_->SetFlow(NULL); |
222 } | 190 } |
223 | 191 |
224 // static | 192 // static |
225 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, | 193 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, |
226 SyncSetupFlowContainer* container, | 194 SyncSetupFlowContainer* container, |
227 SyncSetupWizard::State start, | 195 SyncSetupWizard::State start, |
228 SyncSetupWizard::State end) { | 196 SyncSetupWizard::State end) { |
229 if (start == SyncSetupWizard::NONFATAL_ERROR) | |
230 start = GetStepForNonFatalError(service); | |
231 if ((start == SyncSetupWizard::CONFIGURE || | 197 if ((start == SyncSetupWizard::CONFIGURE || |
232 start == SyncSetupWizard::SYNC_EVERYTHING || | 198 start == SyncSetupWizard::SYNC_EVERYTHING || |
233 start == SyncSetupWizard::ENTER_PASSPHRASE) && | 199 start == SyncSetupWizard::ENTER_PASSPHRASE) && |
234 !service->sync_initialized()) { | 200 !service->sync_initialized()) { |
235 // We are trying to open configuration window, but the backend isn't ready. | 201 // We are trying to open configuration window, but the backend isn't ready. |
236 // We just return NULL. This has the effect of the flow getting reset, and | 202 // We just return NULL. This has the effect of the flow getting reset, and |
237 // the user's action has no effect. | 203 // the user's action has no effect. |
238 LOG(ERROR) << "Attempted to show sync configure before backend ready."; | 204 LOG(ERROR) << "Attempted to show sync configure before backend ready."; |
239 return NULL; | 205 return NULL; |
240 } | 206 } |
241 return new SyncSetupFlow(start, end, container, service); | 207 return new SyncSetupFlow(start, end, container, service); |
242 } | 208 } |
243 | 209 |
244 void SyncSetupFlow::GetArgsForGaiaLogin(DictionaryValue* args) { | |
245 const GoogleServiceAuthError& error = service_->GetAuthError(); | |
246 if (!last_attempted_user_email_.empty()) { | |
247 args->SetString("user", last_attempted_user_email_); | |
248 args->SetInteger("error", error.state()); | |
249 args->SetBoolean("editable_user", true); | |
250 } else { | |
251 string16 user; | |
252 user = UTF8ToUTF16(service_->profile()->GetPrefs()->GetString( | |
253 prefs::kGoogleServicesUsername)); | |
254 args->SetString("user", user); | |
255 args->SetInteger("error", 0); | |
256 args->SetBoolean("editable_user", user.empty()); | |
257 } | |
258 | |
259 args->SetString("captchaUrl", error.captcha().image_url.spec()); | |
260 } | |
261 | |
262 void SyncSetupFlow::GetArgsForConfigure(DictionaryValue* args) { | 210 void SyncSetupFlow::GetArgsForConfigure(DictionaryValue* args) { |
263 // The SYNC_EVERYTHING case will set this to true. | 211 // The SYNC_EVERYTHING case will set this to true. |
264 args->SetBoolean("showSyncEverythingPage", false); | 212 args->SetBoolean("showSyncEverythingPage", false); |
265 | 213 |
266 args->SetBoolean("syncAllDataTypes", | 214 args->SetBoolean("syncAllDataTypes", |
267 service_->profile()->GetPrefs()->GetBoolean( | 215 service_->profile()->GetPrefs()->GetBoolean( |
268 prefs::kSyncKeepEverythingSynced)); | 216 prefs::kSyncKeepEverythingSynced)); |
269 | 217 |
270 // Bookmarks, Preferences, and Themes are launched for good, there's no | 218 // Bookmarks, Preferences, and Themes are launched for good, there's no |
271 // going back now. Check if the other data types are registered though. | 219 // going back now. Check if the other data types are registered though. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 305 |
358 void SyncSetupFlow::Focus() { | 306 void SyncSetupFlow::Focus() { |
359 // This gets called from SyncSetupWizard::Focus(), and might get called | 307 // This gets called from SyncSetupWizard::Focus(), and might get called |
360 // before flow_handler_ is set in AttachSyncSetupHandler() (which gets | 308 // before flow_handler_ is set in AttachSyncSetupHandler() (which gets |
361 // called asynchronously after the UI initializes). | 309 // called asynchronously after the UI initializes). |
362 if (flow_handler_) | 310 if (flow_handler_) |
363 flow_handler_->Focus(); | 311 flow_handler_->Focus(); |
364 } | 312 } |
365 | 313 |
366 // A callback to notify the delegate that the dialog closed. | 314 // A callback to notify the delegate that the dialog closed. |
367 // TODO(rickcam): Bug 90713: Handle OAUTH_LOGIN case here | |
368 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { | 315 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { |
369 DCHECK(json_retval.empty()); | 316 DCHECK(json_retval.empty()); |
370 container_->set_flow(NULL); // Sever ties from the wizard. | 317 container_->set_flow(NULL); // Sever ties from the wizard. |
371 // If we've reached the end, mark it. This could be a discrete run, in which | 318 // If we've reached the end, mark it. This could be a discrete run, in which |
372 // case it's already set, but it simplifes the logic to do it this way. | 319 // case it's already set, but it simplifes the logic to do it this way. |
373 if (current_state_ == end_state_) | 320 if (current_state_ == end_state_) |
374 service_->SetSyncSetupCompleted(); | 321 service_->SetSyncSetupCompleted(); |
375 | 322 |
376 // Record the state at which the user cancelled the signon dialog. | 323 // Record the state at which the user cancelled the signon dialog. |
377 switch (current_state_) { | 324 switch (current_state_) { |
378 case SyncSetupWizard::GAIA_LOGIN: | |
379 ProfileSyncService::SyncEvent( | |
380 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); | |
381 break; | |
382 case SyncSetupWizard::GAIA_SUCCESS: | |
383 ProfileSyncService::SyncEvent( | |
384 ProfileSyncService::CANCEL_DURING_SIGNON); | |
385 break; | |
386 case SyncSetupWizard::CONFIGURE: | 325 case SyncSetupWizard::CONFIGURE: |
387 case SyncSetupWizard::ENTER_PASSPHRASE: | 326 case SyncSetupWizard::ENTER_PASSPHRASE: |
388 case SyncSetupWizard::SETTING_UP: | 327 case SyncSetupWizard::SETTING_UP: |
389 // TODO(atwilson): Treat a close during ENTER_PASSPHRASE like a | 328 // TODO(atwilson): Treat a close during ENTER_PASSPHRASE like a |
390 // Cancel + Skip (i.e. call OnPassphraseCancel()). http://crbug.com/74645 | 329 // Cancel + Skip (i.e. call OnPassphraseCancel()). http://crbug.com/74645 |
391 ProfileSyncService::SyncEvent( | 330 ProfileSyncService::SyncEvent( |
392 ProfileSyncService::CANCEL_DURING_CONFIGURE); | 331 ProfileSyncService::CANCEL_DURING_CONFIGURE); |
393 break; | 332 break; |
394 case SyncSetupWizard::DONE: | |
395 // TODO(sync): rename this histogram; it's tracking authorization AND | |
396 // initial sync download time. | |
397 UMA_HISTOGRAM_MEDIUM_TIMES("Sync.UserPerceivedAuthorizationTime", | |
398 base::TimeTicks::Now() - login_start_time_); | |
399 break; | |
400 default: | 333 default: |
401 break; | 334 break; |
402 } | 335 } |
403 | 336 |
404 service_->SetUIShouldDepictAuthInProgress(false); | |
405 service_->OnUserCancelledDialog(); | 337 service_->OnUserCancelledDialog(); |
406 delete this; | 338 delete this; |
407 } | 339 } |
408 | 340 |
409 void SyncSetupFlow::OnUserSubmittedAuth(const std::string& username, | |
410 const std::string& password, | |
411 const std::string& captcha, | |
412 const std::string& access_code) { | |
413 last_attempted_user_email_ = username; | |
414 service_->SetUIShouldDepictAuthInProgress(true); | |
415 | |
416 // If we're just being called to provide an ASP, then pass it to the | |
417 // SigninManager and wait for the next step. | |
418 if (!access_code.empty()) { | |
419 service_->signin()->ProvideSecondFactorAccessCode(access_code); | |
420 return; | |
421 } | |
422 | |
423 // Kick off a sign-in through the signin manager. | |
424 SigninManager* signin = service_->signin(); | |
425 signin->StartSignIn(username, | |
426 password, | |
427 signin->GetLoginAuthError().captcha().token, | |
428 captcha); | |
429 } | |
430 | |
431 void SyncSetupFlow::OnUserSubmittedOAuth( | |
432 const std::string& oauth1_request_token) { | |
433 GaiaOAuthFetcher* fetcher = new GaiaOAuthFetcher( | |
434 service_->signin(), | |
435 service_->profile()->GetRequestContext(), | |
436 service_->profile(), | |
437 GaiaConstants::kSyncServiceOAuth); | |
438 service_->signin()->StartOAuthSignIn(oauth1_request_token, fetcher); | |
439 } | |
440 | |
441 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) { | 341 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) { |
442 // Update sync histograms. This is a no-op if |configuration| has not changed. | 342 // Update sync histograms. This is a no-op if |configuration| has not changed. |
443 UpdateHistogram(configuration, service_); | 343 UpdateHistogram(configuration, service_); |
444 | 344 |
445 // Go to the "loading..." screen. | 345 // Go to the "loading..." screen. |
446 Advance(SyncSetupWizard::SETTING_UP); | 346 Advance(SyncSetupWizard::SETTING_UP); |
447 | 347 |
448 // Note: encryption will not occur until OnUserChoseDatatypes is called. | 348 // Note: encryption will not occur until OnUserChoseDatatypes is called. |
449 if (configuration.encrypt_all) | 349 if (configuration.encrypt_all) |
450 service_->EnableEncryptEverything(); | 350 service_->EnableEncryptEverything(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 416 } |
517 | 417 |
518 // Use static Run method to get an instance. | 418 // Use static Run method to get an instance. |
519 SyncSetupFlow::SyncSetupFlow(SyncSetupWizard::State start_state, | 419 SyncSetupFlow::SyncSetupFlow(SyncSetupWizard::State start_state, |
520 SyncSetupWizard::State end_state, | 420 SyncSetupWizard::State end_state, |
521 SyncSetupFlowContainer* container, | 421 SyncSetupFlowContainer* container, |
522 ProfileSyncService* service) | 422 ProfileSyncService* service) |
523 : container_(container), | 423 : container_(container), |
524 current_state_(start_state), | 424 current_state_(start_state), |
525 end_state_(end_state), | 425 end_state_(end_state), |
526 login_start_time_(base::TimeTicks::Now()), | |
527 flow_handler_(NULL), | 426 flow_handler_(NULL), |
528 service_(service), | 427 service_(service), |
529 user_tried_creating_explicit_passphrase_(false), | 428 user_tried_creating_explicit_passphrase_(false), |
530 user_tried_setting_passphrase_(false) { | 429 user_tried_setting_passphrase_(false) { |
531 } | 430 } |
532 | 431 |
533 // Returns true if the flow should advance to |state| based on |current_state_|. | 432 // Returns true if the flow should advance to |state| based on |current_state_|. |
534 bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) { | 433 bool SyncSetupFlow::ShouldAdvance(SyncSetupWizard::State state) { |
535 switch (state) { | 434 switch (state) { |
536 case SyncSetupWizard::OAUTH_LOGIN: | |
537 return current_state_ == SyncSetupWizard::FATAL_ERROR || | |
538 current_state_ == SyncSetupWizard::OAUTH_LOGIN || | |
539 current_state_ == SyncSetupWizard::SETTING_UP; | |
540 case SyncSetupWizard::GAIA_LOGIN: | |
541 return current_state_ == SyncSetupWizard::FATAL_ERROR || | |
542 current_state_ == SyncSetupWizard::GAIA_LOGIN || | |
543 current_state_ == SyncSetupWizard::SETTING_UP; | |
544 case SyncSetupWizard::GAIA_SUCCESS: | |
545 return current_state_ == SyncSetupWizard::GAIA_LOGIN || | |
546 current_state_ == SyncSetupWizard::OAUTH_LOGIN; | |
547 case SyncSetupWizard::SYNC_EVERYTHING: // Intentionally fall through. | 435 case SyncSetupWizard::SYNC_EVERYTHING: // Intentionally fall through. |
548 case SyncSetupWizard::CONFIGURE: | 436 case SyncSetupWizard::CONFIGURE: |
549 return current_state_ == SyncSetupWizard::GAIA_SUCCESS; | 437 return current_state_ != SyncSetupWizard::SETTING_UP; |
550 case SyncSetupWizard::ENTER_PASSPHRASE: | 438 case SyncSetupWizard::ENTER_PASSPHRASE: |
551 return (service_->auto_start_enabled() && | 439 return current_state_ == SyncSetupWizard::SYNC_EVERYTHING || |
552 current_state_ == SyncSetupWizard::GAIA_LOGIN) || | |
553 current_state_ == SyncSetupWizard::SYNC_EVERYTHING || | |
554 current_state_ == SyncSetupWizard::CONFIGURE || | 440 current_state_ == SyncSetupWizard::CONFIGURE || |
555 current_state_ == SyncSetupWizard::SETTING_UP; | 441 current_state_ == SyncSetupWizard::SETTING_UP; |
556 case SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR: | |
557 return current_state_ != SyncSetupWizard::ABORT; | |
558 case SyncSetupWizard::SETTING_UP: | 442 case SyncSetupWizard::SETTING_UP: |
559 return current_state_ == SyncSetupWizard::SYNC_EVERYTHING || | 443 return current_state_ == SyncSetupWizard::SYNC_EVERYTHING || |
560 current_state_ == SyncSetupWizard::CONFIGURE || | 444 current_state_ == SyncSetupWizard::CONFIGURE || |
561 current_state_ == SyncSetupWizard::ENTER_PASSPHRASE; | 445 current_state_ == SyncSetupWizard::ENTER_PASSPHRASE; |
562 case SyncSetupWizard::NONFATAL_ERROR: // Intentionally fall through. | |
563 case SyncSetupWizard::FATAL_ERROR: | 446 case SyncSetupWizard::FATAL_ERROR: |
564 return current_state_ != SyncSetupWizard::ABORT; | 447 return current_state_ != SyncSetupWizard::ABORT; |
565 case SyncSetupWizard::ABORT: | 448 case SyncSetupWizard::ABORT: |
566 return true; | 449 return true; |
567 case SyncSetupWizard::DONE: | 450 case SyncSetupWizard::DONE: |
568 return current_state_ == SyncSetupWizard::SETTING_UP || | 451 return current_state_ == SyncSetupWizard::SETTING_UP || |
569 current_state_ == SyncSetupWizard::ENTER_PASSPHRASE; | 452 current_state_ == SyncSetupWizard::ENTER_PASSPHRASE; |
570 default: | 453 default: |
571 NOTREACHED() << "Unhandled State: " << state; | 454 NOTREACHED() << "Unhandled State: " << state; |
572 return false; | 455 return false; |
573 } | 456 } |
574 } | 457 } |
575 | 458 |
576 void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) { | 459 void SyncSetupFlow::ActivateState(SyncSetupWizard::State state) { |
577 DCHECK(flow_handler_); | 460 DCHECK(flow_handler_); |
578 | 461 |
579 if (state == SyncSetupWizard::NONFATAL_ERROR) | |
580 state = GetStepForNonFatalError(service_); | |
581 | |
582 current_state_ = state; | 462 current_state_ = state; |
583 | 463 |
584 switch (state) { | 464 switch (state) { |
585 case SyncSetupWizard::OAUTH_LOGIN: { | |
586 flow_handler_->ShowOAuthLogin(); | |
587 break; | |
588 } | |
589 case SyncSetupWizard::GAIA_LOGIN: { | |
590 DictionaryValue args; | |
591 GetArgsForGaiaLogin(&args); | |
592 flow_handler_->ShowGaiaLogin(args); | |
593 break; | |
594 } | |
595 case SyncSetupWizard::GAIA_SUCCESS: | |
596 // Authentication is complete now. | |
597 service_->SetUIShouldDepictAuthInProgress(false); | |
598 if (end_state_ == SyncSetupWizard::GAIA_SUCCESS) { | |
599 flow_handler_->ShowGaiaSuccessAndClose(); | |
600 break; | |
601 } | |
602 flow_handler_->ShowGaiaSuccessAndSettingUp(); | |
603 break; | |
604 case SyncSetupWizard::SYNC_EVERYTHING: { | 465 case SyncSetupWizard::SYNC_EVERYTHING: { |
605 DictionaryValue args; | 466 DictionaryValue args; |
606 GetArgsForConfigure(&args); | 467 GetArgsForConfigure(&args); |
607 args.SetBoolean("showSyncEverythingPage", true); | 468 args.SetBoolean("showSyncEverythingPage", true); |
608 flow_handler_->ShowConfigure(args); | 469 flow_handler_->ShowConfigure(args); |
609 break; | 470 break; |
610 } | 471 } |
611 case SyncSetupWizard::CONFIGURE: { | 472 case SyncSetupWizard::CONFIGURE: { |
612 DictionaryValue args; | 473 DictionaryValue args; |
613 GetArgsForConfigure(&args); | 474 GetArgsForConfigure(&args); |
614 flow_handler_->ShowConfigure(args); | 475 flow_handler_->ShowConfigure(args); |
615 break; | 476 break; |
616 } | 477 } |
617 case SyncSetupWizard::ENTER_PASSPHRASE: { | 478 case SyncSetupWizard::ENTER_PASSPHRASE: { |
618 DictionaryValue args; | 479 DictionaryValue args; |
619 GetArgsForConfigure(&args); | 480 GetArgsForConfigure(&args); |
620 // TODO(atwilson): Remove ShowPassphraseEntry in favor of using | 481 // TODO(atwilson): Remove ShowPassphraseEntry in favor of using |
621 // ShowConfigure() - http://crbug.com/90786. | 482 // ShowConfigure() - http://crbug.com/90786. |
622 flow_handler_->ShowPassphraseEntry(args); | 483 flow_handler_->ShowPassphraseEntry(args); |
623 break; | 484 break; |
624 } | 485 } |
625 case SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR: { | |
626 // TODO(sync): We should expose a real "display an error" API on | |
627 // SyncSetupFlowHandler (crbug.com/92722) but for now just transition | |
628 // to the login state with a special error code. | |
629 DictionaryValue args; | |
630 GetArgsForGaiaLogin(&args); | |
631 args.SetInteger("error", GoogleServiceAuthError::SERVICE_UNAVAILABLE); | |
632 current_state_ = SyncSetupWizard::GAIA_LOGIN; | |
633 flow_handler_->ShowGaiaLogin(args); | |
634 break; | |
635 } | |
636 case SyncSetupWizard::SETTING_UP: { | 486 case SyncSetupWizard::SETTING_UP: { |
637 flow_handler_->ShowSettingUp(); | 487 flow_handler_->ShowSettingUp(); |
638 break; | 488 break; |
639 } | 489 } |
640 case SyncSetupWizard::FATAL_ERROR: { | 490 case SyncSetupWizard::FATAL_ERROR: { |
641 // This shows the user the "Could not connect to server" error. | 491 // This shows the user the "Could not connect to server" error. |
642 // TODO(sync): Update this error handling to allow different platforms to | 492 // TODO(sync): Update this error handling to allow different platforms to |
643 // display the error appropriately (http://crbug.com/92722). | 493 // display the error appropriately (http://crbug.com/92722). |
644 DictionaryValue args; | 494 flow_handler_->ShowFatalError(); |
645 GetArgsForGaiaLogin(&args); | |
646 args.SetBoolean("fatalError", true); | |
647 current_state_ = SyncSetupWizard::GAIA_LOGIN; | |
648 flow_handler_->ShowGaiaLogin(args); | |
649 break; | 495 break; |
650 } | 496 } |
651 case SyncSetupWizard::DONE: | 497 case SyncSetupWizard::DONE: |
652 case SyncSetupWizard::ABORT: | 498 case SyncSetupWizard::ABORT: |
653 flow_handler_->ShowSetupDone(UTF8ToUTF16( | 499 flow_handler_->ShowSetupDone(UTF8ToUTF16( |
654 service_->profile()->GetPrefs()->GetString( | 500 service_->profile()->GetPrefs()->GetString( |
655 prefs::kGoogleServicesUsername))); | 501 prefs::kGoogleServicesUsername))); |
656 break; | 502 break; |
657 default: | 503 default: |
658 NOTREACHED() << "Invalid advance state: " << state; | 504 NOTREACHED() << "Invalid advance state: " << state; |
659 } | 505 } |
660 } | 506 } |
OLD | NEW |