| 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/browser/headless_window_parenting_client.h" | 21 #include "headless/lib/browser/headless_window_parenting_client.h" |
| 22 #include "headless/lib/browser/headless_window_tree_host.h" | |
| 23 #include "headless/lib/headless_content_main_delegate.h" | 22 #include "headless/lib/headless_content_main_delegate.h" |
| 24 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 25 #include "ui/events/devices/device_data_manager.h" | 24 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/gfx/geometry/size.h" | 25 #include "ui/gfx/geometry/size.h" |
| 27 | 26 |
| 28 namespace headless { | 27 namespace headless { |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 int RunContentMain( | 30 int RunContentMain( |
| 32 HeadlessBrowser::Options options, | 31 HeadlessBrowser::Options options, |
| 33 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { | 32 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { |
| 34 content::ContentMainParams params(nullptr); | 33 content::ContentMainParams params(nullptr); |
| 35 params.argc = options.argc; | 34 params.argc = options.argc; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 112 } |
| 114 | 113 |
| 115 void HeadlessBrowserImpl::set_browser_main_parts( | 114 void HeadlessBrowserImpl::set_browser_main_parts( |
| 116 HeadlessBrowserMainParts* browser_main_parts) { | 115 HeadlessBrowserMainParts* browser_main_parts) { |
| 117 DCHECK(!browser_main_parts_); | 116 DCHECK(!browser_main_parts_); |
| 118 browser_main_parts_ = browser_main_parts; | 117 browser_main_parts_ = browser_main_parts; |
| 119 } | 118 } |
| 120 | 119 |
| 121 void HeadlessBrowserImpl::RunOnStartCallback() { | 120 void HeadlessBrowserImpl::RunOnStartCallback() { |
| 122 DCHECK(aura::Env::GetInstance()); | 121 DCHECK(aura::Env::GetInstance()); |
| 123 ui::DeviceDataManager::CreateInstance(); | |
| 124 | |
| 125 window_tree_host_.reset( | 122 window_tree_host_.reset( |
| 126 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); | 123 aura::WindowTreeHost::Create(gfx::Rect(options()->window_size))); |
| 127 window_tree_host_->InitHost(); | 124 window_tree_host_->InitHost(); |
| 128 | 125 |
| 129 window_parenting_client_.reset( | 126 window_parenting_client_.reset( |
| 130 new HeadlessWindowParentingClient(window_tree_host_->window())); | 127 new HeadlessWindowParentingClient(window_tree_host_->window())); |
| 131 | 128 |
| 132 on_start_callback_.Run(this); | 129 on_start_callback_.Run(this); |
| 133 on_start_callback_ = base::Callback<void(HeadlessBrowser*)>(); | 130 on_start_callback_ = base::Callback<void(HeadlessBrowser*)>(); |
| 134 } | 131 } |
| 135 | 132 |
| 136 HeadlessBrowserContext* HeadlessBrowserImpl::CreateBrowserContext( | 133 HeadlessBrowserContext* HeadlessBrowserImpl::CreateBrowserContext( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 205 |
| 209 // Child processes should not end up here. | 206 // Child processes should not end up here. |
| 210 base::CommandLine command_line(options.argc, options.argv); | 207 base::CommandLine command_line(options.argc, options.argv); |
| 211 DCHECK(!command_line.HasSwitch(switches::kProcessType)); | 208 DCHECK(!command_line.HasSwitch(switches::kProcessType)); |
| 212 #endif | 209 #endif |
| 213 return RunContentMain(std::move(options), | 210 return RunContentMain(std::move(options), |
| 214 std::move(on_browser_start_callback)); | 211 std::move(on_browser_start_callback)); |
| 215 } | 212 } |
| 216 | 213 |
| 217 } // namespace headless | 214 } // namespace headless |
| OLD | NEW |