| 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_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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |