OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/signin/signin_manager_fake.h" | 5 #include "chrome/browser/signin/signin_manager_fake.h" |
6 | 6 |
7 #include "chrome/browser/signin/signin_global_error.h" | |
8 #include "chrome/browser/ui/global_error/global_error_service.h" | |
9 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | |
10 #include "chrome/common/chrome_notification_types.h" | 7 #include "chrome/common/chrome_notification_types.h" |
11 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
12 | 9 |
13 FakeSigninManager::FakeSigninManager(Profile* profile) { | 10 FakeSigninManager::FakeSigninManager(Profile* profile) { |
14 profile_ = profile; | 11 profile_ = profile; |
15 signin_global_error_.reset(new SigninGlobalError(profile)); | |
16 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | |
17 signin_global_error_.get()); | |
18 } | 12 } |
19 | 13 |
20 FakeSigninManager::~FakeSigninManager() { | 14 FakeSigninManager::~FakeSigninManager() {} |
21 if (signin_global_error_.get()) { | |
22 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | |
23 signin_global_error_.get()); | |
24 signin_global_error_.reset(); | |
25 } | |
26 } | |
27 | 15 |
28 void FakeSigninManager::StartSignIn(const std::string& username, | 16 void FakeSigninManager::StartSignIn(const std::string& username, |
29 const std::string& password, | 17 const std::string& password, |
30 const std::string& login_token, | 18 const std::string& login_token, |
31 const std::string& login_captcha) { | 19 const std::string& login_captcha) { |
32 SetAuthenticatedUsername(username); | 20 SetAuthenticatedUsername(username); |
33 } | 21 } |
34 | 22 |
35 void FakeSigninManager::StartSignInWithCredentials( | 23 void FakeSigninManager::StartSignInWithCredentials( |
36 const std::string& session_index, | 24 const std::string& session_index, |
(...skipping 12 matching lines...) Expand all Loading... |
49 content::NotificationService::current()->Notify( | 37 content::NotificationService::current()->Notify( |
50 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 38 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
51 content::Source<Profile>(profile_), | 39 content::Source<Profile>(profile_), |
52 content::NotificationService::NoDetails()); | 40 content::NotificationService::NoDetails()); |
53 } | 41 } |
54 | 42 |
55 // static | 43 // static |
56 ProfileKeyedService* FakeSigninManager::Build(Profile* profile) { | 44 ProfileKeyedService* FakeSigninManager::Build(Profile* profile) { |
57 return new FakeSigninManager(profile); | 45 return new FakeSigninManager(profile); |
58 } | 46 } |
OLD | NEW |