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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc

Issue 508433004: Store local auth credentials after successful login or re-auth. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/signin/about_signin_internals_factory.h" 15 #include "chrome/browser/signin/about_signin_internals_factory.h"
16 #include "chrome/browser/signin/chrome_signin_client_factory.h" 16 #include "chrome/browser/signin/chrome_signin_client_factory.h"
17 #include "chrome/browser/signin/local_auth.h"
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #include "chrome/browser/signin/signin_manager_factory.h" 19 #include "chrome/browser/signin/signin_manager_factory.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 20 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/browser_finder.h" 22 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/browser_window.h" 23 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/sync/one_click_signin_helper.h" 24 #include "chrome/browser/ui/sync/one_click_signin_helper.h"
24 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" 25 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
25 #include "chrome/browser/ui/tabs/tab_strip_model.h" 26 #include "chrome/browser/ui/tabs/tab_strip_model.h"
26 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" 27 #include "chrome/browser/ui/webui/signin/inline_login_ui.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const std::string& display_email, 109 const std::string& display_email,
109 const std::string& refresh_token) { 110 const std::string& refresh_token) {
110 content::WebContents* contents = NULL; 111 content::WebContents* contents = NULL;
111 Browser* browser = NULL; 112 Browser* browser = NULL;
112 if (handler_) { 113 if (handler_) {
113 contents = handler_->web_ui()->GetWebContents(); 114 contents = handler_->web_ui()->GetWebContents();
114 browser = handler_->GetDesktopBrowser(); 115 browser = handler_->GetDesktopBrowser();
115 } 116 }
116 117
117 AboutSigninInternals* about_signin_internals = 118 AboutSigninInternals* about_signin_internals =
118 AboutSigninInternalsFactory::GetForProfile(profile_); 119 AboutSigninInternalsFactory::GetForProfile(profile_);
119 about_signin_internals->OnRefreshTokenReceived("Successful"); 120 about_signin_internals->OnRefreshTokenReceived("Successful");
120 121
121 signin::Source source = signin::GetSourceForPromoURL(current_url_); 122 signin::Source source = signin::GetSourceForPromoURL(current_url_);
123
124 std::string primary_email =
125 SigninManagerFactory::GetForProfile(profile_)->GetAuthenticatedUsername();
126 bool is_primary_account =
127 gaia::AreEmailsSame(email, primary_email) ||
128 source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN;
129 if (is_primary_account)
Marc Treib 2014/08/26 12:23:51 This assumes we want to store the credentials on e
Roger Tawa OOO till Jul 10th 2014/08/26 15:29:57 We already store a hash on first time sign-in, see
130 chrome::SetLocalAuthCredentials(profile_, password_);
131
122 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || 132 if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT ||
123 source == signin::SOURCE_REAUTH) { 133 source == signin::SOURCE_REAUTH) {
124 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)-> 134 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
125 UpdateCredentials(email, refresh_token); 135 UpdateCredentials(email, refresh_token);
126 136
127 if (signin::IsAutoCloseEnabledInURL(current_url_)) { 137 if (signin::IsAutoCloseEnabledInURL(current_url_)) {
128 // Close the gaia sign in tab via a task to make sure we aren't in the 138 // Close the gaia sign in tab via a task to make sure we aren't in the
129 // middle of any webui handler code. 139 // middle of any webui handler code.
130 base::MessageLoop::current()->PostTask( 140 base::MessageLoop::current()->PostTask(
131 FROM_HERE, 141 FROM_HERE,
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 449 }
440 } 450 }
441 451
442 if (show_account_management) { 452 if (show_account_management) {
443 browser->window()->ShowAvatarBubbleFromAvatarButton( 453 browser->window()->ShowAvatarBubbleFromAvatarButton(
444 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, 454 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
445 signin::ManageAccountsParams()); 455 signin::ManageAccountsParams());
446 } 456 }
447 } 457 }
448 } 458 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698