Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / signin / fake_signin_manager.cc
blob51b1541b58f3e9bb3fca9fb309d6d712744be8cd
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/signin/fake_signin_manager.h"
7 #include "base/callback_helpers.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/signin/chrome_signin_manager_delegate.h"
12 #include "chrome/browser/signin/signin_global_error.h"
13 #include "chrome/browser/ui/global_error/global_error_service.h"
14 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/notification_service.h"
18 FakeSigninManagerBase::FakeSigninManagerBase() {
21 FakeSigninManagerBase::~FakeSigninManagerBase() {
24 // static
25 BrowserContextKeyedService* FakeSigninManagerBase::Build(
26 content::BrowserContext* profile) {
27 return new FakeSigninManagerBase();
30 #if !defined (OS_CHROMEOS)
32 FakeSigninManager::FakeSigninManager(Profile* profile)
33 : SigninManager(scoped_ptr<SigninManagerDelegate>(
34 new ChromeSigninManagerDelegate(profile))) {
37 FakeSigninManager::~FakeSigninManager() {
40 void FakeSigninManager::StartSignInWithCredentials(
41 const std::string& session_index,
42 const std::string& username,
43 const std::string& password,
44 const OAuthTokenFetchedCallback& oauth_fetched_callback) {
45 set_auth_in_progress(username);
46 if (!oauth_fetched_callback.is_null())
47 oauth_fetched_callback.Run("fake_oauth_token");
50 void FakeSigninManager::CompletePendingSignin() {
51 SetAuthenticatedUsername(GetUsernameForAuthInProgress());
52 set_auth_in_progress(std::string());
55 void FakeSigninManager::SignOut() {
56 if (IsSignoutProhibited())
57 return;
58 set_auth_in_progress(std::string());
59 authenticated_username_.clear();
60 content::NotificationService::current()->Notify(
61 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
62 content::Source<Profile>(profile_),
63 content::NotificationService::NoDetails());
66 // static
67 BrowserContextKeyedService* FakeSigninManager::Build(
68 content::BrowserContext* profile) {
69 return new FakeSigninManager(static_cast<Profile*>(profile));
72 #endif // !defined (OS_CHROMEOS)