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

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

Issue 14029006: Properly handle user cancellation of signin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/sync/one_click_signin_helper_unittest.cc ('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 b9bbb54e9d126b2c23fb3fe46163998a405fa8a0..85d8447a9a0a234aba0bfe0bea4a885a7fb6bd32 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -208,6 +208,20 @@ void BringTabToFront(WebContents* web_contents) {
}
}
+void CloseTab(content::WebContents* tab) {
+ Browser* browser = chrome::FindBrowserWithWebContents(tab);
+ if (browser) {
+ TabStripModel* tab_strip_model = browser->tab_strip_model();
+ if (tab_strip_model) {
+ int index = tab_strip_model->GetIndexOfWebContents(tab);
+ if (index != TabStripModel::kNoTab) {
+ tab_strip_model->ExecuteContextMenuCommand(
+ index, TabStripModel::CommandCloseTab);
+ }
+ }
+ }
+}
+
} // namespace
SyncSetupHandler::SyncSetupHandler(ProfileManager* profile_manager)
@@ -1273,22 +1287,16 @@ void SyncSetupHandler::CloseGaiaSigninPage() {
if (active_gaia_signin_tab_) {
content::WebContentsObserver::Observe(NULL);
- Browser* browser = chrome::FindBrowserWithWebContents(
- active_gaia_signin_tab_);
- if (browser) {
- TabStripModel* tab_strip_model = browser->tab_strip_model();
- if (tab_strip_model) {
- int index = tab_strip_model->GetIndexOfWebContents(
- active_gaia_signin_tab_);
- if (index != TabStripModel::kNoTab) {
- tab_strip_model->ExecuteContextMenuCommand(
- index, TabStripModel::CommandCloseTab);
- }
- }
- }
- }
+ // This can be invoked from a webui handler in the GAIA page (for example,
+ // if the user clicks 'cancel' in the enterprise signin dialog), so
+ // closing this tab in mid-handler can cause crashes. Instead, close it
+ // via a task so we know we aren't in the middle of any webui code.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&CloseTab, base::Unretained(active_gaia_signin_tab_)));
- active_gaia_signin_tab_ = NULL;
+ active_gaia_signin_tab_ = NULL;
+ }
}
bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username,
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698