OLD | NEW |
---|---|
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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" | 15 #include "chrome/browser/devtools/devtools_embedder_message_dispatcher.h" |
16 #include "chrome/browser/devtools/devtools_file_helper.h" | 16 #include "chrome/browser/devtools/devtools_file_helper.h" |
17 #include "chrome/browser/devtools/devtools_file_system_indexer.h" | 17 #include "chrome/browser/devtools/devtools_file_system_indexer.h" |
18 #include "chrome/browser/devtools/devtools_toggle_action.h" | 18 #include "chrome/browser/devtools/devtools_toggle_action.h" |
19 #include "content/public/browser/devtools_client_host.h" | 19 #include "content/public/browser/devtools_client_host.h" |
20 #include "content/public/browser/devtools_frontend_host_delegate.h" | 20 #include "content/public/browser/devtools_frontend_host_delegate.h" |
21 #include "content/public/browser/notification_observer.h" | 21 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
23 #include "content/public/browser/web_contents_delegate.h" | 23 #include "content/public/browser/web_contents_delegate.h" |
24 #include "ui/gfx/size.h" | |
24 | 25 |
25 class Browser; | 26 class Browser; |
26 class BrowserWindow; | 27 class BrowserWindow; |
27 class DevToolsControllerTest; | 28 class DevToolsControllerTest; |
28 class Profile; | 29 class Profile; |
29 | 30 |
30 namespace base { | 31 namespace base { |
31 class Value; | 32 class Value; |
32 } | 33 } |
33 | 34 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 90 |
90 // Exposed for testing, normal clients should not use this method. | 91 // Exposed for testing, normal clients should not use this method. |
91 static DevToolsWindow* ToggleDevToolsWindow( | 92 static DevToolsWindow* ToggleDevToolsWindow( |
92 content::RenderViewHost* inspected_rvh, | 93 content::RenderViewHost* inspected_rvh, |
93 bool force_open, | 94 bool force_open, |
94 const DevToolsToggleAction& action); | 95 const DevToolsToggleAction& action); |
95 | 96 |
96 static void InspectElement( | 97 static void InspectElement( |
97 content::RenderViewHost* inspected_rvh, int x, int y); | 98 content::RenderViewHost* inspected_rvh, int x, int y); |
98 | 99 |
99 static int GetMinimumWidth(); | |
100 static int GetMinimumHeight(); | |
101 static int GetMinimizedHeight(); | 100 static int GetMinimizedHeight(); |
102 | 101 |
103 // content::DevToolsFrontendHostDelegate: | 102 // content::DevToolsFrontendHostDelegate: |
104 virtual void InspectedContentsClosing() OVERRIDE; | 103 virtual void InspectedContentsClosing() OVERRIDE; |
105 | 104 |
106 content::WebContents* web_contents() { return web_contents_; } | 105 content::WebContents* web_contents() { return web_contents_; } |
107 Browser* browser() { return browser_; } // For tests. | 106 Browser* browser() { return browser_; } // For tests. |
108 DevToolsDockSide dock_side() const { return dock_side_; } | 107 DevToolsDockSide dock_side() const { return dock_side_; } |
109 | 108 |
110 content::RenderViewHost* GetRenderViewHost(); | 109 content::RenderViewHost* GetRenderViewHost(); |
111 content::DevToolsClientHost* GetDevToolsClientHostForTest(); | 110 content::DevToolsClientHost* GetDevToolsClientHostForTest(); |
112 | 111 |
113 // Returns preferred devtools window width for given |container_width|. It | 112 // Inspected WebContents is placed over DevTools WebContents in docked mode. |
114 // tries to use the saved window width, or, if none exists, 1/3 of the | 113 // The following methods return the top-left and bottom-right offsets of |
115 // container width, then clamps to try and ensure both devtools and content | 114 // inspected WebContents relative to DevTools WebContents. |
116 // are at least somewhat visible. | 115 gfx::Size GetTopLeftContentsOffset() const; |
pfeldman
2013/11/18 14:18:27
gfx::Rect GetContentsRect
dgozman
2013/11/18 14:37:14
The whole idea of offsets is that on resize views
pfeldman
2013/11/20 15:02:08
Ok, sgtm.
Did you measure the overhead though? I
dgozman
2013/11/21 15:08:54
I didn't measure the overhead. But this scenario w
| |
117 // Called only for the case when devtools window is docked to the side. | 116 gfx::Size GetBottomRightContentsOffset() const; |
118 int GetWidth(int container_width); | |
119 | 117 |
120 // Returns preferred devtools window height for given |container_height|. | 118 // Minimum size of the docked DevTools WebContents. This includes |
121 // Uses the same logic as GetWidth. | 119 // the overlaying inspected WebContents size. |
122 // Called only for the case when devtools window is docked to bottom. | 120 gfx::Size GetMinimumSize() const; |
123 int GetHeight(int container_height); | |
124 | |
125 // Stores preferred devtools window width for this instance. | |
126 void SetWidth(int width); | |
127 | |
128 // Stores preferred devtools window height for this instance. | |
129 void SetHeight(int height); | |
130 | 121 |
131 void Show(const DevToolsToggleAction& action); | 122 void Show(const DevToolsToggleAction& action); |
132 | 123 |
133 // BeforeUnload interception //////////////////////////////////////////////// | 124 // BeforeUnload interception //////////////////////////////////////////////// |
134 | 125 |
135 // In order to preserve any edits the user may have made in devtools, the | 126 // In order to preserve any edits the user may have made in devtools, the |
136 // beforeunload event of the inspected page is hooked - devtools gets the | 127 // beforeunload event of the inspected page is hooked - devtools gets the |
137 // first shot at handling beforeunload and presents a dialog to the user. If | 128 // first shot at handling beforeunload and presents a dialog to the user. If |
138 // the user accepts the dialog then the script is given a chance to handle | 129 // the user accepts the dialog then the script is given a chance to handle |
139 // it. This way 2 dialogs may be displayed: one from the devtools asking the | 130 // it. This way 2 dialogs may be displayed: one from the devtools asking the |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 const content::FileChooserParams& params) OVERRIDE; | 258 const content::FileChooserParams& params) OVERRIDE; |
268 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; | 259 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; |
269 | 260 |
270 // content::DevToolsFrontendHostDelegate override: | 261 // content::DevToolsFrontendHostDelegate override: |
271 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; | 262 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; |
272 | 263 |
273 // DevToolsEmbedderMessageDispatcher::Delegate overrides: | 264 // DevToolsEmbedderMessageDispatcher::Delegate overrides: |
274 virtual void ActivateWindow() OVERRIDE; | 265 virtual void ActivateWindow() OVERRIDE; |
275 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; | 266 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; |
276 virtual void CloseWindow() OVERRIDE; | 267 virtual void CloseWindow() OVERRIDE; |
277 virtual void SetWindowBounds(int x, int y, int width, int height) OVERRIDE; | 268 virtual void SetContentsOffsets( |
269 int left, int top, int right, int bottom) OVERRIDE; | |
278 virtual void MoveWindow(int x, int y) OVERRIDE; | 270 virtual void MoveWindow(int x, int y) OVERRIDE; |
279 virtual void SetDockSide(const std::string& side) OVERRIDE; | 271 virtual void SetDockSide(const std::string& side) OVERRIDE; |
280 virtual void OpenInNewTab(const std::string& url) OVERRIDE; | 272 virtual void OpenInNewTab(const std::string& url) OVERRIDE; |
281 virtual void SaveToFile(const std::string& url, | 273 virtual void SaveToFile(const std::string& url, |
282 const std::string& content, | 274 const std::string& content, |
283 bool save_as) OVERRIDE; | 275 bool save_as) OVERRIDE; |
284 virtual void AppendToFile(const std::string& url, | 276 virtual void AppendToFile(const std::string& url, |
285 const std::string& content) OVERRIDE; | 277 const std::string& content) OVERRIDE; |
286 virtual void RequestFileSystems() OVERRIDE; | 278 virtual void RequestFileSystems() OVERRIDE; |
287 virtual void AddFileSystem() OVERRIDE; | 279 virtual void AddFileSystem() OVERRIDE; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 DevToolsToggleAction action_on_load_; | 339 DevToolsToggleAction action_on_load_; |
348 content::NotificationRegistrar registrar_; | 340 content::NotificationRegistrar registrar_; |
349 scoped_ptr<content::DevToolsClientHost> frontend_host_; | 341 scoped_ptr<content::DevToolsClientHost> frontend_host_; |
350 scoped_ptr<DevToolsFileHelper> file_helper_; | 342 scoped_ptr<DevToolsFileHelper> file_helper_; |
351 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; | 343 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; |
352 typedef std::map< | 344 typedef std::map< |
353 int, | 345 int, |
354 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > | 346 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > |
355 IndexingJobsMap; | 347 IndexingJobsMap; |
356 IndexingJobsMap indexing_jobs_; | 348 IndexingJobsMap indexing_jobs_; |
357 int width_; | 349 gfx::Size top_left_contents_offset_; |
358 int height_; | 350 gfx::Size bottom_right_contents_offset_; |
359 DevToolsDockSide dock_side_before_minimized_; | 351 DevToolsDockSide dock_side_before_minimized_; |
360 // True if we're in the process of handling a beforeunload event originating | 352 // True if we're in the process of handling a beforeunload event originating |
361 // from the inspected webcontents, see InterceptPageBeforeUnload for details. | 353 // from the inspected webcontents, see InterceptPageBeforeUnload for details. |
362 bool intercepted_page_beforeunload_; | 354 bool intercepted_page_beforeunload_; |
363 | 355 |
364 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; | 356 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; |
365 base::WeakPtrFactory<DevToolsWindow> weak_factory_; | 357 base::WeakPtrFactory<DevToolsWindow> weak_factory_; |
366 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); | 358 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); |
367 }; | 359 }; |
368 | 360 |
369 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ | 361 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ |
OLD | NEW |