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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "components/security_state/content/content_utils.h" |
| 17 #include "components/security_state/core/security_state.h" |
16 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/devtools_agent_host.h" | 19 #include "content/public/browser/devtools_agent_host.h" |
18 #include "content/public/browser/navigation_handle.h" | 20 #include "content/public/browser/navigation_handle.h" |
19 #include "content/public/browser/render_frame_host.h" | 21 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 23 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
23 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
24 #include "content/public/browser/web_contents_delegate.h" | 26 #include "content/public/browser/web_contents_delegate.h" |
25 #include "content/public/common/bindings_policy.h" | 27 #include "content/public/common/bindings_policy.h" |
| 28 #include "content/public/common/origin_util.h" |
26 #include "content/public/renderer/render_frame.h" | 29 #include "content/public/renderer/render_frame.h" |
27 #include "headless/lib/browser/headless_browser_context_impl.h" | 30 #include "headless/lib/browser/headless_browser_context_impl.h" |
28 #include "headless/lib/browser/headless_browser_impl.h" | 31 #include "headless/lib/browser/headless_browser_impl.h" |
29 #include "headless/lib/browser/headless_browser_main_parts.h" | 32 #include "headless/lib/browser/headless_browser_main_parts.h" |
30 #include "headless/lib/browser/headless_devtools_client_impl.h" | 33 #include "headless/lib/browser/headless_devtools_client_impl.h" |
31 #include "services/service_manager/public/cpp/interface_registry.h" | 34 #include "services/service_manager/public/cpp/interface_registry.h" |
32 #include "ui/aura/window.h" | 35 #include "ui/aura/window.h" |
33 | 36 |
34 namespace headless { | 37 namespace headless { |
35 | 38 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 content::WebContents* new_contents) override { | 76 content::WebContents* new_contents) override { |
74 std::unique_ptr<HeadlessWebContentsImpl> web_contents = | 77 std::unique_ptr<HeadlessWebContentsImpl> web_contents = |
75 HeadlessWebContentsImpl::CreateFromWebContents(new_contents, | 78 HeadlessWebContentsImpl::CreateFromWebContents(new_contents, |
76 browser_context_); | 79 browser_context_); |
77 | 80 |
78 DCHECK(new_contents->GetBrowserContext() == browser_context_); | 81 DCHECK(new_contents->GetBrowserContext() == browser_context_); |
79 | 82 |
80 browser_context_->RegisterWebContents(std::move(web_contents)); | 83 browser_context_->RegisterWebContents(std::move(web_contents)); |
81 } | 84 } |
82 | 85 |
| 86 // Return the security style of the given |web_contents|, populating |
| 87 // |security_style_explanations| to explain why the SecurityStyle was chosen. |
| 88 blink::WebSecurityStyle GetSecurityStyle( |
| 89 content::WebContents* web_contents, |
| 90 content::SecurityStyleExplanations* security_style_explanations) |
| 91 override { |
| 92 security_state::SecurityInfo security_info; |
| 93 security_state::GetSecurityInfo( |
| 94 security_state::GetVisibleSecurityState(web_contents), |
| 95 false /* used_policy_installed_certificate */, |
| 96 base::Bind(&content::IsOriginSecure), &security_info); |
| 97 return security_state::GetSecurityStyle(security_info, |
| 98 security_style_explanations); |
| 99 } |
| 100 |
83 private: | 101 private: |
84 HeadlessBrowserContextImpl* browser_context_; // Not owned. | 102 HeadlessBrowserContextImpl* browser_context_; // Not owned. |
85 DISALLOW_COPY_AND_ASSIGN(Delegate); | 103 DISALLOW_COPY_AND_ASSIGN(Delegate); |
86 }; | 104 }; |
87 | 105 |
88 // static | 106 // static |
89 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create( | 107 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create( |
90 HeadlessWebContents::Builder* builder, | 108 HeadlessWebContents::Builder* builder, |
91 aura::Window* parent_window) { | 109 aura::Window* parent_window) { |
92 content::WebContents::CreateParams create_params(builder->browser_context_, | 110 content::WebContents::CreateParams create_params(builder->browser_context_, |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 HeadlessWebContents::Builder::MojoService::MojoService() {} | 275 HeadlessWebContents::Builder::MojoService::MojoService() {} |
258 | 276 |
259 HeadlessWebContents::Builder::MojoService::MojoService( | 277 HeadlessWebContents::Builder::MojoService::MojoService( |
260 const std::string& service_name, | 278 const std::string& service_name, |
261 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 279 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
262 : service_name(service_name), service_factory(service_factory) {} | 280 : service_name(service_name), service_factory(service_factory) {} |
263 | 281 |
264 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 282 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
265 | 283 |
266 } // namespace headless | 284 } // namespace headless |
OLD | NEW |