summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorperia@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-27 10:33:15 +0000
committerperia@chromium.org <peria@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-27 10:33:15 +0000
commit9bc48646f77da626baf7f1f1aed4ccc7db3a4ea6 (patch)
tree7e603f73756b288588b61acecf0c5db8e6ccf7c3
parent5c2a198b6d137e3698af4ac3224575e789032510 (diff)
downloadchromium_src-9bc48646f77da626baf7f1f1aed4ccc7db3a4ea6.zip
chromium_src-9bc48646f77da626baf7f1f1aed4ccc7db3a4ea6.tar.gz
chromium_src-9bc48646f77da626baf7f1f1aed4ccc7db3a4ea6.tar.bz2
On timeout of setting up sync, show a dialog to tell users the task longer time than expected and to enable them to close spinner window.
BUG=128692 TEST=manually Review URL: https://chromiumcodereview.appspot.com/10539128 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148740 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd8
-rw-r--r--chrome/browser/resources/sync_setup_overlay.html9
-rw-r--r--chrome/browser/resources/sync_setup_overlay.js11
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc44
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.h11
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler_unittest.cc3
6 files changed, 84 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 8f2051a..97db9ce9 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -11956,6 +11956,14 @@ Some features may be unavailable. Please check that the profile exists and you
OK, sync everything
</message>
+ <!-- Notify network connection goes time out -->
+ <message name="IDS_SYNC_SETUP_TIME_OUT_TITLE" desc="The title of the 'Timeout' page for sync settings.">
+ Failed to start up the sync backend
+ </message>
+ <message name="IDS_SYNC_SETUP_TIME_OUT_CONTENT" desc="Text explaining what to do if sync times out.">
+ Please make sure your network connection is working and if the problem persists, please sign out and sign in again to refresh your credentials.
+ </message>
+
<!-- Choose data types dialog strings -->
<message name="IDS_CUSTOMIZE_SYNC_DESCRIPTION" desc="The first line of the Customize Sync dialog, explaining what this box does.">
Sync the following items automatically:
diff --git a/chrome/browser/resources/sync_setup_overlay.html b/chrome/browser/resources/sync_setup_overlay.html
index fa036b4..6a69fc3 100644
--- a/chrome/browser/resources/sync_setup_overlay.html
+++ b/chrome/browser/resources/sync_setup_overlay.html
@@ -286,7 +286,7 @@
<a i18n-values="href:encryptionHelpURL" target="_blank"
i18n-content="learnMore"></a>
</div>
- <div id="sync-custom-passphrase"
+ <div id="sync-custom-passphrase"
class="reset-hidden" hidden>
<div id="sync-passphrase-message">
<span i18n-content="sectionExplicitMessagePrefix"></span>
@@ -361,6 +361,13 @@
<input id="sync-spinner-cancel" type="button" i18n-values="value:cancel">
</div>
</div>
+ <div id="sync-setup-timeout" hidden>
+ <h1 i18n-content="syncSetupTimeoutTitle"></h1>
+ <span i18n-content="syncSetupTimeoutContent" class="content-area"></span>
+ <div class="action-area button-strip">
+ <button id="timeout-ok" i18n-content="ok"></button>
+ </div>
+ </div>
<div id="sync-setup-stop-syncing" hidden>
<h1 i18n-content="stopSyncingTitle"></h1>
<div class="content-area">
diff --git a/chrome/browser/resources/sync_setup_overlay.js b/chrome/browser/resources/sync_setup_overlay.js
index 865bcd9..d2feb8b 100644
--- a/chrome/browser/resources/sync_setup_overlay.js
+++ b/chrome/browser/resources/sync_setup_overlay.js
@@ -64,6 +64,10 @@ cr.define('options', function() {
$('confirm-everything-ok').onclick = function() {
self.sendConfiguration_();
};
+ $('timeout-ok').onclick = function() {
+ chrome.send('CloseTimeout');
+ self.closeOverlay_();
+ };
$('stop-syncing-ok').onclick = function() {
chrome.send('SyncSetupStopSyncing');
self.closeOverlay_();
@@ -416,6 +420,11 @@ cr.define('options', function() {
this.setThrobbersVisible_(true);
},
+ showTimeoutPage_: function() {
+ this.resetPage_('sync-setup-timeout');
+ $('sync-setup-timeout').hidden = false;
+ },
+
showSyncEverythingPage_: function() {
$('confirm-sync-preferences').hidden = false;
$('customize-sync-preferences').hidden = true;
@@ -544,6 +553,8 @@ cr.define('options', function() {
this.showConfigure_(args);
else if (page == 'spinner')
this.showSpinner_();
+ else if (page == 'timeout')
+ this.showTimeoutPage_();
},
/**
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index e334eb1..b680a7d 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -285,6 +285,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 },
@@ -487,6 +489,9 @@ void SyncSetupHandler::RegisterMessages() {
"SyncSetupDoSignOutOnAuthError",
base::Bind(&SyncSetupHandler::HandleDoSignOutOnAuthError,
base::Unretained(this)));
+ web_ui()->RegisterMessageCallback("CloseTimeout",
+ base::Bind(&SyncSetupHandler::HandleCloseTimeout,
+ base::Unretained(this)));
web_ui()->RegisterMessageCallback("SyncSetupStopSyncing",
base::Bind(&SyncSetupHandler::HandleStopSyncing,
base::Unretained(this)));
@@ -591,6 +596,29 @@ 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 a timer to handle timeout in waiting for checking network connection.
+ backend_start_timer_.reset();
+
+ // Do not listen to signin events.
+ signin_tracker_.reset();
+
+ StringValue page("timeout");
+ DictionaryValue args;
web_ui()->CallJavascriptFunction(
"SyncSetupOverlay.showSyncSetupPage", page, args);
}
@@ -717,6 +745,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).
@@ -741,6 +772,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.
@@ -900,6 +934,10 @@ void SyncSetupHandler::HandleStopSyncing(const ListValue* args) {
}
}
+void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) {
+ CloseSyncSetup();
+}
+
void SyncSetupHandler::CloseSyncSetup() {
// TODO(atwilson): Move UMA tracking of signin events out of sync module.
ProfileSyncService* sync_service = GetSyncService();
@@ -943,6 +981,9 @@ void SyncSetupHandler::CloseSyncSetup() {
configuring_sync_ = false;
signin_tracker_.reset();
+
+ // Stop a timer to handle timeout in waiting for checking network connection.
+ backend_start_timer_.reset();
}
void SyncSetupHandler::OpenSyncSetup(bool force_login) {
@@ -1012,6 +1053,9 @@ LoginUIService* SyncSetupHandler::GetLoginUIService() const {
}
void SyncSetupHandler::CloseOverlay() {
+ // Stop a timer to handle timeout in waiting for sync setup.
+ backend_start_timer_.reset();
+
CloseSyncSetup();
web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay");
}
diff --git a/chrome/browser/ui/webui/sync_setup_handler.h b/chrome/browser/ui/webui/sync_setup_handler.h
index b2505d0..d319476 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.h
+++ b/chrome/browser/ui/webui/sync_setup_handler.h
@@ -7,6 +7,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/timer.h"
#include "chrome/browser/signin/signin_tracker.h"
#include "chrome/browser/ui/webui/options2/options_ui.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
@@ -109,6 +110,7 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler,
void HandleShowSetupUIWithoutLogin(const base::ListValue* args);
void HandleDoSignOutOnAuthError(const base::ListValue* args);
void HandleStopSyncing(const base::ListValue* args);
+ void HandleCloseTimeout(const base::ListValue* args);
// Helper routine that gets the Profile associated with this object (virtual
// so tests can override).
@@ -141,7 +143,10 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler,
// is running in the background.
void DisplaySpinner();
- // Returns true if this is the active login object.
+ // Displays an error dialog which shows timeout of starting the sync backend.
+ void DisplayTimeout();
+
+ // Returns true if this object is the active login object.
bool IsActiveLogin() const;
// Initiates a login via the signin manager.
@@ -192,6 +197,10 @@ class SyncSetupHandler : public options2::OptionsPageUIHandler,
// When setup starts without login UI, do not retry login and fail.
bool retry_on_signin_failure_;
+ // The OneShotTimer object used to timeout of starting the sync backend
+ // service.
+ scoped_ptr<base::OneShotTimer<SyncSetupHandler> > backend_start_timer_;
+
DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler);
};
diff --git a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
index f8ac644..ae1b4be 100644
--- a/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler_unittest.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/memory/scoped_ptr.h"
+#include "base/message_loop.h"
#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/prefs/pref_service.h"
@@ -421,6 +422,8 @@ class SyncSetupHandlerTest : public testing::TestWithParam<bool> {
scoped_ptr<Profile> profile_;
ProfileSyncServiceMock* mock_pss_;
GoogleServiceAuthError error_;
+ // MessageLoop instance is required to work with OneShotTimer.
+ MessageLoop message_loop_;
SigninManagerMock* mock_signin_;
TestWebUI web_ui_;
scoped_ptr<TestingSyncSetupHandler> handler_;