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

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

Issue 115862: DevTools: pass class and method name as arguments to RPC messages (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webdevtoolsclient_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 "DOMWindow.h" 10 #include "DOMWindow.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 dev_tools_host_->AddProtoFunction( 115 dev_tools_host_->AddProtoFunction(
116 "activateWindow", 116 "activateWindow",
117 WebDevToolsClientImpl::JsActivateWindow); 117 WebDevToolsClientImpl::JsActivateWindow);
118 dev_tools_host_->Build(); 118 dev_tools_host_->Build();
119 } 119 }
120 120
121 WebDevToolsClientImpl::~WebDevToolsClientImpl() { 121 WebDevToolsClientImpl::~WebDevToolsClientImpl() {
122 } 122 }
123 123
124 void WebDevToolsClientImpl::DispatchMessageFromAgent( 124 void WebDevToolsClientImpl::DispatchMessageFromAgent(
125 const std::string& raw_msg) { 125 const std::string& class_name,
126 const std::string& method_name,
127 const std::string& raw_msg) {
128 std::string expr = StringPrintf(
129 "devtools.dispatch('%s','%s',%s)",
130 class_name.c_str(),
131 method_name.c_str(),
132 raw_msg.c_str());
126 if (!loaded_) { 133 if (!loaded_) {
127 pending_incoming_messages_.append(raw_msg); 134 pending_incoming_messages_.append(expr);
128 return; 135 return;
129 } 136 }
130 std::string expr = StringPrintf("devtools.dispatch(%s)", raw_msg.c_str()); 137 ExecuteScript(expr);
138 }
139
140 void WebDevToolsClientImpl::ExecuteScript(const std::string& expr) {
131 web_view_impl_->GetMainFrame()->ExecuteScript( 141 web_view_impl_->GetMainFrame()->ExecuteScript(
132 WebScriptSource(WebString::fromUTF8(expr))); 142 WebScriptSource(WebString::fromUTF8(expr)));
133 } 143 }
134 144
135 void WebDevToolsClientImpl::SendRpcMessage(const std::string& raw_msg) { 145
136 delegate_->SendMessageToAgent(raw_msg); 146 void WebDevToolsClientImpl::SendRpcMessage(const std::string& class_name,
147 const std::string& method_name,
148 const std::string& raw_msg) {
149 delegate_->SendMessageToAgent(class_name, method_name, raw_msg);
137 } 150 }
138 151
139 // static 152 // static
140 v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame( 153 v8::Handle<v8::Value> WebDevToolsClientImpl::JsAddSourceToFrame(
141 const v8::Arguments& args) { 154 const v8::Arguments& args) {
142 if (args.Length() < 2) { 155 if (args.Length() < 2) {
143 return v8::Undefined(); 156 return v8::Undefined();
144 } 157 }
145 158
146 v8::TryCatch exception_catcher; 159 v8::TryCatch exception_catcher;
(...skipping 26 matching lines...) Expand all
173 186
174 // Grant the devtools page the ability to have source view iframes. 187 // Grant the devtools page the ability to have source view iframes.
175 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page(); 188 Page* page = V8Proxy::retrieveFrameForEnteredContext()->page();
176 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin(); 189 SecurityOrigin* origin = page->mainFrame()->domWindow()->securityOrigin();
177 origin->grantUniversalAccess(); 190 origin->grantUniversalAccess();
178 191
179 for (Vector<std::string>::iterator it = 192 for (Vector<std::string>::iterator it =
180 client->pending_incoming_messages_.begin(); 193 client->pending_incoming_messages_.begin();
181 it != client->pending_incoming_messages_.end(); 194 it != client->pending_incoming_messages_.end();
182 ++it) { 195 ++it) {
183 client->DispatchMessageFromAgent(*it); 196 client->ExecuteScript(*it);
184 } 197 }
185 client->pending_incoming_messages_.clear(); 198 client->pending_incoming_messages_.clear();
186 return v8::Undefined(); 199 return v8::Undefined();
187 } 200 }
188 201
189 // static 202 // static
190 v8::Handle<v8::Value> WebDevToolsClientImpl::JsActivateWindow( 203 v8::Handle<v8::Value> WebDevToolsClientImpl::JsActivateWindow(
191 const v8::Arguments& args) { 204 const v8::Arguments& args) {
192 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>( 205 WebDevToolsClientImpl* client = static_cast<WebDevToolsClientImpl*>(
193 v8::External::Cast(*args.Data())->Value()); 206 v8::External::Cast(*args.Data())->Value());
194 client->delegate_->ActivateWindow(); 207 client->delegate_->ActivateWindow();
195 return v8::Undefined(); 208 return v8::Undefined();
196 } 209 }
OLDNEW
« no previous file with comments | « webkit/glue/webdevtoolsclient_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698