blob: 38ea1b9ac61bd2fcb00b01e61c97a3a4d96aa21a [file] [log] [blame]
Avi Drissman60039d42022-09-13 21:49:051// Copyright 2018 The Chromium Authors
Helen Li41066e82018-05-31 22:05:172// 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 Masonbe864662022-06-28 23:45:3112#include "third_party/abseil-cpp/absl/types/variant.h"
Helen Li41066e82018-05-31 22:05:1713
14namespace {
15
16class TestShellContentUtilityClient : public content::ContentUtilityClient {
17 public:
18 TestShellContentUtilityClient() {
Yoichi Osatobbdfbcdc2022-12-12 16:50:3519 network_service_test_helper_ = content::NetworkServiceTestHelper::Create();
Helen Li41066e82018-05-31 22:05:1720 }
Peter Boström951cf77e2021-09-22 00:02:5921
22 TestShellContentUtilityClient(const TestShellContentUtilityClient&) = delete;
23 TestShellContentUtilityClient& operator=(
24 const TestShellContentUtilityClient&) = delete;
25
Helen Li41066e82018-05-31 22:05:1726 ~TestShellContentUtilityClient() override {}
27
Helen Li41066e82018-05-31 22:05:1728 private:
29 std::unique_ptr<content::NetworkServiceTestHelper>
30 network_service_test_helper_;
Helen Li41066e82018-05-31 22:05:1731};
32
33} // namespace
34
35namespace extensions {
36
37TestShellMainDelegate::TestShellMainDelegate() {}
38
39TestShellMainDelegate::~TestShellMainDelegate() {}
40
Samuel Huangf59cd312021-03-30 20:00:4041#if BUILDFLAG(IS_CHROMEOS_LACROS)
Etienne Bergeron3b0d75a2022-07-19 23:00:4442absl::optional<int> TestShellMainDelegate::PostEarlyInitialization(
43 InvokedIn invoked_in) {
Joe Masonbe864662022-06-28 23:45:3144 if (absl::holds_alternative<InvokedInBrowserProcess>(invoked_in)) {
Joe Masoncca092d2022-06-01 21:50:1445 // 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 Bergeron3b0d75a2022-07-19 23:00:4449
50 return absl::nullopt;
Samuel Huangf59cd312021-03-30 20:00:4051}
52#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
53
Helen Li41066e82018-05-31 22:05:1754content::ContentUtilityClient*
55TestShellMainDelegate::CreateContentUtilityClient() {
56 utility_client_ = std::make_unique<TestShellContentUtilityClient>();
57 return utility_client_.get();
58}
59
60} // namespace extensions