| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/public/provider/chrome/browser/test_chrome_browser_provider.h" | 5 #include "ios/public/provider/chrome/browser/test_chrome_browser_provider.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "ios/public/provider/chrome/browser/distribution/test_app_distribution_
provider.h" | 12 #include "ios/public/provider/chrome/browser/distribution/test_app_distribution_
provider.h" |
| 13 #include "ios/public/provider/chrome/browser/omaha/test_omaha_service_provider.h
" | 13 #include "ios/public/provider/chrome/browser/omaha/test_omaha_service_provider.h
" |
| 14 #include "ios/public/provider/chrome/browser/sessions/test_live_tab_context_prov
ider.h" |
| 15 #include "ios/public/provider/chrome/browser/sessions/test_synced_window_delegat
es_getter.h" |
| 14 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service
.h" | 16 #include "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service
.h" |
| 15 #include "ios/public/provider/chrome/browser/signin/test_signin_resources_provid
er.h" | 17 #include "ios/public/provider/chrome/browser/signin/test_signin_resources_provid
er.h" |
| 18 #import "ios/public/provider/chrome/browser/ui/test_infobar_view.h" |
| 19 #import "ios/public/provider/chrome/browser/ui/test_styled_text_field.h" |
| 16 #import "ios/public/provider/chrome/browser/voice/test_voice_search_provider.h" | 20 #import "ios/public/provider/chrome/browser/voice/test_voice_search_provider.h" |
| 17 #import "ios/public/provider/chrome/browser/voice/voice_search_language.h" | 21 #import "ios/public/provider/chrome/browser/voice/voice_search_language.h" |
| 18 | 22 |
| 19 @interface TestStyledTextField : UITextField<TextFieldStyling> | |
| 20 @end | |
| 21 | |
| 22 @implementation TestStyledTextField | |
| 23 @synthesize placeholderStyle = _placeholderStyle; | |
| 24 @synthesize textValidator = _textValidator; | |
| 25 | |
| 26 - (void)setUseErrorStyling:(BOOL)error { | |
| 27 } | |
| 28 @end | |
| 29 | |
| 30 namespace ios { | 23 namespace ios { |
| 31 | 24 |
| 32 TestChromeBrowserProvider::TestChromeBrowserProvider() | 25 TestChromeBrowserProvider::TestChromeBrowserProvider() |
| 33 : app_distribution_provider_( | 26 : app_distribution_provider_( |
| 34 base::MakeUnique<TestAppDistributionProvider>()), | 27 base::MakeUnique<TestAppDistributionProvider>()), |
| 28 live_tab_context_provider_( |
| 29 base::MakeUnique<TestLiveTabContextProvider>()), |
| 35 omaha_service_provider_(base::MakeUnique<TestOmahaServiceProvider>()), | 30 omaha_service_provider_(base::MakeUnique<TestOmahaServiceProvider>()), |
| 36 signin_resources_provider_( | 31 signin_resources_provider_( |
| 37 base::MakeUnique<TestSigninResourcesProvider>()), | 32 base::MakeUnique<TestSigninResourcesProvider>()), |
| 38 voice_search_provider_(base::MakeUnique<TestVoiceSearchProvider>()) {} | 33 voice_search_provider_(base::MakeUnique<TestVoiceSearchProvider>()) {} |
| 39 | 34 |
| 40 TestChromeBrowserProvider::~TestChromeBrowserProvider() {} | 35 TestChromeBrowserProvider::~TestChromeBrowserProvider() {} |
| 41 | 36 |
| 42 // static | 37 // static |
| 43 TestChromeBrowserProvider* TestChromeBrowserProvider::GetTestProvider() { | 38 TestChromeBrowserProvider* TestChromeBrowserProvider::GetTestProvider() { |
| 44 ChromeBrowserProvider* provider = GetChromeBrowserProvider(); | 39 ChromeBrowserProvider* provider = GetChromeBrowserProvider(); |
| 45 DCHECK(provider); | 40 DCHECK(provider); |
| 46 return static_cast<TestChromeBrowserProvider*>(provider); | 41 return static_cast<TestChromeBrowserProvider*>(provider); |
| 47 } | 42 } |
| 48 | 43 |
| 44 InfoBarViewPlaceholder TestChromeBrowserProvider::CreateInfoBarView( |
| 45 CGRect frame, |
| 46 InfoBarViewDelegate* delegate) { |
| 47 return [[TestInfoBarView alloc] init]; |
| 48 } |
| 49 |
| 49 SigninResourcesProvider* | 50 SigninResourcesProvider* |
| 50 TestChromeBrowserProvider::GetSigninResourcesProvider() { | 51 TestChromeBrowserProvider::GetSigninResourcesProvider() { |
| 51 return signin_resources_provider_.get(); | 52 return signin_resources_provider_.get(); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void TestChromeBrowserProvider::SetChromeIdentityServiceForTesting( | 55 void TestChromeBrowserProvider::SetChromeIdentityServiceForTesting( |
| 55 std::unique_ptr<ChromeIdentityService> service) { | 56 std::unique_ptr<ChromeIdentityService> service) { |
| 56 chrome_identity_service_.swap(service); | 57 chrome_identity_service_.swap(service); |
| 57 } | 58 } |
| 58 | 59 |
| 59 ChromeIdentityService* TestChromeBrowserProvider::GetChromeIdentityService() { | 60 ChromeIdentityService* TestChromeBrowserProvider::GetChromeIdentityService() { |
| 60 if (!chrome_identity_service_) { | 61 if (!chrome_identity_service_) { |
| 61 chrome_identity_service_.reset(new FakeChromeIdentityService()); | 62 chrome_identity_service_.reset(new FakeChromeIdentityService()); |
| 62 } | 63 } |
| 63 return chrome_identity_service_.get(); | 64 return chrome_identity_service_.get(); |
| 64 } | 65 } |
| 65 | 66 |
| 67 LiveTabContextProvider* TestChromeBrowserProvider::GetLiveTabContextProvider() { |
| 68 return live_tab_context_provider_.get(); |
| 69 } |
| 70 |
| 66 UITextField<TextFieldStyling>* TestChromeBrowserProvider::CreateStyledTextField( | 71 UITextField<TextFieldStyling>* TestChromeBrowserProvider::CreateStyledTextField( |
| 67 CGRect frame) const { | 72 CGRect frame) const { |
| 68 return [[TestStyledTextField alloc] initWithFrame:frame]; | 73 return [[TestStyledTextField alloc] initWithFrame:frame]; |
| 69 } | 74 } |
| 70 | 75 |
| 71 NSArray* TestChromeBrowserProvider::GetAvailableVoiceSearchLanguages() const { | 76 NSArray* TestChromeBrowserProvider::GetAvailableVoiceSearchLanguages() const { |
| 72 return voice_search_provider_->GetAvailableLanguages(); | 77 return voice_search_provider_->GetAvailableLanguages(); |
| 73 } | 78 } |
| 74 | 79 |
| 75 VoiceSearchProvider* TestChromeBrowserProvider::GetVoiceSearchProvider() const { | 80 VoiceSearchProvider* TestChromeBrowserProvider::GetVoiceSearchProvider() const { |
| 76 return voice_search_provider_.get(); | 81 return voice_search_provider_.get(); |
| 77 } | 82 } |
| 78 | 83 |
| 79 AppDistributionProvider* TestChromeBrowserProvider::GetAppDistributionProvider() | 84 AppDistributionProvider* TestChromeBrowserProvider::GetAppDistributionProvider() |
| 80 const { | 85 const { |
| 81 return app_distribution_provider_.get(); | 86 return app_distribution_provider_.get(); |
| 82 } | 87 } |
| 83 | 88 |
| 84 OmahaServiceProvider* TestChromeBrowserProvider::GetOmahaServiceProvider() | 89 OmahaServiceProvider* TestChromeBrowserProvider::GetOmahaServiceProvider() |
| 85 const { | 90 const { |
| 86 return omaha_service_provider_.get(); | 91 return omaha_service_provider_.get(); |
| 87 } | 92 } |
| 88 | 93 |
| 94 std::unique_ptr<sync_sessions::SyncedWindowDelegatesGetter> |
| 95 TestChromeBrowserProvider::CreateSyncedWindowDelegatesGetter( |
| 96 ios::ChromeBrowserState* browser_state) { |
| 97 return base::MakeUnique<TestSyncedWindowDelegatesGetter>(); |
| 98 } |
| 99 |
| 89 id<NativeAppWhitelistManager> | 100 id<NativeAppWhitelistManager> |
| 90 TestChromeBrowserProvider::GetNativeAppWhitelistManager() const { | 101 TestChromeBrowserProvider::GetNativeAppWhitelistManager() const { |
| 91 return nil; | 102 return nil; |
| 92 } | 103 } |
| 93 | 104 |
| 94 } // namespace ios | 105 } // namespace ios |
| OLD | NEW |