Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: content/shell/browser/shell_devtools_bindings.cc

Issue 2837083003: DevTools: create test infrastructure so devtools drives the test (Closed)
Patch Set: fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/shell/browser/shell_devtools_bindings.h" 5 #include "content/shell/browser/shell_devtools_bindings.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 for (const auto& pair : pending_requests_) 130 for (const auto& pair : pending_requests_)
131 delete pair.first; 131 delete pair.first;
132 if (agent_host_) 132 if (agent_host_)
133 agent_host_->DetachClient(this); 133 agent_host_->DetachClient(this);
134 } 134 }
135 135
136 void ShellDevToolsBindings::ReadyToCommitNavigation( 136 void ShellDevToolsBindings::ReadyToCommitNavigation(
137 NavigationHandle* navigation_handle) { 137 NavigationHandle* navigation_handle) {
138 #if !defined(OS_ANDROID) 138 #if !defined(OS_ANDROID)
139 content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost(); 139 content::RenderFrameHost* frame = navigation_handle->GetRenderFrameHost();
140 if (navigation_handle->IsInMainFrame()) {
141 CreateFrontendHost(frame);
142 }
140 if (!frame->GetParent()) 143 if (!frame->GetParent())
dgozman 2017/06/15 21:16:48 This is the same check as previous if - combine th
chenwilliam 2017/06/19 18:33:29 Done.
141 return; 144 return;
142 std::string origin = navigation_handle->GetURL().GetOrigin().spec(); 145 std::string origin = navigation_handle->GetURL().GetOrigin().spec();
143 auto it = extensions_api_.find(origin); 146 auto it = extensions_api_.find(origin);
144 if (it == extensions_api_.end()) 147 if (it == extensions_api_.end())
145 return; 148 return;
146 std::string script = base::StringPrintf("%s(\"%s\")", it->second.c_str(), 149 std::string script = base::StringPrintf("%s(\"%s\")", it->second.c_str(),
147 base::GenerateGUID().c_str()); 150 base::GenerateGUID().c_str());
148 DevToolsFrontendHost::SetupExtensionsAPI(frame, script); 151 DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
149 #endif 152 #endif
150 } 153 }
151 154
152 void ShellDevToolsBindings::RenderViewCreated(
153 RenderViewHost* render_view_host) {
154 CreateFrontendHost();
155 }
156
157 #if !defined(OS_ANDROID) 155 #if !defined(OS_ANDROID)
158 void ShellDevToolsBindings::CreateFrontendHost() { 156 void ShellDevToolsBindings::CreateFrontendHost(
dgozman 2017/06/15 21:16:48 Inline it to the method above.
chenwilliam 2017/06/19 18:33:29 Done.
159 if (!frontend_host_) { 157 RenderFrameHost* render_frame_host) {
160 frontend_host_.reset(DevToolsFrontendHost::Create( 158 frontend_host_.reset(DevToolsFrontendHost::Create(
161 web_contents()->GetMainFrame(), 159 render_frame_host,
162 base::Bind(&ShellDevToolsBindings::HandleMessageFromDevToolsFrontend, 160 base::Bind(&ShellDevToolsBindings::HandleMessageFromDevToolsFrontend,
163 base::Unretained(this)))); 161 base::Unretained(this))));
164 }
165 } 162 }
166 #endif 163 #endif
167 164
168 #if defined(OS_ANDROID) 165 #if defined(OS_ANDROID)
169 void ShellDevToolsBindings::CreateFrontendHost() {} 166 void ShellDevToolsBindings::CreateFrontendHost() {}
170 #endif 167 #endif
171 168
172 void ShellDevToolsBindings::DocumentAvailableInMainFrame() { 169 void ShellDevToolsBindings::DocumentAvailableInMainFrame() {
173 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_); 170 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
174 agent_host_->AttachClient(this); 171 agent_host_->AttachClient(this);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 393 }
397 394
398 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host, 395 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host,
399 bool replaced) { 396 bool replaced) {
400 agent_host_ = nullptr; 397 agent_host_ = nullptr;
401 if (delegate_) 398 if (delegate_)
402 delegate_->Close(); 399 delegate_->Close();
403 } 400 }
404 401
405 } // namespace content 402 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698