Avi Drissman | 60039d4 | 2022-09-13 21:49:05 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "extensions/shell/test/test_shell_main_delegate.h" |
| 6 | |
| 7 | #include "base/command_line.h" |
| 8 | #include "content/public/browser/browser_main_runner.h" |
| 9 | #include "content/public/common/content_switches.h" |
| 10 | #include "content/public/test/network_service_test_helper.h" |
| 11 | #include "content/public/utility/content_utility_client.h" |
Joe Mason | be86466 | 2022-06-28 23:45:31 | [diff] [blame] | 12 | #include "third_party/abseil-cpp/absl/types/variant.h" |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 13 | |
| 14 | namespace { |
| 15 | |
| 16 | class TestShellContentUtilityClient : public content::ContentUtilityClient { |
| 17 | public: |
| 18 | TestShellContentUtilityClient() { |
Yoichi Osato | bbdfbcdc | 2022-12-12 16:50:35 | [diff] [blame^] | 19 | network_service_test_helper_ = content::NetworkServiceTestHelper::Create(); |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 20 | } |
Peter Boström | 951cf77e | 2021-09-22 00:02:59 | [diff] [blame] | 21 | |
| 22 | TestShellContentUtilityClient(const TestShellContentUtilityClient&) = delete; |
| 23 | TestShellContentUtilityClient& operator=( |
| 24 | const TestShellContentUtilityClient&) = delete; |
| 25 | |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 26 | ~TestShellContentUtilityClient() override {} |
| 27 | |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 28 | private: |
| 29 | std::unique_ptr<content::NetworkServiceTestHelper> |
| 30 | network_service_test_helper_; |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | } // namespace |
| 34 | |
| 35 | namespace extensions { |
| 36 | |
| 37 | TestShellMainDelegate::TestShellMainDelegate() {} |
| 38 | |
| 39 | TestShellMainDelegate::~TestShellMainDelegate() {} |
| 40 | |
Samuel Huang | f59cd31 | 2021-03-30 20:00:40 | [diff] [blame] | 41 | #if BUILDFLAG(IS_CHROMEOS_LACROS) |
Etienne Bergeron | 3b0d75a | 2022-07-19 23:00:44 | [diff] [blame] | 42 | absl::optional<int> TestShellMainDelegate::PostEarlyInitialization( |
| 43 | InvokedIn invoked_in) { |
Joe Mason | be86466 | 2022-06-28 23:45:31 | [diff] [blame] | 44 | if (absl::holds_alternative<InvokedInBrowserProcess>(invoked_in)) { |
Joe Mason | cca092d | 2022-06-01 21:50:14 | [diff] [blame] | 45 | // Browser tests on Lacros requires a non-null LacrosService. |
| 46 | lacros_service_ = std::make_unique<chromeos::LacrosService>(); |
| 47 | } |
| 48 | extensions::ShellMainDelegate::PostEarlyInitialization(invoked_in); |
Etienne Bergeron | 3b0d75a | 2022-07-19 23:00:44 | [diff] [blame] | 49 | |
| 50 | return absl::nullopt; |
Samuel Huang | f59cd31 | 2021-03-30 20:00:40 | [diff] [blame] | 51 | } |
| 52 | #endif // BUILDFLAG(IS_CHROMEOS_LACROS) |
| 53 | |
Helen Li | 41066e8 | 2018-05-31 22:05:17 | [diff] [blame] | 54 | content::ContentUtilityClient* |
| 55 | TestShellMainDelegate::CreateContentUtilityClient() { |
| 56 | utility_client_ = std::make_unique<TestShellContentUtilityClient>(); |
| 57 | return utility_client_.get(); |
| 58 | } |
| 59 | |
| 60 | } // namespace extensions |