summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormlerman <mlerman@chromium.org>2015-01-09 08:23:35 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-09 16:24:21 +0000
commit3247f076b4c8b9be5281d34b217c9236688a6725 (patch)
treed898afb2544adeeb0fa9247065f474d2cafceb9c
parent2d4e62d2cbd43d83fc43d58f0fdaa904633c33c1 (diff)
downloadchromium_src-3247f076b4c8b9be5281d34b217c9236688a6725.zip
chromium_src-3247f076b4c8b9be5281d34b217c9236688a6725.tar.gz
chromium_src-3247f076b4c8b9be5281d34b217c9236688a6725.tar.bz2
Make the SigninErrorController a PKS.
This is a prelude to https://codereview.chromium.org/813133003/, which will introduce some dependencies between the SigninErrorController and some other PKSes. To make these cleaner, this is a yak shave to move the SigninErrorController out from being a member of the ProfileOAuth2TokenService (which is a ProfileKeyedService) and into its own PKS. BUG=434829 Review URL: https://codereview.chromium.org/809313009 Cr-Commit-Position: refs/heads/master@{#310774}
-rw-r--r--chrome/browser/profiles/profiles_state.cc5
-rw-r--r--chrome/browser/signin/android_profile_oauth2_token_service.cc6
-rw-r--r--chrome/browser/signin/android_profile_oauth2_token_service.h4
-rw-r--r--chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc7
-rw-r--r--chrome/browser/signin/profile_oauth2_token_service_factory.cc5
-rw-r--r--chrome/browser/signin/signin_error_controller_factory.cc32
-rw-r--r--chrome/browser/signin/signin_error_controller_factory.h37
-rw-r--r--chrome/browser/signin/signin_error_notifier_ash_unittest.cc8
-rw-r--r--chrome/browser/signin/signin_error_notifier_factory_ash.cc11
-rw-r--r--chrome/browser/signin/signin_global_error_factory.cc11
-rw-r--r--chrome/browser/signin/signin_global_error_unittest.cc6
-rw-r--r--chrome/browser/signin/signin_ui_util.cc7
-rw-r--r--chrome/browser/sync/sync_ui_util.cc11
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc9
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm6
-rw-r--r--chrome/browser/ui/sync/one_click_signin_helper.cc6
-rw-r--r--chrome/browser/ui/webui/options/supervised_user_import_handler.cc17
-rw-r--r--chrome/browser/ui/webui/options/sync_setup_handler.cc9
-rw-r--r--chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc6
-rw-r--r--chrome/browser/ui/webui/signin/inline_login_handler_impl.cc4
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--components/signin/core/browser/mutable_profile_oauth2_token_service.cc24
-rw-r--r--components/signin/core/browser/mutable_profile_oauth2_token_service.h5
-rw-r--r--components/signin/core/browser/mutable_profile_oauth2_token_service_unittest.cc5
-rw-r--r--components/signin/core/browser/profile_oauth2_token_service.cc19
-rw-r--r--components/signin/core/browser/profile_oauth2_token_service.h21
-rw-r--r--components/signin/core/browser/signin_error_controller.h5
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios.h9
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios.mm20
-rw-r--r--components/signin/ios/browser/profile_oauth2_token_service_ios_unittest.mm3
30 files changed, 192 insertions, 128 deletions
diff --git a/chrome/browser/profiles/profiles_state.cc b/chrome/browser/profiles/profiles_state.cc
index 6fc706f..a673b01 100644
--- a/chrome/browser/profiles/profiles_state.cc
+++ b/chrome/browser/profiles/profiles_state.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
@@ -167,9 +168,7 @@ void UpdateGaiaProfileInfoIfNeeded(Profile* profile) {
}
SigninErrorController* GetSigninErrorController(Profile* profile) {
- ProfileOAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- return token_service ? token_service->signin_error_controller() : NULL;
+ return SigninErrorControllerFactory::GetForProfile(profile);
}
Profile* SetActiveProfileToGuestIfLocked() {
diff --git a/chrome/browser/signin/android_profile_oauth2_token_service.cc b/chrome/browser/signin/android_profile_oauth2_token_service.cc
index 7ea5a68..135857b 100644
--- a/chrome/browser/signin/android_profile_oauth2_token_service.cc
+++ b/chrome/browser/signin/android_profile_oauth2_token_service.cc
@@ -159,9 +159,11 @@ static jobject GetForProfile(JNIEnv* env,
env, clazz, j_profile_android);
}
-void AndroidProfileOAuth2TokenService::Initialize(SigninClient* client) {
+void AndroidProfileOAuth2TokenService::Initialize(
+ SigninClient* client,
+ SigninErrorController* signin_error_controller) {
DVLOG(1) << "AndroidProfileOAuth2TokenService::Initialize";
- ProfileOAuth2TokenService::Initialize(client);
+ ProfileOAuth2TokenService::Initialize(client, signin_error_controller);
if (!is_testing_profile_) {
Java_OAuth2TokenService_validateAccounts(
diff --git a/chrome/browser/signin/android_profile_oauth2_token_service.h b/chrome/browser/signin/android_profile_oauth2_token_service.h
index a878536..cae22f7 100644
--- a/chrome/browser/signin/android_profile_oauth2_token_service.h
+++ b/chrome/browser/signin/android_profile_oauth2_token_service.h
@@ -44,7 +44,9 @@ class AndroidProfileOAuth2TokenService : public ProfileOAuth2TokenService {
}
// ProfileOAuth2TokenService overrides:
- virtual void Initialize(SigninClient* client) override;
+ virtual void Initialize(
+ SigninClient* client,
+ SigninErrorController* signin_error_controller) override;
virtual bool RefreshTokenIsAvailable(
const std::string& account_id) const override;
virtual void UpdateAuthError(
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
index 8d54b31..90e9fe3 100644
--- a/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service_builder.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
// TODO(blundell): Should these be namespaced?
KeyedService* BuildFakeProfileOAuth2TokenService(
@@ -13,7 +14,8 @@ KeyedService* BuildFakeProfileOAuth2TokenService(
Profile* profile = Profile::FromBrowserContext(context);
FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService();
service->Initialize(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile));
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ SigninErrorControllerFactory::GetInstance()->GetForProfile(profile));
return service;
}
@@ -23,6 +25,7 @@ KeyedService* BuildAutoIssuingFakeProfileOAuth2TokenService(
FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService();
service->set_auto_post_fetch_response_on_message_loop(true);
service->Initialize(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile));
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ SigninErrorControllerFactory::GetInstance()->GetForProfile(profile));
return service;
}
diff --git a/chrome/browser/signin/profile_oauth2_token_service_factory.cc b/chrome/browser/signin/profile_oauth2_token_service_factory.cc
index 14c76ac..60d4e83 100644
--- a/chrome/browser/signin/profile_oauth2_token_service_factory.cc
+++ b/chrome/browser/signin/profile_oauth2_token_service_factory.cc
@@ -6,6 +6,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -24,6 +25,7 @@ ProfileOAuth2TokenServiceFactory::ProfileOAuth2TokenServiceFactory()
DependsOn(GlobalErrorServiceFactory::GetInstance());
DependsOn(WebDataServiceFactory::GetInstance());
DependsOn(ChromeSigninClientFactory::GetInstance());
+ DependsOn(SigninErrorControllerFactory::GetInstance());
}
ProfileOAuth2TokenServiceFactory::~ProfileOAuth2TokenServiceFactory() {
@@ -55,6 +57,7 @@ KeyedService* ProfileOAuth2TokenServiceFactory::BuildServiceInstanceFor(
PlatformSpecificOAuth2TokenService* service =
new PlatformSpecificOAuth2TokenService();
service->Initialize(
- ChromeSigninClientFactory::GetInstance()->GetForProfile(profile));
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ SigninErrorControllerFactory::GetInstance()->GetForProfile(profile));
return service;
}
diff --git a/chrome/browser/signin/signin_error_controller_factory.cc b/chrome/browser/signin/signin_error_controller_factory.cc
new file mode 100644
index 0000000..796836d
--- /dev/null
+++ b/chrome/browser/signin/signin_error_controller_factory.cc
@@ -0,0 +1,32 @@
+// Copyright 2015 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/signin/signin_error_controller_factory.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+SigninErrorControllerFactory::SigninErrorControllerFactory()
+ : BrowserContextKeyedServiceFactory(
+ "SigninErrorController",
+ BrowserContextDependencyManager::GetInstance()) {}
+
+SigninErrorControllerFactory::~SigninErrorControllerFactory() {}
+
+// static
+SigninErrorController* SigninErrorControllerFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<SigninErrorController*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+SigninErrorControllerFactory* SigninErrorControllerFactory::GetInstance() {
+ return Singleton<SigninErrorControllerFactory>::get();
+}
+
+KeyedService* SigninErrorControllerFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ return new SigninErrorController();
+}
diff --git a/chrome/browser/signin/signin_error_controller_factory.h b/chrome/browser/signin/signin_error_controller_factory.h
new file mode 100644
index 0000000..990243e
--- /dev/null
+++ b/chrome/browser/signin/signin_error_controller_factory.h
@@ -0,0 +1,37 @@
+// Copyright 2015 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_SIGNIN_SIGNIN_ERROR_CONTROLLER_FACTORY_H_
+#define CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_CONTROLLER_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+#include "components/signin/core/browser/signin_error_controller.h"
+
+class Profile;
+
+// Singleton that owns all SigninErrorControllers and associates them with
+// Profiles.
+class SigninErrorControllerFactory : public BrowserContextKeyedServiceFactory {
+ public:
+ // Returns the instance of SigninErrorController associated with this profile
+ // (creating one if none exists). Returns NULL if this profile cannot have an
+ // SigninClient (for example, if |profile| is incognito).
+ static SigninErrorController* GetForProfile(Profile* profile);
+
+ // Returns an instance of the factory singleton.
+ static SigninErrorControllerFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<SigninErrorControllerFactory>;
+
+ SigninErrorControllerFactory();
+ ~SigninErrorControllerFactory() override;
+
+ // BrowserContextKeyedServiceFactory:
+ KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* profile) const override;
+};
+
+#endif // CHROME_BROWSER_SIGNIN_SIGNIN_ERROR_CONTROLLER_FACTORY_H_
diff --git a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
index e49b489..ab1ebf3 100644
--- a/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
+++ b/chrome/browser/signin/signin_error_notifier_ash_unittest.cc
@@ -10,14 +10,13 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/signin/fake_signin_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_error_notifier_factory_ash.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -84,9 +83,8 @@ class SigninErrorNotifierTest : public AshTestBase {
gfx::Screen::SetScreenTypeDelegate(new ScreenTypeDelegateDesktop);
#endif
- error_controller_ =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())->
- signin_error_controller();
+ error_controller_ = SigninErrorControllerFactory::GetForProfile(
+ profile_.get());
SigninErrorNotifierFactory::GetForProfile(profile_.get());
notification_ui_manager_ = g_browser_process->notification_ui_manager();
}
diff --git a/chrome/browser/signin/signin_error_notifier_factory_ash.cc b/chrome/browser/signin/signin_error_notifier_factory_ash.cc
index 100df63..75c975f 100644
--- a/chrome/browser/signin/signin_error_notifier_factory_ash.cc
+++ b/chrome/browser/signin/signin_error_notifier_factory_ash.cc
@@ -7,7 +7,7 @@
#include "ash/shell.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_error_notifier_ash.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
@@ -16,7 +16,7 @@ SigninErrorNotifierFactory::SigninErrorNotifierFactory()
: BrowserContextKeyedServiceFactory(
"SigninErrorNotifier",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
+ DependsOn(SigninErrorControllerFactory::GetInstance());
}
SigninErrorNotifierFactory::~SigninErrorNotifierFactory() {}
@@ -40,9 +40,6 @@ KeyedService* SigninErrorNotifierFactory::BuildServiceInstanceFor(
Profile* profile = static_cast<Profile*>(context);
- SigninErrorController* controller =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
- signin_error_controller();
-
- return new SigninErrorNotifier(controller, profile);
+ return new SigninErrorNotifier(
+ SigninErrorControllerFactory::GetForProfile(profile), profile);
}
diff --git a/chrome/browser/signin/signin_global_error_factory.cc b/chrome/browser/signin/signin_global_error_factory.cc
index 47ecb90..a1900a7 100644
--- a/chrome/browser/signin/signin_global_error_factory.cc
+++ b/chrome/browser/signin/signin_global_error_factory.cc
@@ -6,7 +6,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_global_error.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
@@ -20,7 +20,7 @@ SigninGlobalErrorFactory::SigninGlobalErrorFactory()
: BrowserContextKeyedServiceFactory(
"SigninGlobalError",
BrowserContextDependencyManager::GetInstance()) {
- DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance());
+ DependsOn(SigninErrorControllerFactory::GetInstance());
DependsOn(GlobalErrorServiceFactory::GetInstance());
}
@@ -47,9 +47,6 @@ KeyedService* SigninGlobalErrorFactory::BuildServiceInstanceFor(
Profile* profile = static_cast<Profile*>(context);
- SigninErrorController* controller =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
- signin_error_controller();
-
- return new SigninGlobalError(controller, profile);
+ return new SigninGlobalError(
+ SigninErrorControllerFactory::GetForProfile(profile), profile);
}
diff --git a/chrome/browser/signin/signin_global_error_unittest.cc b/chrome/browser/signin/signin_global_error_unittest.cc
index e34adb9..0acd9c0 100644
--- a/chrome/browser/signin/signin_global_error_unittest.cc
+++ b/chrome/browser/signin/signin_global_error_unittest.cc
@@ -6,10 +6,10 @@
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_service.h"
-#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h"
#include "chrome/browser/signin/fake_signin_manager.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_global_error_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
@@ -40,8 +40,8 @@ class SigninGlobalErrorTest : public testing::Test {
->SetAuthenticatedUsername(kTestAccountId);
global_error_ = SigninGlobalErrorFactory::GetForProfile(profile_.get());
- error_controller_ = ProfileOAuth2TokenServiceFactory::GetForProfile(
- profile_.get())->signin_error_controller();
+ error_controller_ = SigninErrorControllerFactory::GetForProfile(
+ profile_.get());
}
content::TestBrowserThreadBundle thread_bundle_;
diff --git a/chrome/browser/signin/signin_ui_util.cc b/chrome/browser/signin/signin_ui_util.cc
index 8316747..cc6f009 100644
--- a/chrome/browser/signin/signin_ui_util.cc
+++ b/chrome/browser/signin/signin_ui_util.cc
@@ -9,7 +9,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_global_error.h"
#include "chrome/browser/signin/signin_global_error_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
@@ -22,7 +22,6 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/browser/account_tracker_service.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "ui/base/l10n/l10n_util.h"
@@ -107,8 +106,8 @@ void GetStatusLabelsForAuthError(Profile* profile,
link_label->assign(l10n_util::GetStringUTF16(IDS_SYNC_RELOGIN_LINK_LABEL));
const GoogleServiceAuthError::State state =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
- signin_error_controller()->auth_error().state();
+ SigninErrorControllerFactory::GetForProfile(profile)->
+ auth_error().state();
switch (state) {
case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS:
case GoogleServiceAuthError::SERVICE_ERROR:
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index 4d84a0e..8b1a59f 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -11,7 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -24,7 +24,6 @@
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -168,8 +167,8 @@ MessageType GetStatusInfo(ProfileSyncService* service,
if (service) {
// Since there is no auth in progress, check for an auth error first.
AuthError auth_error =
- ProfileOAuth2TokenServiceFactory::GetForProfile(service->profile())->
- signin_error_controller()->auth_error();
+ SigninErrorControllerFactory::GetForProfile(service->profile())->
+ auth_error();
if (auth_error.state() != AuthError::NONE) {
if (status_label && link_label)
signin_ui_util::GetStatusLabelsForAuthError(
@@ -231,8 +230,8 @@ MessageType GetStatusInfo(ProfileSyncService* service,
ProfileSyncService::Status status;
service->QueryDetailedSyncStatus(&status);
AuthError auth_error =
- ProfileOAuth2TokenServiceFactory::GetForProfile(service->profile())->
- signin_error_controller()->auth_error();
+ SigninErrorControllerFactory::GetForProfile(service->profile())->
+ auth_error();
if (status_label) {
status_label->assign(
l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS));
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
index 212e7be..f84856a 100644
--- a/chrome/browser/sync/sync_ui_util_unittest.cc
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -7,12 +7,11 @@
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/fake_signin_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
@@ -342,8 +341,7 @@ TEST_F(SyncUIUtilTest, DistinctCasesReportUniqueMessageSets) {
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
signin.SetAuthenticatedUsername(kTestUser);
scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider(
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile.get())->
- signin_error_controller()));
+ SigninErrorControllerFactory::GetForProfile(profile.get())));
GetDistinctCase(service, &signin, provider.get(), idx);
base::string16 status_label;
base::string16 link_label;
@@ -382,8 +380,7 @@ TEST_F(SyncUIUtilTest, HtmlNotIncludedInStatusIfNotRequested) {
FakeSigninManagerForSyncUIUtilTest signin(profile.get());
signin.SetAuthenticatedUsername(kTestUser);
scoped_ptr<FakeAuthStatusProvider> provider(new FakeAuthStatusProvider(
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile.get())->
- signin_error_controller()));
+ SigninErrorControllerFactory::GetForProfile(profile.get())));
GetDistinctCase(service, &signin, provider.get(), idx);
base::string16 status_label;
base::string16 link_label;
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 1022ad4..2f081ba 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -12,7 +12,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/signin/fake_signin_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -30,7 +30,6 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/testing_profile.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/notification_service.h"
@@ -738,8 +737,7 @@ TEST_F(BrowserWindowControllerTest, TestSigninMenuItemAuthError) {
sync->SetSyncSetupCompleted();
// Force an auth error.
FakeAuthStatusProvider provider(
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
- signin_error_controller());
+ SigninErrorControllerFactory::GetForProfile(profile()));;
GoogleServiceAuthError error(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
provider.SetAuthError("user@gmail.com", "user@gmail.com", error);
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index 6c2c046..6a04286 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -37,7 +37,7 @@
#include "chrome/browser/search/search.h"
#include "chrome/browser/signin/chrome_signin_client.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_names_io_thread.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -63,7 +63,6 @@
#include "components/autofill/core/common/password_form.h"
#include "components/google/core/browser/google_util.h"
#include "components/password_manager/core/browser/password_manager.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
@@ -1433,8 +1432,7 @@ void OneClickSigninHelper::DidStopLoading(
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile);
SigninErrorController* error_controller =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
- signin_error_controller();
+ SigninErrorControllerFactory::GetForProfile(profile);
OneClickSigninSyncStarter::StartSyncMode start_mode =
source_ == signin_metrics::SOURCE_SETTINGS ?
diff --git a/chrome/browser/ui/webui/options/supervised_user_import_handler.cc b/chrome/browser/ui/webui/options/supervised_user_import_handler.cc
index c6e397e..341fd8e 100644
--- a/chrome/browser/ui/webui/options/supervised_user_import_handler.cc
+++ b/chrome/browser/ui/webui/options/supervised_user_import_handler.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service.h"
#include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_service_factory.h"
@@ -23,7 +23,6 @@
#include "chrome/browser/supervised_user/supervised_user_constants.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_manager.h"
#include "content/public/browser/web_ui.h"
@@ -93,8 +92,7 @@ void SupervisedUserImportHandler::InitializeHandler() {
SupervisedUserSyncServiceFactory::GetForProfile(profile);
if (sync_service) {
sync_service->AddObserver(this);
- observer_.Add(ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
- signin_error_controller());
+ observer_.Add(SigninErrorControllerFactory::GetForProfile(profile));
SupervisedUserSharedSettingsService* settings_service =
SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile);
@@ -104,7 +102,7 @@ void SupervisedUserImportHandler::InitializeHandler() {
} else {
DCHECK(!SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext(
profile));
- DCHECK(!ProfileOAuth2TokenServiceFactory::GetForProfile(profile));
+ DCHECK(!SigninErrorControllerFactory::GetForProfile(profile));
}
}
}
@@ -224,13 +222,10 @@ bool SupervisedUserImportHandler::IsAccountConnected() const {
bool SupervisedUserImportHandler::HasAuthError() const {
Profile* profile = Profile::FromWebUI(web_ui());
- ProfileOAuth2TokenService* token_service =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
- if (!token_service)
- return true;
-
SigninErrorController* error_controller =
- token_service->signin_error_controller();
+ SigninErrorControllerFactory::GetForProfile(profile);
+ if (!error_controller)
+ return true;
GoogleServiceAuthError::State state = error_controller->auth_error().state();
diff --git a/chrome/browser/ui/webui/options/sync_setup_handler.cc b/chrome/browser/ui/webui/options/sync_setup_handler.cc
index b9a1e33..9d2abb4 100644
--- a/chrome/browser/ui/webui/options/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/options/sync_setup_handler.cc
@@ -23,7 +23,7 @@
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_header_helper.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
@@ -42,7 +42,6 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/locale_settings.h"
#include "components/google/core/browser/google_util.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/core/browser/signin_metrics.h"
#include "components/signin/core/common/profile_management_switches.h"
@@ -369,8 +368,7 @@ void SyncSetupHandler::DisplayGaiaLoginInNewTabOrWindow() {
signin_metrics::HISTOGRAM_REAUTH_MAX);
SigninErrorController* error_controller =
- ProfileOAuth2TokenServiceFactory::GetForProfile(browser->profile())->
- signin_error_controller();
+ SigninErrorControllerFactory::GetForProfile(browser->profile());
DCHECK(error_controller->HasError());
if (switches::IsNewAvatarMenu() && !force_new_tab) {
browser->window()->ShowAvatarBubbleFromAvatarButton(
@@ -741,8 +739,7 @@ void SyncSetupHandler::OpenSyncSetup() {
SigninManagerFactory::GetForProfile(GetProfile());
if (!signin->IsAuthenticated() ||
- ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile())->
- signin_error_controller()->HasError()) {
+ SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) {
// User is not logged in (cases 1-2), or login has been specially requested
// because previously working credentials have expired (case 3). Close sync
// setup including any visible overlays, and display the gaia auth page.
diff --git a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
index 32c6f10e..045c1ad 100644
--- a/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
+++ b/chrome/browser/ui/webui/options/sync_setup_handler_unittest.cc
@@ -13,7 +13,7 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/signin/fake_signin_manager.h"
-#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
@@ -25,7 +25,6 @@
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/signin/core/browser/fake_auth_status_provider.h"
-#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/sync_prefs.h"
#include "content/public/browser/web_ui.h"
@@ -868,8 +867,7 @@ TEST_F(SyncSetupHandlerTest, ShowSigninOnAuthError) {
SetupInitializedProfileSyncService();
mock_signin_->SetAuthenticatedUsername(kTestUser);
FakeAuthStatusProvider provider(
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile_.get())->
- signin_error_controller());
+ SigninErrorControllerFactory::GetForProfile(profile_.get()));
provider.SetAuthError(kTestUser, kTestUser, error_);
EXPECT_CALL(*mock_pss_, IsSyncEnabledAndLoggedIn())
.WillRepeatedly(Return(true));
diff --git a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
index 89f80a9..308460c 100644
--- a/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
+++ b/chrome/browser/ui/webui/signin/inline_login_handler_impl.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/local_auth.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/sync/profile_sync_service.h"
@@ -160,8 +161,7 @@ void InlineSigninHelper::OnClientOAuthSuccess(const ClientOAuthResult& result) {
ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile_);
SigninErrorController* error_controller =
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)->
- signin_error_controller();
+ SigninErrorControllerFactory::GetForProfile(profile_);
bool is_new_avatar_menu = switches::IsNewAvatarMenu();
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 6470d75..b186c1f 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2507,6 +2507,8 @@
'browser/signin/screenlock_bridge.h',
'browser/signin/signin_cookie_changed_subscription.cc',
'browser/signin/signin_cookie_changed_subscription.h',
+ 'browser/signin/signin_error_controller_factory.cc',
+ 'browser/signin/signin_error_controller_factory.h',
'browser/signin/signin_header_helper.cc',
'browser/signin/signin_header_helper.h',
'browser/signin/signin_manager_factory.cc',
diff --git a/components/signin/core/browser/mutable_profile_oauth2_token_service.cc b/components/signin/core/browser/mutable_profile_oauth2_token_service.cc
index 991fa23..512a18a 100644
--- a/components/signin/core/browser/mutable_profile_oauth2_token_service.cc
+++ b/components/signin/core/browser/mutable_profile_oauth2_token_service.cc
@@ -82,27 +82,27 @@ void MutableProfileOAuth2TokenService::
}
MutableProfileOAuth2TokenService::AccountInfo::AccountInfo(
- ProfileOAuth2TokenService* token_service,
+ SigninErrorController* signin_error_controller,
const std::string& account_id,
const std::string& refresh_token)
- : token_service_(token_service),
+ : signin_error_controller_(signin_error_controller),
account_id_(account_id),
refresh_token_(refresh_token),
last_auth_error_(GoogleServiceAuthError::NONE) {
- DCHECK(token_service_);
+ DCHECK(signin_error_controller_);
DCHECK(!account_id_.empty());
- token_service_->signin_error_controller()->AddProvider(this);
+ signin_error_controller_->AddProvider(this);
}
MutableProfileOAuth2TokenService::AccountInfo::~AccountInfo() {
- token_service_->signin_error_controller()->RemoveProvider(this);
+ signin_error_controller_->RemoveProvider(this);
}
void MutableProfileOAuth2TokenService::AccountInfo::SetLastAuthError(
const GoogleServiceAuthError& error) {
if (error.state() != last_auth_error_.state()) {
last_auth_error_ = error;
- token_service_->signin_error_controller()->AuthStatusChanged();
+ signin_error_controller_->AuthStatusChanged();
}
}
@@ -204,7 +204,9 @@ void MutableProfileOAuth2TokenService::OnWebDataServiceRequestDone(
DCHECK(!loading_primary_account_id_.empty());
if (refresh_tokens().count(loading_primary_account_id_) == 0) {
refresh_tokens()[loading_primary_account_id_].reset(
- new AccountInfo(this, loading_primary_account_id_, std::string()));
+ new AccountInfo(signin_error_controller(),
+ loading_primary_account_id_,
+ std::string()));
}
// If we don't have a refresh token for a known account, signal an error.
@@ -254,7 +256,9 @@ void MutableProfileOAuth2TokenService::LoadAllCredentialsIntoMemory(
account_id = gaia::CanonicalizeEmail(account_id);
refresh_tokens()[account_id].reset(
- new AccountInfo(this, account_id, refresh_token));
+ new AccountInfo(signin_error_controller(),
+ account_id,
+ refresh_token));
FireRefreshTokenAvailable(account_id);
}
}
@@ -328,7 +332,9 @@ void MutableProfileOAuth2TokenService::UpdateCredentials(
refresh_tokens_[account_id]->set_refresh_token(refresh_token);
} else {
refresh_tokens_[account_id].reset(
- new AccountInfo(this, account_id, refresh_token));
+ new AccountInfo(signin_error_controller(),
+ account_id,
+ refresh_token));
}
// Save the token in memory and in persistent store.
diff --git a/components/signin/core/browser/mutable_profile_oauth2_token_service.h b/components/signin/core/browser/mutable_profile_oauth2_token_service.h
index a06efba..57eadb7 100644
--- a/components/signin/core/browser/mutable_profile_oauth2_token_service.h
+++ b/components/signin/core/browser/mutable_profile_oauth2_token_service.h
@@ -8,6 +8,7 @@
#include "base/memory/scoped_vector.h"
#include "base/threading/thread_checker.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "components/signin/core/browser/signin_error_controller.h"
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
@@ -37,7 +38,7 @@ class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService,
protected:
class AccountInfo : public SigninErrorController::AuthStatusProvider {
public:
- AccountInfo(ProfileOAuth2TokenService* token_service,
+ AccountInfo(SigninErrorController* signin_error_controller,
const std::string& account_id,
const std::string& refresh_token);
~AccountInfo() override;
@@ -55,7 +56,7 @@ class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService,
GoogleServiceAuthError GetAuthStatus() const override;
private:
- ProfileOAuth2TokenService* token_service_;
+ SigninErrorController* signin_error_controller_;
std::string account_id_;
std::string refresh_token_;
GoogleServiceAuthError last_auth_error_;
diff --git a/components/signin/core/browser/mutable_profile_oauth2_token_service_unittest.cc b/components/signin/core/browser/mutable_profile_oauth2_token_service_unittest.cc
index a7d75ed..5bbe5d0 100644
--- a/components/signin/core/browser/mutable_profile_oauth2_token_service_unittest.cc
+++ b/components/signin/core/browser/mutable_profile_oauth2_token_service_unittest.cc
@@ -46,7 +46,7 @@ class MutableProfileOAuth2TokenServiceTest
"",
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
- oauth2_service_.Initialize(&client_);
+ oauth2_service_.Initialize(&client_, &signin_error_controller_);
// Make sure PO2TS has a chance to load itself before continuing.
base::RunLoop().RunUntilIdle();
oauth2_service_.AddObserver(this);
@@ -119,6 +119,7 @@ class MutableProfileOAuth2TokenServiceTest
TestSigninClient client_;
MutableProfileOAuth2TokenService oauth2_service_;
TestingOAuth2TokenServiceConsumer consumer_;
+ SigninErrorController signin_error_controller_;
int token_available_count_;
int token_revoked_count_;
int tokens_loaded_count_;
@@ -362,7 +363,7 @@ TEST_F(MutableProfileOAuth2TokenServiceTest, FetchTransientError) {
oauth2_service_.StartRequest(kEmail, scope_list, &consumer_));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(GoogleServiceAuthError::AuthErrorNone(),
- oauth2_service_.signin_error_controller()->auth_error());
+ signin_error_controller_.auth_error());
}
TEST_F(MutableProfileOAuth2TokenServiceTest, CanonicalizeAccountId) {
diff --git a/components/signin/core/browser/profile_oauth2_token_service.cc b/components/signin/core/browser/profile_oauth2_token_service.cc
index 73c513e..0de1e2b 100644
--- a/components/signin/core/browser/profile_oauth2_token_service.cc
+++ b/components/signin/core/browser/profile_oauth2_token_service.cc
@@ -14,25 +14,24 @@
#include "net/url_request/url_request_context_getter.h"
ProfileOAuth2TokenService::ProfileOAuth2TokenService()
- : client_(NULL) {}
+ : client_(NULL),
+ signin_error_controller_(NULL) {}
-ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {
- DCHECK(!signin_error_controller_.get()) <<
- "ProfileOAuth2TokenService::Initialize called but not "
- "ProfileOAuth2TokenService::Shutdown";
-}
+ProfileOAuth2TokenService::~ProfileOAuth2TokenService() {}
-void ProfileOAuth2TokenService::Initialize(SigninClient* client) {
+void ProfileOAuth2TokenService::Initialize(
+ SigninClient* client,
+ SigninErrorController* signin_error_controller) {
DCHECK(client);
DCHECK(!client_);
+ DCHECK(signin_error_controller);
+ DCHECK(!signin_error_controller_);
client_ = client;
-
- signin_error_controller_.reset(new SigninErrorController());
+ signin_error_controller_ = signin_error_controller;
}
void ProfileOAuth2TokenService::Shutdown() {
DCHECK(client_) << "Shutdown() called without matching call to Initialize()";
- signin_error_controller_.reset();
}
net::URLRequestContextGetter* ProfileOAuth2TokenService::GetRequestContext() {
diff --git a/components/signin/core/browser/profile_oauth2_token_service.h b/components/signin/core/browser/profile_oauth2_token_service.h
index 13210c1..c5a3c20 100644
--- a/components/signin/core/browser/profile_oauth2_token_service.h
+++ b/components/signin/core/browser/profile_oauth2_token_service.h
@@ -10,7 +10,6 @@
#include "base/gtest_prod_util.h"
#include "base/memory/linked_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
-#include "components/signin/core/browser/signin_error_controller.h"
#include "google_apis/gaia/oauth2_token_service.h"
namespace net {
@@ -19,6 +18,7 @@ class URLRequestContextGetter;
class GoogleServiceAuthError;
class SigninClient;
+class SigninErrorController;
// ProfileOAuth2TokenService is a KeyedService that retrieves
// OAuth2 access tokens for a given set of scopes using the OAuth2 login
@@ -40,7 +40,8 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
~ProfileOAuth2TokenService() override;
// Initializes this token service with the SigninClient.
- virtual void Initialize(SigninClient* client);
+ virtual void Initialize(SigninClient* client,
+ SigninErrorController* signin_error_controller);
// KeyedService implementation.
void Shutdown() override;
@@ -67,14 +68,6 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
// Revokes all credentials handled by the object.
virtual void RevokeAllCredentials();
- SigninErrorController* signin_error_controller() {
- return signin_error_controller_.get();
- }
-
- const SigninErrorController* signin_error_controller() const {
- return signin_error_controller_.get();
- }
-
SigninClient* client() const { return client_; }
protected:
@@ -96,12 +89,16 @@ class ProfileOAuth2TokenService : public OAuth2TokenService,
// when invalid.
void ValidateAccountId(const std::string& account_id) const;
+ SigninErrorController* signin_error_controller() {
+ return signin_error_controller_;
+ }
+
private:
// The client with which this instance was initialized, or NULL.
SigninClient* client_;
- // Used to expose auth errors to the UI.
- scoped_ptr<SigninErrorController> signin_error_controller_;
+ // The error controller with which this instance was initialized, or NULL.
+ SigninErrorController* signin_error_controller_;
DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenService);
};
diff --git a/components/signin/core/browser/signin_error_controller.h b/components/signin/core/browser/signin_error_controller.h
index 77bd78d..368b916 100644
--- a/components/signin/core/browser/signin_error_controller.h
+++ b/components/signin/core/browser/signin_error_controller.h
@@ -9,13 +9,14 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/observer_list.h"
+#include "components/keyed_service/core/keyed_service.h"
#include "google_apis/gaia/google_service_auth_error.h"
// Keep track of auth errors and expose them to observers in the UI. Services
// that wish to expose auth errors to the user should register an
// AuthStatusProvider to report their current authentication state, and should
// invoke AuthStatusChanged() when their authentication state may have changed.
-class SigninErrorController {
+class SigninErrorController : public KeyedService {
public:
class AuthStatusProvider {
public:
@@ -42,7 +43,7 @@ class SigninErrorController {
};
SigninErrorController();
- ~SigninErrorController();
+ ~SigninErrorController() override;
// Adds a provider which the SigninErrorController object will start querying
// for auth status.
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios.h b/components/signin/ios/browser/profile_oauth2_token_service_ios.h
index 65381ce..28dbc79 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios.h
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios.h
@@ -9,6 +9,7 @@
#include "base/threading/thread_checker.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
+#include "components/signin/core/browser/signin_error_controller.h"
class OAuth2AccessTokenFetcher;
@@ -39,7 +40,9 @@ class ProfileOAuth2TokenServiceIOS : public ProfileOAuth2TokenService {
const std::string& access_token) override;
// ProfileOAuth2TokenService
- virtual void Initialize(SigninClient* client) override;
+ virtual void Initialize(
+ SigninClient* client,
+ SigninErrorController* signin_error_controller) override;
virtual void LoadCredentials(const std::string& primary_account_id) override;
virtual std::vector<std::string> GetAccounts() override;
virtual void UpdateAuthError(const std::string& account_id,
@@ -85,7 +88,7 @@ class ProfileOAuth2TokenServiceIOS : public ProfileOAuth2TokenService {
private:
class AccountInfo : public SigninErrorController::AuthStatusProvider {
public:
- AccountInfo(ProfileOAuth2TokenService* token_service,
+ AccountInfo(SigninErrorController* signin_error_controller,
const std::string& account_id);
virtual ~AccountInfo();
@@ -97,7 +100,7 @@ class ProfileOAuth2TokenServiceIOS : public ProfileOAuth2TokenService {
virtual GoogleServiceAuthError GetAuthStatus() const override;
private:
- ProfileOAuth2TokenService* token_service_;
+ SigninErrorController* signin_error_controller_;
std::string account_id_;
GoogleServiceAuthError last_auth_error_;
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios.mm
index d56678d..cfa017d 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios.mm
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios.mm
@@ -130,25 +130,25 @@ void SSOAccessTokenFetcher::OnAccessTokenResponse(NSString* token,
} // namespace
ProfileOAuth2TokenServiceIOS::AccountInfo::AccountInfo(
- ProfileOAuth2TokenService* token_service,
+ SigninErrorController* signin_error_controller,
const std::string& account_id)
- : token_service_(token_service),
+ : signin_error_controller_(signin_error_controller),
account_id_(account_id),
last_auth_error_(GoogleServiceAuthError::NONE) {
- DCHECK(token_service_);
+ DCHECK(signin_error_controller_);
DCHECK(!account_id_.empty());
- token_service_->signin_error_controller()->AddProvider(this);
+ signin_error_controller_->AddProvider(this);
}
ProfileOAuth2TokenServiceIOS::AccountInfo::~AccountInfo() {
- token_service_->signin_error_controller()->RemoveProvider(this);
+ signin_error_controller_->RemoveProvider(this);
}
void ProfileOAuth2TokenServiceIOS::AccountInfo::SetLastAuthError(
const GoogleServiceAuthError& error) {
if (error.state() != last_auth_error_.state()) {
last_auth_error_ = error;
- token_service_->signin_error_controller()->AuthStatusChanged();
+ signin_error_controller_->AuthStatusChanged();
}
}
@@ -176,9 +176,10 @@ ProfileOAuth2TokenServiceIOS::~ProfileOAuth2TokenServiceIOS() {
DCHECK(thread_checker_.CalledOnValidThread());
}
-void ProfileOAuth2TokenServiceIOS::Initialize(SigninClient* client) {
+void ProfileOAuth2TokenServiceIOS::Initialize(
+ SigninClient* client, SigninErrorController* signin_error_controller) {
DCHECK(thread_checker_.CalledOnValidThread());
- ProfileOAuth2TokenService::Initialize(client);
+ ProfileOAuth2TokenService::Initialize(client, signin_error_controller);
}
void ProfileOAuth2TokenServiceIOS::Shutdown() {
@@ -332,7 +333,8 @@ void ProfileOAuth2TokenServiceIOS::AddOrUpdateAccount(
CancelRequestsForAccount(account_id);
ClearCacheForAccount(account_id);
} else {
- accounts_[account_id].reset(new AccountInfo(this, account_id));
+ accounts_[account_id].reset(
+ new AccountInfo(signin_error_controller(), account_id));
}
UpdateAuthError(account_id, GoogleServiceAuthError::AuthErrorNone());
FireRefreshTokenAvailable(account_id);
diff --git a/components/signin/ios/browser/profile_oauth2_token_service_ios_unittest.mm b/components/signin/ios/browser/profile_oauth2_token_service_ios_unittest.mm
index 11e9840..03e8c88 100644
--- a/components/signin/ios/browser/profile_oauth2_token_service_ios_unittest.mm
+++ b/components/signin/ios/browser/profile_oauth2_token_service_ios_unittest.mm
@@ -32,7 +32,7 @@ class ProfileOAuth2TokenServiceIOSTest : public testing::Test,
net::HTTP_OK,
net::URLRequestStatus::SUCCESS);
fake_provider_ = client_.GetIOSProviderAsFake();
- oauth2_service_.Initialize(&client_);
+ oauth2_service_.Initialize(&client_, &signin_error_controller_);
oauth2_service_.AddObserver(this);
}
@@ -75,6 +75,7 @@ class ProfileOAuth2TokenServiceIOSTest : public testing::Test,
base::MessageLoop message_loop_;
net::FakeURLFetcherFactory factory_;
TestSigninClient client_;
+ SigninErrorController signin_error_controller_;
ios::FakeProfileOAuth2TokenServiceIOSProvider* fake_provider_;
ProfileOAuth2TokenServiceIOS oauth2_service_;
TestingOAuth2TokenServiceConsumer consumer_;