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

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

Issue 63173016: DevTools: place DevTools WebContents underneath inspected WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
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
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;
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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 const content::FileChooserParams& params) OVERRIDE; 259 const content::FileChooserParams& params) OVERRIDE;
269 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; 260 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
270 261
271 // content::DevToolsFrontendHostDelegate override: 262 // content::DevToolsFrontendHostDelegate override:
272 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE; 263 virtual void DispatchOnEmbedder(const std::string& message) OVERRIDE;
273 264
274 // DevToolsEmbedderMessageDispatcher::Delegate overrides: 265 // DevToolsEmbedderMessageDispatcher::Delegate overrides:
275 virtual void ActivateWindow() OVERRIDE; 266 virtual void ActivateWindow() OVERRIDE;
276 virtual void ActivateContents(content::WebContents* contents) OVERRIDE; 267 virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
277 virtual void CloseWindow() OVERRIDE; 268 virtual void CloseWindow() OVERRIDE;
278 virtual void SetWindowBounds(int x, int y, int width, int height) OVERRIDE; 269 virtual void SetContentsOffsets(
270 int left, int top, int right, int bottom) OVERRIDE;
279 virtual void MoveWindow(int x, int y) OVERRIDE; 271 virtual void MoveWindow(int x, int y) OVERRIDE;
280 virtual void SetDockSide(const std::string& side) OVERRIDE; 272 virtual void SetDockSide(const std::string& side) OVERRIDE;
281 virtual void OpenInNewTab(const std::string& url) OVERRIDE; 273 virtual void OpenInNewTab(const std::string& url) OVERRIDE;
282 virtual void SaveToFile(const std::string& url, 274 virtual void SaveToFile(const std::string& url,
283 const std::string& content, 275 const std::string& content,
284 bool save_as) OVERRIDE; 276 bool save_as) OVERRIDE;
285 virtual void AppendToFile(const std::string& url, 277 virtual void AppendToFile(const std::string& url,
286 const std::string& content) OVERRIDE; 278 const std::string& content) OVERRIDE;
287 virtual void RequestFileSystems() OVERRIDE; 279 virtual void RequestFileSystems() OVERRIDE;
288 virtual void AddFileSystem() OVERRIDE; 280 virtual void AddFileSystem() OVERRIDE;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 329
338 class InspectedWebContentsObserver; 330 class InspectedWebContentsObserver;
339 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; 331 scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_;
340 class FrontendWebContentsObserver; 332 class FrontendWebContentsObserver;
341 friend class FrontendWebContentsObserver; 333 friend class FrontendWebContentsObserver;
342 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; 334 scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_;
343 335
344 Profile* profile_; 336 Profile* profile_;
345 content::WebContents* web_contents_; 337 content::WebContents* web_contents_;
346 Browser* browser_; 338 Browser* browser_;
339 // TODO(dgozman): move dock side knowledge entirely to frontend.
347 DevToolsDockSide dock_side_; 340 DevToolsDockSide dock_side_;
348 bool is_loaded_; 341 bool is_loaded_;
349 DevToolsToggleAction action_on_load_; 342 DevToolsToggleAction action_on_load_;
350 content::NotificationRegistrar registrar_; 343 content::NotificationRegistrar registrar_;
351 scoped_ptr<content::DevToolsClientHost> frontend_host_; 344 scoped_ptr<content::DevToolsClientHost> frontend_host_;
352 scoped_ptr<DevToolsFileHelper> file_helper_; 345 scoped_ptr<DevToolsFileHelper> file_helper_;
353 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; 346 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_;
354 typedef std::map< 347 typedef std::map<
355 int, 348 int,
356 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > 349 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
357 IndexingJobsMap; 350 IndexingJobsMap;
358 IndexingJobsMap indexing_jobs_; 351 IndexingJobsMap indexing_jobs_;
359 int width_; 352 gfx::Size top_left_contents_offset_;
360 int height_; 353 gfx::Size bottom_right_contents_offset_;
361 DevToolsDockSide dock_side_before_minimized_; 354 DevToolsDockSide dock_side_before_minimized_;
362 // True if we're in the process of handling a beforeunload event originating 355 // True if we're in the process of handling a beforeunload event originating
363 // from the inspected webcontents, see InterceptPageBeforeUnload for details. 356 // from the inspected webcontents, see InterceptPageBeforeUnload for details.
364 bool intercepted_page_beforeunload_; 357 bool intercepted_page_beforeunload_;
365 358
366 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; 359 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
367 base::WeakPtrFactory<DevToolsWindow> weak_factory_; 360 base::WeakPtrFactory<DevToolsWindow> weak_factory_;
368 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); 361 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
369 }; 362 };
370 363
371 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 364 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698