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

Side by Side Diff: chrome/browser/google_apis/auth_service.cc

Issue 13495003: Add LoginState class to src/chromeos/login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Elim LOGGED_IN_LOCKED Created 7 years, 8 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/google_apis/auth_service.h" 5 #include "chrome/browser/google_apis/auth_service.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "chrome/browser/google_apis/auth_service_observer.h" 13 #include "chrome/browser/google_apis/auth_service_observer.h"
14 #include "chrome/browser/google_apis/operation_registry.h" 14 #include "chrome/browser/google_apis/operation_registry.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/token_service.h" 16 #include "chrome/browser/signin/token_service.h"
17 #include "chrome/browser/signin/token_service_factory.h" 17 #include "chrome/browser/signin/token_service_factory.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "content/public/browser/browser_thread.h" 19 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/notification_details.h" 20 #include "content/public/browser/notification_details.h"
21 #include "content/public/browser/notification_source.h" 21 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/notification_types.h" 22 #include "content/public/browser/notification_types.h"
23 #include "google_apis/gaia/gaia_constants.h" 23 #include "google_apis/gaia/gaia_constants.h"
24 #include "google_apis/gaia/gaia_urls.h" 24 #include "google_apis/gaia/gaia_urls.h"
25 #include "google_apis/gaia/google_service_auth_error.h" 25 #include "google_apis/gaia/google_service_auth_error.h"
26 #include "google_apis/gaia/oauth2_access_token_fetcher.h" 26 #include "google_apis/gaia/oauth2_access_token_fetcher.h"
27 27
28 #if defined(OS_CHROMEOS) 28 #if defined(OS_CHROMEOS)
29 #include "chrome/browser/chromeos/login/user_manager.h" 29 #include "chromeos/login/login_state.h"
30 #endif // OS_CHROMEOS 30 #endif // OS_CHROMEOS
31 31
32 using content::BrowserThread; 32 using content::BrowserThread;
33 33
34 namespace google_apis { 34 namespace google_apis {
35 35
36 namespace { 36 namespace {
37 37
38 // Used for success ratio histograms. 0 for failure, 1 for success, 38 // Used for success ratio histograms. 0 for failure, 1 for success,
39 // 2 for no connection (likely offline). 39 // 2 for no connection (likely offline).
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 refresh_token_.clear(); 283 refresh_token_.clear();
284 } 284 }
285 FOR_EACH_OBSERVER(AuthServiceObserver, 285 FOR_EACH_OBSERVER(AuthServiceObserver,
286 observers_, 286 observers_,
287 OnOAuth2RefreshTokenChanged()); 287 OnOAuth2RefreshTokenChanged());
288 } 288 }
289 289
290 // static 290 // static
291 bool AuthService::CanAuthenticate(Profile* profile) { 291 bool AuthService::CanAuthenticate(Profile* profile) {
292 #if defined(OS_CHROMEOS) 292 #if defined(OS_CHROMEOS)
293 if (!chromeos::UserManager::Get()->IsUserLoggedIn() || 293 if (!chromeos::LoginState::IsInitialized())
294 chromeos::UserManager::Get()->IsLoggedInAsGuest() || 294 return false;
295 chromeos::UserManager::Get()->IsLoggedInAsDemoUser()) 295 chromeos::LoginState::LoggedInUserType user_type =
296 chromeos::LoginState::Get()->GetLoggedInUserType();
297 if (user_type == chromeos::LoginState::LOGGED_IN_USER_NONE ||
298 user_type == chromeos::LoginState::LOGGED_IN_USER_GUEST ||
299 user_type == chromeos::LoginState::LOGGED_IN_USER_RETAIL_MODE)
296 return false; 300 return false;
Nikita (slow) 2013/04/10 08:09:22 nit: Add {}
stevenjb 2013/04/10 16:32:17 Done.
297 #endif // OS_CHROMEOS 301 #endif // OS_CHROMEOS
298 302
299 // Authentication cannot be done with the incognito mode profile. 303 // Authentication cannot be done with the incognito mode profile.
300 if (profile->IsOffTheRecord()) 304 if (profile->IsOffTheRecord())
301 return false; 305 return false;
302 306
303 return true; 307 return true;
304 } 308 }
305 309
306 } // namespace google_apis 310 } // namespace google_apis
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698