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

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

Issue 19820004: Per the Chromium style guide/dos-and-donts doc, don't inline non-"cheap (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 5 #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 6 #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 DEVTOOLS_DOCK_SIDE_BOTTOM, 50 DEVTOOLS_DOCK_SIDE_BOTTOM,
51 DEVTOOLS_DOCK_SIDE_RIGHT, 51 DEVTOOLS_DOCK_SIDE_RIGHT,
52 DEVTOOLS_DOCK_SIDE_MINIMIZED 52 DEVTOOLS_DOCK_SIDE_MINIMIZED
53 }; 53 };
54 54
55 class DevToolsWindow : private content::NotificationObserver, 55 class DevToolsWindow : private content::NotificationObserver,
56 private content::WebContentsDelegate, 56 private content::WebContentsDelegate,
57 private content::DevToolsFrontendHostDelegate { 57 private content::DevToolsFrontendHostDelegate {
58 public: 58 public:
59 static const char kDevToolsApp[]; 59 static const char kDevToolsApp[];
60
61 virtual ~DevToolsWindow();
62
60 static std::string GetDevToolsWindowPlacementPrefKey(); 63 static std::string GetDevToolsWindowPlacementPrefKey();
61 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 64 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
62 static DevToolsWindow* GetDockedInstanceForInspectedTab( 65 static DevToolsWindow* GetDockedInstanceForInspectedTab(
63 content::WebContents* inspected_tab); 66 content::WebContents* inspected_tab);
64 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); 67 static bool IsDevToolsWindow(content::RenderViewHost* window_rvh);
65
66 static DevToolsWindow* OpenDevToolsWindowForWorker( 68 static DevToolsWindow* OpenDevToolsWindowForWorker(
67 Profile* profile, 69 Profile* profile,
68 content::DevToolsAgentHost* worker_agent); 70 content::DevToolsAgentHost* worker_agent);
69 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); 71 static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile);
70 static DevToolsWindow* OpenDevToolsWindow( 72 static DevToolsWindow* OpenDevToolsWindow(
71 content::RenderViewHost* inspected_rvh); 73 content::RenderViewHost* inspected_rvh);
72 static DevToolsWindow* ToggleDevToolsWindow( 74 static DevToolsWindow* ToggleDevToolsWindow(
73 Browser* browser, 75 Browser* browser,
74 DevToolsToggleAction action); 76 DevToolsToggleAction action);
75 static void OpenExternalFrontend(Profile* profile, 77 static void OpenExternalFrontend(Profile* profile,
76 const std::string& frontend_uri, 78 const std::string& frontend_uri,
77 content::DevToolsAgentHost* agent_host); 79 content::DevToolsAgentHost* agent_host);
78 80
79 // Exposed for testing, normal clients should not use this method. 81 // Exposed for testing, normal clients should not use this method.
80 static DevToolsWindow* ToggleDevToolsWindow( 82 static DevToolsWindow* ToggleDevToolsWindow(
81 content::RenderViewHost* inspected_rvh, 83 content::RenderViewHost* inspected_rvh,
82 bool force_open, 84 bool force_open,
83 DevToolsToggleAction action); 85 DevToolsToggleAction action);
84 static void InspectElement( 86 static void InspectElement(
85 content::RenderViewHost* inspected_rvh, int x, int y); 87 content::RenderViewHost* inspected_rvh, int x, int y);
86 88
87 virtual ~DevToolsWindow(); 89 static int GetMinimumWidth();
90 static int GetMinimumHeight();
91 static int GetMinimizedHeight();
88 92
89 // Overridden from DevToolsClientHost. 93 // Overridden from DevToolsClientHost.
90 virtual void InspectedContentsClosing() OVERRIDE; 94 virtual void InspectedContentsClosing() OVERRIDE;
91 content::RenderViewHost* GetRenderViewHost();
92
93 void Show(DevToolsToggleAction action);
94 95
95 content::WebContents* web_contents() { return web_contents_; } 96 content::WebContents* web_contents() { return web_contents_; }
96 Browser* browser() { return browser_; } // For tests. 97 Browser* browser() { return browser_; } // For tests.
97 DevToolsDockSide dock_side() { return dock_side_; } 98 DevToolsDockSide dock_side() { return dock_side_; }
98 99
100 content::RenderViewHost* GetRenderViewHost();
99 content::DevToolsClientHost* GetDevToolsClientHostForTest(); 101 content::DevToolsClientHost* GetDevToolsClientHostForTest();
100 102
101 // Returns preferred devtools window width for given |container_width|. It 103 // Returns preferred devtools window width for given |container_width|. It
102 // tries to use the saved window width, or, if none exists, 1/3 of the 104 // tries to use the saved window width, or, if none exists, 1/3 of the
103 // container width, then clamps to try and ensure both devtools and content 105 // container width, then clamps to try and ensure both devtools and content
104 // are at least somewhat visible. 106 // are at least somewhat visible.
105 // Called only for the case when devtools window is docked to the side. 107 // Called only for the case when devtools window is docked to the side.
106 int GetWidth(int container_width); 108 int GetWidth(int container_width);
107 109
108 // Returns preferred devtools window height for given |container_height|. 110 // Returns preferred devtools window height for given |container_height|.
109 // Uses the same logic as GetWidth. 111 // Uses the same logic as GetWidth.
110 // Called only for the case when devtools window is docked to bottom. 112 // Called only for the case when devtools window is docked to bottom.
111 int GetHeight(int container_height); 113 int GetHeight(int container_height);
112 114
113 // Returns the minimum width devtools window needs.
114 int GetMinimumWidth();
115
116 // Returns the minimum height devtools window needs.
117 int GetMinimumHeight();
118
119 // Stores preferred devtools window width for this instance. 115 // Stores preferred devtools window width for this instance.
120 void SetWidth(int width); 116 void SetWidth(int width);
121 117
122 // Stores preferred devtools window height for this instance. 118 // Stores preferred devtools window height for this instance.
123 void SetHeight(int height); 119 void SetHeight(int height);
124 120
125 // Returns the height in minimized mode. 121 void Show(DevToolsToggleAction action);
126 int GetMinimizedHeight();
127 122
128 private: 123 private:
129 friend class DevToolsControllerTest; 124 friend class DevToolsControllerTest;
125
126 DevToolsWindow(Profile* profile,
127 const GURL& frontend_url,
128 content::RenderViewHost* inspected_rvh,
129 DevToolsDockSide dock_side);
130
130 static DevToolsWindow* Create(Profile* profile, 131 static DevToolsWindow* Create(Profile* profile,
131 const GURL& frontend_url, 132 const GURL& frontend_url,
132 content::RenderViewHost* inspected_rvh, 133 content::RenderViewHost* inspected_rvh,
133 DevToolsDockSide dock_side, 134 DevToolsDockSide dock_side,
134 bool shared_worker_frontend); 135 bool shared_worker_frontend);
135 DevToolsWindow(Profile* profile, 136 static GURL GetDevToolsURL(Profile* profile,
136 const GURL& frontend_url, 137 const GURL& base_url,
137 content::RenderViewHost* inspected_rvh, 138 DevToolsDockSide dock_side,
138 DevToolsDockSide dock_side); 139 bool shared_worker_frontend);
139 140 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*);
140 void CreateDevToolsBrowser(); 141 static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
141 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); 142 static DevToolsDockSide GetDockSideFromPrefs(Profile* profile);
142 BrowserWindow* GetInspectedBrowserWindow(); 143 static std::string SideToString(DevToolsDockSide dock_side);
143 bool IsInspectedBrowserPopup(); 144 static DevToolsDockSide SideFromString(const std::string& dock_side);
144 void UpdateFrontendDockSide();
145 void Hide();
146 145
147 // Overridden from content::NotificationObserver. 146 // Overridden from content::NotificationObserver.
148 virtual void Observe(int type, 147 virtual void Observe(int type,
149 const content::NotificationSource& source, 148 const content::NotificationSource& source,
150 const content::NotificationDetails& details) OVERRIDE; 149 const content::NotificationDetails& details) OVERRIDE;
151 150
152 void ScheduleAction(DevToolsToggleAction action);
153 void DoAction();
154 static GURL GetDevToolsURL(Profile* profile,
155 const GURL& base_url,
156 DevToolsDockSide dock_side,
157 bool shared_worker_frontend);
158 void UpdateTheme();
159 void AddDevToolsExtensionsToClient();
160 void CallClientFunction(const std::string& function_name,
161 const base::Value* arg1 = NULL,
162 const base::Value* arg2 = NULL);
163 // Overridden from content::WebContentsDelegate. 151 // Overridden from content::WebContentsDelegate.
164 virtual content::WebContents* OpenURLFromTab( 152 virtual content::WebContents* OpenURLFromTab(
165 content::WebContents* source, 153 content::WebContents* source,
166 const content::OpenURLParams& params) OVERRIDE; 154 const content::OpenURLParams& params) OVERRIDE;
167 virtual void AddNewContents(content::WebContents* source, 155 virtual void AddNewContents(content::WebContents* source,
168 content::WebContents* new_contents, 156 content::WebContents* new_contents,
169 WindowOpenDisposition disposition, 157 WindowOpenDisposition disposition,
170 const gfx::Rect& initial_pos, 158 const gfx::Rect& initial_pos,
171 bool user_gesture, 159 bool user_gesture,
172 bool* was_blocked) OVERRIDE; 160 bool* was_blocked) OVERRIDE;
173 virtual void CloseContents(content::WebContents* source) OVERRIDE {} 161 virtual void CloseContents(content::WebContents* source) OVERRIDE;
174 virtual bool PreHandleKeyboardEvent( 162 virtual bool PreHandleKeyboardEvent(
175 content::WebContents* source, 163 content::WebContents* source,
176 const content::NativeWebKeyboardEvent& event, 164 const content::NativeWebKeyboardEvent& event,
177 bool* is_keyboard_shortcut) OVERRIDE; 165 bool* is_keyboard_shortcut) OVERRIDE;
178 virtual void HandleKeyboardEvent( 166 virtual void HandleKeyboardEvent(
179 content::WebContents* source, 167 content::WebContents* source,
180 const content::NativeWebKeyboardEvent& event) OVERRIDE; 168 const content::NativeWebKeyboardEvent& event) OVERRIDE;
181 virtual content::JavaScriptDialogManager* 169 virtual content::JavaScriptDialogManager*
182 GetJavaScriptDialogManager() OVERRIDE; 170 GetJavaScriptDialogManager() OVERRIDE;
183 virtual content::ColorChooser* OpenColorChooser( 171 virtual content::ColorChooser* OpenColorChooser(
184 content::WebContents* web_contents, 172 content::WebContents* web_contents,
185 SkColor color) OVERRIDE; 173 SkColor color) OVERRIDE;
186 virtual void RunFileChooser( 174 virtual void RunFileChooser(
187 content::WebContents* web_contents, 175 content::WebContents* web_contents,
188 const content::FileChooserParams& params) OVERRIDE; 176 const content::FileChooserParams& params) OVERRIDE;
189 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 177 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
190 178
191 static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*);
192 static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*);
193
194 // content::DevToolsFrontendHostDelegate overrides. 179 // content::DevToolsFrontendHostDelegate overrides.
195 virtual void ActivateWindow() OVERRIDE; 180 virtual void ActivateWindow() OVERRIDE;
196 virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE; 181 virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE;
197 virtual void CloseWindow() OVERRIDE; 182 virtual void CloseWindow() OVERRIDE;
198 virtual void MoveWindow(int x, int y) OVERRIDE; 183 virtual void MoveWindow(int x, int y) OVERRIDE;
199 virtual void SetDockSide(const std::string& side) OVERRIDE; 184 virtual void SetDockSide(const std::string& side) OVERRIDE;
200 virtual void OpenInNewTab(const std::string& url) OVERRIDE; 185 virtual void OpenInNewTab(const std::string& url) OVERRIDE;
201 virtual void SaveToFile(const std::string& url, 186 virtual void SaveToFile(const std::string& url,
202 const std::string& content, 187 const std::string& content,
203 bool save_as) OVERRIDE; 188 bool save_as) OVERRIDE;
204 virtual void AppendToFile(const std::string& url, 189 virtual void AppendToFile(const std::string& url,
205 const std::string& content) OVERRIDE; 190 const std::string& content) OVERRIDE;
206 virtual void RequestFileSystems() OVERRIDE; 191 virtual void RequestFileSystems() OVERRIDE;
207 virtual void AddFileSystem() OVERRIDE; 192 virtual void AddFileSystem() OVERRIDE;
208 virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; 193 virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE;
209 194
210 // DevToolsFileHelper callbacks. 195 // DevToolsFileHelper callbacks.
211 void FileSavedAs(const std::string& url); 196 void FileSavedAs(const std::string& url);
212 void AppendedTo(const std::string& url); 197 void AppendedTo(const std::string& url);
213 void FileSystemsLoaded( 198 void FileSystemsLoaded(
214 const std::vector<DevToolsFileHelper::FileSystem>& file_systems); 199 const std::vector<DevToolsFileHelper::FileSystem>& file_systems);
200 void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system);
215 void ShowDevToolsConfirmInfoBar( 201 void ShowDevToolsConfirmInfoBar(
216 const string16& message, 202 const string16& message,
217 const base::Callback<void(bool)>& callback); 203 const base::Callback<void(bool)>& callback);
218 void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system);
219 204
205 void CreateDevToolsBrowser();
206 bool FindInspectedBrowserAndTabIndex(Browser**, int* tab);
207 BrowserWindow* GetInspectedBrowserWindow();
208 bool IsInspectedBrowserPopup();
209 void UpdateFrontendDockSide();
210 void Hide();
211 void ScheduleAction(DevToolsToggleAction action);
212 void DoAction();
213 void UpdateTheme();
214 void AddDevToolsExtensionsToClient();
215 void CallClientFunction(const std::string& function_name,
216 const base::Value* arg1 = NULL,
217 const base::Value* arg2 = NULL);
220 void UpdateBrowserToolbar(); 218 void UpdateBrowserToolbar();
221 bool IsDocked(); 219 bool IsDocked();
222 void Restore(); 220 void Restore();
223 static DevToolsDockSide GetDockSideFromPrefs(Profile* profile);
224 static std::string SideToString(DevToolsDockSide dock_side);
225 static DevToolsDockSide SideFromString(const std::string& dock_side);
226
227 content::WebContents* GetInspectedWebContents(); 221 content::WebContents* GetInspectedWebContents();
228 222
229 class InspectedWebContentsObserver; 223 class InspectedWebContentsObserver;
230 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; 224 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_;
231 class FrontendWebContentsObserver; 225 class FrontendWebContentsObserver;
232 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; 226 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_;
233 227
234 Profile* profile_; 228 Profile* profile_;
235 content::WebContents* web_contents_; 229 content::WebContents* web_contents_;
236 Browser* browser_; 230 Browser* browser_;
237 DevToolsDockSide dock_side_; 231 DevToolsDockSide dock_side_;
238 bool is_loaded_; 232 bool is_loaded_;
239 DevToolsToggleAction action_on_load_; 233 DevToolsToggleAction action_on_load_;
240 content::NotificationRegistrar registrar_; 234 content::NotificationRegistrar registrar_;
241 scoped_ptr<content::DevToolsClientHost> frontend_host_; 235 scoped_ptr<content::DevToolsClientHost> frontend_host_;
242 base::WeakPtrFactory<DevToolsWindow> weak_factory_; 236 base::WeakPtrFactory<DevToolsWindow> weak_factory_;
243 scoped_ptr<DevToolsFileHelper> file_helper_; 237 scoped_ptr<DevToolsFileHelper> file_helper_;
244 int width_; 238 int width_;
245 int height_; 239 int height_;
246 DevToolsDockSide dock_side_before_minimized_; 240 DevToolsDockSide dock_side_before_minimized_;
247 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); 241 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
248 }; 242 };
249 243
250 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 244 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | chrome/browser/devtools/devtools_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698