| 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/ui/webui/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 args.SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase()); | 500 args.SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase()); |
| 501 } | 501 } |
| 502 | 502 |
| 503 StringValue page("configure"); | 503 StringValue page("configure"); |
| 504 web_ui()->CallJavascriptFunction( | 504 web_ui()->CallJavascriptFunction( |
| 505 "SyncSetupOverlay.showSyncSetupPage", page, args); | 505 "SyncSetupOverlay.showSyncSetupPage", page, args); |
| 506 | 506 |
| 507 if (UseWebBasedSigninFlow()) { | 507 if (UseWebBasedSigninFlow()) { |
| 508 // Make sure the tab used for the Gaia sign in does not cover the settings | 508 // Make sure the tab used for the Gaia sign in does not cover the settings |
| 509 // tab. | 509 // tab. |
| 510 BringTabToFront(web_ui()->GetWebContents()); | 510 FocusUI(); |
| 511 } | 511 } |
| 512 } | 512 } |
| 513 | 513 |
| 514 void SyncSetupHandler::ConfigureSyncDone() { | 514 void SyncSetupHandler::ConfigureSyncDone() { |
| 515 StringValue page("done"); | 515 StringValue page("done"); |
| 516 web_ui()->CallJavascriptFunction( | 516 web_ui()->CallJavascriptFunction( |
| 517 "SyncSetupOverlay.showSyncSetupPage", page); | 517 "SyncSetupOverlay.showSyncSetupPage", page); |
| 518 | 518 |
| 519 // Suppress the sync promo once the user signs into sync. This way the user | 519 // Suppress the sync promo once the user signs into sync. This way the user |
| 520 // doesn't see the sync promo even if they sign out of sync later on. | 520 // doesn't see the sync promo even if they sign out of sync later on. |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 | 831 |
| 832 // Gaia credentials are valid - update the UI. | 832 // Gaia credentials are valid - update the UI. |
| 833 DisplayGaiaSuccessAndSettingUp(); | 833 DisplayGaiaSuccessAndSettingUp(); |
| 834 } | 834 } |
| 835 | 835 |
| 836 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { | 836 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { |
| 837 // Stop a timer to handle timeout in waiting for checking network connection. | 837 // Stop a timer to handle timeout in waiting for checking network connection. |
| 838 backend_start_timer_.reset(); | 838 backend_start_timer_.reset(); |
| 839 | 839 |
| 840 last_signin_error_ = error; | 840 last_signin_error_ = error; |
| 841 // Got a failed signin - this is either just a typical auth error, or a | 841 |
| 842 // sync error (treat sync errors as "fatal errors" - i.e. non-auth errors). | 842 // If using web-based sign in flow, don't show the gaia sign in page again |
| 843 // On ChromeOS, this condition can happen when auth token is invalid and | 843 // since there is no way to show the user an error message. |
| 844 // cannot start sync backend. | 844 if (UseWebBasedSigninFlow()) { |
| 845 if (retry_on_signin_failure_) { | 845 CloseSyncSetup(); |
| 846 DisplayGaiaLogin(GetSyncService()->HasUnrecoverableError()); | |
| 847 } else { | 846 } else { |
| 848 // TODO(peria): Show error dialog for prompting sign in and out on | 847 // Got a failed signin - this is either just a typical auth error, or a |
| 849 // Chrome OS. http://crbug.com/128692 | 848 // sync error (treat sync errors as "fatal errors" - i.e. non-auth errors). |
| 850 CloseOverlay(); | 849 // On ChromeOS, this condition can happen when auth token is invalid and |
| 850 // cannot start sync backend. |
| 851 // If using web-based sign in flow, don't show the gaia sign in page again |
| 852 // since there is no way to show the user an error message. |
| 853 if (retry_on_signin_failure_) { |
| 854 DisplayGaiaLogin(GetSyncService()->HasUnrecoverableError()); |
| 855 } else { |
| 856 // TODO(peria): Show error dialog for prompting sign in and out on |
| 857 // Chrome OS. http://crbug.com/128692 |
| 858 CloseOverlay(); |
| 859 } |
| 851 } | 860 } |
| 852 } | 861 } |
| 853 | 862 |
| 854 Profile* SyncSetupHandler::GetProfile() const { | 863 Profile* SyncSetupHandler::GetProfile() const { |
| 855 return Profile::FromWebUI(web_ui()); | 864 return Profile::FromWebUI(web_ui()); |
| 856 } | 865 } |
| 857 | 866 |
| 858 ProfileSyncService* SyncSetupHandler::GetSyncService() const { | 867 ProfileSyncService* SyncSetupHandler::GetSyncService() const { |
| 859 return ProfileSyncServiceFactory::GetForProfile(GetProfile()); | 868 return ProfileSyncServiceFactory::GetForProfile(GetProfile()); |
| 860 } | 869 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 if (i != current_profile_index && AreUserNamesEqual( | 1227 if (i != current_profile_index && AreUserNamesEqual( |
| 1219 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1228 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
| 1220 *error_message = l10n_util::GetStringUTF16( | 1229 *error_message = l10n_util::GetStringUTF16( |
| 1221 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1230 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
| 1222 return false; | 1231 return false; |
| 1223 } | 1232 } |
| 1224 } | 1233 } |
| 1225 | 1234 |
| 1226 return true; | 1235 return true; |
| 1227 } | 1236 } |
| OLD | NEW |