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

Unified Diff: chrome/browser/services/gcm/fake_signin_manager.cc

Issue 225403021: Extract Profile-independent GCMService from GCMProfileService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore real IO thread in unit tests. Remove sources of flakiness by waiting instead of pumping whe… Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/services/gcm/fake_signin_manager.h ('k') | chrome/browser/services/gcm/gcm_client_mock.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/services/gcm/fake_signin_manager.cc
diff --git a/chrome/browser/services/gcm/fake_signin_manager.cc b/chrome/browser/services/gcm/fake_signin_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..967c0b9d9ee79dee53d63be4b093c299b2479a98
--- /dev/null
+++ b/chrome/browser/services/gcm/fake_signin_manager.cc
@@ -0,0 +1,56 @@
+// 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.
+
+#include "chrome/browser/services/gcm/fake_signin_manager.h"
+
+#include "base/observer_list.h"
+#include "base/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/signin/chrome_signin_client_factory.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "components/signin/core/common/signin_pref_names.h"
+#include "content/public/browser/browser_context.h"
+
+#if !defined(OS_CHROMEOS)
+#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
+#endif
+
+namespace gcm {
+
+FakeSigninManager::FakeSigninManager(Profile* profile)
+#if defined(OS_CHROMEOS)
+ : SigninManagerBase(
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)),
+#else
+ : SigninManager(
+ ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile)),
+#endif
+ profile_(profile) {
+ Initialize(NULL);
+}
+
+FakeSigninManager::~FakeSigninManager() {
+}
+
+void FakeSigninManager::SignIn(const std::string& username) {
+ SetAuthenticatedUsername(username);
+ FOR_EACH_OBSERVER(Observer,
+ observer_list_,
+ GoogleSigninSucceeded(username, std::string()));
+}
+
+void FakeSigninManager::SignOut() {
+ const std::string username = GetAuthenticatedUsername();
+ clear_authenticated_username();
+ profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
+ FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSignedOut(username));
+}
+
+// static
+KeyedService* FakeSigninManager::Build(content::BrowserContext* context) {
+ return new FakeSigninManager(Profile::FromBrowserContext(context));
+}
+
+} // namespace gcm
« no previous file with comments | « chrome/browser/services/gcm/fake_signin_manager.h ('k') | chrome/browser/services/gcm/gcm_client_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698