diff options
author | ojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-02 00:44:47 +0000 |
---|---|---|
committer | ojan@google.com <ojan@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-02 00:44:47 +0000 |
commit | 04b4a6c37ac2250bc4e7230c24801d5cf9ffd8e7 (patch) | |
tree | 1e67976bfec449d5f6c4b209630491a4bfde3ffc /chrome/browser/browser.h | |
parent | 9e43dae7106b6064ebc6580fe111568f1cbdd393 (diff) | |
download | chromium_src-04b4a6c37ac2250bc4e7230c24801d5cf9ffd8e7.zip chromium_src-04b4a6c37ac2250bc4e7230c24801d5cf9ffd8e7.tar.gz chromium_src-04b4a6c37ac2250bc4e7230c24801d5cf9ffd8e7.tar.bz2 |
A bunch of cleanups to beforeunload/unload handling.
1. Remove all the is_closing_browser plumbing. WebContents/TabContents/RenderViewHost/etc really shouldn't (and don't!) need to know anything about whether we're closing the browser or not.
2. Refactor the handling of beforeunload/unload state in browser.cc. I think this makes it considerably easier to reason about the correctness of it.
3. Added a couple TODOs for future cleanups that would have made this change a bit too large.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.h')
-rw-r--r-- | chrome/browser/browser.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index ba4133e..a172df8 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -187,8 +187,12 @@ class Browser : public TabStripModelDelegate, // Tells us that we've finished firing this tab's beforeunload event. // The proceed bool tells us whether the user chose to proceed closing the - // tab. - void BeforeUnloadFired(TabContents* source, bool proceed); + // tab. Returns true if the tab can continue on firing it's unload event. + // If we're closing the entire browser, then we'll want to delay firing + // unload events until all the beforeunload events have fired. + void BeforeUnloadFired(TabContents* source, + bool proceed, + bool* proceed_to_fire_unload); // Tells us that we've finished firing this tab's unload event. void UnloadFired(TabContents* source); @@ -512,13 +516,19 @@ class Browser : public TabStripModelDelegate, TabContents* new_contents, const gfx::Rect& initial_pos); - // Processes the next tab that needs it's beforeunload event fired before - // we can proceed with closing the browser. - void ProcessPendingBeforeUnloadTabs(); + // Processes the next tab that needs it's beforeunload/unload event fired. + void ProcessPendingTabs(); - // Processes the next tab that needs it's unload event fired before we can - // proceed with closing the browser. - void ProcessPendingUnloadTabs(); + // Whether we've completed firing all the tabs' beforeunload/unload events. + bool HasCompletedUnloadProcessing(); + + // Clears all the state associated with processing tabs' beforeunload/unload + // events since the user cancelled closing the window. + void CancelWindowClose(); + + // Removes the tab from the associated vector. Returns whether the tab + // was in the vector in the first place. + bool RemoveFromVector(UnloadListenerVector* vector, TabContents* tab); // Cleans up state appropriately when we are trying to close the browser // and a tab crashes in it's beforeunload/unload handler. @@ -572,7 +582,7 @@ class Browser : public TabStripModelDelegate, // Whether we are processing the beforeunload and unload events of each tab // in preparation for closing the browser. - bool is_processing_tab_unload_events_; + bool is_attempting_to_close_browser_; // The following factory is used for chrome update coalescing. ScopedRunnableMethodFactory<Browser> chrome_updater_factory_; |