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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 99913004: Add error handling to inline signin flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: roger's comments fixed 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
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/sync/one_click_signin_helper.h" 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 int route_id, 358 int route_id,
359 signin::Source source) { 359 signin::Source source) {
360 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, 360 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id,
361 route_id); 361 route_id);
362 if (!web_contents) 362 if (!web_contents)
363 return; 363 return;
364 364
365 RedirectToNtpOrAppsPage(web_contents, source); 365 RedirectToNtpOrAppsPage(web_contents, source);
366 } 366 }
367 367
368 // If the |source| is not settings page/webstore, redirects to
369 // the NTP/Apps page.
370 void RedirectToNtpOrAppsPageIfNecessary(content::WebContents* contents,
371 signin::Source source) {
372 if (source != signin::SOURCE_SETTINGS &&
373 source != signin::SOURCE_WEBSTORE_INSTALL) {
374 RedirectToNtpOrAppsPage(contents, source);
375 }
376 }
377
378 // Start syncing with the given user information. 368 // Start syncing with the given user information.
379 void StartSync(const StartSyncArgs& args, 369 void StartSync(const StartSyncArgs& args,
380 OneClickSigninSyncStarter::StartSyncMode start_mode) { 370 OneClickSigninSyncStarter::StartSyncMode start_mode) {
381 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { 371 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) {
382 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); 372 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO);
383 return; 373 return;
384 } 374 }
385 375
386 // The starter deletes itself once its done. 376 // The starter deletes itself once its done.
387 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, 377 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index,
(...skipping 24 matching lines...) Expand all
412 if (action != one_click_signin::HISTOGRAM_MAX) 402 if (action != one_click_signin::HISTOGRAM_MAX)
413 LogOneClickHistogramValue(action); 403 LogOneClickHistogramValue(action);
414 } 404 }
415 405
416 void StartExplicitSync(const StartSyncArgs& args, 406 void StartExplicitSync(const StartSyncArgs& args,
417 content::WebContents* contents, 407 content::WebContents* contents,
418 OneClickSigninSyncStarter::StartSyncMode start_mode, 408 OneClickSigninSyncStarter::StartSyncMode start_mode,
419 ConfirmEmailDialogDelegate::Action action) { 409 ConfirmEmailDialogDelegate::Action action) {
420 if (action == ConfirmEmailDialogDelegate::START_SYNC) { 410 if (action == ConfirmEmailDialogDelegate::START_SYNC) {
421 StartSync(args, start_mode); 411 StartSync(args, start_mode);
422 RedirectToNtpOrAppsPageIfNecessary(contents, args.source); 412 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(
413 contents, args.source);
423 } else { 414 } else {
424 // Perform a redirection to the NTP/Apps page to hide the blank page when 415 // Perform a redirection to the NTP/Apps page to hide the blank page when
425 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when 416 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when
426 // the action is CREATE_NEW_USER because the "Create new user" page might 417 // the action is CREATE_NEW_USER because the "Create new user" page might
427 // be opened in a different tab that is already showing settings. 418 // be opened in a different tab that is already showing settings.
428 // 419 //
429 // Don't redirect when the visible URL is not a blank page: if the 420 // Don't redirect when the visible URL is not a blank page: if the
430 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app 421 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app
431 // page that shouldn't be hidden. 422 // page that shouldn't be hidden.
432 // 423 //
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // static 1012 // static
1022 void OneClickSigninHelper::RemoveSigninRedirectURLHistoryItem( 1013 void OneClickSigninHelper::RemoveSigninRedirectURLHistoryItem(
1023 content::WebContents* web_contents) { 1014 content::WebContents* web_contents) {
1024 // Only actually remove the item if it's the blank.html continue url. 1015 // Only actually remove the item if it's the blank.html continue url.
1025 if (signin::IsContinueUrlForWebBasedSigninFlow( 1016 if (signin::IsContinueUrlForWebBasedSigninFlow(
1026 web_contents->GetLastCommittedURL())) { 1017 web_contents->GetLastCommittedURL())) {
1027 new CurrentHistoryCleaner(web_contents); // will self-destruct when done 1018 new CurrentHistoryCleaner(web_contents); // will self-destruct when done
1028 } 1019 }
1029 } 1020 }
1030 1021
1022 // static
1031 void OneClickSigninHelper::ShowSigninErrorBubble(Browser* browser, 1023 void OneClickSigninHelper::ShowSigninErrorBubble(Browser* browser,
1032 const std::string& error) { 1024 const std::string& error) {
1033 DCHECK(!error.empty()); 1025 DCHECK(!error.empty());
1034 1026
1035 browser->window()->ShowOneClickSigninBubble( 1027 browser->window()->ShowOneClickSigninBubble(
1036 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, 1028 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
1037 string16(), /* no SAML email */ 1029 string16(), /* no SAML email */
1038 UTF8ToUTF16(error), 1030 UTF8ToUTF16(error),
1039 // This callback is never invoked. 1031 // This callback is never invoked.
1040 // TODO(rogerta): Separate out the bubble API so we don't have to pass 1032 // TODO(rogerta): Separate out the bubble API so we don't have to pass
1041 // ignored |email| and |callback| params. 1033 // ignored |email| and |callback| params.
1042 BrowserWindow::StartSyncCallback()); 1034 BrowserWindow::StartSyncCallback());
1043 } 1035 }
1044 1036
1037 // static
1038 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(
1039 content::WebContents* contents, signin::Source source) {
1040 if (source != signin::SOURCE_SETTINGS &&
1041 source != signin::SOURCE_WEBSTORE_INSTALL) {
1042 RedirectToNtpOrAppsPage(contents, source);
1043 }
1044 }
1045
1045 void OneClickSigninHelper::RedirectToSignin() { 1046 void OneClickSigninHelper::RedirectToSignin() {
1046 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; 1047 VLOG(1) << "OneClickSigninHelper::RedirectToSignin";
1047 1048
1048 // Extract the existing sounce=X value. Default to "2" if missing. 1049 // Extract the existing sounce=X value. Default to "2" if missing.
1049 signin::Source source = signin::GetSourceForPromoURL(continue_url_); 1050 signin::Source source = signin::GetSourceForPromoURL(continue_url_);
1050 if (source == signin::SOURCE_UNKNOWN) 1051 if (source == signin::SOURCE_UNKNOWN)
1051 source = signin::SOURCE_MENU; 1052 source = signin::SOURCE_MENU;
1052 GURL page = signin::GetPromoURL(source, false); 1053 GURL page = signin::GetPromoURL(source, false);
1053 1054
1054 content::WebContents* contents = web_contents(); 1055 content::WebContents* contents = web_contents();
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 // If the web contents is showing a blank page and not about to be closed, 1480 // If the web contents is showing a blank page and not about to be closed,
1480 // redirect to the NTP or apps page. 1481 // redirect to the NTP or apps page.
1481 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1482 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1482 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1483 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1483 RedirectToNtpOrAppsPage( 1484 RedirectToNtpOrAppsPage(
1484 web_contents(), 1485 web_contents(),
1485 signin::GetSourceForPromoURL(original_continue_url_)); 1486 signin::GetSourceForPromoURL(original_continue_url_));
1486 } 1487 }
1487 } 1488 }
1488 } 1489 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698