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

Side by Side Diff: chrome/browser/debugger/devtools_window.h

Issue 11630004: DevTools: rename debugger/ to devtools/, move DevTools files into content/renderer/devtools. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: For landing Created 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_
6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/debugger/devtools_file_helper.h"
14 #include "chrome/browser/debugger/devtools_toggle_action.h"
15 #include "content/public/browser/devtools_client_host.h"
16 #include "content/public/browser/devtools_frontend_host_delegate.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_delegate.h"
20
21 class Browser;
22 class BrowserWindow;
23 class PrefService;
24 class Profile;
25
26 namespace base {
27 class Value;
28 }
29
30 namespace chrome {
31 class BrowserListImpl;
32 }
33
34 namespace content {
35 class DevToolsAgentHost;
36 class DevToolsClientHost;
37 struct FileChooserParams;
38 class RenderViewHost;
39 class WebContents;
40 }
41
42 namespace IPC {
43 class Message;
44 }
45
46 enum DevToolsDockSide {
47 DEVTOOLS_DOCK_SIDE_UNDOCKED = 0,
48 DEVTOOLS_DOCK_SIDE_BOTTOM,
49 DEVTOOLS_DOCK_SIDE_RIGHT
50 };
51
52 class DevToolsWindow : private content::NotificationObserver,
53 private content::WebContentsDelegate,
54 private content::DevToolsFrontendHostDelegate,
55 private DevToolsFileHelper::Delegate {
56 public:
57 static const char kDevToolsApp[];
58 static void RegisterUserPrefs(PrefService* prefs);
59 static DevToolsWindow* GetDockedInstanceForInspectedTab(
60 content::WebContents* inspected_tab);
61 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh);
62
63 static DevToolsWindow* OpenDevToolsWindowForWorker(
64 Profile* profile,
65 content::DevToolsAgentHost* worker_agent);
66 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile);
67 static DevToolsWindow* OpenDevToolsWindow(
68 content::RenderViewHost* inspected_rvh);
69 static DevToolsWindow* ToggleDevToolsWindow(
70 Browser* browser,
71 DevToolsToggleAction action);
72
73 // Exposed for testing, normal clients should not use this method.
74 static DevToolsWindow* ToggleDevToolsWindow(
75 content::RenderViewHost* inspected_rvh,
76 bool force_open,
77 DevToolsToggleAction action);
78 static void InspectElement(
79 content::RenderViewHost* inspected_rvh, int x, int y);
80
81 virtual ~DevToolsWindow();
82
83 // Overridden from DevToolsClientHost.
84 virtual void InspectedContentsClosing() OVERRIDE;
85 virtual void ContentsReplaced(content::WebContents* new_contents) OVERRIDE;
86 content::RenderViewHost* GetRenderViewHost();
87
88 void Show(DevToolsToggleAction action);
89
90 content::WebContents* web_contents() { return web_contents_; }
91 Browser* browser() { return browser_; } // For tests.
92 DevToolsDockSide dock_side() { return dock_side_; }
93 content::DevToolsClientHost* devtools_client_host() { return frontend_host_; }
94
95 // Returns preferred devtools window width for given |container_width|. It
96 // tries to use the saved window width, or, if none exists, 1/3 of the
97 // container width, then clamps to try and ensure both devtools and content
98 // are at least somewhat visible.
99 // Called only for the case when devtools window is docked to the side.
100 int GetWidth(int container_width);
101
102 // Returns preferred devtools window height for given |container_height|.
103 // Uses the same logic as GetWidth.
104 // Called only for the case when devtools window is docked to bottom.
105 int GetHeight(int container_height);
106
107 // Stores preferred devtools window width for this instance.
108 void SetWidth(int width);
109
110 // Stores preferred devtools window height for this instance.
111 void SetHeight(int height);
112
113 private:
114 static DevToolsWindow* Create(Profile* profile,
115 content::RenderViewHost* inspected_rvh,
116 DevToolsDockSide dock_side,
117 bool shared_worker_frontend);
118 DevToolsWindow(content::WebContents* web_contents,
119 Profile* profile,
120 content::RenderViewHost* inspected_rvh,
121 DevToolsDockSide dock_side);
122
123 void CreateDevToolsBrowser();
124 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab);
125 bool FindInspectedBrowserAndTabIndexFromBrowserList(
126 chrome::BrowserListImpl* browser_list,
127 Browser** browser,
128 int* tab);
129 BrowserWindow* GetInspectedBrowserWindow();
130 bool IsInspectedBrowserPopupOrPanel();
131 void UpdateFrontendDockSide();
132
133 // Overridden from content::NotificationObserver.
134 virtual void Observe(int type,
135 const content::NotificationSource& source,
136 const content::NotificationDetails& details) OVERRIDE;
137
138 void ScheduleAction(DevToolsToggleAction action);
139 void DoAction();
140 static GURL GetDevToolsUrl(Profile* profile,
141 DevToolsDockSide dock_side,
142 bool shared_worker_frontend);
143 void UpdateTheme();
144 void AddDevToolsExtensionsToClient();
145 void CallClientFunction(const std::string& function_name,
146 const base::Value* arg);
147 // Overridden from content::WebContentsDelegate.
148 virtual content::WebContents* OpenURLFromTab(
149 content::WebContents* source,
150 const content::OpenURLParams& params) OVERRIDE;
151 virtual void AddNewContents(content::WebContents* source,
152 content::WebContents* new_contents,
153 WindowOpenDisposition disposition,
154 const gfx::Rect& initial_pos,
155 bool user_gesture,
156 bool* was_blocked) OVERRIDE;
157 virtual void CloseContents(content::WebContents* source) OVERRIDE {}
158 virtual bool PreHandleKeyboardEvent(
159 content::WebContents* source,
160 const content::NativeWebKeyboardEvent& event,
161 bool* is_keyboard_shortcut) OVERRIDE;
162 virtual void HandleKeyboardEvent(
163 content::WebContents* source,
164 const content::NativeWebKeyboardEvent& event) OVERRIDE;
165 virtual content::JavaScriptDialogCreator*
166 GetJavaScriptDialogCreator() OVERRIDE;
167 virtual void RunFileChooser(
168 content::WebContents* web_contents,
169 const content::FileChooserParams& params) OVERRIDE;
170 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
171
172 virtual void FrameNavigating(const std::string& url) OVERRIDE {}
173
174 static DevToolsWindow* AsDevToolsWindow(content::DevToolsClientHost*);
175 static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
176
177 // content::DevToolsFrontendHostDelegate overrides.
178 virtual void ActivateWindow() OVERRIDE;
179 virtual void CloseWindow() OVERRIDE;
180 virtual void MoveWindow(int x, int y) OVERRIDE;
181 virtual void SetDockSide(const std::string& side) OVERRIDE;
182 virtual void OpenInNewTab(const std::string& url) OVERRIDE;
183 virtual void SaveToFile(const std::string& url,
184 const std::string& content,
185 bool save_as) OVERRIDE;
186 virtual void AppendToFile(const std::string& url,
187 const std::string& content) OVERRIDE;
188
189 // Overridden from DevToolsFileHelper::Delegate
190 virtual void FileSavedAs(const std::string& url) OVERRIDE;
191 virtual void AppendedTo(const std::string& url) OVERRIDE;
192
193 void UpdateBrowserToolbar();
194 bool IsDocked();
195 static DevToolsDockSide GetDockSideFromPrefs(Profile* profile);
196 static std::string SideToString(DevToolsDockSide dock_side);
197 static DevToolsDockSide SideFromString(const std::string& dock_side);
198
199 Profile* profile_;
200 content::WebContents* inspected_web_contents_;
201 content::WebContents* web_contents_;
202 Browser* browser_;
203 DevToolsDockSide dock_side_;
204 bool is_loaded_;
205 DevToolsToggleAction action_on_load_;
206 content::NotificationRegistrar registrar_;
207 content::DevToolsClientHost* frontend_host_;
208 scoped_ptr<DevToolsFileHelper> file_helper_;
209 int width_;
210 int height_;
211 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
212 };
213
214 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_WINDOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_toggle_action.h ('k') | chrome/browser/debugger/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698