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

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: rebaseline 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 (!frame->GetParent()) 140 if (navigation_handle->IsInMainFrame()) {
141 frontend_host_.reset(DevToolsFrontendHost::Create(
142 frame,
143 base::Bind(&ShellDevToolsBindings::HandleMessageFromDevToolsFrontend,
144 base::Unretained(this))));
141 return; 145 return;
146 }
142 std::string origin = navigation_handle->GetURL().GetOrigin().spec(); 147 std::string origin = navigation_handle->GetURL().GetOrigin().spec();
143 auto it = extensions_api_.find(origin); 148 auto it = extensions_api_.find(origin);
144 if (it == extensions_api_.end()) 149 if (it == extensions_api_.end())
145 return; 150 return;
146 std::string script = base::StringPrintf("%s(\"%s\")", it->second.c_str(), 151 std::string script = base::StringPrintf("%s(\"%s\")", it->second.c_str(),
147 base::GenerateGUID().c_str()); 152 base::GenerateGUID().c_str());
148 DevToolsFrontendHost::SetupExtensionsAPI(frame, script); 153 DevToolsFrontendHost::SetupExtensionsAPI(frame, script);
149 #endif 154 #endif
150 } 155 }
151 156
152 void ShellDevToolsBindings::RenderViewCreated(
153 RenderViewHost* render_view_host) {
154 CreateFrontendHost();
155 }
156
157 #if !defined(OS_ANDROID)
158 void ShellDevToolsBindings::CreateFrontendHost() {
159 if (!frontend_host_) {
160 frontend_host_.reset(DevToolsFrontendHost::Create(
161 web_contents()->GetMainFrame(),
162 base::Bind(&ShellDevToolsBindings::HandleMessageFromDevToolsFrontend,
163 base::Unretained(this))));
164 }
165 }
166 #endif
167
168 #if defined(OS_ANDROID)
169 void ShellDevToolsBindings::CreateFrontendHost() {}
170 #endif
171
172 void ShellDevToolsBindings::DocumentAvailableInMainFrame() { 157 void ShellDevToolsBindings::DocumentAvailableInMainFrame() {
173 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_); 158 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
174 agent_host_->AttachClient(this); 159 agent_host_->AttachClient(this);
175 if (inspect_element_at_x_ != -1) { 160 if (inspect_element_at_x_ != -1) {
176 agent_host_->InspectElement(this, inspect_element_at_x_, 161 agent_host_->InspectElement(this, inspect_element_at_x_,
177 inspect_element_at_y_); 162 inspect_element_at_y_);
178 inspect_element_at_x_ = -1; 163 inspect_element_at_x_ = -1;
179 inspect_element_at_y_ = -1; 164 inspect_element_at_y_ = -1;
180 } 165 }
181 } 166 }
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 } 381 }
397 382
398 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host, 383 void ShellDevToolsBindings::AgentHostClosed(DevToolsAgentHost* agent_host,
399 bool replaced) { 384 bool replaced) {
400 agent_host_ = nullptr; 385 agent_host_ = nullptr;
401 if (delegate_) 386 if (delegate_)
402 delegate_->Close(); 387 delegate_->Close();
403 } 388 }
404 389
405 } // namespace content 390 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_bindings.h ('k') | content/shell/test_runner/test_interfaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698