Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: chrome/browser/ui/browser_list.h

Issue 2681203002: Add Browser::SkipCallBeforeUnload so that the browser windows can be closed regardless of beforeunl… (Closed)
Patch Set: comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_LIST_H_ 5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_H_
6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_ 6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <vector> 10 #include <vector>
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // Notifies the observers when the current active browser becomes not active. 81 // Notifies the observers when the current active browser becomes not active.
82 static void NotifyBrowserNoLongerActive(Browser* browser); 82 static void NotifyBrowserNoLongerActive(Browser* browser);
83 83
84 // Closes all browsers for |profile| across all desktops. 84 // Closes all browsers for |profile| across all desktops.
85 // TODO(mlerman): Move the Profile Deletion flow to use the overloaded 85 // TODO(mlerman): Move the Profile Deletion flow to use the overloaded
86 // version of this method with a callback, then remove this method. 86 // version of this method with a callback, then remove this method.
87 static void CloseAllBrowsersWithProfile(Profile* profile); 87 static void CloseAllBrowsersWithProfile(Profile* profile);
88 88
89 // Closes all browsers for |profile| across all desktops. Uses 89 // Closes all browsers for |profile| across all desktops. Uses
90 // TryToCloseBrowserList() to do the actual closing and trigger any 90 // TryToCloseBrowserList() to do the actual closing. Trigger any
91 // OnBeforeUnload events. If all OnBeforeUnload events are confirmed, 91 // OnBeforeUnload events if |if_force| is false. If all OnBeforeUnload events
92 // |on_close_success| is called, otherwise |on_close_aborted| is called. 92 // are confirmed or |is_force| is true, |on_close_success| is called,
93 static void CloseAllBrowsersWithProfile( 93 // otherwise |on_close_aborted| is called.
94 Profile* profile, 94 static void CloseAllBrowsersWithProfile(Profile* profile,
95 const CloseCallback& on_close_success, 95 const CloseCallback& on_close_success,
96 const CloseCallback& on_close_aborted); 96 const CloseCallback& on_close_aborted,
97 bool is_force);
Charlie Reis 2017/02/27 21:47:51 nit: skip_beforeunload
zmin 2017/03/06 23:58:08 Done.
97 98
98 // Returns true if at least one incognito session is active across all 99 // Returns true if at least one incognito session is active across all
99 // desktops. 100 // desktops.
100 static bool IsIncognitoSessionActive(); 101 static bool IsIncognitoSessionActive();
101 102
102 // Returns true if at least one incognito session is active for |profile| 103 // Returns true if at least one incognito session is active for |profile|
103 // across all desktops. 104 // across all desktops.
104 static bool IsIncognitoSessionActiveForProfile(Profile* profile); 105 static bool IsIncognitoSessionActiveForProfile(Profile* profile);
105 106
106 private: 107 private:
107 BrowserList(); 108 BrowserList();
108 ~BrowserList(); 109 ~BrowserList();
109 110
110 // Helper method to remove a browser instance from a list of browsers 111 // Helper method to remove a browser instance from a list of browsers
111 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); 112 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list);
112 113
113 // Attempts to close |browsers_to_close| while respecting OnBeforeUnload 114 // Attempts to close |browsers_to_close| while respecting OnBeforeUnload
114 // events. If there are no OnBeforeUnload events to be called, 115 // events. If there are no OnBeforeUnload events to be called,
115 // |on_close_success| will be called, with a parameter of |profile_path|, 116 // |on_close_success| will be called, with a parameter of |profile_path|,
116 // and the Browsers will then be closed. If at least one unfired 117 // and the Browsers will then be closed. If at least one unfired
117 // OnBeforeUnload event is found, handle it with a callback to 118 // OnBeforeUnload event is found, handle it with a callback to
118 // PostBeforeUnloadHandlers, which upon success will recursively call this 119 // PostTryToCloseBrowserWindow, which upon success will recursively call this
119 // method to handle any other OnBeforeUnload events. If aborted in the 120 // method to handle any other OnBeforeUnload events. If aborted in the
120 // OnBeforeUnload event, PostBeforeUnloadHandlers will call |on_close_aborted| 121 // OnBeforeUnload event, PostTryToCloseBrowserWindow will call
121 // instead and reset all OnBeforeUnload event handlers. 122 // |on_close_aborted| instead and reset all OnBeforeUnload event handlers.
122 static void TryToCloseBrowserList( 123 static void TryToCloseBrowserList(const BrowserVector& browsers_to_close,
123 const BrowserVector& browsers_to_close, 124 const CloseCallback& on_close_success,
124 const CloseCallback& on_close_success, 125 const CloseCallback& on_close_aborted,
125 const CloseCallback& on_close_aborted, 126 const base::FilePath& profile_path,
126 const base::FilePath& profile_path); 127 const bool is_force);
Charlie Reis 2017/02/27 21:47:51 skip_beforeunload
zmin 2017/03/06 23:58:08 Done.
127 128
128 // Called after handling an OnBeforeUnload event. If |tab_close_confirmed| is 129 // Called after handling an OnBeforeUnload event. If |tab_close_confirmed| is
129 // true, calls |TryToCloseBrowserList()|, passing the parameters 130 // true, calls |TryToCloseBrowserList()|, passing the parameters
130 // |browsers_to_close|, |on_close_success|, |on_close_aborted|, and 131 // |browsers_to_close|, |on_close_success|, |on_close_aborted|, and
131 // |profile_path|. Otherwise, resets all the OnBeforeUnload event handlers and 132 // |profile_path|. Otherwise, resets all the OnBeforeUnload event handlers and
132 // calls |on_close_aborted|. 133 // calls |on_close_aborted|.
133 static void PostBeforeUnloadHandlers( 134 static void PostTryToCloseBrowserWindow(
134 const BrowserVector& browsers_to_close, 135 const BrowserVector& browsers_to_close,
135 const CloseCallback& on_close_success, 136 const CloseCallback& on_close_success,
136 const CloseCallback& on_close_aborted, 137 const CloseCallback& on_close_aborted,
137 const base::FilePath& profile_path, 138 const base::FilePath& profile_path,
139 const bool is_force,
Charlie Reis 2017/02/27 21:47:51 skip_beforeunload
zmin 2017/03/06 23:58:08 Done.
138 bool tab_close_confirmed); 140 bool tab_close_confirmed);
139 141
140 // A vector of the browsers in this list, in the order they were added. 142 // A vector of the browsers in this list, in the order they were added.
141 BrowserVector browsers_; 143 BrowserVector browsers_;
142 // A vector of the browsers in this list that have been activated, in the 144 // A vector of the browsers in this list that have been activated, in the
143 // reverse order in which they were last activated. 145 // reverse order in which they were last activated.
144 BrowserVector last_active_browsers_; 146 BrowserVector last_active_browsers_;
145 147
146 // A list of observers which will be notified of every browser addition and 148 // A list of observers which will be notified of every browser addition and
147 // removal across all BrowserLists. 149 // removal across all BrowserLists.
148 static base::LazyInstance< 150 static base::LazyInstance<
149 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_; 151 base::ObserverList<chrome::BrowserListObserver>>::Leaky observers_;
150 152
151 static BrowserList* instance_; 153 static BrowserList* instance_;
152 154
153 DISALLOW_COPY_AND_ASSIGN(BrowserList); 155 DISALLOW_COPY_AND_ASSIGN(BrowserList);
154 }; 156 };
155 157
156 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ 158 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698