| 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" |
| 6 |
| 7 #include <utility> |
| 8 |
| 5 #include "content/public/common/user_agent.h" | 9 #include "content/public/common/user_agent.h" |
| 6 #include "headless/public/headless_browser.h" | |
| 7 | 10 |
| 8 using Options = headless::HeadlessBrowser::Options; | 11 using Options = headless::HeadlessBrowser::Options; |
| 9 using Builder = headless::HeadlessBrowser::Options::Builder; | 12 using Builder = headless::HeadlessBrowser::Options::Builder; |
| 10 | 13 |
| 11 namespace headless { | 14 namespace headless { |
| 12 | 15 |
| 13 // Product name for building the default user agent string. | 16 // Product name for building the default user agent string. |
| 14 namespace { | 17 namespace { |
| 15 const char kProductName[] = "HeadlessChrome"; | 18 const char kProductName[] = "HeadlessChrome"; |
| 16 constexpr gfx::Size kDefaultWindowSize(800, 600); | 19 constexpr gfx::Size kDefaultWindowSize(800, 600); |
| 17 } | 20 } |
| 18 | 21 |
| 19 Options::Options(int argc, const char** argv) | 22 Options::Options(int argc, const char** argv) |
| 20 : argc(argc), | 23 : argc(argc), |
| 21 argv(argv), | 24 argv(argv), |
| 22 user_agent(content::BuildUserAgentFromProduct(kProductName)), | |
| 23 message_pump(nullptr), | 25 message_pump(nullptr), |
| 24 single_process_mode(false), | 26 single_process_mode(false), |
| 25 disable_sandbox(false), | 27 disable_sandbox(false), |
| 26 gl_implementation("osmesa"), | 28 gl_implementation("osmesa"), |
| 29 user_agent(content::BuildUserAgentFromProduct(kProductName)), |
| 27 window_size(kDefaultWindowSize) {} | 30 window_size(kDefaultWindowSize) {} |
| 28 | 31 |
| 29 Options::Options(Options&& options) = default; | 32 Options::Options(Options&& options) = default; |
| 30 | 33 |
| 31 Options::~Options() {} | 34 Options::~Options() {} |
| 32 | 35 |
| 33 Options& Options::operator=(Options&& options) = default; | 36 Options& Options::operator=(Options&& options) = default; |
| 34 | 37 |
| 35 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} | 38 Builder::Builder(int argc, const char** argv) : options_(argc, argv) {} |
| 36 | 39 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 66 Builder& Builder::SetSingleProcessMode(bool single_process_mode) { | 69 Builder& Builder::SetSingleProcessMode(bool single_process_mode) { |
| 67 options_.single_process_mode = single_process_mode; | 70 options_.single_process_mode = single_process_mode; |
| 68 return *this; | 71 return *this; |
| 69 } | 72 } |
| 70 | 73 |
| 71 Builder& Builder::SetDisableSandbox(bool disable_sandbox) { | 74 Builder& Builder::SetDisableSandbox(bool disable_sandbox) { |
| 72 options_.disable_sandbox = disable_sandbox; | 75 options_.disable_sandbox = disable_sandbox; |
| 73 return *this; | 76 return *this; |
| 74 } | 77 } |
| 75 | 78 |
| 76 Builder& Builder::SetProtocolHandlers(ProtocolHandlerMap protocol_handlers) { | |
| 77 options_.protocol_handlers = std::move(protocol_handlers); | |
| 78 return *this; | |
| 79 } | |
| 80 | |
| 81 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { | 79 Builder& Builder::SetGLImplementation(const std::string& gl_implementation) { |
| 82 options_.gl_implementation = gl_implementation; | 80 options_.gl_implementation = gl_implementation; |
| 83 return *this; | 81 return *this; |
| 84 } | 82 } |
| 85 | 83 |
| 84 Builder& Builder::SetUserDataDir(const base::FilePath& user_data_dir) { |
| 85 options_.user_data_dir = user_data_dir; |
| 86 return *this; |
| 87 } |
| 88 |
| 86 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { | 89 Builder& Builder::SetWindowSize(const gfx::Size& window_size) { |
| 87 options_.window_size = window_size; | 90 options_.window_size = window_size; |
| 88 return *this; | 91 return *this; |
| 89 } | 92 } |
| 90 | 93 |
| 91 Options Builder::Build() { | 94 Options Builder::Build() { |
| 92 return std::move(options_); | 95 return std::move(options_); |
| 93 } | 96 } |
| 94 | 97 |
| 95 } // namespace headless | 98 } // namespace headless |
| OLD | NEW |