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

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: addressing 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 edits going away and another
jeremy 2013/11/13 10:52:34 *devtools edits
lushnikov 2013/11/13 13:39:08 Done.
141 // 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. Instead of firing beforeunload event on |contents|,
146 // method |DevToolsWindow::InterceptPageBeforeUnload| gets called.
jeremy 2013/11/13 10:52:34 How about something like: 1. |DevToolsWindow::Inte
lushnikov 2013/11/13 13:39:08 Reworded and put smth like this
147 // 2. |DevToolsWindow::InterceptPageBeforeUnload| fires beforeunload event
148 // for DevTools frontend, which will asynchronously call
149 // |WebContentsDelegate::BeforeUnloadFired| method with the boolean
150 // argument describing user decision if he wants to close DevTools.
jeremy 2013/11/13 10:52:34 remove "with the boolean" till end of sentence
lushnikov 2013/11/13 13:39:08 Done.
151 // In case of docked DevTools window, DevTools are set as a delegate for
152 // its frontend, so method |DevToolsWindow::BeforeUnloadFired| will be
153 // called. But if DevTools window is undocked, then method
154 // |Browser::BeforeUnloadFired| will be called, and then with the help of
155 // proxying |DevToolsWindow::HandleBeforeUnload| method will end up
156 // in |DevToolsWindow::BeforeUnloadFired| as well.
jeremy 2013/11/13 10:52:34 For the rest of this, how about something like: If
lushnikov 2013/11/13 13:39:08 Done.
157 // 3a. If |DevToolsWindow::BeforeUnloadFired| was called with |proceed|
158 // argument set to false, then it calls method
159 // |WebContentsDelegate::BeforeUnloadFired| on |contents|
160 // delegate with the |proceed| argument set to false. This looks as if
161 // |contents| got its beforeunload event fired and user rejected page
162 // close.
jeremy 2013/11/13 10:52:34 If |DevToolsWindow::BeforeUnloadFired| is called w
lushnikov 2013/11/13 13:39:08 Done.
163 // 3b. If |DevToolsWindow::BeforeUnloadFired| was called with |proceed|
164 // argument set to true, then it fires beforeunload event on |contents|
165 // and everything proceeds as it normally would without the Devtools
166 // interception.
167 // 4. If the user cancels the dialog put up by either the WebContents or
168 // DevTools frontend, then |contents|'s |BeforeUnloadFired| callback is
169 // called with the proceed argument set to false, this causes
170 // |DevToolsWindow::OnPageCloseCancelled| to be called.
171
172 // DevTools window in undocked state is not set as a delegate of
173 // its frontend. Instead, an instance of browser is set as the delegate, and
174 // thus beforeunload event callback from DevTools frontend is not delivered
175 // to the instance of DevTools window, which is solely responsible for
176 // managing custom beforeunload event flow.
177 // This is a helper method to route callback from
178 // |Browser::BeforeUnloadFired| back to |DevToolsWindow::BeforeUnloadFired|.
179 // The |proceed| bool tells us if the user chose to proceed closing the
180 // |contents|, and out parameter |proceed_to_fire_unload| signals whether the
181 // method client should continue to fire unload event.
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.
jeremy 2013/11/13 10:52:34 * |proceed| - true if the user clicked 'ok' in the
lushnikov 2013/11/13 13:39:08 Done.
184 static bool HandleBeforeUnload(content::WebContents* contents,
185 bool proceed,
186 bool* proceed_to_fire_unload);
187
188 // This function returns true if there is a DevTools window inspecting
189 // given |contents| which would like to intercept beforeunload events as
190 // described above. In this case clients should not fire beforeunload
191 // event on |contents| themselfes as DevTools window will take care of it.
jeremy 2013/11/13 10:52:34 // Sends a beforeunload event to the Devtools fro
lushnikov 2013/11/13 13:39:08 Done.
192 static bool InterceptPageBeforeUnload(content::WebContents* contents);
193
194 // Returns true if DevTools browser has already fired its beforeunload event
195 // as a result of beforeunload event interception.
196 static bool HasFiredBeforeUnloadEventForDevToolsBrowser(Browser* browser);
197
198 // Returns true if DevTools window would like to hook beforeunload event
199 // of this |contents|.
200 static bool NeedsToInterceptBeforeUnload(content::WebContents* contents);
201
202 // Notify DevTools window that closing of |contents| was cancelled
203 // by user.
204 static void OnPageCloseCanceled(content::WebContents* contents);
205
206 void SetDockSideForTest(DevToolsDockSide dock_side);
207
133 private: 208 private:
134 friend class DevToolsControllerTest; 209 friend class DevToolsControllerTest;
135 210
136 DevToolsWindow(Profile* profile, 211 DevToolsWindow(Profile* profile,
137 const GURL& frontend_url, 212 const GURL& frontend_url,
138 content::RenderViewHost* inspected_rvh, 213 content::RenderViewHost* inspected_rvh,
139 DevToolsDockSide dock_side); 214 DevToolsDockSide dock_side);
140 215
141 static DevToolsWindow* Create(Profile* profile, 216 static DevToolsWindow* Create(Profile* profile,
142 const GURL& frontend_url, 217 const GURL& frontend_url,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 scoped_ptr<DevToolsFileHelper> file_helper_; 349 scoped_ptr<DevToolsFileHelper> file_helper_;
275 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_; 350 scoped_refptr<DevToolsFileSystemIndexer> file_system_indexer_;
276 typedef std::map< 351 typedef std::map<
277 int, 352 int,
278 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> > 353 scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob> >
279 IndexingJobsMap; 354 IndexingJobsMap;
280 IndexingJobsMap indexing_jobs_; 355 IndexingJobsMap indexing_jobs_;
281 int width_; 356 int width_;
282 int height_; 357 int height_;
283 DevToolsDockSide dock_side_before_minimized_; 358 DevToolsDockSide dock_side_before_minimized_;
359 bool inspected_page_is_closing_;
284 360
285 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_; 361 scoped_ptr<DevToolsEmbedderMessageDispatcher> embedder_message_dispatcher_;
286 base::WeakPtrFactory<DevToolsWindow> weak_factory_; 362 base::WeakPtrFactory<DevToolsWindow> weak_factory_;
287 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); 363 DISALLOW_COPY_AND_ASSIGN(DevToolsWindow);
288 }; 364 };
289 365
290 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ 366 #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698