blob: 046b7550fe1f6ff3d3e3a0182b52f1698f2cea0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/renderer/devtools_agent.h"
#include "chrome/common/devtools_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_view.h"
#include "webkit/glue/webdevtoolsagent.h"
DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view)
: routing_id_(routing_id),
view_(view) {
}
DevToolsAgent::~DevToolsAgent() {
}
// Called on the Renderer thread.
bool DevToolsAgent::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DevToolsAgent, message)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Attach, OnAttach)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_Detach, OnDetach)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_InspectElement, OnInspectElement)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void DevToolsAgent::SendMessageToClient(const std::string& raw_msg) {
IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient(
routing_id_,
DevToolsClientMsg_RpcMessage(raw_msg));
view_->Send(m);
}
void DevToolsAgent::OnAttach() {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->Attach();
}
}
void DevToolsAgent::OnDetach() {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->Detach();
}
}
void DevToolsAgent::OnRpcMessage(const std::string& raw_msg) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->DispatchMessageFromClient(raw_msg);
}
}
void DevToolsAgent::OnInspectElement(int x, int y) {
WebDevToolsAgent* web_agent = GetWebAgent();
if (web_agent) {
web_agent->Attach();
web_agent->InspectElement(x, y);
}
}
WebDevToolsAgent* DevToolsAgent::GetWebAgent() {
WebView* web_view = view_->webview();
if (!web_view)
return NULL;
return web_view->GetWebDevToolsAgent();
}
|