summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/components_tests.gyp1
-rw-r--r--components/signin.gypi21
-rw-r--r--components/signin/core/browser/signin_client.h14
-rw-r--r--components/signin/core/browser/test_signin_client.cc18
-rw-r--r--components/signin/core/browser/test_signin_client.h16
-rw-r--r--components/signin/ios/DEPS4
-rw-r--r--components/signin/ios/browser/BUILD.gn15
-rw-r--r--components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h (renamed from ios/public/test/fake_profile_oauth2_token_service_ios_provider.h)13
-rw-r--r--components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm (renamed from ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm)25
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h7
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm48
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios_delegate_unittest.mm63
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h (renamed from ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h)15
-rw-r--r--ios/chrome/browser/signin/signin_client_impl.cc12
-rw-r--r--ios/chrome/browser/signin/signin_client_impl.h3
-rw-r--r--ios/ios_tests.gyp2
-rw-r--r--ios/provider/ios_components.gyp20
-rw-r--r--ios/public/provider/chrome/browser/chrome_browser_provider.h2
18 files changed, 108 insertions, 191 deletions
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index 02c39b3..e0e1e53 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -999,6 +999,7 @@
'components.gyp:open_from_clipboard',
'components.gyp:sessions_ios',
'components.gyp:signin_ios_browser',
+ 'components.gyp:signin_ios_browser_test_support',
'components.gyp:translate_ios_browser',
'components.gyp:webp_transcode',
],
diff --git a/components/signin.gypi b/components/signin.gypi
index 15cb1d8..ea821e4 100644
--- a/components/signin.gypi
+++ b/components/signin.gypi
@@ -116,14 +116,13 @@
],
'conditions': [
['OS == "ios"', {
+ # GN version: //components/signin/core/browser:ios
'targets': [
{
- # GN version: //components/signin/core/browser:ios
'target_name': 'signin_ios_browser',
'type': 'static_library',
'dependencies': [
'signin_core_browser',
- '../ios/provider/ios_components.gyp:ios_components',
],
'include_dirs': [
'..',
@@ -136,8 +135,26 @@
'signin/ios/browser/oauth2_token_service_observer_bridge.mm',
'signin/ios/browser/profile_oauth2_token_service_ios_delegate.h',
'signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm',
+ 'signin/ios/browser/profile_oauth2_token_service_ios_provider.h',
],
},
+ {
+ 'target_name': 'signin_ios_browser_test_support',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../base/base.gyp:base',
+ 'signin_ios_browser',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ # Note: file list duplicated in GN build.
+ 'signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h',
+ 'signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm',
+ ],
+ },
+
],
}],
],
diff --git a/components/signin/core/browser/signin_client.h b/components/signin/core/browser/signin_client.h
index 13bdf84..dd8224b 100644
--- a/components/signin/core/browser/signin_client.h
+++ b/components/signin/core/browser/signin_client.h
@@ -27,14 +27,6 @@ namespace net {
class URLRequestContextGetter;
}
-#if defined(OS_IOS)
-namespace ios {
-// TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from the
-// core SigninClient.
-class ProfileOAuth2TokenServiceIOSProvider;
-}
-#endif
-
// An interface that needs to be supplied to the Signin component by its
// embedder.
class SigninClient : public KeyedService {
@@ -125,12 +117,6 @@ class SigninClient : public KeyedService {
virtual bool UpdateAccountInfo(
AccountTrackerService::AccountInfo* out_account_info) = 0;
-#if defined(OS_IOS)
- // TODO(msarda): http://crbug.com/358544 Remove this iOS specific code from
- // the core SigninClient.
- virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() = 0;
-#endif
-
// Execute |callback| if and when there is a network connection.
virtual void DelayNetworkCall(const base::Closure& callback) = 0;
diff --git a/components/signin/core/browser/test_signin_client.cc b/components/signin/core/browser/test_signin_client.cc
index 45c0fde..096fe06 100644
--- a/components/signin/core/browser/test_signin_client.cc
+++ b/components/signin/core/browser/test_signin_client.cc
@@ -11,10 +11,6 @@
#include "components/webdata/common/web_database_service.h"
#include "testing/gtest/include/gtest/gtest.h"
-#if defined(OS_IOS)
-#include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
-#endif
-
TestSigninClient::TestSigninClient()
: request_context_(new net::TestURLRequestContextGetter(
base::ThreadTaskRunnerHandle::Get())),
@@ -97,20 +93,6 @@ bool TestSigninClient::UpdateAccountInfo(
return false;
}
-#if defined(OS_IOS)
-ios::ProfileOAuth2TokenServiceIOSProvider* TestSigninClient::GetIOSProvider() {
- return GetIOSProviderAsFake();
-}
-
-ios::FakeProfileOAuth2TokenServiceIOSProvider*
-TestSigninClient::GetIOSProviderAsFake() {
- if (!iosProvider_) {
- iosProvider_.reset(new ios::FakeProfileOAuth2TokenServiceIOSProvider());
- }
- return iosProvider_.get();
-}
-#endif
-
bool TestSigninClient::IsFirstRun() const {
return false;
}
diff --git a/components/signin/core/browser/test_signin_client.h b/components/signin/core/browser/test_signin_client.h
index 8c35970..3a7895c 100644
--- a/components/signin/core/browser/test_signin_client.h
+++ b/components/signin/core/browser/test_signin_client.h
@@ -13,10 +13,6 @@
#include "components/signin/core/browser/signin_client.h"
#include "net/url_request/url_request_test_util.h"
-#if defined(OS_IOS)
-#include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
-#endif
-
class PrefService;
// An implementation of SigninClient for use in unittests. Instantiates test
@@ -67,10 +63,6 @@ class TestSigninClient : public SigninClient {
// in the default constructor.
void SetURLRequestContext(net::URLRequestContextGetter* request_context);
-#if defined(OS_IOS)
- ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() override;
-#endif
-
// Returns true.
bool ShouldMergeSigninCredentialsIntoCookieJar() override;
@@ -84,10 +76,6 @@ class TestSigninClient : public SigninClient {
bool UpdateAccountInfo(
AccountTrackerService::AccountInfo* out_account_info) override;
-#if defined(OS_IOS)
- ios::FakeProfileOAuth2TokenServiceIOSProvider* GetIOSProviderAsFake();
-#endif
-
void set_are_signin_cookies_allowed(bool value) {
are_signin_cookies_allowed_ = value;
}
@@ -119,10 +107,6 @@ class TestSigninClient : public SigninClient {
// Pointer to be filled by PostSignedIn.
std::string signed_in_password_;
-#if defined(OS_IOS)
- scoped_ptr<ios::FakeProfileOAuth2TokenServiceIOSProvider> iosProvider_;
-#endif
-
DISALLOW_COPY_AND_ASSIGN(TestSigninClient);
};
diff --git a/components/signin/ios/DEPS b/components/signin/ios/DEPS
deleted file mode 100644
index a2fbbc5..0000000
--- a/components/signin/ios/DEPS
+++ /dev/null
@@ -1,4 +0,0 @@
-include_rules = [
- "+ios/public/provider/components/signin",
- "+ios/public/test",
-]
diff --git a/components/signin/ios/browser/BUILD.gn b/components/signin/ios/browser/BUILD.gn
index 531d11c..70b03f5 100644
--- a/components/signin/ios/browser/BUILD.gn
+++ b/components/signin/ios/browser/BUILD.gn
@@ -10,10 +10,23 @@ static_library("browser") {
"oauth2_token_service_observer_bridge.mm",
"profile_oauth2_token_service_ios_delegate.h",
"profile_oauth2_token_service_ios_delegate.mm",
+ "profile_oauth2_token_service_ios_provider.h",
]
deps = [
"//signin/core/browser",
- #'../ios/provider/ios_components.gyp:ios_components', TODO(GYP)
+ ]
+}
+
+static_library("test_support") {
+ testonly = true
+ sources = [
+ "fake_profile_oauth2_token_service_ios_provider.h",
+ "fake_profile_oauth2_token_service_ios_provider.mm",
+ ]
+
+ deps = [
+ "//base",
+ ":browser",
]
}
diff --git a/ios/public/test/fake_profile_oauth2_token_service_ios_provider.h b/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h
index 64c335a..6df9ecd 100644
--- a/ios/public/test/fake_profile_oauth2_token_service_ios_provider.h
+++ b/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h
@@ -10,9 +10,7 @@
#include <vector>
#include "base/memory/scoped_ptr.h"
-#include "ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h"
-
-namespace ios {
+#include "components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h"
// Mock class of ProfileOAuth2TokenServiceIOSProvider for testing.
class FakeProfileOAuth2TokenServiceIOSProvider
@@ -22,20 +20,15 @@ class FakeProfileOAuth2TokenServiceIOSProvider
~FakeProfileOAuth2TokenServiceIOSProvider() override;
// ProfileOAuth2TokenServiceIOSProvider
- void InitializeSharedAuthentication() override;
-
void GetAccessToken(const std::string& account_id,
const std::string& client_id,
const std::string& client_secret,
const std::set<std::string>& scopes,
const AccessTokenCallback& callback) override;
-
std::vector<std::string> GetAllAccountIds() override;
-
AuthenticationErrorCategory GetAuthenticationErrorCategory(
NSError* error) const override;
-
- ios::AccountInfo GetAccountInfo(const std::string& account_id) const override;
+ AccountInfo GetAccountInfo(const std::string& account_id) const override;
// Methods to configure this fake provider.
void AddAccount(const std::string& account_id);
@@ -55,6 +48,4 @@ class FakeProfileOAuth2TokenServiceIOSProvider
DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenServiceIOSProvider);
};
-} // namespace ios
-
#endif // IOS_TEST_PROVIDER_CHROME_BROWSER_SIGNIN_MOCK_PROFILE_OAUTH2_TOKEN_SERVICE_PROVIDER_IOS_H_
diff --git a/ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm b/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm
index f8d6cf8..345aab1 100644
--- a/ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm
+++ b/components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.mm
@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
+#include "components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h"
#include <Foundation/Foundation.h>
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
-namespace ios {
-
FakeProfileOAuth2TokenServiceIOSProvider::
- FakeProfileOAuth2TokenServiceIOSProvider() {}
+ FakeProfileOAuth2TokenServiceIOSProvider() {
+}
FakeProfileOAuth2TokenServiceIOSProvider::
- ~FakeProfileOAuth2TokenServiceIOSProvider() {}
+ ~FakeProfileOAuth2TokenServiceIOSProvider() {
+}
void FakeProfileOAuth2TokenServiceIOSProvider::GetAccessToken(
const std::string& account_id,
@@ -45,8 +45,8 @@ void FakeProfileOAuth2TokenServiceIOSProvider::ClearAccounts() {
accounts_.clear();
}
-void
-FakeProfileOAuth2TokenServiceIOSProvider::IssueAccessTokenForAllRequests() {
+void FakeProfileOAuth2TokenServiceIOSProvider::
+ IssueAccessTokenForAllRequests() {
for (auto i = requests_.begin(); i != requests_.end(); ++i) {
std::string account_id = i->first;
AccessTokenCallback callback = i->second;
@@ -71,19 +71,14 @@ void FakeProfileOAuth2TokenServiceIOSProvider::
requests_.clear();
}
-void
-FakeProfileOAuth2TokenServiceIOSProvider::InitializeSharedAuthentication() {}
-
AuthenticationErrorCategory
FakeProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory(
NSError* error) const {
DCHECK(error);
- return ios::kAuthenticationErrorCategoryAuthorizationErrors;
+ return kAuthenticationErrorCategoryAuthorizationErrors;
}
-ios::AccountInfo FakeProfileOAuth2TokenServiceIOSProvider::GetAccountInfo(
+AccountInfo FakeProfileOAuth2TokenServiceIOSProvider::GetAccountInfo(
const std::string& account_id) const {
- return ios::AccountInfo();
+ return AccountInfo();
}
-
-} // namespace ios
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
index b03af70..730117a 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.h
@@ -11,14 +11,13 @@
#include "components/signin/core/browser/signin_error_controller.h"
#include "google_apis/gaia/oauth2_token_service_delegate.h"
-namespace ios {
class ProfileOAuth2TokenServiceIOSProvider;
-}
class ProfileOAuth2TokenServiceIOSDelegate : public OAuth2TokenServiceDelegate {
public:
ProfileOAuth2TokenServiceIOSDelegate(
SigninClient* client,
+ ProfileOAuth2TokenServiceIOSProvider* provider,
SigninErrorController* signin_error_controller);
~ProfileOAuth2TokenServiceIOSDelegate() override;
@@ -111,9 +110,6 @@ class ProfileOAuth2TokenServiceIOSDelegate : public OAuth2TokenServiceDelegate {
// to information about the account.
typedef std::map<std::string, linked_ptr<AccountInfo>> AccountInfoMap;
- // Returns the iOS provider;
- ios::ProfileOAuth2TokenServiceIOSProvider* GetProvider();
-
// Returns the account ids that should be ignored by this token service.
std::set<std::string> GetExcludedSecondaryAccounts();
@@ -136,6 +132,7 @@ class ProfileOAuth2TokenServiceIOSDelegate : public OAuth2TokenServiceDelegate {
// The client with which this instance was initialied, or NULL.
SigninClient* client_;
+ ProfileOAuth2TokenServiceIOSProvider* provider_;
// The error controller with which this instance was initialized, or NULL.
SigninErrorController* signin_error_controller_;
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
index a177f8e..6e91264 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate.mm
@@ -19,8 +19,8 @@
#include "base/values.h"
#include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h"
#include "google_apis/gaia/oauth2_access_token_fetcher.h"
-#include "ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h"
#include "net/url_request/url_request_status.h"
namespace {
@@ -28,35 +28,35 @@ namespace {
// Match the way Chromium handles authentication errors in
// google_apis/gaia/oauth2_access_token_fetcher.cc:
GoogleServiceAuthError GetGoogleServiceAuthErrorFromNSError(
- ios::ProfileOAuth2TokenServiceIOSProvider* provider,
+ ProfileOAuth2TokenServiceIOSProvider* provider,
NSError* error) {
if (!error)
return GoogleServiceAuthError::AuthErrorNone();
- ios::AuthenticationErrorCategory errorCategory =
+ AuthenticationErrorCategory errorCategory =
provider->GetAuthenticationErrorCategory(error);
switch (errorCategory) {
- case ios::kAuthenticationErrorCategoryUnknownErrors:
+ case kAuthenticationErrorCategoryUnknownErrors:
// Treat all unknown error as unexpected service response errors.
// This may be too general and may require a finer grain filtering.
return GoogleServiceAuthError(
GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE);
- case ios::kAuthenticationErrorCategoryAuthorizationErrors:
+ case kAuthenticationErrorCategoryAuthorizationErrors:
return GoogleServiceAuthError(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
- case ios::kAuthenticationErrorCategoryAuthorizationForbiddenErrors:
+ case kAuthenticationErrorCategoryAuthorizationForbiddenErrors:
// HTTP_FORBIDDEN (403) is treated as temporary error, because it may be
// '403 Rate Limit Exceeded.' (for more details, see
// google_apis/gaia/oauth2_access_token_fetcher.cc).
return GoogleServiceAuthError(
GoogleServiceAuthError::SERVICE_UNAVAILABLE);
- case ios::kAuthenticationErrorCategoryNetworkServerErrors:
+ case kAuthenticationErrorCategoryNetworkServerErrors:
// Just set the connection error state to FAILED.
return GoogleServiceAuthError::FromConnectionError(
net::URLRequestStatus::FAILED);
- case ios::kAuthenticationErrorCategoryUserCancellationErrors:
+ case kAuthenticationErrorCategoryUserCancellationErrors:
return GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED);
- case ios::kAuthenticationErrorCategoryUnknownIdentityErrors:
+ case kAuthenticationErrorCategoryUnknownIdentityErrors:
return GoogleServiceAuthError(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
}
}
@@ -64,7 +64,7 @@ GoogleServiceAuthError GetGoogleServiceAuthErrorFromNSError(
class SSOAccessTokenFetcher : public OAuth2AccessTokenFetcher {
public:
SSOAccessTokenFetcher(OAuth2AccessTokenConsumer* consumer,
- ios::ProfileOAuth2TokenServiceIOSProvider* provider,
+ ProfileOAuth2TokenServiceIOSProvider* provider,
const std::string account_id);
~SSOAccessTokenFetcher() override;
@@ -80,7 +80,7 @@ class SSOAccessTokenFetcher : public OAuth2AccessTokenFetcher {
NSError* error);
private:
- ios::ProfileOAuth2TokenServiceIOSProvider* provider_; // weak
+ ProfileOAuth2TokenServiceIOSProvider* provider_; // weak
std::string account_id_;
bool request_was_cancelled_;
base::WeakPtrFactory<SSOAccessTokenFetcher> weak_factory_;
@@ -90,7 +90,7 @@ class SSOAccessTokenFetcher : public OAuth2AccessTokenFetcher {
SSOAccessTokenFetcher::SSOAccessTokenFetcher(
OAuth2AccessTokenConsumer* consumer,
- ios::ProfileOAuth2TokenServiceIOSProvider* provider,
+ ProfileOAuth2TokenServiceIOSProvider* provider,
const std::string account_id)
: OAuth2AccessTokenFetcher(consumer),
provider_(provider),
@@ -173,11 +173,14 @@ ProfileOAuth2TokenServiceIOSDelegate::AccountInfo::GetAuthStatus() const {
ProfileOAuth2TokenServiceIOSDelegate::ProfileOAuth2TokenServiceIOSDelegate(
SigninClient* client,
+ ProfileOAuth2TokenServiceIOSProvider* provider,
SigninErrorController* signin_error_controller)
- : client_(client), signin_error_controller_(signin_error_controller) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(client);
- DCHECK(signin_error_controller);
+ : client_(client),
+ provider_(provider),
+ signin_error_controller_(signin_error_controller) {
+ DCHECK(client_);
+ DCHECK(provider_);
+ DCHECK(signin_error_controller_);
}
ProfileOAuth2TokenServiceIOSDelegate::~ProfileOAuth2TokenServiceIOSDelegate() {
@@ -189,14 +192,6 @@ void ProfileOAuth2TokenServiceIOSDelegate::Shutdown() {
accounts_.clear();
}
-ios::ProfileOAuth2TokenServiceIOSProvider*
-ProfileOAuth2TokenServiceIOSDelegate::GetProvider() {
- ios::ProfileOAuth2TokenServiceIOSProvider* provider =
- client_->GetIOSProvider();
- DCHECK(provider);
- return provider;
-}
-
void ProfileOAuth2TokenServiceIOSDelegate::LoadCredentials(
const std::string& primary_account_id) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -205,7 +200,6 @@ void ProfileOAuth2TokenServiceIOSDelegate::LoadCredentials(
// primary account id must not be empty.
DCHECK(!primary_account_id.empty());
- GetProvider()->InitializeSharedAuthentication();
ReloadCredentials(primary_account_id);
FireRefreshTokensLoaded();
}
@@ -226,7 +220,7 @@ void ProfileOAuth2TokenServiceIOSDelegate::ReloadCredentials() {
return;
}
- std::vector<std::string> new_accounts(GetProvider()->GetAllAccountIds());
+ std::vector<std::string> new_accounts(provider_->GetAllAccountIds());
if (GetExcludeAllSecondaryAccounts()) {
// Only keep the |primary_account_id| in the list of new accounts.
if (std::find(new_accounts.begin(), new_accounts.end(),
@@ -299,7 +293,7 @@ ProfileOAuth2TokenServiceIOSDelegate::CreateAccessTokenFetcher(
const std::string& account_id,
net::URLRequestContextGetter* getter,
OAuth2AccessTokenConsumer* consumer) {
- return new SSOAccessTokenFetcher(consumer, GetProvider(), account_id);
+ return new SSOAccessTokenFetcher(consumer, provider_, account_id);
}
std::vector<std::string> ProfileOAuth2TokenServiceIOSDelegate::GetAccounts() {
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate_unittest.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate_unittest.mm
index bf4b0b2..6ec18aa 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate_unittest.mm
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_delegate_unittest.mm
@@ -10,10 +10,10 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/test_signin_client.h"
#include "components/signin/core/common/signin_pref_names.h"
+#include "components/signin/ios/browser/fake_profile_oauth2_token_service_ios_provider.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/oauth2_access_token_consumer.h"
#include "google_apis/gaia/oauth2_token_service_test_util.h"
-#include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -40,9 +40,8 @@ class ProfileOAuth2TokenServiceIOSDelegateTest
factory_.SetFakeResponse(GaiaUrls::GetInstance()->oauth2_revoke_url(), "",
net::HTTP_OK, net::URLRequestStatus::SUCCESS);
- fake_provider_ = client_.GetIOSProviderAsFake();
oauth2_service_delegate_.reset(new ProfileOAuth2TokenServiceIOSDelegate(
- &client_, &signin_error_controller_));
+ &client_, &fake_provider_, &signin_error_controller_));
oauth2_service_delegate_->AddObserver(this);
}
@@ -85,7 +84,7 @@ class ProfileOAuth2TokenServiceIOSDelegateTest
TestingPrefServiceSimple prefs_;
TestSigninClient client_;
SigninErrorController signin_error_controller_;
- ios::FakeProfileOAuth2TokenServiceIOSProvider* fake_provider_;
+ FakeProfileOAuth2TokenServiceIOSProvider fake_provider_;
scoped_ptr<ProfileOAuth2TokenServiceIOSDelegate> oauth2_service_delegate_;
TestingOAuth2TokenServiceConsumer consumer_;
int token_available_count_;
@@ -98,7 +97,7 @@ class ProfileOAuth2TokenServiceIOSDelegateTest
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
LoadRevokeCredentialsOneAccount) {
- fake_provider_->AddAccount("account_id");
+ fake_provider_.AddAccount("account_id");
oauth2_service_delegate_->LoadCredentials("account_id");
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, token_available_count_);
@@ -119,9 +118,9 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
LoadRevokeCredentialsMultipleAccounts) {
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
- fake_provider_->AddAccount("account_id_3");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_3");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
EXPECT_EQ(3, token_available_count_);
@@ -150,17 +149,17 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
}
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ReloadCredentials) {
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
- fake_provider_->AddAccount("account_id_3");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_3");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
// Change the accounts.
ResetObserverCounts();
- fake_provider_->ClearAccounts();
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_4");
+ fake_provider_.ClearAccounts();
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_4");
oauth2_service_delegate_->ReloadCredentials();
EXPECT_EQ(1, token_available_count_);
@@ -181,8 +180,8 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
ReloadCredentialsIgnoredIfNoPrimaryAccountId) {
// Change the accounts.
ResetObserverCounts();
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
base::RunLoop().RunUntilIdle();
oauth2_service_delegate_->ReloadCredentials();
@@ -201,8 +200,8 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
ReloadCredentialsWithPrimaryAccountId) {
// Change the accounts.
ResetObserverCounts();
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
base::RunLoop().RunUntilIdle();
oauth2_service_delegate_->ReloadCredentials("account_id_1");
@@ -219,8 +218,8 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeAllSecondaryAccounts) {
// Change the accounts.
ResetObserverCounts();
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
base::RunLoop().RunUntilIdle();
oauth2_service_delegate_->ExcludeAllSecondaryAccounts();
@@ -236,7 +235,7 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeAllSecondaryAccounts) {
}
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, StartRequestSuccess) {
- fake_provider_->AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_1");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
@@ -252,14 +251,14 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, StartRequestSuccess) {
EXPECT_EQ(0, access_token_failure_);
ResetObserverCounts();
- fake_provider_->IssueAccessTokenForAllRequests();
+ fake_provider_.IssueAccessTokenForAllRequests();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(1, access_token_success_);
EXPECT_EQ(0, access_token_failure_);
}
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, StartRequestFailure) {
- fake_provider_->AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_1");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
@@ -275,16 +274,16 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, StartRequestFailure) {
EXPECT_EQ(0, access_token_failure_);
ResetObserverCounts();
- fake_provider_->IssueAccessTokenErrorForAllRequests();
+ fake_provider_.IssueAccessTokenErrorForAllRequests();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0, access_token_success_);
EXPECT_EQ(1, access_token_failure_);
}
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeSecondaryAccounts) {
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
- fake_provider_->AddAccount("account_id_3");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_3");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
@@ -323,8 +322,8 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeSecondaryAccounts) {
// Unit test for for http://crbug.com/453470 .
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeSecondaryAccountTwice) {
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
oauth2_service_delegate_->LoadCredentials("account_id_1");
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(
@@ -354,9 +353,9 @@ TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest, ExcludeSecondaryAccountTwice) {
TEST_F(ProfileOAuth2TokenServiceIOSDelegateTest,
LoadRevokeCredentialsClearsExcludedAccounts) {
- fake_provider_->AddAccount("account_id_1");
- fake_provider_->AddAccount("account_id_2");
- fake_provider_->AddAccount("account_id_3");
+ fake_provider_.AddAccount("account_id_1");
+ fake_provider_.AddAccount("account_id_2");
+ fake_provider_.AddAccount("account_id_3");
std::vector<std::string> excluded_accounts;
excluded_accounts.push_back("account_id_2");
diff --git a/ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h
index 4833cd6..ad9966d 100644
--- a/ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
-#define IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
+#ifndef COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
+#define COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
#if defined(__OBJC__)
@class NSDate;
@@ -21,8 +21,6 @@ class NSString;
#include "base/callback.h"
-namespace ios {
-
// Account information.
struct AccountInfo {
AccountInfo() {}
@@ -57,11 +55,6 @@ class ProfileOAuth2TokenServiceIOSProvider {
ProfileOAuth2TokenServiceIOSProvider() {}
virtual ~ProfileOAuth2TokenServiceIOSProvider() {}
- // Initializes the shared authentication library. This method should be called
- // when loading credentials if the user is signed in to Chrome via the shared
- // authentication library.
- virtual void InitializeSharedAuthentication() = 0;
-
// Returns the ids of all accounts.
virtual std::vector<std::string> GetAllAccountIds() = 0;
@@ -82,6 +75,4 @@ class ProfileOAuth2TokenServiceIOSProvider {
virtual AccountInfo GetAccountInfo(const std::string& account_id) const = 0;
};
-} // namespace ios
-
-#endif // IOS_PUBLIC_PROVIDER_COMPONENTS_SIGNIN_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
+#endif // COMPONENTS_SIGNIN_IOS_BROWSER_PROFILE_OAUTH2_TOKEN_SERVICE_IOS_PROVIDER_H_
diff --git a/ios/chrome/browser/signin/signin_client_impl.cc b/ios/chrome/browser/signin/signin_client_impl.cc
index 8840961..da96e34 100644
--- a/ios/chrome/browser/signin/signin_client_impl.cc
+++ b/ios/chrome/browser/signin/signin_client_impl.cc
@@ -17,6 +17,7 @@
#include "components/signin/core/common/profile_management_switches.h"
#include "components/signin/core/common/signin_pref_names.h"
#include "components/signin/core/common/signin_switches.h"
+#include "components/signin/ios/browser/profile_oauth2_token_service_ios_provider.h"
#include "google_apis/gaia/gaia_constants.h"
#include "google_apis/gaia/gaia_urls.h"
#include "ios/chrome/browser/application_context.h"
@@ -27,7 +28,6 @@
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state_manager.h"
#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
-#include "ios/public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h"
#include "net/url_request/url_request_context_getter.h"
#include "url/gurl.h"
@@ -192,8 +192,9 @@ void SigninClientImpl::OnSignedIn(const std::string& account_id,
bool SigninClientImpl::UpdateAccountInfo(
AccountTrackerService::AccountInfo* out_account_info) {
DCHECK(!out_account_info->account_id.empty());
- ios::AccountInfo account_info =
- GetIOSProvider()->GetAccountInfo(out_account_info->account_id);
+ AccountInfo account_info = ios::GetChromeBrowserProvider()
+ ->GetProfileOAuth2TokenServiceIOSProvider()
+ ->GetAccountInfo(out_account_info->account_id);
if (account_info.gaia.empty()) {
// There is no account information for this account, so there is nothing
// to be updated here.
@@ -218,11 +219,6 @@ bool SigninClientImpl::UpdateAccountInfo(
return updated;
}
-ios::ProfileOAuth2TokenServiceIOSProvider* SigninClientImpl::GetIOSProvider() {
- return ios::GetChromeBrowserProvider()
- ->GetProfileOAuth2TokenServiceIOSProvider();
-}
-
void SigninClientImpl::OnErrorChanged() {
ios::BrowserStateInfoCache* cache = GetApplicationContext()
->GetChromeBrowserStateManager()
diff --git a/ios/chrome/browser/signin/signin_client_impl.h b/ios/chrome/browser/signin/signin_client_impl.h
index 1c338dd..267ebf6 100644
--- a/ios/chrome/browser/signin/signin_client_impl.h
+++ b/ios/chrome/browser/signin/signin_client_impl.h
@@ -80,12 +80,9 @@ class SigninClientImpl
const std::string& gaia_id,
const std::string& username,
const std::string& password) override;
-
bool UpdateAccountInfo(
AccountTrackerService::AccountInfo* out_account_info) override;
- ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() override;
-
// SigninErrorController::Observer implementation.
void OnErrorChanged() override;
diff --git a/ios/ios_tests.gyp b/ios/ios_tests.gyp
index 7518951..4408588 100644
--- a/ios/ios_tests.gyp
+++ b/ios/ios_tests.gyp
@@ -12,8 +12,6 @@
'sources': [
# TODO(droger): Move most of these files to
# //ios/chrome/ios_chrome_tests.gyp, see http://crbug.com/437333
- 'public/test/fake_profile_oauth2_token_service_ios_provider.h',
- 'public/test/fake_profile_oauth2_token_service_ios_provider.mm',
'public/test/fake_string_provider.cc',
'public/test/fake_string_provider.h',
'public/test/fake_sync_service_factory.cc',
diff --git a/ios/provider/ios_components.gyp b/ios/provider/ios_components.gyp
deleted file mode 100644
index bd3f4f2..0000000
--- a/ios/provider/ios_components.gyp
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2014 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.
-{
- 'variables': {
- 'chromium_code': 1,
- },
- 'targets': [
- {
- 'target_name': 'ios_components',
- 'type': 'none',
- 'include_dirs': [
- '../..',
- ],
- 'sources': [
- '../public/provider/components/signin/browser/profile_oauth2_token_service_ios_provider.h',
- ]
- },
- ],
-}
diff --git a/ios/public/provider/chrome/browser/chrome_browser_provider.h b/ios/public/provider/chrome/browser/chrome_browser_provider.h
index 713cefa..096b9c3 100644
--- a/ios/public/provider/chrome/browser/chrome_browser_provider.h
+++ b/ios/public/provider/chrome/browser/chrome_browser_provider.h
@@ -11,6 +11,7 @@
class InfoBarViewDelegate;
class PrefService;
+class ProfileOAuth2TokenServiceIOSProvider;
namespace autofill {
class CardUnmaskPromptController;
@@ -42,7 +43,6 @@ namespace ios {
class ChromeBrowserProvider;
class ChromeBrowserStateManager;
class GeolocationUpdaterProvider;
-class ProfileOAuth2TokenServiceIOSProvider;
class StringProvider;
class UpdatableResourceProvider;