| 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 | 
| 12 using Options = headless::HeadlessBrowser::Options; | 16 using Options = headless::HeadlessBrowser::Options; | 
| 13 using Builder = headless::HeadlessBrowser::Options::Builder; | 17 using Builder = headless::HeadlessBrowser::Options::Builder; | 
| 14 | 18 | 
| 15 namespace headless { | 19 namespace headless { | 
| 16 | 20 | 
| 17 namespace { | 21 namespace { | 
| 18 // Product name for building the default user agent string. | 22 // Product name for building the default user agent string. | 
| 19 const char kProductName[] = "HeadlessChrome"; | 23 const char kProductName[] = "HeadlessChrome"; | 
| 20 constexpr gfx::Size kDefaultWindowSize(800, 600); | 24 constexpr gfx::Size kDefaultWindowSize(800, 600); | 
| 21 | 25 | 
| 22 std::string GetProductNameAndVersion() { | 26 std::string GetProductNameAndVersion() { | 
| 23   return std::string(kProductName) + "/" + PRODUCT_VERSION; | 27   return std::string(kProductName) + "/" + PRODUCT_VERSION; | 
| 24 } | 28 } | 
| 25 }  // namespace | 29 }  // namespace | 
| 26 | 30 | 
| 27 Options::Options(int argc, const char** argv) | 31 Options::Options(int argc, const char** argv) | 
| 28     : argc(argc), | 32     : argc(argc), | 
| 29       argv(argv), | 33       argv(argv), | 
|  | 34 #if defined(OS_WIN) | 
|  | 35       instance(0), | 
|  | 36       sandbox_info(nullptr), | 
|  | 37 #endif | 
| 30       devtools_socket_fd(0), | 38       devtools_socket_fd(0), | 
| 31       message_pump(nullptr), | 39       message_pump(nullptr), | 
| 32       single_process_mode(false), | 40       single_process_mode(false), | 
| 33       disable_sandbox(false), | 41       disable_sandbox(false), | 
| 34 #if !defined(OS_MACOSX) | 42 #if !defined(OS_MACOSX) | 
| 35       gl_implementation("osmesa"), | 43       gl_implementation("osmesa"), | 
| 36 #else | 44 #else | 
| 37       gl_implementation("any"), | 45       gl_implementation("any"), | 
| 38 #endif | 46 #endif | 
| 39       product_name_and_version(GetProductNameAndVersion()), | 47       product_name_and_version(GetProductNameAndVersion()), | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 108 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { | 116 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { | 
| 109   options_.gl_implementation = gl_implementation; | 117   options_.gl_implementation = gl_implementation; | 
| 110   return *this; | 118   return *this; | 
| 111 } | 119 } | 
| 112 | 120 | 
| 113 Builder& Builder::AddMojoServiceName(const std::string& mojo_service_name) { | 121 Builder& Builder::AddMojoServiceName(const std::string& mojo_service_name) { | 
| 114   options_.mojo_service_names.insert(mojo_service_name); | 122   options_.mojo_service_names.insert(mojo_service_name); | 
| 115   return *this; | 123   return *this; | 
| 116 } | 124 } | 
| 117 | 125 | 
|  | 126 #if defined(OS_WIN) | 
|  | 127 Builder& Builder::SetInstance(HINSTANCE instance) { | 
|  | 128   options_.instance = instance; | 
|  | 129   return *this; | 
|  | 130 } | 
|  | 131 | 
|  | 132 Builder& Builder::SetSandboxInfo(sandbox::SandboxInterfaceInfo* sandbox_info) { | 
|  | 133   options_.sandbox_info = sandbox_info; | 
|  | 134   return *this; | 
|  | 135 } | 
|  | 136 #endif  // defined(OS_WIN) | 
|  | 137 | 
| 118 Builder& Builder::SetUserDataDir(const base::FilePath& user_data_dir) { | 138 Builder& Builder::SetUserDataDir(const base::FilePath& user_data_dir) { | 
| 119   options_.user_data_dir = user_data_dir; | 139   options_.user_data_dir = user_data_dir; | 
| 120   return *this; | 140   return *this; | 
| 121 } | 141 } | 
| 122 | 142 | 
| 123 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { | 143 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { | 
| 124   options_.window_size = window_size; | 144   options_.window_size = window_size; | 
| 125   return *this; | 145   return *this; | 
| 126 } | 146 } | 
| 127 | 147 | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 144 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { | 164 Builder& Builder::SetCrashDumpsDir(const base::FilePath& dir) { | 
| 145   options_.crash_dumps_dir = dir; | 165   options_.crash_dumps_dir = dir; | 
| 146   return *this; | 166   return *this; | 
| 147 } | 167 } | 
| 148 | 168 | 
| 149 Options Builder::Build() { | 169 Options Builder::Build() { | 
| 150   return std::move(options_); | 170   return std::move(options_); | 
| 151 } | 171 } | 
| 152 | 172 | 
| 153 }  // namespace headless | 173 }  // namespace headless | 
| OLD | NEW | 
|---|