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/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 Loading... | |
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/net/nss_cert_database_factory.h" | |
49 #include "chrome/browser/chromeos/settings/cros_settings.h" | 50 #include "chrome/browser/chromeos/settings/cros_settings.h" |
50 #include "chrome/browser/extensions/extension_service.h" | 51 #include "chrome/browser/extensions/extension_service.h" |
51 #include "chrome/browser/first_run/first_run.h" | 52 #include "chrome/browser/first_run/first_run.h" |
52 #include "chrome/browser/google/google_util_chromeos.h" | 53 #include "chrome/browser/google/google_util_chromeos.h" |
53 #include "chrome/browser/lifetime/application_lifetime.h" | 54 #include "chrome/browser/lifetime/application_lifetime.h" |
54 #include "chrome/browser/pref_service_flags_storage.h" | 55 #include "chrome/browser/pref_service_flags_storage.h" |
55 #include "chrome/browser/profiles/profile.h" | 56 #include "chrome/browser/profiles/profile.h" |
56 #include "chrome/browser/profiles/profile_manager.h" | 57 #include "chrome/browser/profiles/profile_manager.h" |
57 #include "chrome/browser/rlz/rlz.h" | 58 #include "chrome/browser/rlz/rlz.h" |
58 #include "chrome/browser/sync/profile_sync_service.h" | 59 #include "chrome/browser/sync/profile_sync_service.h" |
59 #include "chrome/browser/sync/profile_sync_service_factory.h" | 60 #include "chrome/browser/sync/profile_sync_service_factory.h" |
60 #include "chrome/browser/ui/app_list/start_page_service.h" | 61 #include "chrome/browser/ui/app_list/start_page_service.h" |
61 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 62 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
62 #include "chrome/common/chrome_paths.h" | 63 #include "chrome/common/chrome_paths.h" |
63 #include "chrome/common/chrome_switches.h" | 64 #include "chrome/common/chrome_switches.h" |
64 #include "chrome/common/logging_chrome.h" | 65 #include "chrome/common/logging_chrome.h" |
65 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
67 #include "chromeos/cert_loader.h" | |
66 #include "chromeos/chromeos_switches.h" | 68 #include "chromeos/chromeos_switches.h" |
67 #include "chromeos/cryptohome/cryptohome_util.h" | 69 #include "chromeos/cryptohome/cryptohome_util.h" |
68 #include "chromeos/dbus/cryptohome_client.h" | 70 #include "chromeos/dbus/cryptohome_client.h" |
69 #include "chromeos/dbus/dbus_method_call_status.h" | 71 #include "chromeos/dbus/dbus_method_call_status.h" |
70 #include "chromeos/dbus/dbus_thread_manager.h" | 72 #include "chromeos/dbus/dbus_thread_manager.h" |
71 #include "chromeos/dbus/session_manager_client.h" | 73 #include "chromeos/dbus/session_manager_client.h" |
72 #include "chromeos/ime/input_method_manager.h" | 74 #include "chromeos/ime/input_method_manager.h" |
73 #include "chromeos/settings/cros_settings_names.h" | 75 #include "chromeos/settings/cros_settings_names.h" |
74 #include "content/public/browser/browser_thread.h" | 76 #include "content/public/browser/browser_thread.h" |
75 #include "content/public/browser/notification_service.h" | 77 #include "content/public/browser/notification_service.h" |
76 #include "google_apis/gaia/gaia_auth_consumer.h" | 78 #include "google_apis/gaia/gaia_auth_consumer.h" |
77 #include "net/base/network_change_notifier.h" | 79 #include "net/base/network_change_notifier.h" |
78 #include "net/url_request/url_request_context.h" | 80 #include "net/url_request/url_request_context.h" |
79 #include "net/url_request/url_request_context_getter.h" | 81 #include "net/url_request/url_request_context_getter.h" |
80 #include "url/gurl.h" | 82 #include "url/gurl.h" |
81 | 83 |
82 using content::BrowserThread; | 84 using content::BrowserThread; |
83 | 85 |
86 namespace net { | |
87 class NSSCertDatabase; | |
88 } | |
89 | |
84 namespace chromeos { | 90 namespace chromeos { |
85 | 91 |
86 namespace { | 92 namespace { |
87 | 93 |
88 #if defined(ENABLE_RLZ) | 94 #if defined(ENABLE_RLZ) |
89 // Flag file that disables RLZ tracking, when present. | 95 // Flag file that disables RLZ tracking, when present. |
90 const base::FilePath::CharType kRLZDisabledFlagName[] = | 96 const base::FilePath::CharType kRLZDisabledFlagName[] = |
91 FILE_PATH_LITERAL(".rlz_disabled"); | 97 FILE_PATH_LITERAL(".rlz_disabled"); |
92 | 98 |
93 base::FilePath GetRlzDisabledFlagPath() { | 99 base::FilePath GetRlzDisabledFlagPath() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 bool has_cookies, | 133 bool has_cookies, |
128 bool has_active_session, | 134 bool has_active_session, |
129 LoginUtils::Delegate* delegate) OVERRIDE; | 135 LoginUtils::Delegate* delegate) OVERRIDE; |
130 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; | 136 virtual void DelegateDeleted(LoginUtils::Delegate* delegate) OVERRIDE; |
131 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; | 137 virtual void CompleteOffTheRecordLogin(const GURL& start_url) OVERRIDE; |
132 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; | 138 virtual void SetFirstLoginPrefs(PrefService* prefs) OVERRIDE; |
133 virtual scoped_refptr<Authenticator> CreateAuthenticator( | 139 virtual scoped_refptr<Authenticator> CreateAuthenticator( |
134 LoginStatusConsumer* consumer) OVERRIDE; | 140 LoginStatusConsumer* consumer) OVERRIDE; |
135 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; | 141 virtual void RestoreAuthenticationSession(Profile* profile) OVERRIDE; |
136 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; | 142 virtual void InitRlzDelayed(Profile* user_profile) OVERRIDE; |
143 virtual void StartCertLoader(Profile* user_profile) OVERRIDE; | |
137 | 144 |
138 // OAuth2LoginManager::Observer overrides. | 145 // OAuth2LoginManager::Observer overrides. |
139 virtual void OnSessionRestoreStateChanged( | 146 virtual void OnSessionRestoreStateChanged( |
140 Profile* user_profile, | 147 Profile* user_profile, |
141 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; | 148 OAuth2LoginManager::SessionRestoreState state) OVERRIDE; |
142 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE; | 149 virtual void OnNewRefreshTokenAvaiable(Profile* user_profile) OVERRIDE; |
143 | 150 |
144 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. | 151 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. |
145 virtual void OnConnectionTypeChanged( | 152 virtual void OnConnectionTypeChanged( |
146 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; | 153 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 // OAuthLoginManager. | 197 // OAuthLoginManager. |
191 void InitSessionRestoreStrategy(); | 198 void InitSessionRestoreStrategy(); |
192 | 199 |
193 // Restores GAIA auth cookies for the created user profile from OAuth2 token. | 200 // Restores GAIA auth cookies for the created user profile from OAuth2 token. |
194 void RestoreAuthSession(Profile* user_profile, | 201 void RestoreAuthSession(Profile* user_profile, |
195 bool restore_from_auth_cookies); | 202 bool restore_from_auth_cookies); |
196 | 203 |
197 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. | 204 // Initializes RLZ. If |disabled| is true, RLZ pings are disabled. |
198 void InitRlz(Profile* user_profile, bool disabled); | 205 void InitRlz(Profile* user_profile, bool disabled); |
199 | 206 |
207 // Starts CertLoader with the provided NSS database. It must be called at most | |
208 // once, and with the primary user's database. | |
209 void StartCertLoaderWithNSSDB(net::NSSCertDatabase* database); | |
210 | |
200 // Attempts restarting the browser process and esures that this does | 211 // Attempts restarting the browser process and esures that this does |
201 // not happen while we are still fetching new OAuth refresh tokens. | 212 // not happen while we are still fetching new OAuth refresh tokens. |
202 void AttemptRestart(Profile* profile); | 213 void AttemptRestart(Profile* profile); |
203 | 214 |
204 UserContext user_context_; | 215 UserContext user_context_; |
205 | 216 |
206 // True if the authentication profile's cookie jar should contain | 217 // True if the authentication profile's cookie jar should contain |
207 // authentication cookies from the authentication extension log in flow. | 218 // authentication cookies from the authentication extension log in flow. |
208 bool has_web_auth_cookies_; | 219 bool has_web_auth_cookies_; |
209 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). | 220 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
577 | 588 |
578 user_profile->OnLogin(); | 589 user_profile->OnLogin(); |
579 | 590 |
580 // Send the notification before creating the browser so additional objects | 591 // Send the notification before creating the browser so additional objects |
581 // that need the profile (e.g. the launcher) can be created first. | 592 // that need the profile (e.g. the launcher) can be created first. |
582 content::NotificationService::current()->Notify( | 593 content::NotificationService::current()->Notify( |
583 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 594 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
584 content::NotificationService::AllSources(), | 595 content::NotificationService::AllSources(), |
585 content::Details<Profile>(user_profile)); | 596 content::Details<Profile>(user_profile)); |
586 | 597 |
587 // Initialize RLZ only for primary user. | 598 // Initialize RLZ and CertLoader only for primary user. |
588 if (UserManager::Get()->GetPrimaryUser() == | 599 if (UserManager::Get()->GetPrimaryUser() == |
589 UserManager::Get()->GetUserByProfile(user_profile)) { | 600 UserManager::Get()->GetUserByProfile(user_profile)) { |
590 InitRlzDelayed(user_profile); | 601 InitRlzDelayed(user_profile); |
602 if (CertLoader::IsInitialized()) | |
Nikita (slow)
2014/01/23 17:15:38
When CertLoader is initialized?
What happens if i
tbarzic
2014/01/23 17:47:56
It's initialized together with DBusServices on sta
| |
603 StartCertLoader(user_profile); | |
591 } | 604 } |
592 // TODO(altimofeev): This pointer should probably never be NULL, but it looks | 605 // TODO(altimofeev): This pointer should probably never be NULL, but it looks |
593 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 606 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
594 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed | 607 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed |
595 // during shutdown in tests -- see http://crosbug.com/18269. Replace this | 608 // during shutdown in tests -- see http://crosbug.com/18269. Replace this |
596 // 'if' statement with a CHECK(delegate_) once the underlying issue is | 609 // 'if' statement with a CHECK(delegate_) once the underlying issue is |
597 // resolved. | 610 // resolved. |
598 if (delegate_) | 611 if (delegate_) |
599 delegate_->OnProfilePrepared(user_profile); | 612 delegate_->OnProfilePrepared(user_profile); |
600 } | 613 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 // Negative ping delay means to send ping immediately after a first search is | 646 // Negative ping delay means to send ping immediately after a first search is |
634 // recorded. | 647 // recorded. |
635 RLZTracker::InitRlzFromProfileDelayed( | 648 RLZTracker::InitRlzFromProfileDelayed( |
636 user_profile, UserManager::Get()->IsCurrentUserNew(), | 649 user_profile, UserManager::Get()->IsCurrentUserNew(), |
637 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 650 ping_delay < 0, base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
638 if (delegate_) | 651 if (delegate_) |
639 delegate_->OnRlzInitialized(user_profile); | 652 delegate_->OnRlzInitialized(user_profile); |
640 #endif | 653 #endif |
641 } | 654 } |
642 | 655 |
656 void LoginUtilsImpl::StartCertLoader(Profile* user_profile) { | |
657 chromeos::GetNSSCertDatabaseForProfile( | |
658 user_profile, | |
659 base::Bind(&LoginUtilsImpl::StartCertLoaderWithNSSDB, AsWeakPtr())); | |
660 } | |
661 | |
662 void LoginUtilsImpl::StartCertLoaderWithNSSDB(net::NSSCertDatabase* database) { | |
663 if (!CertLoader::IsInitialized()) | |
664 return; | |
stevenjb
2014/01/23 18:17:42
This is testing in case the callback occurs during
tbarzic
2014/01/23 19:18:37
I was just about to remove this.
| |
665 | |
666 CertLoader::Get()->StartWithNSSDB(database); | |
667 } | |
668 | |
643 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 669 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
644 VLOG(1) << "Completing incognito login"; | 670 VLOG(1) << "Completing incognito login"; |
645 | 671 |
646 // For guest session we ask session manager to restart Chrome with --bwsi | 672 // For guest session we ask session manager to restart Chrome with --bwsi |
647 // flag. We keep only some of the arguments of this process. | 673 // flag. We keep only some of the arguments of this process. |
648 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 674 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
649 CommandLine command_line(browser_command_line.GetProgram()); | 675 CommandLine command_line(browser_command_line.GetProgram()); |
650 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url, | 676 std::string cmd_line_str = GetOffTheRecordCommandLine(start_url, |
651 browser_command_line, | 677 browser_command_line, |
652 &command_line); | 678 &command_line); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
878 | 904 |
879 CrosSettings* cros_settings = CrosSettings::Get(); | 905 CrosSettings* cros_settings = CrosSettings::Get(); |
880 bool allow_new_user = false; | 906 bool allow_new_user = false; |
881 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 907 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
882 if (allow_new_user) | 908 if (allow_new_user) |
883 return true; | 909 return true; |
884 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 910 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
885 } | 911 } |
886 | 912 |
887 } // namespace chromeos | 913 } // namespace chromeos |
OLD | NEW |