OLD | NEW |
---|---|
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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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, |
318 contents->GetRenderProcessHost()->GetID(), | 318 contents->GetRenderProcessHost()->GetID(), |
guohui
2014/09/23 19:38:46
eh i think you should remove the check, and always
Ilya Sherman
2014/09/23 22:17:02
Ah, I see -- that makes more sense :)
Done.
| |
319 contents->GetRoutingID(), | 319 contents->GetRoutingID(), |
320 args.source)); | 320 args.source)); |
321 } | 321 } |
322 } | 322 } |
323 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { | 323 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { |
324 chrome::ShowSettingsSubPage(args.browser, | 324 chrome::ShowSettingsSubPage(args.browser, |
325 std::string(chrome::kCreateProfileSubPage)); | 325 std::string(chrome::kCreateProfileSubPage)); |
326 } | 326 } |
327 } | 327 } |
328 } | 328 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 Loading... | |
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_); |
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: |
(...skipping 22 matching lines...) Expand all Loading... | |
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 } |
OLD | NEW |