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

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

Issue 471763008: Nicely handle OnBeforeUnloads with guest and lock mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup browser close; callback reset Created 6 years, 3 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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 static void AddObserver(chrome::BrowserListObserver* observer); 65 static void AddObserver(chrome::BrowserListObserver* observer);
66 static void RemoveObserver(chrome::BrowserListObserver* observer); 66 static void RemoveObserver(chrome::BrowserListObserver* observer);
67 67
68 // Called by Browser objects when their window is activated (focused). This 68 // Called by Browser objects when their window is activated (focused). This
69 // allows us to determine what the last active Browser was on each desktop. 69 // allows us to determine what the last active Browser was on each desktop.
70 // Note: This only takes effect on the appropriate browser list as determined 70 // Note: This only takes effect on the appropriate browser list as determined
71 // by |browser->host_desktop_type()|. 71 // by |browser->host_desktop_type()|.
72 static void SetLastActive(Browser* browser); 72 static void SetLastActive(Browser* browser);
73 73
74 // Closes all browsers for |profile| across all desktops. 74 // Closes all browsers for |profile| across all desktops.
75 // TODO(mlerman): Move the Profile Deletion flow to use the overloaded
76 // version of this method with a callback, then remove this method.
75 static void CloseAllBrowsersWithProfile(Profile* profile); 77 static void CloseAllBrowsersWithProfile(Profile* profile);
76 78
79 // Closes all browsers for |profile| across all desktops. If an OnBeforeUnload
80 // event causes any browser to not be closed, |on_close_aborted| is called.
Peter Kasting 2014/08/28 18:46:13 This comment is now out-of-date.
Mike Lerman 2014/08/29 18:02:21 Done.
81 // Otherwise, |on_close_success| is called.
82 static void CloseAllBrowsersWithProfile(
83 Profile* profile, const base::Callback<void(size_t)>& on_close_success);
Peter Kasting 2014/08/28 18:46:12 Nit: One arg per line
Mike Lerman 2014/08/29 18:02:21 Done.
84
77 // Returns true if at least one incognito session is active across all 85 // Returns true if at least one incognito session is active across all
78 // desktops. 86 // desktops.
79 static bool IsOffTheRecordSessionActive(); 87 static bool IsOffTheRecordSessionActive();
80 88
81 // Returns true if at least one incognito session is active for |profile| 89 // Returns true if at least one incognito session is active for |profile|
82 // across all desktops. 90 // across all desktops.
83 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); 91 static bool IsOffTheRecordSessionActiveForProfile(Profile* profile);
84 92
85 private: 93 private:
86 BrowserList(); 94 BrowserList();
87 ~BrowserList(); 95 ~BrowserList();
88 96
89 // Helper method to remove a browser instance from a list of browsers 97 // Helper method to remove a browser instance from a list of browsers
90 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); 98 static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list);
91 99
100 // Attempt to close |browser_to_close| while respecting OnBeforeUnload events.
Peter Kasting 2014/08/28 18:46:13 Nit: Attempt -> Attempts; browser -> browsers
Mike Lerman 2014/08/29 18:02:21 Done.
101 // If successful |on_close_confirmed| will be called, with a parameter of
102 // |profile_index|.
103 static void TryToCloseBrowserList(
104 const BrowserVector& browsers_to_close,
105 const base::Callback<void(size_t)>& on_close_confirmed,
Peter Kasting 2014/08/28 18:46:12 Nit: Maybe rename this arg |on_close_completed| or
Mike Lerman 2014/08/29 18:02:21 Done.
106 const size_t profile_index);
Peter Kasting 2014/08/28 18:46:12 Nit: Pass by const value is unusual; probably shou
Mike Lerman 2014/08/29 18:02:21 This parameter has changed from a size_t to a base
107
108 // Called after handling an OnBeforeUnload event. |proceed| indicates if the
109 // user responded that closing the browser tab should proceed or not. If so,
Peter Kasting 2014/08/28 18:46:12 Nit: Remove "or not" (makes the sentence technical
Mike Lerman 2014/08/29 18:02:21 Done.
110 // call |TryToCloseBrowserList|, passing the parameters |browsers_to_close|,
Peter Kasting 2014/08/28 18:46:12 Nit: call -> calls
Mike Lerman 2014/08/29 18:02:21 Done.
111 // |on_close_confirmed|, and |profile_index|. Otherwise, reset all the
Peter Kasting 2014/08/28 18:46:12 Nit: reset -> resets (although perhaps this should
Mike Lerman 2014/08/29 18:02:21 Done. (the method called is ResetBeforeUnloadHandl
112 // OnBeforeUnload events.
Peter Kasting 2014/08/28 18:46:12 Nit: events -> handlers? (You can't reset an even
Mike Lerman 2014/08/29 18:02:21 How about "event handlers"? It's really the event
113 static void PostBeforeUnloadHandlers(
114 const BrowserVector& browsers_to_close,
115 const base::Callback<void(size_t)>& on_close_confirmed,
116 const size_t profile_index,
117 bool proceed);
118
92 // A vector of the browsers in this list, in the order they were added. 119 // A vector of the browsers in this list, in the order they were added.
93 BrowserVector browsers_; 120 BrowserVector browsers_;
94 // A vector of the browsers in this list that have been activated, in the 121 // A vector of the browsers in this list that have been activated, in the
95 // reverse order in which they were last activated. 122 // reverse order in which they were last activated.
96 BrowserVector last_active_browsers_; 123 BrowserVector last_active_browsers_;
97 124
98 // A list of observers which will be notified of every browser addition and 125 // A list of observers which will be notified of every browser addition and
99 // removal across all BrowserLists. 126 // removal across all BrowserLists.
100 static base::LazyInstance<ObserverList<chrome::BrowserListObserver> >::Leaky 127 static base::LazyInstance<ObserverList<chrome::BrowserListObserver> >::Leaky
101 observers_; 128 observers_;
102 129
103 // Nothing fancy, since we only have two HDTs. 130 // Nothing fancy, since we only have two HDTs.
104 static BrowserList* native_instance_; 131 static BrowserList* native_instance_;
105 static BrowserList* ash_instance_; 132 static BrowserList* ash_instance_;
106 133
107 DISALLOW_COPY_AND_ASSIGN(BrowserList); 134 DISALLOW_COPY_AND_ASSIGN(BrowserList);
108 }; 135 };
109 136
110 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ 137 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698