Chromium Code Reviews| 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 CommitPending(); | 455 CommitPending(); |
| 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 | |
| 466 DevToolsManager* manager = DevToolsManager::GetInstance(); | |
| 467 if (manager->delegate()) { | |
| 468 type_ = manager->delegate()->GetTargetType(host); | |
| 469 title_ = manager->delegate()->GetTargetTitle(host); | |
|
pfeldman
2017/04/07 18:31:03
meh
| |
| 470 } | |
| 471 | |
| 465 NotifyCreated(); | 472 NotifyCreated(); |
| 466 } | 473 } |
| 467 | 474 |
| 468 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { | 475 void RenderFrameDevToolsAgentHost::SetPending(RenderFrameHostImpl* host) { |
| 469 DCHECK(!pending_); | 476 DCHECK(!pending_); |
| 470 current_frame_crashed_ = false; | 477 current_frame_crashed_ = false; |
| 471 pending_.reset(new FrameHostHolder(this, host)); | 478 pending_.reset(new FrameHostHolder(this, host)); |
| 472 if (IsAttached()) | 479 if (IsAttached()) |
| 473 pending_->Reattach(current_.get()); | 480 pending_->Reattach(current_.get()); |
| 474 | 481 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1008 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); | 1015 WebContentsImpl* contents = static_cast<WebContentsImpl*>(web_contents()); |
| 1009 if (!contents) | 1016 if (!contents) |
| 1010 return ""; | 1017 return ""; |
| 1011 contents = contents->GetOuterWebContents(); | 1018 contents = contents->GetOuterWebContents(); |
| 1012 if (contents) | 1019 if (contents) |
| 1013 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); | 1020 return DevToolsAgentHost::GetOrCreateFor(contents)->GetId(); |
| 1014 return ""; | 1021 return ""; |
| 1015 } | 1022 } |
| 1016 | 1023 |
| 1017 std::string RenderFrameDevToolsAgentHost::GetType() { | 1024 std::string RenderFrameDevToolsAgentHost::GetType() { |
| 1018 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1025 if (!type_.empty()) |
| 1019 if (manager->delegate() && current_) { | 1026 return type_; |
| 1020 std::string result = manager->delegate()->GetTargetType(current_->host()); | |
| 1021 if (!result.empty()) | |
| 1022 return result; | |
| 1023 } | |
| 1024 if (IsChildFrame()) | 1027 if (IsChildFrame()) |
| 1025 return kTypeFrame; | 1028 return kTypeFrame; |
| 1026 return kTypePage; | 1029 return kTypePage; |
| 1027 } | 1030 } |
| 1028 | 1031 |
| 1029 std::string RenderFrameDevToolsAgentHost::GetTitle() { | 1032 std::string RenderFrameDevToolsAgentHost::GetTitle() { |
| 1030 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1033 if (!title_.empty()) |
| 1031 if (manager->delegate() && current_) { | 1034 return title_; |
| 1032 std::string result = manager->delegate()->GetTargetTitle(current_->host()); | 1035 if (current_ && current_->host()->GetParent()) |
| 1033 if (!result.empty()) | 1036 return current_->host()->GetLastCommittedURL().spec(); |
| 1034 return result; | |
| 1035 } | |
| 1036 content::WebContents* web_contents = GetWebContents(); | 1037 content::WebContents* web_contents = GetWebContents(); |
| 1037 if (web_contents) | 1038 if (web_contents) |
| 1038 return base::UTF16ToUTF8(web_contents->GetTitle()); | 1039 return base::UTF16ToUTF8(web_contents->GetTitle()); |
| 1039 return GetURL().spec(); | 1040 return GetURL().spec(); |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 std::string RenderFrameDevToolsAgentHost::GetDescription() { | 1043 std::string RenderFrameDevToolsAgentHost::GetDescription() { |
| 1043 DevToolsManager* manager = DevToolsManager::GetInstance(); | 1044 DevToolsManager* manager = DevToolsManager::GetInstance(); |
| 1044 if (manager->delegate() && current_) | 1045 if (manager->delegate() && current_) |
| 1045 return manager->delegate()->GetTargetDescription(current_->host()); | 1046 return manager->delegate()->GetTargetDescription(current_->host()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 RenderFrameHost* host) { | 1168 RenderFrameHost* host) { |
| 1168 return (current_ && current_->host() == host) || | 1169 return (current_ && current_->host() == host) || |
| 1169 (pending_ && pending_->host() == host); | 1170 (pending_ && pending_->host() == host); |
| 1170 } | 1171 } |
| 1171 | 1172 |
| 1172 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 1173 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 1173 return current_ && current_->host()->GetParent(); | 1174 return current_ && current_->host()->GetParent(); |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 } // namespace content | 1177 } // namespace content |
| OLD | NEW |