| 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 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); | 456 WebContentsObserver::Observe(WebContents::FromRenderFrameHost(host)); |
| 457 | 457 |
| 458 if (web_contents() && web_contents()->GetCrashedStatus() != | 458 if (web_contents() && web_contents()->GetCrashedStatus() != |
| 459 base::TERMINATION_STATUS_STILL_RUNNING) { | 459 base::TERMINATION_STATUS_STILL_RUNNING) { |
| 460 current_frame_crashed_ = true; | 460 current_frame_crashed_ = true; |
| 461 } | 461 } |
| 462 | 462 |
| 463 g_instances.Get().push_back(this); | 463 g_instances.Get().push_back(this); |
| 464 AddRef(); // Balanced in RenderFrameHostDestroyed. | 464 AddRef(); // Balanced in RenderFrameHostDestroyed. |
| 465 | 465 |
| 466 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 467 if (manager->delegate()) { | |
| 468 type_ = manager->delegate()->GetTargetType(host); | |
| 469 title_ = manager->delegate()->GetTargetTitle(host); | |
| 470 } | |
| 471 | |
| 472 NotifyCreated(); | 466 NotifyCreated(); |
| 473 } | 467 } |
| 474 | 468 |
| 475 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { | 469 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { |
| 476 DCHECK(!pending_); | 470 DCHECK(!pending_); |
| 477 current_frame_crashed_ = false; | 471 current_frame_crashed_ = false; |
| 478 pending_.reset(new FrameHostHolder(this, host)); | 472 pending_.reset(new FrameHostHolder(this, host)); |
| 479 if (IsAttached()) | 473 if (IsAttached()) |
| 480 pending_->Reattach(current_.get()); | 474 pending_->Reattach(current_.get()); |
| 481 | 475 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); | 1009 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); |
| 1016 if (!contents) | 1010 if (!contents) |
| 1017 return ""; | 1011 return ""; |
| 1018 contents = contents->GetOuterWebContents(); | 1012 contents = contents->GetOuterWebContents(); |
| 1019 if (contents) | 1013 if (contents) |
| 1020 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); | 1014 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); |
| 1021 return ""; | 1015 return ""; |
| 1022 } | 1016 } |
| 1023 | 1017 |
| 1024 std::string RenderFrameDevToolsAgentHost::GetType() { | 1018 std::string RenderFrameDevToolsAgentHost::GetType() { |
| 1025 if (!type_.empty()) | 1019 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 1026 return type_; | 1020 if (manager->delegate() && current_) { |
| 1021 std::string type = manager->delegate()->GetTargetType(current_->host()); |
| 1022 if (!type.empty()) |
| 1023 return type; |
| 1024 } |
| 1025 |
| 1027 if (IsChildFrame()) | 1026 if (IsChildFrame()) |
| 1028 return kTypeFrame; | 1027 return kTypeFrame; |
| 1029 return kTypePage; | 1028 return kTypePage; |
| 1030 } | 1029 } |
| 1031 | 1030 |
| 1032 std::string RenderFrameDevToolsAgentHost::GetTitle() { | 1031 std::string RenderFrameDevToolsAgentHost::GetTitle() { |
| 1033 if (!title_.empty()) | 1032 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 1034 return title_; | 1033 if (manager->delegate() && current_) { |
| 1034 std::string title = manager->delegate()->GetTargetTitle(current_->host()); |
| 1035 if (!title.empty()) |
| 1036 return title; |
| 1037 } |
| 1038 |
| 1035 if (current_ && current_->host()->GetParent()) | 1039 if (current_ && current_->host()->GetParent()) |
| 1036 return current_->host()->GetLastCommittedURL().spec(); | 1040 return current_->host()->GetLastCommittedURL().spec(); |
| 1037 content::WebContents* web_contents = GetWebContents(); | 1041 content::WebContents* web_contents = GetWebContents(); |
| 1038 if (web_contents) | 1042 if (web_contents) |
| 1039 return base::UTF16ToUTF8(web_contents->GetTitle()); | 1043 return base::UTF16ToUTF8(web_contents->GetTitle()); |
| 1040 return GetURL().spec(); | 1044 return GetURL().spec(); |
| 1041 } | 1045 } |
| 1042 | 1046 |
| 1043 std::string RenderFrameDevToolsAgentHost::GetDescription() { | 1047 std::string RenderFrameDevToolsAgentHost::GetDescription() { |
| 1044 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1048 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 RenderFrameHost* host) { | 1172 RenderFrameHost* host) { |
| 1169 return (current_ && current_->host() == host) || | 1173 return (current_ && current_->host() == host) || |
| 1170 (pending_ && pending_->host() == host); | 1174 (pending_ && pending_->host() == host); |
| 1171 } | 1175 } |
| 1172 | 1176 |
| 1173 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1177 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1174 return current_ && current_->host()->GetParent(); | 1178 return current_ && current_->host()->GetParent(); |
| 1175 } | 1179 } |
| 1176 | 1180 |
| 1177 } // namespace content | 1181 } // namespace content |
| OLD | NEW |