| 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/lib/browser/headless_browser_impl.h" | 5 #include "headless/lib/browser/headless_browser_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 std::unique_ptr<HeadlessBrowserImpl> browser( | 57 std::unique_ptr<HeadlessBrowserImpl> browser( |
| 58 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options))); | 58 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options))); |
| 59 headless::HeadlessContentMainDelegate delegate(std::move(browser)); | 59 headless::HeadlessContentMainDelegate delegate(std::move(browser)); |
| 60 params.delegate = &delegate; | 60 params.delegate = &delegate; |
| 61 return content::ContentMain(params); | 61 return content::ContentMain(params); |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 HeadlessBrowserWindow::HeadlessBrowserWindow(gfx::Size size) |
| 67 : bounds_(size), state_("normal") {} |
| 68 |
| 69 void HeadlessBrowserWindow::set_state(std::string state) { |
| 70 DCHECK(state == "normal" || state == "minimized" || state == "maximized" || |
| 71 state == "fullscreen"); |
| 72 state_ = state; |
| 73 } |
| 74 |
| 66 HeadlessBrowserImpl::HeadlessBrowserImpl( | 75 HeadlessBrowserImpl::HeadlessBrowserImpl( |
| 67 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, | 76 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, |
| 68 HeadlessBrowser::Options options) | 77 HeadlessBrowser::Options options) |
| 69 : on_start_callback_(on_start_callback), | 78 : on_start_callback_(on_start_callback), |
| 70 options_(std::move(options)), | 79 options_(std::move(options)), |
| 80 window_(options_.window_size), |
| 71 browser_main_parts_(nullptr), | 81 browser_main_parts_(nullptr), |
| 72 default_browser_context_(nullptr), | 82 default_browser_context_(nullptr), |
| 73 agent_host_(nullptr), | 83 agent_host_(nullptr), |
| 74 weak_ptr_factory_(this) {} | 84 weak_ptr_factory_(this) {} |
| 75 | 85 |
| 76 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} | 86 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} |
| 77 | 87 |
| 78 HeadlessBrowserContext::Builder | 88 HeadlessBrowserContext::Builder |
| 79 HeadlessBrowserImpl::CreateBrowserContextBuilder() { | 89 HeadlessBrowserImpl::CreateBrowserContextBuilder() { |
| 80 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 90 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 284 |
| 275 // Child processes should not end up here. | 285 // Child processes should not end up here. |
| 276 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 286 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 277 ::switches::kProcessType)); | 287 ::switches::kProcessType)); |
| 278 #endif | 288 #endif |
| 279 return RunContentMain(std::move(options), | 289 return RunContentMain(std::move(options), |
| 280 std::move(on_browser_start_callback)); | 290 std::move(on_browser_start_callback)); |
| 281 } | 291 } |
| 282 | 292 |
| 283 } // namespace headless | 293 } // namespace headless |
| OLD | NEW |