diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-28 01:17:41 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-28 01:17:41 +0000 |
commit | c987a24655fedc08f1e04ee79e06e3f0df25d03a (patch) | |
tree | 5c1516372e1c2f6e8738c8168240c2784e2eb133 /chrome/browser | |
parent | 160b8f609544fed63af64d1c24e4a70dda725e0d (diff) | |
download | chromium_src-c987a24655fedc08f1e04ee79e06e3f0df25d03a.zip chromium_src-c987a24655fedc08f1e04ee79e06e3f0df25d03a.tar.gz chromium_src-c987a24655fedc08f1e04ee79e06e3f0df25d03a.tar.bz2 |
Remove kDefaultHostDesktopType from browser_finder.cc.
This forces GetBrowserCount() and GetTabbedBrowserCount() to also take HostDesktopType; changed all consumers to provide desktop context in their query.
Introducing GetTotalBrowserCountForProfile() which is like GetBrowserCount(), but cummulative over all desktops; used in two scenarios where the caller of the old GetBrowserCount() actually wanted to know whether all browsers for a given profile were gone from the p.o.v. of the browser process (i.e. accross all desktops).
BUG=129187
Review URL: https://chromiumcodereview.appspot.com/12315094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@185092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 6 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chrome_main_browsertest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/extensions/api/management/management_apitest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/extensions/app_process_apitest.cc | 9 | ||||
-rw-r--r-- | chrome/browser/extensions/window_open_apitest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/popup_blocker_browsertest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/browser_browsertest.cc | 27 | ||||
-rw-r--r-- | chrome/browser/ui/browser_finder.cc | 25 | ||||
-rw-r--r-- | chrome/browser/ui/browser_finder.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/panels/panel_browsertest.cc | 16 | ||||
-rw-r--r-- | chrome/browser/ui/startup/startup_browser_creator.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/startup/startup_browser_creator_browsertest.cc | 41 | ||||
-rw-r--r-- | chrome/browser/ui/startup/startup_browser_creator_interactive_uitest.cc | 20 | ||||
-rw-r--r-- | chrome/browser/ui/views/frame/app_non_client_frame_view_ash_browsertest.cc | 9 |
16 files changed, 153 insertions, 82 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index 4fb994e..93e807c 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -365,8 +365,10 @@ void RecordLastRunAppBundlePath() { } - (void)didEndMainMessageLoop { - DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile])); - if (!chrome::GetBrowserCount([self lastProfile])) { + DCHECK_EQ(0u, chrome::GetBrowserCount([self lastProfile], + chrome::HOST_DESKTOP_TYPE_NATIVE)); + if (!chrome::GetBrowserCount([self lastProfile], + chrome::HOST_DESKTOP_TYPE_NATIVE)) { // As we're shutting down, we need to nuke the TabRestoreService, which // will start the shutdown of the NavigationControllers and allow for // proper shutdown. If we don't do this, Chrome won't shut down cleanly, diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index e083f34..66c4a3c 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -613,7 +613,8 @@ void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) { } void TestingAutomationProvider::GetNormalBrowserWindowCount(int* window_count) { - *window_count = static_cast<int>(chrome::GetTabbedBrowserCount(profile_)); + *window_count = static_cast<int>(chrome::GetTabbedBrowserCount( + profile_, chrome::HOST_DESKTOP_TYPE_NATIVE)); } void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { diff --git a/chrome/browser/chrome_main_browsertest.cc b/chrome/browser/chrome_main_browsertest.cc index 0ea403b..c194e55 100644 --- a/chrome/browser/chrome_main_browsertest.cc +++ b/chrome/browser/chrome_main_browsertest.cc @@ -41,7 +41,8 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunch) { ui_test_utils::BrowserAddedObserver observer; Relaunch(GetCommandLineForRelaunch()); observer.WaitForSingleNewBrowser(); - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); } IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { @@ -71,7 +72,8 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, ReuseBrowserInstanceWhenOpeningFile) { IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { // We should start with one normal window. - ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Run with --incognito switch and an URL specified. base::FilePath test_file_path = ui_test_utils::GetTestFilePath( @@ -88,21 +90,25 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, MAYBE_SecondLaunchWithIncognitoUrl) { observer.WaitForSingleNewBrowser(); ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); - ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), + browser()->host_desktop_type())); } IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { // We should start with one normal window. - ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Create an incognito window. chrome::NewIncognitoWindow(browser()); ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); - ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Close the first window. Profile* profile = browser()->profile(); + chrome::HostDesktopType host_desktop_type = browser()->host_desktop_type(); content::WindowedNotificationObserver observer( chrome::NOTIFICATION_BROWSER_CLOSED, content::NotificationService::AllSources()); @@ -111,7 +117,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { // There should only be the incognito window open now. ASSERT_EQ(1u, chrome::GetTotalBrowserCount()); - ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile)); + ASSERT_EQ(0u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); // Run with just an URL specified, no --incognito switch. base::FilePath test_file_path = ui_test_utils::GetTestFilePath( @@ -126,7 +132,7 @@ IN_PROC_BROWSER_TEST_F(ChromeMainTest, SecondLaunchFromIncognitoWithNormalUrl) { // There should be one normal and one incognito window now. ASSERT_EQ(2u, chrome::GetTotalBrowserCount()); - ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile)); + ASSERT_EQ(1u, chrome::GetTabbedBrowserCount(profile, host_desktop_type)); } #endif // !OS_MACOSX diff --git a/chrome/browser/extensions/api/management/management_apitest.cc b/chrome/browser/extensions/api/management/management_apitest.cc index dd43018..cb440bf 100644 --- a/chrome/browser/extensions/api/management/management_apitest.cc +++ b/chrome/browser/extensions/api/management/management_apitest.cc @@ -176,7 +176,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, DISABLED_LaunchPanelApp) { ASSERT_FALSE(HasFatalFailure()); // Stop the test if any ASSERT failed. // Find the app's browser. Check that it is a popup. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); Browser* app_browser = FindOtherBrowser(browser()); ASSERT_TRUE(app_browser->is_type_popup()); ASSERT_TRUE(app_browser->is_app()); @@ -191,7 +192,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, DISABLED_LaunchPanelApp) { // Unload the extension. UninstallExtension(app_id); - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); ASSERT_FALSE(service->GetExtensionById(app_id, true)); // Set a pref indicating that the user wants to launch in a regular tab. @@ -209,7 +211,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, DISABLED_LaunchPanelApp) { // Find the app's browser. Apps that should load in a panel ignore // prefs, so we should still see the launch in a popup. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); app_browser = FindOtherBrowser(browser()); ASSERT_TRUE(app_browser->is_type_popup()); ASSERT_TRUE(app_browser->is_app()); @@ -228,7 +231,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { // Code below assumes that the test starts with a single browser window // hosting one tab. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); ASSERT_EQ(1, browser()->tab_strip_model()->count()); // Load an app with app.launch.container = "tab". @@ -237,12 +241,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { ASSERT_FALSE(HasFatalFailure()); // Check that the app opened in a new tab of the existing browser. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); ASSERT_EQ(2, browser()->tab_strip_model()->count()); // Unload the extension. UninstallExtension(app_id); - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); ASSERT_FALSE(service->GetExtensionById(app_id, true)); // Set a pref indicating that the user wants to launch in a window. @@ -259,12 +265,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { #if defined(OS_MACOSX) // App windows are not yet implemented on mac os. We should fall back // to a normal tab. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); ASSERT_EQ(2, browser()->tab_strip_model()->count()); #else // Find the app's browser. Opening in a new window will create // a new browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); Browser* app_browser = FindOtherBrowser(browser()); ASSERT_TRUE(app_browser->is_app()); ASSERT_FALSE(app_browser->is_type_panel()); diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc index ceb75f6..759a46c 100644 --- a/chrome/browser/extensions/app_process_apitest.cc +++ b/chrome/browser/extensions/app_process_apitest.cc @@ -113,7 +113,8 @@ class AppApiTest : public ExtensionApiTest { // Opening tabs with window.open should keep the page in the opener's // process. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); OpenWindow(tab1, base_url.Resolve("path1/empty.html"), true, NULL); LOG(INFO) << "WindowOpenHelper 1."; OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL); @@ -204,7 +205,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcess) { GetRenderProcessHost()); // Now let's do the same using window.open. The same should happen. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); LOG(INFO) << "WindowOpenHelper 1."; OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); @@ -329,7 +331,8 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { GetRenderProcessHost()); // Now let's do the same using window.open. The same should happen. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); OpenWindow(tab, base_url.Resolve("path1/empty.html"), true, NULL); OpenWindow(tab, base_url.Resolve("path2/empty.html"), true, NULL); diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index d9b93b6..360e68c 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -73,7 +73,8 @@ bool WaitForTabsAndPopups(Browser* browser, const base::TimeDelta kWaitTime = base::TimeDelta::FromSeconds(10); base::TimeTicks end_time = base::TimeTicks::Now() + kWaitTime; while (base::TimeTicks::Now() < end_time) { - if (chrome::GetBrowserCount(browser->profile()) == num_browsers && + if (chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type()) == num_browsers && browser->tab_strip_model()->count() == num_tabs && GetPanelCount(browser) == num_panels) break; @@ -81,7 +82,9 @@ bool WaitForTabsAndPopups(Browser* browser, content::RunAllPendingInMessageLoop(); } - EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(num_browsers, + chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); EXPECT_EQ(num_tabs, browser->tab_strip_model()->count()); EXPECT_EQ(num_panels, GetPanelCount(browser)); @@ -101,7 +104,9 @@ bool WaitForTabsAndPopups(Browser* browser, } EXPECT_EQ(num_popups, num_popups_seen); - return ((num_browsers == chrome::GetBrowserCount(browser->profile())) && + return ((num_browsers == + chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())) && (num_tabs == browser->tab_strip_model()->count()) && (num_panels == GetPanelCount(browser)) && (num_popups == num_popups_seen)); diff --git a/chrome/browser/popup_blocker_browsertest.cc b/chrome/browser/popup_blocker_browsertest.cc index 151f70e..c2e3ede 100644 --- a/chrome/browser/popup_blocker_browsertest.cc +++ b/chrome/browser/popup_blocker_browsertest.cc @@ -70,7 +70,8 @@ class PopupBlockerBrowserTest : public InProcessBrowserTest { ui_test_utils::NavigateToURL(browser, url); observer.Wait(); - ASSERT_EQ(2u, chrome::GetBrowserCount(browser->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); std::vector<WebContents*> blocked_contents = GetBlockedContents(browser); ASSERT_TRUE(blocked_contents.empty()); @@ -83,7 +84,8 @@ class PopupBlockerBrowserTest : public InProcessBrowserTest { // If the popup blocker blocked the blank post, there should be only one // tab in only one browser window and the URL of current tab must be equal // to the original URL. - EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); EXPECT_EQ(1, browser->tab_strip_model()->count()); WebContents* web_contents = browser->tab_strip_model()->GetActiveWebContents(); diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 53e1589..efda053 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -463,7 +463,7 @@ Browser::~Browser() { tab_restore_service->BrowserClosed(tab_restore_service_delegate()); #if !defined(OS_MACOSX) - if (!chrome::GetBrowserCount(profile_)) { + if (!chrome::GetTotalBrowserCountForProfile(profile_)) { // We're the last browser window with this profile. We need to nuke the // TabRestoreService, which will start the shutdown of the // NavigationControllers and allow for proper shutdown. If we don't do this diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc index a367044..38937ad 100644 --- a/chrome/browser/ui/browser_browsertest.cc +++ b/chrome/browser/ui/browser_browsertest.cc @@ -789,7 +789,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { WebContents* app_tab = chrome::AddSelectedTabWithURL( browser(), http_url, content::PAGE_TRANSITION_TYPED); ASSERT_EQ(2, browser()->tab_strip_model()->count()); - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Normal tabs should accept load drops. EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); @@ -799,7 +800,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, DISABLED_ConvertTabToAppShortcut) { chrome::ConvertTabToAppWindow(browser(), app_tab); // The launch should have created a new browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Find the new browser. Browser* app_browser = NULL; @@ -934,7 +936,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, AppIdSwitch) { // Check that the new browser has an app name. // The launch should have created a new browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Find the new browser. Browser* new_browser = NULL; @@ -1041,7 +1044,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) { launch.ProcessStartupURLs(std::vector<GURL>()); // The launch should have created a new browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Find the new browser. Browser* new_browser = NULL; @@ -1115,7 +1119,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { EXPECT_EQ(extension_app->GetFullLaunchURL(), app_window->GetURL()); // The launch should have created a new browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Find the new browser. Browser* new_browser = NULL; @@ -1862,7 +1867,8 @@ class ClickModifierTest : public InProcessBrowserTest { WebKit::WebMouseEvent::Button button, WindowOpenDisposition disposition) { ui_test_utils::NavigateToURL(browser, url); - EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); EXPECT_EQ(1, browser->tab_strip_model()->count()); content::WebContents* web_contents = browser->tab_strip_model()->GetActiveWebContents(); @@ -1882,7 +1888,8 @@ class ClickModifierTest : public InProcessBrowserTest { same_tab_observer.WaitForObservation( base::Bind(&content::RunThisRunLoop, base::Unretained(&run_loop)), content::GetQuitTaskForRunLoop(&run_loop)); - EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); EXPECT_EQ(1, browser->tab_strip_model()->count()); EXPECT_EQ(getSecondPageTitle(), web_contents->GetTitle()); return; @@ -1895,11 +1902,13 @@ class ClickModifierTest : public InProcessBrowserTest { observer.Wait(); if (disposition == NEW_WINDOW) { - EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(2u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); return; } - EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser->profile(), + browser->host_desktop_type())); EXPECT_EQ(2, browser->tab_strip_model()->count()); web_contents = browser->tab_strip_model()->GetActiveWebContents(); WaitForLoadStop(web_contents); diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc index 0ee386c..a7c2261 100644 --- a/chrome/browser/ui/browser_finder.cc +++ b/chrome/browser/ui/browser_finder.cc @@ -16,14 +16,6 @@ using content::WebContents; namespace { -// TODO(mad) eventually move this to host_desktop_type.h. -#if defined(OS_CHROMEOS) -chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH; -#else -chrome::HostDesktopType kDefaultHostDesktopType = - chrome::HOST_DESKTOP_TYPE_NATIVE; -#endif - // Type used to indicate to match anything. const int kMatchAny = 0; @@ -204,12 +196,21 @@ size_t GetTotalBrowserCount() { return count; } -size_t GetBrowserCount(Profile* profile) { - return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchAny); +size_t GetTotalBrowserCountForProfile(Profile* profile) { + size_t count = 0; + for (HostDesktopType t = HOST_DESKTOP_TYPE_FIRST; t < HOST_DESKTOP_TYPE_COUNT; + t = static_cast<HostDesktopType>(t + 1)) { + count += GetBrowserCount(profile, t); + } + return count; +} + +size_t GetBrowserCount(Profile* profile, HostDesktopType type) { + return GetBrowserCountImpl(profile, type, kMatchAny); } -size_t GetTabbedBrowserCount(Profile* profile) { - return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchTabbed); +size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { + return GetBrowserCountImpl(profile, type, kMatchTabbed); } } // namespace chrome diff --git a/chrome/browser/ui/browser_finder.h b/chrome/browser/ui/browser_finder.h index 8401ebb..6039a65 100644 --- a/chrome/browser/ui/browser_finder.h +++ b/chrome/browser/ui/browser_finder.h @@ -82,11 +82,17 @@ Browser* FindLastActiveWithHostDesktopType(HostDesktopType type); // Returns the number of browsers across all profiles and desktops. size_t GetTotalBrowserCount(); -// Returns the number of browsers with the Profile |profile|. -size_t GetBrowserCount(Profile* profile); +// Returns the number of browsers with the Profile |profile| accross all +// desktops. +size_t GetTotalBrowserCountForProfile(Profile* profile); -// Returns the number of tabbed browsers with the Profile |profile|. -size_t GetTabbedBrowserCount(Profile* profile); +// Returns the number of browsers with the Profile |profile| on the desktop +// defined by |type|. +size_t GetBrowserCount(Profile* profile, HostDesktopType type); + +// Returns the number of tabbed browsers with the Profile |profile| on the +// desktop defined by |type|. +size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type); } // namespace chrome diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc index 63547e7..dbc2235 100644 --- a/chrome/browser/ui/panels/panel_browsertest.cc +++ b/chrome/browser/ui/panels/panel_browsertest.cc @@ -1701,7 +1701,9 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevTools) { // Open devtools. size_t num_browsers = 1; - EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(num_browsers, chrome::GetBrowserCount( + browser()->profile(), + browser()->host_desktop_type())); content::WindowedNotificationObserver signal( chrome::NOTIFICATION_BROWSER_WINDOW_READY, content::NotificationService::AllSources()); @@ -1710,7 +1712,9 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevTools) { // Check that the new browser window that opened is dev tools window. ++num_browsers; - EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(num_browsers, chrome::GetBrowserCount( + browser()->profile(), + browser()->host_desktop_type())); for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { if (*iter == browser()) continue; @@ -1737,7 +1741,9 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevToolsConsole) { // Open devtools console. size_t num_browsers = 1; - EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(num_browsers, chrome::GetBrowserCount( + browser()->profile(), + browser()->host_desktop_type())); content::WindowedNotificationObserver signal( chrome::NOTIFICATION_BROWSER_WINDOW_READY, content::NotificationService::AllSources()); @@ -1746,7 +1752,9 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, DevToolsConsole) { // Check that the new browser window that opened is dev tools window. ++num_browsers; - EXPECT_EQ(num_browsers, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(num_browsers, chrome::GetBrowserCount( + browser()->profile(), + browser()->host_desktop_type())); for (chrome::BrowserIterator iter; !iter.done(); iter.Next()) { if (*iter == browser()) continue; diff --git a/chrome/browser/ui/startup/startup_browser_creator.cc b/chrome/browser/ui/startup/startup_browser_creator.cc index ff86e6f..56e5e90 100644 --- a/chrome/browser/ui/startup/startup_browser_creator.cc +++ b/chrome/browser/ui/startup/startup_browser_creator.cc @@ -588,7 +588,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( // chrome to shut down. // TODO(jackhou): Do this properly once keep-alive is handled by the // background page of apps. Tracked at http://crbug.com/175381 - if (chrome::GetBrowserCount(last_used_profile) != 0) + if (chrome::GetTotalBrowserCountForProfile(last_used_profile) != 0) return true; } diff --git a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc index d7221eb..d507676 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_browsertest.cc @@ -22,6 +22,7 @@ #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" #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" @@ -72,7 +73,8 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest { ASSERT_TRUE(*out_app_extension); // Code that opens a new browser assumes we start with exactly one. - ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); } void SetAppLaunchPref(const std::string& app_id, @@ -85,7 +87,8 @@ class StartupBrowserCreatorTest : public ExtensionBrowserTest { // Check that there are two browsers. Find the one that is not |browser()|. void FindOneOtherBrowser(Browser** out_other_browser) { // There should only be one other browser. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Find the new browser. Browser* other_browser = NULL; @@ -313,7 +316,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, OpenAppShortcutTabPref) { // When an app shortcut is open and the pref indicates a tab should // open, the tab is open in a new browser window. Expect a new window. - ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + ASSERT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); Browser* new_browser = NULL; ASSERT_NO_FATAL_FAILURE(FindOneOtherBrowser(&new_browser)); @@ -595,14 +599,16 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, StartupURLsForTwoProfiles) { Browser* new_browser = NULL; // |browser()| is still around at this point, even though we've closed its // window. Thus the browser count for default_profile is 2. - ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile)); + ASSERT_EQ(2u, chrome::GetBrowserCount(default_profile, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(default_profile, browser()); ASSERT_TRUE(new_browser); TabStripModel* tab_strip = new_browser->tab_strip_model(); ASSERT_EQ(1, tab_strip->count()); EXPECT_EQ(urls1[0], tab_strip->GetWebContentsAt(0)->GetURL()); - ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile)); + ASSERT_EQ(1u, chrome::GetBrowserCount(other_profile, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(other_profile, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); @@ -667,7 +673,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, UpdateWithTwoProfiles) { EXPECT_TRUE(profile2->restored_last_session()); Browser* new_browser = NULL; - ASSERT_EQ(1u, chrome::GetBrowserCount(profile1)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile1, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(profile1, NULL); ASSERT_TRUE(new_browser); TabStripModel* tab_strip = new_browser->tab_strip_model(); @@ -675,7 +682,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, UpdateWithTwoProfiles) { EXPECT_EQ(GURL(chrome::kAboutBlankURL), tab_strip->GetWebContentsAt(0)->GetURL()); - ASSERT_EQ(1u, chrome::GetBrowserCount(profile2)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile2, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(profile2, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); @@ -728,6 +736,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, SessionStartupPref::SetStartupPref(profile_urls, pref_urls); // Close the browser. + chrome::HostDesktopType original_desktop_type = + browser()->host_desktop_type(); browser()->window()->Close(); // Do a simple non-process-startup browser launch. @@ -753,7 +763,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, Browser* new_browser = NULL; // The last open profile (the profile_home1 in this case) will always be // launched, even if it will open just the home page. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home1, original_desktop_type)); new_browser = FindOneOtherBrowserForProfile(profile_home1, NULL); ASSERT_TRUE(new_browser); TabStripModel* tab_strip = new_browser->tab_strip_model(); @@ -762,7 +772,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, tab_strip->GetWebContentsAt(0)->GetURL()); // profile_urls opened the urls. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls, original_desktop_type)); new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); @@ -770,7 +780,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, EXPECT_EQ(urls[0], tab_strip->GetWebContentsAt(0)->GetURL()); // profile_last opened the last open pages. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last, original_desktop_type)); new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); @@ -779,7 +789,7 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, tab_strip->GetWebContentsAt(0)->GetURL()); // profile_home2 was not launched since it would've only opened the home page. - ASSERT_EQ(0u, chrome::GetBrowserCount(profile_home2)); + ASSERT_EQ(0u, chrome::GetBrowserCount(profile_home2, original_desktop_type)); } IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { @@ -847,7 +857,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { // The profile which normally opens the home page displays the new tab page. Browser* new_browser = NULL; - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_home, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(profile_home, NULL); ASSERT_TRUE(new_browser); TabStripModel* tab_strip = new_browser->tab_strip_model(); @@ -858,7 +869,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); // The profile which normally opens last open pages displays the new tab page. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_last, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(profile_last, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); @@ -869,7 +881,8 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, ProfilesLaunchedAfterCrash) { InfoBarService::FromWebContents(web_contents)->GetInfoBarCount()); // The profile which normally opens URLs displays the new tab page. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_urls, + browser()->host_desktop_type())); new_browser = FindOneOtherBrowserForProfile(profile_urls, NULL); ASSERT_TRUE(new_browser); tab_strip = new_browser->tab_strip_model(); diff --git a/chrome/browser/ui/startup/startup_browser_creator_interactive_uitest.cc b/chrome/browser/ui/startup/startup_browser_creator_interactive_uitest.cc index 77da246..bf3a31f 100644 --- a/chrome/browser/ui/startup/startup_browser_creator_interactive_uitest.cc +++ b/chrome/browser/ui/startup/startup_browser_creator_interactive_uitest.cc @@ -76,28 +76,32 @@ IN_PROC_BROWSER_TEST_F(StartupBrowserCreatorTest, LastUsedProfileActivated) { Browser* new_browser = NULL; // The last used profile (the profile_2 in this case) must be active. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_2)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_2, + browser()->host_desktop_type())); new_browser = FindBrowserWithProfile(profile_2, - chrome::HOST_DESKTOP_TYPE_NATIVE); + browser()->host_desktop_type()); ASSERT_TRUE(new_browser); EXPECT_TRUE(new_browser->window()->IsActive()); // All other profiles browser should not be active. - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_1)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_1, + browser()->host_desktop_type())); new_browser = FindBrowserWithProfile(profile_1, - chrome::HOST_DESKTOP_TYPE_NATIVE); + browser()->host_desktop_type()); ASSERT_TRUE(new_browser); EXPECT_FALSE(new_browser->window()->IsActive()); - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_3)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_3, + browser()->host_desktop_type())); new_browser = FindBrowserWithProfile(profile_3, - chrome::HOST_DESKTOP_TYPE_NATIVE); + browser()->host_desktop_type()); ASSERT_TRUE(new_browser); EXPECT_FALSE(new_browser->window()->IsActive()); - ASSERT_EQ(1u, chrome::GetBrowserCount(profile_4)); + ASSERT_EQ(1u, chrome::GetBrowserCount(profile_4, + browser()->host_desktop_type())); new_browser = FindBrowserWithProfile(profile_4, - chrome::HOST_DESKTOP_TYPE_NATIVE); + browser()->host_desktop_type()); ASSERT_TRUE(new_browser); EXPECT_FALSE(new_browser->window()->IsActive()); diff --git a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash_browsertest.cc b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash_browsertest.cc index b98a819..7374050 100644 --- a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash_browsertest.cc +++ b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash_browsertest.cc @@ -147,7 +147,8 @@ IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAshTest, ClickClose) { content::Source<Browser>(app_browser())); eg.ClickLeftButton(); signal.Wait(); - EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); } // Ensure that closing a maximized app with Ctrl-W does not crash the @@ -157,7 +158,8 @@ IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAshTest, KeyboardClose) { aura::test::EventGenerator eg(root_window); // Base browser and app browser. - EXPECT_EQ(2u, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(2u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); // Send Control-W. content::WindowedNotificationObserver signal( @@ -168,7 +170,8 @@ IN_PROC_BROWSER_TEST_F(AppNonClientFrameViewAshTest, KeyboardClose) { signal.Wait(); // App browser is closed. - EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile())); + EXPECT_EQ(1u, chrome::GetBrowserCount(browser()->profile(), + browser()->host_desktop_type())); } // Ensure that snapping left with Alt-[ closes the control window. |