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 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
13 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
16 #include "components/security_state/content/content_utils.h" | 17 #include "components/security_state/content/content_utils.h" |
17 #include "components/security_state/core/security_state.h" | 18 #include "components/security_state/core/security_state.h" |
18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/devtools_agent_host.h" | 20 #include "content/public/browser/devtools_agent_host.h" |
20 #include "content/public/browser/navigation_handle.h" | 21 #include "content/public/browser/navigation_handle.h" |
21 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
23 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
24 #include "content/public/browser/render_widget_host.h" | 25 #include "content/public/browser/render_widget_host.h" |
25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
26 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
27 #include "content/public/common/bindings_policy.h" | 28 #include "content/public/common/bindings_policy.h" |
28 #include "content/public/common/origin_util.h" | 29 #include "content/public/common/origin_util.h" |
29 #include "headless/lib/browser/headless_browser_context_impl.h" | 30 #include "headless/lib/browser/headless_browser_context_impl.h" |
30 #include "headless/lib/browser/headless_browser_impl.h" | 31 #include "headless/lib/browser/headless_browser_impl.h" |
31 #include "headless/lib/browser/headless_browser_main_parts.h" | 32 #include "headless/lib/browser/headless_browser_main_parts.h" |
32 #include "headless/lib/browser/headless_devtools_client_impl.h" | 33 #include "headless/lib/browser/headless_devtools_client_impl.h" |
| 34 #include "headless/lib/browser/headless_print_manager.h" |
33 #include "services/service_manager/public/cpp/interface_registry.h" | 35 #include "services/service_manager/public/cpp/interface_registry.h" |
34 | 36 |
35 namespace headless { | 37 namespace headless { |
36 | 38 |
37 // static | 39 // static |
38 HeadlessWebContentsImpl* HeadlessWebContentsImpl::From( | 40 HeadlessWebContentsImpl* HeadlessWebContentsImpl::From( |
39 HeadlessWebContents* web_contents) { | 41 HeadlessWebContents* web_contents) { |
40 // This downcast is safe because there is only one implementation of | 42 // This downcast is safe because there is only one implementation of |
41 // HeadlessWebContents. | 43 // HeadlessWebContents. |
42 return static_cast<HeadlessWebContentsImpl*>(web_contents); | 44 return static_cast<HeadlessWebContentsImpl*>(web_contents); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 HeadlessWebContentsImpl::HeadlessWebContentsImpl( | 167 HeadlessWebContentsImpl::HeadlessWebContentsImpl( |
166 content::WebContents* web_contents, | 168 content::WebContents* web_contents, |
167 HeadlessBrowserContextImpl* browser_context) | 169 HeadlessBrowserContextImpl* browser_context) |
168 : content::WebContentsObserver(web_contents), | 170 : content::WebContentsObserver(web_contents), |
169 web_contents_delegate_( | 171 web_contents_delegate_( |
170 new HeadlessWebContentsImpl::Delegate(browser_context)), | 172 new HeadlessWebContentsImpl::Delegate(browser_context)), |
171 web_contents_(web_contents), | 173 web_contents_(web_contents), |
172 agent_host_(content::DevToolsAgentHost::GetOrCreateFor(web_contents)), | 174 agent_host_(content::DevToolsAgentHost::GetOrCreateFor(web_contents)), |
173 browser_context_(browser_context), | 175 browser_context_(browser_context), |
174 render_process_host_(web_contents->GetRenderProcessHost()) { | 176 render_process_host_(web_contents->GetRenderProcessHost()) { |
| 177 printing::HeadlessPrintManager::CreateForWebContents(web_contents); |
175 web_contents_->SetDelegate(web_contents_delegate_.get()); | 178 web_contents_->SetDelegate(web_contents_delegate_.get()); |
176 render_process_host_->AddObserver(this); | 179 render_process_host_->AddObserver(this); |
177 } | 180 } |
178 | 181 |
179 HeadlessWebContentsImpl::~HeadlessWebContentsImpl() { | 182 HeadlessWebContentsImpl::~HeadlessWebContentsImpl() { |
180 if (render_process_host_) | 183 if (render_process_host_) |
181 render_process_host_->RemoveObserver(this); | 184 render_process_host_->RemoveObserver(this); |
182 } | 185 } |
183 | 186 |
184 void HeadlessWebContentsImpl::RenderFrameCreated( | 187 void HeadlessWebContentsImpl::RenderFrameCreated( |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 HeadlessWebContents::Builder::MojoService::MojoService() {} | 322 HeadlessWebContents::Builder::MojoService::MojoService() {} |
320 | 323 |
321 HeadlessWebContents::Builder::MojoService::MojoService( | 324 HeadlessWebContents::Builder::MojoService::MojoService( |
322 const std::string& service_name, | 325 const std::string& service_name, |
323 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 326 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
324 : service_name(service_name), service_factory(service_factory) {} | 327 : service_name(service_name), service_factory(service_factory) {} |
325 | 328 |
326 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 329 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
327 | 330 |
328 } // namespace headless | 331 } // namespace headless |
OLD | NEW |