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

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

Issue 2161493002: [DevTools] Pass client initiating DevToolsAgentHost::inspectElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 5 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_frontend.h" 5 #include "content/shell/browser/shell_devtools_frontend.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void ShellDevToolsFrontend::Activate() { 126 void ShellDevToolsFrontend::Activate() {
127 frontend_shell_->ActivateContents(web_contents()); 127 frontend_shell_->ActivateContents(web_contents());
128 } 128 }
129 129
130 void ShellDevToolsFrontend::Focus() { 130 void ShellDevToolsFrontend::Focus() {
131 web_contents()->Focus(); 131 web_contents()->Focus();
132 } 132 }
133 133
134 void ShellDevToolsFrontend::InspectElementAt(int x, int y) { 134 void ShellDevToolsFrontend::InspectElementAt(int x, int y) {
135 if (agent_host_) 135 if (agent_host_) {
136 agent_host_->InspectElement(x, y); 136 agent_host_->InspectElement(this, x, y);
137 } else {
138 inspect_element_at_x_ = x;
139 inspect_element_at_y_ = y;
140 }
137 } 141 }
138 142
139 void ShellDevToolsFrontend::Close() { 143 void ShellDevToolsFrontend::Close() {
140 frontend_shell_->Close(); 144 frontend_shell_->Close();
141 } 145 }
142 146
143 void ShellDevToolsFrontend::DisconnectFromTarget() { 147 void ShellDevToolsFrontend::DisconnectFromTarget() {
144 if (!agent_host_) 148 if (!agent_host_)
145 return; 149 return;
146 agent_host_->DetachClient(this); 150 agent_host_->DetachClient(this);
147 agent_host_ = NULL; 151 agent_host_ = NULL;
148 } 152 }
149 153
150 ShellDevToolsFrontend::ShellDevToolsFrontend(Shell* frontend_shell, 154 ShellDevToolsFrontend::ShellDevToolsFrontend(Shell* frontend_shell,
151 WebContents* inspected_contents) 155 WebContents* inspected_contents)
152 : WebContentsObserver(frontend_shell->web_contents()), 156 : WebContentsObserver(frontend_shell->web_contents()),
153 frontend_shell_(frontend_shell), 157 frontend_shell_(frontend_shell),
154 inspected_contents_(inspected_contents), 158 inspected_contents_(inspected_contents),
159 inspect_element_at_x_(-1),
160 inspect_element_at_y_(-1),
155 weak_factory_(this) { 161 weak_factory_(this) {
156 } 162 }
157 163
158 ShellDevToolsFrontend::~ShellDevToolsFrontend() { 164 ShellDevToolsFrontend::~ShellDevToolsFrontend() {
159 for (const auto& pair : pending_requests_) 165 for (const auto& pair : pending_requests_)
160 delete pair.first; 166 delete pair.first;
161 } 167 }
162 168
163 void ShellDevToolsFrontend::RenderViewCreated( 169 void ShellDevToolsFrontend::RenderViewCreated(
164 RenderViewHost* render_view_host) { 170 RenderViewHost* render_view_host) {
165 if (!frontend_host_) { 171 if (!frontend_host_) {
166 frontend_host_.reset(DevToolsFrontendHost::Create( 172 frontend_host_.reset(DevToolsFrontendHost::Create(
167 web_contents()->GetMainFrame(), 173 web_contents()->GetMainFrame(),
168 base::Bind(&ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend, 174 base::Bind(&ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend,
169 base::Unretained(this)))); 175 base::Unretained(this))));
170 } 176 }
171 } 177 }
172 178
173 void ShellDevToolsFrontend::DocumentAvailableInMainFrame() { 179 void ShellDevToolsFrontend::DocumentAvailableInMainFrame() {
174 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_); 180 agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents_);
175 agent_host_->AttachClient(this); 181 agent_host_->AttachClient(this);
182 if (inspect_element_at_x_ != -1) {
183 agent_host_->InspectElement(
184 this, inspect_element_at_x_, inspect_element_at_y_);
185 inspect_element_at_x_ = -1;
186 inspect_element_at_y_ = -1;
187 }
176 } 188 }
177 189
178 void ShellDevToolsFrontend::WebContentsDestroyed() { 190 void ShellDevToolsFrontend::WebContentsDestroyed() {
179 if (agent_host_) 191 if (agent_host_)
180 agent_host_->DetachClient(this); 192 agent_host_->DetachClient(this);
181 delete this; 193 delete this;
182 } 194 }
183 195
184 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( 196 void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend(
185 const std::string& message) { 197 const std::string& message) {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 CallClientFunction("DevToolsAPI.embedderMessageAck", 357 CallClientFunction("DevToolsAPI.embedderMessageAck",
346 &id_value, arg, nullptr); 358 &id_value, arg, nullptr);
347 } 359 }
348 360
349 void ShellDevToolsFrontend::AgentHostClosed( 361 void ShellDevToolsFrontend::AgentHostClosed(
350 DevToolsAgentHost* agent_host, bool replaced) { 362 DevToolsAgentHost* agent_host, bool replaced) {
351 frontend_shell_->Close(); 363 frontend_shell_->Close();
352 } 364 }
353 365
354 } // namespace content 366 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | third_party/WebKit/Source/web/WebDevToolsAgentImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698