Chromium Code Reviews| 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" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 false /* used_policy_installed_certificate */, | 95 false /* used_policy_installed_certificate */, |
| 96 base::Bind(&content::IsOriginSecure), &security_info); | 96 base::Bind(&content::IsOriginSecure), &security_info); |
| 97 return security_state::GetSecurityStyle(security_info, | 97 return security_state::GetSecurityStyle(security_info, |
| 98 security_style_explanations); | 98 security_style_explanations); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ActivateContents(content::WebContents* contents) override { | 101 void ActivateContents(content::WebContents* contents) override { |
| 102 contents->GetRenderViewHost()->GetWidget()->Focus(); | 102 contents->GetRenderViewHost()->GetWidget()->Focus(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void CloseContents(content::WebContents* source) override { | |
| 106 std::vector<HeadlessWebContents*> allContents = | |
|
Sami
2017/03/08 10:47:24
s/allContents/all_contents/
| |
| 107 browser_context_->GetAllWebContents(); | |
| 108 | |
| 109 for (HeadlessWebContents* wc : allContents) { | |
| 110 HeadlessWebContentsImpl* hwc = HeadlessWebContentsImpl::From(wc); | |
| 111 if (hwc->web_contents() == source) { | |
| 112 wc->Close(); | |
| 113 return; | |
| 114 } | |
| 115 } | |
| 116 } | |
| 117 | |
| 105 private: | 118 private: |
| 106 HeadlessBrowserContextImpl* browser_context_; // Not owned. | 119 HeadlessBrowserContextImpl* browser_context_; // Not owned. |
| 107 DISALLOW_COPY_AND_ASSIGN(Delegate); | 120 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 108 }; | 121 }; |
| 109 | 122 |
| 110 // static | 123 // static |
| 111 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create( | 124 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create( |
| 112 HeadlessWebContents::Builder* builder) { | 125 HeadlessWebContents::Builder* builder) { |
| 113 content::WebContents::CreateParams create_params(builder->browser_context_, | 126 content::WebContents::CreateParams create_params(builder->browser_context_, |
| 114 nullptr); | 127 nullptr); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 HeadlessWebContents::Builder::MojoService::MojoService() {} | 312 HeadlessWebContents::Builder::MojoService::MojoService() {} |
| 300 | 313 |
| 301 HeadlessWebContents::Builder::MojoService::MojoService( | 314 HeadlessWebContents::Builder::MojoService::MojoService( |
| 302 const std::string& service_name, | 315 const std::string& service_name, |
| 303 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 316 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
| 304 : service_name(service_name), service_factory(service_factory) {} | 317 : service_name(service_name), service_factory(service_factory) {} |
| 305 | 318 |
| 306 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 319 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
| 307 | 320 |
| 308 } // namespace headless | 321 } // namespace headless |
| OLD | NEW |