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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// Copyright (c) 2011 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 "content/browser/debugger/devtools_frontend_host.h"
#include "content/browser/debugger/devtools_manager_impl.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/devtools_messages.h"
#include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_frontend_host_delegate.h"
namespace content {
// static
DevToolsClientHost* DevToolsClientHost::CreateDevToolsFrontendHost(
TabContents* client_tab_contents,
DevToolsFrontendHostDelegate* delegate) {
return new DevToolsFrontendHost(client_tab_contents, delegate);
}
// static
void DevToolsClientHost::SetupDevToolsFrontendClient(
RenderViewHost* frontend_rvh) {
frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient(
frontend_rvh->routing_id()));
}
DevToolsFrontendHost::DevToolsFrontendHost(
TabContents* tab_contents,
DevToolsFrontendHostDelegate* delegate)
: RenderViewHostObserver(tab_contents->render_view_host()),
tab_contents_(tab_contents),
delegate_(delegate) {
}
DevToolsFrontendHost::~DevToolsFrontendHost() {
}
void DevToolsFrontendHost::DispatchOnInspectorFrontend(
const std::string& message) {
RenderViewHost* target_host = tab_contents_->render_view_host();
target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
target_host->routing_id(),
message));
}
void DevToolsFrontendHost::InspectedTabClosing() {
delegate_->InspectedTabClosing();
}
void DevToolsFrontendHost::FrameNavigating(const std::string& url) {
delegate_->FrameNavigating(url);
}
void DevToolsFrontendHost::TabReplaced(TabContents* new_tab) {
delegate_->TabReplaced(new_tab);
}
bool DevToolsFrontendHost::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message)
IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
OnDispatchOnInspectorBackend)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_MoveWindow, OnMoveWindow)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestDockWindow, OnRequestDockWindow)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestUndockWindow,
OnRequestUndockWindow)
IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAs,
OnSaveAs)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void DevToolsFrontendHost::OnDispatchOnInspectorBackend(
const std::string& message) {
DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message);
// delegate_->DispatchOnInspectorBackend(message);
}
void DevToolsFrontendHost::OnActivateWindow() {
delegate_->ActivateWindow();
}
void DevToolsFrontendHost::OnCloseWindow() {
delegate_->CloseWindow();
}
void DevToolsFrontendHost::OnMoveWindow(int x, int y) {
delegate_->MoveWindow(x, y);
}
void DevToolsFrontendHost::OnSaveAs(
const std::string& suggested_file_name,
const std::string& content) {
delegate_->SaveToFile(suggested_file_name, content);
}
void DevToolsFrontendHost::OnRequestDockWindow() {
delegate_->DockWindow();
}
void DevToolsFrontendHost::OnRequestUndockWindow() {
delegate_->UndockWindow();
}
} // namespace content
|