OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FAST_UNLOAD_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_FAST_UNLOAD_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_FAST_UNLOAD_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_FAST_UNLOAD_CONTROLLER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // the tabs in the background. | 49 // the tabs in the background. |
50 // 4. The browser gets notified that the tab strip is empty and calls | 50 // 4. The browser gets notified that the tab strip is empty and calls |
51 // CloseFrame where the empty tab strip causes the window to hide. | 51 // CloseFrame where the empty tab strip causes the window to hide. |
52 // Once the detached tabs finish, the browser calls CloseFrame again and | 52 // Once the detached tabs finish, the browser calls CloseFrame again and |
53 // the window is finally closed. | 53 // the window is finally closed. |
54 // | 54 // |
55 class FastUnloadController : public content::NotificationObserver, | 55 class FastUnloadController : public content::NotificationObserver, |
56 public TabStripModelObserver { | 56 public TabStripModelObserver { |
57 public: | 57 public: |
58 explicit FastUnloadController(Browser* browser); | 58 explicit FastUnloadController(Browser* browser); |
59 virtual ~FastUnloadController(); | 59 ~FastUnloadController() override; |
60 | 60 |
61 // Returns true if |contents| can be cleanly closed. When |browser_| is being | 61 // Returns true if |contents| can be cleanly closed. When |browser_| is being |
62 // closed, this function will return false to indicate |contents| should not | 62 // closed, this function will return false to indicate |contents| should not |
63 // be cleanly closed, since the fast shutdown path will just kill its | 63 // be cleanly closed, since the fast shutdown path will just kill its |
64 // renderer. | 64 // renderer. |
65 bool CanCloseContents(content::WebContents* contents); | 65 bool CanCloseContents(content::WebContents* contents); |
66 | 66 |
67 // Returns true if we need to run unload events for the |contents|. | 67 // Returns true if we need to run unload events for the |contents|. |
68 static bool ShouldRunUnloadEventsHelper(content::WebContents* contents); | 68 static bool ShouldRunUnloadEventsHelper(content::WebContents* contents); |
69 | 69 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // Returns true if all tabs' beforeunload/unload events have fired. | 109 // Returns true if all tabs' beforeunload/unload events have fired. |
110 bool HasCompletedUnloadProcessing() const; | 110 bool HasCompletedUnloadProcessing() const; |
111 | 111 |
112 // Clears all the state associated with processing tabs' beforeunload/unload | 112 // Clears all the state associated with processing tabs' beforeunload/unload |
113 // events since the user cancelled closing the window. | 113 // events since the user cancelled closing the window. |
114 void CancelWindowClose(); | 114 void CancelWindowClose(); |
115 | 115 |
116 private: | 116 private: |
117 // Overridden from content::NotificationObserver: | 117 // Overridden from content::NotificationObserver: |
118 virtual void Observe(int type, | 118 void Observe(int type, |
119 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
120 const content::NotificationDetails& details) override; | 120 const content::NotificationDetails& details) override; |
121 | 121 |
122 // Overridden from TabStripModelObserver: | 122 // Overridden from TabStripModelObserver: |
123 virtual void TabInsertedAt(content::WebContents* contents, | 123 void TabInsertedAt(content::WebContents* contents, |
124 int index, | 124 int index, |
125 bool foreground) override; | 125 bool foreground) override; |
126 virtual void TabDetachedAt(content::WebContents* contents, | 126 void TabDetachedAt(content::WebContents* contents, int index) override; |
127 int index) override; | 127 void TabReplacedAt(TabStripModel* tab_strip_model, |
128 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 128 content::WebContents* old_contents, |
129 content::WebContents* old_contents, | 129 content::WebContents* new_contents, |
130 content::WebContents* new_contents, | 130 int index) override; |
131 int index) override; | 131 void TabStripEmpty() override; |
132 virtual void TabStripEmpty() override; | |
133 | 132 |
134 void TabAttachedImpl(content::WebContents* contents); | 133 void TabAttachedImpl(content::WebContents* contents); |
135 void TabDetachedImpl(content::WebContents* contents); | 134 void TabDetachedImpl(content::WebContents* contents); |
136 | 135 |
137 // Detach |contents| and wait for it to finish closing. | 136 // Detach |contents| and wait for it to finish closing. |
138 // The close must be inititiated outside of this method. | 137 // The close must be inititiated outside of this method. |
139 // Returns true if it succeeds. | 138 // Returns true if it succeeds. |
140 bool DetachWebContents(content::WebContents* contents); | 139 bool DetachWebContents(content::WebContents* contents); |
141 | 140 |
142 // Processes the next tab that needs it's beforeunload/unload event fired. | 141 // Processes the next tab that needs it's beforeunload/unload event fired. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 scoped_ptr<DetachedWebContentsDelegate> detached_delegate_; | 196 scoped_ptr<DetachedWebContentsDelegate> detached_delegate_; |
198 | 197 |
199 base::WeakPtrFactory<FastUnloadController> weak_factory_; | 198 base::WeakPtrFactory<FastUnloadController> weak_factory_; |
200 | 199 |
201 DISALLOW_COPY_AND_ASSIGN(FastUnloadController); | 200 DISALLOW_COPY_AND_ASSIGN(FastUnloadController); |
202 }; | 201 }; |
203 | 202 |
204 } // namespace chrome | 203 } // namespace chrome |
205 | 204 |
206 #endif // CHROME_BROWSER_UI_FAST_UNLOAD_CONTROLLER_H_ | 205 #endif // CHROME_BROWSER_UI_FAST_UNLOAD_CONTROLLER_H_ |
OLD | NEW |