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

Side by Side Diff: chrome/browser/ui/webui/inline_login_ui.cc

Issue 116543007: Add cross account error detection to inline signin (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years 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.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/inline_login_ui.h" 5 #include "chrome/browser/ui/webui/inline_login_ui.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 sync_service && sync_service->HasSyncSetupCompleted()) ? 293 sync_service && sync_service->HasSyncSetupCompleted()) ?
294 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : 294 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE :
295 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : 295 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST :
296 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; 296 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS;
297 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required = 297 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required =
298 source == signin::SOURCE_SETTINGS || 298 source == signin::SOURCE_SETTINGS ||
299 source == signin::SOURCE_WEBSTORE_INSTALL || 299 source == signin::SOURCE_WEBSTORE_INSTALL ||
300 choose_what_to_sync_? 300 choose_what_to_sync_?
301 OneClickSigninSyncStarter::NO_CONFIRMATION : 301 OneClickSigninSyncStarter::NO_CONFIRMATION :
302 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; 302 OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
303 // Call OneClickSigninSyncStarter to exchange oauth code for tokens. 303 OneClickSigninSyncStarter::Callback sync_callback = base::Bind(
304 // OneClickSigninSyncStarter will delete itself once the job is done. 304 &InlineLoginUIHandler::SyncStarterCallback,
305 new OneClickSigninSyncStarter( 305 weak_factory_.GetWeakPtr());
306 profile_, NULL, "" /* session_index, not used */, 306
307 email_, password_, oauth_code, 307 bool cross_account_error_handled =
308 start_mode, 308 OneClickSigninHelper::HandleCrossAccountError(
309 contents, 309 contents, "" /* session_index, not used */,
310 confirmation_required, 310 email_, password_, oauth_code,
311 base::Bind(&InlineLoginUIHandler::SyncStarterCallback, 311 OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT,
312 weak_factory_.GetWeakPtr())); 312 source, start_mode, sync_callback);
313
314 if (!cross_account_error_handled) {
315 // Call OneClickSigninSyncStarter to exchange oauth code for tokens.
316 // OneClickSigninSyncStarter will delete itself once the job is done.
317 new OneClickSigninSyncStarter(
318 profile_, NULL, "" /* session_index, not used */,
319 email_, password_, oauth_code,
320 start_mode,
321 contents,
322 confirmation_required,
323 sync_callback);
324 }
313 } 325 }
314 326
315 email_.clear(); 327 email_.clear();
316 password_.clear(); 328 password_.clear();
317 web_ui()->CallJavascriptFunction("inline.login.closeDialog"); 329 web_ui()->CallJavascriptFunction("inline.login.closeDialog");
318 #endif // OS_CHROMEOS 330 #endif // OS_CHROMEOS
319 } 331 }
320 332
321 // GaiaAuthConsumer override. 333 // GaiaAuthConsumer override.
322 virtual void OnClientOAuthCodeFailure(const GoogleServiceAuthError& error) 334 virtual void OnClientOAuthCodeFailure(const GoogleServiceAuthError& error)
(...skipping 17 matching lines...) Expand all
340 if (browser) 352 if (browser)
341 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg); 353 OneClickSigninHelper::ShowSigninErrorBubble(browser, error_msg);
342 354
343 email_.clear(); 355 email_.clear();
344 password_.clear(); 356 password_.clear();
345 } 357 }
346 358
347 void SyncStarterCallback(OneClickSigninSyncStarter::SyncSetupResult result) { 359 void SyncStarterCallback(OneClickSigninSyncStarter::SyncSetupResult result) {
348 content::WebContents* contents = web_ui()->GetWebContents(); 360 content::WebContents* contents = web_ui()->GetWebContents();
349 const GURL& current_url = contents->GetURL(); 361 const GURL& current_url = contents->GetURL();
350 bool auto_close = signin::IsAutoCloseEnabledInURL(current_url); 362
351 signin::Source source = signin::GetSourceForPromoURL(current_url); 363 if (signin::IsAutoCloseEnabledInURL(current_url)) {
352 if (auto_close) {
353 base::MessageLoop::current()->PostTask( 364 base::MessageLoop::current()->PostTask(
354 FROM_HERE, 365 FROM_HERE,
355 base::Bind( 366 base::Bind(
356 &InlineLoginUIHandler::CloseTab, weak_factory_.GetWeakPtr())); 367 &InlineLoginUIHandler::CloseTab, weak_factory_.GetWeakPtr()));
357 return; 368 } else {
369 signin::Source source = signin::GetSourceForPromoURL(current_url);
370 DCHECK(source != signin::SOURCE_UNKNOWN);
371 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(
372 contents, source);
358 } 373 }
359
360 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(contents, source);
361 } 374 }
362 375
363 void CloseTab() { 376 void CloseTab() {
364 content::WebContents* tab = web_ui()->GetWebContents(); 377 content::WebContents* tab = web_ui()->GetWebContents();
365 Browser* browser = chrome::FindBrowserWithWebContents(tab); 378 Browser* browser = chrome::FindBrowserWithWebContents(tab);
366 if (browser) { 379 if (browser) {
367 TabStripModel* tab_strip_model = browser->tab_strip_model(); 380 TabStripModel* tab_strip_model = browser->tab_strip_model();
368 if (tab_strip_model) { 381 if (tab_strip_model) {
369 int index = tab_strip_model->GetIndexOfWebContents(tab); 382 int index = tab_strip_model->GetIndexOfWebContents(tab);
370 if (index != TabStripModel::kNoTab) { 383 if (index != TabStripModel::kNoTab) {
(...skipping 30 matching lines...) Expand all
401 content::WebUIDataSource::Add(profile, CreateWebUIDataSource()); 414 content::WebUIDataSource::Add(profile, CreateWebUIDataSource());
402 415
403 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile)); 416 web_ui->AddMessageHandler(new InlineLoginUIHandler(profile));
404 // Required for intercepting extension function calls when the page is loaded 417 // Required for intercepting extension function calls when the page is loaded
405 // in a bubble (not a full tab, thus tab helpers are not registered 418 // in a bubble (not a full tab, thus tab helpers are not registered
406 // automatically). 419 // automatically).
407 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); 420 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents());
408 } 421 }
409 422
410 InlineLoginUI::~InlineLoginUI() {} 423 InlineLoginUI::~InlineLoginUI() {}
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698