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

Side by Side Diff: webkit/glue/webdevtoolsagent_impl.cc

Issue 56149: DevTools: add support for main resource load tracking. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webdevtoolsagent_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "config.h" 5 #include "config.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "Document.h" 9 #include "Document.h"
10 #include "EventListener.h" 10 #include "EventListener.h"
(...skipping 24 matching lines...) Expand all
35 using WebCore::ScriptValue; 35 using WebCore::ScriptValue;
36 using WebCore::String; 36 using WebCore::String;
37 37
38 WebDevToolsAgentImpl::WebDevToolsAgentImpl( 38 WebDevToolsAgentImpl::WebDevToolsAgentImpl(
39 WebViewImpl* web_view_impl, 39 WebViewImpl* web_view_impl,
40 WebDevToolsAgentDelegate* delegate) 40 WebDevToolsAgentDelegate* delegate)
41 : delegate_(delegate), 41 : delegate_(delegate),
42 web_view_impl_(web_view_impl), 42 web_view_impl_(web_view_impl),
43 document_(NULL), 43 document_(NULL),
44 attached_(false) { 44 attached_(false) {
45 debugger_agent_delegate_stub_.reset(new DebuggerAgentDelegateStub(this)); 45 debugger_agent_delegate_stub_.set(new DebuggerAgentDelegateStub(this));
46 dom_agent_delegate_stub_.reset(new DomAgentDelegateStub(this)); 46 dom_agent_delegate_stub_.set(new DomAgentDelegateStub(this));
47 net_agent_delegate_stub_.reset(new NetAgentDelegateStub(this)); 47 net_agent_delegate_stub_.set(new NetAgentDelegateStub(this));
48 tools_agent_delegate_stub_.reset(new ToolsAgentDelegateStub(this)); 48 tools_agent_delegate_stub_.set(new ToolsAgentDelegateStub(this));
49 } 49 }
50 50
51 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() { 51 WebDevToolsAgentImpl::~WebDevToolsAgentImpl() {
52 } 52 }
53 53
54 void WebDevToolsAgentImpl::Attach() { 54 void WebDevToolsAgentImpl::Attach() {
55 if (attached_) { 55 if (attached_) {
56 return; 56 return;
57 } 57 }
58 debugger_agent_impl_.reset( 58 debugger_agent_impl_.set(
59 new DebuggerAgentImpl(debugger_agent_delegate_stub_.get())); 59 new DebuggerAgentImpl(debugger_agent_delegate_stub_.get()));
60 dom_agent_impl_.reset(new DomAgentImpl(dom_agent_delegate_stub_.get())); 60 dom_agent_impl_.set(new DomAgentImpl(dom_agent_delegate_stub_.get()));
61 net_agent_impl_.reset(new NetAgentImpl(net_agent_delegate_stub_.get())); 61 net_agent_impl_.set(new NetAgentImpl(net_agent_delegate_stub_.get()));
62 if (document_) { 62 if (document_) {
63 debugger_agent_impl_->SetDocument(document_); 63 debugger_agent_impl_->SetDocument(document_);
64 dom_agent_impl_->SetDocument(document_); 64 dom_agent_impl_->SetDocument(document_);
65 net_agent_impl_->SetDocument(document_); 65 net_agent_impl_->SetDocument(document_);
66 } 66 }
67 attached_ = true; 67 attached_ = true;
68 } 68 }
69 69
70 void WebDevToolsAgentImpl::Detach() { 70 void WebDevToolsAgentImpl::Detach() {
71 debugger_agent_impl_.reset(NULL); 71 debugger_agent_impl_.set(NULL);
72 dom_agent_impl_.reset(NULL); 72 dom_agent_impl_.set(NULL);
73 net_agent_impl_.reset(NULL); 73 net_agent_impl_.set(NULL);
74 attached_ = false; 74 attached_ = false;
75 } 75 }
76 76
77 void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) { 77 void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) {
78 // Store document reference no matter if client is attached.
78 if (ready) { 79 if (ready) {
79 Page* page = web_view_impl_->page(); 80 Page* page = web_view_impl_->page();
80 document_ = page->mainFrame()->document(); 81 document_ = page->mainFrame()->document();
81 } else { 82 } else {
82 document_ = NULL; 83 document_ = NULL;
83 } 84 }
84 if (attached_) { 85 if (attached_) {
85 debugger_agent_impl_->SetDocument(document_); 86 debugger_agent_impl_->SetDocument(document_);
86 dom_agent_impl_->SetDocument(document_); 87 dom_agent_impl_->SetDocument(document_);
87 net_agent_impl_->SetDocument(document_); 88 net_agent_impl_->SetDocument(document_);
(...skipping 11 matching lines...) Expand all
99 const WebRequest& request = ds->GetRequest(); 100 const WebRequest& request = ds->GetRequest();
100 GURL url = ds->HasUnreachableURL() ? 101 GURL url = ds->HasUnreachableURL() ?
101 ds->GetUnreachableURL() : 102 ds->GetUnreachableURL() :
102 request.GetURL(); 103 request.GetURL();
103 tools_agent_delegate_stub_->FrameNavigate( 104 tools_agent_delegate_stub_->FrameNavigate(
104 url.possibly_invalid_spec(), 105 url.possibly_invalid_spec(),
105 webview->GetMainFrame() == frame); 106 webview->GetMainFrame() == frame);
106 } 107 }
107 108
108 void WebDevToolsAgentImpl::HighlightDOMNode(int node_id) { 109 void WebDevToolsAgentImpl::HighlightDOMNode(int node_id) {
109 if (!attached_) 110 if (!attached_) {
110 return; 111 return;
112 }
111 Node* node = dom_agent_impl_->GetNodeForId(node_id); 113 Node* node = dom_agent_impl_->GetNodeForId(node_id);
112 if (!node) 114 if (!node) {
113 return; 115 return;
116 }
114 Page* page = web_view_impl_->page(); 117 Page* page = web_view_impl_->page();
115 page->inspectorController()->highlight(node); 118 page->inspectorController()->highlight(node);
116 } 119 }
117 120
118 void WebDevToolsAgentImpl::HideDOMNodeHighlight() { 121 void WebDevToolsAgentImpl::HideDOMNodeHighlight() {
119 Page* page = web_view_impl_->page(); 122 Page* page = web_view_impl_->page();
120 page->inspectorController()->hideHighlight(); 123 page->inspectorController()->hideHighlight();
121 } 124 }
122 125
123 void WebDevToolsAgentImpl::EvaluateJavaScript(int call_id, const String& js) { 126 void WebDevToolsAgentImpl::EvaluateJavaScript(int call_id, const String& js) {
(...skipping 21 matching lines...) Expand all
145 json_args); 148 json_args);
146 } 149 }
147 tools_agent_delegate_stub_->DidExecuteUtilityFunction(call_id, 150 tools_agent_delegate_stub_->DidExecuteUtilityFunction(call_id,
148 result); 151 result);
149 } 152 }
150 153
151 void WebDevToolsAgentImpl::DispatchMessageFromClient( 154 void WebDevToolsAgentImpl::DispatchMessageFromClient(
152 const std::string& raw_msg) { 155 const std::string& raw_msg) {
153 OwnPtr<ListValue> message( 156 OwnPtr<ListValue> message(
154 static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg))); 157 static_cast<ListValue*>(DevToolsRpc::ParseMessage(raw_msg)));
155 if (ToolsAgentDispatch::Dispatch(this, *message.get())) 158 if (ToolsAgentDispatch::Dispatch(this, *message.get())) {
156 return; 159 return;
160 }
157 161
158 if (!attached_) 162 if (!attached_) {
159 return; 163 return;
164 }
160 165
161 if (debugger_agent_impl_.get() && 166 if (debugger_agent_impl_.get() &&
162 DebuggerAgentDispatch::Dispatch( 167 DebuggerAgentDispatch::Dispatch(
163 debugger_agent_impl_.get(), 168 debugger_agent_impl_.get(),
164 *message.get())) 169 *message.get())) {
165 return; 170 return;
171 }
166 172
167 if (DomAgentDispatch::Dispatch(dom_agent_impl_.get(), *message.get())) 173 if (DomAgentDispatch::Dispatch(dom_agent_impl_.get(), *message.get())) {
168 return; 174 return;
169 if (NetAgentDispatch::Dispatch(net_agent_impl_.get(), *message.get())) 175 }
176 if (NetAgentDispatch::Dispatch(net_agent_impl_.get(), *message.get())) {
170 return; 177 return;
178 }
171 } 179 }
172 180
173 void WebDevToolsAgentImpl::InspectElement(int x, int y) { 181 void WebDevToolsAgentImpl::InspectElement(int x, int y) {
174 Node* node = web_view_impl_->GetNodeForWindowPos(x, y); 182 Node* node = web_view_impl_->GetNodeForWindowPos(x, y);
175 if (!node) 183 if (!node) {
176 return; 184 return;
185 }
177 186
178 int node_id = dom_agent_impl_->PushNodePathToClient(node); 187 int node_id = dom_agent_impl_->PushNodePathToClient(node);
179 tools_agent_delegate_stub_->UpdateFocusedNode(node_id); 188 tools_agent_delegate_stub_->UpdateFocusedNode(node_id);
180 } 189 }
181 190
182 void WebDevToolsAgentImpl::SendRpcMessage(const std::string& raw_msg) { 191 void WebDevToolsAgentImpl::SendRpcMessage(const std::string& raw_msg) {
183 delegate_->SendMessageToClient(raw_msg); 192 delegate_->SendMessageToClient(raw_msg);
184 } 193 }
185 194
186 // static 195 // static
187 void WebDevToolsAgent::ExecuteDebuggerCommand(const std::string& command) { 196 void WebDevToolsAgent::ExecuteDebuggerCommand(const std::string& command) {
188 DebuggerAgentManager::ExecuteDebuggerCommand(command); 197 DebuggerAgentManager::ExecuteDebuggerCommand(command);
189 } 198 }
OLDNEW
« no previous file with comments | « webkit/glue/webdevtoolsagent_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698