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

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

Issue 2896763002: Implement window management devtools commands for headless. (Closed)
Patch Set: nit and rebase Created 3 years, 7 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
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_browser_impl.h" 5 #include "headless/lib/browser/headless_browser_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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 const std::string& devtools_agent_host_id) { 193 const std::string& devtools_agent_host_id) {
194 for (HeadlessBrowserContext* context : GetAllBrowserContexts()) { 194 for (HeadlessBrowserContext* context : GetAllBrowserContexts()) {
195 HeadlessWebContents* web_contents = 195 HeadlessWebContents* web_contents =
196 context->GetWebContentsForDevToolsAgentHostId(devtools_agent_host_id); 196 context->GetWebContentsForDevToolsAgentHostId(devtools_agent_host_id);
197 if (web_contents) 197 if (web_contents)
198 return web_contents; 198 return web_contents;
199 } 199 }
200 return nullptr; 200 return nullptr;
201 } 201 }
202 202
203 HeadlessWebContentsImpl* HeadlessBrowserImpl::GetWebContentsForWindowId(
204 const int window_id) {
205 for (HeadlessBrowserContext* context : GetAllBrowserContexts()) {
206 for (HeadlessWebContents* web_contents : context->GetAllWebContents()) {
207 auto* contents = HeadlessWebContentsImpl::From(web_contents);
208 if (contents->window_id() == window_id) {
209 return contents;
210 }
211 }
212 }
213 return nullptr;
214 }
215
203 HeadlessBrowserContext* HeadlessBrowserImpl::GetBrowserContextForId( 216 HeadlessBrowserContext* HeadlessBrowserImpl::GetBrowserContextForId(
204 const std::string& id) { 217 const std::string& id) {
205 auto find_it = browser_contexts_.find(id); 218 auto find_it = browser_contexts_.find(id);
206 if (find_it == browser_contexts_.end()) 219 if (find_it == browser_contexts_.end())
207 return nullptr; 220 return nullptr;
208 return find_it->second.get(); 221 return find_it->second.get();
209 } 222 }
210 223
211 HeadlessDevToolsTarget* HeadlessBrowserImpl::GetDevToolsTarget() { 224 HeadlessDevToolsTarget* HeadlessBrowserImpl::GetDevToolsTarget() {
212 return agent_host_ ? this : nullptr; 225 return agent_host_ ? this : nullptr;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 287
275 // Child processes should not end up here. 288 // Child processes should not end up here.
276 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( 289 DCHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch(
277 ::switches::kProcessType)); 290 ::switches::kProcessType));
278 #endif 291 #endif
279 return RunContentMain(std::move(options), 292 return RunContentMain(std::move(options),
280 std::move(on_browser_start_callback)); 293 std::move(on_browser_start_callback));
281 } 294 }
282 295
283 } // namespace headless 296 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_browser_impl.h ('k') | headless/lib/browser/headless_devtools_client_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698