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 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 service_manager::InterfaceRegistry* interface_registry = | 208 service_manager::InterfaceRegistry* interface_registry = |
209 render_frame_host->GetInterfaceRegistry(); | 209 render_frame_host->GetInterfaceRegistry(); |
210 | 210 |
211 for (const MojoService& service : mojo_services_) { | 211 for (const MojoService& service : mojo_services_) { |
212 interface_registry->AddInterface(service.service_name, | 212 interface_registry->AddInterface(service.service_name, |
213 service.service_factory, | 213 service.service_factory, |
214 browser()->BrowserMainThread()); | 214 browser()->BrowserMainThread()); |
215 } | 215 } |
| 216 |
| 217 std::string devtools_agent_host_id = |
| 218 content::DevToolsAgentHost::GetOrCreateFor(render_frame_host)->GetId(); |
| 219 render_frame_host_to_devtools_agent_host_id_[render_frame_host] = |
| 220 devtools_agent_host_id; |
| 221 devtools_agent_id_to_frame_tree_node_id_[devtools_agent_host_id] = |
| 222 render_frame_host->GetFrameTreeNodeId(); |
| 223 } |
| 224 |
| 225 void HeadlessWebContentsImpl::RenderFrameDeleted( |
| 226 content::RenderFrameHost* render_frame_host) { |
| 227 auto find_it = |
| 228 render_frame_host_to_devtools_agent_host_id_.find(render_frame_host); |
| 229 if (find_it == render_frame_host_to_devtools_agent_host_id_.end()) |
| 230 return; |
| 231 |
| 232 devtools_agent_id_to_frame_tree_node_id_.erase(find_it->second); |
| 233 render_frame_host_to_devtools_agent_host_id_.erase(find_it); |
| 234 } |
| 235 |
| 236 bool HeadlessWebContentsImpl::GetFrameTreeNodeIdForDevToolsAgentHostId( |
| 237 const std::string& devtools_agent_host_id, |
| 238 int* frame_tree_node_id) const { |
| 239 const auto& find_it = |
| 240 devtools_agent_id_to_frame_tree_node_id_.find(devtools_agent_host_id); |
| 241 if (find_it == devtools_agent_id_to_frame_tree_node_id_.end()) |
| 242 return false; |
| 243 *frame_tree_node_id = find_it->second; |
| 244 return true; |
216 } | 245 } |
217 | 246 |
218 bool HeadlessWebContentsImpl::OpenURL(const GURL& url) { | 247 bool HeadlessWebContentsImpl::OpenURL(const GURL& url) { |
219 if (!url.is_valid()) | 248 if (!url.is_valid()) |
220 return false; | 249 return false; |
221 content::NavigationController::LoadURLParams params(url); | 250 content::NavigationController::LoadURLParams params(url); |
222 params.transition_type = ui::PageTransitionFromInt( | 251 params.transition_type = ui::PageTransitionFromInt( |
223 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 252 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
224 web_contents_->GetController().LoadURLWithParams(params); | 253 web_contents_->GetController().LoadURLWithParams(params); |
225 web_contents_delegate_->ActivateContents(web_contents_.get()); | 254 web_contents_delegate_->ActivateContents(web_contents_.get()); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 HeadlessWebContents::Builder::MojoService::MojoService() {} | 376 HeadlessWebContents::Builder::MojoService::MojoService() {} |
348 | 377 |
349 HeadlessWebContents::Builder::MojoService::MojoService( | 378 HeadlessWebContents::Builder::MojoService::MojoService( |
350 const std::string& service_name, | 379 const std::string& service_name, |
351 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 380 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
352 : service_name(service_name), service_factory(service_factory) {} | 381 : service_name(service_name), service_factory(service_factory) {} |
353 | 382 |
354 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 383 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
355 | 384 |
356 } // namespace headless | 385 } // namespace headless |
OLD | NEW |