Chromium Code Reviews| 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_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 Loading... | |
| 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. Otherwise, it starts prompting the user, returns true and |
| 327 // will call |on_close_confirmed| with the result of the user's decision. | 326 // will call |on_close_confirmed| with the result of the user's decision. |
| 328 // After calling this function, if the window will not be closed, call | 327 // After calling this function, if the window will not be closed, call |
| 329 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling | 328 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling |
|
sky
2017/02/13 16:55:51
Update comment.
| |
| 330 // this function multiple times without an intervening call to | 329 // this function multiple times without an intervening call to |
| 331 // ResetBeforeUnloadHandlers() will run only the beforeunload handlers | 330 // ResetCloseWindow() will run only the beforeunload handlers |
| 332 // registered since the previous call. | 331 // registered since the previous call. |
| 333 bool CallBeforeUnloadHandlers( | 332 // If |skip_before_unload_event| is set to true, all prompting will be |
|
sky
2017/02/13 16:55:51
I'm confused by the behavior of skip_before_unload
| |
| 334 const base::Callback<void(bool)>& on_close_confirmed); | 333 // skipped as user confirm the dialog. |on_close_confirmed| will always |
| 334 // be called. | |
| 335 bool TryToCloseWindow(bool skip_before_unload_event, | |
| 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 ResetCloseWindow(); |
|
sky
2017/02/13 16:55:51
It isn't obvious from this name it ties with TryTo
| |
| 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 Loading... | |
| 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_ |
| OLD | NEW |