OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webui/signin/inline_login_handler_impl.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 AccountTrackerService* account_tracker = | 126 AccountTrackerService* account_tracker = |
127 AccountTrackerServiceFactory::GetForProfile(profile_); | 127 AccountTrackerServiceFactory::GetForProfile(profile_); |
128 std::string account_id = | 128 std::string account_id = |
129 account_tracker->PickAccountIdForAccount(gaia_id_, email_); | 129 account_tracker->PickAccountIdForAccount(gaia_id_, email_); |
130 | 130 |
131 // Prime the account tracker with this combination of gaia id/display email. | 131 // Prime the account tracker with this combination of gaia id/display email. |
132 account_tracker->SeedAccountInfo(gaia_id_, email_); | 132 account_tracker->SeedAccountInfo(gaia_id_, email_); |
133 | 133 |
134 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url_); | 134 signin_metrics::Source source = signin::GetSourceForPromoURL(current_url_); |
135 | 135 |
136 std::string primary_email = | 136 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile_); |
137 SigninManagerFactory::GetForProfile(profile_)->GetAuthenticatedUsername(); | 137 std::string primary_email = signin_manager->GetAuthenticatedUsername(); |
138 if (gaia::AreEmailsSame(email_, primary_email) && | 138 if (gaia::AreEmailsSame(email_, primary_email) && |
139 source == signin_metrics::SOURCE_REAUTH && | 139 source == signin_metrics::SOURCE_REAUTH && |
140 switches::IsNewProfileManagement() && | 140 switches::IsNewProfileManagement() && |
141 !password_.empty() && | 141 !password_.empty() && |
142 profiles::IsLockAvailable(profile_)) { | 142 profiles::IsLockAvailable(profile_)) { |
143 LocalAuth::SetLocalAuthCredentials(profile_, password_); | 143 LocalAuth::SetLocalAuthCredentials(profile_, password_); |
144 } | 144 } |
145 | 145 |
146 if (source == signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || | 146 if (source == signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || |
147 source == signin_metrics::SOURCE_REAUTH) { | 147 source == signin_metrics::SOURCE_REAUTH) { |
148 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> | 148 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> |
149 UpdateCredentials(account_id, result.refresh_token); | 149 UpdateCredentials(account_id, result.refresh_token); |
150 | 150 |
151 if (signin::IsAutoCloseEnabledInURL(current_url_)) { | 151 if (signin::IsAutoCloseEnabledInURL(current_url_)) { |
152 // Close the gaia sign in tab via a task to make sure we aren't in the | 152 // Close the gaia sign in tab via a task to make sure we aren't in the |
153 // middle of any webui handler code. | 153 // middle of any webui handler code. |
154 base::MessageLoop::current()->PostTask( | 154 base::MessageLoop::current()->PostTask( |
155 FROM_HERE, | 155 FROM_HERE, |
156 base::Bind(&InlineLoginHandlerImpl::CloseTab, | 156 base::Bind(&InlineLoginHandlerImpl::CloseTab, |
157 handler_, | 157 handler_, |
158 signin::ShouldShowAccountManagement(current_url_))); | 158 signin::ShouldShowAccountManagement(current_url_))); |
159 } | 159 } |
| 160 |
| 161 if (source == signin_metrics::SOURCE_REAUTH) |
| 162 signin_manager->MergeSigninCredentialIntoCookieJar(); |
160 } else { | 163 } else { |
161 ProfileSyncService* sync_service = | 164 ProfileSyncService* sync_service = |
162 ProfileSyncServiceFactory::GetForProfile(profile_); | 165 ProfileSyncServiceFactory::GetForProfile(profile_); |
163 SigninErrorController* error_controller = | 166 SigninErrorController* error_controller = |
164 SigninErrorControllerFactory::GetForProfile(profile_); | 167 SigninErrorControllerFactory::GetForProfile(profile_); |
165 | 168 |
166 bool is_new_avatar_menu = switches::IsNewAvatarMenu(); | 169 bool is_new_avatar_menu = switches::IsNewAvatarMenu(); |
167 | 170 |
168 OneClickSigninSyncStarter::StartSyncMode start_mode; | 171 OneClickSigninSyncStarter::StartSyncMode start_mode; |
169 if (source == signin_metrics::SOURCE_SETTINGS || choose_what_to_sync_) { | 172 if (source == signin_metrics::SOURCE_SETTINGS || choose_what_to_sync_) { |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 } | 460 } |
458 } | 461 } |
459 | 462 |
460 if (show_account_management) { | 463 if (show_account_management) { |
461 browser->window()->ShowAvatarBubbleFromAvatarButton( | 464 browser->window()->ShowAvatarBubbleFromAvatarButton( |
462 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 465 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
463 signin::ManageAccountsParams()); | 466 signin::ManageAccountsParams()); |
464 } | 467 } |
465 } | 468 } |
466 } | 469 } |
OLD | NEW |