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_UNLOAD_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 public: | 29 public: |
30 explicit UnloadController(Browser* browser); | 30 explicit UnloadController(Browser* browser); |
31 virtual ~UnloadController(); | 31 virtual ~UnloadController(); |
32 | 32 |
33 // Returns true if |contents| can be cleanly closed. When |browser_| is being | 33 // Returns true if |contents| can be cleanly closed. When |browser_| is being |
34 // closed, this function will return false to indicate |contents| should not | 34 // closed, this function will return false to indicate |contents| should not |
35 // be cleanly closed, since the fast shutdown path will just kill its | 35 // be cleanly closed, since the fast shutdown path will just kill its |
36 // renderer. | 36 // renderer. |
37 bool CanCloseContents(content::WebContents* contents); | 37 bool CanCloseContents(content::WebContents* contents); |
38 | 38 |
| 39 // Returns true if we need to run unload events for the |contents|. |
| 40 static bool ShouldRunUnloadEventsHelper(content::WebContents* contents); |
| 41 |
39 // Helper function to run beforeunload listeners on a WebContents. | 42 // Helper function to run beforeunload listeners on a WebContents. |
40 // Returns true if |contents| beforeunload listeners were invoked. | 43 // Returns true if |contents| beforeunload listeners were invoked. |
41 static bool RunUnloadEventsHelper(content::WebContents* contents); | 44 static bool RunUnloadEventsHelper(content::WebContents* contents); |
42 | 45 |
43 // Called when a BeforeUnload handler is fired for |contents|. |proceed| | 46 // Called when a BeforeUnload handler is fired for |contents|. |proceed| |
44 // indicates the user's response to the Y/N BeforeUnload handler dialog. If | 47 // indicates the user's response to the Y/N BeforeUnload handler dialog. If |
45 // this parameter is false, any pending attempt to close the whole browser | 48 // this parameter is false, any pending attempt to close the whole browser |
46 // will be canceled. Returns true if Unload handlers should be fired. When the | 49 // will be canceled. Returns true if Unload handlers should be fired. When the |
47 // |browser_| is being closed, Unload handlers for any particular WebContents | 50 // |browser_| is being closed, Unload handlers for any particular WebContents |
48 // will not be run until every WebContents being closed has a chance to run | 51 // will not be run until every WebContents being closed has a chance to run |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 base::Callback<void(bool)> on_close_confirmed_; | 155 base::Callback<void(bool)> on_close_confirmed_; |
153 | 156 |
154 base::WeakPtrFactory<UnloadController> weak_factory_; | 157 base::WeakPtrFactory<UnloadController> weak_factory_; |
155 | 158 |
156 DISALLOW_COPY_AND_ASSIGN(UnloadController); | 159 DISALLOW_COPY_AND_ASSIGN(UnloadController); |
157 }; | 160 }; |
158 | 161 |
159 } // namespace chrome | 162 } // namespace chrome |
160 | 163 |
161 #endif // CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ | 164 #endif // CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ |
OLD | NEW |