diff options
Diffstat (limited to 'chrome')
100 files changed, 668 insertions, 575 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 9f086bf..f004104 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -268,8 +268,8 @@ bool TestingAutomationProvider::OnMessageReceived( IPC_MESSAGE_HANDLER(AutomationMsg_LastActiveBrowserWindow, GetLastActiveBrowserWindow) IPC_MESSAGE_HANDLER(AutomationMsg_ActiveWindow, GetActiveWindow) - IPC_MESSAGE_HANDLER(AutomationMsg_FindNormalBrowserWindow, - FindNormalBrowserWindow) + IPC_MESSAGE_HANDLER(AutomationMsg_FindTabbedBrowserWindow, + FindTabbedBrowserWindow) IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) @@ -287,6 +287,8 @@ bool TestingAutomationProvider::OnMessageReceived( IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) + IPC_MESSAGE_HANDLER(AutomationMsg_IsBrowserInApplicationMode, + IsBrowserInApplicationMode) IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) IPC_MESSAGE_HANDLER(AutomationMsg_TabProcessID, GetTabProcessID) IPC_MESSAGE_HANDLER(AutomationMsg_TabTitle, GetTabTitle) @@ -730,7 +732,7 @@ void TestingAutomationProvider::GetBrowserWindowCount(int* window_count) { void TestingAutomationProvider::GetNormalBrowserWindowCount(int* window_count) { *window_count = static_cast<int>( - BrowserList::GetBrowserCountForType(profile_, Browser::TYPE_NORMAL)); + BrowserList::GetBrowserCountForType(profile_, true)); } void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { @@ -740,11 +742,9 @@ void TestingAutomationProvider::GetBrowserWindow(int index, int* handle) { *handle = browser_tracker_->Add(browser); } -void TestingAutomationProvider::FindNormalBrowserWindow(int* handle) { +void TestingAutomationProvider::FindTabbedBrowserWindow(int* handle) { *handle = 0; - Browser* browser = BrowserList::FindBrowserWithType(profile_, - Browser::TYPE_NORMAL, - false); + Browser* browser = BrowserList::FindTabbedBrowser(profile_, false); if (browser) *handle = browser_tracker_->Add(browser); } @@ -1094,6 +1094,21 @@ void TestingAutomationProvider::GetType(int handle, int* type_as_int) { } } +void TestingAutomationProvider::IsBrowserInApplicationMode(int handle, + bool* is_application, + bool* success) { + *is_application = false; + *success = false; + + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + if (browser) { + *success = true; + *is_application = browser->is_app(); + } + } +} + void TestingAutomationProvider::GetTab(int win_handle, int tab_index, int* tab_handle) { diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index fa551fc..b56c137 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -98,10 +98,10 @@ class TestingAutomationProvider : public AutomationProvider, IPC::Message* reply_message); void GetBrowserWindowCount(int* window_count); void GetNormalBrowserWindowCount(int* window_count); - // Be aware that the browser window returned might be of non TYPE_NORMAL + // Be aware that the browser window returned might be of non TYPE_TABBED // or in incognito mode. void GetBrowserWindow(int index, int* handle); - void FindNormalBrowserWindow(int* handle); + void FindTabbedBrowserWindow(int* handle); void GetLastActiveBrowserWindow(int* handle); void GetActiveWindow(int* handle); void ExecuteBrowserCommandAsync(int handle, int command, bool* success); @@ -130,6 +130,9 @@ class TestingAutomationProvider : public AutomationProvider, int flags); void GetTabCount(int handle, int* tab_count); void GetType(int handle, int* type_as_int); + void IsBrowserInApplicationMode(int handle, + bool* is_application, + bool* success); void GetTab(int win_handle, int tab_index, int* tab_handle); void GetTabProcessID(int handle, int* process_id); void GetTabTitle(int handle, int* title_string_size, std::wstring* title); diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index ae7f4ce..6090ea1 100644 --- a/chrome/browser/bookmarks/bookmark_utils.cc +++ b/chrome/browser/bookmarks/bookmark_utils.cc @@ -370,7 +370,7 @@ void OpenAll(gfx::NativeWindow parent, NewBrowserPageNavigator navigator_impl(profile); if (!navigator) { Browser* browser = - BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, false); + BrowserList::FindTabbedBrowser(profile, false); if (!browser || !browser->GetSelectedTabContents()) { navigator = &navigator_impl; } else { diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 65259d0..545d427 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -752,7 +752,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, OpenAppWindowLikeNtp) { ASSERT_TRUE(new_browser); ASSERT_TRUE(new_browser != browser()); - EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); + EXPECT_TRUE(new_browser->is_app()); // The browser's app name should include the extension's id. std::string app_name = new_browser->app_name_; diff --git a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc index f403694..690956a 100644 --- a/chrome/browser/chromeos/frame/browser_frame_chromeos.cc +++ b/chrome/browser/chromeos/frame/browser_frame_chromeos.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -31,7 +31,8 @@ BrowserFrameChromeos::~BrowserFrameChromeos() { void BrowserFrameChromeos::InitBrowserFrame() { BrowserFrameGtk::InitBrowserFrame(); - if (!browser_view()->IsBrowserTypePopup()) { + if (!browser_view()->IsBrowserTypePopup() && + !browser_view()->IsBrowserTypePanel()) { // On chromeos we want windows to always render as active. DisableInactiveRendering(); } @@ -40,8 +41,9 @@ void BrowserFrameChromeos::InitBrowserFrame() { bool BrowserFrameChromeos::IsMaximized() const { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeosFrame)) return WindowGtk::IsMaximized(); - bool is_popup = browser_view()->IsBrowserTypePopup(); - return !IsFullscreen() && (!is_popup || WindowGtk::IsMaximized()); + bool is_popup_or_panel = browser_view()->IsBrowserTypePopup() || + browser_view()->IsBrowserTypePanel(); + return !IsFullscreen() && (!is_popup_or_panel || WindowGtk::IsMaximized()); } } // namespace chromeos diff --git a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc b/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc index 6bfd458..2932112 100644 --- a/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc +++ b/chrome/browser/chromeos/frame/browser_non_client_frame_view_factory_chromeos.cc @@ -12,7 +12,7 @@ namespace browser { BrowserNonClientFrameView* CreateBrowserNonClientFrameView( BrowserFrame* frame, BrowserView* browser_view) { - if (browser_view->IsBrowserTypePopup()) + if (browser_view->IsBrowserTypePopup() || browser_view->IsBrowserTypePanel()) return new PopupNonClientFrameView(); else return new chromeos::BrowserFrameViewChromeos(frame, browser_view); diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc index dce2741..6f42dc6 100644 --- a/chrome/browser/chromeos/frame/browser_view.cc +++ b/chrome/browser/chromeos/frame/browser_view.cc @@ -431,7 +431,7 @@ void BrowserView::InitSystemMenu() { BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { // Create a browser view for chromeos. BrowserView* view; - if (browser->type() & Browser::TYPE_POPUP) + if (browser->is_type_popup() || browser->is_type_panel()) view = new chromeos::PanelBrowserView(browser); else view = new chromeos::BrowserView(browser); diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h index f25741d..4da430b 100644 --- a/chrome/browser/chromeos/frame/browser_view.h +++ b/chrome/browser/chromeos/frame/browser_view.h @@ -32,7 +32,7 @@ class StatusAreaView; class StatusAreaButton; // chromeos::BrowserView adds ChromeOS specific controls and menus to a -// BrowserView created with Browser::TYPE_NORMAL. This extender adds controls +// BrowserView created with Browser::TYPE_TABBED. This extender adds controls // to the title bar as follows: // ____ __ __ // / \ \ \ [StatusArea] diff --git a/chrome/browser/chromeos/frame/dom_browser.cc b/chrome/browser/chromeos/frame/dom_browser.cc index b593f89..6c9a4ff 100644 --- a/chrome/browser/chromeos/frame/dom_browser.cc +++ b/chrome/browser/chromeos/frame/dom_browser.cc @@ -12,7 +12,7 @@ namespace chromeos { // DOMBrowser: public ---------------------------------------------------------- DOMBrowser::DOMBrowser(Profile* profile) - : Browser(Browser::TYPE_NORMAL, profile) { + : Browser(Browser::TYPE_TABBED, profile) { } DOMBrowser::~DOMBrowser() { diff --git a/chrome/browser/chromeos/network_login_observer.cc b/chrome/browser/chromeos/network_login_observer.cc index 3325b83..388bcd7 100644 --- a/chrome/browser/chromeos/network_login_observer.cc +++ b/chrome/browser/chromeos/network_login_observer.cc @@ -28,10 +28,8 @@ NetworkLoginObserver::~NetworkLoginObserver() { void NetworkLoginObserver::CreateModalPopup(views::WindowDelegate* view) { Browser* browser = BrowserList::GetLastActive(); - if (browser && browser->type() != Browser::TYPE_NORMAL) { - browser = BrowserList::FindBrowserWithType(browser->profile(), - Browser::TYPE_NORMAL, - true); + if (browser && !browser->is_type_tabbed()) { + browser = BrowserList::FindTabbedBrowser(browser->profile(), true); } if (browser) { views::Window* window = browser::CreateViewsWindow( diff --git a/chrome/browser/chromeos/panels/panel_browsertest.cc b/chrome/browser/chromeos/panels/panel_browsertest.cc index 7420b0d3..35c8d7c 100644 --- a/chrome/browser/chromeos/panels/panel_browsertest.cc +++ b/chrome/browser/chromeos/panels/panel_browsertest.cc @@ -56,7 +56,8 @@ IN_PROC_BROWSER_TEST_F(PanelTest, PanelOpenSmall) { } ASSERT_TRUE(new_browser); - EXPECT_EQ(Browser::TYPE_POPUP, new_browser->type()); + EXPECT_TRUE(new_browser->is_type_popup()); + EXPECT_FALSE(new_browser->is_app()); // This window type tells the cros window manager to treat the window // as a panel. EXPECT_EQ( diff --git a/chrome/browser/chromeos/setting_level_bubble.cc b/chrome/browser/chromeos/setting_level_bubble.cc index d918e7b..ff0e0fd 100644 --- a/chrome/browser/chromeos/setting_level_bubble.cc +++ b/chrome/browser/chromeos/setting_level_bubble.cc @@ -51,9 +51,8 @@ static views::Widget* GetToplevelWidget() { // We just use the default profile here -- this gets overridden as needed // in Chrome OS depending on whether the user is logged in or not. Browser* browser = - BrowserList::FindBrowserWithType( + BrowserList::FindTabbedBrowser( ProfileManager::GetDefaultProfile(), - Browser::TYPE_NORMAL, true); // match_incognito if (browser) { window = GTK_WINDOW(browser->window()->GetNativeHandle()); diff --git a/chrome/browser/chromeos/status/window_switcher_button.cc b/chrome/browser/chromeos/status/window_switcher_button.cc index 6006dec..f51129d 100644 --- a/chrome/browser/chromeos/status/window_switcher_button.cc +++ b/chrome/browser/chromeos/status/window_switcher_button.cc @@ -20,7 +20,7 @@ int GetNormalBrowserCount() { int count = 0; BrowserList::const_iterator iter; for (iter = BrowserList::begin(); iter != BrowserList::end(); ++iter) { - if ((*iter)->type() == Browser::TYPE_NORMAL) + if ((*iter)->is_type_tabbed()) count++; } return count; diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher.cc b/chrome/browser/chromeos/tab_closeable_state_watcher.cc index 81331e5..408c766 100644 --- a/chrome/browser/chromeos/tab_closeable_state_watcher.cc +++ b/chrome/browser/chromeos/tab_closeable_state_watcher.cc @@ -81,14 +81,14 @@ TabCloseableStateWatcher::~TabCloseableStateWatcher() { } bool TabCloseableStateWatcher::CanCloseTab(const Browser* browser) const { - return browser->type() != Browser::TYPE_NORMAL ? true : - (can_close_tab_ || waiting_for_browser_); + return browser->is_type_tabbed() ? + (can_close_tab_ || waiting_for_browser_) : true; } bool TabCloseableStateWatcher::CanCloseTabs(const Browser* browser, std::vector<int>* indices) const { if (signing_off_ || waiting_for_browser_ || tabstrip_watchers_.size() > 1 || - browser->type() != Browser::TYPE_NORMAL || + !browser->is_type_tabbed() || (browser->profile()->IsOffTheRecord() && !guest_session_)) return true; @@ -155,8 +155,8 @@ void TabCloseableStateWatcher::OnWindowCloseCanceled(Browser* browser) { void TabCloseableStateWatcher::OnBrowserAdded(const Browser* browser) { waiting_for_browser_ = false; - // Only normal browsers may affect closeable state. - if (browser->type() != Browser::TYPE_NORMAL) + // Only tabbed browsers may affect closeable state. + if (!browser->is_type_tabbed()) return; // Create TabStripWatcher to observe tabstrip of new browser. @@ -167,8 +167,8 @@ void TabCloseableStateWatcher::OnBrowserAdded(const Browser* browser) { } void TabCloseableStateWatcher::OnBrowserRemoved(const Browser* browser) { - // Only normal browsers may affect closeable state. - if (browser->type() != Browser::TYPE_NORMAL) + // Only tabbed browsers may affect closeable state. + if (!browser->is_type_tabbed()) return; // Remove TabStripWatcher for browser that is being removed. @@ -225,7 +225,7 @@ void TabCloseableStateWatcher::OnTabStripChanged(const Browser* browser, void TabCloseableStateWatcher::CheckAndUpdateState( const Browser* browser_to_check) { if (waiting_for_browser_ || signing_off_ || tabstrip_watchers_.empty() || - (browser_to_check && browser_to_check->type() != Browser::TYPE_NORMAL)) + (browser_to_check && !browser_to_check->is_type_tabbed())) return; bool new_can_close; @@ -278,8 +278,8 @@ bool TabCloseableStateWatcher::CanCloseBrowserImpl( if (signing_off_) return true; - // Non-normal browsers are always closeable. - if (browser->type() != Browser::TYPE_NORMAL) + // Non-tabbed browsers are always closeable. + if (!browser->is_type_tabbed()) return true; // If this is not the last normal browser, it's always closeable. diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index e43e52a..8145ff7 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -139,7 +139,7 @@ void DevToolsWindow::Show(DevToolsToggleAction action) { Browser* inspected_browser; int inspected_tab_index; // Tell inspected browser to update splitter and switch to inspected panel. - if (!IsInspectedBrowserPopup() && + if (!IsInspectedBrowserPopupOrPanel() && FindInspectedBrowserAndTabIndex(&inspected_browser, &inspected_tab_index)) { BrowserWindow* inspected_window = inspected_browser->window(); @@ -188,7 +188,8 @@ void DevToolsWindow::Activate() { void DevToolsWindow::SetDocked(bool docked) { if (docked_ == docked) return; - if (docked && (!GetInspectedBrowserWindow() || IsInspectedBrowserPopup())) { + if (docked && (!GetInspectedBrowserWindow() || + IsInspectedBrowserPopupOrPanel())) { // Cannot dock, avoid window flashing due to close-reopen cycle. return; } @@ -267,13 +268,13 @@ BrowserWindow* DevToolsWindow::GetInspectedBrowserWindow() { browser->window() : NULL; } -bool DevToolsWindow::IsInspectedBrowserPopup() { +bool DevToolsWindow::IsInspectedBrowserPopupOrPanel() { Browser* browser = NULL; int tab; if (!FindInspectedBrowserAndTabIndex(&browser, &tab)) return false; - return (browser->type() & Browser::TYPE_POPUP) != 0; + return browser->is_type_popup() || browser->is_type_panel(); } void DevToolsWindow::UpdateFrontendAttachedState() { diff --git a/chrome/browser/debugger/devtools_window.h b/chrome/browser/debugger/devtools_window.h index becad62..42a3fa9 100644 --- a/chrome/browser/debugger/devtools_window.h +++ b/chrome/browser/debugger/devtools_window.h @@ -55,7 +55,7 @@ class DevToolsWindow void CreateDevToolsBrowser(); bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); BrowserWindow* GetInspectedBrowserWindow(); - bool IsInspectedBrowserPopup(); + bool IsInspectedBrowserPopupOrPanel(); void UpdateFrontendAttachedState(); // Overridden from NotificationObserver. diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 0a5733e..4362686 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -634,14 +634,15 @@ class DownloadTest : public InProcessBrowserTest { // Figure out if the appropriate download visibility was done. A // utility function to support ChromeOS variations. On ChromeOS // a webui panel is used instead of the download shelf; the - // test for TYPE_APP_PANEL detects this type of panel. + // test for is_type_panel and is_app detects this type of panel. + // TODO(stevenjb): The download panel may not be the only app panel. + // We need a better way to check for this. static bool IsDownloadUIVisible(Browser* browser) { #if defined(OS_CHROMEOS) for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { - if ((*it)->type() == Browser::TYPE_APP_PANEL) { + if ((*it)->is_type_panel() && (*it)->is_app() ) return true; - } } return false; #else diff --git a/chrome/browser/extensions/extension_context_menu_browsertest.cc b/chrome/browser/extensions/extension_context_menu_browsertest.cc index 7c6e34e..ed0bc8c 100644 --- a/chrome/browser/extensions/extension_context_menu_browsertest.cc +++ b/chrome/browser/extensions/extension_context_menu_browsertest.cc @@ -413,9 +413,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, IncognitoSplit) { GURL page_url("http://www.google.com"); // Create and build our test context menu. - Browser* browser_incognito = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), - Browser::TYPE_NORMAL, false); + Browser* browser_incognito = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); ASSERT_TRUE(browser_incognito); scoped_ptr<TestRenderViewContextMenu> menu( CreateMenu(browser(), page_url, GURL(), GURL())); diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 8fdd20f..8ad5798 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -452,8 +452,7 @@ Browser* ExtensionFunctionDispatcher::GetCurrentBrowser( // we will search the incognito version only, regardless of the value of // |include_incognito|. Profile* profile = render_view_host()->process()->profile(); - browser = BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, - include_incognito); + browser = BrowserList::FindTabbedBrowser(profile, include_incognito); // NOTE(rafaelw): This can return NULL in some circumstances. In particular, // a background_page onload chrome.tabs api call can make it into here diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index bb476f8..003f563 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -18,6 +18,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/renderer_preferences_util.h" #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" +#include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -592,9 +593,8 @@ void ExtensionHost::ShowCreatedWindow(int route_id, if (disposition == NEW_POPUP) { // Find a browser with a matching profile for creating a popup. // (If none is found, NULL argument to NavigateParams is valid.) - Browser* browser = BrowserList::FindBrowserWithType( + Browser* browser = BrowserList::FindTabbedBrowser( contents->profile(), - Browser::TYPE_NORMAL, false); // Match incognito exactly. TabContentsWrapper* wrapper = new TabContentsWrapper(contents); browser::NavigateParams params(browser, wrapper); @@ -627,9 +627,8 @@ void ExtensionHost::ShowCreatedWindow(int route_id, // If there's no associated tab contents, or it doesn't have a matching // profile, try finding an open window. Again, we must make sure to find a // window with the correct profile. - Browser* browser = BrowserList::FindBrowserWithType( + Browser* browser = BrowserList::FindTabbedBrowser( contents->profile(), - Browser::TYPE_NORMAL, false); // Match incognito exactly. // If there's no Browser open with the right profile, create a new one. diff --git a/chrome/browser/extensions/extension_icon_source_apitest.cc b/chrome/browser/extensions/extension_icon_source_apitest.cc index 826db97..bbca39f 100644 --- a/chrome/browser/extensions/extension_icon_source_apitest.cc +++ b/chrome/browser/extensions/extension_icon_source_apitest.cc @@ -58,9 +58,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionIconSourceTest, IconsLoadedIncognito) { ui_test_utils::OpenURLOffTheRecord( browser()->profile(), GURL("chrome-extension://gbmgkahjioeacddebbnengilkgbkhodg/index.html")); - Browser* otr_browser = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + Browser* otr_browser = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString( otr_browser->GetSelectedTabContents()->render_view_host(), L"", L"window.domAutomationController.send(document.title)", diff --git a/chrome/browser/extensions/extension_incognito_apitest.cc b/chrome/browser/extensions/extension_incognito_apitest.cc index 7ca16aa..c18105f 100644 --- a/chrome/browser/extensions/extension_incognito_apitest.cc +++ b/chrome/browser/extensions/extension_incognito_apitest.cc @@ -29,9 +29,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoNoScript) { browser()->profile(), test_server()->GetURL("files/extensions/test_file.html")); - Browser* otr_browser = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + Browser* otr_browser = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); TabContents* tab = otr_browser->GetSelectedTabContents(); // Verify the script didn't run. @@ -67,9 +66,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoYesScript) { browser()->profile(), test_server()->GetURL("files/extensions/test_file.html")); - Browser* otr_browser = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + Browser* otr_browser = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); TabContents* tab = otr_browser->GetSelectedTabContents(); // Verify the script ran. @@ -178,9 +176,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, IncognitoPopup) { browser()->profile(), test_server()->GetURL("files/extensions/test_file.html")); - Browser* incognito_browser = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + Browser* incognito_browser = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); // Simulate the incognito's browser action being clicked. BrowserActionTestUtil(incognito_browser).Press(0); diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index e24a5d4..a735efd 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -225,10 +225,8 @@ void ExtensionInstallUI::ShowThemeInfoBar(const std::string& previous_theme_id, if (!new_theme->is_theme()) return; - // Get last active normal browser of profile. - Browser* browser = BrowserList::FindBrowserWithType(profile, - Browser::TYPE_NORMAL, - true); + // Get last active tabbed browser of profile. + Browser* browser = BrowserList::FindTabbedBrowser(profile, true); if (!browser) return; diff --git a/chrome/browser/extensions/extension_management_apitest.cc b/chrome/browser/extensions/extension_management_apitest.cc index c2c6bbe..064f188 100644 --- a/chrome/browser/extensions/extension_management_apitest.cc +++ b/chrome/browser/extensions/extension_management_apitest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -88,7 +88,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchPanelApp) { // Find the app's browser. Check that it is a panel. ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); Browser* app_browser = FindOtherBrowser(browser()); - ASSERT_EQ(Browser::TYPE_APP_POPUP, app_browser->type()); +#if defined(OS_CHROMEOS) + ASSERT_TRUE(app_browser->is_type_panel()); +#else + ASSERT_TRUE(app_browser->is_type_popup()); +#endif + ASSERT_TRUE(app_browser->is_app()); // Close the app panel. app_browser->CloseWindow(); @@ -117,7 +122,12 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchPanelApp) { // prefs, so we should still see the launch in a panel. ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); app_browser = FindOtherBrowser(browser()); - ASSERT_EQ(Browser::TYPE_APP_POPUP, app_browser->type()); +#if defined(OS_CHROMEOS) + ASSERT_TRUE(app_browser->is_type_panel()); +#else + ASSERT_TRUE(app_browser->is_type_popup()); +#endif + ASSERT_TRUE(app_browser->is_app()); } IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { @@ -170,6 +180,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementApiTest, LaunchTabApp) { // a new browser. ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); Browser* app_browser = FindOtherBrowser(browser()); - ASSERT_EQ(Browser::TYPE_APP, app_browser->type()); + ASSERT_TRUE(app_browser->is_app()); + ASSERT_FALSE(app_browser->is_type_panel()); #endif } diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc index 9c87a7c..24db588 100644 --- a/chrome/browser/extensions/extension_override_apitest.cc +++ b/chrome/browser/extensions/extension_override_apitest.cc @@ -86,9 +86,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, MAYBE_OverrideNewtabIncognito) { // new tab page because we can't load chrome-extension URLs in incognito. ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("chrome://newtab/")); - Browser* otr_browser = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + Browser* otr_browser = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); TabContents* tab = otr_browser->GetSelectedTabContents(); ASSERT_TRUE(tab->controller().GetActiveEntry()); EXPECT_FALSE(tab->controller().GetActiveEntry()->url(). diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index 90db625..a43d894 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -79,7 +79,7 @@ static GURL ResolvePossiblyRelativeURL(const std::string& url_string, const Extension* extension); // Return the type name for a browser window type. -static std::string GetWindowTypeText(Browser::Type type); +static std::string GetWindowTypeText(const Browser* browser); int ExtensionTabUtil::GetWindowId(const Browser* browser) { return browser->session_id().id(); @@ -169,7 +169,7 @@ DictionaryValue* ExtensionTabUtil::CreateWindowValue(const Browser* browser, result->SetInteger(keys::kTopKey, bounds.y()); result->SetInteger(keys::kWidthKey, bounds.width()); result->SetInteger(keys::kHeightKey, bounds.height()); - result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser->type())); + result->SetString(keys::kWindowTypeKey, GetWindowTypeText(browser)); if (populate_tabs) { result->Set(keys::kTabsKey, ExtensionTabUtil::CreateTabList(browser)); @@ -280,8 +280,8 @@ bool GetCurrentWindowFunction::RunImpl() { } bool GetLastFocusedWindowFunction::RunImpl() { - Browser* browser = BrowserList::FindBrowserWithType( - profile(), Browser::TYPE_ANY, include_incognito()); + Browser* browser = BrowserList::FindAnyBrowser( + profile(), include_incognito()); if (!browser || !browser->window()) { error_ = keys::kNoLastFocusedWindowError; return false; @@ -416,8 +416,9 @@ bool CreateWindowFunction::RunImpl() { #endif Profile* window_profile = profile(); - Browser::Type window_type = Browser::TYPE_NORMAL; + Browser::Type window_type = Browser::TYPE_TABBED; bool focused = true; + std::string app_name; if (args) { // Any part of the bounds can optionally be set by the caller. @@ -471,25 +472,31 @@ bool CreateWindowFunction::RunImpl() { if (args->HasKey(keys::kWindowTypeKey)) { EXTENSION_FUNCTION_VALIDATE(args->GetString(keys::kWindowTypeKey, &type_str)); - if (type_str == keys::kWindowTypeValueNormal) { - window_type = Browser::TYPE_NORMAL; - } else if (type_str == keys::kWindowTypeValuePopup) { - window_type = Browser::TYPE_APP_POPUP; + if (type_str == keys::kWindowTypeValuePopup) { + window_type = Browser::TYPE_POPUP; + app_name = GetExtension()->id(); } else if (type_str == keys::kWindowTypeValuePanel) { if (GetExtension()->HasApiPermission( Extension::kExperimentalPermission)) { - window_type = Browser::TYPE_APP_PANEL; + window_type = Browser::TYPE_PANEL; + app_name = GetExtension()->id(); } else { error_ = errors::kExperimentalFeature; return false; } - } else { + } else if (type_str != keys::kWindowTypeValueNormal) { EXTENSION_FUNCTION_VALIDATE(false); } } } - Browser* new_window = Browser::CreateForType(window_type, window_profile); + Browser* new_window; + if (app_name.empty()) { + new_window = Browser::CreateForType(window_type, window_profile); + } else { + new_window = Browser::CreateForApp(window_type, app_name, gfx::Size(), + window_profile); + } for (std::vector<GURL>::iterator i = urls.begin(); i != urls.end(); ++i) new_window->AddSelectedTabWithURL(*i, PageTransition::LINK); if (contents) { @@ -500,10 +507,10 @@ bool CreateWindowFunction::RunImpl() { new_window->NewTab(); } new_window->SelectNumberedTab(0); - if (window_type & Browser::TYPE_POPUP) - new_window->window()->SetBounds(popup_bounds); - else + if (app_name.empty()) new_window->window()->SetBounds(window_bounds); + else + new_window->window()->SetBounds(popup_bounds); if (focused) new_window->window()->Show(); @@ -718,13 +725,12 @@ bool CreateTabFunction::RunImpl() { EXTENSION_FUNCTION_VALIDATE(args->GetBoolean(keys::kPinnedKey, &pinned)); // We can't load extension URLs into incognito windows unless the extension - // uses split mode. Special case to fall back to a normal window. + // uses split mode. Special case to fall back to a tabbed window. if (url.SchemeIs(chrome::kExtensionScheme) && !GetExtension()->incognito_split_mode() && browser->profile()->IsOffTheRecord()) { Profile* profile = browser->profile()->GetOriginalProfile(); - browser = BrowserList::FindBrowserWithType(profile, - Browser::TYPE_NORMAL, false); + browser = BrowserList::FindTabbedBrowser(profile, false); if (!browser) { browser = Browser::Create(profile); browser->window()->Show(); @@ -984,7 +990,7 @@ bool MoveTabFunction::RunImpl() { return false; } - if (target_browser->type() != Browser::TYPE_NORMAL) { + if (!target_browser->is_type_tabbed()) { error_ = keys::kCanOnlyMoveTabsWithinNormalWindowsError; return false; } @@ -1348,19 +1354,13 @@ static bool GetTabById(int tab_id, Profile* profile, return false; } -static std::string GetWindowTypeText(Browser::Type type) { - if (type == Browser::TYPE_APP_PANEL && - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableExperimentalExtensionApis)) - return keys::kWindowTypeValuePanel; - - if ((type & Browser::TYPE_POPUP) == Browser::TYPE_POPUP) +static std::string GetWindowTypeText(const Browser* browser) { + if (browser->is_type_popup()) return keys::kWindowTypeValuePopup; - - if ((type & Browser::TYPE_APP) == Browser::TYPE_APP) + if (browser->is_type_panel()) + return keys::kWindowTypeValuePanel; + if (browser->is_app()) return keys::kWindowTypeValueApp; - - DCHECK(type == Browser::TYPE_NORMAL); return keys::kWindowTypeValueNormal; } diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc index 5be059b..edd13b8 100644 --- a/chrome/browser/extensions/window_open_apitest.cc +++ b/chrome/browser/extensions/window_open_apitest.cc @@ -41,8 +41,8 @@ void WaitForTabsAndPopups(Browser* browser, int num_tabs, int num_popups) { if (*iter == browser) continue; - // Check for TYPE_POPUP or TYPE_APP_POPUP/PANEL. - ASSERT_TRUE((*iter)->type() & Browser::TYPE_POPUP); + // Check for TYPE_POPUP or TYPE_PANEL. + ASSERT_TRUE((*iter)->is_type_popup() || (*iter)->is_type_panel()); } break; @@ -104,9 +104,11 @@ class WindowOpenPanelTest : public ExtensionApiTest { virtual void SetUpCommandLine(CommandLine* command_line) { ExtensionApiTest::SetUpCommandLine(command_line); command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); + command_line->AppendSwitch(switches::kEnablePanels); } }; -IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, WindowOpenPanel) { +// TODO(jianli): Enable it when Panel::CreateNativePanel is implemented. +IN_PROC_BROWSER_TEST_F(WindowOpenPanelTest, DISABLED_WindowOpenPanel) { ASSERT_TRUE(RunExtensionTest("window_open/panel")) << message_; } diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index cb9534e..ff31887 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -239,9 +239,8 @@ class GeolocationBrowserTest : public InProcessBrowserTest { LOG(WARNING) << "before navigate"; if (options == INITIALIZATION_OFFTHERECORD) { ui_test_utils::OpenURLOffTheRecord(browser()->profile(), current_url_); - current_browser_ = BrowserList::FindBrowserWithType( - browser()->profile()->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, - false); + current_browser_ = BrowserList::FindTabbedBrowser( + browser()->profile()->GetOffTheRecordProfile(), false); } else if (options == INITIALIZATION_NEWTAB) { current_browser_ = browser(); current_browser_->NewTab(); diff --git a/chrome/browser/sessions/session_restore.cc b/chrome/browser/sessions/session_restore.cc index 4b06737..8f70163 100644 --- a/chrome/browser/sessions/session_restore.cc +++ b/chrome/browser/sessions/session_restore.cc @@ -581,14 +581,14 @@ class SessionRestoreImpl : public NotificationObserver { for (std::vector<SessionWindow*>::iterator i = windows->begin(); i != windows->end(); ++i) { Browser* browser = NULL; - if (!has_tabbed_browser && (*i)->type == Browser::TYPE_NORMAL) + if (!has_tabbed_browser && (*i)->type == Browser::TYPE_TABBED) has_tabbed_browser = true; - if (i == windows->begin() && (*i)->type == Browser::TYPE_NORMAL && + if (i == windows->begin() && (*i)->type == Browser::TYPE_TABBED && !clobber_existing_window_) { // If there is an open tabbed browser window, use it. Otherwise fall // through and create a new one. browser = current_browser; - if (browser && (browser->type() != Browser::TYPE_NORMAL || + if (browser && (!browser->is_type_tabbed() || browser->profile()->IsOffTheRecord())) { browser = NULL; } @@ -599,7 +599,7 @@ class SessionRestoreImpl : public NotificationObserver { (*i)->bounds, (*i)->is_maximized); } - if ((*i)->type == Browser::TYPE_NORMAL) + if ((*i)->type == Browser::TYPE_TABBED) last_browser = browser; const int initial_tab_count = browser->tab_count(); int selected_tab_index = (*i)->selected_tab_index; @@ -614,7 +614,7 @@ class SessionRestoreImpl : public NotificationObserver { // included at least one tabbed browser, then close the browser window // that was opened when the user clicked to restore the session. if (clobber_existing_window_ && current_browser && has_tabbed_browser && - current_browser->type() == Browser::TYPE_NORMAL) { + current_browser->is_type_tabbed()) { current_browser->CloseAllTabs(); } if (last_browser && !urls_to_open_.empty()) diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc index 9e6e609b..79b1990 100644 --- a/chrome/browser/sessions/session_restore_uitest.cc +++ b/chrome/browser/sessions/session_restore_uitest.cc @@ -326,11 +326,11 @@ TEST_F(SessionRestoreUITest, NormalAndPopup) { // The order of whether the normal window or popup is first depends upon // activation order, which is not necessarily consistant across runs. - if (type1 == Browser::TYPE_NORMAL) { + if (type1 == Browser::TYPE_TABBED) { EXPECT_EQ(type2, Browser::TYPE_POPUP); } else { EXPECT_EQ(type1, Browser::TYPE_POPUP); - EXPECT_EQ(type2, Browser::TYPE_NORMAL); + EXPECT_EQ(type2, Browser::TYPE_TABBED); } } @@ -381,7 +381,7 @@ TEST_F(SessionRestoreUITest, TwoWindowsCloseOneRestoreOnlyOne) { ASSERT_EQ(1, window_count); // Open a second window. - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true)); ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); ASSERT_EQ(2, window_count); diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 283371e..5727ef5 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -1308,42 +1308,31 @@ bool SessionService::ShouldTrackChangesToWindow(const SessionID& window_id) { } +bool SessionService::should_track_changes_for_browser_type(Browser::Type type) { + return type == Browser::TYPE_TABBED || + (type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups); +} + SessionService::WindowType SessionService::WindowTypeForBrowserType( Browser::Type type) { - // We don't support masks here, only discrete types. switch (type) { case Browser::TYPE_POPUP: return TYPE_POPUP; - case Browser::TYPE_APP: - return TYPE_APP; - case Browser::TYPE_APP_POPUP: - return TYPE_APP_POPUP; - case Browser::TYPE_DEVTOOLS: - return TYPE_DEVTOOLS; - case Browser::TYPE_APP_PANEL: - return TYPE_APP_PANEL; - case Browser::TYPE_NORMAL: + case Browser::TYPE_TABBED: + return TYPE_TABBED; default: - return TYPE_NORMAL; + DCHECK(false); + return TYPE_TABBED; } } -Browser::Type SessionService::BrowserTypeForWindowType( - SessionService::WindowType type) { +Browser::Type SessionService::BrowserTypeForWindowType(WindowType type) { switch (type) { case TYPE_POPUP: return Browser::TYPE_POPUP; - case TYPE_APP: - return Browser::TYPE_APP; - case TYPE_APP_POPUP: - return Browser::TYPE_APP_POPUP; - case TYPE_DEVTOOLS: - return Browser::TYPE_DEVTOOLS; - case TYPE_APP_PANEL: - return Browser::TYPE_APP_PANEL; - case TYPE_NORMAL: + case TYPE_TABBED: default: - return Browser::TYPE_NORMAL; + return Browser::TYPE_TABBED; } } diff --git a/chrome/browser/sessions/session_service.h b/chrome/browser/sessions/session_service.h index d105280..1541537 100644 --- a/chrome/browser/sessions/session_service.h +++ b/chrome/browser/sessions/session_service.h @@ -187,13 +187,10 @@ class SessionService : public BaseSessionService, // These types mirror Browser::Type, but are re-defined here because these // specific enumeration _values_ are written into the session database and // are needed to maintain forward compatibility. + // Note that we only store browsers of type TYPE_TABBED and TYPE_POPUP. enum WindowType { - TYPE_NORMAL = 0, - TYPE_POPUP = 1, - TYPE_APP = 2, - TYPE_APP_POPUP = TYPE_APP + TYPE_POPUP, - TYPE_DEVTOOLS = TYPE_APP + 4, - TYPE_APP_PANEL = TYPE_APP + 8 + TYPE_TABBED = 0, + TYPE_POPUP = 1 }; void Init(); @@ -366,10 +363,7 @@ class SessionService : public BaseSessionService, bool ShouldTrackChangesToWindow(const SessionID& window_id); // Returns true if we track changes to the specified browser type. - static bool should_track_changes_for_browser_type(Browser::Type type) { - return type == Browser::TYPE_NORMAL || - (type == Browser::TYPE_POPUP && browser_defaults::kRestorePopups); - } + static bool should_track_changes_for_browser_type(Browser::Type type); // Returns true if we should record a window close as pending. // |has_open_trackable_browsers_| must be up-to-date before calling this. diff --git a/chrome/browser/sessions/session_service_unittest.cc b/chrome/browser/sessions/session_service_unittest.cc index d10548e9..0f74792 100644 --- a/chrome/browser/sessions/session_service_unittest.cc +++ b/chrome/browser/sessions/session_service_unittest.cc @@ -46,7 +46,7 @@ class SessionServiceTest : public BrowserWithTestWindowTest, SessionService* session_service = new SessionService(path_); helper_.set_service(session_service); - service()->SetWindowType(window_id, Browser::TYPE_NORMAL); + service()->SetWindowType(window_id, Browser::TYPE_TABBED); service()->SetWindowBounds(window_id, window_bounds, false); } @@ -161,7 +161,7 @@ TEST_F(SessionServiceTest, Basic) { ASSERT_EQ(0, windows[0]->selected_tab_index); ASSERT_EQ(window_id.id(), windows[0]->window_id.id()); ASSERT_EQ(1U, windows[0]->tabs.size()); - ASSERT_EQ(Browser::TYPE_NORMAL, windows[0]->type); + ASSERT_EQ(Browser::TYPE_TABBED, windows[0]->type); SessionTab* tab = windows[0]->tabs[0]; helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); @@ -271,7 +271,7 @@ TEST_F(SessionServiceTest, TwoWindows) { UpdateNavigation(window_id, tab1_id, nav1, 0, true); const gfx::Rect window2_bounds(3, 4, 5, 6); - service()->SetWindowType(window2_id, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, Browser::TYPE_TABBED); service()->SetWindowBounds(window2_id, window2_bounds, true); helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); UpdateNavigation(window2_id, tab2_id, nav2, 0, true); @@ -323,7 +323,7 @@ TEST_F(SessionServiceTest, WindowWithNoTabsGetsPruned) { UpdateNavigation(window_id, tab1_id, nav1, 0, true); const gfx::Rect window2_bounds(3, 4, 5, 6); - service()->SetWindowType(window2_id, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, Browser::TYPE_TABBED); service()->SetWindowBounds(window2_id, window2_bounds, false); helper_.PrepareTabInWindow(window2_id, tab2_id, 0, true); @@ -383,7 +383,7 @@ TEST_F(SessionServiceTest, WindowCloseCommittedAfterNavigate) { SessionID tab2_id; ASSERT_NE(window2_id.id(), window_id.id()); - service()->SetWindowType(window2_id, Browser::TYPE_NORMAL); + service()->SetWindowType(window2_id, Browser::TYPE_TABBED); service()->SetWindowBounds(window2_id, window_bounds, false); TabNavigation nav1(0, GURL("http://google.com"), GURL(), @@ -485,14 +485,14 @@ TEST_F(SessionServiceTest, RestorePopup) { ReadWindows(&(windows.get())); ASSERT_EQ(2U, windows->size()); - int normal_index = windows[0]->type == Browser::TYPE_NORMAL ? + int tabbed_index = windows[0]->type == Browser::TYPE_TABBED ? 0 : 1; - int popup_index = normal_index == 0 ? 1 : 0; - ASSERT_EQ(0, windows[normal_index]->selected_tab_index); - ASSERT_EQ(window_id.id(), windows[normal_index]->window_id.id()); - ASSERT_EQ(1U, windows[normal_index]->tabs.size()); + int popup_index = tabbed_index == 0 ? 1 : 0; + ASSERT_EQ(0, windows[tabbed_index]->selected_tab_index); + ASSERT_EQ(window_id.id(), windows[tabbed_index]->window_id.id()); + ASSERT_EQ(1U, windows[tabbed_index]->tabs.size()); - SessionTab* tab = windows[normal_index]->tabs[0]; + SessionTab* tab = windows[tabbed_index]->tabs[0]; helper_.AssertTabEquals(window_id, tab_id, 0, 0, 1, *tab); helper_.AssertNavigationEquals(nav1, tab->navigations[0]); diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index 5749f31..27488c9 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -99,7 +99,7 @@ SessionTab::~SessionTab() { SessionWindow::SessionWindow() : selected_tab_index(-1), - type(Browser::TYPE_NORMAL), + type(Browser::TYPE_TABBED), is_constrained(true), is_maximized(false) { } diff --git a/chrome/browser/sessions/session_types.h b/chrome/browser/sessions/session_types.h index 3a70156..c76f291 100644 --- a/chrome/browser/sessions/session_types.h +++ b/chrome/browser/sessions/session_types.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -166,7 +166,7 @@ struct SessionWindow { int selected_tab_index; // Type of the browser. Currently we only store browsers of type - // TYPE_NORMAL and TYPE_POPUP. + // TYPE_TABBED and TYPE_POPUP. // This would be Browser::Type, but that would cause a circular dependency. int type; diff --git a/chrome/browser/sessions/tab_restore_service_browsertest.cc b/chrome/browser/sessions/tab_restore_service_browsertest.cc index d1af01b..9b282b2 100644 --- a/chrome/browser/sessions/tab_restore_service_browsertest.cc +++ b/chrome/browser/sessions/tab_restore_service_browsertest.cc @@ -87,7 +87,7 @@ class TabRestoreServiceTest : public RenderViewHostTestHarness { SessionServiceFactory::GetForProfile(profile()); SessionID tab_id; SessionID window_id; - session_service->SetWindowType(window_id, Browser::TYPE_NORMAL); + session_service->SetWindowType(window_id, Browser::TYPE_TABBED); session_service->SetTabWindow(window_id, tab_id); session_service->SetTabIndexInWindow(window_id, tab_id, 0); session_service->SetSelectedTabInWindow(window_id, 0); diff --git a/chrome/browser/sync/glue/session_model_associator.cc b/chrome/browser/sync/glue/session_model_associator.cc index 1244508..e7e5c58a 100644 --- a/chrome/browser/sync/glue/session_model_associator.cc +++ b/chrome/browser/sync/glue/session_model_associator.cc @@ -122,7 +122,7 @@ void SessionModelAssociator::ReassociateWindows(bool reload_tabs) { // for us to get a handle to a browser that is about to be removed. If // the tab count is 0 or the window is NULL, the browser is about to be // deleted, so we ignore it. - if (ShouldSyncWindowType((*i)->type()) && (*i)->tab_count() && + if (ShouldSyncWindow(*i) && (*i)->tab_count() && (*i)->window()) { sync_pb::SessionWindow window_s; SessionID::id_type window_id = (*i)->session_id().id(); @@ -130,10 +130,9 @@ void SessionModelAssociator::ReassociateWindows(bool reload_tabs) { (*i)->tab_count() << " tabs."; window_s.set_window_id(window_id); window_s.set_selected_tab_index((*i)->active_index()); - if ((*i)->type() == - Browser::TYPE_NORMAL) { + if ((*i)->is_type_tabbed()) { window_s.set_browser_type( - sync_pb::SessionWindow_BrowserType_TYPE_NORMAL); + sync_pb::SessionWindow_BrowserType_TYPE_TABBED); } else { window_s.set_browser_type( sync_pb::SessionWindow_BrowserType_TYPE_POPUP); @@ -170,22 +169,10 @@ void SessionModelAssociator::ReassociateWindows(bool reload_tabs) { } // Static. -bool SessionModelAssociator::ShouldSyncWindowType(const Browser::Type& type) { - switch (type) { - case Browser::TYPE_POPUP: - return true; - case Browser::TYPE_APP: - return false; - case Browser::TYPE_APP_POPUP: - return false; - case Browser::TYPE_DEVTOOLS: - return false; - case Browser::TYPE_APP_PANEL: - return false; - case Browser::TYPE_NORMAL: - default: - return true; - } +bool SessionModelAssociator::ShouldSyncWindow(const Browser* browser) { + if (browser->is_app()) + return false; + return browser->is_type_tabbed() || browser->is_type_popup(); } void SessionModelAssociator::ReassociateTabs( @@ -582,7 +569,7 @@ void SessionModelAssociator::PopulateSessionWindowFromSpecifics( session_window->selected_tab_index = specifics.selected_tab_index(); if (specifics.has_browser_type()) { if (specifics.browser_type() == - sync_pb::SessionWindow_BrowserType_TYPE_NORMAL) { + sync_pb::SessionWindow_BrowserType_TYPE_TABBED) { session_window->type = 1; } else { session_window->type = 2; @@ -910,9 +897,9 @@ void SessionModelAssociator::PopulateSessionSpecificsWindow( DCHECK(CalledOnValidThread()); session_window->set_window_id(window.window_id.id()); session_window->set_selected_tab_index(window.selected_tab_index); - if (window.type == Browser::TYPE_NORMAL) { + if (window.type == Browser::TYPE_TABBED) { session_window->set_browser_type( - sync_pb::SessionWindow_BrowserType_TYPE_NORMAL); + sync_pb::SessionWindow_BrowserType_TYPE_TABBED); } else if (window.type == Browser::TYPE_POPUP) { session_window->set_browser_type( sync_pb::SessionWindow_BrowserType_TYPE_POPUP); diff --git a/chrome/browser/sync/glue/session_model_associator.h b/chrome/browser/sync/glue/session_model_associator.h index 28582e0..b975013 100644 --- a/chrome/browser/sync/glue/session_model_associator.h +++ b/chrome/browser/sync/glue/session_model_associator.h @@ -301,7 +301,7 @@ class SessionModelAssociator void DeleteForeignSessions(); // Determine if a window is of a type we're interested in syncing. - static bool ShouldSyncWindowType(const Browser::Type& type); + static bool ShouldSyncWindow(const Browser* browser); // Build a sync tag from tab_node_id. static inline std::string TabIdToTag( diff --git a/chrome/browser/sync/glue/session_model_associator_unittest.cc b/chrome/browser/sync/glue/session_model_associator_unittest.cc index 693e65f..e04b02a 100644 --- a/chrome/browser/sync/glue/session_model_associator_unittest.cc +++ b/chrome/browser/sync/glue/session_model_associator_unittest.cc @@ -54,7 +54,7 @@ TEST_F(SessionModelAssociatorTest, IsValidSessionTab) { TEST_F(SessionModelAssociatorTest, PopulateSessionWindow) { sync_pb::SessionWindow window_s; window_s.add_tab(0); - window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_NORMAL); + window_s.set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); window_s.set_selected_tab_index(1); std::string tag = "tag"; diff --git a/chrome/browser/sync/profile_sync_service_session_unittest.cc b/chrome/browser/sync/profile_sync_service_session_unittest.cc index 475fd39..33f0baf 100644 --- a/chrome/browser/sync/profile_sync_service_session_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_session_unittest.cc @@ -76,7 +76,7 @@ class ProfileSyncServiceSessionTest ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); SessionService* session_service = new SessionService(temp_dir_.path()); helper_.set_service(session_service); - service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); + service()->SetWindowType(window_id_, Browser::TYPE_TABBED); service()->SetWindowBounds(window_id_, window_bounds_, false); registrar_.Add(this, NotificationType::FOREIGN_SESSION_UPDATED, NotificationService::AllSources()); @@ -280,7 +280,7 @@ TEST_F(ProfileSyncServiceSessionTest, WriteForeignSessionToNode) { sync_pb::SessionHeader* header_s = meta_specifics.mutable_header(); sync_pb::SessionWindow* window_s = header_s->add_window(); window_s->add_tab(0); - window_s->set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_NORMAL); + window_s->set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); window_s->set_selected_tab_index(1); sync_pb::SessionSpecifics tab_specifics; diff --git a/chrome/browser/sync/protocol/proto_enum_conversions.cc b/chrome/browser/sync/protocol/proto_enum_conversions.cc index 5d3c1d6..1d81529 100644 --- a/chrome/browser/sync/protocol/proto_enum_conversions.cc +++ b/chrome/browser/sync/protocol/proto_enum_conversions.cc @@ -23,9 +23,9 @@ namespace browser_sync { const char* GetBrowserTypeString( sync_pb::SessionWindow::BrowserType browser_type) { ASSERT_ENUM_BOUNDS(sync_pb::SessionWindow, BrowserType, - TYPE_NORMAL, TYPE_POPUP); + TYPE_TABBED, TYPE_POPUP); switch (browser_type) { - ENUM_CASE(sync_pb::SessionWindow, TYPE_NORMAL); + ENUM_CASE(sync_pb::SessionWindow, TYPE_TABBED); ENUM_CASE(sync_pb::SessionWindow, TYPE_POPUP); } NOTREACHED(); diff --git a/chrome/browser/sync/protocol/session_specifics.proto b/chrome/browser/sync/protocol/session_specifics.proto index bfed4aa..28ffbd9 100644 --- a/chrome/browser/sync/protocol/session_specifics.proto +++ b/chrome/browser/sync/protocol/session_specifics.proto @@ -33,12 +33,12 @@ message SessionWindow { // Index of the selected tab in tabs; -1 if no tab is selected. optional int32 selected_tab_index = 2 [default = -1]; // Type of the browser. Currently we only store browsers of type - // TYPE_NORMAL and TYPE_POPUP. + // TYPE_TABBED and TYPE_POPUP. enum BrowserType { - TYPE_NORMAL = 1; + TYPE_TABBED = 1; TYPE_POPUP = 2; } - optional BrowserType browser_type = 3 [default = TYPE_NORMAL]; + optional BrowserType browser_type = 3 [default = TYPE_TABBED]; // The tabs that compose a window (correspond to tab id's). repeated int32 tab = 4; } diff --git a/chrome/browser/sync/sync_setup_wizard_unittest.cc b/chrome/browser/sync/sync_setup_wizard_unittest.cc index ef7acd0..073ca89 100644 --- a/chrome/browser/sync/sync_setup_wizard_unittest.cc +++ b/chrome/browser/sync/sync_setup_wizard_unittest.cc @@ -173,7 +173,7 @@ class SyncSetupWizardTest : public BrowserWithTestWindowTest { profile()->CreateBookmarkModel(false); // Wait for the bookmarks model to load. profile()->BlockUntilBookmarkModelLoaded(); - set_browser(new Browser(Browser::TYPE_NORMAL, profile())); + set_browser(new Browser(Browser::TYPE_TABBED, profile())); test_window_ = new TestBrowserWindowForWizardTest(browser()); set_window(test_window_); browser()->set_window(window()); diff --git a/chrome/browser/tab_restore_uitest.cc b/chrome/browser/tab_restore_uitest.cc index d9b23fd..dfe1c54 100644 --- a/chrome/browser/tab_restore_uitest.cc +++ b/chrome/browser/tab_restore_uitest.cc @@ -224,7 +224,7 @@ TEST_F(TabRestoreUITest, RestoreToDifferentWindow) { EXPECT_EQ(starting_tab_count + 2, tab_count); // Create a new browser. - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, false)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, false)); int window_count; ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(2, window_count); @@ -267,7 +267,7 @@ TEST_F(TabRestoreUITest, MAYBE_BasicRestoreFromClosedWindow) { ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_proxy->NavigateToURL(url2_)); // Create a new browser. - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, false)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, false)); int window_count; ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(2, window_count); @@ -351,7 +351,7 @@ TEST_F(TabRestoreUITest, RestoreWindowAndTab) { EXPECT_EQ(starting_tab_count + 2, tab_count); // Create a new browser. - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, false)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, false)); int window_count; ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(2, window_count); @@ -401,7 +401,7 @@ TEST_F(TabRestoreUITest, RestoreIntoSameWindow) { ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab_proxy->NavigateToURL(url2_)); // Create a new browser. - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, false)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, false)); int window_count; ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(2, window_count); @@ -545,7 +545,7 @@ TEST_F(TabRestoreUITest, RestoreWindow) { // Create a new window. int window_count; ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, false)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, false)); int new_window_count = 0; ASSERT_TRUE(automation()->GetBrowserWindowCount(&new_window_count)); EXPECT_EQ(++window_count, new_window_count); diff --git a/chrome/browser/tabs/pinned_tab_codec.cc b/chrome/browser/tabs/pinned_tab_codec.cc index bf53a4c..91279e0 100644 --- a/chrome/browser/tabs/pinned_tab_codec.cc +++ b/chrome/browser/tabs/pinned_tab_codec.cc @@ -102,7 +102,7 @@ void PinnedTabCodec::WritePinnedTabs(Profile* profile) { for (BrowserList::const_iterator i = BrowserList::begin(); i != BrowserList::end(); ++i) { Browser* browser = *i; - if (browser->type() == Browser::TYPE_NORMAL && + if (browser->is_type_tabbed() && browser->profile() == profile && HasPinnedTabs(browser)) { EncodePinnedTabs(browser, &values); } diff --git a/chrome/browser/tabs/pinned_tab_service.cc b/chrome/browser/tabs/pinned_tab_service.cc index 0633998..ac61609 100644 --- a/chrome/browser/tabs/pinned_tab_service.cc +++ b/chrome/browser/tabs/pinned_tab_service.cc @@ -14,7 +14,7 @@ static bool IsLastNormalBrowser(Browser* browser) { for (BrowserList::const_iterator i = BrowserList::begin(); i != BrowserList::end(); ++i) { - if (*i != browser && (*i)->type() == Browser::TYPE_NORMAL && + if (*i != browser && (*i)->is_type_tabbed() && (*i)->profile() == browser->profile()) { return false; } @@ -43,7 +43,7 @@ void PinnedTabService::Observe(NotificationType type, switch (type.value) { case NotificationType::BROWSER_OPENED: { Browser* browser = Source<Browser>(source).ptr(); - if (!has_normal_browser_ && browser->type() == Browser::TYPE_NORMAL && + if (!has_normal_browser_ && browser->is_type_tabbed() && browser->profile() == profile_) { has_normal_browser_ = true; } diff --git a/chrome/browser/tabs/tab_finder.cc b/chrome/browser/tabs/tab_finder.cc index 3e35487..448455b 100644 --- a/chrome/browser/tabs/tab_finder.cc +++ b/chrome/browser/tabs/tab_finder.cc @@ -159,7 +159,7 @@ bool TabFinder::TabMatchesURL(TabContents* tab_contents, const GURL& url) { } TabContents* TabFinder::FindTabInBrowser(Browser* browser, const GURL& url) { - if (browser->type() != Browser::TYPE_NORMAL) + if (!browser->is_type_tabbed()) return NULL; for (int i = 0; i < browser->tab_count(); ++i) { diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 2acca11..b288f11 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -982,9 +982,7 @@ void TaskManager::OpenAboutMemory() { // non-tabbed window, the call to OpenURL above will have opened a // TabContents in a tabbed browser, so we need to grab it with GetLastActive // before the call to show(). - if (browser->type() & (Browser::TYPE_APP | - Browser::TYPE_DEVTOOLS | - Browser::TYPE_POPUP)) { + if (!browser->is_type_tabbed()) { browser = BrowserList::GetLastActive(); DCHECK(browser); } diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 1545c27..194acff 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -193,6 +193,14 @@ const char kHashMark[] = "#"; extern bool g_log_bug53991; +//////////////////////////////////////////////////////////////////////////////// +// Browser, CreateParams: + +Browser::CreateParams::CreateParams(Type type, Profile* profile) + : type(type), + profile(profile) { +} + /////////////////////////////////////////////////////////////////////////////// // Browser, Constructors, Creation, Showing: @@ -337,54 +345,59 @@ Browser::~Browser() { // static Browser* Browser::Create(Profile* profile) { - Browser* browser = new Browser(TYPE_NORMAL, profile); + Browser* browser = new Browser(TYPE_TABBED, profile); browser->InitBrowserWindow(); return browser; } // static -Browser* Browser::CreateForType(Type type, Profile* profile) { - Browser* browser = new Browser(type, profile); +Browser* Browser::CreateWithParams(const CreateParams& params) { + Browser* browser = new Browser(params.type, params.profile); + browser->app_name_ = params.app_name; + if (!params.initial_bounds.IsEmpty()) + browser->set_override_bounds(params.initial_bounds); browser->InitBrowserWindow(); return browser; } // static -Browser* Browser::CreateForApp(const std::string& app_name, - const gfx::Size& window_size, - Profile* profile, - bool is_panel) { - Browser::Type type = TYPE_APP; +Browser* Browser::CreateForType(Type type, Profile* profile) { + CreateParams params(type, profile); + return CreateWithParams(params); +} - if (is_panel) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) { - type = TYPE_APP_PANEL; - } else { - // TYPE_APP_PANEL is the logical choice. However, the panel UI - // is not fully implemented. See crbug/55943. - type = TYPE_APP_POPUP; - } - } +// static +Browser* Browser::CreateForApp(Type type, + const std::string& app_name, + const gfx::Size& window_size, + Profile* profile) { + DCHECK(type != TYPE_TABBED); + DCHECK(!app_name.empty()); - Browser* browser = new Browser(type, profile); - browser->app_name_ = app_name; + RegisterAppPrefs(app_name, profile); - if (!window_size.IsEmpty()) { - gfx::Rect initial_pos(window_size); - browser->set_override_bounds(initial_pos); +#if !defined(OS_CHROMEOS) + if (type == TYPE_PANEL && + !CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) { + // The panel UI is not fully implemented, so we default to TYPE_POPUP when + // the panel switch is not enabled. See crbug/55943. + type = TYPE_POPUP; } +#endif - browser->InitBrowserWindow(); + CreateParams params(type, profile); + params.app_name = app_name; + if (!window_size.IsEmpty()) + params.initial_bounds.set_size(window_size); - return browser; + return CreateWithParams(params); } // static Browser* Browser::CreateForDevTools(Profile* profile) { - Browser* browser = new Browser(TYPE_DEVTOOLS, profile); - browser->app_name_ = DevToolsWindow::kDevToolsApp; - browser->InitBrowserWindow(); - return browser; + CreateParams params(TYPE_POPUP, profile); + params.app_name = DevToolsWindow::kDevToolsApp; + return CreateWithParams(params); } void Browser::InitBrowserWindow() { @@ -401,7 +414,7 @@ void Browser::InitBrowserWindow() { // Set the app user model id for this application to that of the application // name. See http://crbug.com/7028. app::win::SetAppIdForWindow( - type_ & TYPE_APP ? + is_app() ? ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : ShellIntegration::GetChromiumAppId(profile_->GetPath()), window()->GetNativeHandle()); @@ -472,6 +485,14 @@ bool Browser::HasFindBarController() const { return find_bar_controller_.get() != NULL; } +bool Browser::is_app() const { + return !app_name_.empty(); +} + +bool Browser::is_devtools() const { + return app_name_ == DevToolsWindow::kDevToolsApp; +} + /////////////////////////////////////////////////////////////////////////////// // Browser, Creation Helpers: @@ -550,17 +571,16 @@ TabContents* Browser::OpenApplicationWindow( else app_name = web_app::GenerateApplicationNameFromURL(url); - RegisterAppPrefs(app_name, profile); - - bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL); + Type type = extension && (container == extension_misc::LAUNCH_PANEL) ? + TYPE_PANEL : TYPE_POPUP; gfx::Size window_size; if (extension) window_size.SetSize(extension->launch_width(), extension->launch_height()); - Browser* browser = Browser::CreateForApp(app_name, window_size, profile, - as_panel); + Browser* browser = Browser::CreateForApp(type, app_name, window_size, + profile); if (app_browser) *app_browser = browser; @@ -608,8 +628,7 @@ TabContents* Browser::OpenAppShortcutWindow(Profile* profile, TabContents* Browser::OpenApplicationTab(Profile* profile, const Extension* extension, TabContents* existing_tab) { - Browser* browser = - BrowserList::FindBrowserWithType(profile, Browser::TYPE_NORMAL, false); + Browser* browser = BrowserList::FindTabbedBrowser(profile, false); TabContents* contents = NULL; if (!browser) return contents; @@ -761,8 +780,18 @@ std::string Browser::GetWindowPlacementKey() const { } bool Browser::ShouldSaveWindowPlacement() const { - // Only save the window placement of popups if they are restored. - return (type() & TYPE_POPUP) == 0 || browser_defaults::kRestorePopups; + switch (type_) { + case TYPE_TABBED: + return true; + case TYPE_POPUP: + // Only save the window placement of popups if they are restored. + return browser_defaults::kRestorePopups; + case TYPE_PANEL: + // Do not save the window placement of panels. + return false; + default: + return false; + } } void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) { @@ -842,7 +871,7 @@ string16 Browser::GetWindowTitleForCurrentTab() const { #else int string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT; // Don't append the app name to window titles on app frames and app popups - if (type_ & TYPE_APP) + if (is_app()) string_id = IDS_BROWSER_WINDOW_TITLE_FORMAT_NO_LOGO; return l10n_util::GetStringFUTF16(string_id, title); #endif @@ -915,7 +944,7 @@ void Browser::OnWindowClosing() { TabRestoreService* tab_restore_service = TabRestoreServiceFactory::GetForProfile(profile()); - if (tab_restore_service && type() == TYPE_NORMAL && tab_count()) + if (tab_restore_service && is_type_tabbed() && tab_count()) tab_restore_service->BrowserClosing(tab_restore_service_delegate()); // TODO(sky): convert session/tab restore to use notification. @@ -1142,35 +1171,34 @@ void Browser::ShowSingletonTab(const GURL& url) { void Browser::UpdateCommandsForFullscreenMode(bool is_fullscreen) { #if !defined(OS_MACOSX) - const bool show_main_ui = (type() == TYPE_NORMAL) && !is_fullscreen; + const bool show_main_ui = is_type_tabbed() && !is_fullscreen; #else - const bool show_main_ui = (type() == TYPE_NORMAL); + const bool show_main_ui = is_type_tabbed(); #endif - bool main_not_fullscreen_or_popup = - show_main_ui && !is_fullscreen && (type() & TYPE_POPUP) == 0; + bool main_not_fullscreen = show_main_ui && !is_fullscreen; // Navigation commands command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); // Window management commands command_updater_.UpdateCommandEnabled(IDC_SHOW_AS_TAB, - (type() & TYPE_POPUP) && !is_fullscreen); + type_ != TYPE_TABBED && !is_fullscreen); // Focus various bits of UI command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); command_updater_.UpdateCommandEnabled(IDC_FOCUS_LOCATION, show_main_ui); command_updater_.UpdateCommandEnabled(IDC_FOCUS_SEARCH, show_main_ui); command_updater_.UpdateCommandEnabled( - IDC_FOCUS_MENU_BAR, main_not_fullscreen_or_popup); + IDC_FOCUS_MENU_BAR, main_not_fullscreen); command_updater_.UpdateCommandEnabled( - IDC_FOCUS_NEXT_PANE, main_not_fullscreen_or_popup); + IDC_FOCUS_NEXT_PANE, main_not_fullscreen); command_updater_.UpdateCommandEnabled( - IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen_or_popup); + IDC_FOCUS_PREVIOUS_PANE, main_not_fullscreen); command_updater_.UpdateCommandEnabled( - IDC_FOCUS_BOOKMARKS, main_not_fullscreen_or_popup); + IDC_FOCUS_BOOKMARKS, main_not_fullscreen); command_updater_.UpdateCommandEnabled( - IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen_or_popup); + IDC_FOCUS_CHROMEOS_STATUS, main_not_fullscreen); // Show various bits of UI command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); @@ -1242,21 +1270,20 @@ bool Browser::SupportsWindowFeatureImpl(WindowFeature feature, features |= FEATURE_DOWNLOADSHELF; #endif // !defined(OS_CHROMEOS) - if (type() == TYPE_NORMAL) { + if (is_type_tabbed()) features |= FEATURE_BOOKMARKBAR; - } if (!hide_ui_for_fullscreen) { - if (type() != TYPE_NORMAL) + if (!is_type_tabbed()) features |= FEATURE_TITLEBAR; - if (type() == TYPE_NORMAL) + if (is_type_tabbed()) features |= FEATURE_TABSTRIP; - if (type() == TYPE_NORMAL) + if (is_type_tabbed()) features |= FEATURE_TOOLBAR; - if ((type() & Browser::TYPE_APP) == 0) + if (!is_app()) features |= FEATURE_LOCATIONBAR; } return !!(features & feature); @@ -1408,7 +1435,7 @@ void Browser::CloseWindow() { void Browser::NewTab() { UserMetrics::RecordAction(UserMetricsAction("NewTab")); - if (type() == TYPE_NORMAL) { + if (is_type_tabbed()) { AddBlankTab(true); GetSelectedTabContentsWrapper()->view()->RestoreFocus(); } else { @@ -2513,7 +2540,7 @@ Browser* Browser::CreateNewStripWithContents( dock_info.AdjustOtherWindowBounds(); // Create an empty new browser window the same size as the old one. - Browser* browser = new Browser(TYPE_NORMAL, profile_); + Browser* browser = new Browser(TYPE_TABBED, profile_); browser->set_override_bounds(new_window_bounds); browser->set_maximized_state( maximize ? MAXIMIZED_STATE_MAXIMIZED : MAXIMIZED_STATE_UNMAXIMIZED); @@ -2572,12 +2599,12 @@ void Browser::DuplicateContentsAt(int index) { add_types); } else { Browser* browser = NULL; - if (type_ & TYPE_APP) { - CHECK_EQ((type_ & TYPE_POPUP), 0); - CHECK_NE(type_, TYPE_APP_PANEL); - browser = Browser::CreateForApp(app_name_, gfx::Size(), profile_, - false); - } else if (type_ == TYPE_POPUP) { + if (is_app()) { + CHECK(!is_type_popup()); + CHECK(!is_type_panel()); + browser = Browser::CreateForApp(TYPE_POPUP, app_name_, gfx::Size(), + profile_); + } else if (is_type_popup()) { browser = Browser::CreateForType(TYPE_POPUP, profile_); } @@ -2633,7 +2660,7 @@ bool Browser::RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { } bool Browser::CanReloadContents(TabContents* source) const { - return type() != TYPE_DEVTOOLS; + return !is_devtools(); } bool Browser::CanCloseContents(std::vector<int>* indices) { @@ -3023,7 +3050,7 @@ void Browser::CloseContents(TabContents* source) { } void Browser::MoveContents(TabContents* source, const gfx::Rect& pos) { - if ((type() & TYPE_POPUP) == 0) { + if (!IsPopupOrPanel(source)) { NOTREACHED() << "moving invalid browser type"; return; } @@ -3036,9 +3063,9 @@ void Browser::DetachContents(TabContents* source) { tab_handler_->GetTabStripModel()->DetachTabContentsAt(index); } -bool Browser::IsPopup(const TabContents* source) const { +bool Browser::IsPopupOrPanel(const TabContents* source) const { // A non-tabbed BROWSER is an unconstrained popup. - return !!(type() & TYPE_POPUP); + return is_type_popup() || is_type_panel(); } void Browser::ContentsMouseEvent( @@ -3107,17 +3134,16 @@ bool Browser::TakeFocus(bool reverse) { } bool Browser::IsApplication() const { - return (type_ & TYPE_APP) != 0; + return is_app(); } void Browser::ConvertContentsToApplication(TabContents* contents) { const GURL& url = contents->controller().GetActiveEntry()->url(); std::string app_name = web_app::GenerateApplicationNameFromURL(url); - RegisterAppPrefs(app_name, contents->profile()); DetachContents(contents); Browser* app_browser = Browser::CreateForApp( - app_name, gfx::Size(), profile_, false); + TYPE_POPUP, app_name, gfx::Size(), profile_); TabContentsWrapper* wrapper = TabContentsWrapper::GetCurrentWrapperForContents(contents); if (!wrapper) @@ -3455,10 +3481,8 @@ void Browser::Observe(NotificationType type, break; case NotificationType::EXTENSION_READY_FOR_INSTALL: { - // Handle EXTENSION_READY_FOR_INSTALL for last active normal browser. - if (BrowserList::FindBrowserWithType(profile(), - Browser::TYPE_NORMAL, - true) != this) + // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser. + if (BrowserList::FindTabbedBrowser(profile(), true) != this) break; // We only want to show the loading dialog for themes, but we don't want @@ -3514,9 +3538,9 @@ void Browser::OnStateChanged() { DCHECK(profile_->GetProfileSyncService()); #if !defined(OS_MACOSX) - const bool show_main_ui = (type() == TYPE_NORMAL) && !window_->IsFullscreen(); + const bool show_main_ui = is_type_tabbed() && !window_->IsFullscreen(); #else - const bool show_main_ui = (type() == TYPE_NORMAL); + const bool show_main_ui = is_type_tabbed(); #endif command_updater_.UpdateCommandEnabled(IDC_SYNC_BOOKMARKS, @@ -3583,7 +3607,7 @@ gfx::Rect Browser::GetInstantBounds() { // Browser, protected: BrowserWindow* Browser::CreateBrowserWindow() { - if (type() == Browser::TYPE_APP_PANEL && + if (type_ == TYPE_PANEL && CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels)) return PanelManager::GetInstance()->CreatePanel(this); @@ -3690,15 +3714,14 @@ void Browser::InitCommandState() { enable_extensions); // Initialize other commands based on the window type. - bool normal_window = type() == TYPE_NORMAL; - bool non_devtools_window = type() != TYPE_DEVTOOLS; + bool normal_window = is_type_tabbed(); // Navigation commands command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); // Window management commands command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, - type() != TYPE_APP_PANEL); + !(is_type_panel() && is_app())); command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, normal_window); @@ -3718,16 +3741,15 @@ void Browser::InitCommandState() { #endif // Clipboard commands - command_updater_.UpdateCommandEnabled(IDC_COPY_URL, non_devtools_window); + command_updater_.UpdateCommandEnabled(IDC_COPY_URL, !is_devtools()); // Find-in-page - command_updater_.UpdateCommandEnabled(IDC_FIND, non_devtools_window); - command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, non_devtools_window); - command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, non_devtools_window); + command_updater_.UpdateCommandEnabled(IDC_FIND, !is_devtools()); + command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, !is_devtools()); + command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, !is_devtools()); // Autofill - command_updater_.UpdateCommandEnabled(IDC_AUTOFILL_DEFAULT, - non_devtools_window); + command_updater_.UpdateCommandEnabled(IDC_AUTOFILL_DEFAULT, !is_devtools()); // Show various bits of UI command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window); @@ -3766,9 +3788,8 @@ void Browser::UpdateCommandsForTabState() { CanReloadContents(current_tab)); // Window management commands - bool non_app_window = !(type() & TYPE_APP); command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, - non_app_window && CanDuplicateContentsAt(active_index())); + !is_app() && CanDuplicateContentsAt(active_index())); // Page-related commands window_->SetStarredState(current_tab_wrapper->is_starred()); @@ -3847,7 +3868,7 @@ void Browser::UpdateCommandsForBookmarkEditing() { browser_defaults::bookmarks_enabled; command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_PAGE, - enabled && type() == TYPE_NORMAL); + enabled && is_type_tabbed()); command_updater_.UpdateCommandEnabled(IDC_BOOKMARK_ALL_TABS, enabled && CanBookmarkAllTabs()); } @@ -4212,11 +4233,11 @@ bool Browser::CanCloseWithInProgressDownloads() { for (BrowserList::const_iterator iter = BrowserList::begin(); iter != BrowserList::end(); ++iter) { // Don't count this browser window or any other in the process of closing. - // Only consider normal browser windows, not popups. + // Only consider tabbed browser windows, not popups. Browser* const browser = *iter; if (browser == this || browser->is_attempting_to_close_browser_ - || browser->type() != Browser::TYPE_NORMAL) + || !browser->is_type_tabbed()) continue; // Verify that this is not the last non-incognito or incognito browser, @@ -4252,8 +4273,7 @@ bool Browser::CanCloseWithInProgressDownloads() { // static Browser* Browser::GetTabbedBrowser(Profile* profile, bool match_incognito) { - return BrowserList::FindBrowserWithType(profile, TYPE_NORMAL, - match_incognito); + return BrowserList::FindTabbedBrowser(profile, match_incognito); } // static @@ -4332,22 +4352,13 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index, // static void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) { - // A set of apps that we've already started. - static std::set<std::string>* g_app_names = NULL; - - if (!g_app_names) - g_app_names = new std::set<std::string>; - - // Only register once for each app name. - if (g_app_names->find(app_name) != g_app_names->end()) - return; - g_app_names->insert(app_name); - // We need to register the window position pref. std::string window_pref(prefs::kBrowserWindowPlacement); window_pref.append("_"); window_pref.append(app_name); - profile->GetPrefs()->RegisterDictionaryPref(window_pref.c_str()); + PrefService* prefs = profile->GetPrefs(); + if (!prefs->FindPreference(window_pref.c_str())) + prefs->RegisterDictionaryPref(window_pref.c_str()); } void Browser::TabRestoreServiceChanged(TabRestoreService* service) { @@ -4414,7 +4425,7 @@ bool Browser::OpenInstant(WindowOpenDisposition disposition) { } void Browser::CreateInstantIfNecessary() { - if (type() == TYPE_NORMAL && InstantController::IsEnabled(profile()) && + if (is_type_tabbed() && InstantController::IsEnabled(profile()) && !profile()->IsOffTheRecord()) { instant_.reset(new InstantController(profile_, this)); instant_unload_handler_.reset(new InstantUnloadHandler(this)); @@ -4467,7 +4478,7 @@ void Browser::ViewSource(TabContentsWrapper* contents, view_source_contents, add_types); } else { - Browser* browser = Browser::CreateForType(TYPE_NORMAL, profile_); + Browser* browser = Browser::CreateForType(TYPE_TABBED, profile_); // Preserve the size of the original window. The new window has already // been given an offset by the OS, so we shouldn't copy the old bounds. diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 7cc2d82..aadb6b2 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -77,25 +77,9 @@ class Browser : public TabHandlerDelegate, // enum, look at SessionService::WindowType to see if it needs to be // updated. enum Type { - TYPE_NORMAL = 1, + TYPE_TABBED = 1, TYPE_POPUP = 2, - // The old-style app created via "Create application shortcuts". - // Shortcuts to a URL and shortcuts to an installed application - // both have this type. - TYPE_APP = 4, - TYPE_APP_POPUP = TYPE_APP | TYPE_POPUP, - TYPE_DEVTOOLS = TYPE_APP | 8, - - // TODO(skerner): crbug/56776: Until the panel UI is complete on all - // platforms, apps that set app.launch.container = "panel" have type - // APP_POPUP. (see Browser::CreateForApp) - // NOTE: TYPE_APP_PANEL is a superset of TYPE_APP_POPUP. - TYPE_APP_PANEL = TYPE_APP | TYPE_POPUP | 16, - TYPE_ANY = TYPE_NORMAL | - TYPE_POPUP | - TYPE_APP | - TYPE_DEVTOOLS | - TYPE_APP_PANEL + TYPE_PANEL = 3, }; // Possible elements of the Browser window. @@ -124,6 +108,25 @@ class Browser : public TabHandlerDelegate, MAXIMIZED_STATE_UNMAXIMIZED }; + struct CreateParams { + CreateParams(Type type, Profile* profile); + + // The browser type. + Type type; + + // The associated profile. + Profile* profile; + + // The application name that is also the name of the window to the shell. + // This name should be set when: + // 1) we launch an application via an application shortcut or extension API. + // 2) we launch an undocked devtool window. + std::string app_name; + + // The bounds of the window to open. + gfx::Rect initial_bounds; + }; + // Constructors, Creation, Showing ////////////////////////////////////////// // Creates a new browser of the given |type| and for the given |profile|. The @@ -138,17 +141,20 @@ class Browser : public TabHandlerDelegate, // window is created by this function call. static Browser* Create(Profile* profile); + // Like Create, but creates a browser of the specified parameters. + static Browser* CreateWithParams(const CreateParams& params); + // Like Create, but creates a browser of the specified type. static Browser* CreateForType(Type type, Profile* profile); // Like Create, but creates a toolbar-less "app" window for the specified // app. |app_name| is required and is used to identify the window to the - // shell. If |extension| is set, it is used to determine the size of the + // shell. If |window_size| is set, it is used to determine the size of the // window to open. - static Browser* CreateForApp(const std::string& app_name, + static Browser* CreateForApp(Type type, + const std::string& app_name, const gfx::Size& window_size, - Profile* profile, - bool is_panel); + Profile* profile); // Like Create, but creates a tabstrip-less and toolbar-less // DevTools "app" window. @@ -731,12 +737,20 @@ class Browser : public TabHandlerDelegate, // Figure out if there are tabs that have beforeunload handlers. bool TabsNeedBeforeUnloadFired(); + bool is_type_tabbed() const { return type_ == TYPE_TABBED; } + bool is_type_popup() const { return type_ == TYPE_POPUP; } + bool is_type_panel() const { return type_ == TYPE_PANEL; } + + bool is_app() const; + bool is_devtools() const; + protected: // Wrapper for the factory method in BrowserWindow. This allows subclasses to // set their own window. virtual BrowserWindow* CreateBrowserWindow(); private: + FRIEND_TEST_ALL_PREFIXES(AppModeTest, EnableAppModeTest); FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); FRIEND_TEST_ALL_PREFIXES(BrowserTest, OpenAppWindowLikeNtp); @@ -778,7 +792,7 @@ class Browser : public TabHandlerDelegate, virtual void CloseContents(TabContents* source); virtual void MoveContents(TabContents* source, const gfx::Rect& pos); virtual void DetachContents(TabContents* source); - virtual bool IsPopup(const TabContents* source) const; + virtual bool IsPopupOrPanel(const TabContents* source) const; virtual bool CanReloadContents(TabContents* source) const; virtual void UpdateTargetURL(TabContents* source, const GURL& url); virtual void ContentsMouseEvent( @@ -925,6 +939,7 @@ class Browser : public TabHandlerDelegate, // TODO(beng): remove, and provide AutomationProvider a better way to access // the LocationBarView's edit. friend class AutomationProvider; + friend class BrowserProxy; friend class TestingAutomationProvider; // Returns the StatusBubble from the current toolbar. It is possible for @@ -1079,8 +1094,10 @@ class Browser : public TabHandlerDelegate, // The CommandUpdater that manages the browser window commands. CommandUpdater command_updater_; - // An optional application name which is used to retrieve and save window - // positions. + // The application name that is also the name of the window to the shell. + // This name should be set when: + // 1) we launch an application via an application shortcut or extension API. + // 2) we launch an undocked devtool window. std::string app_name_; // Unique identifier of this browser for session restore. This id is only diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc index 6700377..71c61f0 100644 --- a/chrome/browser/ui/browser_init.cc +++ b/chrome/browser/ui/browser_init.cc @@ -967,7 +967,7 @@ Browser* BrowserInit::LaunchWithProfile::OpenTabsInBrowser( if (!profile_ && browser) profile_ = browser->profile(); - if (!browser || browser->type() != Browser::TYPE_NORMAL) { + if (!browser || !browser->is_type_tabbed()) { browser = Browser::Create(profile_); } else { #if defined(TOOLKIT_GTK) diff --git a/chrome/browser/ui/browser_init_browsertest.cc b/chrome/browser/ui/browser_init_browsertest.cc index e5e9a54..929ae83 100644 --- a/chrome/browser/ui/browser_init_browsertest.cc +++ b/chrome/browser/ui/browser_init_browsertest.cc @@ -88,7 +88,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) { Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP, browser()->profile()); - ASSERT_EQ(popup->type(), Browser::TYPE_POPUP); + ASSERT_TRUE(popup->is_type_popup()); ASSERT_EQ(popup, observer.added_browser_); CommandLine dummy(CommandLine::NO_PROGRAM); @@ -122,7 +122,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutNoPref) { ASSERT_FALSE(HasFatalFailure()); // Expect an app window. - EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); + EXPECT_TRUE(new_browser->is_app()); // The browser's app_name should include the app's ID. EXPECT_NE( @@ -151,7 +151,7 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutWindowPref) { ASSERT_FALSE(HasFatalFailure()); // Expect an app window. - EXPECT_EQ(Browser::TYPE_APP, new_browser->type()); + EXPECT_TRUE(new_browser->is_app()); // The browser's app_name should include the app's ID. EXPECT_NE( @@ -181,8 +181,8 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutTabPref) { FindOneOtherBrowser(&new_browser); ASSERT_FALSE(HasFatalFailure()); - // The tab should be in a normal window. - EXPECT_EQ(Browser::TYPE_NORMAL, new_browser->type()); + // The tab should be in a tabbed window. + EXPECT_TRUE(new_browser->is_type_tabbed()); // The browser's app_name should not include the app's ID: It is in a // normal browser. @@ -208,7 +208,11 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenAppShortcutPanel) { ASSERT_FALSE(HasFatalFailure()); // Expect an app panel. - EXPECT_EQ(Browser::TYPE_APP_POPUP, new_browser->type()); +#if defined(OS_CHROMEOS) + EXPECT_TRUE(new_browser->is_type_panel() && new_browser->is_app()); +#else + EXPECT_TRUE(new_browser->is_type_popup() && new_browser->is_app()); +#endif // The new browser's app_name should include the app's ID. EXPECT_NE( diff --git a/chrome/browser/ui/browser_list.cc b/chrome/browser/ui/browser_list.cc index a3ca6e5..10332e5d 100644 --- a/chrome/browser/ui/browser_list.cc +++ b/chrome/browser/ui/browser_list.cc @@ -99,14 +99,13 @@ class BrowserActivityObserver : public NotificationObserver { BrowserActivityObserver* activity_observer = NULL; -// Type used to indicate only the type should be matched. -const int kMatchNothing = 0; +// Type used to indicate to match anything. +const int kMatchAny = 0; // See BrowserMatches for details. const int kMatchOriginalProfile = 1 << 0; - -// See BrowserMatches for details. const int kMatchCanSupportWindowFeature = 1 << 1; +const int kMatchTabbed = 1 << 2; // Returns true if the specified |browser| matches the specified arguments. // |match_types| is a bitmask dictating what parameters to match: @@ -115,9 +114,9 @@ const int kMatchCanSupportWindowFeature = 1 << 1; // incognito windows. // . If it contains kMatchCanSupportWindowFeature // |CanSupportWindowFeature(window_feature)| must return true. +// . If it contains kMatchTabbed, the browser must be a tabbed browser. bool BrowserMatches(Browser* browser, Profile* profile, - Browser::Type type, Browser::WindowFeature window_feature, uint32 match_types) { if (match_types & kMatchCanSupportWindowFeature && @@ -133,8 +132,8 @@ bool BrowserMatches(Browser* browser, return false; } - if (type != Browser::TYPE_ANY && browser->type() != type) - return false; + if (match_types & kMatchTabbed) + return browser->is_type_tabbed(); return true; } @@ -146,16 +145,32 @@ template <class T> Browser* FindBrowserMatching(const T& begin, const T& end, Profile* profile, - Browser::Type type, Browser::WindowFeature window_feature, uint32 match_types) { for (T i = begin; i != end; ++i) { - if (BrowserMatches(*i, profile, type, window_feature, match_types)) + if (BrowserMatches(*i, profile, window_feature, match_types)) return *i; } return NULL; } +Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, + bool match_tabbed, + bool match_incognito) { + uint32 match_types = kMatchAny; + if (match_tabbed) + match_types |= kMatchTabbed; + if (match_incognito) + match_types |= kMatchOriginalProfile; + Browser* browser = FindBrowserMatching( + BrowserList::begin_last_active(), BrowserList::end_last_active(), + profile, Browser::FEATURE_NONE, match_types); + // Fall back to a forward scan of all Browsers if no active one was found. + return browser ? browser : + FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile, + Browser::FEATURE_NONE, match_types); +} + } // namespace BrowserList::BrowserVector BrowserList::browsers_; @@ -455,9 +470,9 @@ void BrowserList::SessionEnding() { bool BrowserList::HasBrowserWithProfile(Profile* profile) { return FindBrowserMatching(BrowserList::begin(), BrowserList::end(), - profile, Browser::TYPE_ANY, + profile, Browser::FEATURE_NONE, - kMatchNothing) != NULL; + kMatchAny) != NULL; } // static @@ -513,43 +528,40 @@ Browser* BrowserList::GetLastActive() { } // static -Browser* BrowserList::GetLastActiveWithProfile(Profile* p) { +Browser* BrowserList::GetLastActiveWithProfile(Profile* profile) { // We are only interested in last active browsers, so we don't fall back to // all browsers like FindBrowserWith* do. return FindBrowserMatching( - BrowserList::begin_last_active(), BrowserList::end_last_active(), p, - Browser::TYPE_ANY, Browser::FEATURE_NONE, kMatchNothing); + BrowserList::begin_last_active(), BrowserList::end_last_active(), profile, + Browser::FEATURE_NONE, kMatchAny); } // static -Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t, - bool match_incognito) { - uint32 match_types = match_incognito ? kMatchOriginalProfile : kMatchNothing; - Browser* browser = FindBrowserMatching( - BrowserList::begin_last_active(), BrowserList::end_last_active(), - p, t, Browser::FEATURE_NONE, match_types); - // Fall back to a forward scan of all Browsers if no active one was found. - return browser ? browser : - FindBrowserMatching(BrowserList::begin(), BrowserList::end(), p, t, - Browser::FEATURE_NONE, match_types); +Browser* BrowserList::FindTabbedBrowser(Profile* profile, + bool match_incognito) { + return FindBrowserWithTabbedOrAnyType(profile, true, match_incognito); +} + +// static +Browser* BrowserList::FindAnyBrowser(Profile* profile, bool match_incognito) { + return FindBrowserWithTabbedOrAnyType(profile, false, match_incognito); } // static -Browser* BrowserList::FindBrowserWithFeature(Profile* p, +Browser* BrowserList::FindBrowserWithFeature(Profile* profile, Browser::WindowFeature feature) { Browser* browser = FindBrowserMatching( BrowserList::begin_last_active(), BrowserList::end_last_active(), - p, Browser::TYPE_ANY, feature, kMatchCanSupportWindowFeature); + profile, feature, kMatchCanSupportWindowFeature); // Fall back to a forward scan of all Browsers if no active one was found. return browser ? browser : - FindBrowserMatching(BrowserList::begin(), BrowserList::end(), p, - Browser::TYPE_ANY, feature, - kMatchCanSupportWindowFeature); + FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile, + feature, kMatchCanSupportWindowFeature); } // static -Browser* BrowserList::FindBrowserWithProfile(Profile* p) { - return FindBrowserWithType(p, Browser::TYPE_ANY, false); +Browser* BrowserList::FindBrowserWithProfile(Profile* profile) { + return FindAnyBrowser(profile, false); } // static @@ -563,23 +575,24 @@ Browser* BrowserList::FindBrowserWithID(SessionID::id_type desired_id) { } // static -size_t BrowserList::GetBrowserCountForType(Profile* p, Browser::Type type) { +size_t BrowserList::GetBrowserCountForType(Profile* profile, + bool match_tabbed) { size_t result = 0; for (BrowserList::const_iterator i = BrowserList::begin(); i != BrowserList::end(); ++i) { - if (BrowserMatches(*i, p, type, Browser::FEATURE_NONE, kMatchNothing)) + if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, + match_tabbed ? kMatchTabbed : kMatchAny)) ++result; } return result; } // static -size_t BrowserList::GetBrowserCount(Profile* p) { +size_t BrowserList::GetBrowserCount(Profile* profile) { size_t result = 0; for (BrowserList::const_iterator i = BrowserList::begin(); i != BrowserList::end(); ++i) { - if (BrowserMatches(*i, p, Browser::TYPE_ANY, Browser::FEATURE_NONE, - kMatchNothing)) { + if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, kMatchAny)) { result++; } } diff --git a/chrome/browser/ui/browser_list.h b/chrome/browser/ui/browser_list.h index 8825e49..1260735 100644 --- a/chrome/browser/ui/browser_list.h +++ b/chrome/browser/ui/browser_list.h @@ -63,28 +63,31 @@ class BrowserList { // Identical in behavior to GetLastActive(), except that the most recently // open browser owned by |profile| is returned. If none exist, returns NULL. // WARNING: see warnings in GetLastActive(). - static Browser* GetLastActiveWithProfile(Profile *profile); + static Browser* GetLastActiveWithProfile(Profile* profile); - // Find an existing browser window with the provided type. Searches in the + // Find an existing browser window with tabbed type. Searches in the // order of last activation. Only browsers that have been active can be // returned. If |match_incognito| is true, will match a browser with either // a regular or incognito profile that matches the given one. Returns NULL if // no such browser currently exists. - static Browser* FindBrowserWithType(Profile* p, Browser::Type t, - bool match_incognito); + static Browser* FindTabbedBrowser(Profile* profile, bool match_incognito); + + // Find an existing browser window with any type. See comment above for + // additional information. + static Browser* FindAnyBrowser(Profile* profile, bool match_incognito); // Find an existing browser window that can provide the specified type (this // uses Browser::CanSupportsWindowFeature, not // Browser::SupportsWindowFeature). This searches in the order of last // activation. Only browsers that have been active can be returned. Returns // NULL if no such browser currently exists. - static Browser* FindBrowserWithFeature(Profile* p, + static Browser* FindBrowserWithFeature(Profile* profile, Browser::WindowFeature feature); // Find an existing browser window with the provided profile. Searches in the // order of last activation. Only browsers that have been active can be // returned. Returns NULL if no such browser currently exists. - static Browser* FindBrowserWithProfile(Profile* p); + static Browser* FindBrowserWithProfile(Profile* profile); // Find an existing browser with the provided ID. Returns NULL if no such // browser currently exists. @@ -152,11 +155,11 @@ class BrowserList { // Return the number of browsers with the following profile which are // currently open. - static size_t GetBrowserCount(Profile* p); + static size_t GetBrowserCount(Profile* profile); // Return the number of browsers with the following profile and type which are // currently open. - static size_t GetBrowserCountForType(Profile* p, Browser::Type type); + static size_t GetBrowserCountForType(Profile* profile, bool match_tabbed); // Returns true if at least one incognito session is active. static bool IsOffTheRecordSessionActive(); diff --git a/chrome/browser/ui/browser_list_unittest.cc b/chrome/browser/ui/browser_list_unittest.cc index e292eec..78b677b 100644 --- a/chrome/browser/ui/browser_list_unittest.cc +++ b/chrome/browser/ui/browser_list_unittest.cc @@ -26,9 +26,9 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyCount) { EXPECT_EQ(0U, CountAllTabs()); // Create more browsers/windows. - scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_NORMAL, profile())); - scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_NORMAL, profile())); - scoped_ptr<Browser> browser4(new Browser(Browser::TYPE_NORMAL, profile())); + scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile())); + scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile())); + scoped_ptr<Browser> browser4(new Browser(Browser::TYPE_TABBED, profile())); scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get())); scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get())); @@ -74,8 +74,8 @@ TEST_F(BrowserListTest, TabContentsIteratorVerifyBrowser) { EXPECT_EQ(1U, BrowserList::size()); // Create more browsers/windows. - scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_NORMAL, profile())); - scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_NORMAL, profile())); + scoped_ptr<Browser> browser2(new Browser(Browser::TYPE_TABBED, profile())); + scoped_ptr<Browser> browser3(new Browser(Browser::TYPE_TABBED, profile())); scoped_ptr<TestBrowserWindow> window2(new TestBrowserWindow(browser2.get())); scoped_ptr<TestBrowserWindow> window3(new TestBrowserWindow(browser3.get())); diff --git a/chrome/browser/ui/browser_navigator.cc b/chrome/browser/ui/browser_navigator.cc index 6666315..c2169b7 100644 --- a/chrome/browser/ui/browser_navigator.cc +++ b/chrome/browser/ui/browser_navigator.cc @@ -19,6 +19,7 @@ #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/chrome_web_ui_factory.h" #include "chrome/common/chrome_switches.h" +#include "chrome/common/extensions/extension.h" #include "chrome/common/url_constants.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/tab_contents.h" @@ -60,9 +61,7 @@ bool WindowCanOpenTabs(Browser* browser) { // Finds an existing Browser compatible with |profile|, making a new one if no // such Browser is located. Browser* GetOrCreateBrowser(Profile* profile) { - Browser* browser = BrowserList::FindBrowserWithType(profile, - Browser::TYPE_NORMAL, - false); + Browser* browser = BrowserList::FindTabbedBrowser(profile, false); return browser ? browser : Browser::Create(profile); } @@ -178,26 +177,32 @@ Browser* GetBrowserForDisposition(browser::NavigateParams* params) { return GetOrCreateBrowser(profile); return NULL; case NEW_POPUP: { - // Make a new popup window. Coerce app-style if |params->browser| or the - // |source| represents an app. - Browser::Type type = Browser::TYPE_POPUP; - if ((params->browser && (params->browser->type() & Browser::TYPE_APP)) || - (params->source_contents && - params->source_contents->extension_tab_helper()->is_app())) { - type = Browser::TYPE_APP_POPUP; - } + // Make a new popup window. if (profile) { - Browser* browser = new Browser(type, profile); - browser->set_override_bounds(params->window_bounds); - browser->InitBrowserWindow(); - return browser; + // Coerce app-style if |params->browser| or |source| represents an app. + std::string app_name; + if (params->browser && !params->browser->app_name().empty()) { + app_name = params->browser->app_name(); + } else if (params->source_contents && + params->source_contents->extension_tab_helper()->is_app()) { + app_name = params->source_contents->extension_tab_helper()-> + extension_app()->id(); + } + if (app_name.empty()) { + Browser::CreateParams browser_params(Browser::TYPE_POPUP, profile); + browser_params.initial_bounds = params->window_bounds; + return Browser::CreateWithParams(browser_params); + } else { + return Browser::CreateForApp(Browser::TYPE_POPUP, app_name, + params->window_bounds.size(), profile); + } } return NULL; } case NEW_WINDOW: // Make a new normal browser window. if (profile) { - Browser* browser = new Browser(Browser::TYPE_NORMAL, profile); + Browser* browser = new Browser(Browser::TYPE_TABBED, profile); browser->InitBrowserWindow(); return browser; } diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc index 1efab77..156db2d 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.cc +++ b/chrome/browser/ui/browser_navigator_browsertest.cc @@ -39,6 +39,14 @@ Browser* BrowserNavigatorTest::CreateEmptyBrowserForType(Browser::Type type, return browser; } +Browser* BrowserNavigatorTest::CreateEmptyBrowserForApp(Browser::Type type, + Profile* profile) { + Browser* browser = Browser::CreateForApp(Browser::TYPE_POPUP, "Test", + gfx::Size(), profile); + browser->AddBlankTab(true); + return browser; +} + TabContentsWrapper* BrowserNavigatorTest::CreateTabContents() { return Browser::TabContentsFactory( browser()->profile(), @@ -215,7 +223,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, // need a different profile, and creating a popup window with an incognito // profile is a quick and dirty way of achieving this. Browser* popup = CreateEmptyBrowserForType( - Browser::TYPE_POPUP, browser()->profile()->GetOffTheRecordProfile()); + Browser::TYPE_POPUP, + browser()->profile()->GetOffTheRecordProfile()); browser::NavigateParams p(MakeNavigateParams(popup)); p.disposition = NEW_FOREGROUND_TAB; browser::Navigate(&p); @@ -236,7 +245,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, EXPECT_EQ(1, browser()->tab_count()); EXPECT_EQ(1, popup->tab_count()); EXPECT_EQ(1, p.browser->tab_count()); - EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type()); + EXPECT_TRUE(p.browser->is_type_tabbed()); } // This test verifies that navigating with WindowOpenDisposition = NEW_POPUP @@ -255,7 +264,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopup) { // TODO(stevenjb): Enable this test. See: crbug.com/79493 EXPECT_TRUE(p.browser->window()->IsActive()); #endif - EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); + EXPECT_TRUE(p.browser->is_type_popup()); + EXPECT_FALSE(p.browser->is_app()); // We should have two windows, the browser() provided by the framework and the // new popup window. @@ -280,7 +290,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { // Navigate() should have opened a new normal popup window. EXPECT_NE(p1.browser, p2.browser); - EXPECT_EQ(Browser::TYPE_POPUP, p2.browser->type()); + EXPECT_TRUE(p2.browser->is_type_popup()); + EXPECT_FALSE(p2.browser->is_app()); // We should have three windows, the browser() provided by the framework, // the first popup window, and the second popup window. @@ -294,8 +305,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromPopup) { // from an app frame results in a new Browser with TYPE_APP_POPUP. IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromAppWindow) { - Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP, - browser()->profile()); + Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, + browser()->profile()); browser::NavigateParams p(MakeNavigateParams(app_browser)); p.disposition = NEW_POPUP; p.window_bounds = gfx::Rect(0, 0, 200, 200); @@ -304,7 +315,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, // Navigate() should have opened a new popup app window. EXPECT_NE(app_browser, p.browser); EXPECT_NE(browser(), p.browser); - EXPECT_EQ(Browser::TYPE_APP_POPUP, p.browser->type()); + EXPECT_TRUE(p.browser->is_type_popup()); + EXPECT_TRUE(p.browser->is_app()); // We should now have three windows, the app window, the app popup it created, // and the original browser() provided by the framework. @@ -318,8 +330,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, // from an app popup results in a new Browser also of TYPE_APP_POPUP. IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewPopupFromAppPopup) { - Browser* app_browser = CreateEmptyBrowserForType(Browser::TYPE_APP, - browser()->profile()); + Browser* app_browser = CreateEmptyBrowserForApp(Browser::TYPE_TABBED, + browser()->profile()); // Open an app popup. browser::NavigateParams p1(MakeNavigateParams(app_browser)); p1.disposition = NEW_POPUP; @@ -334,7 +346,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, // Navigate() should have opened a new popup app window. EXPECT_NE(browser(), p1.browser); EXPECT_NE(p1.browser, p2.browser); - EXPECT_EQ(Browser::TYPE_APP_POPUP, p2.browser->type()); + EXPECT_TRUE(p2.browser->is_type_popup()); + EXPECT_TRUE(p2.browser->is_app()); // We should now have four windows, the app window, the first app popup, // the second app popup, and the original browser() provided by the framework. @@ -381,7 +394,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_NewWindow) { // Navigate() should have opened a new toplevel window. EXPECT_NE(browser(), p.browser); - EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type()); + EXPECT_TRUE(p.browser->is_type_tabbed()); // We should now have two windows, the browser() provided by the framework and // the new normal window. @@ -417,7 +430,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_Incognito) { // reuses an existing incognito window when possible. IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, Disposition_IncognitoRefocus) { Browser* incognito_browser = - CreateEmptyBrowserForType(Browser::TYPE_NORMAL, + CreateEmptyBrowserForType(Browser::TYPE_TABBED, browser()->profile()->GetOffTheRecordProfile()); browser::NavigateParams p(MakeNavigateParams()); p.disposition = OFF_THE_RECORD; @@ -480,7 +493,8 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, DISABLED_TargetContents_Popup) { // Navigate() should have opened a new popup window. EXPECT_NE(browser(), p.browser); - EXPECT_EQ(Browser::TYPE_POPUP, p.browser->type()); + EXPECT_TRUE(p.browser->is_type_popup()); + EXPECT_FALSE(p.browser->is_app()); // The web platform is weird. The window bounds specified in // |p.window_bounds| are used as follows: @@ -576,7 +590,7 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest, NullBrowser_NewWindow) { // Navigate() should have created a new browser. EXPECT_NE(browser(), p.browser); - EXPECT_EQ(Browser::TYPE_NORMAL, p.browser->type()); + EXPECT_TRUE( p.browser->is_type_tabbed()); // We should now have two windows, the browser() provided by the framework and // the new normal window. diff --git a/chrome/browser/ui/browser_navigator_browsertest.h b/chrome/browser/ui/browser_navigator_browsertest.h index 4f9aa3b..31e480b 100644 --- a/chrome/browser/ui/browser_navigator_browsertest.h +++ b/chrome/browser/ui/browser_navigator_browsertest.h @@ -31,6 +31,7 @@ class BrowserNavigatorTest : public InProcessBrowserTest, browser::NavigateParams MakeNavigateParams(Browser* browser) const; Browser* CreateEmptyBrowserForType(Browser::Type type, Profile* profile); + Browser* CreateEmptyBrowserForApp(Browser::Type type, Profile* profile); TabContentsWrapper* CreateTabContents(); diff --git a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm index 73e5167..37a0530 100644 --- a/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm +++ b/chrome/browser/ui/cocoa/applescript/browsercrapplication+applescript_test.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -21,10 +21,10 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) { // Create additional |Browser*| objects of different type. Profile* profile = browser()->profile(); Browser* b1 = Browser::CreateForType(Browser::TYPE_POPUP, profile); - Browser* b2 = Browser::CreateForApp("", gfx::Size(), profile, true); - Browser* b3 = Browser::CreateForApp("", gfx::Size(), profile, false); + Browser* b2 = Browser::CreateForApp(Browser::TYPE_PANEL, "Test", + gfx::Size(), profile); - EXPECT_EQ(4U, [[NSApp appleScriptWindows] count]); + EXPECT_EQ(3U, [[NSApp appleScriptWindows] count]); for (WindowAppleScript* window in [NSApp appleScriptWindows]) { EXPECT_NSEQ(AppleScript::kWindowsProperty, [window containerProperty]); @@ -34,7 +34,6 @@ IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) { // Close the additional browsers. b1->CloseAllTabs(); b2->CloseAllTabs(); - b3->CloseAllTabs(); } // Insert a new window. diff --git a/chrome/browser/ui/cocoa/browser_test_helper.cc b/chrome/browser/ui/cocoa/browser_test_helper.cc index d1a22ca..08cc8c2 100644 --- a/chrome/browser/ui/cocoa/browser_test_helper.cc +++ b/chrome/browser/ui/cocoa/browser_test_helper.cc @@ -20,7 +20,7 @@ BrowserTestHelper::BrowserTestHelper() profile_->CreateAutocompleteClassifier(); profile_->CreateTemplateURLModel(); - browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); } BrowserTestHelper::~BrowserTestHelper() { diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h index cc72002..f390dee 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.h +++ b/chrome/browser/ui/cocoa/browser_window_controller.h @@ -309,11 +309,11 @@ class TabContents; // does, NO otherwise). (E.g., normal browser windows may, pop-ups may not.) - (BOOL)supportsBookmarkBar; -// Called to check if this controller's window is a normal window (e.g., not a +// Called to check if this controller's window is a tabbed window (e.g., not a // pop-up window). Returns YES if it is, NO otherwise. // Note: The |-has...| methods are usually preferred, so this method is largely // deprecated. -- (BOOL)isNormalWindow; +- (BOOL)isTabbedWindow; @end // @interface BrowserWindowController(WindowType) diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm index f94d18c..ec58717 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller.mm @@ -276,8 +276,8 @@ enum { // When we are given x/y coordinates of 0 on a created popup window, assume // none were given by the window.open() command. - if (browser_->type() & Browser::TYPE_POPUP && - windowRect.x() == 0 && windowRect.y() == 0) { + if ((browser_->is_type_popup() || browser_->is_type_panel()) && + windowRect.x() == 0 && windowRect.y() == 0) { gfx::Size size = windowRect.size(); windowRect.set_origin(WindowSizer::GetDefaultPopupOrigin(size)); } @@ -373,7 +373,7 @@ enum { // out, measure the current content area size and grow if needed. The // window has not been placed onscreen yet, so this extra resize will not // cause visible jank. - if (browser_->type() & Browser::TYPE_POPUP) { + if (browser_->is_type_popup() || browser_->is_type_panel()) { CGFloat deltaH = desiredContentRect.height() - NSHeight([[self tabContentArea] frame]); // Do not shrink the window, as that may break minimum size invariants. @@ -1536,11 +1536,10 @@ enum { if (browser_->profile()->IsOffTheRecord()) style |= THEMED_INCOGNITO; - Browser::Type type = browser_->type(); - if (type == Browser::TYPE_POPUP) - style |= THEMED_POPUP; - else if (type == Browser::TYPE_DEVTOOLS) + if (browser_->is_devtools()) style |= THEMED_DEVTOOLS; + if (browser_->is_type_popup()) + style |= THEMED_POPUP; return style; } @@ -2187,8 +2186,8 @@ willAnimateFromState:(bookmarks::VisualState)oldState return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; } -- (BOOL)isNormalWindow { - return browser_->type() == Browser::TYPE_NORMAL; +- (BOOL)isTabbedWindow { + return browser_->is_type_tabbed(); } @end // @implementation BrowserWindowController(WindowType) diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm index 5666f2c..c3cec87 100644 --- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm @@ -112,7 +112,7 @@ TEST_F(BrowserWindowControllerTest, TestNormal) { [controller_ updateBookmarkBarVisibilityWithAnimation:NO]; // Make sure a normal BrowserWindowController is, uh, normal. - EXPECT_TRUE([controller_ isNormalWindow]); + EXPECT_TRUE([controller_ isTabbedWindow]); EXPECT_TRUE([controller_ hasTabStrip]); EXPECT_FALSE([controller_ hasTitleBar]); EXPECT_TRUE([controller_ isBookmarkBarVisible]); @@ -125,7 +125,7 @@ TEST_F(BrowserWindowControllerTest, TestNormal) { BrowserWindowController* controller = static_cast<BrowserWindowController*>([cocoaWindow windowController]); ASSERT_TRUE([controller isKindOfClass:[BrowserWindowController class]]); - EXPECT_FALSE([controller isNormalWindow]); + EXPECT_FALSE([controller isTabbedWindow]); EXPECT_FALSE([controller hasTabStrip]); EXPECT_TRUE([controller hasTitleBar]); EXPECT_FALSE([controller isBookmarkBarVisible]); @@ -154,7 +154,7 @@ TEST_F(BrowserWindowControllerTest, BookmarkBarControllerIndirection) { TEST_F(BrowserWindowControllerTest, TestIncognitoWidthSpace) { scoped_ptr<TestingProfile> incognito_profile(new TestingProfile()); incognito_profile->set_off_the_record(true); - scoped_ptr<Browser> browser(new Browser(Browser::TYPE_NORMAL, + scoped_ptr<Browser> browser(new Browser(Browser::TYPE_TABBED, incognito_profile.get())); controller_.reset([[BrowserWindowController alloc] initWithBrowser:browser.get() diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm index 55f8c6c..fd2464f 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm @@ -73,7 +73,7 @@ class ExtensionPopupControllerTest : public CocoaTest { CocoaTest::SetUp(); profile_.reset(new ExtensionTestingProfile()); profile_->InitExtensionProfile(); - browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); [ExtensionPopupController showURL:GURL("http://google.com") inBrowser:browser_.get() anchoredAt:NSZeroPoint diff --git a/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm b/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm index 8de5ebf..26a730a 100644 --- a/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm +++ b/chrome/browser/ui/cocoa/framed_browser_window_unittest.mm @@ -131,7 +131,7 @@ TEST_F(FramedBrowserWindowTest, WindowWidgetLocation) { isKindOfClass:[BrowserWindowController class]]; [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] hasTabStrip]; [[[controller expect] andReturnValue:OCMOCK_VALUE(no)] hasTitleBar]; - [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isNormalWindow]; + [[[controller expect] andReturnValue:OCMOCK_VALUE(yes)] isTabbedWindow]; [window_ setWindowController:controller]; closeBoxControl = [window_ standardWindowButton:NSWindowCloseButton]; diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm index ae50e5b..46b3f5d 100644 --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm @@ -284,7 +284,7 @@ // drop handler when the type of window is known. BrowserWindowController* windowController = [BrowserWindowController browserWindowControllerForView:self]; - if ([windowController isNormalWindow]) + if ([windowController isTabbedWindow]) dropHandler_.reset([[URLDropTargetHandler alloc] initWithView:self]); } } diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm index 35d8f7d..9d3e144 100644 --- a/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm +++ b/chrome/browser/ui/cocoa/notifications/balloon_controller_unittest.mm @@ -58,7 +58,7 @@ class BalloonControllerTest : public RenderViewHostTestHarness { CocoaTest::BootstrapCocoa(); profile_.reset(new TestingProfile()); profile_->CreateRequestContext(); - browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); collection_.reset(new MockBalloonCollection()); } diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc index 1ef312f..8b10866 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_bar_gtk_unittest.cc @@ -33,7 +33,7 @@ class BookmarkBarGtkUnittest : public ::testing::Test { profile_.reset(new TestingProfile()); profile_->CreateBookmarkModel(true); profile_->BlockUntilBookmarkModelLoaded(); - browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); origin_provider_.reset(new EmptyTabstripOriginProvider); bookmark_bar_.reset(new BookmarkBarGtk(NULL, profile_.get(), browser_.get(), diff --git a/chrome/browser/ui/gtk/browser_titlebar.cc b/chrome/browser/ui/gtk/browser_titlebar.cc index 14e6d4d..3fd1a25 100644 --- a/chrome/browser/ui/gtk/browser_titlebar.cc +++ b/chrome/browser/ui/gtk/browser_titlebar.cc @@ -288,7 +288,7 @@ void BrowserTitlebar::Init() { gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_left_buttons_vbox_, FALSE, FALSE, 0); if (browser_window_->browser()->profile()->IsOffTheRecord() && - browser_window_->browser()->type() == Browser::TYPE_NORMAL) { + browser_window_->browser()->is_type_tabbed()) { titlebar_left_spy_frame_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); gtk_widget_set_no_show_all(titlebar_left_spy_frame_, TRUE); gtk_alignment_set_padding(GTK_ALIGNMENT(titlebar_left_spy_frame_), 0, @@ -317,7 +317,7 @@ void BrowserTitlebar::Init() { // We use an alignment to control the titlebar height. titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); - if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) { + if (browser_window_->browser()->is_type_tabbed()) { gtk_box_pack_start(GTK_BOX(container_hbox_), titlebar_alignment_, TRUE, TRUE, 0); @@ -449,7 +449,7 @@ void BrowserTitlebar::BuildButtons(const std::string& button_string) { // If we are in incognito mode, add the spy guy to either the end of the left // or the beginning of the right depending on which side has fewer buttons. if (browser_window_->browser()->profile()->IsOffTheRecord() && - browser_window_->browser()->type() == Browser::TYPE_NORMAL) { + browser_window_->browser()->is_type_tabbed()) { GtkWidget* spy_guy = gtk_image_new_from_pixbuf(GetOTRAvatar()); gtk_misc_set_alignment(GTK_MISC(spy_guy), 0.0, 1.0); gtk_widget_set_size_request(spy_guy, -1, 0); @@ -549,10 +549,9 @@ void BrowserTitlebar::UpdateTitleAndIcon() { string16 title = browser_window_->browser()->GetWindowTitleForCurrentTab(); gtk_label_set_text(GTK_LABEL(app_mode_title_), UTF16ToUTF8(title).c_str()); - // Note: this isn't browser_window_->browser()->type() & Browser::TYPE_APP - // because we want to exclude Browser::TYPE_APP_POPUP. - if (browser_window_->browser()->type() == Browser::TYPE_APP || - browser_window_->browser()->type() == Browser::TYPE_APP_PANEL) { + // Note: we want to exclude the application popup window. + if (browser_window_->browser()->is_app() && + !browser_window_->browser()->is_type_popup()) { // Update the system app icon. We don't need to update the icon in the top // left of the custom frame, that will get updated when the throbber is // updated. @@ -577,10 +576,9 @@ void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) { } else { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - // Note: this isn't browser_window_->browser()->type() & Browser::TYPE_APP - // because we want to exclude Browser::TYPE_APP_POPUP. - if (browser_window_->browser()->type() == Browser::TYPE_APP || - browser_window_->browser()->type() == Browser::TYPE_APP_PANEL) { + // Note: we want to exclude the application popup window. + if (browser_window_->browser()->is_app() && + !browser_window_->browser()->is_type_popup()) { SkBitmap icon = browser_window_->browser()->GetCurrentPageIcon(); if (icon.empty()) { // Fallback to the Chromium icon if the page has no icon. @@ -600,7 +598,7 @@ void BrowserTitlebar::UpdateThrobber(TabContents* tab_contents) { } void BrowserTitlebar::UpdateTitlebarAlignment() { - if (browser_window_->browser()->type() == Browser::TYPE_NORMAL) { + if (browser_window_->browser()->is_type_tabbed()) { int top_padding = 0; int side_padding = 0; int vertical_offset = kNormalVerticalOffset; diff --git a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc index 18a2b54..863fe3d 100644 --- a/chrome/browser/ui/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/ui/gtk/browser_toolbar_gtk.cc @@ -630,7 +630,7 @@ void BrowserToolbarGtk::NotifyPrefChanged(const std::string* pref) { bool BrowserToolbarGtk::ShouldOnlyShowLocation() const { // If we're a popup window, only show the location bar (omnibox). - return browser_->type() != Browser::TYPE_NORMAL; + return !browser_->is_type_tabbed(); } gboolean BrowserToolbarGtk::OnWrenchMenuButtonExpose(GtkWidget* sender, diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index b79d6ac..8d8f117 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -322,7 +322,7 @@ void BrowserWindowGtk::Init() { gtk_window_group_add_window(gtk_window_group_new(), window_); g_object_unref(gtk_window_get_group(window_)); - if (browser_->type() & Browser::TYPE_APP) { + if (browser_->is_app()) { std::string app_name = browser_->app_name(); if (app_name != DevToolsWindow::kDevToolsApp) { std::string wmclassname = web_app::GetWMClassFromAppName(app_name); @@ -353,7 +353,7 @@ void BrowserWindowGtk::Init() { // popups need the widgets inited before they can set the window size // properly. For other windows, we set the geometry first to prevent resize // flicker. - if (browser_->type() & Browser::TYPE_POPUP) { + if (browser_->is_type_popup() || browser_->is_type_panel()) { InitWidgets(); SetGeometryHints(); } else { @@ -763,7 +763,7 @@ void BrowserWindowGtk::UpdateLoadingAnimations(bool should_animate) { } void BrowserWindowGtk::LoadingAnimationCallback() { - if (browser_->type() == Browser::TYPE_NORMAL) { + if (browser_->is_type_tabbed()) { // Loading animations are shown in the tab for tabbed windows. We check the // browser type instead of calling IsTabStripVisible() because the latter // will return false for fullscreen windows, but we still need to update @@ -1554,11 +1554,12 @@ void BrowserWindowGtk::SetGeometryHints() { // // For popup windows, we assume that if x == y == 0, the opening page // did not specify a position. Let the WM position the popup instead. - bool is_popup = browser_->type() & Browser::TYPE_POPUP; - bool popup_without_position = is_popup && + bool is_popup_or_panel = browser_->is_type_popup() || + browser_->is_type_panel(); + bool popup_without_position = is_popup_or_panel && bounds.x() == 0 && bounds.y() == 0; bool move = browser_->bounds_overridden() && !popup_without_position; - SetBoundsImpl(bounds, !is_popup, move); + SetBoundsImpl(bounds, !is_popup_or_panel, move); } void BrowserWindowGtk::ConnectHandlersToSignals() { @@ -2248,7 +2249,7 @@ bool BrowserWindowGtk::UsingCustomPopupFrame() const { GtkThemeService* theme_provider = GtkThemeService::GetFrom( browser()->profile()); return !theme_provider->UsingNativeTheme() && - browser()->type() & Browser::TYPE_POPUP; + (browser()->is_type_popup() || browser()->is_type_panel()); } bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { @@ -2259,7 +2260,7 @@ bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { // detect the window edge for behavioral purposes. The edge if any is present // only for visual aspects. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) && - browser_->type() == Browser::TYPE_APP_PANEL) + browser_->is_type_panel()) return false; if (IsMaximized() || IsFullscreen()) @@ -2318,13 +2319,11 @@ bool BrowserWindowGtk::GetWindowEdge(int x, int y, GdkWindowEdge* edge) { bool BrowserWindowGtk::UseCustomFrame() { // We always use custom frame for panels. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePanels) && - browser_->type() == Browser::TYPE_APP_PANEL) + browser_->is_type_panel()) return true; // We don't use the custom frame for app mode windows or app window popups. - return use_custom_frame_pref_.GetValue() && - browser_->type() != Browser::TYPE_APP && - browser_->type() != Browser::TYPE_APP_POPUP; + return use_custom_frame_pref_.GetValue() && !browser_->is_app(); } bool BrowserWindowGtk::BoundsMatchMonitorSize() { diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index 547caaa..0776afb 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -1028,10 +1028,8 @@ void GetTextColors(GdkColor* normal_base, GtkWindow* GetLastActiveBrowserWindow() { if (Browser* b = BrowserList::GetLastActive()) { - if (b->type() != Browser::TYPE_NORMAL) { - b = BrowserList::FindBrowserWithType(b->profile(), - Browser::TYPE_NORMAL, - true); + if (!b->is_type_tabbed()) { + b = BrowserList::FindTabbedBrowser(b->profile(), true); } if (b) diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 6941fa1..7e1e60d 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -1154,7 +1154,7 @@ void LocationBarViewGtk::UpdateStarIcon() { } bool LocationBarViewGtk::ShouldOnlyShowLocation() { - return browser_->type() != Browser::TYPE_NORMAL; + return !browser_->is_type_tabbed(); } void LocationBarViewGtk::AdjustChildrenVisibility() { diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc b/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc index 3a5ab1b..3421b7a 100644 --- a/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc +++ b/chrome/browser/ui/panels/panel_browser_window_gtk_browsertest.cc @@ -22,9 +22,11 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserWindowGtkTest, CreatePanel) { PanelManager* panel_manager = PanelManager::GetInstance(); EXPECT_EQ(0, panel_manager->active_count()); // No panels initially. - Browser* panel_browser = Browser::CreateForType(Browser::TYPE_APP_PANEL, - browser()->profile()); - EXPECT_EQ(Browser::TYPE_APP_PANEL, panel_browser->type()); + Browser* panel_browser = Browser::CreateForApp(Browser::TYPE_PANEL, + "PanelTest", + gfx::Size(), + browser()->profile()); + EXPECT_TRUE(panel_browser->is_type_panel()); EXPECT_EQ(1, panel_manager->active_count()); gfx::Rect bounds = panel_browser->window()->GetBounds(); diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc index 58647a5..7bd45b8 100644 --- a/chrome/browser/ui/panels/panel_browsertest.cc +++ b/chrome/browser/ui/panels/panel_browsertest.cc @@ -24,9 +24,9 @@ class PanelBrowserTest : public InProcessBrowserTest { // Panel is now only supported on windows. #if defined(OS_WIN) IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) { - Browser* panel = Browser::CreateForApp("", gfx::Size(), - browser()->profile(), true); - EXPECT_EQ(Browser::TYPE_APP_PANEL, panel->type()); + Browser* panel = Browser::CreateForApp(Browser::TYPE_PANEL, "PanelTest", + gfx::Size(), browser()->profile()); + EXPECT_EQ(Browser::TYPE_PANEL, panel->type()); panel->window()->Show(); panel->window()->Close(); } diff --git a/chrome/browser/ui/tests/browser_uitest.cc b/chrome/browser/ui/tests/browser_uitest.cc index ead99ff..7fae5b6 100644 --- a/chrome/browser/ui/tests/browser_uitest.cc +++ b/chrome/browser/ui/tests/browser_uitest.cc @@ -306,31 +306,6 @@ TEST_F(LaunchBrowserWithNonAsciiUserDatadir, TestNonAsciiUserDataDir) { } #endif // defined(OS_WIN) -class AppModeTest : public UITest { - public: - AppModeTest() { - // Load a local file. - FilePath test_file(test_data_directory_); - test_file = test_file.AppendASCII("title1.html"); - GURL test_file_url(net::FilePathToFileURL(test_file)); - - launch_arguments_.AppendSwitchASCII(switches::kApp, test_file_url.spec()); - } -}; - -TEST_F(AppModeTest, EnableAppModeTest) { - // Test that an application browser window loads correctly. - - // Verify that the window is present. - scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(browser.get()); - - // Verify the browser is an application. - Browser::Type type; - ASSERT_TRUE(browser->GetType(&type)); - EXPECT_EQ(Browser::TYPE_APP, type); -} - // Tests to ensure that the browser continues running in the background after // the last window closes. class RunInBackgroundTest : public UITest { @@ -352,7 +327,7 @@ TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) { ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(0, window_count); ASSERT_TRUE(IsBrowserRunning()); - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true)); ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(1, window_count); } @@ -375,9 +350,36 @@ TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { // Starting a browser window should work just fine. ASSERT_TRUE(IsBrowserRunning()); - ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, true)); + ASSERT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true)); ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); EXPECT_EQ(1, window_count); } } // namespace + +// This test needs to be placed outside the anonymouse namespace because we +// need to access private type of Browser. +class AppModeTest : public UITest { + public: + AppModeTest() { + // Load a local file. + FilePath test_file(test_data_directory_); + test_file = test_file.AppendASCII("title1.html"); + GURL test_file_url(net::FilePathToFileURL(test_file)); + + launch_arguments_.AppendSwitchASCII(switches::kApp, test_file_url.spec()); + } +}; + +TEST_F(AppModeTest, EnableAppModeTest) { + // Test that an application browser window loads correctly. + + // Verify that the window is present. + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser.get()); + + // Verify the browser is in application mode. + bool is_application; + ASSERT_TRUE(browser->IsApplication(&is_application)); + EXPECT_TRUE(is_application); +} diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc index f7dbd76..645d0aa 100644 --- a/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc +++ b/chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc @@ -497,7 +497,7 @@ TEST_F(BackFwdMenuModelTest, EscapeLabel) { TEST_F(BackFwdMenuModelTest, FaviconLoadTest) { profile()->CreateHistoryService(true, false); profile()->CreateFaviconService(); - Browser browser(Browser::TYPE_NORMAL, profile()); + Browser browser(Browser::TYPE_TABBED, profile()); FaviconDelegate favicon_delegate; BackForwardMenuModel back_model( diff --git a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc b/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc index 5223640..de4e0ef 100644 --- a/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc +++ b/chrome/browser/ui/touch/frame/browser_non_client_frame_view_factory_touch.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -11,7 +11,8 @@ namespace browser { BrowserNonClientFrameView* CreateBrowserNonClientFrameView( BrowserFrame* frame, BrowserView* browser_view) { - if (browser_view->IsBrowserTypePopup()) { + if (browser_view->IsBrowserTypePopup() || + browser_view->IsBrowserTypePanel()) { // TODO(anicolao): implement popups for touch NOTIMPLEMENTED(); return NULL; diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc index 2b9ede0..27a52e2 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc @@ -319,10 +319,8 @@ void ShowExtensionInstallDialog( const std::vector<string16>& permissions, ExtensionInstallUI::PromptType type) { #if defined(OS_CHROMEOS) - // Use a normal browser window as parent on ChromeOS. - Browser* browser = BrowserList::FindBrowserWithType(profile, - Browser::TYPE_NORMAL, - true); + // Use a tabbed browser window as parent on ChromeOS. + Browser* browser = BrowserList::FindTabbedBrowser(profile, true); #else Browser* browser = BrowserList::GetLastActiveWithProfile(profile); #endif diff --git a/chrome/browser/ui/views/file_manager_dialogs.cc b/chrome/browser/ui/views/file_manager_dialogs.cc index acea5c9..1d3c076 100644 --- a/chrome/browser/ui/views/file_manager_dialogs.cc +++ b/chrome/browser/ui/views/file_manager_dialogs.cc @@ -176,7 +176,7 @@ void FileManagerDialog::SelectFileImpl( if (browser_mode_) { Browser* browser = BrowserList::GetLastActive(); if (browser) { - DCHECK_EQ(browser->type(), Browser::TYPE_NORMAL); + DCHECK_EQ(browser->type(), Browser::TYPE_TABBED); CreateHtmlDialogView(browser->profile(), params); return; } diff --git a/chrome/browser/ui/views/frame/browser_frame_win.cc b/chrome/browser/ui/views/frame/browser_frame_win.cc index e537d99..49e14db 100644 --- a/chrome/browser/ui/views/frame/browser_frame_win.cc +++ b/chrome/browser/ui/views/frame/browser_frame_win.cc @@ -207,7 +207,7 @@ ui::ThemeProvider* BrowserFrameWin::GetThemeProviderForFrame() const { bool BrowserFrameWin::AlwaysUseNativeFrame() const { // App panel windows draw their own frame. - if (browser_view_->IsBrowserTypePanel()) + if (browser_view_->IsBrowserTypePanel() && browser_view_->IsBrowserTypeApp()) return false; // We don't theme popup or app windows, so regardless of whether or not a diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc index 93b2c8c..cda4b37 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_factory_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -12,7 +12,7 @@ namespace browser { BrowserNonClientFrameView* CreateBrowserNonClientFrameView( BrowserFrame* frame, BrowserView* browser_view) { - if (browser_view->IsBrowserTypePopup()) + if (browser_view->IsBrowserTypePopup() || browser_view->IsBrowserTypePanel()) return new PopupNonClientFrameView(); else return new OpaqueBrowserFrameView(frame, browser_view); diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index 263d218..f95a326 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -143,10 +143,10 @@ const char BrowserView::kViewClassName[] = "browser/ui/views/BrowserView"; // normal browser. static gfx::NativeWindow GetNormalBrowserWindowForBrowser(Browser* browser, Profile* profile) { - if (browser->type() != Browser::TYPE_NORMAL) { - Browser* normal_browser = BrowserList::FindBrowserWithType( + if (!browser->is_type_tabbed()) { + Browser* normal_browser = BrowserList::FindTabbedBrowser( profile ? profile : browser->profile(), - Browser::TYPE_NORMAL, true); + true); if (normal_browser && normal_browser->window()) return normal_browser->window()->GetNativeHandle(); } @@ -1440,7 +1440,7 @@ bool BrowserView::ShouldShowWindowTitle() const { } SkBitmap BrowserView::GetWindowAppIcon() { - if (browser_->type() & Browser::TYPE_APP) { + if (browser_->is_app()) { TabContentsWrapper* contents = browser_->GetSelectedTabContentsWrapper(); if (contents && contents->extension_tab_helper()->GetExtensionAppIcon()) return *contents->extension_tab_helper()->GetExtensionAppIcon(); @@ -1450,7 +1450,7 @@ SkBitmap BrowserView::GetWindowAppIcon() { } SkBitmap BrowserView::GetWindowIcon() { - if (browser_->type() & Browser::TYPE_APP) + if (browser_->is_app()) return browser_->GetCurrentPageIcon(); return SkBitmap(); } @@ -1488,7 +1488,7 @@ void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const { *bounds = browser_->GetSavedWindowBounds(); - if (browser_->type() & Browser::TYPE_POPUP) { + if (browser_->is_type_popup() || browser_->is_type_panel()) { // We are a popup window. The value passed in |bounds| represents two // pieces of information: // - the position of the window, in screen coordinates (outer position). @@ -1854,7 +1854,7 @@ void BrowserView::LoadingAnimationCallback() { now - last_animation_time_); } last_animation_time_ = now; - if (browser_->type() == Browser::TYPE_NORMAL) { + if (browser_->is_type_tabbed()) { // Loading animations are shown in the tab for tabbed windows. We check the // browser type instead of calling IsTabStripVisible() because the latter // will return false for fullscreen windows, but we still need to update @@ -1881,7 +1881,7 @@ void BrowserView::InitSystemMenu() { if (IsBrowserTypeNormal()) BuildSystemMenuForBrowserWindow(); else - BuildSystemMenuForAppOrPopupWindow(browser_->type() == Browser::TYPE_APP); + BuildSystemMenuForAppOrPopupWindow(); system_menu_.reset( new views::NativeMenuWin(system_menu_contents_.get(), frame_->GetWindow()->GetNativeWindow())); @@ -2247,8 +2247,8 @@ void BrowserView::BuildSystemMenuForBrowserWindow() { // since it already has menus (Page, Chrome). } -void BrowserView::BuildSystemMenuForAppOrPopupWindow(bool is_app) { - if (is_app) { +void BrowserView::BuildSystemMenuForAppOrPopupWindow() { + if (browser_->is_app()) { system_menu_contents_->AddSeparator(); system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); @@ -2268,7 +2268,7 @@ void BrowserView::BuildSystemMenuForAppOrPopupWindow(bool is_app) { system_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); system_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT); system_menu_contents_->AddSeparator(); - if (is_app) { + if (browser_->is_app()) { system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_APP_MENU_NEW_WEB_PAGE); } else { diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h index 0184d14..c80cee6 100644 --- a/chrome/browser/ui/views/frame/browser_view.h +++ b/chrome/browser/ui/views/frame/browser_view.h @@ -185,21 +185,27 @@ class BrowserView : public BrowserBubbleHost, #endif // Returns true if the Browser object associated with this BrowserView is a - // normal-type window (i.e. a browser window, not an app or popup). + // tabbed-type window (i.e. a browser window, not an app or popup). bool IsBrowserTypeNormal() const { - return browser_->type() == Browser::TYPE_NORMAL; + return browser_->is_type_tabbed(); } // Returns true if the Browser object associated with this BrowserView is a - // app panel window. + // panel window. bool IsBrowserTypePanel() const { - return browser_->type() == Browser::TYPE_APP_PANEL; + return browser_->is_type_panel(); } // Returns true if the Browser object associated with this BrowserView is a // popup window. bool IsBrowserTypePopup() const { - return (browser_->type() & Browser::TYPE_POPUP) != 0; + return browser_->is_type_popup(); + } + + // Returns true if the Browser object associated with this BrowserView + // represents an app. + bool IsBrowserTypeApp() const { + return browser_->is_app(); } // Register preferences specific to this view. @@ -492,7 +498,7 @@ class BrowserView : public BrowserBubbleHost, #if defined(OS_WIN) // Builds the correct menu for when we have minimal chrome. void BuildSystemMenuForBrowserWindow(); - void BuildSystemMenuForAppOrPopupWindow(bool is_app); + void BuildSystemMenuForAppOrPopupWindow(); #endif // Retrieves the command id for the specified Windows app command. diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index 663dc7e..69f3565 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -1069,7 +1069,7 @@ void OpaqueBrowserFrameView::LayoutWindowControls() { restore_button_->SetVisible(false); maximize_button_->SetVisible(false); - if (browser_view_->browser()->type() == Browser::TYPE_DEVTOOLS) { + if (browser_view_->browser()->is_devtools()) { close_button_->SetVisible(true); minimize_button_->SetBounds(close_button_->bounds().x(), 0, 0, 0); } else { diff --git a/chrome/browser/ui/webui/active_downloads_ui.cc b/chrome/browser/ui/webui/active_downloads_ui.cc index 35fcf0e..9bd9ddd 100644 --- a/chrome/browser/ui/webui/active_downloads_ui.cc +++ b/chrome/browser/ui/webui/active_downloads_ui.cc @@ -61,6 +61,7 @@ static const int kPopupHeight = 36 * 2 + 29; static const char kPropertyPath[] = "path"; static const char kPropertyTitle[] = "title"; static const char kPropertyDirectory[] = "isDirectory"; +static const char kActiveDownloadAppName[] = "active-downloads"; class ActiveDownloadsUIHTMLSource : public ChromeURLDataManager::DataSource { public: @@ -282,7 +283,8 @@ void ActiveDownloadsHandler::OpenNewPopupWindow(const ListValue* args) { void ActiveDownloadsHandler::OpenNewWindow(const ListValue* args, bool popup) { std::string url = UTF16ToUTF8(ExtractStringValue(args)); Browser* browser = popup ? - Browser::CreateForType(Browser::TYPE_APP_PANEL, profile_) : + Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName, + gfx::Size(), profile_) : BrowserList::GetLastActive(); browser::NavigateParams params(browser, GURL(url), PageTransition::LINK); params.disposition = NEW_FOREGROUND_TAB; @@ -386,7 +388,8 @@ Browser* ActiveDownloadsUI::OpenPopup(Profile* profile) { // Create new browser if no matching pop up is found. if (browser == NULL) { - browser = Browser::CreateForType(Browser::TYPE_APP_PANEL, profile); + browser = Browser::CreateForApp(Browser::TYPE_PANEL, kActiveDownloadAppName, + gfx::Size(), profile); browser::NavigateParams params( browser, @@ -412,7 +415,7 @@ Browser* ActiveDownloadsUI::GetPopup(Profile* profile) { for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { - if (((*it)->type() == Browser::TYPE_APP_PANEL)) { + if ((*it)->is_type_panel() && (*it)->is_app()) { TabContents* tab_contents = (*it)->GetSelectedTabContents(); DCHECK(tab_contents); if (!tab_contents) diff --git a/chrome/browser/ui/webui/mediaplayer_browsertest.cc b/chrome/browser/ui/webui/mediaplayer_browsertest.cc index 0d5fb19..2bd67e4 100644 --- a/chrome/browser/ui/webui/mediaplayer_browsertest.cc +++ b/chrome/browser/ui/webui/mediaplayer_browsertest.cc @@ -28,7 +28,7 @@ class MediaPlayerBrowserTest : public InProcessBrowserTest { bool IsPlayerVisible() { for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { - if ((*it)->type() == Browser::TYPE_APP_PANEL) { + if ((*it)->is_type_panel() && (*it)->is_app()) { const GURL& url = (*it)->GetTabContentsAt((*it)->active_index())->GetURL(); @@ -44,7 +44,7 @@ class MediaPlayerBrowserTest : public InProcessBrowserTest { bool IsPlaylistVisible() { for (BrowserList::const_iterator it = BrowserList::begin(); it != BrowserList::end(); ++it) { - if ((*it)->type() == Browser::TYPE_APP_PANEL) { + if ((*it)->is_type_panel() && (*it)->is_app()) { const GURL& url = (*it)->GetTabContentsAt((*it)->active_index())->GetURL(); diff --git a/chrome/browser/ui/webui/mediaplayer_ui.cc b/chrome/browser/ui/webui/mediaplayer_ui.cc index c6bfaa6..0f7523c 100644 --- a/chrome/browser/ui/webui/mediaplayer_ui.cc +++ b/chrome/browser/ui/webui/mediaplayer_ui.cc @@ -55,6 +55,7 @@ static const char kPropertyError[] = "error"; static const char* kMediaplayerURL = "chrome://mediaplayer"; static const char* kMediaplayerPlaylistURL = "chrome://mediaplayer#playlist"; +static const char* kMediaPlayerAppName = "mediaplayer"; static const int kPopupLeft = 0; static const int kPopupTop = 0; static const int kPopupWidth = 350; @@ -504,8 +505,10 @@ void MediaPlayer::RemoveHandler(MediaplayerHandler* handler) { void MediaPlayer::PopupPlaylist(Browser* creator) { Profile* profile = BrowserList::GetLastActive()->profile(); - playlist_browser_ = Browser::CreateForType(Browser::TYPE_APP_PANEL, - profile); + playlist_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, + kMediaPlayerAppName, + gfx::Size(), + profile); playlist_browser_->AddSelectedTabWithURL(GURL(kMediaplayerPlaylistURL), PageTransition::LINK); playlist_browser_->window()->SetBounds(gfx::Rect(kPopupLeft, @@ -524,8 +527,10 @@ void MediaPlayer::PopupMediaPlayer(Browser* creator) { return; } Profile* profile = BrowserList::GetLastActive()->profile(); - mediaplayer_browser_ = Browser::CreateForType(Browser::TYPE_APP_PANEL, - profile); + mediaplayer_browser_ = Browser::CreateForApp(Browser::TYPE_PANEL, + kMediaPlayerAppName, + gfx::Size(), + profile); #if defined(OS_CHROMEOS) // Since we are on chromeos, popups should be a PanelBrowserView, // so we can just cast it. diff --git a/chrome/browser/ui/window_sizer.cc b/chrome/browser/ui/window_sizer.cc index e5663d2..2c46c0c 100644 --- a/chrome/browser/ui/window_sizer.cc +++ b/chrome/browser/ui/window_sizer.cc @@ -83,7 +83,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider { BrowserList::const_reverse_iterator end = BrowserList::end_last_active(); for (; (it != end); ++it) { Browser* last_active = *it; - if (last_active && last_active->type() == Browser::TYPE_NORMAL) { + if (last_active && last_active->is_type_tabbed()) { window = last_active->window(); DCHECK(window); break; diff --git a/chrome/common/automation_messages_internal.h b/chrome/common/automation_messages_internal.h index 694314d..678a68e 100644 --- a/chrome/common/automation_messages_internal.h +++ b/chrome/common/automation_messages_internal.h @@ -876,9 +876,9 @@ IPC_SYNC_MESSAGE_CONTROL1_1(AutomationMsg_TabIndex, int) // This message requests the handle (int64 app-unique identifier) of -// a valid normal browser window, i.e. normal type and non-incognito mode. +// a valid tabbed browser window, i.e. normal type and non-incognito mode. // On error, the returned handle value is 0. -IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_FindNormalBrowserWindow, +IPC_SYNC_MESSAGE_CONTROL0_1(AutomationMsg_FindTabbedBrowserWindow, int) // This message requests the number of normal browser windows, i.e. normal @@ -1470,6 +1470,12 @@ IPC_SYNC_MESSAGE_CONTROL1_2(AutomationMsg_GetParentBrowserOfTab, IPC_MESSAGE_ROUTED1(AutomationMsg_MoveWindow, gfx::Rect /* window position and dimentions */) +// Is the browser in application mode? +IPC_SYNC_MESSAGE_CONTROL1_2(AutomationMsg_IsBrowserInApplicationMode, + int /* browser_handle */, + bool /* is_application */, + bool /* success */) + // Renderer -> browser messages. // Sent when the renderer has scheduled a client redirect to occur. diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc index e282256..dfb69bd 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -68,7 +68,7 @@ bool AutomatedUITestBase::CloseActiveWindow() { LogErrorMessage("Application closed unexpectedly."); return false; } - scoped_refptr<BrowserProxy> browser(automation()->FindNormalBrowserWindow()); + scoped_refptr<BrowserProxy> browser(automation()->FindTabbedBrowserWindow()); if (!browser.get()) { LogErrorMessage("Can't find browser window."); return false; @@ -242,7 +242,7 @@ bool AutomatedUITestBase::Home() { bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( scoped_refptr<BrowserProxy>* previous_browser) { - if (!automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, + if (!automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, true /* SW_SHOWNORMAL */)) { LogWarningMessage("failed_to_open_new_browser_window"); return false; diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index dc00fbe..5c12a70 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -416,9 +416,9 @@ bool AutomationProxy::GetBrowserLocale(string16* locale) { return !locale->empty(); } -scoped_refptr<BrowserProxy> AutomationProxy::FindNormalBrowserWindow() { +scoped_refptr<BrowserProxy> AutomationProxy::FindTabbedBrowserWindow() { int handle = 0; - if (!Send(new AutomationMsg_FindNormalBrowserWindow(&handle))) + if (!Send(new AutomationMsg_FindTabbedBrowserWindow(&handle))) return NULL; return ProxyObjectFromHandle<BrowserProxy>(handle); diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index e273e4b..0390f03 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -154,10 +154,10 @@ class AutomationProxy : public IPC::Channel::Listener, scoped_refptr<BrowserProxy> GetBrowserWindow(int window_index); // Finds the first browser window that is not incognito mode and of type - // TYPE_NORMAL, and returns its corresponding BrowserProxy, transferring + // TYPE_TABBED, and returns its corresponding BrowserProxy, transferring // ownership of the pointer to the caller. // On failure, returns NULL. - scoped_refptr<BrowserProxy> FindNormalBrowserWindow(); + scoped_refptr<BrowserProxy> FindTabbedBrowserWindow(); // Returns the BrowserProxy for the browser window which was last active, // transferring ownership of the pointer to the caller. diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 1db1dd2..9030f32 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -167,6 +167,21 @@ bool BrowserProxy::GetType(Browser::Type* type) const { return true; } +bool BrowserProxy::IsApplication(bool* is_application) { + DCHECK(is_application); + + if (!is_valid()) + return false; + + bool success = false; + if (!sender_->Send(new AutomationMsg_IsBrowserInApplicationMode( + handle_, is_application, &success))) { + return false; + } + + return success; +} + bool BrowserProxy::ApplyAccelerator(int id) { return RunCommandAsync(id); } diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index 9e82fa4..ab198bc 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -64,6 +64,10 @@ class BrowserProxy : public AutomationResourceProxy { // successful. bool GetType(Browser::Type* type) const WARN_UNUSED_RESULT; + // Sets |is_application| to whether the browser is currently in application + // mode. + bool IsApplication(bool* is_application) WARN_UNUSED_RESULT; + // Returns the TabProxy for the tab at the given index, transferring // ownership of the pointer to the caller. On failure, returns NULL. // diff --git a/chrome/test/browser_with_test_window_test.cc b/chrome/test/browser_with_test_window_test.cc index c945bf0..9cdbd40 100644 --- a/chrome/test/browser_with_test_window_test.cc +++ b/chrome/test/browser_with_test_window_test.cc @@ -32,7 +32,7 @@ void BrowserWithTestWindowTest::SetUp() { TestingBrowserProcessTest::SetUp(); profile_.reset(CreateProfile()); - browser_.reset(new Browser(Browser::TYPE_NORMAL, profile())); + browser_.reset(new Browser(Browser::TYPE_TABBED, profile())); window_.reset(new TestBrowserWindow(browser())); browser_->set_window(window_.get()); } diff --git a/chrome/test/live_sync/live_sessions_sync_test.cc b/chrome/test/live_sync/live_sessions_sync_test.cc index 0168e3d..ed9c879 100644 --- a/chrome/test/live_sync/live_sessions_sync_test.cc +++ b/chrome/test/live_sync/live_sessions_sync_test.cc @@ -33,7 +33,7 @@ TestSessionService::TestSessionService(SessionService* service, void TestSessionService::SetUp() { ASSERT_TRUE(service()) << "SetUp() called without setting SessionService"; ASSERT_TRUE(profile_); - service()->SetWindowType(window_id_, Browser::TYPE_NORMAL); + service()->SetWindowType(window_id_, Browser::TYPE_TABBED); service()->SetWindowBounds(window_id_, window_bounds_, false); } diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index 29e7d27..1a64cdd 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -188,7 +188,7 @@ class MemoryTest : public UIPerfTest { int window_count; EXPECT_TRUE(automation()->GetBrowserWindowCount(&window_count)); - EXPECT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, + EXPECT_TRUE(automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, show_window_)); int expected_window_count = window_count + 1; EXPECT_TRUE(automation()->WaitForWindowCountToBecome( diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc index 0a6c484..95ac964 100644 --- a/chrome/test/pyautolib/pyautolib.cc +++ b/chrome/test/pyautolib/pyautolib.cc @@ -183,7 +183,7 @@ FilePath PyUITestBase::GetDownloadDirectory() { } bool PyUITestBase::OpenNewBrowserWindow(bool show) { - return automation()->OpenNewBrowserWindow(Browser::TYPE_NORMAL, show); + return automation()->OpenNewBrowserWindow(Browser::TYPE_TABBED, show); } bool PyUITestBase::CloseBrowserWindow(int window_index) { diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 6ab4429..6e777c4 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -472,8 +472,8 @@ Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) { void OpenURLOffTheRecord(Profile* profile, const GURL& url) { Browser::OpenURLOffTheRecord(profile, url); - Browser* browser = BrowserList::FindBrowserWithType( - profile->GetOffTheRecordProfile(), Browser::TYPE_NORMAL, false); + Browser* browser = BrowserList::FindTabbedBrowser( + profile->GetOffTheRecordProfile(), false); WaitForNavigations(&browser->GetSelectedTabContents()->controller(), 1); } |