| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/devtools/render_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 RenderFrameHost* current) { | 282 RenderFrameHost* current) { |
| 283 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(pending); | 283 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(pending); |
| 284 if (!agent_host) | 284 if (!agent_host) |
| 285 return; | 285 return; |
| 286 if (agent_host->pending_ && agent_host->pending_->host() == pending) { | 286 if (agent_host->pending_ && agent_host->pending_->host() == pending) { |
| 287 DCHECK(agent_host->current_ && agent_host->current_->host() == current); | 287 DCHECK(agent_host->current_ && agent_host->current_->host() == current); |
| 288 agent_host->DiscardPending(); | 288 agent_host->DiscardPending(); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 | 291 |
| 292 // static |
| 293 void RenderFrameDevToolsAgentHost::OnBeforeNavigation( |
| 294 RenderFrameHost* current, RenderFrameHost* pending) { |
| 295 RenderFrameDevToolsAgentHost* agent_host = FindAgentHost(current); |
| 296 if (agent_host) |
| 297 agent_host->AboutToNavigateRenderFrame(current, pending); |
| 298 } |
| 299 |
| 292 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( | 300 RenderFrameDevToolsAgentHost::RenderFrameDevToolsAgentHost( |
| 293 RenderFrameHostImpl* host) | 301 RenderFrameHostImpl* host) |
| 294 : dom_handler_(new devtools::dom::DOMHandler()), | 302 : dom_handler_(new devtools::dom::DOMHandler()), |
| 295 input_handler_(new devtools::input::InputHandler()), | 303 input_handler_(new devtools::input::InputHandler()), |
| 296 inspector_handler_(new devtools::inspector::InspectorHandler()), | 304 inspector_handler_(new devtools::inspector::InspectorHandler()), |
| 297 io_handler_(new devtools::io::IOHandler(GetIOContext())), | 305 io_handler_(new devtools::io::IOHandler(GetIOContext())), |
| 298 network_handler_(new devtools::network::NetworkHandler()), | 306 network_handler_(new devtools::network::NetworkHandler()), |
| 299 page_handler_(nullptr), | 307 page_handler_(nullptr), |
| 300 power_handler_(new devtools::power::PowerHandler()), | 308 power_handler_(new devtools::power::PowerHandler()), |
| 301 security_handler_(nullptr), | 309 security_handler_(nullptr), |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 468 } |
| 461 | 469 |
| 462 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 470 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { |
| 463 Instances::iterator it = std::find(g_instances.Get().begin(), | 471 Instances::iterator it = std::find(g_instances.Get().begin(), |
| 464 g_instances.Get().end(), | 472 g_instances.Get().end(), |
| 465 this); | 473 this); |
| 466 if (it != g_instances.Get().end()) | 474 if (it != g_instances.Get().end()) |
| 467 g_instances.Get().erase(it); | 475 g_instances.Get().erase(it); |
| 468 } | 476 } |
| 469 | 477 |
| 470 // TODO(creis): Consider removing this in favor of RenderFrameHostChanged. | |
| 471 void RenderFrameDevToolsAgentHost::AboutToNavigateRenderFrame( | 478 void RenderFrameDevToolsAgentHost::AboutToNavigateRenderFrame( |
| 472 RenderFrameHost* old_host, | 479 RenderFrameHost* old_host, |
| 473 RenderFrameHost* new_host) { | 480 RenderFrameHost* new_host) { |
| 474 DCHECK(!pending_ || pending_->host() != old_host); | 481 DCHECK(!pending_ || pending_->host() != old_host); |
| 475 if (!current_ || current_->host() != old_host) | 482 if (!current_ || current_->host() != old_host) |
| 476 return; | 483 return; |
| 477 if (old_host == new_host && !current_frame_crashed_) | 484 if (old_host == new_host && !current_frame_crashed_) |
| 478 return; | 485 return; |
| 479 DCHECK(!pending_); | 486 DCHECK(!pending_); |
| 480 SetPending(static_cast<RenderFrameHostImpl*>(new_host)); | 487 SetPending(static_cast<RenderFrameHostImpl*>(new_host)); |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 RenderFrameHost* host) { | 730 RenderFrameHost* host) { |
| 724 return (current_ && current_->host() == host) || | 731 return (current_ && current_->host() == host) || |
| 725 (pending_ && pending_->host() == host); | 732 (pending_ && pending_->host() == host); |
| 726 } | 733 } |
| 727 | 734 |
| 728 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 735 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 729 return current_ && current_->host()->GetParent(); | 736 return current_ && current_->host()->GetParent(); |
| 730 } | 737 } |
| 731 | 738 |
| 732 } // namespace content | 739 } // namespace content |
| OLD | NEW |