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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/chromeos/chromeos_version.h" | 10 #include "base/chromeos/chromeos_version.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 40 #include "chrome/browser/chromeos/login/language_switch_menu.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/oauth_login_manager.h" | 42 #include "chrome/browser/chromeos/login/oauth_login_manager.h" |
43 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 43 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
44 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 44 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
45 #include "chrome/browser/chromeos/login/screen_locker.h" | 45 #include "chrome/browser/chromeos/login/screen_locker.h" |
46 #include "chrome/browser/chromeos/login/user_manager.h" | 46 #include "chrome/browser/chromeos/login/user_manager.h" |
47 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" | 47 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" |
48 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" | 48 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" |
49 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 49 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
| 50 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
50 #include "chrome/browser/chromeos/settings/cros_settings.h" | 51 #include "chrome/browser/chromeos/settings/cros_settings.h" |
51 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 52 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
52 #include "chrome/browser/extensions/extension_service.h" | 53 #include "chrome/browser/extensions/extension_service.h" |
53 #include "chrome/browser/first_run/first_run.h" | 54 #include "chrome/browser/first_run/first_run.h" |
54 #include "chrome/browser/google/google_util_chromeos.h" | 55 #include "chrome/browser/google/google_util_chromeos.h" |
55 #include "chrome/browser/managed_mode/managed_mode.h" | 56 #include "chrome/browser/managed_mode/managed_mode.h" |
56 #include "chrome/browser/net/chrome_url_request_context.h" | 57 #include "chrome/browser/net/chrome_url_request_context.h" |
57 #include "chrome/browser/net/preconnect.h" | 58 #include "chrome/browser/net/preconnect.h" |
58 #include "chrome/browser/policy/browser_policy_connector.h" | 59 #include "chrome/browser/policy/browser_policy_connector.h" |
59 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 60 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 has_web_auth_cookies_(false), | 121 has_web_auth_cookies_(false), |
121 login_manager_(OAuthLoginManager::Create(this)), | 122 login_manager_(OAuthLoginManager::Create(this)), |
122 delegate_(NULL), | 123 delegate_(NULL), |
123 should_restore_auth_session_(false), | 124 should_restore_auth_session_(false), |
124 session_restore_strategy_( | 125 session_restore_strategy_( |
125 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), | 126 OAuthLoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), |
126 url_request_context_getter_(NULL) { | 127 url_request_context_getter_(NULL) { |
127 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 128 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
128 // During tests, the browser_process may not be initialized yet causing | 129 // During tests, the browser_process may not be initialized yet causing |
129 // this to fail. | 130 // this to fail. |
130 if (g_browser_process) { | 131 // TODO(dzhioev): Disabled in tests for a while. |
| 132 // TODO(dzhioev): Move prewarm out of LoginUtils. |
| 133 if (g_browser_process && |
| 134 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kTestType)) { |
131 registrar_.Add( | 135 registrar_.Add( |
132 this, | 136 this, |
133 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 137 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
134 content::Source<Profile>(ProfileManager::GetDefaultProfile())); | 138 content::Source<Profile>(ProfileHelper::GetSigninProfile())); |
135 } | 139 } |
136 } | 140 } |
137 | 141 |
138 virtual ~LoginUtilsImpl() { | 142 virtual ~LoginUtilsImpl() { |
139 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 143 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
140 } | 144 } |
141 | 145 |
142 // LoginUtils implementation: | 146 // LoginUtils implementation: |
143 virtual void DoBrowserLaunch(Profile* profile, | 147 virtual void DoBrowserLaunch(Profile* profile, |
144 LoginDisplayHost* login_host) OVERRIDE; | 148 LoginDisplayHost* login_host) OVERRIDE; |
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 public: | 797 public: |
794 WarmingObserver() | 798 WarmingObserver() |
795 : url_request_context_getter_(NULL) { | 799 : url_request_context_getter_(NULL) { |
796 ConnectivityStateHelper::Get()->AddNetworkManagerObserver(this); | 800 ConnectivityStateHelper::Get()->AddNetworkManagerObserver(this); |
797 // During tests, the browser_process may not be initialized yet causing | 801 // During tests, the browser_process may not be initialized yet causing |
798 // this to fail. | 802 // this to fail. |
799 if (g_browser_process) { | 803 if (g_browser_process) { |
800 registrar_.Add( | 804 registrar_.Add( |
801 this, | 805 this, |
802 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 806 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
803 content::Source<Profile>(ProfileManager::GetDefaultProfile())); | 807 content::Source<Profile>(ProfileHelper::GetSigninProfile())); |
804 } | 808 } |
805 } | 809 } |
806 | 810 |
807 virtual ~WarmingObserver() {} | 811 virtual ~WarmingObserver() {} |
808 | 812 |
809 // If we're now connected, prewarm the auth url. | 813 // If we're now connected, prewarm the auth url. |
810 virtual void NetworkManagerChanged() OVERRIDE { | 814 virtual void NetworkManagerChanged() OVERRIDE { |
811 ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); | 815 ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); |
812 if (csh->IsConnected()) { | 816 if (csh->IsConnected()) { |
813 const int kConnectionsNeeded = 1; | 817 const int kConnectionsNeeded = 1; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 bool LoginUtils::IsWhitelisted(const std::string& username) { | 963 bool LoginUtils::IsWhitelisted(const std::string& username) { |
960 CrosSettings* cros_settings = CrosSettings::Get(); | 964 CrosSettings* cros_settings = CrosSettings::Get(); |
961 bool allow_new_user = false; | 965 bool allow_new_user = false; |
962 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 966 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
963 if (allow_new_user) | 967 if (allow_new_user) |
964 return true; | 968 return true; |
965 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 969 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
966 } | 970 } |
967 | 971 |
968 } // namespace chromeos | 972 } // namespace chromeos |
OLD | NEW |