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

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

Issue 579033002: [Clean-up] Remove some dead code for handling Webstore sign-in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 } else { 297 } else {
298 // Perform a redirection to the NTP/Apps page to hide the blank page when 298 // Perform a redirection to the NTP/Apps page to hide the blank page when
299 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when 299 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when
300 // the action is CREATE_NEW_USER because the "Create new user" page might 300 // the action is CREATE_NEW_USER because the "Create new user" page might
301 // be opened in a different tab that is already showing settings. 301 // be opened in a different tab that is already showing settings.
302 if (enable_inline) { 302 if (enable_inline) {
303 // Redirect/tab closing for inline flow is handled by the sync callback. 303 // Redirect/tab closing for inline flow is handled by the sync callback.
304 args.callback.Run(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 304 args.callback.Run(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
305 } else { 305 } else {
306 // Don't redirect when the visible URL is not a blank page: if the 306 // Don't redirect when the visible URL is not a blank page: if the
307 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app 307 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app
Ilya Sherman 2014/09/17 22:42:02 Note: I'm not sure how this comment should be upda
guohui 2014/09/18 21:25:55 i think the comment could be removed, together wit
Ilya Sherman 2014/09/18 21:55:57 Done.
308 // page that shouldn't be hidden. 308 // page that shouldn't be hidden.
309 // 309 //
310 // If redirecting, don't do so immediately, otherwise there may be 2 310 // If redirecting, don't do so immediately, otherwise there may be 2
311 // nested navigations and a crash would occur (crbug.com/293261). Post 311 // nested navigations and a crash would occur (crbug.com/293261). Post
312 // the task to the current thread instead. 312 // the task to the current thread instead.
313 if (signin::IsContinueUrlForWebBasedSigninFlow( 313 if (signin::IsContinueUrlForWebBasedSigninFlow(
314 contents->GetVisibleURL())) { 314 contents->GetVisibleURL())) {
315 base::MessageLoopProxy::current()->PostNonNestableTask( 315 base::MessageLoopProxy::current()->PostNonNestableTask(
316 FROM_HERE, 316 FROM_HERE,
317 base::Bind(RedirectToNtpOrAppsPageWithIds, 317 base::Bind(RedirectToNtpOrAppsPageWithIds,
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 session_index(session_index), 521 session_index(session_index),
522 email(email), 522 email(email),
523 password(password), 523 password(password),
524 refresh_token(refresh_token), 524 refresh_token(refresh_token),
525 web_contents(web_contents), 525 web_contents(web_contents),
526 source(source), 526 source(source),
527 callback(callback) { 527 callback(callback) {
528 DCHECK(session_index.empty() != refresh_token.empty()); 528 DCHECK(session_index.empty() != refresh_token.empty());
529 if (untrusted_confirmation_required) { 529 if (untrusted_confirmation_required) {
530 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; 530 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN;
531 } else if (source == signin::SOURCE_SETTINGS || 531 } else if (source == signin::SOURCE_SETTINGS) {
532 source == signin::SOURCE_WEBSTORE_INSTALL) { 532 // Do not display a status confirmation for re-auth.
533 // Do not display a status confirmation for webstore installs or re-auth.
534 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; 533 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION;
535 } else { 534 } else {
536 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; 535 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
537 } 536 }
538 } 537 }
539 538
540 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {} 539 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {}
541 540
542 // SyncStarterWrapper --------------------------------------------------------- 541 // SyncStarterWrapper ---------------------------------------------------------
543 542
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 one_click_signin::HISTOGRAM_MAX); 719 one_click_signin::HISTOGRAM_MAX);
721 break; 720 break;
722 case signin::SOURCE_SETTINGS: 721 case signin::SOURCE_SETTINGS:
723 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action, 722 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action,
724 one_click_signin::HISTOGRAM_MAX); 723 one_click_signin::HISTOGRAM_MAX);
725 break; 724 break;
726 case signin::SOURCE_EXTENSION_INSTALL_BUBBLE: 725 case signin::SOURCE_EXTENSION_INSTALL_BUBBLE:
727 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action, 726 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action,
728 one_click_signin::HISTOGRAM_MAX); 727 one_click_signin::HISTOGRAM_MAX);
729 break; 728 break;
730 case signin::SOURCE_WEBSTORE_INSTALL:
731 UMA_HISTOGRAM_ENUMERATION("Signin.WebstoreInstallActions", action,
732 one_click_signin::HISTOGRAM_MAX);
733 break;
734 case signin::SOURCE_APP_LAUNCHER: 729 case signin::SOURCE_APP_LAUNCHER:
735 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action, 730 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action,
736 one_click_signin::HISTOGRAM_MAX); 731 one_click_signin::HISTOGRAM_MAX);
737 break; 732 break;
738 case signin::SOURCE_APPS_PAGE_LINK: 733 case signin::SOURCE_APPS_PAGE_LINK:
739 UMA_HISTOGRAM_ENUMERATION("Signin.AppsPageLinkActions", action, 734 UMA_HISTOGRAM_ENUMERATION("Signin.AppsPageLinkActions", action,
740 one_click_signin::HISTOGRAM_MAX); 735 one_click_signin::HISTOGRAM_MAX);
741 break; 736 break;
742 case signin::SOURCE_BOOKMARK_BUBBLE: 737 case signin::SOURCE_BOOKMARK_BUBBLE:
743 UMA_HISTOGRAM_ENUMERATION("Signin.BookmarkBubbleActions", action, 738 UMA_HISTOGRAM_ENUMERATION("Signin.BookmarkBubbleActions", action,
(...skipping 10 matching lines...) Expand all
754 case signin::SOURCE_DEVICES_PAGE: 749 case signin::SOURCE_DEVICES_PAGE:
755 UMA_HISTOGRAM_ENUMERATION("Signin.DevicesPageActions", action, 750 UMA_HISTOGRAM_ENUMERATION("Signin.DevicesPageActions", action,
756 one_click_signin::HISTOGRAM_MAX); 751 one_click_signin::HISTOGRAM_MAX);
757 break; 752 break;
758 case signin::SOURCE_REAUTH: 753 case signin::SOURCE_REAUTH:
759 UMA_HISTOGRAM_ENUMERATION("Signin.ReauthActions", action, 754 UMA_HISTOGRAM_ENUMERATION("Signin.ReauthActions", action,
760 one_click_signin::HISTOGRAM_MAX); 755 one_click_signin::HISTOGRAM_MAX);
761 break; 756 break;
762 default: 757 default:
763 // This switch statement needs to be updated when the enum Source changes. 758 // This switch statement needs to be updated when the enum Source changes.
764 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 13, 759 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 12,
765 kSourceEnumHasChangedButNotThisSwitchStatement); 760 kSourceEnumHasChangedButNotThisSwitchStatement);
766 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action, 761 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action,
767 one_click_signin::HISTOGRAM_MAX); 762 one_click_signin::HISTOGRAM_MAX);
768 } 763 }
769 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, 764 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action,
770 one_click_signin::HISTOGRAM_MAX); 765 one_click_signin::HISTOGRAM_MAX);
771 } 766 }
772 767
773 // static 768 // static
774 void OneClickSigninHelper::CreateForWebContentsWithPasswordManager( 769 void OneClickSigninHelper::CreateForWebContentsWithPasswordManager(
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 content::Referrer(), 1200 content::Referrer(),
1206 CURRENT_TAB, 1201 CURRENT_TAB,
1207 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 1202 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1208 false); 1203 false);
1209 contents->OpenURL(params); 1204 contents->OpenURL(params);
1210 } 1205 }
1211 1206
1212 // static 1207 // static
1213 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( 1208 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(
1214 content::WebContents* contents, signin::Source source) { 1209 content::WebContents* contents, signin::Source source) {
1215 if (source != signin::SOURCE_SETTINGS && 1210 if (source != signin::SOURCE_SETTINGS) {
1216 source != signin::SOURCE_WEBSTORE_INSTALL) {
1217 RedirectToNtpOrAppsPage(contents, source); 1211 RedirectToNtpOrAppsPage(contents, source);
1218 } 1212 }
1219 } 1213 }
1220 1214
1221 void OneClickSigninHelper::RedirectToSignin() { 1215 void OneClickSigninHelper::RedirectToSignin() {
1222 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; 1216 VLOG(1) << "OneClickSigninHelper::RedirectToSignin";
1223 1217
1224 // Extract the existing sounce=X value. Default to "2" if missing. 1218 // Extract the existing sounce=X value. Default to "2" if missing.
1225 signin::Source source = signin::GetSourceForPromoURL(continue_url_); 1219 signin::Source source = signin::GetSourceForPromoURL(continue_url_);
1226 if (source == signin::SOURCE_UNKNOWN) 1220 if (source == signin::SOURCE_UNKNOWN)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 start_mode); 1542 start_mode);
1549 } 1543 }
1550 1544
1551 // If this explicit sign in is not from settings page/webstore, show 1545 // If this explicit sign in is not from settings page/webstore, show
1552 // the NTP/Apps page after sign in completes. In the case of the 1546 // the NTP/Apps page after sign in completes. In the case of the
1553 // settings page, it will get auto-closed after sync setup. In the case 1547 // settings page, it will get auto-closed after sync setup. In the case
1554 // of webstore, it will redirect back to webstore. 1548 // of webstore, it will redirect back to webstore.
1555 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); 1549 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_);
1556 } 1550 }
1557 1551
1558 // Observe the sync service if the Webstore tab or the settings tab 1552 // Observe the sync service if the settings tab requested a gaia sign in,
1559 // requested a gaia sign in, so that when sign in and sync setup are 1553 // so that when sign in and sync setup are successful, we can redirect to
1560 // successful, we can redirect to the correct URL, or auto-close the gaia 1554 // the correct URL, or auto-close the gaia sign in tab.
1561 // sign in tab. 1555 if (original_source == signin::SOURCE_SETTINGS) {
1562 if (original_source == signin::SOURCE_SETTINGS ||
1563 (original_source == signin::SOURCE_WEBSTORE_INSTALL &&
1564 source_ == signin::SOURCE_SETTINGS)) {
1565 // The observer deletes itself once it's done. 1556 // The observer deletes itself once it's done.
1566 new OneClickSigninSyncObserver(contents, original_continue_url_); 1557 new OneClickSigninSyncObserver(contents, original_continue_url_);
guohui 2014/09/18 21:25:55 i think original_continue_url was added for websto
Ilya Sherman 2014/09/18 21:55:57 I think you might be right, but I'm not 100% certa
1567 } 1558 }
1568 break; 1559 break;
1569 } 1560 }
1570 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: 1561 case AUTO_ACCEPT_REJECTED_FOR_PROFILE:
1571 AddEmailToOneClickRejectedList(profile, email_); 1562 AddEmailToOneClickRejectedList(profile, email_);
1572 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); 1563 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED);
1573 break; 1564 break;
1574 default: 1565 default:
1575 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; 1566 NOTREACHED() << "Invalid auto_accept=" << auto_accept_;
1576 break; 1567 break;
(...skipping 20 matching lines...) Expand all
1597 // If the web contents is showing a blank page and not about to be closed, 1588 // If the web contents is showing a blank page and not about to be closed,
1598 // redirect to the NTP or apps page. 1589 // redirect to the NTP or apps page.
1599 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1590 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1600 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1591 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1601 RedirectToNtpOrAppsPage( 1592 RedirectToNtpOrAppsPage(
1602 web_contents(), 1593 web_contents(),
1603 signin::GetSourceForPromoURL(original_continue_url_)); 1594 signin::GetSourceForPromoURL(original_continue_url_));
1604 } 1595 }
1605 } 1596 }
1606 } 1597 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/signin_promo_unittest.cc ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698