summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/after_startup_task_utils.cc6
-rw-r--r--chrome/browser/app_controller_mac.mm11
-rw-r--r--chrome/browser/apps/app_window_interactive_uitest.cc18
-rw-r--r--chrome/browser/chromeos/boot_times_recorder.cc5
-rw-r--r--chrome/browser/custom_home_pages_table_model.cc4
-rw-r--r--chrome/browser/devtools/devtools_sanity_browsertest.cc1
-rw-r--r--chrome/browser/devtools/devtools_ui_bindings.cc7
-rw-r--r--chrome/browser/devtools/devtools_window.cc9
-rw-r--r--chrome/browser/devtools/remote_debugging_server.cc10
-rw-r--r--chrome/browser/download/download_status_updater_win.cc5
-rw-r--r--chrome/browser/extensions/api/cookies/cookies_api.cc5
-rw-r--r--chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc1
-rw-r--r--chrome/browser/extensions/api/management/management_apitest.cc8
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_api.cc5
-rw-r--r--chrome/browser/extensions/api/tabs/tabs_event_router.cc1
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_api.cc1
-rw-r--r--chrome/browser/extensions/extension_tab_util.cc17
-rw-r--r--chrome/browser/extensions/window_open_apitest.cc16
-rw-r--r--chrome/browser/fast_shutdown_browsertest.cc6
-rw-r--r--chrome/browser/lifetime/application_lifetime.cc17
-rw-r--r--chrome/browser/lifetime/browser_close_manager.cc43
-rw-r--r--chrome/browser/lifetime/browser_close_manager_browsertest.cc50
-rw-r--r--chrome/browser/memory/tab_manager.cc8
-rw-r--r--chrome/browser/metrics/first_web_contents_profiler.cc7
-rw-r--r--chrome/browser/profile_resetter/profile_resetter.cc8
-rw-r--r--chrome/browser/profiles/profile_manager.cc6
-rw-r--r--chrome/browser/push_messaging/push_messaging_notification_manager.cc8
-rw-r--r--chrome/browser/search/search.cc1
-rw-r--r--chrome/browser/sessions/better_session_restore_browsertest.cc6
-rw-r--r--chrome/browser/sessions/session_restore_browsertest_chromeos.cc16
-rw-r--r--chrome/browser/sessions/session_service.cc14
-rw-r--r--chrome/browser/task_manager/tab_contents_information.cc1
-rw-r--r--chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc2
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc14
-rw-r--r--chrome/browser/ui/browser.cc6
-rw-r--r--chrome/browser/ui/browser_browsertest.cc30
-rw-r--r--chrome/browser/ui/browser_finder.cc10
-rw-r--r--chrome/browser/ui/browser_iterator.cc23
-rw-r--r--chrome/browser/ui/browser_iterator.h61
-rw-r--r--chrome/browser/ui/browser_list.cc26
-rw-r--r--chrome/browser/ui/browser_tab_strip_tracker.cc5
-rw-r--r--chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm9
-rw-r--r--chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm10
-rw-r--r--chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc4
-rw-r--r--chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm10
-rw-r--r--chrome/browser/ui/extensions/hosted_app_browsertest.cc24
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc14
-rw-r--r--chrome/browser/ui/settings_window_manager_browsertest.cc8
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_browsertest.cc13
-rw-r--r--chrome/browser/ui/startup/startup_browser_creator_triggered_reset_browsertest_win.cc8
-rw-r--r--chrome/browser/ui/sync/browser_synced_window_delegate.cc1
-rw-r--r--chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc8
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_iterator.cc14
-rw-r--r--chrome/browser/ui/tab_contents/tab_contents_iterator.h7
-rw-r--r--chrome/browser/ui/tabs/pinned_tab_codec.cc4
-rw-r--r--chrome/browser/ui/tabs/pinned_tab_service.cc8
-rw-r--r--chrome/browser/ui/tabs/tab_strip_model_stats_recorder.cc1
-rw-r--r--chrome/browser/ui/uma_browsing_activity_observer.cc5
-rw-r--r--chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc8
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller.cc2
-rw-r--r--chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc7
-rw-r--r--chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc1
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--chrome/test/base/dialog_test_browser_window.cc5
-rw-r--r--chrome/test/base/ui_test_utils.cc15
65 files changed, 281 insertions, 405 deletions
diff --git a/chrome/browser/after_startup_task_utils.cc b/chrome/browser/after_startup_task_utils.cc
index d1e7fd5..dac77d0 100644
--- a/chrome/browser/after_startup_task_utils.cc
+++ b/chrome/browser/after_startup_task_utils.cc
@@ -17,7 +17,7 @@
#include "base/tracked_objects.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@@ -162,8 +162,8 @@ void StartupObserver::Start() {
#if !defined(OS_ANDROID)
WebContents* contents = nullptr;
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- contents = (*iter)->tab_strip_model()->GetActiveWebContents();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ contents = browser->tab_strip_model()->GetActiveWebContents();
if (contents && contents->GetMainFrame() &&
contents->GetMainFrame()->GetVisibilityState() ==
blink::WebPageVisibilityStateVisible) {
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index 26784c9..92701bd 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -53,7 +53,7 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_mac.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -490,7 +490,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)app {
// If there are no windows, quit immediately.
- if (chrome::BrowserIterator().done() &&
+ if (BrowserList::GetInstance()->empty() &&
!AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0)) {
return NSTerminateNow;
}
@@ -635,10 +635,8 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
// completed, raise browser windows.
reopenTime_ = base::TimeTicks();
std::set<NSWindow*> browserWindows;
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- Browser* browser = *iter;
+ for (auto* browser : *BrowserList::GetInstance())
browserWindows.insert(browser->window()->GetNativeWindow());
- }
if (!browserWindows.empty()) {
ui::FocusWindowSetOnCurrentSpace(browserWindows);
}
@@ -1191,8 +1189,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver {
// notifications so we still need to open a new window.
if (hasVisibleWindows) {
std::set<NSWindow*> browserWindows;
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- Browser* browser = *iter;
+ for (auto* browser : *BrowserList::GetInstance()) {
// When focusing Chrome, don't focus any browser windows associated with
// a currently running app shim, so ignore them.
if (browser && browser->is_app()) {
diff --git a/chrome/browser/apps/app_window_interactive_uitest.cc b/chrome/browser/apps/app_window_interactive_uitest.cc
index 8af143a..4099c7d 100644
--- a/chrome/browser/apps/app_window_interactive_uitest.cc
+++ b/chrome/browser/apps/app_window_interactive_uitest.cc
@@ -6,7 +6,7 @@
#include "build/build_config.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "extensions/browser/app_window/native_app_window.h"
@@ -525,8 +525,8 @@ class AppWindowHiddenKeepAliveTest : public extensions::PlatformAppBrowserTest {
// A window that becomes hidden should not keep Chrome alive.
IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, ShownThenHidden) {
LoadAndLaunchPlatformApp("minimal", "Launched");
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- it->window()->Close();
+ for (auto* browser : *BrowserList::GetInstance())
+ browser->window()->Close();
EXPECT_TRUE(chrome::WillKeepAlive());
GetFirstAppWindow()->Hide();
@@ -541,8 +541,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, ShownThenHiddenThenShown) {
app_window->Show(AppWindow::SHOW_ACTIVE);
EXPECT_TRUE(chrome::WillKeepAlive());
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- it->window()->Close();
+ for (auto* browser : *BrowserList::GetInstance())
+ browser->window()->Close();
EXPECT_TRUE(chrome::WillKeepAlive());
app_window->GetBaseWindow()->Close();
}
@@ -554,8 +554,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, StaysHidden) {
AppWindow* app_window = GetFirstAppWindow();
EXPECT_TRUE(app_window->is_hidden());
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- it->window()->Close();
+ for (auto* browser : *BrowserList::GetInstance())
+ browser->window()->Close();
// This will time out if the command above does not terminate Chrome.
content::RunMessageLoop();
}
@@ -569,8 +569,8 @@ IN_PROC_BROWSER_TEST_F(AppWindowHiddenKeepAliveTest, HiddenThenShown) {
EXPECT_TRUE(app_window->is_hidden());
// Close all browser windows.
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- it->window()->Close();
+ for (auto* browser : *BrowserList::GetInstance())
+ browser->window()->Close();
// The app window will show after 3 seconds.
ExtensionTestMessageListener shown_listener("Shown", false);
diff --git a/chrome/browser/chromeos/boot_times_recorder.cc b/chrome/browser/chromeos/boot_times_recorder.cc
index 83a6585..3435dee 100644
--- a/chrome/browser/chromeos/boot_times_recorder.cc
+++ b/chrome/browser/chromeos/boot_times_recorder.cc
@@ -31,7 +31,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -66,8 +66,7 @@ RenderWidgetHost* GetRenderWidgetHost(NavigationController* tab) {
const std::string GetTabUrl(RenderWidgetHost* rwh) {
RenderWidgetHostView* rwhv = rwh->GetView();
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
for (int i = 0, tab_count = browser->tab_strip_model()->count();
i < tab_count;
++i) {
diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc
index c34bf4b..0b35feb 100644
--- a/chrome/browser/custom_home_pages_table_model.cc
+++ b/chrome/browser/custom_home_pages_table_model.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/settings_window_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -188,8 +187,7 @@ void CustomHomePagesTableModel::SetToCurrentlyOpenPages() {
// Add tabs from appropriate browser windows.
int add_index = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (!ShouldIncludeBrowser(browser))
continue;
diff --git a/chrome/browser/devtools/devtools_sanity_browsertest.cc b/chrome/browser/devtools/devtools_sanity_browsertest.cc
index 2c8f739..322ae3d 100644
--- a/chrome/browser/devtools/devtools_sanity_browsertest.cc
+++ b/chrome/browser/devtools/devtools_sanity_browsertest.cc
@@ -33,7 +33,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc
index 4ecdab0..7dc6302 100644
--- a/chrome/browser/devtools/devtools_ui_bindings.cc
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc
@@ -27,7 +27,6 @@
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -106,11 +105,11 @@ base::DictionaryValue* CreateFileSystemValue(
}
Browser* FindBrowser(content::WebContents* web_contents) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- int tab_index = it->tab_strip_model()->GetIndexOfWebContents(
+ for (auto* browser : *BrowserList::GetInstance()) {
+ int tab_index = browser->tab_strip_model()->GetIndexOfWebContents(
web_contents);
if (tab_index != TabStripModel::kNoTab)
- return *it;
+ return browser;
}
return NULL;
}
diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc
index e64dafc..4bfa6e4 100644
--- a/chrome/browser/devtools/devtools_window.cc
+++ b/chrome/browser/devtools/devtools_window.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/task_management/web_contents_tags.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
@@ -76,11 +75,11 @@ bool FindInspectedBrowserAndTabIndex(
if (!inspected_web_contents)
return false;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- int tab_index = it->tab_strip_model()->GetIndexOfWebContents(
- inspected_web_contents);
+ for (auto* b : *BrowserList::GetInstance()) {
+ int tab_index =
+ b->tab_strip_model()->GetIndexOfWebContents(inspected_web_contents);
if (tab_index != TabStripModel::kNoTab) {
- *browser = *it;
+ *browser = b;
*tab = tab_index;
return true;
}
diff --git a/chrome/browser/devtools/remote_debugging_server.cc b/chrome/browser/devtools/remote_debugging_server.cc
index ba64ad2..b916a30 100644
--- a/chrome/browser/devtools/remote_debugging_server.cc
+++ b/chrome/browser/devtools/remote_debugging_server.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/chrome_paths.h"
#include "components/devtools_http_handler/devtools_http_handler.h"
@@ -104,8 +104,8 @@ ChromeDevToolsHttpHandlerDelegate::~ChromeDevToolsHttpHandlerDelegate() {
std::string ChromeDevToolsHttpHandlerDelegate::GetDiscoveryPageHTML() {
std::set<Profile*> profiles;
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- profiles.insert((*it)->profile());
+ for (auto* browser : *BrowserList::GetInstance())
+ profiles.insert(browser->profile());
for (std::set<Profile*>::iterator it = profiles.begin();
it != profiles.end(); ++it) {
@@ -127,8 +127,8 @@ std::string ChromeDevToolsHttpHandlerDelegate::GetFrontendResource(
std::string ChromeDevToolsHttpHandlerDelegate::GetPageThumbnailData(
const GURL& url) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Profile* profile = (*it)->profile();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ Profile* profile = browser->profile();
scoped_refptr<history::TopSites> top_sites =
TopSitesFactory::GetForProfile(profile);
if (!top_sites)
diff --git a/chrome/browser/download/download_status_updater_win.cc b/chrome/browser/download/download_status_updater_win.cc
index 47ed35b..257b854 100644
--- a/chrome/browser/download/download_status_updater_win.cc
+++ b/chrome/browser/download/download_status_updater_win.cc
@@ -11,7 +11,7 @@
#include "base/win/scoped_comptr.h"
#include "base/win/windows_version.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "ui/views/win/hwnd_util.h"
@@ -39,8 +39,7 @@ void UpdateTaskbarProgressBar(int download_count,
}
// Iterate through all the browser windows, and draw the progress bar.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
BrowserWindow* window = browser->window();
if (!window)
continue;
diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc
index c90fd9e..c3dfe74 100644
--- a/chrome/browser/extensions/api/cookies/cookies_api.cc
+++ b/chrome/browser/extensions/api/cookies/cookies_api.cc
@@ -21,7 +21,7 @@
#include "chrome/browser/extensions/api/cookies/cookies_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/extensions/api/cookies.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -537,8 +537,7 @@ bool CookiesGetAllCookieStoresFunction::RunSync() {
// Iterate through all browser instances, and for each browser,
// add its tab IDs to either the regular or incognito tab ID list depending
// whether the browser is regular or incognito.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (browser->profile() == original_profile) {
cookies_helpers::AppendToTabIdList(browser, original_tab_ids.get());
} else if (incognito_tab_ids.get() &&
diff --git a/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc b/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc
index 896a1099..a80fc25 100644
--- a/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc
+++ b/chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc
@@ -11,7 +11,6 @@
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/notification_service.h"
diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc
index 85fc4e2..d6348af 100644
--- a/chrome/browser/extensions/api/management/management_apitest.cc
+++ b/chrome/browser/extensions/api/management/management_apitest.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -34,10 +34,10 @@ namespace {
// Find a browser other than |browser|.
Browser* FindOtherBrowser(Browser* browser) {
Browser* found = NULL;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it == browser)
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser)
continue;
- found = *it;
+ found = b;
}
return found;
}
diff --git a/chrome/browser/extensions/api/tabs/tabs_api.cc b/chrome/browser/extensions/api/tabs/tabs_api.cc
index 6924b10..011aa4b 100644
--- a/chrome/browser/extensions/api/tabs/tabs_api.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_api.cc
@@ -42,7 +42,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
@@ -915,8 +915,7 @@ bool TabsQueryFunction::RunSync() {
Browser* last_active_browser = chrome::FindAnyBrowser(
GetProfile(), include_incognito(), chrome::GetActiveDesktop());
Browser* current_browser = GetCurrentBrowser();
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (!GetProfile()->IsSameProfile(browser->profile()))
continue;
diff --git a/chrome/browser/extensions/api/tabs/tabs_event_router.cc b/chrome/browser/extensions/api/tabs/tabs_event_router.cc
index 1d329e0..3eadeab 100644
--- a/chrome/browser/extensions/api/tabs/tabs_event_router.cc
+++ b/chrome/browser/extensions/api/tabs/tabs_event_router.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/extension_constants.h"
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
index 635636e..21aa3dd 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/retargeting_details.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/extensions/api/web_navigation.h"
#include "content/public/browser/navigation_details.h"
diff --git a/chrome/browser/extensions/extension_tab_util.cc b/chrome/browser/extensions/extension_tab_util.cc
index 30821a3..aa71cbb9 100644
--- a/chrome/browser/extensions/extension_tab_util.cc
+++ b/chrome/browser/extensions/extension_tab_util.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
@@ -77,8 +76,7 @@ Browser* GetBrowserInProfileWithId(Profile* profile,
include_incognito && profile->HasOffTheRecordProfile()
? profile->GetOffTheRecordProfile()
: NULL;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if ((browser->profile() == profile ||
browser->profile() == incognito_profile) &&
ExtensionTabUtil::GetWindowId(browser) == window_id &&
@@ -321,9 +319,9 @@ int ExtensionTabUtil::GetWindowId(const Browser* browser) {
int ExtensionTabUtil::GetWindowIdOfTabStripModel(
const TabStripModel* tab_strip_model) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->tab_strip_model() == tab_strip_model)
- return GetWindowId(*it);
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->tab_strip_model() == tab_strip_model)
+ return GetWindowId(browser);
}
return -1;
}
@@ -489,8 +487,8 @@ bool ExtensionTabUtil::GetTabStripModel(const WebContents* web_contents,
DCHECK(tab_strip_model);
DCHECK(tab_index);
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- TabStripModel* tab_strip = it->tab_strip_model();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ TabStripModel* tab_strip = browser->tab_strip_model();
int index = tab_strip->GetIndexOfWebContents(web_contents);
if (index != -1) {
*tab_strip_model = tab_strip;
@@ -531,8 +529,7 @@ bool ExtensionTabUtil::GetTabById(int tab_id,
Profile* incognito_profile =
include_incognito && profile->HasOffTheRecordProfile() ?
profile->GetOffTheRecordProfile() : NULL;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* target_browser = *it;
+ for (auto* target_browser : *BrowserList::GetInstance()) {
if (target_browser->profile() == profile ||
target_browser->profile() == incognito_profile) {
TabStripModel* target_tab_strip = target_browser->tab_strip_model();
diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc
index a27ebb5..5cc0677 100644
--- a/chrome/browser/extensions/window_open_apitest.cc
+++ b/chrome/browser/extensions/window_open_apitest.cc
@@ -13,7 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/panels/panel_manager.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
@@ -99,11 +99,11 @@ bool WaitForTabsAndPopups(Browser* browser,
EXPECT_EQ(num_panels, GetPanelCount(browser));
int num_popups_seen = 0;
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- if (*iter == browser)
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser)
continue;
- EXPECT_TRUE((*iter)->is_type_popup());
+ EXPECT_TRUE(b->is_type_popup());
++num_popups_seen;
}
EXPECT_EQ(num_popups, num_popups_seen);
@@ -124,11 +124,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, BrowserIsApp) {
EXPECT_TRUE(WaitForTabsAndPopups(browser(), 0, 2, 0));
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- if (*iter == browser())
- ASSERT_FALSE(iter->is_app());
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser())
+ ASSERT_FALSE(b->is_app());
else
- ASSERT_TRUE(iter->is_app());
+ ASSERT_TRUE(b->is_app());
}
}
diff --git a/chrome/browser/fast_shutdown_browsertest.cc b/chrome/browser/fast_shutdown_browsertest.cc
index e507061..fda079b 100644
--- a/chrome/browser/fast_shutdown_browsertest.cc
+++ b/chrome/browser/fast_shutdown_browsertest.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -58,9 +58,7 @@ IN_PROC_BROWSER_TEST_F(FastShutdown, DISABLED_SlowTermination) {
// Close the new window, removing the one and only beforeunload handler.
ASSERT_EQ(2u, chrome::GetTotalBrowserCount());
- chrome::BrowserIterator it;
- it.Next();
- chrome::CloseWindow(*it);
+ chrome::CloseWindow(*(BrowserList::GetInstance()->begin() + 1));
// Need to wait for the renderer process to shutdown to ensure that we got the
// set cookies IPC.
diff --git a/chrome/browser/lifetime/application_lifetime.cc b/chrome/browser/lifetime/application_lifetime.cc
index 448b492..f914130 100644
--- a/chrome/browser/lifetime/application_lifetime.cc
+++ b/chrome/browser/lifetime/application_lifetime.cc
@@ -23,7 +23,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -54,8 +54,7 @@ namespace {
// This currently checks if there is pending download, or if it needs to
// handle unload handler.
bool AreAllBrowsersCloseable() {
- chrome::BrowserIterator browser_it;
- if (browser_it.done())
+ if (BrowserList::GetInstance()->empty())
return true;
// If there are any downloads active, all browsers are not closeable.
@@ -64,8 +63,8 @@ bool AreAllBrowsersCloseable() {
return false;
// Check TabsNeedBeforeUnloadFired().
- for (; !browser_it.done(); browser_it.Next()) {
- if (browser_it->TabsNeedBeforeUnloadFired())
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->TabsNeedBeforeUnloadFired())
return false;
}
return true;
@@ -84,8 +83,8 @@ bool g_send_stop_request_to_session_manager = false;
void MarkAsCleanShutdown() {
// TODO(beng): Can this use ProfileManager::GetLoadedProfiles() instead?
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- it->profile()->SetExitType(Profile::EXIT_NORMAL);
+ for (auto* browser : *BrowserList::GetInstance())
+ browser->profile()->SetExitType(Profile::EXIT_NORMAL);
}
void AttemptExitInternal(bool try_to_quit_application) {
@@ -176,8 +175,8 @@ void AttemptUserExit() {
#if !defined(OS_ANDROID)
void AttemptRestart() {
// TODO(beng): Can this use ProfileManager::GetLoadedProfiles instead?
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- content::BrowserContext::SaveSessionState(it->profile());
+ for (auto* browser : *BrowserList::GetInstance())
+ content::BrowserContext::SaveSessionState(browser->profile());
PrefService* pref_service = g_browser_process->local_state();
pref_service->SetBoolean(prefs::kWasRestarted, true);
diff --git a/chrome/browser/lifetime/browser_close_manager.cc b/chrome/browser/lifetime/browser_close_manager.cc
index 234eeb4..5d35dcb 100644
--- a/chrome/browser/lifetime/browser_close_manager.cc
+++ b/chrome/browser/lifetime/browser_close_manager.cc
@@ -4,6 +4,10 @@
#include "chrome/browser/lifetime/browser_close_manager.h"
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
#include "build/build_config.h"
#include "chrome/browser/background/background_mode_manager.h"
#include "chrome/browser/browser_process.h"
@@ -12,7 +16,6 @@
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -56,8 +59,8 @@ void BrowserCloseManager::StartClosingBrowsers() {
void BrowserCloseManager::CancelBrowserClose() {
browser_shutdown::SetTryingToQuit(false);
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- it->ResetBeforeUnloadHandlers();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ browser->ResetBeforeUnloadHandlers();
}
}
@@ -67,10 +70,10 @@ void BrowserCloseManager::TryToCloseBrowsers() {
// stop closing. CallBeforeUnloadHandlers prompts the user and calls
// OnBrowserReportCloseable with the result. If the user confirms the close,
// this will trigger TryToCloseBrowsers to try again.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->CallBeforeUnloadHandlers(
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->CallBeforeUnloadHandlers(
base::Bind(&BrowserCloseManager::OnBrowserReportCloseable, this))) {
- current_browser_ = *it;
+ current_browser_ = browser;
return;
}
}
@@ -150,16 +153,19 @@ void BrowserCloseManager::CloseBrowsers() {
background_mode_manager->SuspendBackgroundMode();
}
+ // Make a copy of the BrowserList to simplify the case where we need to
+ // destroy a Browser during the loop.
+ std::vector<Browser*> browser_list_copy;
+ std::copy(BrowserList::GetInstance()->begin(),
+ BrowserList::GetInstance()->end(),
+ std::back_inserter(browser_list_copy));
+
bool session_ending =
browser_shutdown::GetShutdownType() == browser_shutdown::END_SESSION;
- for (scoped_ptr<chrome::BrowserIterator> it_ptr(
- new chrome::BrowserIterator());
- !it_ptr->done();) {
- Browser* browser = **it_ptr;
+
+ for (auto* browser : browser_list_copy) {
browser->window()->Close();
- if (!session_ending) {
- it_ptr->Next();
- } else {
+ if (session_ending) {
// This path is hit during logoff/power-down. In this case we won't get
// a final message and so we force the browser to be deleted.
// Close doesn't immediately destroy the browser
@@ -170,13 +176,10 @@ void BrowserCloseManager::CloseBrowsers() {
while (browser->tab_strip_model()->count())
delete browser->tab_strip_model()->GetWebContentsAt(0);
browser->window()->DestroyBrowser();
- it_ptr.reset(new chrome::BrowserIterator());
- if (!it_ptr->done() && browser == **it_ptr) {
- // Destroying the browser should have removed it from the browser list.
- // We should never get here.
- NOTREACHED();
- return;
- }
+ // Destroying the browser should have removed it from the browser list.
+ DCHECK(BrowserList::GetInstance()->end() ==
+ std::find(BrowserList::GetInstance()->begin(),
+ BrowserList::GetInstance()->end(), browser));
}
}
}
diff --git a/chrome/browser/lifetime/browser_close_manager_browsertest.cc b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
index 1d87662..fdc7d4e 100644
--- a/chrome/browser/lifetime/browser_close_manager_browsertest.cc
+++ b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
@@ -27,7 +27,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_switches.h"
@@ -268,7 +268,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest, TestSingleTabShutdown) {
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
@@ -292,7 +292,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test is flaky on Mac. http://crbug.com/517687
@@ -333,7 +333,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
chrome::CloseAllBrowsersAndQuit();
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that the tab closed after the aborted shutdown attempt is not re-opened
@@ -397,7 +397,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest, TestMultipleWindows) {
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that tabs in the same window with a beforeunload event that hangs are
@@ -439,7 +439,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that tabs in different windows with a beforeunload event that hangs are
@@ -474,7 +474,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that a window created during shutdown is closed.
@@ -491,7 +491,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that a window created during shutdown with a beforeunload handler can
@@ -523,7 +523,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that tabs added during shutdown are closed.
@@ -546,7 +546,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test that tabs created during shutdown with beforeunload handlers can cancel
@@ -587,7 +587,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
@@ -619,7 +619,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test is flaky on Windows and Mac. See http://crbug.com/276366.
@@ -659,7 +659,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
@@ -690,7 +690,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerBrowserTest,
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
INSTANTIATE_TEST_CASE_P(BrowserCloseManagerBrowserTest,
@@ -745,7 +745,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
TestBrowserCloseManager::NO_USER_CHOICE);
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_EQ(1, DownloadService::NonMaliciousDownloadCountAllProfiles());
// Attempting to close again should not crash.
@@ -795,7 +795,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
TestBrowserCloseManager::NO_USER_CHOICE);
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
// Test shutdown with a download in progress.
@@ -820,7 +820,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
TestBrowserCloseManager::USER_CHOICE_USER_ALLOWS_CLOSE);
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
if (browser_defaults::kBrowserAliveWithNoWindows)
EXPECT_EQ(1, DownloadService::NonMaliciousDownloadCountAllProfiles());
else
@@ -857,7 +857,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
TestBrowserCloseManager::USER_CHOICE_USER_ALLOWS_CLOSE);
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_EQ(0, DownloadService::NonMaliciousDownloadCountAllProfiles());
}
@@ -907,7 +907,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
TestBrowserCloseManager::USER_CHOICE_USER_ALLOWS_CLOSE);
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
if (browser_defaults::kBrowserAliveWithNoWindows)
EXPECT_EQ(1, DownloadService::NonMaliciousDownloadCountAllProfiles());
else
@@ -940,7 +940,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithDownloadsBrowserTest,
ASSERT_NO_FATAL_FAILURE(AcceptClose());
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
}
#endif // defined(OS_MACOSX)
@@ -985,7 +985,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
close_observer.Wait();
}
EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(IsBackgroundModeSuspended());
// Background mode should be resumed when a new browser window is opened.
@@ -1001,7 +1001,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
chrome::CloseAllBrowsersAndQuit();
close_observer.Wait();
EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_FALSE(IsBackgroundModeSuspended());
}
@@ -1016,7 +1016,7 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
browser()->window()->Close();
close_observer.Wait();
EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_FALSE(IsBackgroundModeSuspended());
}
@@ -1031,12 +1031,12 @@ IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
browser()->window()->Close();
close_observer.Wait();
EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_FALSE(IsBackgroundModeSuspended());
chrome::CloseAllBrowsers();
EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(IsBackgroundModeSuspended());
}
diff --git a/chrome/browser/memory/tab_manager.cc b/chrome/browser/memory/tab_manager.cc
index ebcbe64..a26a9ee 100644
--- a/chrome/browser/memory/tab_manager.cc
+++ b/chrome/browser/memory/tab_manager.cc
@@ -36,7 +36,6 @@
#include "chrome/browser/memory/tab_manager_web_contents_data.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
@@ -91,8 +90,7 @@ int64_t IdFromWebContents(WebContents* web_contents) {
int FindTabStripModelById(int64_t target_web_contents_id,
TabStripModel** model) {
DCHECK(model);
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
TabStripModel* local_model = browser->tab_strip_model();
for (int idx = 0; idx < local_model->count(); idx++) {
WebContents* web_contents = local_model->GetWebContentsAt(idx);
@@ -393,8 +391,8 @@ void TabManager::PurgeBrowserMemory() {
int TabManager::GetTabCount() const {
int tab_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- tab_count += it->tab_strip_model()->count();
+ for (auto* browser : *BrowserList::GetInstance())
+ tab_count += browser->tab_strip_model()->count();
return tab_count;
}
diff --git a/chrome/browser/metrics/first_web_contents_profiler.cc b/chrome/browser/metrics/first_web_contents_profiler.cc
index fcce4d9..4985a71 100644
--- a/chrome/browser/metrics/first_web_contents_profiler.cc
+++ b/chrome/browser/metrics/first_web_contents_profiler.cc
@@ -14,7 +14,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/metrics/profiler/tracking_synchronizer.h"
#include "components/metrics/proto/profiler_event.pb.h"
@@ -23,10 +23,9 @@
// static
void FirstWebContentsProfiler::Start() {
- for (chrome::BrowserIterator browser_it; !browser_it.done();
- browser_it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
content::WebContents* web_contents =
- browser_it->tab_strip_model()->GetActiveWebContents();
+ browser->tab_strip_model()->GetActiveWebContents();
if (web_contents) {
// FirstWebContentsProfiler owns itself and is also bound to
// |web_contents|'s lifetime by observing WebContentsDestroyed().
diff --git a/chrome/browser/profile_resetter/profile_resetter.cc b/chrome/browser/profile_resetter/profile_resetter.cc
index 56ae49b..258705d 100644
--- a/chrome/browser/profile_resetter/profile_resetter.cc
+++ b/chrome/browser/profile_resetter/profile_resetter.cc
@@ -23,7 +23,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/browser_distribution.h"
@@ -295,9 +295,9 @@ void ProfileResetter::ResetStartupPages() {
void ProfileResetter::ResetPinnedTabs() {
// Unpin all the tabs.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->is_type_tabbed() && it->profile() == profile_) {
- TabStripModel* tab_model = it->tab_strip_model();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->is_type_tabbed() && browser->profile() == profile_) {
+ TabStripModel* tab_model = browser->tab_strip_model();
// Here we assume that indexof(any mini tab) < indexof(any normal tab).
// If we unpin the tab, it can be moved to the right. Thus traversing in
// reverse direction is correct.
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index 070486a..8fae692 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -54,7 +54,7 @@
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/sync/sync_promo_ui.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
@@ -1485,8 +1485,8 @@ void ProfileManager::BrowserListObserver::OnBrowserRemoved(
Profile* profile = browser->profile();
Profile* original_profile = profile->GetOriginalProfile();
// Do nothing if the closed window is not the last window of the same profile.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile()->GetOriginalProfile() == original_profile)
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile()->GetOriginalProfile() == original_profile)
return;
}
diff --git a/chrome/browser/push_messaging/push_messaging_notification_manager.cc b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
index c0fd19f..1131921 100644
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
@@ -37,7 +37,7 @@
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#else
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#endif
@@ -153,10 +153,10 @@ void PushMessagingNotificationManager::DidGetNotificationsFromDatabase(
Profile* profile = (*it)->GetProfile();
WebContents* active_web_contents = (*it)->GetActiveWebContents();
#else
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Profile* profile = it->profile();
+ for (auto* browser : *BrowserList::GetInstance()) {
+ Profile* profile = browser->profile();
WebContents* active_web_contents =
- it->tab_strip_model()->GetActiveWebContents();
+ browser->tab_strip_model()->GetActiveWebContents();
#endif
if (IsTabVisible(profile, active_web_contents, origin)) {
notification_needed = false;
diff --git a/chrome/browser/search/search.cc b/chrome/browser/search/search.cc
index 45732f8..505d79b 100644
--- a/chrome/browser/search/search.cc
+++ b/chrome/browser/search/search.cc
@@ -22,7 +22,6 @@
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_instant_controller.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/search/instant_search_prerenderer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/sessions/better_session_restore_browsertest.cc b/chrome/browser/sessions/better_session_restore_browsertest.cc
index 3b30f4c..1694716 100644
--- a/chrome/browser/sessions/better_session_restore_browsertest.cc
+++ b/chrome/browser/sessions/better_session_restore_browsertest.cc
@@ -30,7 +30,7 @@
#include "chrome/browser/sessions/session_service_test_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -595,8 +595,8 @@ class RestartTest : public BetterSessionRestoreTest {
protected:
void Restart() {
// Simulate restarting the browser, but let the test exit peacefully.
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- content::BrowserContext::SaveSessionState(it->profile());
+ for (auto* browser : *BrowserList::GetInstance())
+ content::BrowserContext::SaveSessionState(browser->profile());
PrefService* pref_service = g_browser_process->local_state();
pref_service->SetBoolean(prefs::kWasRestarted, true);
#if defined(OS_WIN)
diff --git a/chrome/browser/sessions/session_restore_browsertest_chromeos.cc b/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
index 75ffb6c..6bdbd1d 100644
--- a/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
+++ b/chrome/browser/sessions/session_restore_browsertest_chromeos.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/defaults.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
#include "chrome/common/chrome_paths.h"
@@ -93,9 +93,9 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreBrowserWindows) {
IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreBrowserWindows) {
size_t total_count = 0;
size_t incognito_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
++total_count;
- if (it->profile()->IsOffTheRecord())
+ if (browser->profile()->IsOffTheRecord())
++incognito_count;
}
EXPECT_EQ(2u, total_count);
@@ -118,11 +118,11 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreAppsV1) {
size_t total_count = 0;
size_t app1_count = 0;
size_t app2_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
++total_count;
- if (it->app_name() == test_app_popup_name1)
+ if (browser->app_name() == test_app_popup_name1)
++app1_count;
- if (it->app_name() == test_app_popup_name2)
+ if (browser->app_name() == test_app_popup_name2)
++app2_count;
}
EXPECT_EQ(1u, app1_count);
@@ -156,9 +156,9 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, PRE_RestoreMaximized) {
IN_PROC_BROWSER_TEST_F(SessionRestoreTestChromeOS, RestoreMaximized) {
size_t total_count = 0;
size_t maximized_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
++total_count;
- if (it->window()->IsMaximized())
+ if (browser->window()->IsMaximized())
++maximized_count;
}
EXPECT_EQ(4u, total_count);
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 6671aeb..5ed9b0b 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -32,7 +32,6 @@
#include "chrome/browser/sessions/session_restore.h"
#include "chrome/browser/sessions/session_service_utils.h"
#include "chrome/browser/sessions/session_tab_helper.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
@@ -839,8 +838,7 @@ void SessionService::BuildCommandsForBrowser(
void SessionService::BuildCommandsFromBrowsers(
IdToRange* tab_to_available_range,
std::set<SessionID::id_type>* windows_to_track) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
// Make sure the browser has tabs and a window. Browser's destructor
// removes itself from the BrowserList. When a browser is closed the
// destructor is not necessarily run immediately. This means it's possible
@@ -910,8 +908,7 @@ bool SessionService::IsOnlyOneTabLeft() const {
}
int window_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
const SessionID::id_type window_id = browser->session_id().id();
if (ShouldTrackBrowser(browser) &&
window_closing_ids_.find(window_id) == window_closing_ids_.end()) {
@@ -933,8 +930,7 @@ bool SessionService::HasOpenTrackableBrowsers(
return true;
}
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
const SessionID::id_type browser_id = browser->session_id().id();
if (browser_id != window_id.id() &&
window_closing_ids_.find(browser_id) == window_closing_ids_.end() &&
@@ -1110,8 +1106,8 @@ void SessionService::MaybeDeleteSessionOnlyData() {
}
// Check for any open windows for the current profile that we aren't tracking.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if ((*it)->profile() == profile())
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile() == profile())
return;
}
DeleteSessionOnlyData(profile());
diff --git a/chrome/browser/task_manager/tab_contents_information.cc b/chrome/browser/task_manager/tab_contents_information.cc
index c566491..90700e4 100644
--- a/chrome/browser/task_manager/tab_contents_information.cc
+++ b/chrome/browser/task_manager/tab_contents_information.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/task_manager/task_manager_util.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "components/favicon/content/content_favicon_driver.h"
#include "content/public/browser/render_process_host.h"
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
index b701a42..654749d 100644
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
@@ -177,7 +177,7 @@ AppShortcutLauncherItemController::GetRunningApplications() {
if (!extension)
return items;
- for (auto& browser : *BrowserList::GetInstance()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
if (!launcher_controller()->IsBrowserFromActiveUser(browser))
continue;
TabStripModel* tab_strip = browser->tab_strip_model();
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index d30f677..cec1b4b 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -39,7 +39,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
@@ -147,16 +146,13 @@ void ClickAllAppsButtonFromStartPage(ui::test::EventGenerator* generator,
// Find the browser that associated with |app_name|.
Browser* FindBrowserForApp(const std::string& app_name) {
- Browser* browser = nullptr;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
std::string browser_app_name =
- web_app::GetExtensionIdFromApplicationName((*it)->app_name());
- if (browser_app_name == app_name) {
- browser = *it;
- break;
- }
+ web_app::GetExtensionIdFromApplicationName(browser->app_name());
+ if (browser_app_name == app_name)
+ return browser;
}
- return browser;
+ return nullptr;
}
// Close |app_browser| and wait until it's closed.
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 2de528d..547c619 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -98,7 +98,6 @@
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_instant_controller.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_live_tab_context.h"
#include "chrome/browser/ui/browser_navigator.h"
@@ -799,15 +798,14 @@ Browser::DownloadClosePreventionType Browser::OkToCloseWithInProgressDownloads(
// profile, that are relevant for the ok-to-close decision.
int profile_window_count = 0;
int total_window_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
// Don't count this browser window or any other in the process of closing.
- Browser* const browser = *it;
// Window closing may be delayed, and windows that are in the process of
// closing don't count against our totals.
if (browser == this || browser->IsAttemptingToCloseBrowser())
continue;
- if (it->profile() == profile())
+ if (browser->profile() == profile())
profile_window_count++;
total_window_count++;
}
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 2bb48ce..b1c7107 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -45,7 +45,7 @@
#include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_ui_prefs.h"
#include "chrome/browser/ui/browser_window.h"
@@ -1410,9 +1410,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) {
// Find the new browser.
Browser* app_browser = NULL;
- for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) {
- if (*it != browser())
- app_browser = *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser())
+ app_browser = b;
}
ASSERT_TRUE(app_browser);
@@ -1590,13 +1590,13 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, ShouldShowLocationBar) {
// Find the new browsers.
Browser* app_browser = NULL;
Browser* dev_tools_browser = NULL;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it == browser()) {
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser()) {
continue;
- } else if ((*it)->app_name() == DevToolsWindow::kDevToolsApp) {
- dev_tools_browser = *it;
+ } else if (b->app_name() == DevToolsWindow::kDevToolsApp) {
+ dev_tools_browser = b;
} else {
- app_browser = *it;
+ app_browser = b;
}
}
ASSERT_TRUE(dev_tools_browser);
@@ -1655,9 +1655,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
// Find the new browser.
Browser* new_browser = NULL;
- for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) {
- if (*it != browser())
- new_browser = *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser())
+ new_browser = b;
}
ASSERT_TRUE(new_browser);
ASSERT_TRUE(new_browser != browser());
@@ -1717,9 +1717,9 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) {
// Find the new browser.
Browser* new_browser = NULL;
- for (chrome::BrowserIterator it; !it.done() && !new_browser; it.Next()) {
- if (*it != browser())
- new_browser = *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser())
+ new_browser = b;
}
ASSERT_TRUE(new_browser);
ASSERT_TRUE(new_browser != browser());
diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
index a785240..e79cae3 100644
--- a/chrome/browser/ui/browser_finder.cc
+++ b/chrome/browser/ui/browser_finder.cc
@@ -8,7 +8,6 @@
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
@@ -176,9 +175,9 @@ Browser* FindBrowserWithProfile(Profile* profile,
}
Browser* FindBrowserWithID(SessionID::id_type desired_id) {
- for (BrowserIterator it; !it.done(); it.Next()) {
- if (it->session_id().id() == desired_id)
- return *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->session_id().id() == desired_id)
+ return browser;
}
return NULL;
}
@@ -186,8 +185,7 @@ Browser* FindBrowserWithID(SessionID::id_type desired_id) {
Browser* FindBrowserWithWindow(gfx::NativeWindow window) {
if (!window)
return NULL;
- for (BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (browser->window() && browser->window()->GetNativeWindow() == window)
return browser;
}
diff --git a/chrome/browser/ui/browser_iterator.cc b/chrome/browser/ui/browser_iterator.cc
deleted file mode 100644
index e2c22d9..0000000
--- a/chrome/browser/ui/browser_iterator.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/browser_iterator.h"
-
-// TODO(scottmg): Remove this file entirely. http://crbug.com/558054.
-
-namespace chrome {
-
-BrowserIterator::BrowserIterator()
- : browser_list_(BrowserList::GetInstance()),
- iterator_(browser_list_->begin()) {
-}
-
-BrowserIterator::~BrowserIterator() {
-}
-
-void BrowserIterator::Next() {
- ++iterator_;
-}
-
-} // namespace chrome
diff --git a/chrome/browser/ui/browser_iterator.h b/chrome/browser/ui/browser_iterator.h
deleted file mode 100644
index edfc1ced..0000000
--- a/chrome/browser/ui/browser_iterator.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
-#define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
-
-#include "base/macros.h"
-#include "chrome/browser/ui/browser_list.h"
-#include "chrome/browser/ui/host_desktop.h"
-
-class Browser;
-
-namespace chrome {
-
-// TODO(scottmg): Remove this file entirely. http://crbug.com/558054.
-
-// Iterates over all existing browsers (potentially across multiple desktops).
-// Note: to iterate only over the browsers of a specific desktop, use the
-// const_iterator of a given BrowserList instead.
-//
-// Example:
-// for (BrowserIterator iterator; !iterator.done(); iterator.Next()) {
-// Browser* cur = *iterator;
-// -or-
-// iterator->OperationOnBrowser();
-// ...
-// }
-class BrowserIterator {
- public:
- BrowserIterator();
- ~BrowserIterator();
-
- // Returns true if this iterator is past the last Browser.
- bool done() const {
- // |iterator_| is never at the end of a list unless it is done (it
- // immediately moves to the next browser list upon hitting the end of the
- // current list unless there are no remaining empty browser lists).
- return iterator_ == browser_list_->end();
- }
-
- // Returns the current Browser, valid as long as !done().
- Browser* operator->() const { return *iterator_; }
- Browser* operator*() const { return *iterator_; }
-
- // Advances |iterator_| to the next browser.
- void Next();
-
- private:
- // The BrowserList being iterated over.
- BrowserList* browser_list_;
-
- // The underlying iterator over browsers in |browser_list_|.
- BrowserList::const_iterator iterator_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserIterator);
-};
-
-} // namespace chrome
-
-#endif // CHROME_BROWSER_UI_BROWSER_ITERATOR_H_
diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc
index a02cb99..00d1e5a 100644
--- a/chrome/browser/ui/browser_list.cc
+++ b/chrome/browser/ui/browser_list.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -112,9 +112,10 @@ void BrowserList::RemoveObserver(chrome::BrowserListObserver* observer) {
// static
void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) {
BrowserVector browsers_to_close;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile())
- browsers_to_close.push_back(*it);
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile()->GetOriginalProfile() ==
+ profile->GetOriginalProfile())
+ browsers_to_close.push_back(browser);
}
for (BrowserVector::const_iterator it = browsers_to_close.begin();
@@ -127,9 +128,10 @@ void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) {
void BrowserList::CloseAllBrowsersWithProfile(Profile* profile,
const base::Callback<void(const base::FilePath&)>& on_close_success) {
BrowserVector browsers_to_close;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile())
- browsers_to_close.push_back(*it);
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile()->GetOriginalProfile() ==
+ profile->GetOriginalProfile())
+ browsers_to_close.push_back(browser);
}
TryToCloseBrowserList(browsers_to_close,
@@ -197,8 +199,8 @@ void BrowserList::SetLastActive(Browser* browser) {
// static
bool BrowserList::IsOffTheRecordSessionActive() {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile()->IsOffTheRecord())
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile()->IsOffTheRecord())
return true;
}
return false;
@@ -206,9 +208,9 @@ bool BrowserList::IsOffTheRecordSessionActive() {
// static
bool BrowserList::IsOffTheRecordSessionActiveForProfile(Profile* profile) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile()->IsSameProfile(profile) &&
- it->profile()->IsOffTheRecord()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile()->IsSameProfile(profile) &&
+ browser->profile()->IsOffTheRecord()) {
return true;
}
}
diff --git a/chrome/browser/ui/browser_tab_strip_tracker.cc b/chrome/browser/ui/browser_tab_strip_tracker.cc
index 16e78dc..1d5e563 100644
--- a/chrome/browser/ui/browser_tab_strip_tracker.cc
+++ b/chrome/browser/ui/browser_tab_strip_tracker.cc
@@ -6,7 +6,6 @@
#include "base/auto_reset.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tab_strip_tracker_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -38,8 +37,8 @@ void BrowserTabStripTracker::Init(InitWith init_with) {
MaybeTrackBrowser(browser);
} else {
DCHECK(InitWith::ALL_BROWERS == init_with);
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- MaybeTrackBrowser(*it);
+ for (auto* browser : *BrowserList::GetInstance())
+ MaybeTrackBrowser(browser);
}
}
diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm
index 1736b9f..32d24f7 100644
--- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm
+++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript.mm
@@ -11,7 +11,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/applescript/bookmark_folder_applescript.h"
#import "chrome/browser/ui/cocoa/applescript/constants_applescript.h"
#import "chrome/browser/ui/cocoa/applescript/error_applescript.h"
@@ -27,13 +27,12 @@ using bookmarks::BookmarkModel;
arrayWithCapacity:chrome::GetTotalBrowserCount()];
// Iterate through all browsers and check if it closing,
// if not add it to list.
- for (chrome::BrowserIterator browserIterator; !browserIterator.done();
- browserIterator.Next()) {
- if ((*browserIterator)->IsAttemptingToCloseBrowser())
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->IsAttemptingToCloseBrowser())
continue;
base::scoped_nsobject<WindowAppleScript> window(
- [[WindowAppleScript alloc] initWithBrowser:*browserIterator]);
+ [[WindowAppleScript alloc] initWithBrowser:browser]);
[window setContainer:NSApp
property:AppleScript::kWindowsProperty];
[appleScriptWindows addObject:window];
diff --git a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm
index cc8c4a2..8035dfc 100644
--- a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm
+++ b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac_browsertest.mm
@@ -18,7 +18,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/launch_util.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "extensions/browser/app_window/app_window_registry.h"
@@ -158,7 +158,8 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
// When a browser window is focused, the menu items for the app should be
// removed.
- BrowserWindow* chrome_window = chrome::BrowserIterator()->window();
+ BrowserWindow* chrome_window =
+ (*BrowserList::GetInstance()->begin())->window();
[[NSNotificationCenter defaultCenter]
postNotificationName:NSWindowDidBecomeMainNotification
object:chrome_window->GetNativeWindow()];
@@ -192,7 +193,8 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
CheckHasAppMenus(app_1_);
// Closing a background window without focusing it should not change menus.
- BrowserWindow* chrome_window = chrome::BrowserIterator()->window();
+ BrowserWindow* chrome_window =
+ (*BrowserList::GetInstance()->begin())->window();
chrome_window->Close();
[[NSNotificationCenter defaultCenter]
postNotificationName:NSWindowWillCloseNotification
@@ -245,7 +247,7 @@ IN_PROC_BROWSER_TEST_F(AppShimMenuControllerBrowserTest,
SetUpApps(PACKAGED_1 | PACKAGED_2);
FirstWindowForApp(app_2_)->GetBaseWindow()->Close();
- chrome::BrowserIterator()->window()->Close();
+ (*BrowserList::GetInstance()->begin())->window()->Close();
NSWindow* app_1_window = FirstWindowForApp(app_1_)->GetNativeWindow();
ui::test::ScopedFakeNSWindowFocus fake_focus;
diff --git a/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc b/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc
index 8d1ddd3..13524bb 100644
--- a/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc
+++ b/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.cc
@@ -17,7 +17,7 @@
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_switches.h"
@@ -169,7 +169,7 @@ bool QuitWithAppsController::ShouldQuit() {
// quitting. If there are no browser windows, always show the notification.
bool suppress_always = !g_browser_process->local_state()->GetBoolean(
prefs::kNotifyWhenAppsKeepChromeAlive);
- if (!chrome::BrowserIterator().done() &&
+ if (!BrowserList::GetInstance()->empty() &&
(suppress_for_session_ || suppress_always)) {
return false;
}
diff --git a/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm b/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm
index d7aa404..8ea62f2 100644
--- a/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm
+++ b/chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac_interactive_uitest.mm
@@ -20,7 +20,7 @@
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/browser/notification_service.h"
@@ -82,7 +82,7 @@ IN_PROC_BROWSER_TEST_P(QuitWithAppsControllerInteractiveTest, QuitBehavior) {
ASSERT_TRUE(listener.WaitUntilSatisfied());
// One browser and one app window at this point.
- EXPECT_FALSE(chrome::BrowserIterator().done());
+ EXPECT_FALSE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0));
// On the first quit, show notification.
@@ -103,7 +103,7 @@ IN_PROC_BROWSER_TEST_P(QuitWithAppsControllerInteractiveTest, QuitBehavior) {
NotificationUIManager::GetProfileID(profiles[0]));
ASSERT_TRUE(notification);
- EXPECT_FALSE(chrome::BrowserIterator().done());
+ EXPECT_FALSE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0));
// If notification is closed by user, don't show it next time.
@@ -116,7 +116,7 @@ IN_PROC_BROWSER_TEST_P(QuitWithAppsControllerInteractiveTest, QuitBehavior) {
NotificationUIManager::GetProfileID(profiles[0]));
EXPECT_EQ(NULL, notification);
- EXPECT_FALSE(chrome::BrowserIterator().done());
+ EXPECT_FALSE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0));
// Get a reference to the open app window before the browser closes.
@@ -129,7 +129,7 @@ IN_PROC_BROWSER_TEST_P(QuitWithAppsControllerInteractiveTest, QuitBehavior) {
chrome_browser_application_mac::Terminate();
observer.Wait();
- EXPECT_TRUE(chrome::BrowserIterator().done());
+ EXPECT_TRUE(BrowserList::GetInstance()->empty());
EXPECT_TRUE(AppWindowRegistryUtil::IsAppWindowVisibleInAnyProfile(0));
// Trying to quit while there are no browsers always shows notification.
diff --git a/chrome/browser/ui/extensions/hosted_app_browsertest.cc b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
index 55abe04..2d4a5e5 100644
--- a/chrome/browser/ui/extensions/hosted_app_browsertest.cc
+++ b/chrome/browser/ui/extensions/hosted_app_browsertest.cc
@@ -11,7 +11,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
@@ -62,14 +62,14 @@ class HostedAppTest : public ExtensionBrowserTest {
browser()->profile(), app, extensions::LAUNCH_CONTAINER_WINDOW,
NEW_WINDOW, extensions::SOURCE_TEST)));
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it == browser())
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser())
continue;
std::string browser_app_id =
- web_app::GetExtensionIdFromApplicationName((*it)->app_name());
+ web_app::GetExtensionIdFromApplicationName(b->app_name());
if (browser_app_id == app->id()) {
- app_browser_ = *it;
+ app_browser_ = b;
break;
}
}
@@ -231,16 +231,16 @@ IN_PROC_BROWSER_TEST_F(HostedAppTest, ShouldUseWebAppFrame) {
Browser* bookmark_app_browser = nullptr;
Browser* packaged_app_browser = nullptr;
Browser* dev_tools_browser = nullptr;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it == browser()) {
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser()) {
continue;
- } else if ((*it)->app_name() == DevToolsWindow::kDevToolsApp) {
- dev_tools_browser = *it;
- } else if ((*it)->tab_strip_model()->GetActiveWebContents() ==
+ } else if (b->app_name() == DevToolsWindow::kDevToolsApp) {
+ dev_tools_browser = b;
+ } else if (b->tab_strip_model()->GetActiveWebContents() ==
bookmark_app_window) {
- bookmark_app_browser = *it;
+ bookmark_app_browser = b;
} else {
- packaged_app_browser = *it;
+ packaged_app_browser = b;
}
}
ASSERT_TRUE(dev_tools_browser);
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index b510f88..17891fa 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -19,7 +19,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/panels/base_panel_browser_test.h"
#include "chrome/browser/ui/panels/docked_panel_collection.h"
@@ -1637,10 +1637,10 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevTools) {
EXPECT_EQ(num_browsers, chrome::GetBrowserCount(
browser()->profile(),
browser()->host_desktop_type()));
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- if (*iter == browser())
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser())
continue;
- ASSERT_TRUE((*iter)->is_devtools());
+ ASSERT_TRUE(b->is_devtools());
}
panel->Close();
@@ -1671,10 +1671,10 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevToolsConsole) {
EXPECT_EQ(num_browsers, chrome::GetBrowserCount(
browser()->profile(),
browser()->host_desktop_type()));
- for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) {
- if (*iter == browser())
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b == browser())
continue;
- ASSERT_TRUE((*iter)->is_devtools());
+ ASSERT_TRUE(b->is_devtools());
}
panel->Close();
diff --git a/chrome/browser/ui/settings_window_manager_browsertest.cc b/chrome/browser/ui/settings_window_manager_browsertest.cc
index 0aa1080..fc7127e 100644
--- a/chrome/browser/ui/settings_window_manager_browsertest.cc
+++ b/chrome/browser/ui/settings_window_manager_browsertest.cc
@@ -15,7 +15,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/settings_window_manager_observer.h"
@@ -100,9 +100,9 @@ class SettingsWindowManagerTest : public InProcessBrowserTest {
void CloseNonDefaultBrowsers() {
std::list<Browser*> browsers_to_close;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it != browser())
- browsers_to_close.push_back(*it);
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser())
+ browsers_to_close.push_back(b);
}
for (std::list<Browser*>::iterator iter = browsers_to_close.begin();
iter != browsers_to_close.end(); ++iter) {
diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
index 758f575..2515fb5 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc
@@ -30,7 +30,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/browser_window.h"
@@ -92,9 +91,9 @@ Browser* FindOneOtherBrowser(Browser* browser) {
// Find the new browser.
Browser* other_browser = NULL;
- for (chrome::BrowserIterator it; !it.done() && !other_browser; it.Next()) {
- if (*it != browser)
- other_browser = *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser)
+ other_browser = b;
}
return other_browser;
}
@@ -190,9 +189,9 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest {
Browser* FindOneOtherBrowserForProfile(Profile* profile,
Browser* not_this_browser) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it != not_this_browser && it->profile() == profile)
- return *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser != not_this_browser && browser->profile() == profile)
+ return browser;
}
return NULL;
}
diff --git a/chrome/browser/ui/startup/startup_browser_creator_triggered_reset_browsertest_win.cc b/chrome/browser/ui/startup/startup_browser_creator_triggered_reset_browsertest_win.cc
index 5e96d5d..29def81 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_triggered_reset_browsertest_win.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_triggered_reset_browsertest_win.cc
@@ -16,7 +16,7 @@
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -36,9 +36,9 @@ Browser* FindOneOtherBrowser(Browser* browser) {
browser->host_desktop_type()));
// Find the new browser.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it != browser)
- return *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser)
+ return b;
}
return nullptr;
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegate.cc b/chrome/browser/ui/sync/browser_synced_window_delegate.cc
index ded8fd3..912b20b 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegate.cc
+++ b/chrome/browser/ui/sync/browser_synced_window_delegate.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/sync/tab_contents_synced_tab_delegate.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/sessions/core/session_id.h"
diff --git a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
index 6e33d97..5e6f66ca 100644
--- a/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
+++ b/chrome/browser/ui/sync/browser_synced_window_delegates_getter.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/sync/browser_synced_window_delegate.h"
#include "components/sync_sessions/synced_window_delegate.h"
@@ -20,10 +20,10 @@ std::set<const SyncedWindowDelegate*>
BrowserSyncedWindowDelegatesGetter::GetSyncedWindowDelegates() {
std::set<const SyncedWindowDelegate*> synced_window_delegates;
// Add all the browser windows.
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (it->profile() != profile_)
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (browser->profile() != profile_)
continue;
- synced_window_delegates.insert(it->synced_window_delegate());
+ synced_window_delegates.insert(browser->synced_window_delegate());
}
return synced_window_delegates;
}
diff --git a/chrome/browser/ui/tab_contents/tab_contents_iterator.cc b/chrome/browser/ui/tab_contents/tab_contents_iterator.cc
index bc03577..34df98b 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_iterator.cc
+++ b/chrome/browser/ui/tab_contents/tab_contents_iterator.cc
@@ -11,25 +11,29 @@
TabContentsIterator::TabContentsIterator()
: web_view_index_(-1),
- cur_(NULL) {
+ cur_(NULL),
+ browser_iterator_(BrowserList::GetInstance()->begin()) {
// Load the first WebContents into |cur_|.
Next();
}
+TabContentsIterator::~TabContentsIterator() {
+}
+
void TabContentsIterator::Next() {
// The current WebContents should be valid unless we are at the beginning.
DCHECK(cur_ || web_view_index_ == -1) << "Trying to advance past the end";
// Update |cur_| to the next WebContents in the list.
- while (!browser_iterator_.done()) {
- if (++web_view_index_ >= browser_iterator_->tab_strip_model()->count()) {
+ while (browser_iterator_ != BrowserList::GetInstance()->end()) {
+ if (++web_view_index_ >= (*browser_iterator_)->tab_strip_model()->count()) {
// Advance to the next Browser in the list.
- browser_iterator_.Next();
+ ++browser_iterator_;
web_view_index_ = -1;
continue;
}
- content::WebContents* next_tab = browser_iterator_->tab_strip_model()
+ content::WebContents* next_tab = (*browser_iterator_)->tab_strip_model()
->GetWebContentsAt(web_view_index_);
if (next_tab) {
cur_ = next_tab;
diff --git a/chrome/browser/ui/tab_contents/tab_contents_iterator.h b/chrome/browser/ui/tab_contents/tab_contents_iterator.h
index 13bfba0..b13bdb5 100644
--- a/chrome/browser/ui/tab_contents/tab_contents_iterator.h
+++ b/chrome/browser/ui/tab_contents/tab_contents_iterator.h
@@ -8,7 +8,7 @@
#include <set>
#include "base/macros.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
namespace content {
class WebContents;
@@ -29,6 +29,7 @@ class WebContents;
class TabContentsIterator {
public:
TabContentsIterator();
+ ~TabContentsIterator();
// Returns true if we are past the last Browser.
bool done() const { return cur_ == NULL; }
@@ -36,7 +37,7 @@ class TabContentsIterator {
// Returns the Browser instance associated with the current
// WebContents. Valid as long as !done().
Browser* browser() const {
- if (!browser_iterator_.done())
+ if (browser_iterator_ != BrowserList::GetInstance()->end())
return *browser_iterator_;
return NULL;
}
@@ -64,7 +65,7 @@ class TabContentsIterator {
content::WebContents* cur_;
// An iterator over all the browsers.
- chrome::BrowserIterator browser_iterator_;
+ BrowserList::const_iterator browser_iterator_;
DISALLOW_COPY_AND_ASSIGN(TabContentsIterator);
};
diff --git a/chrome/browser/ui/tabs/pinned_tab_codec.cc b/chrome/browser/ui/tabs/pinned_tab_codec.cc
index 68d0362..35fb9d9 100644
--- a/chrome/browser/ui/tabs/pinned_tab_codec.cc
+++ b/chrome/browser/ui/tabs/pinned_tab_codec.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
@@ -90,8 +89,7 @@ void PinnedTabCodec::WritePinnedTabs(Profile* profile) {
return;
base::ListValue values;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (browser->is_type_tabbed() &&
browser->profile() == profile && HasPinnedTabs(browser)) {
EncodePinnedTabs(browser, &values);
diff --git a/chrome/browser/ui/tabs/pinned_tab_service.cc b/chrome/browser/ui/tabs/pinned_tab_service.cc
index 0762dcd..5f56a5e 100644
--- a/chrome/browser/ui/tabs/pinned_tab_service.cc
+++ b/chrome/browser/ui/tabs/pinned_tab_service.cc
@@ -7,7 +7,7 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/pinned_tab_codec.h"
#include "content/public/browser/notification_service.h"
@@ -16,9 +16,9 @@ namespace {
// Returns true if |browser| is the only normal (tabbed) browser for |browser|'s
// profile (across all desktops).
bool IsOnlyNormalBrowser(Browser* browser) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (*it != browser && it->is_type_tabbed() &&
- it->profile() == browser->profile()) {
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser && b->is_type_tabbed() &&
+ b->profile() == browser->profile()) {
return false;
}
}
diff --git a/chrome/browser/ui/tabs/tab_strip_model_stats_recorder.cc b/chrome/browser/ui/tabs/tab_strip_model_stats_recorder.cc
index e61fc3dd..5db6a72 100644
--- a/chrome/browser/ui/tabs/tab_strip_model_stats_recorder.cc
+++ b/chrome/browser/ui/tabs/tab_strip_model_stats_recorder.cc
@@ -11,7 +11,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/supports_user_data.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
diff --git a/chrome/browser/ui/uma_browsing_activity_observer.cc b/chrome/browser/ui/uma_browsing_activity_observer.cc
index e5f7927..4b56cfc 100644
--- a/chrome/browser/ui/uma_browsing_activity_observer.cc
+++ b/chrome/browser/ui/uma_browsing_activity_observer.cc
@@ -9,7 +9,7 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/search_engines/template_url_service.h"
@@ -96,9 +96,8 @@ void UMABrowsingActivityObserver::LogBrowserTabCount() const {
int app_window_count = 0;
int popup_window_count = 0;
int tabbed_window_count = 0;
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
// Record how many tabs each window has open.
- Browser* browser = *it;
UMA_HISTOGRAM_CUSTOM_COUNTS("Tabs.TabCountPerWindow",
browser->tab_strip_model()->count(),
1, 200, 50);
diff --git a/chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc b/chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc
index 799fb73b..c7d104c 100644
--- a/chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc
+++ b/chrome/browser/ui/views/frame/browser_window_property_manager_browsertest_win.cc
@@ -25,7 +25,7 @@
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/app_launch_params.h"
#include "chrome/browser/ui/extensions/application_launch.h"
@@ -262,9 +262,9 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowPropertyManagerTest, DISABLED_HostedApp) {
// Find the new browser.
Browser* app_browser = nullptr;
- for (chrome::BrowserIterator it; !it.done() && !app_browser; it.Next()) {
- if (*it != browser())
- app_browser = *it;
+ for (auto* b : *BrowserList::GetInstance()) {
+ if (b != browser())
+ app_browser = b;
}
ASSERT_TRUE(app_browser);
ASSERT_TRUE(app_browser != browser());
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller.cc b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
index 1d4faf0..82b4d76 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller.cc
@@ -1811,7 +1811,7 @@ gfx::NativeWindow TabDragController::GetLocalProcessWindow(
// window which was used for dragging is not hidden once all of its tabs are
// attached to another browser window in DragBrowserToNewTabStrip().
// TODO(pkotwicz): Fix this properly (crbug.com/358482)
- for (auto& browser : *BrowserList::GetInstance()) {
+ for (auto* browser : *BrowserList::GetInstance()) {
if (browser->tab_strip_model()->empty())
exclude.insert(browser->window()->GetNativeWindow());
}
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
index 9a9de9c12..f3c8874 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -1507,10 +1506,10 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
// Should be two windows and not dragging.
ASSERT_FALSE(TabDragController::IsActive());
ASSERT_EQ(2u, browser_list->size());
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- EXPECT_FALSE(GetIsDragged(*it));
+ for (auto* browser : *BrowserList::GetInstance()) {
+ EXPECT_FALSE(GetIsDragged(browser));
// Should not be maximized
- EXPECT_FALSE(it->window()->IsMaximized());
+ EXPECT_FALSE(browser->window()->IsMaximized());
}
}
diff --git a/chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc b/chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc
index e1ef734..d69aa2d 100644
--- a/chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc
+++ b/chrome/browser/ui/webui/memory_internals/memory_internals_proxy.cc
@@ -29,7 +29,6 @@
#include "chrome/browser/ui/android/tab_model/tab_model.h"
#include "chrome/browser/ui/android/tab_model/tab_model_list.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
#include "chrome/browser/ui/webui/memory_internals/memory_internals_handler.h"
#include "chrome/common/features.h"
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index adae246..5e0959a 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1552,8 +1552,6 @@
'browser/ui/browser_finder.h',
'browser/ui/browser_instant_controller.cc',
'browser/ui/browser_instant_controller.h',
- 'browser/ui/browser_iterator.cc',
- 'browser/ui/browser_iterator.h',
'browser/ui/browser_list.cc',
'browser/ui/browser_list.h',
'browser/ui/browser_live_tab_context.cc',
diff --git a/chrome/test/base/dialog_test_browser_window.cc b/chrome/test/base/dialog_test_browser_window.cc
index 5328cb9..7d73785 100644
--- a/chrome/test/base/dialog_test_browser_window.cc
+++ b/chrome/test/base/dialog_test_browser_window.cc
@@ -5,7 +5,7 @@
#include "chrome/test/base/dialog_test_browser_window.h"
#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_iterator.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"
@@ -49,8 +49,7 @@ void DialogTestBrowserWindow::RemoveObserver(
}
Browser* DialogTestBrowserWindow::FindBrowser() const {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- Browser* browser = *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
if (browser->window() == this)
return browser;
}
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index e4cb294..487c264 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -29,7 +29,6 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_iterator.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
@@ -178,8 +177,8 @@ void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
number_of_navigations);
std::set<Browser*> initial_browsers;
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- initial_browsers.insert(*it);
+ for (auto* browser : *BrowserList::GetInstance())
+ initial_browsers.insert(browser);
content::WindowedNotificationObserver tab_added_observer(
chrome::NOTIFICATION_TAB_ADDED,
@@ -360,9 +359,9 @@ void SendToOmniboxAndSubmit(LocationBar* location_bar,
}
Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) {
- for (chrome::BrowserIterator it; !it.done(); it.Next()) {
- if (excluded_browsers.find(*it) == excluded_browsers.end())
- return *it;
+ for (auto* browser : *BrowserList::GetInstance()) {
+ if (excluded_browsers.find(browser) == excluded_browsers.end())
+ return browser;
}
return nullptr;
}
@@ -447,8 +446,8 @@ BrowserAddedObserver::BrowserAddedObserver()
: notification_observer_(
chrome::NOTIFICATION_BROWSER_OPENED,
content::NotificationService::AllSources()) {
- for (chrome::BrowserIterator it; !it.done(); it.Next())
- original_browsers_.insert(*it);
+ for (auto* browser : *BrowserList::GetInstance())
+ original_browsers_.insert(browser);
}
BrowserAddedObserver::~BrowserAddedObserver() {