Chromium Code Reviews| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 129 } |
| 130 // The starter deletes itself once its done. | 130 // The starter deletes itself once its done. |
| 131 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, | 131 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, |
| 132 args.email, args.password, start_mode, | 132 args.email, args.password, start_mode, |
| 133 /* force_same_tab_navigation */ | 133 /* force_same_tab_navigation */ |
| 134 args.last_minute_source_change); | 134 args.last_minute_source_change); |
| 135 | 135 |
| 136 int action = one_click_signin::HISTOGRAM_MAX; | 136 int action = one_click_signin::HISTOGRAM_MAX; |
| 137 switch (args.auto_accept) { | 137 switch (args.auto_accept) { |
| 138 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 138 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
| 139 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; | |
| 140 break; | |
| 141 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | |
| 142 action = | 139 action = |
| 143 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 140 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
| 144 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : | 141 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : |
| 145 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 142 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
| 146 break; | 143 break; |
| 144 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | |
| 145 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; | |
| 146 break; | |
| 147 case OneClickSigninHelper::AUTO_ACCEPT_NONE: | 147 case OneClickSigninHelper::AUTO_ACCEPT_NONE: |
| 148 action = | 148 action = |
| 149 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 149 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
| 150 one_click_signin::HISTOGRAM_WITH_DEFAULTS : | 150 one_click_signin::HISTOGRAM_WITH_DEFAULTS : |
| 151 one_click_signin::HISTOGRAM_WITH_ADVANCED; | 151 one_click_signin::HISTOGRAM_WITH_ADVANCED; |
| 152 break; | 152 break; |
| 153 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: | 153 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: |
| 154 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 154 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 155 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 155 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
| 156 break; | 156 break; |
| (...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 const bool continue_url_match = (url.ReplaceComponents(replacements) == | 986 const bool continue_url_match = (url.ReplaceComponents(replacements) == |
| 987 continue_url_.ReplaceComponents(replacements)); | 987 continue_url_.ReplaceComponents(replacements)); |
| 988 if (!continue_url_match) { | 988 if (!continue_url_match) { |
| 989 VLOG(1) << "OneClickSigninHelper::DidStopLoading: invalid url='" | 989 VLOG(1) << "OneClickSigninHelper::DidStopLoading: invalid url='" |
| 990 << url.spec() | 990 << url.spec() |
| 991 << "' expected continue url=" << continue_url_; | 991 << "' expected continue url=" << continue_url_; |
| 992 CleanTransientState(); | 992 CleanTransientState(); |
| 993 return; | 993 return; |
| 994 } | 994 } |
| 995 | 995 |
| 996 // In explicit sign ins, the user may have checked the box | 996 // In explicit sign ins, the user may have changed the box |
| 997 // "Let me choose what to sync". This is reflected as a change in the | 997 // "Let me choose what to sync". This is reflected as a change in the |
| 998 // source of the continue URL. Make one last check of the current URL | 998 // source of the continue URL. Make one last check of the current URL |
| 999 // to see if there is a valid source and its set to settings. If so, | 999 // to see if there is a valid source. If so, it overrides the |
| 1000 // it overrides the current source. | 1000 // current source. |
| 1001 SyncPromoUI::Source source = | 1001 SyncPromoUI::Source source = |
| 1002 SyncPromoUI::GetSourceForSyncPromoURL(url); | 1002 SyncPromoUI::GetSourceForSyncPromoURL(url); |
| 1003 if (source == SyncPromoUI::SOURCE_SETTINGS && | 1003 if (source != source_) { |
|
Andrew T Wilson (Slow)
2013/02/14 18:18:49
Why not just do source_ = source (why have an if a
Roger Tawa OOO till Jul 10th
2013/02/14 18:53:35
We need the if to set the bool variable. I've als
| |
| 1004 source_ != SyncPromoUI::SOURCE_SETTINGS) { | 1004 source_ = source; |
| 1005 source_ = SyncPromoUI::SOURCE_SETTINGS; | |
| 1006 last_minute_source_change = true; | 1005 last_minute_source_change = true; |
| 1007 } | 1006 } |
| 1008 } | 1007 } |
| 1009 } | 1008 } |
| 1010 | 1009 |
| 1011 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 1010 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 1012 Profile* profile = | 1011 Profile* profile = |
| 1013 Profile::FromBrowserContext(contents->GetBrowserContext()); | 1012 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 1014 | 1013 |
| 1015 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | 1014 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1075 start_mode)); | 1074 start_mode)); |
| 1076 } else { | 1075 } else { |
| 1077 StartExplicitSync( | 1076 StartExplicitSync( |
| 1078 StartSyncArgs(profile, browser, auto_accept_, session_index_, | 1077 StartSyncArgs(profile, browser, auto_accept_, session_index_, |
| 1079 email_, password_, last_minute_source_change), | 1078 email_, password_, last_minute_source_change), |
| 1080 contents, | 1079 contents, |
| 1081 start_mode, | 1080 start_mode, |
| 1082 IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_CANCEL_BUTTON); | 1081 IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_CANCEL_BUTTON); |
| 1083 } | 1082 } |
| 1084 | 1083 |
| 1085 if (last_minute_source_change && | 1084 if (source_ == SyncPromoUI::SOURCE_SETTINGS && |
| 1086 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_) == | 1085 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_) == |
| 1087 SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | 1086 SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { |
| 1088 redirect_url_ = continue_url_; | 1087 redirect_url_ = continue_url_; |
| 1089 ProfileSyncService* sync_service = | 1088 ProfileSyncService* sync_service = |
| 1090 ProfileSyncServiceFactory::GetForProfile(profile); | 1089 ProfileSyncServiceFactory::GetForProfile(profile); |
| 1091 if (sync_service) | 1090 if (sync_service) |
| 1092 sync_service->AddObserver(this); | 1091 sync_service->AddObserver(this); |
| 1093 } | 1092 } |
| 1094 | 1093 |
| 1095 // If this explicit sign in is not from settings page/webstore, show the | 1094 // If this explicit sign in is not from settings page/webstore, show the |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1164 break; | 1163 break; |
| 1165 } | 1164 } |
| 1166 } | 1165 } |
| 1167 | 1166 |
| 1168 RedirectToNTP(); | 1167 RedirectToNTP(); |
| 1169 } | 1168 } |
| 1170 | 1169 |
| 1171 void OneClickSigninHelper::SigninSuccess() { | 1170 void OneClickSigninHelper::SigninSuccess() { |
| 1172 RedirectToNTP(); | 1171 RedirectToNTP(); |
| 1173 } | 1172 } |
| OLD | NEW |