| 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 <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 CommitPending(); | 426 CommitPending(); |
| 427 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); | 427 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); |
| 428 | 428 |
| 429 if (web_contents() && web_contents()->GetCrashedStatus() != | 429 if (web_contents() && web_contents()->GetCrashedStatus() != |
| 430 base::TERMINATION_STATUS_STILL_RUNNING) { | 430 base::TERMINATION_STATUS_STILL_RUNNING) { |
| 431 current_frame_crashed_ = true; | 431 current_frame_crashed_ = true; |
| 432 } | 432 } |
| 433 | 433 |
| 434 g_instances.Get().push_back(this); | 434 g_instances.Get().push_back(this); |
| 435 AddRef(); // Balanced in RenderFrameHostDestroyed. | 435 AddRef(); // Balanced in RenderFrameHostDestroyed. |
| 436 DevToolsManager::GetInstance()->AgentHostCreated(this); |
| 436 } | 437 } |
| 437 | 438 |
| 438 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { | 439 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { |
| 439 DCHECK(!pending_); | 440 DCHECK(!pending_); |
| 440 current_frame_crashed_ = false; | 441 current_frame_crashed_ = false; |
| 441 pending_.reset(new FrameHostHolder(this, host)); | 442 pending_.reset(new FrameHostHolder(this, host)); |
| 442 if (IsAttached()) | 443 if (IsAttached()) |
| 443 pending_->Reattach(current_.get()); | 444 pending_->Reattach(current_.get()); |
| 444 | 445 |
| 445 // Can only be null in constructor. | 446 // Can only be null in constructor. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // extensions::ProcessManager no longer relies on this notification. | 559 // extensions::ProcessManager no longer relies on this notification. |
| 559 DevToolsAgentHostImpl::NotifyCallbacks(this, false); | 560 DevToolsAgentHostImpl::NotifyCallbacks(this, false); |
| 560 } | 561 } |
| 561 | 562 |
| 562 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { | 563 RenderFrameDevToolsAgentHost::~RenderFrameDevToolsAgentHost() { |
| 563 Instances::iterator it = std::find(g_instances.Get().begin(), | 564 Instances::iterator it = std::find(g_instances.Get().begin(), |
| 564 g_instances.Get().end(), | 565 g_instances.Get().end(), |
| 565 this); | 566 this); |
| 566 if (it != g_instances.Get().end()) | 567 if (it != g_instances.Get().end()) |
| 567 g_instances.Get().erase(it); | 568 g_instances.Get().erase(it); |
| 569 DevToolsManager::GetInstance()->AgentHostDestroyed(this); |
| 568 } | 570 } |
| 569 | 571 |
| 570 void RenderFrameDevToolsAgentHost::ReadyToCommitNavigation( | 572 void RenderFrameDevToolsAgentHost::ReadyToCommitNavigation( |
| 571 NavigationHandle* navigation_handle) { | 573 NavigationHandle* navigation_handle) { |
| 572 // CommitPending may destruct |this|. | 574 // CommitPending may destruct |this|. |
| 573 scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); | 575 scoped_refptr<RenderFrameDevToolsAgentHost> protect(this); |
| 574 | 576 |
| 575 // TODO(clamy): Switch RenderFrameDevToolsAgentHost to always buffer messages | 577 // TODO(clamy): Switch RenderFrameDevToolsAgentHost to always buffer messages |
| 576 // until ReadyToCommitNavigation is called, now that it is also called in | 578 // until ReadyToCommitNavigation is called, now that it is also called in |
| 577 // non-PlzNavigate mode. | 579 // non-PlzNavigate mode. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); | 942 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); |
| 941 if (!contents) | 943 if (!contents) |
| 942 return ""; | 944 return ""; |
| 943 contents = contents->GetOuterWebContents(); | 945 contents = contents->GetOuterWebContents(); |
| 944 if (contents) | 946 if (contents) |
| 945 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); | 947 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); |
| 946 return ""; | 948 return ""; |
| 947 } | 949 } |
| 948 | 950 |
| 949 std::string RenderFrameDevToolsAgentHost::GetType() { | 951 std::string RenderFrameDevToolsAgentHost::GetType() { |
| 950 DevToolsManager* manager = DevToolsManager::GetInstance(); | 952 DevToolsManagerDelegate* manager_delegate = |
| 951 if (manager->delegate() && current_) { | 953 DevToolsManager::GetInstance()->GetDelegate(); |
| 952 std::string result = manager->delegate()->GetTargetType(current_->host()); | 954 if (manager_delegate && current_) { |
| 955 std::string result = manager_delegate->GetTargetType(current_->host()); |
| 953 if (!result.empty()) | 956 if (!result.empty()) |
| 954 return result; | 957 return result; |
| 955 } | 958 } |
| 956 if (IsChildFrame()) | 959 if (IsChildFrame()) |
| 957 return kTypeFrame; | 960 return kTypeFrame; |
| 958 return kTypePage; | 961 return kTypePage; |
| 959 } | 962 } |
| 960 | 963 |
| 961 std::string RenderFrameDevToolsAgentHost::GetTitle() { | 964 std::string RenderFrameDevToolsAgentHost::GetTitle() { |
| 962 DevToolsManager* manager = DevToolsManager::GetInstance(); | 965 DevToolsManagerDelegate* manager_delegate = |
| 963 if (manager->delegate() && current_) { | 966 DevToolsManager::GetInstance()->GetDelegate(); |
| 964 std::string result = manager->delegate()->GetTargetTitle(current_->host()); | 967 if (manager_delegate && current_) { |
| 968 std::string result = manager_delegate->GetTargetTitle(current_->host()); |
| 965 if (!result.empty()) | 969 if (!result.empty()) |
| 966 return result; | 970 return result; |
| 967 } | 971 } |
| 968 content::WebContents* web_contents = GetWebContents(); | 972 content::WebContents* web_contents = GetWebContents(); |
| 969 if (web_contents) | 973 if (web_contents) |
| 970 return base::UTF16ToUTF8(web_contents->GetTitle()); | 974 return base::UTF16ToUTF8(web_contents->GetTitle()); |
| 971 return GetURL().spec(); | 975 return GetURL().spec(); |
| 972 } | 976 } |
| 973 | 977 |
| 974 std::string RenderFrameDevToolsAgentHost::GetDescription() { | 978 std::string RenderFrameDevToolsAgentHost::GetDescription() { |
| 975 DevToolsManager* manager = DevToolsManager::GetInstance(); | 979 DevToolsManagerDelegate* manager_delegate = |
| 976 if (manager->delegate() && current_) | 980 DevToolsManager::GetInstance()->GetDelegate(); |
| 977 return manager->delegate()->GetTargetDescription(current_->host()); | 981 if (manager_delegate && current_) |
| 982 return manager_delegate->GetTargetDescription(current_->host()); |
| 978 return ""; | 983 return ""; |
| 979 } | 984 } |
| 980 | 985 |
| 981 GURL RenderFrameDevToolsAgentHost::GetURL() { | 986 GURL RenderFrameDevToolsAgentHost::GetURL() { |
| 982 // Order is important here. | 987 // Order is important here. |
| 983 WebContents* web_contents = GetWebContents(); | 988 WebContents* web_contents = GetWebContents(); |
| 984 if (web_contents && !IsChildFrame()) | 989 if (web_contents && !IsChildFrame()) |
| 985 return web_contents->GetVisibleURL(); | 990 return web_contents->GetVisibleURL(); |
| 986 if (pending_) | 991 if (pending_) |
| 987 return pending_->host()->GetLastCommittedURL(); | 992 return pending_->host()->GetLastCommittedURL(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 RenderFrameHost* host) { | 1099 RenderFrameHost* host) { |
| 1095 return (current_ && current_->host() == host) || | 1100 return (current_ && current_->host() == host) || |
| 1096 (pending_ && pending_->host() == host); | 1101 (pending_ && pending_->host() == host); |
| 1097 } | 1102 } |
| 1098 | 1103 |
| 1099 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1104 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1100 return current_ && current_->host()->GetParent(); | 1105 return current_ && current_->host()->GetParent(); |
| 1101 } | 1106 } |
| 1102 | 1107 |
| 1103 } // namespace content | 1108 } // namespace content |
| OLD | NEW |