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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 if (browser) { 201 if (browser) {
202 TabStripModel* tab_strip_model = browser->tab_strip_model(); 202 TabStripModel* tab_strip_model = browser->tab_strip_model();
203 if (tab_strip_model) { 203 if (tab_strip_model) {
204 int index = tab_strip_model->GetIndexOfWebContents(web_contents); 204 int index = tab_strip_model->GetIndexOfWebContents(web_contents);
205 if (index != TabStripModel::kNoTab) 205 if (index != TabStripModel::kNoTab)
206 tab_strip_model->ActivateTabAt(index, false); 206 tab_strip_model->ActivateTabAt(index, false);
207 } 207 }
208 } 208 }
209 } 209 }
210 210
211 void CloseTab(content::WebContents* tab) {
212 Browser* browser = chrome::FindBrowserWithWebContents(tab);
213 if (browser) {
214 TabStripModel* tab_strip_model = browser->tab_strip_model();
215 if (tab_strip_model) {
216 int index = tab_strip_model->GetIndexOfWebContents(tab);
217 if (index != TabStripModel::kNoTab) {
218 tab_strip_model->ExecuteContextMenuCommand(
219 index, TabStripModel::CommandCloseTab);
220 }
221 }
222 }
223 }
224
211 } // namespace 225 } // namespace
212 226
213 SyncSetupHandler::SyncSetupHandler(ProfileManager* profile_manager) 227 SyncSetupHandler::SyncSetupHandler(ProfileManager* profile_manager)
214 : configuring_sync_(false), 228 : configuring_sync_(false),
215 profile_manager_(profile_manager), 229 profile_manager_(profile_manager),
216 last_signin_error_(GoogleServiceAuthError::NONE), 230 last_signin_error_(GoogleServiceAuthError::NONE),
217 retry_on_signin_failure_(true), 231 retry_on_signin_failure_(true),
218 active_gaia_signin_tab_(NULL) { 232 active_gaia_signin_tab_(NULL) {
219 } 233 }
220 234
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 backend_start_timer_.reset(); 1280 backend_start_timer_.reset();
1267 1281
1268 CloseSyncSetup(); 1282 CloseSyncSetup();
1269 web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay"); 1283 web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay");
1270 } 1284 }
1271 1285
1272 void SyncSetupHandler::CloseGaiaSigninPage() { 1286 void SyncSetupHandler::CloseGaiaSigninPage() {
1273 if (active_gaia_signin_tab_) { 1287 if (active_gaia_signin_tab_) {
1274 content::WebContentsObserver::Observe(NULL); 1288 content::WebContentsObserver::Observe(NULL);
1275 1289
1276 Browser* browser = chrome::FindBrowserWithWebContents( 1290 // This can be invoked from a webui handler in the GAIA page (for example,
1277 active_gaia_signin_tab_); 1291 // if the user clicks 'cancel' in the enterprise signin dialog), so
1278 if (browser) { 1292 // closing this tab in mid-handler can cause crashes. Instead, close it
1279 TabStripModel* tab_strip_model = browser->tab_strip_model(); 1293 // via a task so we know we aren't in the middle of any webui code.
1280 if (tab_strip_model) { 1294 MessageLoop::current()->PostTask(
1281 int index = tab_strip_model->GetIndexOfWebContents( 1295 FROM_HERE,
1282 active_gaia_signin_tab_); 1296 base::Bind(&CloseTab, base::Unretained(active_gaia_signin_tab_)));
1283 if (index != TabStripModel::kNoTab) { 1297
1284 tab_strip_model->ExecuteContextMenuCommand( 1298 active_gaia_signin_tab_ = NULL;
1285 index, TabStripModel::CommandCloseTab);
1286 }
1287 }
1288 }
1289 } 1299 }
1290
1291 active_gaia_signin_tab_ = NULL;
1292 } 1300 }
1293 1301
1294 bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username, 1302 bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username,
1295 string16* error_message) { 1303 string16* error_message) {
1296 if (username.empty()) 1304 if (username.empty())
1297 return true; 1305 return true;
1298 1306
1299 // Can be null during some unit tests. 1307 // Can be null during some unit tests.
1300 if (!web_ui()) 1308 if (!web_ui())
1301 return true; 1309 return true;
(...skipping 17 matching lines...) Expand all
1319 if (i != current_profile_index && AreUserNamesEqual( 1327 if (i != current_profile_index && AreUserNamesEqual(
1320 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { 1328 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) {
1321 *error_message = l10n_util::GetStringUTF16( 1329 *error_message = l10n_util::GetStringUTF16(
1322 IDS_SYNC_USER_NAME_IN_USE_ERROR); 1330 IDS_SYNC_USER_NAME_IN_USE_ERROR);
1323 return false; 1331 return false;
1324 } 1332 }
1325 } 1333 }
1326 1334
1327 return true; 1335 return true;
1328 } 1336 }
OLDNEW
« 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