OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "headless/public/headless_browser.h" | 5 #include "headless/public/headless_browser.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/public/common/user_agent.h" | 9 #include "content/public/common/user_agent.h" |
10 #include "headless/public/version.h" | 10 #include "headless/public/version.h" |
11 | 11 |
12 #if defined(OS_WIN) | |
13 #include "sandbox/win/src/sandbox_types.h" | |
14 #endif | |
15 | |
16 using Options = headless::HeadlessBrowser::Options; | 12 using Options = headless::HeadlessBrowser::Options; |
17 using Builder = headless::HeadlessBrowser::Options::Builder; | 13 using Builder = headless::HeadlessBrowser::Options::Builder; |
18 | 14 |
19 namespace headless { | 15 namespace headless { |
20 | 16 |
21 namespace { | 17 namespace { |
22 // Product name for building the default user agent string. | 18 // Product name for building the default user agent string. |
23 const char kProductName[] = "HeadlessChrome"; | 19 const char kProductName[] = "HeadlessChrome"; |
24 constexpr gfx::Size kDefaultWindowSize(800, 600); | 20 constexpr gfx::Size kDefaultWindowSize(800, 600); |
25 | 21 |
26 std::string GetProductNameAndVersion() { | 22 std::string GetProductNameAndVersion() { |
27 return std::string(kProductName) + "/" + PRODUCT_VERSION; | 23 return std::string(kProductName) + "/" + PRODUCT_VERSION; |
28 } | 24 } |
29 } // namespace | 25 } // namespace |
30 | 26 |
31 Options::Options(int argc, const char** argv) | 27 Options::Options(int argc, const char** argv) |
32 : argc(argc), | 28 : argc(argc), |
33 argv(argv), | 29 argv(argv), |
34 #if defined(OS_WIN) | |
35 instance(0), | |
36 sandbox_info(nullptr), | |
37 #endif | |
38 message_pump(nullptr), | 30 message_pump(nullptr), |
39 single_process_mode(false), | 31 single_process_mode(false), |
40 disable_sandbox(false), | 32 disable_sandbox(false), |
41 #if !defined(OS_MACOSX) | 33 #if !defined(OS_MACOSX) |
42 gl_implementation("osmesa"), | 34 gl_implementation("osmesa"), |
43 #else | 35 #else |
44 gl_implementation("any"), | 36 gl_implementation("any"), |
45 #endif | 37 #endif |
46 product_name_and_version(GetProductNameAndVersion()), | 38 product_name_and_version(GetProductNameAndVersion()), |
47 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)), | 39 user_agent(content::BuildUserAgentFromProduct(product_name_and_version)), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { | 98 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { |
107 options_.gl_implementation = gl_implementation; | 99 options_.gl_implementation = gl_implementation; |
108 return *this; | 100 return *this; |
109 } | 101 } |
110 | 102 |
111 Builder& Builder::AddMojoServiceName(const std::string& mojo_service_name) { | 103 Builder& Builder::AddMojoServiceName(const std::string& mojo_service_name) { |
112 options_.mojo_service_names.insert(mojo_service_name); | 104 options_.mojo_service_names.insert(mojo_service_name); |
113 return *this; | 105 return *this; |
114 } | 106 } |
115 | 107 |
116 #if defined(OS_WIN) | |
117 Builder& Builder::SetInstance(HINSTANCE instance) { | |
118 options_.instance = instance; | |
119 return *this; | |
120 } | |
121 | |
122 Builder& Builder::SetSandboxInfo(sandbox::SandboxInterfaceInfo* sandbox_info) { | |
123 options_.sandbox_info = sandbox_info; | |
124 return *this; | |
125 } | |
126 #endif // defined(OS_WIN) | |
127 | |
128 Builder& Builder::SetUserDataDir(const base::FilePath& user_data_dir) { | 108 Builder& Builder::SetUserDataDir(const base::FilePath& user_data_dir) { |
129 options_.user_data_dir = user_data_dir; | 109 options_.user_data_dir = user_data_dir; |
130 return *this; | 110 return *this; |
131 } | 111 } |
132 | 112 |
133 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { | 113 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { |
134 options_.window_size = window_size; | 114 options_.window_size = window_size; |
135 return *this; | 115 return *this; |
136 } | 116 } |
137 | 117 |
(...skipping 16 matching lines...) Expand all Loading... |
154 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { | 134 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { |
155 options_.crash_dumps_dir = dir; | 135 options_.crash_dumps_dir = dir; |
156 return *this; | 136 return *this; |
157 } | 137 } |
158 | 138 |
159 Options Builder::Build() { | 139 Options Builder::Build() { |
160 return std::move(options_); | 140 return std::move(options_); |
161 } | 141 } |
162 | 142 |
163 } // namespace headless | 143 } // namespace headless |
OLD | NEW |