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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 | 209 |
| 210 service_manager::InterfaceRegistry* interface_registry = | 210 service_manager::InterfaceRegistry* interface_registry = |
| 211 render_frame_host->GetInterfaceRegistry(); | 211 render_frame_host->GetInterfaceRegistry(); |
| 212 | 212 |
| 213 for (const MojoService& service : mojo_services_) { | 213 for (const MojoService& service : mojo_services_) { |
| 214 interface_registry->AddInterface(service.service_name, | 214 interface_registry->AddInterface(service.service_name, |
| 215 service.service_factory, | 215 service.service_factory, |
| 216 browser()->BrowserMainThread()); | 216 browser()->BrowserMainThread()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 browser_context_->SetFrameTreeNodeId(render_frame_host->GetProcess()->GetID(), | |
| 220 render_frame_host->GetRoutingID(), | |
| 221 render_frame_host->GetFrameTreeNodeId()); | |
| 222 | |
| 223 void RemoveFrameTreeNode(int render_process_id, int render_frame_id); | |
|
Sami
2017/04/26 16:21:17
Probably did not mean to have this here?
alex clarke (OOO till 29th)
2017/04/27 08:49:44
Done.
| |
| 224 | |
| 219 std::string devtools_agent_host_id = | 225 std::string devtools_agent_host_id = |
| 220 content::DevToolsAgentHost::GetOrCreateFor(render_frame_host)->GetId(); | 226 content::DevToolsAgentHost::GetOrCreateFor(render_frame_host)->GetId(); |
| 221 render_frame_host_to_devtools_agent_host_id_[render_frame_host] = | 227 render_frame_host_to_devtools_agent_host_id_[render_frame_host] = |
| 222 devtools_agent_host_id; | 228 devtools_agent_host_id; |
| 223 devtools_agent_id_to_frame_tree_node_id_[devtools_agent_host_id] = | 229 devtools_agent_id_to_frame_tree_node_id_[devtools_agent_host_id] = |
| 224 render_frame_host->GetFrameTreeNodeId(); | 230 render_frame_host->GetFrameTreeNodeId(); |
| 225 } | 231 } |
| 226 | 232 |
| 227 void HeadlessWebContentsImpl::RenderFrameDeleted( | 233 void HeadlessWebContentsImpl::RenderFrameDeleted( |
| 228 content::RenderFrameHost* render_frame_host) { | 234 content::RenderFrameHost* render_frame_host) { |
| 235 browser_context_->RemoveFrameTreeNode( | |
| 236 render_frame_host->GetProcess()->GetID(), | |
| 237 render_frame_host->GetRoutingID()); | |
| 238 | |
| 229 auto find_it = | 239 auto find_it = |
| 230 render_frame_host_to_devtools_agent_host_id_.find(render_frame_host); | 240 render_frame_host_to_devtools_agent_host_id_.find(render_frame_host); |
| 231 if (find_it == render_frame_host_to_devtools_agent_host_id_.end()) | 241 if (find_it == render_frame_host_to_devtools_agent_host_id_.end()) |
| 232 return; | 242 return; |
| 233 | 243 |
| 234 devtools_agent_id_to_frame_tree_node_id_.erase(find_it->second); | 244 devtools_agent_id_to_frame_tree_node_id_.erase(find_it->second); |
| 235 render_frame_host_to_devtools_agent_host_id_.erase(find_it); | 245 render_frame_host_to_devtools_agent_host_id_.erase(find_it); |
| 236 } | 246 } |
| 237 | 247 |
| 238 bool HeadlessWebContentsImpl::GetFrameTreeNodeIdForDevToolsAgentHostId( | 248 bool HeadlessWebContentsImpl::GetFrameTreeNodeIdForDevToolsAgentHostId( |
| 239 const std::string& devtools_agent_host_id, | 249 const std::string& devtools_agent_host_id, |
| 240 int* frame_tree_node_id) const { | 250 int* frame_tree_node_id) const { |
| 241 const auto& find_it = | 251 const auto& find_it = |
| 242 devtools_agent_id_to_frame_tree_node_id_.find(devtools_agent_host_id); | 252 devtools_agent_id_to_frame_tree_node_id_.find(devtools_agent_host_id); |
| 243 if (find_it == devtools_agent_id_to_frame_tree_node_id_.end()) | 253 if (find_it == devtools_agent_id_to_frame_tree_node_id_.end()) |
| 244 return false; | 254 return false; |
| 245 *frame_tree_node_id = find_it->second; | 255 *frame_tree_node_id = find_it->second; |
| 246 return true; | 256 return true; |
| 247 } | 257 } |
| 248 | 258 |
| 259 std::string | |
| 260 HeadlessWebContentsImpl::GetUntrustedDevToolsFrameIdForFrameTreeNodeId( | |
| 261 int process_id, | |
| 262 int frame_tree_node_id) const { | |
| 263 return content::DevToolsAgentHost:: | |
| 264 GetUntrustedDevToolsFrameIdForFrameTreeNodeId(process_id, | |
| 265 frame_tree_node_id); | |
| 266 } | |
| 267 | |
| 268 int HeadlessWebContentsImpl::GetRenderProcessId() const { | |
| 269 return web_contents()->GetRenderProcessHost()->GetID(); | |
| 270 } | |
| 271 | |
| 249 bool HeadlessWebContentsImpl::OpenURL(const GURL& url) { | 272 bool HeadlessWebContentsImpl::OpenURL(const GURL& url) { |
| 250 if (!url.is_valid()) | 273 if (!url.is_valid()) |
| 251 return false; | 274 return false; |
| 252 content::NavigationController::LoadURLParams params(url); | 275 content::NavigationController::LoadURLParams params(url); |
| 253 params.transition_type = ui::PageTransitionFromInt( | 276 params.transition_type = ui::PageTransitionFromInt( |
| 254 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); | 277 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); |
| 255 web_contents_->GetController().LoadURLWithParams(params); | 278 web_contents_->GetController().LoadURLWithParams(params); |
| 256 web_contents_delegate_->ActivateContents(web_contents_.get()); | 279 web_contents_delegate_->ActivateContents(web_contents_.get()); |
| 257 web_contents_->Focus(); | 280 web_contents_->Focus(); |
| 258 return true; | 281 return true; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 392 HeadlessWebContents::Builder::MojoService::MojoService() {} | 415 HeadlessWebContents::Builder::MojoService::MojoService() {} |
| 393 | 416 |
| 394 HeadlessWebContents::Builder::MojoService::MojoService( | 417 HeadlessWebContents::Builder::MojoService::MojoService( |
| 395 const std::string& service_name, | 418 const std::string& service_name, |
| 396 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) | 419 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) |
| 397 : service_name(service_name), service_factory(service_factory) {} | 420 : service_name(service_name), service_factory(service_factory) {} |
| 398 | 421 |
| 399 HeadlessWebContents::Builder::MojoService::~MojoService() {} | 422 HeadlessWebContents::Builder::MojoService::~MojoService() {} |
| 400 | 423 |
| 401 } // namespace headless | 424 } // namespace headless |
| OLD | NEW |