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

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

Issue 11620007: Switch from OnIPAddressChanged and OnConnectionTypeChange to OnNetworkChanged Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 int pid_; 174 int pid_;
175 std::string command_line_; 175 std::string command_line_;
176 PrefService* local_state_; 176 PrefService* local_state_;
177 base::OneShotTimer<JobRestartRequest> timer_; 177 base::OneShotTimer<JobRestartRequest> timer_;
178 }; 178 };
179 179
180 class LoginUtilsImpl 180 class LoginUtilsImpl
181 : public LoginUtils, 181 : public LoginUtils,
182 public OAuth1TokenFetcher::Delegate, 182 public OAuth1TokenFetcher::Delegate,
183 public OAuthLoginVerifier::Delegate, 183 public OAuthLoginVerifier::Delegate,
184 public net::NetworkChangeNotifier::ConnectionTypeObserver, 184 public net::NetworkChangeNotifier::NetworkChangeObserver,
185 public content::NotificationObserver, 185 public content::NotificationObserver,
186 public base::SupportsWeakPtr<LoginUtilsImpl> { 186 public base::SupportsWeakPtr<LoginUtilsImpl> {
187 public: 187 public:
188 LoginUtilsImpl() 188 LoginUtilsImpl()
189 : pending_requests_(false), 189 : pending_requests_(false),
190 using_oauth_(false), 190 using_oauth_(false),
191 has_web_auth_cookies_(false), 191 has_web_auth_cookies_(false),
192 delegate_(NULL), 192 delegate_(NULL),
193 job_restart_request_(NULL), 193 job_restart_request_(NULL),
194 should_restore_auth_session_(false), 194 should_restore_auth_session_(false),
195 url_request_context_getter_(NULL) { 195 url_request_context_getter_(NULL) {
196 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); 196 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
197 // During tests, the browser_process may not be initialized yet causing 197 // During tests, the browser_process may not be initialized yet causing
198 // this to fail. 198 // this to fail.
199 if (g_browser_process) { 199 if (g_browser_process) {
200 registrar_.Add( 200 registrar_.Add(
201 this, 201 this,
202 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, 202 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED,
203 content::Source<Profile>(ProfileManager::GetDefaultProfile())); 203 content::Source<Profile>(ProfileManager::GetDefaultProfile()));
204 } 204 }
205 } 205 }
206 206
207 virtual ~LoginUtilsImpl() { 207 virtual ~LoginUtilsImpl() {
208 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 208 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
209 } 209 }
210 210
211 // LoginUtils implementation: 211 // LoginUtils implementation:
212 virtual void DoBrowserLaunch(Profile* profile, 212 virtual void DoBrowserLaunch(Profile* profile,
213 LoginDisplayHost* login_host) OVERRIDE; 213 LoginDisplayHost* login_host) OVERRIDE;
214 virtual void PrepareProfile( 214 virtual void PrepareProfile(
215 const std::string& username, 215 const std::string& username,
216 const std::string& display_email, 216 const std::string& display_email,
217 const std::string& password, 217 const std::string& password,
218 bool pending_requests, 218 bool pending_requests,
(...skipping 20 matching lines...) Expand all
239 const std::string& secret) OVERRIDE; 239 const std::string& secret) OVERRIDE;
240 void OnOAuth1AccessTokenFetchFailed() OVERRIDE; 240 void OnOAuth1AccessTokenFetchFailed() OVERRIDE;
241 241
242 // OAuthLoginVerifier::Delegate overrides. 242 // OAuthLoginVerifier::Delegate overrides.
243 virtual void OnOAuthVerificationSucceeded(const std::string& user_name, 243 virtual void OnOAuthVerificationSucceeded(const std::string& user_name,
244 const std::string& sid, 244 const std::string& sid,
245 const std::string& lsid, 245 const std::string& lsid,
246 const std::string& auth) OVERRIDE; 246 const std::string& auth) OVERRIDE;
247 virtual void OnOAuthVerificationFailed(const std::string& user_name) OVERRIDE; 247 virtual void OnOAuthVerificationFailed(const std::string& user_name) OVERRIDE;
248 248
249 // net::NetworkChangeNotifier::ConnectionTypeObserver overrides. 249 // net::NetworkChangeNotifier::NetworkChangeObserver overrides.
250 virtual void OnConnectionTypeChanged( 250 virtual void OnNetworkChanged(
251 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; 251 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE;
252 252
253 // content::NotificationObserver overrides. 253 // content::NotificationObserver overrides.
254 virtual void Observe(int type, 254 virtual void Observe(int type,
255 const content::NotificationSource& source, 255 const content::NotificationSource& source,
256 const content::NotificationDetails& details) OVERRIDE; 256 const content::NotificationDetails& details) OVERRIDE;
257 257
258 protected: 258 protected:
259 virtual std::string GetOffTheRecordCommandLine( 259 virtual std::string GetOffTheRecordCommandLine(
260 const GURL& start_url, 260 const GURL& start_url,
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 void LoginUtilsImpl::OnOAuthVerificationSucceeded( 1195 void LoginUtilsImpl::OnOAuthVerificationSucceeded(
1196 const std::string& user_name, const std::string& sid, 1196 const std::string& user_name, const std::string& sid,
1197 const std::string& lsid, const std::string& auth) { 1197 const std::string& lsid, const std::string& auth) {
1198 // Kick off sync engine. 1198 // Kick off sync engine.
1199 GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth, 1199 GaiaAuthConsumer::ClientLoginResult credentials(sid, lsid, auth,
1200 std::string()); 1200 std::string());
1201 StartSignedInServices(ProfileManager::GetDefaultProfile(), credentials); 1201 StartSignedInServices(ProfileManager::GetDefaultProfile(), credentials);
1202 } 1202 }
1203 1203
1204 1204
1205 void LoginUtilsImpl::OnConnectionTypeChanged( 1205 void LoginUtilsImpl::OnNetworkChanged(
1206 net::NetworkChangeNotifier::ConnectionType type) { 1206 net::NetworkChangeNotifier::ConnectionType type) {
1207 if (type != net::NetworkChangeNotifier::CONNECTION_NONE && 1207 if (type != net::NetworkChangeNotifier::CONNECTION_NONE &&
1208 UserManager::Get()->IsUserLoggedIn()) { 1208 UserManager::Get()->IsUserLoggedIn()) {
1209 if (oauth_login_verifier_.get() && 1209 if (oauth_login_verifier_.get() &&
1210 !oauth_login_verifier_->is_done()) { 1210 !oauth_login_verifier_->is_done()) {
1211 // If we come online for the first time after successful offline login, 1211 // If we come online for the first time after successful offline login,
1212 // we need to kick off OAuth token verification process again. 1212 // we need to kick off OAuth token verification process again.
1213 oauth_login_verifier_->ContinueVerification(); 1213 oauth_login_verifier_->ContinueVerification();
1214 } else if (should_restore_auth_session_) { 1214 } else if (should_restore_auth_session_) {
1215 should_restore_auth_session_ = false; 1215 should_restore_auth_session_ = false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1251 bool LoginUtils::IsWhitelisted(const std::string& username) { 1251 bool LoginUtils::IsWhitelisted(const std::string& username) {
1252 CrosSettings* cros_settings = CrosSettings::Get(); 1252 CrosSettings* cros_settings = CrosSettings::Get();
1253 bool allow_new_user = false; 1253 bool allow_new_user = false;
1254 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); 1254 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user);
1255 if (allow_new_user) 1255 if (allow_new_user)
1256 return true; 1256 return true;
1257 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); 1257 return cros_settings->FindEmailInList(kAccountsPrefUsers, username);
1258 } 1258 }
1259 1259
1260 } // namespace chromeos 1260 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698