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 "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "content/public/app/content_main.h" | 8 #include "content/public/app/content_main.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 void HeadlessBrowserImpl::RunOnStartCallback() { | 68 void HeadlessBrowserImpl::RunOnStartCallback() { |
69 DCHECK(aura::Env::GetInstance()); | 69 DCHECK(aura::Env::GetInstance()); |
70 window_tree_host_.reset(aura::WindowTreeHost::Create(gfx::Rect())); | 70 window_tree_host_.reset(aura::WindowTreeHost::Create(gfx::Rect())); |
71 window_tree_host_->InitHost(); | 71 window_tree_host_->InitHost(); |
72 | 72 |
73 on_start_callback_.Run(this); | 73 on_start_callback_.Run(this); |
74 on_start_callback_ = base::Callback<void(HeadlessBrowser*)>(); | 74 on_start_callback_ = base::Callback<void(HeadlessBrowser*)>(); |
75 } | 75 } |
76 | 76 |
| 77 void HeadlessBrowserImpl::SetOptionsForTesting( |
| 78 const HeadlessBrowser::Options& options) { |
| 79 options_ = options; |
| 80 browser_context()->SetOptionsForTesting(options); |
| 81 } |
| 82 |
77 int HeadlessBrowserMain( | 83 int HeadlessBrowserMain( |
78 const HeadlessBrowser::Options& options, | 84 const HeadlessBrowser::Options& options, |
79 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { | 85 const base::Callback<void(HeadlessBrowser*)>& on_browser_start_callback) { |
80 scoped_ptr<HeadlessBrowserImpl> browser( | 86 scoped_ptr<HeadlessBrowserImpl> browser( |
81 new HeadlessBrowserImpl(on_browser_start_callback, options)); | 87 new HeadlessBrowserImpl(on_browser_start_callback, options)); |
82 | 88 |
83 // TODO(skyostil): Implement custom message pumps. | 89 // TODO(skyostil): Implement custom message pumps. |
84 DCHECK(!options.message_pump); | 90 DCHECK(!options.message_pump); |
85 | 91 |
86 headless::HeadlessContentMainDelegate delegate(std::move(browser)); | 92 headless::HeadlessContentMainDelegate delegate(std::move(browser)); |
87 content::ContentMainParams params(&delegate); | 93 content::ContentMainParams params(&delegate); |
88 params.argc = options.argc; | 94 params.argc = options.argc; |
89 params.argv = options.argv; | 95 params.argv = options.argv; |
90 return content::ContentMain(params); | 96 return content::ContentMain(params); |
91 } | 97 } |
92 | 98 |
93 } // namespace headless | 99 } // namespace headless |
OLD | NEW |