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_web_contents_impl.h" | 5 #include "headless/lib/browser/headless_web_contents_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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 TabSocket::Name_, | 166 TabSocket::Name_, |
167 base::Bind( | 167 base::Bind( |
168 &ForwardToServiceFactory, | 168 &ForwardToServiceFactory, |
169 base::Bind( | 169 base::Bind( |
170 &HeadlessTabSocketImpl::CreateMojoService, | 170 &HeadlessTabSocketImpl::CreateMojoService, |
171 base::Unretained( | 171 base::Unretained( |
172 headless_web_contents->headless_tab_socket_.get())))); | 172 headless_web_contents->headless_tab_socket_.get())))); |
173 } | 173 } |
174 | 174 |
175 headless_web_contents->mojo_services_ = std::move(builder->mojo_services_); | 175 headless_web_contents->mojo_services_ = std::move(builder->mojo_services_); |
176 headless_web_contents->InitializeScreen(builder->window_size_); | 176 headless_web_contents->InitializeScreen( |
| 177 builder->window_size_, |
| 178 builder->browser_context_->options()->screen_size()); |
177 if (!headless_web_contents->OpenURL(builder->initial_url_)) | 179 if (!headless_web_contents->OpenURL(builder->initial_url_)) |
178 return nullptr; | 180 return nullptr; |
179 return headless_web_contents; | 181 return headless_web_contents; |
180 } | 182 } |
181 | 183 |
182 // static | 184 // static |
183 std::unique_ptr<HeadlessWebContentsImpl> | 185 std::unique_ptr<HeadlessWebContentsImpl> |
184 HeadlessWebContentsImpl::CreateFromWebContents( | 186 HeadlessWebContentsImpl::CreateFromWebContents( |
185 content::WebContents* web_contents, | 187 content::WebContents* web_contents, |
186 HeadlessBrowserContextImpl* browser_context) { | 188 HeadlessBrowserContextImpl* browser_context) { |
187 std::unique_ptr<HeadlessWebContentsImpl> headless_web_contents = | 189 std::unique_ptr<HeadlessWebContentsImpl> headless_web_contents = |
188 base::WrapUnique( | 190 base::WrapUnique( |
189 new HeadlessWebContentsImpl(web_contents, browser_context)); | 191 new HeadlessWebContentsImpl(web_contents, browser_context)); |
190 | 192 |
191 return headless_web_contents; | 193 return headless_web_contents; |
192 } | 194 } |
193 | 195 |
194 void HeadlessWebContentsImpl::InitializeScreen(const gfx::Size& initial_size) { | 196 void HeadlessWebContentsImpl::InitializeScreen( |
195 browser()->PlatformInitializeWebContents(initial_size, this); | 197 const gfx::Size& initial_window_size, |
| 198 const gfx::Size& screen_size) { |
| 199 browser()->PlatformInitializeWebContents(initial_window_size, screen_size, |
| 200 this); |
196 } | 201 } |
197 | 202 |
198 HeadlessWebContentsImpl::HeadlessWebContentsImpl( | 203 HeadlessWebContentsImpl::HeadlessWebContentsImpl( |
199 content::WebContents* web_contents, | 204 content::WebContents* web_contents, |
200 HeadlessBrowserContextImpl* browser_context) | 205 HeadlessBrowserContextImpl* browser_context) |
201 : content::WebContentsObserver(web_contents), | 206 : content::WebContentsObserver(web_contents), |
202 web_contents_delegate_( | 207 web_contents_delegate_( |
203 new HeadlessWebContentsImpl::Delegate(browser_context)), | 208 new HeadlessWebContentsImpl::Delegate(browser_context)), |
204 web_contents_(web_contents), | 209 web_contents_(web_contents), |
205 agent_host_(content::DevToolsAgentHost::GetOrCreateFor(web_contents)), | 210 agent_host_(content::DevToolsAgentHost::GetOrCreateFor(web_contents)), |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 HeadlessWebContents::Builder::MojoService::MojoService() {} | 402 HeadlessWebContents::Builder::MojoService::MojoService() {} |
398 | 403 |
399 HeadlessWebContents::Builder::MojoService::MojoService( | 404 HeadlessWebContents::Builder::MojoService::MojoService( |
400 const std::string& service_name, | 405 const std::string& service_name, |
401 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 406 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
402 : service_name(service_name), service_factory(service_factory) {} | 407 : service_name(service_name), service_factory(service_factory) {} |
403 | 408 |
404 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 409 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
405 | 410 |
406 } // namespace headless | 411 } // namespace headless |
OLD | NEW |