diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 14:36:58 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-31 14:36:58 +0000 |
commit | 7e4dde9f30c2583e35b222d432b4927dfbbd112f (patch) | |
tree | 3f47d272e027df6c9081f1a07d627c19e679041f | |
parent | 85aba15b5a4774eb20f0c9b93ac86dcd84bf6af2 (diff) | |
download | chromium_src-7e4dde9f30c2583e35b222d432b4927dfbbd112f.zip chromium_src-7e4dde9f30c2583e35b222d432b4927dfbbd112f.tar.gz chromium_src-7e4dde9f30c2583e35b222d432b4927dfbbd112f.tar.bz2 |
Move AuthService::CanAuthenticate(Profile*) out of AuthService.
This is a part of the effort to remove dependency in c/b/google_apis
to chrome/, so that the directory can be moved to top-level google_apis/.
BUG=264570
Review URL: https://chromiumcodereview.appspot.com/21225002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214734 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/contacts/google_contact_store.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/drive/drive_integration_service.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/profiles/profile_util.cc | 22 | ||||
-rw-r--r-- | chrome/browser/chromeos/profiles/profile_util.h | 19 | ||||
-rw-r--r-- | chrome/browser/google_apis/DEPS | 1 | ||||
-rw-r--r-- | chrome/browser/google_apis/auth_service.cc | 21 | ||||
-rw-r--r-- | chrome/browser/google_apis/auth_service.h | 7 | ||||
-rw-r--r-- | chrome/chrome_browser_chromeos.gypi | 2 |
8 files changed, 47 insertions, 31 deletions
diff --git a/chrome/browser/chromeos/contacts/google_contact_store.cc b/chrome/browser/chromeos/contacts/google_contact_store.cc index a4f40d4..45f0301 100644 --- a/chrome/browser/chromeos/contacts/google_contact_store.cc +++ b/chrome/browser/chromeos/contacts/google_contact_store.cc @@ -14,6 +14,7 @@ #include "chrome/browser/chromeos/contacts/contact_database.h" #include "chrome/browser/chromeos/contacts/contact_store_observer.h" #include "chrome/browser/chromeos/contacts/gdata_contacts_service.h" +#include "chrome/browser/chromeos/profiles/profile_util.h" #include "chrome/browser/google_apis/auth_service.h" #include "chrome/browser/google_apis/time_util.h" #include "chrome/browser/profiles/profile.h" @@ -413,7 +414,7 @@ bool GoogleContactStoreFactory::CanCreateContactStoreForProfile( Profile* profile) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(profile); - return google_apis::AuthService::CanAuthenticate(profile); + return chromeos::IsProfileAssociatedWithGaiaAccount(profile); } ContactStore* GoogleContactStoreFactory::CreateContactStore(Profile* profile) { diff --git a/chrome/browser/chromeos/drive/drive_integration_service.cc b/chrome/browser/chromeos/drive/drive_integration_service.cc index 27ec94b..74bc5fa 100644 --- a/chrome/browser/chromeos/drive/drive_integration_service.cc +++ b/chrome/browser/chromeos/drive/drive_integration_service.cc @@ -21,6 +21,7 @@ #include "chrome/browser/chromeos/drive/logging.h" #include "chrome/browser/chromeos/drive/resource_metadata.h" #include "chrome/browser/chromeos/drive/resource_metadata_storage.h" +#include "chrome/browser/chromeos/profiles/profile_util.h" #include "chrome/browser/download/download_service.h" #include "chrome/browser/download/download_service_factory.h" #include "chrome/browser/download/download_util.h" @@ -52,7 +53,7 @@ namespace { bool IsDriveEnabledForProfile(Profile* profile) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - if (!google_apis::AuthService::CanAuthenticate(profile)) + if (!chromeos::IsProfileAssociatedWithGaiaAccount(profile)) return false; // Disable Drive if preference is set. This can happen with commandline flag diff --git a/chrome/browser/chromeos/profiles/profile_util.cc b/chrome/browser/chromeos/profiles/profile_util.cc new file mode 100644 index 0000000..25222ba --- /dev/null +++ b/chrome/browser/chromeos/profiles/profile_util.cc @@ -0,0 +1,22 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/chromeos/profiles/profile_util.h" + +#include "chrome/browser/profiles/profile.h" +#include "chromeos/login/login_state.h" + +namespace chromeos { + +bool IsProfileAssociatedWithGaiaAccount(Profile* profile) { + if (!chromeos::LoginState::IsInitialized()) + return false; + if (!chromeos::LoginState::Get()->IsUserGaiaAuthenticated()) + return false; + if (profile->IsOffTheRecord()) + return false; + return true; +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/profiles/profile_util.h b/chrome/browser/chromeos/profiles/profile_util.h new file mode 100644 index 0000000..e6270b0 --- /dev/null +++ b/chrome/browser/chromeos/profiles/profile_util.h @@ -0,0 +1,19 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_UTIL_H_ +#define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_UTIL_H_ + +class Profile; + +namespace chromeos { + +// Checks if the current log-in state and the profile is GAIA-authenticated and +// thus has access to Google services. This excludes, for example, public +// accounts, locally managed users, guest or incognito profiles. +bool IsProfileAssociatedWithGaiaAccount(Profile* profile); + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_UTIL_H_ diff --git a/chrome/browser/google_apis/DEPS b/chrome/browser/google_apis/DEPS index 716bc43..49f3249 100644 --- a/chrome/browser/google_apis/DEPS +++ b/chrome/browser/google_apis/DEPS @@ -8,7 +8,6 @@ include_rules = [ specific_include_rules = { # AuthService should be gone. crbug.com/162157 "auth_service\.(h|cc)": [ - "!chrome/browser/profiles/profile.h", "!chrome/browser/signin/oauth2_token_service.h", ], } diff --git a/chrome/browser/google_apis/auth_service.cc b/chrome/browser/google_apis/auth_service.cc index d4468c6..481fc8a 100644 --- a/chrome/browser/google_apis/auth_service.cc +++ b/chrome/browser/google_apis/auth_service.cc @@ -12,13 +12,8 @@ #include "base/message_loop/message_loop_proxy.h" #include "base/metrics/histogram.h" #include "chrome/browser/google_apis/auth_service_observer.h" -#include "chrome/browser/profiles/profile.h" #include "google_apis/gaia/google_service_auth_error.h" -#if defined(OS_CHROMEOS) -#include "chromeos/login/login_state.h" -#endif // OS_CHROMEOS - namespace google_apis { namespace { @@ -235,20 +230,4 @@ void AuthService::OnHandleRefreshToken(bool has_refresh_token) { OnOAuth2RefreshTokenChanged()); } -// static -bool AuthService::CanAuthenticate(Profile* profile) { -#if defined(OS_CHROMEOS) - if (!chromeos::LoginState::IsInitialized()) - return false; - if (!chromeos::LoginState::Get()->IsUserGaiaAuthenticated()) - return false; -#endif // OS_CHROMEOS - - // Authentication cannot be done with the incognito mode profile. - if (profile->IsOffTheRecord()) - return false; - - return true; -} - } // namespace google_apis diff --git a/chrome/browser/google_apis/auth_service.h b/chrome/browser/google_apis/auth_service.h index b9b7b75..a93e017 100644 --- a/chrome/browser/google_apis/auth_service.h +++ b/chrome/browser/google_apis/auth_service.h @@ -14,8 +14,6 @@ #include "chrome/browser/google_apis/auth_service_interface.h" #include "chrome/browser/signin/oauth2_token_service.h" -class Profile; - namespace net { class URLRequestContextGetter; } @@ -56,11 +54,6 @@ class AuthService : public AuthServiceInterface, const std::string& account_id, const GoogleServiceAuthError& error) OVERRIDE; - // Returns true if authentication can be done using the class for the given - // profile. For instance, this function returns false if the profile is - // used for the incognito mode. - static bool CanAuthenticate(Profile* profile); - private: // Called when the state of the refresh token changes. void OnHandleRefreshToken(bool has_refresh_token); diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi index 3a02b68..22541f9 100644 --- a/chrome/chrome_browser_chromeos.gypi +++ b/chrome/chrome_browser_chromeos.gypi @@ -726,6 +726,8 @@ 'browser/chromeos/prerender_condition_network.h', 'browser/chromeos/profiles/profile_helper.cc', 'browser/chromeos/profiles/profile_helper.h', + 'browser/chromeos/profiles/profile_util.cc', + 'browser/chromeos/profiles/profile_util.h', 'browser/chromeos/proxy_config_service_impl.cc', 'browser/chromeos/proxy_config_service_impl.h', 'browser/chromeos/proxy_cros_settings_parser.cc', |