Chromium Code Reviews| 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 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "content/public/app/content_main.h" | 14 #include "content/public/app/content_main.h" |
| 15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "headless/lib/browser/headless_browser_context_impl.h" | 18 #include "headless/lib/browser/headless_browser_context_impl.h" |
| 19 #include "headless/lib/browser/headless_browser_main_parts.h" | 19 #include "headless/lib/browser/headless_browser_main_parts.h" |
| 20 #include "headless/lib/browser/headless_web_contents_impl.h" | 20 #include "headless/lib/browser/headless_web_contents_impl.h" |
| 21 #include "headless/lib/headless_content_main_delegate.h" | 21 #include "headless/lib/headless_content_main_delegate.h" |
| 22 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 23 #include "ui/aura/test/test_focus_client.h" | |
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 24 #include "ui/events/devices/device_data_manager.h" | 25 #include "ui/events/devices/device_data_manager.h" |
| 25 #include "ui/gfx/geometry/size.h" | 26 #include "ui/gfx/geometry/size.h" |
| 26 | 27 |
| 27 namespace headless { | 28 namespace headless { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 int RunContentMain( | 31 int RunContentMain( |
| 31 HeadlessBrowser::Options options, | 32 HeadlessBrowser::Options options, |
| 32 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { | 33 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { |
| 33 content::ContentMainParams params(nullptr); | 34 content::ContentMainParams params(nullptr); |
| 34 params.argc = options.argc; | 35 params.argc = options.argc; |
| 35 params.argv = options.argv; | 36 params.argv = options.argv; |
| 36 | 37 |
| 37 // TODO(skyostil): Implement custom message pumps. | 38 // TODO(skyostil): Implement custom message pumps. |
| 38 DCHECK(!options.message_pump); | 39 DCHECK(!options.message_pump); |
| 39 | 40 |
| 40 std::unique_ptr<HeadlessBrowserImpl> browser( | 41 std::unique_ptr<HeadlessBrowserImpl> browser( |
| 41 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options))); | 42 new HeadlessBrowserImpl(on_browser_start_callback, std::move(options))); |
| 42 headless::HeadlessContentMainDelegate delegate(std::move(browser)); | 43 headless::HeadlessContentMainDelegate delegate(std::move(browser)); |
| 43 params.delegate = &delegate; | 44 params.delegate = &delegate; |
| 44 return content::ContentMain(params); | 45 return content::ContentMain(params); |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace | 48 } // namespace |
| 48 | 49 |
| 49 HeadlessBrowserImpl::HeadlessBrowserImpl( | 50 HeadlessBrowserImpl::HeadlessBrowserImpl( |
| 50 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, | 51 const base::Callback<void(HeadlessBrowser*)>& on_start_callback, |
| 51 HeadlessBrowser::Options options) | 52 HeadlessBrowser::Options options) |
| 52 : on_start_callback_(on_start_callback), | 53 : focus_client_(new aura::test::TestFocusClient()), |
|
Eric Seckler
2017/02/22 09:00:04
Let's get rid of the init here, since you reset it
irisu
2017/02/23 00:02:26
Done.
| |
| 54 on_start_callback_(on_start_callback), | |
| 53 options_(std::move(options)), | 55 options_(std::move(options)), |
| 54 browser_main_parts_(nullptr), | 56 browser_main_parts_(nullptr), |
| 55 default_browser_context_(nullptr), | 57 default_browser_context_(nullptr), |
| 56 weak_ptr_factory_(this) {} | 58 weak_ptr_factory_(this) {} |
| 57 | 59 |
| 58 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} | 60 HeadlessBrowserImpl::~HeadlessBrowserImpl() {} |
| 59 | 61 |
| 60 HeadlessBrowserContext::Builder | 62 HeadlessBrowserContext::Builder |
| 61 HeadlessBrowserImpl::CreateBrowserContextBuilder() { | 63 HeadlessBrowserImpl::CreateBrowserContextBuilder() { |
| 62 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 64 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 211 |
| 210 // Child processes should not end up here. | 212 // Child processes should not end up here. |
| 211 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 213 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 212 switches::kProcessType)); | 214 switches::kProcessType)); |
| 213 #endif | 215 #endif |
| 214 return RunContentMain(std::move(options), | 216 return RunContentMain(std::move(options), |
| 215 std::move(on_browser_start_callback)); | 217 std::move(on_browser_start_callback)); |
| 216 } | 218 } |
| 217 | 219 |
| 218 } // namespace headless | 220 } // namespace headless |
| OLD | NEW |