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

Side by Side Diff: chrome/browser/chromeos/login/login_utils.cc

Issue 148183013: Use per-user nssdb in onc certificate importer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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 | Annotate | Revision Log
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/chromeos/login/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 28 matching lines...) Expand all
39 #include "chrome/browser/chromeos/login/chrome_restart_request.h" 39 #include "chrome/browser/chromeos/login/chrome_restart_request.h"
40 #include "chrome/browser/chromeos/login/input_events_blocker.h" 40 #include "chrome/browser/chromeos/login/input_events_blocker.h"
41 #include "chrome/browser/chromeos/login/login_display_host.h" 41 #include "chrome/browser/chromeos/login/login_display_host.h"
42 #include "chrome/browser/chromeos/login/oauth2_login_manager.h" 42 #include "chrome/browser/chromeos/login/oauth2_login_manager.h"
43 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" 43 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h"
44 #include "chrome/browser/chromeos/login/parallel_authenticator.h" 44 #include "chrome/browser/chromeos/login/parallel_authenticator.h"
45 #include "chrome/browser/chromeos/login/profile_auth_data.h" 45 #include "chrome/browser/chromeos/login/profile_auth_data.h"
46 #include "chrome/browser/chromeos/login/screen_locker.h" 46 #include "chrome/browser/chromeos/login/screen_locker.h"
47 #include "chrome/browser/chromeos/login/supervised_user_manager.h" 47 #include "chrome/browser/chromeos/login/supervised_user_manager.h"
48 #include "chrome/browser/chromeos/login/user_manager.h" 48 #include "chrome/browser/chromeos/login/user_manager.h"
49 #include "chrome/browser/chromeos/policy/user_network_configuration_updater.h"
50 #include "chrome/browser/chromeos/policy/user_network_configuration_updater_fact ory.h"
49 #include "chrome/browser/chromeos/settings/cros_settings.h" 51 #include "chrome/browser/chromeos/settings/cros_settings.h"
50 #include "chrome/browser/extensions/extension_service.h" 52 #include "chrome/browser/extensions/extension_service.h"
51 #include "chrome/browser/first_run/first_run.h" 53 #include "chrome/browser/first_run/first_run.h"
52 #include "chrome/browser/google/google_util_chromeos.h" 54 #include "chrome/browser/google/google_util_chromeos.h"
53 #include "chrome/browser/lifetime/application_lifetime.h" 55 #include "chrome/browser/lifetime/application_lifetime.h"
54 #include "chrome/browser/net/nss_context.h" 56 #include "chrome/browser/net/nss_context.h"
55 #include "chrome/browser/pref_service_flags_storage.h" 57 #include "chrome/browser/pref_service_flags_storage.h"
56 #include "chrome/browser/profiles/profile.h" 58 #include "chrome/browser/profiles/profile.h"
57 #include "chrome/browser/profiles/profile_manager.h" 59 #include "chrome/browser/profiles/profile_manager.h"
58 #include "chrome/browser/rlz/rlz.h" 60 #include "chrome/browser/rlz/rlz.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 bool has_cookies, 135 bool has_cookies,
134 bool has_active_session, 136 bool has_active_session,
135 LoginUtils::Delegate* delegate) OVERRIDE; 137 LoginUtils::Delegate* delegate) OVERRIDE;
136 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; 138 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE;
137 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; 139 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE;
138 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; 140 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE;
139 virtual scoped_refptr<Authenticator> CreateAuthenticator( 141 virtual scoped_refptr<Authenticator> CreateAuthenticator(
140 LoginStatusConsumer* consumer) OVERRIDE; 142 LoginStatusConsumer* consumer) OVERRIDE;
141 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; 143 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE;
142 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; 144 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE;
143 virtual void StartCertLoader(Profile* user_profile) OVERRIDE; 145 virtual void InitNSSCertDatabaseUsers(Profile* user_profile) OVERRIDE;
144 146
145 // OAuth2LoginManager::Observer overrides. 147 // OAuth2LoginManager::Observer overrides.
146 virtual void OnSessionRestoreStateChanged( 148 virtual void OnSessionRestoreStateChanged(
147 Profile* user_profile, 149 Profile* user_profile,
148 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; 150 OAuth2LoginManager::SessionRestoreState state) OVERRIDE;
149 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE; 151 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE;
150 152
151 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. 153 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides.
152 virtual void OnConnectionTypeChanged( 154 virtual void OnConnectionTypeChanged(
153 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 155 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // OAuthLoginManager. 199 // OAuthLoginManager.
198 void InitSessionRestoreStrategy(); 200 void InitSessionRestoreStrategy();
199 201
200 // Restores GAIA auth cookies for the created user profile from OAuth2 token. 202 // Restores GAIA auth cookies for the created user profile from OAuth2 token.
201 void RestoreAuthSession(Profile* user_profile, 203 void RestoreAuthSession(Profile* user_profile,
202 bool restore_from_auth_cookies); 204 bool restore_from_auth_cookies);
203 205
204 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. 206 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled.
205 void InitRlz(Profile* user_profile, bool disabled); 207 void InitRlz(Profile* user_profile, bool disabled);
206 208
207 // Starts CertLoader with the provided NSS database. It must be called at most 209 // Starts CertLoader with the provided NSS database and sets the database for
208 // once, and with the primary user's database. 210 // the user's NetworkConfigrationUpdater. It must be called at most once, and
209 void StartCertLoaderWithNSSDB(net::NSSCertDatabase* database); 211 // with the primary user's database.
212 void OnNSSCertDatabase(Profile* user_proilfe, net::NSSCertDatabase* database);
210 213
211 // Attempts restarting the browser process and esures that this does 214 // Attempts restarting the browser process and esures that this does
212 // not happen while we are still fetching new OAuth refresh tokens. 215 // not happen while we are still fetching new OAuth refresh tokens.
213 void AttemptRestart(Profile* profile); 216 void AttemptRestart(Profile* profile);
214 217
215 UserContext user_context_; 218 UserContext user_context_;
216 219
217 // True if the authentication profile's cookie jar should contain 220 // True if the authentication profile's cookie jar should contain
218 // authentication cookies from the authentication extension log in flow. 221 // authentication cookies from the authentication extension log in flow.
219 bool has_web_auth_cookies_; 222 bool has_web_auth_cookies_;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 591
589 user_profile->OnLogin(); 592 user_profile->OnLogin();
590 593
591 // Send the notification before creating the browser so additional objects 594 // Send the notification before creating the browser so additional objects
592 // that need the profile (e.g. the launcher) can be created first. 595 // that need the profile (e.g. the launcher) can be created first.
593 content::NotificationService::current()->Notify( 596 content::NotificationService::current()->Notify(
594 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 597 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
595 content::NotificationService::AllSources(), 598 content::NotificationService::AllSources(),
596 content::Details<Profile>(user_profile)); 599 content::Details<Profile>(user_profile));
597 600
598 // Initialize RLZ and CertLoader only for primary user. 601 // Initialize RLZ, and sets user NSSDB where needed. Both should be done for
602 // the primary user only.
599 if (UserManager::Get()->GetPrimaryUser() == 603 if (UserManager::Get()->GetPrimaryUser() ==
600 UserManager::Get()->GetUserByProfile(user_profile)) { 604 UserManager::Get()->GetUserByProfile(user_profile)) {
601 InitRlzDelayed(user_profile); 605 InitRlzDelayed(user_profile);
602 if (CertLoader::IsInitialized()) 606 InitNSSCertDatabaseUsers(user_profile);
603 StartCertLoader(user_profile);
604 } 607 }
605 // TODO(altimofeev): This pointer should probably never be NULL, but it looks 608 // TODO(altimofeev): This pointer should probably never be NULL, but it looks
606 // like LoginUtilsImpl::OnProfileCreated() may be getting called before 609 // like LoginUtilsImpl::OnProfileCreated() may be getting called before
607 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed 610 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed
608 // during shutdown in tests -- see http://crosbug.com/18269. Replace this 611 // during shutdown in tests -- see http://crosbug.com/18269. Replace this
609 // 'if' statement with a CHECK(delegate_) once the underlying issue is 612 // 'if' statement with a CHECK(delegate_) once the underlying issue is
610 // resolved. 613 // resolved.
611 if (delegate_) 614 if (delegate_)
612 delegate_->OnProfilePrepared(user_profile); 615 delegate_->OnProfilePrepared(user_profile);
613 } 616 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 // Negative ping delay means to send ping immediately after a first search is 649 // Negative ping delay means to send ping immediately after a first search is
647 // recorded. 650 // recorded.
648 RLZTracker::InitRlzFromProfileDelayed( 651 RLZTracker::InitRlzFromProfileDelayed(
649 user_profile, UserManager::Get()->IsCurrentUserNew(), 652 user_profile, UserManager::Get()->IsCurrentUserNew(),
650 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); 653 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay)));
651 if (delegate_) 654 if (delegate_)
652 delegate_->OnRlzInitialized(user_profile); 655 delegate_->OnRlzInitialized(user_profile);
653 #endif 656 #endif
654 } 657 }
655 658
656 void LoginUtilsImpl::StartCertLoader(Profile* user_profile) { 659 void LoginUtilsImpl::InitNSSCertDatabaseUsers(Profile* user_profile) {
657 GetNSSCertDatabaseForProfile( 660 GetNSSCertDatabaseForProfile(
658 user_profile, 661 user_profile,
659 base::Bind(&LoginUtilsImpl::StartCertLoaderWithNSSDB, AsWeakPtr())); 662 base::Bind(&LoginUtilsImpl::OnNSSCertDatabase, AsWeakPtr(),
663 base::Unretained(user_profile)));
660 } 664 }
661 665
662 void LoginUtilsImpl::StartCertLoaderWithNSSDB(net::NSSCertDatabase* database) { 666 void LoginUtilsImpl::OnNSSCertDatabase(Profile* user_profile,
663 CertLoader::Get()->StartWithNSSDB(database); 667 net::NSSCertDatabase* database) {
668 if (CertLoader::IsInitialized())
669 CertLoader::Get()->StartWithNSSDB(database);
670 policy::UserNetworkConfigurationUpdaterFactory::GetForProfile(user_profile)
671 ->SetCertDatabase(database);
664 } 672 }
665 673
666 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { 674 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) {
667 VLOG(1) << "Completing incognito login"; 675 VLOG(1) << "Completing incognito login";
668 676
669 // For guest session we ask session manager to restart Chrome with --bwsi 677 // For guest session we ask session manager to restart Chrome with --bwsi
670 // flag. We keep only some of the arguments of this process. 678 // flag. We keep only some of the arguments of this process.
671 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); 679 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
672 CommandLine command_line(browser_command_line.GetProgram()); 680 CommandLine command_line(browser_command_line.GetProgram());
673 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url, 681 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url,
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 909
902 CrosSettings* cros_settings = CrosSettings::Get(); 910 CrosSettings* cros_settings = CrosSettings::Get();
903 bool allow_new_user = false; 911 bool allow_new_user = false;
904 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 912 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
905 if (allow_new_user) 913 if (allow_new_user)
906 return true; 914 return true;
907 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 915 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
908 } 916 }
909 917
910 } // namespace chromeos 918 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698