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

Unified Diff: chrome/browser/ui/webui/sync_setup_handler.cc

Issue 10539128: Set timeout in sync setup (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Do not show GAIA login on timeout Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/sync_setup_handler.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 7a7d34e8836636538239b46853a990aba5aa3e81..4980a4008a4bc98d3d16869e9d3a151f88129d85 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -196,7 +196,8 @@ SyncSetupHandler::SyncSetupHandler(ProfileManager* profile_manager)
: configuring_sync_(false),
profile_manager_(profile_manager),
last_signin_error_(GoogleServiceAuthError::NONE),
- retry_on_signin_failure_(true) {
+ retry_on_signin_failure_(true),
+ visible_timeout_(false) {
}
SyncSetupHandler::~SyncSetupHandler() {
@@ -285,6 +286,8 @@ void SyncSetupHandler::GetStaticLocalizedValues(
static OptionsStringResource resources[] = {
{ "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE },
+ { "syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE },
+ { "syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT },
{ "cannotBeBlank", IDS_SYNC_CANNOT_BE_BLANK },
{ "emailLabel", IDS_SYNC_LOGIN_EMAIL_NEW_LINE },
{ "passwordLabel", IDS_SYNC_LOGIN_PASSWORD_NEW_LINE },
@@ -591,6 +594,27 @@ void SyncSetupHandler::DisplaySpinner() {
configuring_sync_ = true;
StringValue page("spinner");
DictionaryValue args;
+
+ const int kTimeoutSec = 30;
+ DCHECK(!backend_start_timer_.get());
+ backend_start_timer_.reset(new base::OneShotTimer<SyncSetupHandler>());
+ backend_start_timer_->Start(FROM_HERE,
+ base::TimeDelta::FromSeconds(kTimeoutSec),
+ this, &SyncSetupHandler::DisplayTimeout);
+
+ web_ui()->CallJavascriptFunction(
+ "SyncSetupOverlay.showSyncSetupPage", page, args);
+}
+
+// TODO(kochi): Handle error conditions other than timeout.
+// http://crbug.com/128692
+void SyncSetupHandler::DisplayTimeout() {
+ // Stop setting up sync service
+ CloseSyncSetup();
+
+ visible_timeout_ = true;
+ StringValue page("timeout");
+ DictionaryValue args;
web_ui()->CallJavascriptFunction(
"SyncSetupOverlay.showSyncSetupPage", page, args);
}
@@ -610,6 +634,7 @@ void SyncSetupHandler::DisplayGaiaSuccessAndSettingUp() {
}
void SyncSetupHandler::OnDidClosePage(const ListValue* args) {
+ visible_timeout_ = false;
CloseSyncSetup();
}
@@ -709,6 +734,9 @@ void SyncSetupHandler::GaiaCredentialsValid() {
}
void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) {
+ // Stop a timer to handle timeout in waiting for checking network connection.
+ backend_start_timer_.reset();
+
last_signin_error_ = error;
// Got a failed signin - this is either just a typical auth error, or a
// sync error (treat sync errors as "fatal errors" - i.e. non-auth errors).
@@ -733,6 +761,9 @@ ProfileSyncService* SyncSetupHandler::GetSyncService() const {
void SyncSetupHandler::SigninSuccess() {
DCHECK(GetSyncService()->sync_initialized());
+ // Stop a timer to handle timeout in waiting for checking network connection.
+ backend_start_timer_.reset();
+
// If we have signed in while sync is already setup, it must be due to some
// kind of re-authentication flow. In that case, just close the signin dialog
// rather than forcing the user to go through sync configuration.
@@ -847,6 +878,11 @@ void SyncSetupHandler::HandleConfigure(const ListValue* args) {
}
void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
+ // Stop recursive calls if timeout dialog is visible.
+ if (visible_timeout_) {
Andrew T Wilson (Slow) 2012/07/02 15:31:58 I don't get it - why is HandleAttachHandler gettin
peria 2012/07/03 08:06:46 Yes, this method is called a dialog is shown up in
Andrew T Wilson (Slow) 2012/07/03 16:35:05 Your new code still breaks if you get a timeout wh
peria 2012/07/06 06:37:57 I checked with current code (Patch 10), - click "
+ return;
+ }
kochi 2012/07/02 09:34:48 You don't need {} here.
peria 2012/07/03 08:06:46 removed the branch.
+
bool force_login = false;
std::string json;
if (args->GetString(0, &json) && !json.empty()) {
@@ -935,6 +971,9 @@ void SyncSetupHandler::CloseSyncSetup() {
configuring_sync_ = false;
signin_tracker_.reset();
+
+ // Stop a timer to handle timeout in waiting for sync setup.
+ backend_start_timer_.reset();
}
void SyncSetupHandler::OpenSyncSetup(bool force_login) {
« no previous file with comments | « chrome/browser/ui/webui/sync_setup_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698