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

Side by Side Diff: content/browser/debugger/devtools_frontend_host.cc

Issue 8549022: Define DevTools content API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years 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
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/debugger/devtools_frontend_host.h"
6
7 #include "content/browser/debugger/devtools_manager_impl.h"
8 #include "content/browser/renderer_host/render_view_host.h"
9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "content/common/devtools_messages.h"
11 #include "content/public/browser/devtools_client_host.h"
12 #include "content/public/browser/devtools_frontend_host_delegate.h"
13
14 namespace content {
15
16 // static
17 DevToolsClientHost* DevToolsClientHost::CreateDevToolsFrontendHost(
18 TabContents* client_tab_contents,
19 DevToolsFrontendHostDelegate* delegate) {
20 return new DevToolsFrontendHost(client_tab_contents, delegate);
21 }
22
23 // static
24 void DevToolsClientHost::SetupDevToolsFrontendClient(
25 RenderViewHost* frontend_rvh) {
26 frontend_rvh->Send(new DevToolsMsg_SetupDevToolsClient(
27 frontend_rvh->routing_id()));
28 }
29
30 DevToolsFrontendHost::DevToolsFrontendHost(
31 TabContents* tab_contents,
32 DevToolsFrontendHostDelegate* delegate)
33 : RenderViewHostObserver(tab_contents->render_view_host()),
34 tab_contents_(tab_contents),
35 delegate_(delegate) {
36 }
37
38 DevToolsFrontendHost::~DevToolsFrontendHost() {
39 }
40
41 void DevToolsFrontendHost::DispatchOnInspectorFrontend(
42 const std::string& message) {
43 RenderViewHost* target_host = tab_contents_->render_view_host();
44 target_host->Send(new DevToolsClientMsg_DispatchOnInspectorFrontend(
45 target_host->routing_id(),
46 message));
47 }
48
49 void DevToolsFrontendHost::InspectedTabClosing() {
50 delegate_->InspectedTabClosing();
51 }
52
53 void DevToolsFrontendHost::FrameNavigating(const std::string& url) {
54 delegate_->FrameNavigating(url);
55 }
56
57 void DevToolsFrontendHost::TabReplaced(TabContents* new_tab) {
58 delegate_->TabReplaced(new_tab);
59 }
60
61 bool DevToolsFrontendHost::OnMessageReceived(
62 const IPC::Message& message) {
63 bool handled = true;
64 IPC_BEGIN_MESSAGE_MAP(DevToolsFrontendHost, message)
65 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DispatchOnInspectorBackend,
66 OnDispatchOnInspectorBackend)
67 IPC_MESSAGE_HANDLER(DevToolsHostMsg_ActivateWindow, OnActivateWindow)
68 IPC_MESSAGE_HANDLER(DevToolsHostMsg_CloseWindow, OnCloseWindow)
69 IPC_MESSAGE_HANDLER(DevToolsHostMsg_MoveWindow, OnMoveWindow)
70 IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestDockWindow, OnRequestDockWindow)
71 IPC_MESSAGE_HANDLER(DevToolsHostMsg_RequestUndockWindow,
72 OnRequestUndockWindow)
73 IPC_MESSAGE_HANDLER(DevToolsHostMsg_SaveAs,
74 OnSaveAs)
75 IPC_MESSAGE_UNHANDLED(handled = false)
76 IPC_END_MESSAGE_MAP()
77 return handled;
78 }
79
80 void DevToolsFrontendHost::OnDispatchOnInspectorBackend(
81 const std::string& message) {
82 DevToolsManagerImpl::GetInstance()->DispatchOnInspectorBackend(this, message);
83 // delegate_->DispatchOnInspectorBackend(message);
84 }
85
86 void DevToolsFrontendHost::OnActivateWindow() {
87 delegate_->ActivateWindow();
88 }
89
90 void DevToolsFrontendHost::OnCloseWindow() {
91 delegate_->CloseWindow();
92 }
93
94 void DevToolsFrontendHost::OnMoveWindow(int x, int y) {
95 delegate_->MoveWindow(x, y);
96 }
97
98 void DevToolsFrontendHost::OnSaveAs(
99 const std::string& suggested_file_name,
100 const std::string& content) {
101 delegate_->SaveToFile(suggested_file_name, content);
102 }
103
104 void DevToolsFrontendHost::OnRequestDockWindow() {
105 delegate_->DockWindow();
106 }
107
108 void DevToolsFrontendHost::OnRequestUndockWindow() {
109 delegate_->UndockWindow();
110 }
111
112 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698