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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 // 2. WebContents notifies us via its delegate and BeforeUnloadFired() | 34 // 2. WebContents notifies us via its delegate and BeforeUnloadFired() |
35 // that the beforeunload handler was run. If the user allowed the | 35 // that the beforeunload handler was run. If the user allowed the |
36 // close to continue, we detached the tab and hold onto it while the | 36 // close to continue, we detached the tab and hold onto it while the |
37 // close finishes. | 37 // close finishes. |
38 // | 38 // |
39 // Typical flow of closing a window: | 39 // Typical flow of closing a window: |
40 // 1. BrowserView::CanClose() calls TabsNeedBeforeUnloadFired(). | 40 // 1. BrowserView::CanClose() calls TabsNeedBeforeUnloadFired(). |
41 // If beforeunload/unload handlers need to run, UnloadController returns | 41 // If beforeunload/unload handlers need to run, UnloadController returns |
42 // true and calls ProcessPendingTabs() (private method). | 42 // true and calls ProcessPendingTabs() (private method). |
43 // 2. For each tab with a beforeunload/unload handler, ProcessPendingTabs() | 43 // 2. For each tab with a beforeunload/unload handler, ProcessPendingTabs() |
44 // calls |web_contents->OnCloseStarted()| | 44 // calls |CoreTabHelper::OnCloseStarted()| |
45 // and |web_contents->GetRenderViewHost()->FirePageBeforeUnload()|. | 45 // and |web_contents->GetRenderViewHost()->FirePageBeforeUnload()|. |
46 // 3. If the user allowed the close to continue, we detach all the tabs with | 46 // 3. If the user allowed the close to continue, we detach all the tabs with |
47 // unload handlers, remove them from the tab strip, and finish closing | 47 // unload handlers, remove them from the tab strip, and finish closing |
48 // the tabs in the background. | 48 // the tabs in the background. |
49 // 4. The browser gets notified that the tab strip is empty and calls | 49 // 4. The browser gets notified that the tab strip is empty and calls |
50 // CloseFrame where the empty tab strip causes the window to hide. | 50 // CloseFrame where the empty tab strip causes the window to hide. |
51 // Once the detached tabs finish, the browser calls CloseFrame again and | 51 // Once the detached tabs finish, the browser calls CloseFrame again and |
52 // the window is finally closed. | 52 // the window is finally closed. |
53 // | 53 // |
54 class UnloadController : public content::NotificationObserver, | 54 class UnloadController : public content::NotificationObserver, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 scoped_ptr<DetachedWebContentsDelegate> detached_delegate_; | 171 scoped_ptr<DetachedWebContentsDelegate> detached_delegate_; |
172 | 172 |
173 base::WeakPtrFactory<UnloadController> weak_factory_; | 173 base::WeakPtrFactory<UnloadController> weak_factory_; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(UnloadController); | 175 DISALLOW_COPY_AND_ASSIGN(UnloadController); |
176 }; | 176 }; |
177 | 177 |
178 } // namespace chrome | 178 } // namespace chrome |
179 | 179 |
180 #endif // CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ | 180 #endif // CHROME_BROWSER_UI_UNLOAD_CONTROLLER_H_ |
OLD | NEW |