summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 18:48:25 +0000
committerrsimha@chromium.org <rsimha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-23 18:48:25 +0000
commit9dc828562c2e5cb8c7df4a66844647a677bda85b (patch)
tree7e73bfa33e841842333eed18af0784a8f2a64d67
parentea6d54eba85b0191d9975297e217ff9c7e277c17 (diff)
downloadchromium_src-9dc828562c2e5cb8c7df4a66844647a677bda85b.zip
chromium_src-9dc828562c2e5cb8c7df4a66844647a677bda85b.tar.gz
chromium_src-9dc828562c2e5cb8c7df4a66844647a677bda85b.tar.bz2
[sync] Close duplicate overlay if user opens settings/syncSetup twice
If the user brings up the advanced sync settings page in a tab, and then attempts to bring it up in another tab by directly navigating to chrome://settings/syncSetup, we are supposed to transfer focus to the first instance of the dialog because it is possible to register only one instance of SyncSetupHandler as the handler of messages from the UI layer. However, before transfering focus to the original sync setup overlay, we neglect to close the blank sync setup overlay in the second tab. This patch adds logic to HandleShowSyncSetupUI to check if there is already an existing sync setup dialog in a different tab, and if so, it clsoes the blank overlay in the duplicate tab before transfering focus to the original sync setup dialog. BUG=261566 TEST=Open sync settings, and then navigate to settings/syncSetup in another tab. Focus should be transferred back to the first tab, and overlays should be closed on the second tab. Review URL: https://chromiumcodereview.appspot.com/19846008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213179 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc22
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.h3
2 files changed, 22 insertions, 3 deletions
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 491b60a..07fb346 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -735,7 +735,15 @@ void SyncSetupHandler::HandleShowSetupUI(const ListValue* args) {
return;
}
- // Bring up the existing wizard, or just display it on this page.
+ // If a setup wizard is already present, but not on this page, close the
+ // blank setup overlay on this page. This can happen if the user navigates to
+ // chrome://settings/syncSetup in more than one tab. See crbug.com/261566.
+ // Note: The following block will transfer focus to the existing wizard.
+ if (IsExistingWizardPresent() && !IsActiveLogin())
+ CloseOverlay();
+
+ // If a setup wizard is present on this page or another, bring it to focus.
+ // Otherwise, display a new one on this page.
if (!FocusExistingWizardIfPresent())
OpenSyncSetup();
}
@@ -880,10 +888,18 @@ void SyncSetupHandler::CloseUI() {
CloseOverlay();
}
-bool SyncSetupHandler::FocusExistingWizardIfPresent() {
+bool SyncSetupHandler::IsExistingWizardPresent() {
LoginUIService* service = GetLoginUIService();
- if (!service->current_login_ui())
+ DCHECK(service);
+ return service->current_login_ui() != NULL;
+}
+
+bool SyncSetupHandler::FocusExistingWizardIfPresent() {
+ if (!IsExistingWizardPresent())
return false;
+
+ LoginUIService* service = GetLoginUIService();
+ DCHECK(service);
service->current_login_ui()->FocusUI();
return true;
}
diff --git a/chrome/browser/ui/webui/sync_setup_handler.h b/chrome/browser/ui/webui/sync_setup_handler.h
index 2f562ac..574bb28 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.h
+++ b/chrome/browser/ui/webui/sync_setup_handler.h
@@ -141,6 +141,9 @@ class SyncSetupHandler : public options::OptionsPageUIHandler,
// Returns true if this object is the active login object.
bool IsActiveLogin() const;
+ // If a wizard already exists, return true. Otherwise, return false.
+ bool IsExistingWizardPresent();
+
// If a wizard already exists, focus it and return true.
bool FocusExistingWizardIfPresent();