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

Side by Side Diff: chrome/renderer/devtools_agent.cc

Issue 287009: Move WebDevToolsAgent{Delegate} into the WebKit API.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 | « chrome/renderer/devtools_agent.h ('k') | chrome/renderer/devtools_agent_filter.h » ('j') | 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 "chrome/renderer/devtools_agent.h" 5 #include "chrome/renderer/devtools_agent.h"
6 6
7 #include "chrome/common/devtools_messages.h" 7 #include "chrome/common/devtools_messages.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "chrome/renderer/render_view.h" 9 #include "chrome/renderer/render_view.h"
10 #include "webkit/api/public/WebDevToolsAgent.h"
11 #include "webkit/api/public/WebPoint.h"
10 #include "webkit/api/public/WebString.h" 12 #include "webkit/api/public/WebString.h"
11 #include "webkit/glue/webdevtoolsagent.h"
12 13
14 using WebKit::WebDevToolsAgent;
15 using WebKit::WebPoint;
13 using WebKit::WebString; 16 using WebKit::WebString;
14 17
15 // static 18 // static
16 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_; 19 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_;
17 20
18 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view) 21 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view)
19 : routing_id_(routing_id), 22 : routing_id_(routing_id),
20 view_(view) { 23 view_(view) {
21 agent_for_routing_id_[routing_id] = this; 24 agent_for_routing_id_[routing_id] = this;
22 } 25 }
23 26
24 DevToolsAgent::~DevToolsAgent() { 27 DevToolsAgent::~DevToolsAgent() {
25 agent_for_routing_id_.erase(routing_id_); 28 agent_for_routing_id_.erase(routing_id_);
26 } 29 }
27 30
28 void DevToolsAgent::OnNavigate() { 31 void DevToolsAgent::OnNavigate() {
29 WebDevToolsAgent* web_agent = GetWebAgent(); 32 WebDevToolsAgent* web_agent = GetWebAgent();
30 if (web_agent) { 33 if (web_agent) {
31 web_agent->OnNavigate(); 34 web_agent->didNavigate();
32 } 35 }
33 } 36 }
34 37
35 // Called on the Renderer thread. 38 // Called on the Renderer thread.
36 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) { 39 bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
37 bool handled = true; 40 bool handled = true;
38 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message) 41 IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message)
39 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach) 42 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach)
40 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach) 43 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach)
41 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) 44 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage)
42 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement) 45 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement)
43 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled, 46 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_SetApuAgentEnabled,
44 OnSetApuAgentEnabled) 47 OnSetApuAgentEnabled)
45 IPC_MESSAGE_UNHANDLED(handled = false) 48 IPC_MESSAGE_UNHANDLED(handled = false)
46 IPC_END_MESSAGE_MAP() 49 IPC_END_MESSAGE_MAP()
47 return handled; 50 return handled;
48 } 51 }
49 52
50 void DevToolsAgent::SendMessageToClient(const WebKit::WebString& class_name, 53 void DevToolsAgent::sendMessageToFrontend(const WebString& class_name,
51 const WebKit::WebString& method_name, 54 const WebString& method_name,
52 const WebKit::WebString& param1, 55 const WebString& param1,
53 const WebKit::WebString& param2, 56 const WebString& param2,
54 const WebKit::WebString& param3) { 57 const WebString& param3) {
55 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( 58 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient(
56 routing_id_, 59 routing_id_,
57 DevToolsClientMsg_RpcMessage( 60 DevToolsClientMsg_RpcMessage(
58 class_name.utf8(), 61 class_name.utf8(),
59 method_name.utf8(), 62 method_name.utf8(),
60 param1.utf8(), 63 param1.utf8(),
61 param2.utf8(), 64 param2.utf8(),
62 param3.utf8())); 65 param3.utf8()));
63 view_->Send(m); 66 view_->Send(m);
64 } 67 }
65 68
66 int DevToolsAgent::GetHostId() { 69 int DevToolsAgent::hostIdentifier() {
67 return routing_id_; 70 return routing_id_;
68 } 71 }
69 72
70 void DevToolsAgent::ForceRepaint() { 73 void DevToolsAgent::forceRepaint() {
71 view_->GenerateFullRepaint(); 74 view_->GenerateFullRepaint();
72 } 75 }
73 76
74 // static 77 // static
75 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { 78 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) {
76 std::map<int, DevToolsAgent*>::iterator it = 79 std::map<int, DevToolsAgent*>::iterator it =
77 agent_for_routing_id_.find(host_id); 80 agent_for_routing_id_.find(host_id);
78 if (it != agent_for_routing_id_.end()) { 81 if (it != agent_for_routing_id_.end()) {
79 return it->second; 82 return it->second;
80 } 83 }
81 return NULL; 84 return NULL;
82 } 85 }
83 86
84 void DevToolsAgent::OnAttach() { 87 void DevToolsAgent::OnAttach() {
85 WebDevToolsAgent* web_agent = GetWebAgent(); 88 WebDevToolsAgent* web_agent = GetWebAgent();
86 if (web_agent) { 89 if (web_agent) {
87 web_agent->Attach(); 90 web_agent->attach();
88 } 91 }
89 } 92 }
90 93
91 void DevToolsAgent::OnDetach() { 94 void DevToolsAgent::OnDetach() {
92 WebDevToolsAgent* web_agent = GetWebAgent(); 95 WebDevToolsAgent* web_agent = GetWebAgent();
93 if (web_agent) { 96 if (web_agent) {
94 web_agent->Detach(); 97 web_agent->detach();
95 } 98 }
96 } 99 }
97 100
98 void DevToolsAgent::OnRpcMessage(const std::string& class_name, 101 void DevToolsAgent::OnRpcMessage(const std::string& class_name,
99 const std::string& method_name, 102 const std::string& method_name,
100 const std::string& param1, 103 const std::string& param1,
101 const std::string& param2, 104 const std::string& param2,
102 const std::string& param3) { 105 const std::string& param3) {
103 WebDevToolsAgent* web_agent = GetWebAgent(); 106 WebDevToolsAgent* web_agent = GetWebAgent();
104 if (web_agent) { 107 if (web_agent) {
105 web_agent->DispatchMessageFromClient( 108 web_agent->dispatchMessageFromFrontend(
106 WebString::fromUTF8(class_name), 109 WebString::fromUTF8(class_name),
107 WebString::fromUTF8(method_name), 110 WebString::fromUTF8(method_name),
108 WebString::fromUTF8(param1), 111 WebString::fromUTF8(param1),
109 WebString::fromUTF8(param2), 112 WebString::fromUTF8(param2),
110 WebString::fromUTF8(param3)); 113 WebString::fromUTF8(param3));
111 } 114 }
112 } 115 }
113 116
114 void DevToolsAgent::OnInspectElement(int x, int y) { 117 void DevToolsAgent::OnInspectElement(int x, int y) {
115 WebDevToolsAgent* web_agent = GetWebAgent(); 118 WebDevToolsAgent* web_agent = GetWebAgent();
116 if (web_agent) { 119 if (web_agent) {
117 web_agent->Attach(); 120 web_agent->attach();
118 web_agent->InspectElement(x, y); 121 web_agent->inspectElementAt(WebPoint(x, y));
119 } 122 }
120 } 123 }
121 124
122 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { 125 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) {
123 WebDevToolsAgent* web_agent = GetWebAgent(); 126 WebDevToolsAgent* web_agent = GetWebAgent();
124 if (web_agent) { 127 if (web_agent) {
125 web_agent->SetApuAgentEnabled(enabled); 128 web_agent->setApuAgentEnabled(enabled);
126 } 129 }
127 } 130 }
128 131
129 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { 132 WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
130 WebView* web_view = view_->webview(); 133 WebView* web_view = view_->webview();
131 if (!web_view) 134 if (!web_view)
132 return NULL; 135 return NULL;
133 return web_view->GetWebDevToolsAgent(); 136 return web_view->devToolsAgent();
134 } 137 }
OLDNEW
« no previous file with comments | « chrome/renderer/devtools_agent.h ('k') | chrome/renderer/devtools_agent_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698