OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "components/signin/core/browser/test_signin_client.h" | 6 #include "components/signin/core/browser/test_signin_client.h" |
7 #include "components/signin/core/browser/webdata/token_service_table.h" | 7 #include "components/signin/core/browser/webdata/token_service_table.h" |
8 #include "components/webdata/common/web_data_service_base.h" | 8 #include "components/webdata/common/web_data_service_base.h" |
9 #include "components/webdata/common/web_database_service.h" | 9 #include "components/webdata/common/web_database_service.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #if defined(OS_IOS) | 12 #if defined(OS_IOS) |
13 #include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h" | 13 #include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h" |
14 #endif | 14 #endif |
15 | 15 |
| 16 namespace { |
| 17 |
| 18 // Helper for testing. |
| 19 const int kInvalidProcessId = -1; |
| 20 } |
| 21 |
16 TestSigninClient::TestSigninClient() | 22 TestSigninClient::TestSigninClient() |
17 : request_context_(new net::TestURLRequestContextGetter( | 23 : request_context_(new net::TestURLRequestContextGetter( |
18 base::MessageLoopProxy::current())) { | 24 base::MessageLoopProxy::current())) { |
19 LoadDatabase(); | 25 LoadDatabase(); |
20 } | 26 } |
21 | 27 |
22 TestSigninClient::~TestSigninClient() {} | 28 TestSigninClient::~TestSigninClient() {} |
23 | 29 |
24 PrefService* TestSigninClient::GetPrefs() { return NULL; } | 30 PrefService* TestSigninClient::GetPrefs() { return NULL; } |
25 | 31 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 } | 70 } |
65 | 71 |
66 ios::FakeProfileOAuth2TokenServiceIOSProvider* | 72 ios::FakeProfileOAuth2TokenServiceIOSProvider* |
67 TestSigninClient::GetIOSProviderAsFake() { | 73 TestSigninClient::GetIOSProviderAsFake() { |
68 if (!iosProvider_) { | 74 if (!iosProvider_) { |
69 iosProvider_.reset(new ios::FakeProfileOAuth2TokenServiceIOSProvider()); | 75 iosProvider_.reset(new ios::FakeProfileOAuth2TokenServiceIOSProvider()); |
70 } | 76 } |
71 return iosProvider_.get(); | 77 return iosProvider_.get(); |
72 } | 78 } |
73 #endif | 79 #endif |
| 80 |
| 81 void TestSigninClient::SetSigninProcess(int process_id) { |
| 82 if (process_id == signin_host_id_) |
| 83 return; |
| 84 DLOG_IF(WARNING, signin_host_id_ != kInvalidProcessId) |
| 85 << "Replacing in-use signin process."; |
| 86 signin_host_id_ = process_id; |
| 87 } |
| 88 |
| 89 void TestSigninClient::ClearSigninProcess() { |
| 90 signin_host_id_ = kInvalidProcessId; |
| 91 } |
| 92 |
| 93 bool TestSigninClient::IsSigninProcess(int process_id) const { |
| 94 return process_id == signin_host_id_; |
| 95 } |
| 96 |
| 97 bool TestSigninClient::HasSigninProcess() const { |
| 98 return signin_host_id_ != kInvalidProcessId; |
| 99 } |
OLD | NEW |