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

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: Restore incorrectly deleted code 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
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 // Redirect, but don't do so immediately; otherwise there might be two
307 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app 307 // nested navigations, which would cause a crash: http://crbug.com/293261
308 // page that shouldn't be hidden. 308 // Instead, post a task to the current thread.
309 // 309 base::MessageLoopProxy::current()->PostNonNestableTask(
310 // If redirecting, don't do so immediately, otherwise there may be 2 310 FROM_HERE,
311 // nested navigations and a crash would occur (crbug.com/293261). Post 311 base::Bind(RedirectToNtpOrAppsPageWithIds,
312 // the task to the current thread instead. 312 contents->GetRenderProcessHost()->GetID(),
313 if (signin::IsContinueUrlForWebBasedSigninFlow( 313 contents->GetRoutingID(),
314 contents->GetVisibleURL())) { 314 args.source));
315 base::MessageLoopProxy::current()->PostNonNestableTask(
316 FROM_HERE,
317 base::Bind(RedirectToNtpOrAppsPageWithIds,
318 contents->GetRenderProcessHost()->GetID(),
319 contents->GetRoutingID(),
320 args.source));
321 }
322 } 315 }
323 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { 316 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) {
324 chrome::ShowSettingsSubPage(args.browser, 317 chrome::ShowSettingsSubPage(args.browser,
325 std::string(chrome::kCreateProfileSubPage)); 318 std::string(chrome::kCreateProfileSubPage));
326 } 319 }
327 } 320 }
328 } 321 }
329 322
330 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { 323 void ClearPendingEmailOnIOThread(content::ResourceContext* context) {
331 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 324 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 session_index(session_index), 514 session_index(session_index),
522 email(email), 515 email(email),
523 password(password), 516 password(password),
524 refresh_token(refresh_token), 517 refresh_token(refresh_token),
525 web_contents(web_contents), 518 web_contents(web_contents),
526 source(source), 519 source(source),
527 callback(callback) { 520 callback(callback) {
528 DCHECK(session_index.empty() != refresh_token.empty()); 521 DCHECK(session_index.empty() != refresh_token.empty());
529 if (untrusted_confirmation_required) { 522 if (untrusted_confirmation_required) {
530 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; 523 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN;
531 } else if (source == signin::SOURCE_SETTINGS || 524 } else if (source == signin::SOURCE_SETTINGS) {
532 source == signin::SOURCE_WEBSTORE_INSTALL) { 525 // 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; 526 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION;
535 } else { 527 } else {
536 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; 528 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN;
537 } 529 }
538 } 530 }
539 531
540 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {} 532 OneClickSigninHelper::StartSyncArgs::~StartSyncArgs() {}
541 533
542 // SyncStarterWrapper --------------------------------------------------------- 534 // SyncStarterWrapper ---------------------------------------------------------
543 535
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 one_click_signin::HISTOGRAM_MAX); 712 one_click_signin::HISTOGRAM_MAX);
721 break; 713 break;
722 case signin::SOURCE_SETTINGS: 714 case signin::SOURCE_SETTINGS:
723 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action, 715 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action,
724 one_click_signin::HISTOGRAM_MAX); 716 one_click_signin::HISTOGRAM_MAX);
725 break; 717 break;
726 case signin::SOURCE_EXTENSION_INSTALL_BUBBLE: 718 case signin::SOURCE_EXTENSION_INSTALL_BUBBLE:
727 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action, 719 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action,
728 one_click_signin::HISTOGRAM_MAX); 720 one_click_signin::HISTOGRAM_MAX);
729 break; 721 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: 722 case signin::SOURCE_APP_LAUNCHER:
735 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action, 723 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action,
736 one_click_signin::HISTOGRAM_MAX); 724 one_click_signin::HISTOGRAM_MAX);
737 break; 725 break;
738 case signin::SOURCE_APPS_PAGE_LINK: 726 case signin::SOURCE_APPS_PAGE_LINK:
739 UMA_HISTOGRAM_ENUMERATION("Signin.AppsPageLinkActions", action, 727 UMA_HISTOGRAM_ENUMERATION("Signin.AppsPageLinkActions", action,
740 one_click_signin::HISTOGRAM_MAX); 728 one_click_signin::HISTOGRAM_MAX);
741 break; 729 break;
742 case signin::SOURCE_BOOKMARK_BUBBLE: 730 case signin::SOURCE_BOOKMARK_BUBBLE:
743 UMA_HISTOGRAM_ENUMERATION("Signin.BookmarkBubbleActions", action, 731 UMA_HISTOGRAM_ENUMERATION("Signin.BookmarkBubbleActions", action,
(...skipping 10 matching lines...) Expand all
754 case signin::SOURCE_DEVICES_PAGE: 742 case signin::SOURCE_DEVICES_PAGE:
755 UMA_HISTOGRAM_ENUMERATION("Signin.DevicesPageActions", action, 743 UMA_HISTOGRAM_ENUMERATION("Signin.DevicesPageActions", action,
756 one_click_signin::HISTOGRAM_MAX); 744 one_click_signin::HISTOGRAM_MAX);
757 break; 745 break;
758 case signin::SOURCE_REAUTH: 746 case signin::SOURCE_REAUTH:
759 UMA_HISTOGRAM_ENUMERATION("Signin.ReauthActions", action, 747 UMA_HISTOGRAM_ENUMERATION("Signin.ReauthActions", action,
760 one_click_signin::HISTOGRAM_MAX); 748 one_click_signin::HISTOGRAM_MAX);
761 break; 749 break;
762 default: 750 default:
763 // This switch statement needs to be updated when the enum Source changes. 751 // This switch statement needs to be updated when the enum Source changes.
764 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 13, 752 COMPILE_ASSERT(signin::SOURCE_UNKNOWN == 12,
765 kSourceEnumHasChangedButNotThisSwitchStatement); 753 kSourceEnumHasChangedButNotThisSwitchStatement);
766 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action, 754 UMA_HISTOGRAM_ENUMERATION("Signin.UnknownActions", action,
767 one_click_signin::HISTOGRAM_MAX); 755 one_click_signin::HISTOGRAM_MAX);
768 } 756 }
769 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, 757 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action,
770 one_click_signin::HISTOGRAM_MAX); 758 one_click_signin::HISTOGRAM_MAX);
771 } 759 }
772 760
773 // static 761 // static
774 void OneClickSigninHelper::CreateForWebContentsWithPasswordManager( 762 void OneClickSigninHelper::CreateForWebContentsWithPasswordManager(
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 content::Referrer(), 1193 content::Referrer(),
1206 CURRENT_TAB, 1194 CURRENT_TAB,
1207 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, 1195 ui::PAGE_TRANSITION_AUTO_TOPLEVEL,
1208 false); 1196 false);
1209 contents->OpenURL(params); 1197 contents->OpenURL(params);
1210 } 1198 }
1211 1199
1212 // static 1200 // static
1213 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( 1201 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary(
1214 content::WebContents* contents, signin::Source source) { 1202 content::WebContents* contents, signin::Source source) {
1215 if (source != signin::SOURCE_SETTINGS && 1203 if (source != signin::SOURCE_SETTINGS) {
1216 source != signin::SOURCE_WEBSTORE_INSTALL) {
1217 RedirectToNtpOrAppsPage(contents, source); 1204 RedirectToNtpOrAppsPage(contents, source);
1218 } 1205 }
1219 } 1206 }
1220 1207
1221 void OneClickSigninHelper::RedirectToSignin() { 1208 void OneClickSigninHelper::RedirectToSignin() {
1222 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; 1209 VLOG(1) << "OneClickSigninHelper::RedirectToSignin";
1223 1210
1224 // Extract the existing sounce=X value. Default to "2" if missing. 1211 // Extract the existing sounce=X value. Default to "2" if missing.
1225 signin::Source source = signin::GetSourceForPromoURL(continue_url_); 1212 signin::Source source = signin::GetSourceForPromoURL(continue_url_);
1226 if (source == signin::SOURCE_UNKNOWN) 1213 if (source == signin::SOURCE_UNKNOWN)
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1548 start_mode); 1535 start_mode);
1549 } 1536 }
1550 1537
1551 // If this explicit sign in is not from settings page/webstore, show 1538 // 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 1539 // 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 1540 // settings page, it will get auto-closed after sync setup. In the case
1554 // of webstore, it will redirect back to webstore. 1541 // of webstore, it will redirect back to webstore.
1555 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); 1542 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_);
1556 } 1543 }
1557 1544
1558 // Observe the sync service if the Webstore tab or the settings tab 1545 // 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 1546 // 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 1547 // the correct URL, or auto-close the gaia sign in tab.
1561 // sign in tab. 1548 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. 1549 // The observer deletes itself once it's done.
1566 new OneClickSigninSyncObserver(contents, original_continue_url_); 1550 new OneClickSigninSyncObserver(contents, original_continue_url_);
1567 } 1551 }
1568 break; 1552 break;
1569 } 1553 }
1570 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: 1554 case AUTO_ACCEPT_REJECTED_FOR_PROFILE:
1571 AddEmailToOneClickRejectedList(profile, email_); 1555 AddEmailToOneClickRejectedList(profile, email_);
1572 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); 1556 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED);
1573 break; 1557 break;
1574 default: 1558 default:
(...skipping 22 matching lines...) Expand all
1597 // If the web contents is showing a blank page and not about to be closed, 1581 // If the web contents is showing a blank page and not about to be closed,
1598 // redirect to the NTP or apps page. 1582 // redirect to the NTP or apps page.
1599 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && 1583 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) &&
1600 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { 1584 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
1601 RedirectToNtpOrAppsPage( 1585 RedirectToNtpOrAppsPage(
1602 web_contents(), 1586 web_contents(),
1603 signin::GetSourceForPromoURL(original_continue_url_)); 1587 signin::GetSourceForPromoURL(original_continue_url_));
1604 } 1588 }
1605 } 1589 }
1606 } 1590 }
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