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

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

Issue 23835007: DevTools: Do not close devtools if there are dirty files in workspace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Jeremy's comments Created 7 years, 1 month 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 int GetHeight(int container_height); 123 int GetHeight(int container_height);
124 124
125 // Stores preferred devtools window width for this instance. 125 // Stores preferred devtools window width for this instance.
126 void SetWidth(int width); 126 void SetWidth(int width);
127 127
128 // Stores preferred devtools window height for this instance. 128 // Stores preferred devtools window height for this instance.
129 void SetHeight(int height); 129 void SetHeight(int height);
130 130
131 void Show(const DevToolsToggleAction& action); 131 void Show(const DevToolsToggleAction& action);
132 132
133 // BeforeUnload interception ////////////////////////////////////////////////
134
135 // 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
137 // 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
139 // it. This way 2 dialogs may be displayed: one from the DevTools asking the
140 // user to confirm that they're ok with their devtools edits going away and
jeremy 2013/11/14 08:53:13 nit: devtools -> DevTools
lushnikov 2013/11/14 09:49:39 Converted everything to "devtools" instead as this
141 // another from the webpage as the result of its beforeunload handler.
142 // The following set of methods handle beforeunload event flow through
143 // DevTools window. When the |contents| with DevTools opened on them are
144 // getting closed, the following sequence of calls takes place:
145 // 1. |DevToolsWindow::InterceptPageBeforeUnload| is called and indicates
146 // whether DevTools intercept the beforeunload event.
147 // If InterceptPageBeforeUnload() returns true then the following steps
148 // will take place; otherwise only step 4 will be reached.
jeremy 2013/11/14 08:53:13 reached -> reached and none of the corresponding f
lushnikov 2013/11/14 09:49:39 Done.
149 // 2. |DevToolsWindow::InterceptPageBeforeUnload| fires beforeunload event
150 // for DevTools frontend, which will asynchronously call
151 // |WebContentsDelegate::BeforeUnloadFired| method.
152 // In case of docked DevTools window, DevTools are set as a delegate for
153 // its frontend, so method |DevToolsWindow::BeforeUnloadFired| will be
154 // called directly.
155 // If DevTools window is undocked it's not set as the delegate so the call
156 // to BeforeUnloadFired is proxied through HandleBeforeUnload() rather
157 // than getting called directly.
158 // 3a. If |DevToolsWindow::BeforeUnloadFired| is called with |proceed|=false
159 // it calls throught to the content's BeforeUnloadFired(), which from the
160 // WebContents perspective looks the same as the |content|'s own
161 // beforeunload dialog having had it's 'stay on this page' button clicked.
162 // 3b. If |DevToolsWindow::BeforeUnloadFired| was called with |proceed|
jeremy 2013/11/14 08:53:13 Replace everything up to ',' with: If |proceed| =
lushnikov 2013/11/14 09:49:39 Done.
163 // argument set to true, then it fires beforeunload event on |contents|
164 // and everything proceeds as it normally would without the Devtools
165 // interception.
166 // 4. If the user cancels the dialog put up by either the WebContents or
167 // DevTools frontend, then |contents|'s |BeforeUnloadFired| callback is
168 // called with the proceed argument set to false, this causes
169 // |DevToolsWindow::OnPageCloseCancelled| to be called.
170
171 // DevTools window in undocked state is not set as a delegate of
172 // its frontend. Instead, an instance of browser is set as the delegate, and
173 // thus beforeunload event callback from DevTools frontend is not delivered
174 // to the instance of DevTools window, which is solely responsible for
175 // managing custom beforeunload event flow.
176 // This is a helper method to route callback from
177 // |Browser::BeforeUnloadFired| back to |DevToolsWindow::BeforeUnloadFired|.
178 // * |proceed| - true if the user clicked 'ok' in the beforeunload dialog,
179 // false otherwise.
180 // * |proceed_to_fire_unload| - output parameter, whether we should continue
181 // to fire the unload event or stop things here.
182 // Returns true if DevTools window is in a state of intercepting beforeunload
183 // event and if it will manage unload process on its own.
184 static bool HandleBeforeUnload(content::WebContents* contents,
185 bool proceed,
186 bool* proceed_to_fire_unload);
187
188 // Returns true if this contents beforeunload event was intercepted by
189 // DevTools and false otherwise. If the event was intercepted, caller should
190 // not fire beforeunlaod event on |contents| itself as DevTools window will
191 // take care of it, otherwise caller should continue handling the event as
192 // usual.
193 static bool InterceptPageBeforeUnload(content::WebContents* contents);
194
195 // Returns true if DevTools browser has already fired its beforeunload event
196 // as a result of beforeunload event interception.
197 static bool HasFiredBeforeUnloadEventForDevToolsBrowser(Browser* browser);
198
199 // Returns true if DevTools window would like to hook beforeunload event
200 // of this |contents|.
201 static bool NeedsToInterceptBeforeUnload(content::WebContents* contents);
202
203 // Notify DevTools window that closing of |contents| was cancelled
204 // by user.
205 static void OnPageCloseCanceled(content::WebContents* contents);
206
207 void SetDockSideForTest(DevToolsDockSide dock_side);
208
133 private: 209 private:
134 friend class DevToolsControllerTest; 210 friend class DevToolsControllerTest;
135 211
136 DevToolsWindow(Profile* profile, 212 DevToolsWindow(Profile* profile,
137 const GURL& frontend_url, 213 const GURL& frontend_url,
138 content::RenderViewHost* inspected_rvh, 214 content::RenderViewHost* inspected_rvh,
139 DevToolsDockSide dock_side); 215 DevToolsDockSide dock_side);
140 216
141 static DevToolsWindow* Create(Profile* profile, 217 static DevToolsWindow* Create(Profile* profile,
142 const GURL& frontend_url, 218 const GURL& frontend_url,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 scoped_ptr<DevToolsFileHelper> file_helper_; 350 scoped_ptr<DevToolsFileHelper> file_helper_;
275 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; 351 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_;
276 typedef std::map< 352 typedef std::map<
277 int, 353 int,
278 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > 354 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
279 IndexingJobsMap; 355 IndexingJobsMap;
280 IndexingJobsMap indexing_jobs_; 356 IndexingJobsMap indexing_jobs_;
281 int width_; 357 int width_;
282 int height_; 358 int height_;
283 DevToolsDockSide dock_side_before_minimized_; 359 DevToolsDockSide dock_side_before_minimized_;
360 bool inspected_page_is_closing_;
jeremy 2013/11/14 08:53:13 Can you add a comment explaining what this does?
lushnikov 2013/11/14 09:49:39 Done.
284 361
285 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; 362 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
286 base::WeakPtrFactory<DevToolsWindow> weak_factory_; 363 base::WeakPtrFactory<DevToolsWindow> weak_factory_;
287 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); 364 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
288 }; 365 };
289 366
290 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 367 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698