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

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added Linux implementation. 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/session/user_session_manager.h" 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 22 matching lines...) Expand all
33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 33 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
34 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 34 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
35 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 35 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
36 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 36 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
37 #include "chrome/browser/chromeos/profiles/profile_helper.h" 37 #include "chrome/browser/chromeos/profiles/profile_helper.h"
38 #include "chrome/browser/chromeos/settings/cros_settings.h" 38 #include "chrome/browser/chromeos/settings/cros_settings.h"
39 #include "chrome/browser/first_run/first_run.h" 39 #include "chrome/browser/first_run/first_run.h"
40 #include "chrome/browser/google/google_brand_chromeos.h" 40 #include "chrome/browser/google/google_brand_chromeos.h"
41 #include "chrome/browser/lifetime/application_lifetime.h" 41 #include "chrome/browser/lifetime/application_lifetime.h"
42 #include "chrome/browser/net/crl_set_fetcher.h" 42 #include "chrome/browser/net/crl_set_fetcher.h"
43 #include "chrome/browser/net/nss_context.h"
44 #include "chrome/browser/profiles/profile.h" 43 #include "chrome/browser/profiles/profile.h"
45 #include "chrome/browser/profiles/profile_manager.h" 44 #include "chrome/browser/profiles/profile_manager.h"
46 #include "chrome/browser/rlz/rlz.h" 45 #include "chrome/browser/rlz/rlz.h"
47 #include "chrome/browser/signin/signin_manager_factory.h" 46 #include "chrome/browser/signin/signin_manager_factory.h"
48 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/logging_chrome.h" 48 #include "chrome/common/logging_chrome.h"
50 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
51 #include "chromeos/cert_loader.h"
52 #include "chromeos/chromeos_switches.h" 50 #include "chromeos/chromeos_switches.h"
53 #include "chromeos/cryptohome/cryptohome_util.h" 51 #include "chromeos/cryptohome/cryptohome_util.h"
54 #include "chromeos/dbus/cryptohome_client.h" 52 #include "chromeos/dbus/cryptohome_client.h"
55 #include "chromeos/dbus/dbus_thread_manager.h" 53 #include "chromeos/dbus/dbus_thread_manager.h"
56 #include "chromeos/dbus/session_manager_client.h" 54 #include "chromeos/dbus/session_manager_client.h"
57 #include "chromeos/ime/input_method_manager.h" 55 #include "chromeos/ime/input_method_manager.h"
58 #include "chromeos/network/portal_detector/network_portal_detector.h" 56 #include "chromeos/network/portal_detector/network_portal_detector.h"
59 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" 57 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h"
60 #include "chromeos/settings/cros_settings_names.h" 58 #include "chromeos/settings/cros_settings_names.h"
61 #include "components/component_updater/component_updater_service.h" 59 #include "components/component_updater/component_updater_service.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const base::FilePath::CharType kRLZDisabledFlagName[] = 149 const base::FilePath::CharType kRLZDisabledFlagName[] =
152 FILE_PATH_LITERAL(".rlz_disabled"); 150 FILE_PATH_LITERAL(".rlz_disabled");
153 151
154 base::FilePath GetRlzDisabledFlagPath() { 152 base::FilePath GetRlzDisabledFlagPath() {
155 base::FilePath homedir; 153 base::FilePath homedir;
156 PathService::Get(base::DIR_HOME, &homedir); 154 PathService::Get(base::DIR_HOME, &homedir);
157 return homedir.Append(kRLZDisabledFlagName); 155 return homedir.Append(kRLZDisabledFlagName);
158 } 156 }
159 #endif 157 #endif
160 158
161 // Callback to GetNSSCertDatabaseForProfile. It starts CertLoader using the
162 // provided NSS database. It must be called for primary user only.
163 void OnGetNSSCertDatabaseForUser(net::NSSCertDatabase* database) {
164 if (!CertLoader::IsInitialized())
165 return;
166
167 CertLoader::Get()->StartWithNSSDB(database);
168 }
169
170 } // namespace 159 } // namespace
171 160
172 #if defined(ENABLE_RLZ) 161 #if defined(ENABLE_RLZ)
173 void UserSessionManagerDelegate::OnRlzInitialized() { 162 void UserSessionManagerDelegate::OnRlzInitialized() {
174 } 163 }
175 #endif 164 #endif
176 165
177 UserSessionManagerDelegate::~UserSessionManagerDelegate() { 166 UserSessionManagerDelegate::~UserSessionManagerDelegate() {
178 } 167 }
179 168
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 content::NotificationService::current()->Notify( 756 content::NotificationService::current()->Notify(
768 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 757 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
769 content::NotificationService::AllSources(), 758 content::NotificationService::AllSources(),
770 content::Details<Profile>(profile)); 759 content::Details<Profile>(profile));
771 760
772 // Initialize various services only for primary user. 761 // Initialize various services only for primary user.
773 const user_manager::User* user = 762 const user_manager::User* user =
774 ProfileHelper::Get()->GetUserByProfile(profile); 763 ProfileHelper::Get()->GetUserByProfile(profile);
775 if (user_manager->GetPrimaryUser() == user) { 764 if (user_manager->GetPrimaryUser() == user) {
776 InitRlz(profile); 765 InitRlz(profile);
777 InitializeCerts(profile);
778 InitializeCRLSetFetcher(user); 766 InitializeCRLSetFetcher(user);
779 } 767 }
780 768
781 // TODO(nkostylev): This pointer should probably never be NULL, but it looks 769 // TODO(nkostylev): This pointer should probably never be NULL, but it looks
782 // like LoginUtilsImpl::OnProfileCreated() may be getting called before 770 // like LoginUtilsImpl::OnProfileCreated() may be getting called before
783 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is 771 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is
784 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace 772 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace
785 // this 'if' statement with a CHECK(delegate_) once the underlying issue is 773 // this 'if' statement with a CHECK(delegate_) once the underlying issue is
786 // resolved. 774 // resolved.
787 if (delegate_) 775 if (delegate_)
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 RLZTracker::InitRlzFromProfileDelayed( 863 RLZTracker::InitRlzFromProfileDelayed(
876 profile, 864 profile,
877 user_manager::UserManager::Get()->IsCurrentUserNew(), 865 user_manager::UserManager::Get()->IsCurrentUserNew(),
878 ping_delay < 0, 866 ping_delay < 0,
879 base::TimeDelta::FromMilliseconds(abs(ping_delay))); 867 base::TimeDelta::FromMilliseconds(abs(ping_delay)));
880 if (delegate_) 868 if (delegate_)
881 delegate_->OnRlzInitialized(); 869 delegate_->OnRlzInitialized();
882 #endif 870 #endif
883 } 871 }
884 872
885 void UserSessionManager::InitializeCerts(Profile* profile) {
886 // Now that the user profile has been initialized
887 // |GetNSSCertDatabaseForProfile| is safe to be used.
888 if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) {
889 GetNSSCertDatabaseForProfile(profile,
890 base::Bind(&OnGetNSSCertDatabaseForUser));
891 }
892 }
893
894 void UserSessionManager::InitializeCRLSetFetcher( 873 void UserSessionManager::InitializeCRLSetFetcher(
895 const user_manager::User* user) { 874 const user_manager::User* user) {
896 const std::string username_hash = user->username_hash(); 875 const std::string username_hash = user->username_hash();
897 if (!username_hash.empty()) { 876 if (!username_hash.empty()) {
898 base::FilePath path; 877 base::FilePath path;
899 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash); 878 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash);
900 component_updater::ComponentUpdateService* cus = 879 component_updater::ComponentUpdateService* cus =
901 g_browser_process->component_updater(); 880 g_browser_process->component_updater();
902 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher(); 881 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher();
903 if (crl_set && cus) 882 if (crl_set && cus)
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 default_ime_states_[profile]; 978 default_ime_states_[profile];
1000 if (!state) { 979 if (!state) {
1001 // Profile can be NULL in tests. 980 // Profile can be NULL in tests.
1002 state = input_method::InputMethodManager::Get()->CreateNewState(profile); 981 state = input_method::InputMethodManager::Get()->CreateNewState(profile);
1003 default_ime_states_[profile] = state; 982 default_ime_states_[profile] = state;
1004 } 983 }
1005 return state; 984 return state;
1006 } 985 }
1007 986
1008 } // namespace chromeos 987 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698