diff options
author | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 01:37:08 +0000 |
---|---|---|
committer | yoz@chromium.org <yoz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 01:37:08 +0000 |
commit | 119e8cfc6366a3958129ed4a08e9011b0770a072 (patch) | |
tree | 55a5dc312791891db5c286ad8e808a0068222b0b | |
parent | 938dad8ea926a90c64d7b9495cb1abac0b361d5e (diff) | |
download | chromium_src-119e8cfc6366a3958129ed4a08e9011b0770a072.zip chromium_src-119e8cfc6366a3958129ed4a08e9011b0770a072.tar.gz chromium_src-119e8cfc6366a3958129ed4a08e9011b0770a072.tar.bz2 |
Revert 183580 - added a static initializer on Mac
> Merge BrowserListImpl into BrowserList.
>
> Kept AddBrowser and RemoveBrowser static (having it access the private members of the appropriate list for the browser added/removed); kept AddObserver and RemoveObserver static so that observers are notified about browser additions, removals, and set actives on every desktop (observers should filter if they so desire).
>
> The only calls that are not-static (i.e. for which consumers need to be aware of HostDesktopType) are: iterators, size(), empty(), get(), and GetLastActive(). All the consumers were already made multi-desktop aware in the multiple CLs preceding this one :)!
>
> BUG=129187
>
>
> Review URL: https://chromiumcodereview.appspot.com/12281006
TBR=gab@chromium.org
Review URL: https://codereview.chromium.org/12310034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183701 0039d316-1c4b-4281-b951-d872f2087c98
34 files changed, 403 insertions, 300 deletions
diff --git a/chrome/browser/app_controller_mac_browsertest.mm b/chrome/browser/app_controller_mac_browsertest.mm index 62d2680..aec0f00 100644 --- a/chrome/browser/app_controller_mac_browsertest.mm +++ b/chrome/browser/app_controller_mac_browsertest.mm @@ -10,6 +10,7 @@ #import "chrome/browser/app_controller_mac.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #import "chrome/common/chrome_switches.h" @@ -22,7 +23,7 @@ namespace { class AppControllerPlatformAppBrowserTest : public InProcessBrowserTest { protected: AppControllerPlatformAppBrowserTest() - : native_browser_list(BrowserList::GetInstance( + : native_browser_list(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)) { } @@ -32,7 +33,7 @@ class AppControllerPlatformAppBrowserTest : public InProcessBrowserTest { } // Mac only has the native desktop. - const BrowserList* native_browser_list; + const chrome::BrowserListImpl* native_browser_list; }; // Test that if only a platform app window is open and no browser windows are @@ -52,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(AppControllerPlatformAppBrowserTest, class AppControllerWebAppBrowserTest : public InProcessBrowserTest { protected: AppControllerWebAppBrowserTest() - : native_browser_list(BrowserList::GetInstance( + : native_browser_list(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)) { } @@ -65,7 +66,7 @@ class AppControllerWebAppBrowserTest : public InProcessBrowserTest { } // Mac only has the native desktop. - const BrowserList* native_browser_list; + const chrome::BrowserListImpl* native_browser_list; }; // Test that in web app mode a reopen event opens the app URL. diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index bf80305..4e7dffd 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -55,7 +55,7 @@ #include "chrome/browser/sessions/tab_restore_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/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/find_bar/find_notification_details.h" #include "chrome/browser/ui/host_desktop.h" @@ -821,7 +821,7 @@ void BrowserClosedNotificationObserver::Observe( } // The automation layer doesn't support non-native desktops. - int browser_count = static_cast<int>(BrowserList::GetInstance( + int browser_count = static_cast<int>(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); // We get the notification before the browser is removed from the BrowserList. bool app_closing = browser_count == 1; @@ -871,7 +871,7 @@ void BrowserCountChangeNotificationObserver::Observe( type == chrome::NOTIFICATION_BROWSER_CLOSED); // The automation layer doesn't support non-native desktops. - int current_count = static_cast<int>(BrowserList::GetInstance( + int current_count = static_cast<int>(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); if (type == chrome::NOTIFICATION_BROWSER_CLOSED) { // At the time of the notification the browser being closed is not removed diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 97978f21..b844bac 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -27,7 +27,7 @@ #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.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_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/view_type_utils.h" @@ -156,8 +156,8 @@ namespace automation_util { Browser* GetBrowserAt(int index) { // The automation layer doesn't support non-native desktops. - BrowserList* native_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + chrome::BrowserListImpl* native_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); if (index < 0 || index >= static_cast<int>(native_list->size())) return NULL; return native_list->get(index); diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 51edc54..030501c 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -93,6 +93,7 @@ #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_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/extensions/application_launch.h" @@ -289,7 +290,8 @@ void TestingAutomationProvider::OnBrowserRemoved(Browser* browser) { // want the automation provider (and hence the process) to go away when the // last browser goes away. // The automation layer doesn't support non-native desktops. - if (BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->empty() && + if (chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->empty() && !CommandLine::ForCurrentProcess()->HasSwitch( switches::kKeepAliveForTest)) { // If you change this, update Observer for chrome::SESSION_END @@ -608,7 +610,7 @@ void TestingAutomationProvider::Reload(int handle, void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) { // The automation layer doesn't support non-native desktops. - *window_count = static_cast<int>(BrowserList::GetInstance( + *window_count = static_cast<int>(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); } @@ -1127,7 +1129,7 @@ void TestingAutomationProvider::GetBrowserWindowCountJSON( DictionaryValue dict; // The automation layer doesn't support non-native desktops. dict.SetInteger("count", - static_cast<int>(BrowserList::GetInstance( + static_cast<int>(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)->size())); AutomationJSONReply(this, reply_message).SendSuccess(&dict); } @@ -1519,7 +1521,7 @@ void TestingAutomationProvider::WaitForBrowserWindowCountToBecome( int target_count, IPC::Message* reply_message) { // The automation layer doesn't support non-native desktops. - int current_count = static_cast<int>(BrowserList::GetInstance( + int current_count = static_cast<int>(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); if (current_count == target_count) { AutomationMsg_WaitForBrowserWindowCountToBecome::WriteReplyParams( diff --git a/chrome/browser/chromeos/memory/oom_priority_manager.cc b/chrome/browser/chromeos/memory/oom_priority_manager.cc index 555ae6b..3225299 100644 --- a/chrome/browser/chromeos/memory/oom_priority_manager.cc +++ b/chrome/browser/chromeos/memory/oom_priority_manager.cc @@ -28,7 +28,7 @@ #include "chrome/browser/memory_details.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_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -529,8 +529,10 @@ void OomPriorityManager::Observe(int type, // 2) last time a tab was selected // 3) is the tab currently selected void OomPriorityManager::AdjustOomPriorities() { - if (BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH)->empty()) + if (chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_ASH)->empty()) { return; + } // Check for a discontinuity in time caused by the machine being suspended. if (!last_adjust_time_.is_null()) { @@ -557,9 +559,9 @@ OomPriorityManager::TabStatsList OomPriorityManager::GetTabStatsOnUIThread() { TabStatsList stats_list; stats_list.reserve(32); // 99% of users have < 30 tabs open bool browser_active = true; - const BrowserList* ash_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); - for (BrowserList::const_reverse_iterator browser_iterator = + const chrome::BrowserListImpl* ash_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + for (chrome::BrowserListImpl::const_reverse_iterator browser_iterator = ash_browser_list->begin_last_active(); browser_iterator != ash_browser_list->end_last_active(); ++browser_iterator) { diff --git a/chrome/browser/devtools/browser_list_tabcontents_provider.cc b/chrome/browser/devtools/browser_list_tabcontents_provider.cc index 37de019..0c75c39 100644 --- a/chrome/browser/devtools/browser_list_tabcontents_provider.cc +++ b/chrome/browser/devtools/browser_list_tabcontents_provider.cc @@ -12,6 +12,7 @@ #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_list_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" @@ -84,8 +85,8 @@ std::string BrowserListTabContentsProvider::GetPageThumbnailData( RenderViewHost* BrowserListTabContentsProvider::CreateNewTarget() { // TODO(gab): Do not hardcode HOST_DESKTOP_TYPE_NATIVE below once // chrome::NewEmptyWindow() above has been made multi-desktop friendly. - const BrowserList* browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + const chrome::BrowserListImpl* browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); if (browser_list->empty()) chrome::NewEmptyWindowDeprecated(profile_); diff --git a/chrome/browser/devtools/devtools_window.cc b/chrome/browser/devtools/devtools_window.cc index 93722f5..cd928ce 100644 --- a/chrome/browser/devtools/devtools_window.cc +++ b/chrome/browser/devtools/devtools_window.cc @@ -27,7 +27,7 @@ #include "chrome/browser/themes/theme_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/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -822,9 +822,9 @@ void DevToolsWindow::OpenInNewTab(const std::string& url) { host_desktop_type = chrome::GetActiveDesktop(); } - const BrowserList* browser_list = - BrowserList::GetInstance(host_desktop_type); - for (BrowserList::const_iterator it = browser_list->begin(); + const chrome::BrowserListImpl* browser_list = + chrome::BrowserListImpl::GetInstance(host_desktop_type); + for (chrome::BrowserListImpl::const_iterator it = browser_list->begin(); it != browser_list->end(); ++it) { if ((*it)->type() == Browser::TYPE_TABBED) { (*it)->OpenURL(params); diff --git a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc index 9579482..1eccab5 100644 --- a/chrome/browser/managed_mode/managed_mode_navigation_observer.cc +++ b/chrome/browser/managed_mode/managed_mode_navigation_observer.cc @@ -22,7 +22,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_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/pref_names.h" @@ -92,7 +92,8 @@ void GoBackToSafety(content::WebContents* web_contents) { // If this is the last tab on this desktop, open a new window. chrome::HostDesktopType host_desktop_type = chrome::GetHostDesktopTypeForNativeView(web_contents->GetNativeView()); - const BrowserList* browser_list = BrowserList::GetInstance(host_desktop_type); + const chrome::BrowserListImpl* browser_list = + chrome::BrowserListImpl::GetInstance(host_desktop_type); if (browser_list->size() == 1) { Browser* browser = browser_list->get(0); DCHECK(browser == chrome::FindBrowserWithWebContents(web_contents)); diff --git a/chrome/browser/metrics/perf_provider_chromeos.cc b/chrome/browser/metrics/perf_provider_chromeos.cc index c3f5bef..303fada 100644 --- a/chrome/browser/metrics/perf_provider_chromeos.cc +++ b/chrome/browser/metrics/perf_provider_chromeos.cc @@ -41,8 +41,9 @@ namespace metrics { // is destroyed. class WindowedIncognitoObserver : public chrome::BrowserListObserver { public: - WindowedIncognitoObserver() : incognito_launched_(false) { - BrowserList::AddObserver(this); + WindowedIncognitoObserver() + : incognito_launched_(false) { + BrowserList::AddObserver(this); } virtual ~WindowedIncognitoObserver() { diff --git a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc index 3ed753a..c0e8a6b 100644 --- a/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc +++ b/chrome/browser/metro_viewer/metro_viewer_process_host_win.cc @@ -8,7 +8,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/ui/ash/ash_init.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -22,11 +22,11 @@ namespace { void CloseOpenAshBrowsers() { - BrowserList* browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + chrome::BrowserListImpl* browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); if (browser_list) { - for (BrowserList::const_iterator i = browser_list->begin(); - i != browser_list->end(); ++i) { + for (chrome::BrowserListImpl::const_iterator i = browser_list->begin(); + i != browser_list->end(); ++i) { Browser* browser = *i; browser->window()->Close(); // If the attempt to Close the browser fails due to unload handlers on diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc index 3b98fbd..6406679 100644 --- a/chrome/browser/policy/policy_browsertest.cc +++ b/chrome/browser/policy/policy_browsertest.cc @@ -50,6 +50,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" @@ -1313,8 +1314,8 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { // Verifies that incognito windows can't be opened when disabled by policy. // Only test this on the native desktop. - const BrowserList* native_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + const chrome::BrowserListImpl* native_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); // Disable incognito via policy and verify that incognito windows can't be // opened. diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc index 385de9f9..f934e99 100644 --- a/chrome/browser/sessions/session_restore_browsertest.cc +++ b/chrome/browser/sessions/session_restore_browsertest.cc @@ -21,7 +21,7 @@ #include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" @@ -48,7 +48,7 @@ class SessionRestoreTest : public InProcessBrowserTest { public: SessionRestoreTest() - : native_browser_list(BrowserList::GetInstance( + : native_browser_list(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)) { } @@ -169,7 +169,7 @@ class SessionRestoreTest : public InProcessBrowserTest { GURL url3_; // The SessionRestore browser tests only uses the native desktop for now. - const BrowserList* native_browser_list; + const chrome::BrowserListImpl* native_browser_list; }; #if defined(OS_CHROMEOS) diff --git a/chrome/browser/sessions/tab_restore_browsertest.cc b/chrome/browser/sessions/tab_restore_browsertest.cc index fb8bf52..ea72074 100644 --- a/chrome/browser/sessions/tab_restore_browsertest.cc +++ b/chrome/browser/sessions/tab_restore_browsertest.cc @@ -10,7 +10,7 @@ #include "chrome/app/chrome_command_ids.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_commands.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/find_bar/find_notification_details.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -34,7 +34,7 @@ class TabRestoreTest : public InProcessBrowserTest { public: TabRestoreTest() - : native_browser_list(BrowserList::GetInstance( + : native_browser_list(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)) { url1_ = ui_test_utils::GetTestUrl( base::FilePath().AppendASCII("session_history"), @@ -148,7 +148,7 @@ class TabRestoreTest : public InProcessBrowserTest { GURL url2_; // The TabRestore browser tests only uses the native desktop for now. - const BrowserList* native_browser_list; + const chrome::BrowserListImpl* native_browser_list; private: DISALLOW_COPY_AND_ASSIGN(TabRestoreTest); 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 2ce5659..6d866da 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 @@ -13,7 +13,7 @@ #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_finder.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/extensions/native_app_window.h" #include "chrome/browser/ui/host_desktop.h" @@ -149,9 +149,9 @@ AppShortcutLauncherItemController::GetRunningApplications() { if (!extension) return items; - const BrowserList* ash_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); - for (BrowserList::const_reverse_iterator it = + const chrome::BrowserListImpl* ash_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + for (chrome::BrowserListImpl::const_reverse_iterator it = ash_browser_list->begin_last_active(); it != ash_browser_list->end_last_active(); ++it) { Browser* browser = *it; diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc index 59b8ed4..685f8fb 100644 --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc @@ -39,6 +39,7 @@ #include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/extensions/application_launch.h" @@ -1162,7 +1163,7 @@ void ChromeLauncherControllerPerApp::UpdateBrowserItemStatus() { aura::Window* window = ash::wm::GetActiveWindow(); if (window && chrome::FindBrowserWithWindow(window)) { browser_status = ash::STATUS_ACTIVE; - } else if (!BrowserList::GetInstance( + } else if (!chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_ASH)->empty()) { browser_status = ash::STATUS_RUNNING; } else { @@ -1434,10 +1435,10 @@ ChromeLauncherControllerPerApp::GetBrowserApplicationList() { items.push_back(new ChromeLauncherAppMenuItem( l10n_util::GetStringFUTF16(IDS_LAUNCHER_CHROME_BROWSER_NAME, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)), NULL)); - const BrowserList* ash_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + const chrome::BrowserListImpl* ash_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); int index = 1; - for (BrowserList::const_reverse_iterator it = + for (chrome::BrowserListImpl::const_reverse_iterator it = ash_browser_list->begin_last_active(); it != ash_browser_list->end_last_active(); ++it, ++index) { Browser* browser = *it; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index d206c55..1bde2f4 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -95,6 +95,7 @@ #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_list_impl.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_tab_contents.h" #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" @@ -631,7 +632,7 @@ void Browser::OnWindowClosing() { browser_shutdown::IsTryingToQuit() || !chrome::WillKeepAlive(); if (should_quit_if_last_browser && - BrowserList::GetInstance(host_desktop_type_)->size() == 1) { + chrome::BrowserListImpl::GetInstance(host_desktop_type_)->size() == 1) { browser_shutdown::OnShutdownStarting(browser_shutdown::WINDOW_CLOSE); } diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc index 0ee386c..55e5480 100644 --- a/chrome/browser/ui/browser_finder.cc +++ b/chrome/browser/ui/browser_finder.cc @@ -6,7 +6,7 @@ #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_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -84,7 +84,8 @@ Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, chrome::HostDesktopType desktop_type, bool match_tabbed, bool match_original_profiles) { - BrowserList* browser_list_impl = BrowserList::GetInstance(desktop_type); + chrome::BrowserListImpl* browser_list_impl = + chrome::BrowserListImpl::GetInstance(desktop_type); if (!browser_list_impl) return NULL; uint32 match_types = kMatchAny; @@ -108,10 +109,11 @@ Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, size_t GetBrowserCountImpl(Profile* profile, chrome::HostDesktopType desktop_type, uint32 match_types) { - BrowserList* browser_list_impl = BrowserList::GetInstance(desktop_type); + chrome::BrowserListImpl* browser_list_impl = + chrome::BrowserListImpl::GetInstance(desktop_type); size_t count = 0; if (browser_list_impl) { - for (BrowserList::const_iterator i = browser_list_impl->begin(); + for (chrome::BrowserListImpl::const_iterator i = browser_list_impl->begin(); i != browser_list_impl->end(); ++i) { if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, match_types)) count++; @@ -181,7 +183,7 @@ Browser* FindBrowserWithWebContents(const WebContents* web_contents) { } Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { - BrowserList* list = BrowserList::GetInstance(type); + BrowserListImpl* list = BrowserListImpl::GetInstance(type); // We are only interested in last active browsers, so we don't fall back to // all browsers like FindBrowserWith* do. return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), @@ -189,7 +191,7 @@ Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { } Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) { - BrowserList* browser_list_impl = BrowserList::GetInstance(type); + BrowserListImpl* browser_list_impl = BrowserListImpl::GetInstance(type); if (browser_list_impl) return browser_list_impl->GetLastActive(); return NULL; @@ -199,7 +201,7 @@ size_t GetTotalBrowserCount() { size_t count = 0; for (HostDesktopType t = HOST_DESKTOP_TYPE_FIRST; t < HOST_DESKTOP_TYPE_COUNT; t = static_cast<HostDesktopType>(t + 1)) { - count += BrowserList::GetInstance(t)->size(); + count += BrowserListImpl::GetInstance(t)->size(); } return count; } diff --git a/chrome/browser/ui/browser_iterator.cc b/chrome/browser/ui/browser_iterator.cc index 96df7fd..73571d5 100644 --- a/chrome/browser/ui/browser_iterator.cc +++ b/chrome/browser/ui/browser_iterator.cc @@ -7,7 +7,8 @@ namespace chrome { BrowserIterator::BrowserIterator() - : current_browser_list_(BrowserList::GetInstance(HOST_DESKTOP_TYPE_FIRST)), + : current_browser_list_( + BrowserListImpl::GetInstance(HOST_DESKTOP_TYPE_FIRST)), current_iterator_(current_browser_list_->begin()), next_desktop_type_( static_cast<HostDesktopType>(HOST_DESKTOP_TYPE_FIRST + 1)) { @@ -23,7 +24,7 @@ void BrowserIterator::NextBrowserListIfAtEnd() { // Make sure either |current_iterator_| is valid or done(). while (current_iterator_ == current_browser_list_->end() && next_desktop_type_ < HOST_DESKTOP_TYPE_COUNT) { - current_browser_list_ = BrowserList::GetInstance(next_desktop_type_); + current_browser_list_ = BrowserListImpl::GetInstance(next_desktop_type_); current_iterator_ = current_browser_list_->begin(); next_desktop_type_ = static_cast<HostDesktopType>(next_desktop_type_ + 1); } diff --git a/chrome/browser/ui/browser_iterator.h b/chrome/browser/ui/browser_iterator.h index 387fcc0..91ea8e8 100644 --- a/chrome/browser/ui/browser_iterator.h +++ b/chrome/browser/ui/browser_iterator.h @@ -5,7 +5,7 @@ #ifndef CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ #define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/host_desktop.h" class Browser; @@ -14,7 +14,7 @@ namespace chrome { // 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. +// const_iterator of a given BrowserListImpl instead. // // Example: // for (BrowserIterator iterator; !iterator.done(); iterator.Next()) { @@ -52,12 +52,12 @@ class BrowserIterator { // |current_iterator_| is valid or done(). void NextBrowserListIfAtEnd(); - // The BrowserList currently being iterated over. Instances of this class do - // not own this pointer. - BrowserList* current_browser_list_; + // The BrowserListImpl currently being iterated over. Instances of this class + // do not own this pointer. + BrowserListImpl* current_browser_list_; // The underlying iterator over browsers in |current_browser_list_|. - BrowserList::const_iterator current_iterator_; + BrowserListImpl::const_iterator current_iterator_; // The next HostDesktopType to iterate over when |current_iterator_| reaches // |current_browser_list_->end()|. diff --git a/chrome/browser/ui/browser_iterator_unittest.cc b/chrome/browser/ui/browser_iterator_unittest.cc index 7f30a14..33d3be2 100644 --- a/chrome/browser/ui/browser_iterator_unittest.cc +++ b/chrome/browser/ui/browser_iterator_unittest.cc @@ -5,7 +5,7 @@ #include "chrome/browser/ui/browser_iterator.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/test/base/browser_with_test_window_test.h" @@ -49,14 +49,14 @@ TEST_F(BrowserIteratorTest, BrowsersOnMultipleDesktops) { chrome::CreateBrowserWithTestWindowForParams(&ash_params)); // Sanity checks. - BrowserList* native_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + chrome::BrowserListImpl* native_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); #if defined(OS_CHROMEOS) // On Chrome OS, the native list and the ash list are the same. EXPECT_EQ(5U, native_list->size()); #else - BrowserList* ash_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + chrome::BrowserListImpl* ash_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); EXPECT_EQ(3U, native_list->size()); EXPECT_EQ(2U, ash_list->size()); #endif @@ -76,14 +76,14 @@ TEST_F(BrowserIteratorTest, NoBrowsersOnAshDesktop) { chrome::CreateBrowserWithTestWindowForParams(&native_params)); // Sanity checks. - BrowserList* native_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + chrome::BrowserListImpl* native_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); EXPECT_EQ(3U, native_list->size()); #if !defined(OS_CHROMEOS) // On non-Chrome OS platforms the Ash list is independent from the native // list, double-check that it's empty. - BrowserList* ash_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + chrome::BrowserListImpl* ash_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); EXPECT_EQ(0U, ash_list->size()); #endif @@ -100,14 +100,14 @@ TEST_F(BrowserIteratorTestWithInitialWindowInAsh, NoBrowsersOnNativeDesktop) { scoped_ptr<Browser> browser3( chrome::CreateBrowserWithTestWindowForParams(&ash_params)); - BrowserList* ash_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + chrome::BrowserListImpl* ash_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); EXPECT_EQ(3U, ash_list->size()); #if !defined(OS_CHROMEOS) // On non-Chrome OS platforms the native list is independent from the Ash // list; double-check that it's empty. - BrowserList* native_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + chrome::BrowserListImpl* native_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); EXPECT_EQ(0U, native_list->size()); #endif diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc index 9f8c4b3..42b26e0 100644 --- a/chrome/browser/ui/browser_list.cc +++ b/chrome/browser/ui/browser_list.cc @@ -4,20 +4,13 @@ #include "chrome/browser/ui/browser_list.h" -#include <algorithm> - -#include "base/logging.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/browser_shutdown.h" -#include "chrome/browser/lifetime/application_lifetime.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_impl.h" #include "chrome/browser/ui/browser_list_observer.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/host_desktop.h" -#include "chrome/common/chrome_notification_types.h" -#include "content/public/browser/notification_service.h" #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/login/user_manager.h" @@ -25,97 +18,42 @@ using content::WebContents; -// static -// Intentionally leak |observers_| to avoid exit time destructors. -ObserverList<chrome::BrowserListObserver>* BrowserList::observers_ = - new ObserverList<chrome::BrowserListObserver>; - -// static -BrowserList* BrowserList::native_instance_ = NULL; -BrowserList* BrowserList::ash_instance_ = NULL; - -//////////////////////////////////////////////////////////////////////////////// -// BrowserList, public: +namespace { -Browser* BrowserList::GetLastActive() const { - if (!last_active_browsers_.empty()) - return *(last_active_browsers_.rbegin()); - return NULL; +chrome::BrowserListImpl* GetNativeList() { + return chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); } -// static -BrowserList* BrowserList::GetInstance(chrome::HostDesktopType type) { - BrowserList** list = NULL; - if (type == chrome::HOST_DESKTOP_TYPE_NATIVE) - list = &native_instance_; - else if (type == chrome::HOST_DESKTOP_TYPE_ASH) - list = &ash_instance_; - else - NOTREACHED(); - if (!*list) - *list = new BrowserList; - return *list; -} +} // namespace // static void BrowserList::AddBrowser(Browser* browser) { - DCHECK(browser); - // Push |browser| on the appropriate list instance. - BrowserList* browser_list = GetInstance(browser->host_desktop_type()); - browser_list->browsers_.push_back(browser); - - g_browser_process->AddRefModule(); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_BROWSER_OPENED, - content::Source<Browser>(browser), - content::NotificationService::NoDetails()); - - FOR_EACH_OBSERVER(chrome::BrowserListObserver, *observers_, - OnBrowserAdded(browser)); + chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> + AddBrowser(browser); } // static void BrowserList::RemoveBrowser(Browser* browser) { - // Remove |browser| from the appropriate list instance. - BrowserList* browser_list = GetInstance(browser->host_desktop_type()); - RemoveBrowserFrom(browser, &browser_list->last_active_browsers_); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_BROWSER_CLOSED, - content::Source<Browser>(browser), - content::NotificationService::NoDetails()); - - RemoveBrowserFrom(browser, &browser_list->browsers_); - - FOR_EACH_OBSERVER(chrome::BrowserListObserver, *observers_, - OnBrowserRemoved(browser)); - - g_browser_process->ReleaseModule(); - - // If we're exiting, send out the APP_TERMINATING notification to allow other - // modules to shut themselves down. - if (browser_list->browsers_.empty() && - (browser_shutdown::IsTryingToQuit() || - g_browser_process->IsShuttingDown())) { - // Last browser has just closed, and this is a user-initiated quit or there - // is no module keeping the app alive, so send out our notification. No need - // to call ProfileManager::ShutdownSessionServices() as part of the - // shutdown, because Browser::WindowClosing() already makes sure that the - // SessionService is created and notified. - chrome::NotifyAppTerminating(); - chrome::OnAppExiting(); - } + chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> + RemoveBrowser(browser); } // static void BrowserList::AddObserver(chrome::BrowserListObserver* observer) { - observers_->AddObserver(observer); + for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST; + t < chrome::HOST_DESKTOP_TYPE_COUNT; + t = static_cast<chrome::HostDesktopType>(t + 1)) { + chrome::BrowserListImpl::GetInstance(t)->AddObserver(observer); + } } // static void BrowserList::RemoveObserver(chrome::BrowserListObserver* observer) { - observers_->RemoveObserver(observer); + for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST; + t < chrome::HOST_DESKTOP_TYPE_COUNT; + t = static_cast<chrome::HostDesktopType>(t + 1)) { + chrome::BrowserListImpl::GetInstance(t)->RemoveObserver(observer); + } } void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) { @@ -133,13 +71,8 @@ void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) { // static void BrowserList::SetLastActive(Browser* browser) { - BrowserList* browser_list = GetInstance(browser->host_desktop_type()); - - RemoveBrowserFrom(browser, &browser_list->last_active_browsers_); - browser_list->last_active_browsers_.push_back(browser); - - FOR_EACH_OBSERVER(chrome::BrowserListObserver, *observers_, - OnBrowserSetLastActive(browser)); + chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> + SetLastActive(browser); } // static @@ -167,21 +100,3 @@ bool BrowserList::IsOffTheRecordSessionActiveForProfile(Profile* profile) { } return false; } - -//////////////////////////////////////////////////////////////////////////////// -// BrowserList, private: - -BrowserList::BrowserList() { -} - -BrowserList::~BrowserList() { -} - -// static -void BrowserList::RemoveBrowserFrom(Browser* browser, - BrowserVector* browser_list) { - BrowserVector::iterator remove_browser = - std::find(browser_list->begin(), browser_list->end(), browser); - if (remove_browser != browser_list->end()) - browser_list->erase(remove_browser); -} diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h index 215dece..b969ab3f 100644 --- a/chrome/browser/ui/browser_list.h +++ b/chrome/browser/ui/browser_list.h @@ -8,8 +8,6 @@ #include <vector> #include "base/basictypes.h" -#include "base/observer_list.h" -#include "chrome/browser/ui/host_desktop.h" class Browser; class Profile; @@ -18,56 +16,23 @@ namespace chrome { class BrowserListObserver; } -// Maintains a list of Browser objects present in a given HostDesktop (see -// HostDesktopType). +// Stores a list of all Browser objects. class BrowserList { public: typedef std::vector<Browser*> BrowserVector; - typedef BrowserVector::const_iterator const_iterator; - typedef BrowserVector::const_reverse_iterator const_reverse_iterator; - // Returns the last active browser for this list. - Browser* GetLastActive() const; - - // Browsers are added to the list before they have constructed windows, - // so the |window()| member function may return NULL. - const_iterator begin() const { return browsers_.begin(); } - const_iterator end() const { return browsers_.end(); } - - bool empty() const { return browsers_.empty(); } - size_t size() const { return browsers_.size(); } - - Browser* get(size_t index) const { return browsers_[index]; } - - // Returns iterated access to list of open browsers ordered by when - // they were last active. The underlying data structure is a vector - // and we push_back on recent access so a reverse iterator gives the - // latest accessed browser first. - const_reverse_iterator begin_last_active() const { - return last_active_browsers_.rbegin(); - } - const_reverse_iterator end_last_active() const { - return last_active_browsers_.rend(); - } - - static BrowserList* GetInstance(chrome::HostDesktopType type); - - // Adds or removes |browser| from the list it is associated with. The browser - // object should be valid BEFORE these calls (for the benefit of observers), - // so notify and THEN delete the object. + // Adds and removes browsers from the list they are associated with. The + // browser object should be valid BEFORE these calls (for the benefit of + // observers), so notify and THEN delete the object. static void AddBrowser(Browser* browser); static void RemoveBrowser(Browser* browser); - // Adds and removes |observer| from the observer list for all desktops. - // Observers are responsible for making sure the notifying browser is relevant - // to them (e.g., on the specific desktop they care about if any). + // Adds and removes |observer| from the observer list of each desktop. static void AddObserver(chrome::BrowserListObserver* observer); static void RemoveObserver(chrome::BrowserListObserver* observer); // Called by Browser objects when their window is activated (focused). This - // allows us to determine what the last active Browser was on each desktop. - // Note: This only takes effect on the appropriate browser list as determined - // by |browser->host_desktop_type()|. + // allows us to determine what the last active Browser was. static void SetLastActive(Browser* browser); // Closes all browsers for |profile| across all desktops. @@ -80,29 +45,6 @@ class BrowserList { // Returns true if at least one incognito session is active for |profile| // across all desktops. static bool IsOffTheRecordSessionActiveForProfile(Profile* profile); - - private: - BrowserList(); - ~BrowserList(); - - // Helper method to remove a browser instance from a list of browsers - static void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); - - // A vector of the browsers in this list, in the order they were added. - BrowserVector browsers_; - // A vector of the browsers in this list that have been activated, in the - // reverse order in which they were last activated. - BrowserVector last_active_browsers_; - - // A list of observers which will be notified of every browser addition and - // removal across all BrowserLists. - static ObserverList<chrome::BrowserListObserver>* observers_; - - // Nothing fancy, since we only have two HDTs. - static BrowserList* native_instance_; - static BrowserList* ash_instance_; - - DISALLOW_COPY_AND_ASSIGN(BrowserList); }; #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ diff --git a/chrome/browser/ui/browser_list_impl.cc b/chrome/browser/ui/browser_list_impl.cc new file mode 100644 index 0000000..82b47f5 --- /dev/null +++ b/chrome/browser/ui/browser_list_impl.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2012 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_list_impl.h" + +#include "base/command_line.h" +#include "base/logging.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/browser_shutdown.h" +#include "chrome/browser/lifetime/application_lifetime.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_list_observer.h" +#include "chrome/common/chrome_notification_types.h" +#include "chrome/common/chrome_switches.h" +#include "content/public/browser/notification_service.h" + +// #include "build/build_config.h" +// #include "base/prefs/pref_service.h" + +namespace chrome { + +// static +BrowserListImpl* BrowserListImpl::native_instance_ = NULL; +BrowserListImpl* BrowserListImpl::ash_instance_ = NULL; + +//////////////////////////////////////////////////////////////////////////////// +// BrowserListImpl, public: + +// static +BrowserListImpl* BrowserListImpl::GetInstance(HostDesktopType type) { + BrowserListImpl** list = NULL; + if (type == HOST_DESKTOP_TYPE_NATIVE) + list = &native_instance_; + else if (type == HOST_DESKTOP_TYPE_ASH) + list = &ash_instance_; + else + NOTREACHED(); + if (!*list) + *list = new BrowserListImpl; + return *list; +} + +void BrowserListImpl::AddBrowser(Browser* browser) { + DCHECK(browser); + browsers_.push_back(browser); + + g_browser_process->AddRefModule(); + + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_BROWSER_OPENED, + content::Source<Browser>(browser), + content::NotificationService::NoDetails()); + + // Send out notifications after add has occurred. Do some basic checking to + // try to catch evil observers that change the list from under us. + size_t original_count = observers_.size(); + FOR_EACH_OBSERVER(BrowserListObserver, observers_, OnBrowserAdded(browser)); + DCHECK_EQ(original_count, observers_.size()) + << "observer list modified during notification"; +} + +void BrowserListImpl::RemoveBrowser(Browser* browser) { + RemoveBrowserFrom(browser, &last_active_browsers_); + + content::NotificationService::current()->Notify( + chrome::NOTIFICATION_BROWSER_CLOSED, + content::Source<Browser>(browser), + content::NotificationService::NoDetails()); + + RemoveBrowserFrom(browser, &browsers_); + + FOR_EACH_OBSERVER(BrowserListObserver, observers_, OnBrowserRemoved(browser)); + + g_browser_process->ReleaseModule(); + + // If we're exiting, send out the APP_TERMINATING notification to allow other + // modules to shut themselves down. + if (browsers_.empty() && + (browser_shutdown::IsTryingToQuit() || + g_browser_process->IsShuttingDown())) { + // Last browser has just closed, and this is a user-initiated quit or there + // is no module keeping the app alive, so send out our notification. No need + // to call ProfileManager::ShutdownSessionServices() as part of the + // shutdown, because Browser::WindowClosing() already makes sure that the + // SessionService is created and notified. + chrome::NotifyAppTerminating(); + chrome::OnAppExiting(); + } +} + +void BrowserListImpl::AddObserver(BrowserListObserver* observer) { + observers_.AddObserver(observer); +} + +void BrowserListImpl::RemoveObserver(BrowserListObserver* observer) { + observers_.RemoveObserver(observer); +} + +void BrowserListImpl::SetLastActive(Browser* browser) { + RemoveBrowserFrom(browser, &last_active_browsers_); + last_active_browsers_.push_back(browser); + + FOR_EACH_OBSERVER(BrowserListObserver, observers_, + OnBrowserSetLastActive(browser)); +} + +Browser* BrowserListImpl::GetLastActive() const { + if (!last_active_browsers_.empty()) + return *(last_active_browsers_.rbegin()); + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////// +// BrowserListImpl, private: + +BrowserListImpl::BrowserListImpl() { +} + +BrowserListImpl::~BrowserListImpl() { +} + +void BrowserListImpl::RemoveBrowserFrom(Browser* browser, + BrowserVector* browser_list) { + const iterator remove_browser = + std::find(browser_list->begin(), browser_list->end(), browser); + if (remove_browser != browser_list->end()) + browser_list->erase(remove_browser); +} + +} // namespace chrome diff --git a/chrome/browser/ui/browser_list_impl.h b/chrome/browser/ui/browser_list_impl.h new file mode 100644 index 0000000..d7107e3 --- /dev/null +++ b/chrome/browser/ui/browser_list_impl.h @@ -0,0 +1,92 @@ +// Copyright (c) 2012 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_LIST_IMPL_H_ +#define CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ + +#include "base/observer_list.h" +#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/host_desktop.h" + +class Browser; +class Profile; + +namespace chrome { + +class BrowserListObserver; + +// Maintains a list of Browser objects present in a given HostDesktop (see +// HostDesktopType). +class BrowserListImpl { + public: + typedef std::vector<Browser*> BrowserVector; + typedef BrowserVector::iterator iterator; + typedef BrowserVector::const_iterator const_iterator; + typedef BrowserVector::const_reverse_iterator const_reverse_iterator; + + static BrowserListImpl* GetInstance(HostDesktopType type); + + // Adds and removes browsers from the global list. The browser object should + // be valid BEFORE these calls (for the benefit of observers), so notify and + // THEN delete the object. + void AddBrowser(Browser* browser); + void RemoveBrowser(Browser* browser); + + // Called by Browser objects when their window is activated (focused). This + // allows us to determine what the last active Browser was. + void SetLastActive(Browser* browser); + + Browser* GetLastActive() const; + + // Browsers are added to the list before they have constructed windows, + // so the |window()| member function may return NULL. + const_iterator begin() const { return browsers_.begin(); } + const_iterator end() const { return browsers_.end(); } + + bool empty() const { return browsers_.empty(); } + size_t size() const { return browsers_.size(); } + + Browser* get(size_t index) const { return browsers_[index]; } + + // Returns iterated access to list of open browsers ordered by when + // they were last active. The underlying data structure is a vector + // and we push_back on recent access so a reverse iterator gives the + // latest accessed browser first. + const_reverse_iterator begin_last_active() const { + return last_active_browsers_.rbegin(); + } + const_reverse_iterator end_last_active() const { + return last_active_browsers_.rend(); + } + + private: + BrowserListImpl(); + ~BrowserListImpl(); + + // Only callable by BrowserList::(Add|Remove)Observer. + // TODO(gab): Merge BrowserListImpl into BrowserList removing the need for + // friend. + friend void BrowserList::AddObserver(chrome::BrowserListObserver*); + friend void BrowserList::RemoveObserver(chrome::BrowserListObserver*); + void AddObserver(BrowserListObserver* observer); + void RemoveObserver(BrowserListObserver* observer); + + // Helper method to remove a browser instance from a list of browsers + void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list); + + ObserverList<BrowserListObserver> observers_; + + BrowserVector browsers_; + BrowserVector last_active_browsers_; + + // Nothing fancy, since we only have two HDTs. + static BrowserListImpl* native_instance_; + static BrowserListImpl* ash_instance_; + + DISALLOW_COPY_AND_ASSIGN(BrowserListImpl); +}; + +} // namespace chrome + +#endif // CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_ diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index 49959a5..d60aacb 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -26,7 +26,7 @@ #include "chrome/browser/themes/theme_properties.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_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/gtk_theme_service.h" @@ -431,8 +431,8 @@ void MakeAppModalWindowGroup() { void AppModalDismissedUngroupWindows() { // GTK only has the native desktop. - const BrowserList* native_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + const chrome::BrowserListImpl* native_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); if (!native_browser_list->empty()) { std::vector<GtkWindow*> transient_windows; diff --git a/chrome/browser/ui/host_desktop.cc b/chrome/browser/ui/host_desktop.cc index d1ac55c..50900ca 100644 --- a/chrome/browser/ui/host_desktop.cc +++ b/chrome/browser/ui/host_desktop.cc @@ -11,7 +11,7 @@ #include "ash/shell.h" #include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/aura/active_desktop_monitor.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" namespace chrome { @@ -79,8 +79,10 @@ HostDesktopType GetHostDesktopTypeForBrowser(const Browser* browser) { for (HostDesktopType type = HOST_DESKTOP_TYPE_FIRST; type < HOST_DESKTOP_TYPE_COUNT; type = static_cast<HostDesktopType>(type + 1)) { - BrowserList::const_iterator begin = BrowserList::GetInstance(type)->begin(); - BrowserList::const_iterator end = BrowserList::GetInstance(type)->end(); + BrowserListImpl::const_iterator begin = + BrowserListImpl::GetInstance(type)->begin(); + BrowserListImpl::const_iterator end = + BrowserListImpl::GetInstance(type)->end(); if (std::find(begin, end, browser) != end) return type; } diff --git a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc index 8b3675f0..110bf2f 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_iterator_unittest.cc @@ -11,7 +11,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_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/common/pref_names.h" @@ -35,8 +35,8 @@ size_t CountAllTabs() { TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { // Make sure we have 1 window to start with. - EXPECT_EQ(1U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(1U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); EXPECT_EQ(0U, CountAllTabs()); @@ -56,13 +56,13 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { // Sanity checks. #if defined(OS_CHROMEOS) // The ash desktop is the native desktop on Chrome OS. - EXPECT_EQ(4U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(4U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); #else - EXPECT_EQ(2U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); - EXPECT_EQ(2U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH)->size()); + EXPECT_EQ(2U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(2U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_ASH)->size()); #endif EXPECT_EQ(0, browser()->tab_strip_model()->count()); EXPECT_EQ(0, browser2->tab_strip_model()->count()); @@ -94,8 +94,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) { // Make sure we have 1 window to start with. - EXPECT_EQ(1U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(1U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); // Create more browsers/windows. Browser::CreateParams native_params(profile(), @@ -111,13 +111,13 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) { // Sanity checks. #if defined(OS_CHROMEOS) // The ash desktop is the native desktop on Chrome OS. - EXPECT_EQ(3U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(3U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); #else - EXPECT_EQ(2U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); - EXPECT_EQ(1U, - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH)->size()); + EXPECT_EQ(2U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE)->size()); + EXPECT_EQ(1U, chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_ASH)->size()); #endif EXPECT_EQ(0, browser()->tab_strip_model()->count()); EXPECT_EQ(0, browser2->tab_strip_model()->count()); 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 63617cd..a28641b 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 @@ -12,7 +12,7 @@ #include "base/strings/string_number_conversions.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_list_impl.h" #include "chrome/browser/ui/host_desktop.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/views/frame/browser_view.h" @@ -143,7 +143,7 @@ using test::IDString; using test::GetTabStripForBrowser; TabDragControllerTest::TabDragControllerTest() - : native_browser_list(BrowserList::GetInstance( + : native_browser_list(chrome::BrowserListImpl::GetInstance( chrome::HOST_DESKTOP_TYPE_NATIVE)) { } @@ -564,7 +564,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, namespace { void DeleteSourceDetachedStep2(WebContents* tab, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_EQ(2u, browser_list->size()); Browser* new_browser = browser_list->get(1); // This ends up closing the source window. @@ -606,7 +606,8 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, namespace { -void PressEscapeWhileDetachedStep2(const BrowserList* browser_list) { +void PressEscapeWhileDetachedStep2( + const chrome::BrowserListImpl* browser_list) { ASSERT_EQ(2u, browser_list->size()); Browser* new_browser = browser_list->get(1); ui_controls::SendKeyPress( @@ -645,7 +646,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, namespace { void DragAllStep2(DetachToBrowserTabDragControllerTest* test, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { // Should only be one window. ASSERT_EQ(1u, browser_list->size()); if (test->input_source() == INPUT_SOURCE_TOUCH) { @@ -692,7 +693,7 @@ namespace { void DragAllToSeparateWindowStep2(DetachToBrowserTabDragControllerTest* test, TabStrip* attached_tab_strip, TabStrip* target_tab_strip, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); @@ -755,7 +756,7 @@ void DragAllToSeparateWindowAndCancelStep2( DetachToBrowserTabDragControllerTest* test, TabStrip* attached_tab_strip, TabStrip* target_tab_strip, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_TRUE(attached_tab_strip->IsDragSessionActive()); ASSERT_FALSE(target_tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); @@ -911,7 +912,7 @@ namespace { // Invoked from the nested message loop. void CancelOnNewTabWhenDraggingStep2( DetachToBrowserTabDragControllerTest* test, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_TRUE(TabDragController::IsActive()); ASSERT_EQ(2u, browser_list->size()); @@ -953,7 +954,7 @@ namespace { void DragInMaximizedWindowStep2(DetachToBrowserTabDragControllerTest* test, Browser* browser, TabStrip* tab_strip, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { // There should be another browser. ASSERT_EQ(2u, browser_list->size()); Browser* new_browser = browser_list->get(1); @@ -1278,7 +1279,7 @@ class DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest // Invoked from the nested message loop. void CancelDragTabToWindowInSeparateDisplayStep3( TabStrip* tab_strip, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); ASSERT_EQ(2u, browser_list->size()); @@ -1293,7 +1294,7 @@ void CancelDragTabToWindowInSeparateDisplayStep2( TabStrip* tab_strip, aura::RootWindow* current_root, gfx::Point final_destination, - const BrowserList* browser_list) { + const chrome::BrowserListImpl* browser_list) { ASSERT_FALSE(tab_strip->IsDragSessionActive()); ASSERT_TRUE(TabDragController::IsActive()); ASSERT_EQ(2u, browser_list->size()); diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h index 896770a..3515be1 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h @@ -10,10 +10,13 @@ #include "chrome/test/base/in_process_browser_test.h" class Browser; -class BrowserList; class TabStrip; class TabStripModel; +namespace chrome { +class BrowserListImpl; +} + namespace content { class WebContents; } @@ -46,7 +49,7 @@ class TabDragControllerTest : public InProcessBrowserTest { // The tab drag controller interactive ui tests only use the native desktop // for now. - const BrowserList* native_browser_list; + const chrome::BrowserListImpl* native_browser_list; private: DISALLOW_COPY_AND_ASSIGN(TabDragControllerTest); diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc index 4cee28f..3b4709d 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest_win.cc @@ -9,7 +9,7 @@ #include "base/command_line.h" #include "base/strings/string_number_conversions.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/views/frame/browser_view.h" diff --git a/chrome/browser/ui/window_sizer/window_sizer.cc b/chrome/browser/ui/window_sizer/window_sizer.cc index 86b9404..2afc78d 100644 --- a/chrome/browser/ui/window_sizer/window_sizer.cc +++ b/chrome/browser/ui/window_sizer/window_sizer.cc @@ -11,7 +11,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/ash/ash_init.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window_state.h" #include "chrome/browser/ui/host_desktop.h" @@ -117,9 +117,10 @@ class DefaultStateProvider : public WindowSizer::StateProvider { // GetBoundsOverrideAsh should take over below before this is reached). // TODO(gab): This code should go in a native desktop specific window // sizer as part of fixing crbug.com/175812. - const BrowserList* native_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); - for (BrowserList::const_reverse_iterator it = + const chrome::BrowserListImpl* native_browser_list = + chrome::BrowserListImpl::GetInstance( + chrome::HOST_DESKTOP_TYPE_NATIVE); + for (chrome::BrowserListImpl::const_reverse_iterator it = native_browser_list->begin_last_active(); it != native_browser_list->end_last_active(); ++it) { Browser* last_active = *it; diff --git a/chrome/browser/ui/window_sizer/window_sizer_ash.cc b/chrome/browser/ui/window_sizer/window_sizer_ash.cc index c080be3..bd834d8 100644 --- a/chrome/browser/ui/window_sizer/window_sizer_ash.cc +++ b/chrome/browser/ui/window_sizer/window_sizer_ash.cc @@ -10,7 +10,7 @@ #include "base/compiler_specific.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" #include "chrome/browser/ui/host_desktop.h" @@ -40,9 +40,9 @@ bool IsValidBrowser(Browser* browser, const gfx::Rect& bounds_in_screen) { // on the screen defined by |bounds_in_screen| and visible. bool IsValidToplevelWindow(aura::Window* window, const gfx::Rect& bounds_in_screen) { - const BrowserList* ash_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); - for (BrowserList::const_iterator iter = ash_browser_list->begin(); + const chrome::BrowserListImpl* ash_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + for (chrome::BrowserListImpl::const_iterator iter = ash_browser_list->begin(); iter != ash_browser_list->end(); ++iter) { Browser* browser = *iter; @@ -100,9 +100,9 @@ aura::Window* GetTopWindow(const gfx::Rect& bounds_in_screen) { // the |bounds_in_screen| rectangle. int GetNumberOfValidTopLevelBrowserWindows(const gfx::Rect& bounds_in_screen) { int count = 0; - const BrowserList* ash_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); - for (BrowserList::const_iterator iter = ash_browser_list->begin(); + const chrome::BrowserListImpl* ash_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); + for (chrome::BrowserListImpl::const_iterator iter = ash_browser_list->begin(); iter != ash_browser_list->end(); ++iter) { if (IsValidBrowser(*iter, bounds_in_screen)) diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 2616f8f..271e0c6 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -264,6 +264,8 @@ 'browser/ui/browser_iterator.h', 'browser/ui/browser_list.cc', 'browser/ui/browser_list.h', + 'browser/ui/browser_list_impl.cc', + 'browser/ui/browser_list_impl.h', 'browser/ui/browser_mac.cc', 'browser/ui/browser_mac.h', 'browser/ui/browser_navigator.cc', diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc index 85a3c60..fd04549 100644 --- a/chrome/test/base/in_process_browser_test.cc +++ b/chrome/test/base/in_process_browser_test.cc @@ -22,7 +22,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_list.h" +#include "chrome/browser/ui/browser_list_impl.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" @@ -329,8 +329,8 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() { #endif // Browser tests do not support multi-desktop for now. - const BrowserList* native_browser_list = - BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); + const chrome::BrowserListImpl* native_browser_list = + chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); if (!native_browser_list->empty()) { browser_ = native_browser_list->get(0); #if defined(USE_ASH) |