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 |