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

Side by Side Diff: chrome/browser/ui/browser.h

Issue 2681203002: Add Browser::SkipCallBeforeUnload so that the browser windows can be closed regardless of beforeunl… (Closed)
Patch Set: comments Created 3 years, 10 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
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_UI_BROWSER_H_ 5 #ifndef CHROME_BROWSER_UI_BROWSER_H_
6 #define CHROME_BROWSER_UI_BROWSER_H_ 6 #define CHROME_BROWSER_UI_BROWSER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 bool include_app_name, 310 bool include_app_name,
311 content::WebContents* contents) const; 311 content::WebContents* contents) const;
312 312
313 // Prepares a title string for display (removes embedded newlines, etc). 313 // Prepares a title string for display (removes embedded newlines, etc).
314 static void FormatTitleForDisplay(base::string16* title); 314 static void FormatTitleForDisplay(base::string16* title);
315 315
316 // OnBeforeUnload handling ////////////////////////////////////////////////// 316 // OnBeforeUnload handling //////////////////////////////////////////////////
317 317
318 // Gives beforeunload handlers the chance to cancel the close. Returns whether 318 // Gives beforeunload handlers the chance to cancel the close. Returns whether
319 // to proceed with the close. If called while the process begun by 319 // to proceed with the close. If called while the process begun by
320 // CallBeforeUnloadHandlers is in progress, returns false without taking 320 // TryToCloseWindow is in progress, returns false without taking action.
321 // action.
322 bool ShouldCloseWindow(); 321 bool ShouldCloseWindow();
323 322
324 // Begins the process of confirming whether the associated browser can be 323 // Begins the process of confirming whether the associated browser can be
325 // closed. If there are no tabs with beforeunload handlers it will immediately 324 // closed. If there are no tabs with beforeunload handlers it will immediately
326 // return false. Otherwise, it starts prompting the user, returns true and 325 // return false. If |skip_before_unload_event| is true, all beforeunload
Charlie Reis 2017/02/27 21:47:51 Please add a very clear disclaimer here that befor
zmin 2017/03/06 23:58:08 Done.
327 // will call |on_close_confirmed| with the result of the user's decision. 326 // handlers will be skipped and window closing will be confirmed without
327 // showing the prompt, the function will return false as well.
328 // Otherwise, it starts prompting the user, returns true and will call
329 // |on_close_confirmed| with the result of the user's decision.
328 // After calling this function, if the window will not be closed, call 330 // After calling this function, if the window will not be closed, call
329 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling 331 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling
330 // this function multiple times without an intervening call to 332 // this function multiple times without an intervening call to
331 // ResetBeforeUnloadHandlers() will run only the beforeunload handlers 333 // ResetTryToCloseWindow() will run only the beforeunload handlers
332 // registered since the previous call. 334 // registered since the previous call.
333 bool CallBeforeUnloadHandlers( 335 bool TryToCloseWindow(bool skip_before_unload_event,
Charlie Reis 2017/02/27 21:47:51 You can probably simplify all of these to skip_bef
zmin 2017/03/06 23:58:08 Done.
334 const base::Callback<void(bool)>& on_close_confirmed); 336 const base::Callback<void(bool)>& on_close_confirmed);
335 337
336 // Clears the results of any beforeunload confirmation dialogs triggered by a 338 // Clears the results of any beforeunload confirmation dialogs triggered by a
337 // CallBeforeUnloadHandlers call. 339 // TryToCloseWindow call.
338 void ResetBeforeUnloadHandlers(); 340 void ResetTryToCloseWindow();
339 341
340 // Figure out if there are tabs that have beforeunload handlers. 342 // Figure out if there are tabs that have beforeunload handlers.
341 // It starts beforeunload/unload processing as a side-effect. 343 // It starts beforeunload/unload processing as a side-effect.
342 bool TabsNeedBeforeUnloadFired(); 344 bool TabsNeedBeforeUnloadFired();
343 345
344 // Returns true if all tabs' beforeunload/unload events have fired. 346 // Returns true if all tabs' beforeunload/unload events have fired.
345 bool HasCompletedUnloadProcessing() const; 347 bool HasCompletedUnloadProcessing() const;
346 348
347 bool IsAttemptingToCloseBrowser() const; 349 bool IsAttemptingToCloseBrowser() const;
348 350
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 // The following factory is used for chrome update coalescing. 1019 // The following factory is used for chrome update coalescing.
1018 base::WeakPtrFactory<Browser> chrome_updater_factory_; 1020 base::WeakPtrFactory<Browser> chrome_updater_factory_;
1019 1021
1020 // The following factory is used to close the frame at a later time. 1022 // The following factory is used to close the frame at a later time.
1021 base::WeakPtrFactory<Browser> weak_factory_; 1023 base::WeakPtrFactory<Browser> weak_factory_;
1022 1024
1023 DISALLOW_COPY_AND_ASSIGN(Browser); 1025 DISALLOW_COPY_AND_ASSIGN(Browser);
1024 }; 1026 };
1025 1027
1026 #endif // CHROME_BROWSER_UI_BROWSER_H_ 1028 #endif // CHROME_BROWSER_UI_BROWSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698