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/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 Loading... |
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 if (!chromeos::LoginState::Get()->IsUserAuthenticated()) |
296 return false; | 296 return false; |
297 #endif // OS_CHROMEOS | 297 #endif // OS_CHROMEOS |
298 | 298 |
299 // Authentication cannot be done with the incognito mode profile. | 299 // Authentication cannot be done with the incognito mode profile. |
300 if (profile->IsOffTheRecord()) | 300 if (profile->IsOffTheRecord()) |
301 return false; | 301 return false; |
302 | 302 |
303 return true; | 303 return true; |
304 } | 304 } |
305 | 305 |
306 } // namespace google_apis | 306 } // namespace google_apis |
OLD | NEW |