Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: headless/lib/browser/headless_web_contents_impl.cc

Issue 2733293004: Override CloseContents in HeadlessWebContentsImpl Delegate so that the json/close endpoint works wi… (Closed)
Patch Set: Fixed a nullptr issue Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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*> all_contents =
107 browser_context_->GetAllWebContents();
108
109 for (HeadlessWebContents* wc : all_contents) {
110 if (wc == nullptr) {
Sami 2017/03/13 12:40:28 nit: You can just do "if (!wc)"
111 continue;
112 }
113 HeadlessWebContentsImpl* hwc = HeadlessWebContentsImpl::From(wc);
114 if (hwc->web_contents() == source) {
115 wc->Close();
116 return;
117 }
118 }
119 }
120
105 private: 121 private:
106 HeadlessBrowserContextImpl* browser_context_; // Not owned. 122 HeadlessBrowserContextImpl* browser_context_; // Not owned.
107 DISALLOW_COPY_AND_ASSIGN(Delegate); 123 DISALLOW_COPY_AND_ASSIGN(Delegate);
108 }; 124 };
109 125
110 // static 126 // static
111 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create( 127 std::unique_ptr<HeadlessWebContentsImpl> HeadlessWebContentsImpl::Create(
112 HeadlessWebContents::Builder* builder) { 128 HeadlessWebContents::Builder* builder) {
113 content::WebContents::CreateParams create_params(builder->browser_context_, 129 content::WebContents::CreateParams create_params(builder->browser_context_,
114 nullptr); 130 nullptr);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 HeadlessWebContents::Builder::MojoService::MojoService() {} 315 HeadlessWebContents::Builder::MojoService::MojoService() {}
300 316
301 HeadlessWebContents::Builder::MojoService::MojoService( 317 HeadlessWebContents::Builder::MojoService::MojoService(
302 const std::string& service_name, 318 const std::string& service_name,
303 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) 319 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory)
304 : service_name(service_name), service_factory(service_factory) {} 320 : service_name(service_name), service_factory(service_factory) {}
305 321
306 HeadlessWebContents::Builder::MojoService::~MojoService() {} 322 HeadlessWebContents::Builder::MojoService::~MojoService() {}
307 323
308 } // namespace headless 324 } // namespace headless
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698