| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 bool include_app_name, | 317 bool include_app_name, |
| 318 content::WebContents* contents) const; | 318 content::WebContents* contents) const; |
| 319 | 319 |
| 320 // Prepares a title string for display (removes embedded newlines, etc). | 320 // Prepares a title string for display (removes embedded newlines, etc). |
| 321 static void FormatTitleForDisplay(base::string16* title); | 321 static void FormatTitleForDisplay(base::string16* title); |
| 322 | 322 |
| 323 // OnBeforeUnload handling ////////////////////////////////////////////////// | 323 // OnBeforeUnload handling ////////////////////////////////////////////////// |
| 324 | 324 |
| 325 // Gives beforeunload handlers the chance to cancel the close. Returns whether | 325 // Gives beforeunload handlers the chance to cancel the close. Returns whether |
| 326 // to proceed with the close. If called while the process begun by | 326 // to proceed with the close. If called while the process begun by |
| 327 // CallBeforeUnloadHandlers is in progress, returns false without taking | 327 // TryToCloseWindow is in progress, returns false without taking action. |
| 328 // action. | |
| 329 bool ShouldCloseWindow(); | 328 bool ShouldCloseWindow(); |
| 330 | 329 |
| 331 // Begins the process of confirming whether the associated browser can be | 330 // Begins the process of confirming whether the associated browser can be |
| 332 // closed. If there are no tabs with beforeunload handlers it will immediately | 331 // closed. If there are no tabs with beforeunload handlers it will immediately |
| 333 // return false. Otherwise, it starts prompting the user, returns true and | 332 // return false. If |skip_beforeunload| is true, all beforeunload |
| 334 // will call |on_close_confirmed| with the result of the user's decision. | 333 // handlers will be skipped and window closing will be confirmed without |
| 334 // showing the prompt, the function will return false as well. |
| 335 // Otherwise, it starts prompting the user, returns true and will call |
| 336 // |on_close_confirmed| with the result of the user's decision. |
| 335 // After calling this function, if the window will not be closed, call | 337 // After calling this function, if the window will not be closed, call |
| 336 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling | 338 // ResetBeforeUnloadHandlers() to reset all beforeunload handlers; calling |
| 337 // this function multiple times without an intervening call to | 339 // this function multiple times without an intervening call to |
| 338 // ResetBeforeUnloadHandlers() will run only the beforeunload handlers | 340 // ResetTryToCloseWindow() will run only the beforeunload handlers |
| 339 // registered since the previous call. | 341 // registered since the previous call. |
| 340 bool CallBeforeUnloadHandlers( | 342 // Note that if the browser window has been used before, users should always |
| 341 const base::Callback<void(bool)>& on_close_confirmed); | 343 // have a chance to save their work before the window is closed without |
| 344 // triggering beforeunload event. |
| 345 bool TryToCloseWindow(bool skip_beforeunload, |
| 346 const base::Callback<void(bool)>& on_close_confirmed); |
| 342 | 347 |
| 343 // Clears the results of any beforeunload confirmation dialogs triggered by a | 348 // Clears the results of any beforeunload confirmation dialogs triggered by a |
| 344 // CallBeforeUnloadHandlers call. | 349 // TryToCloseWindow call. |
| 345 void ResetBeforeUnloadHandlers(); | 350 void ResetTryToCloseWindow(); |
| 346 | 351 |
| 347 // Figure out if there are tabs that have beforeunload handlers. | 352 // Figure out if there are tabs that have beforeunload handlers. |
| 348 // It starts beforeunload/unload processing as a side-effect. | 353 // It starts beforeunload/unload processing as a side-effect. |
| 349 bool TabsNeedBeforeUnloadFired(); | 354 bool TabsNeedBeforeUnloadFired(); |
| 350 | 355 |
| 351 // Returns true if all tabs' beforeunload/unload events have fired. | 356 // Returns true if all tabs' beforeunload/unload events have fired. |
| 352 bool HasCompletedUnloadProcessing() const; | 357 bool HasCompletedUnloadProcessing() const; |
| 353 | 358 |
| 354 bool IsAttemptingToCloseBrowser() const; | 359 bool IsAttemptingToCloseBrowser() const; |
| 355 | 360 |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 // The following factory is used for chrome update coalescing. | 1035 // The following factory is used for chrome update coalescing. |
| 1031 base::WeakPtrFactory<Browser> chrome_updater_factory_; | 1036 base::WeakPtrFactory<Browser> chrome_updater_factory_; |
| 1032 | 1037 |
| 1033 // The following factory is used to close the frame at a later time. | 1038 // The following factory is used to close the frame at a later time. |
| 1034 base::WeakPtrFactory<Browser> weak_factory_; | 1039 base::WeakPtrFactory<Browser> weak_factory_; |
| 1035 | 1040 |
| 1036 DISALLOW_COPY_AND_ASSIGN(Browser); | 1041 DISALLOW_COPY_AND_ASSIGN(Browser); |
| 1037 }; | 1042 }; |
| 1038 | 1043 |
| 1039 #endif // CHROME_BROWSER_UI_BROWSER_H_ | 1044 #endif // CHROME_BROWSER_UI_BROWSER_H_ |
| OLD | NEW |