diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 06:36:25 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 06:36:25 +0000 |
commit | 7c9f703035c1487dd76fbd9472ecdfc2e005b237 (patch) | |
tree | 026da0467831f20419c0f4f8bb55012ab05a42d1 | |
parent | 7593a062b567d95aaa556fcbb30f6ec456b352fb (diff) | |
download | chromium_src-7c9f703035c1487dd76fbd9472ecdfc2e005b237.zip chromium_src-7c9f703035c1487dd76fbd9472ecdfc2e005b237.tar.gz chromium_src-7c9f703035c1487dd76fbd9472ecdfc2e005b237.tar.bz2 |
When launcing apps from launcher, use pinned tabs, not app tabs.
Theory: pinned tabs are actually pretty ok, once the url
schenanigans are disabled and they don't have big ugly icons,
especially if we were to add something to the right-click menu
of the apps in the launcher like 'launch in a normal tab'.
Review URL: http://codereview.chromium.org/3152040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57146 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser.cc | 14 | ||||
-rw-r--r-- | chrome/browser/browser_browsertest.cc | 58 |
2 files changed, 6 insertions, 66 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 3811898..a435baf 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -626,17 +626,11 @@ TabContents* Browser::OpenApplicationTab(Profile* profile, // TODO(erikkay): This doesn't seem like the right transition in all cases. PageTransition::Type transition = PageTransition::START_PAGE; - GURL url = extension->GetFullLaunchURL(); - TabContents* tab_contents = - local_browser->CreateTabContentsForURL(url, GURL(), profile, - transition, false, NULL); - tab_contents->SetExtensionApp(extension); - local_browser->AddTab(tab_contents, transition); - if (browser) - *browser = local_browser; - - return tab_contents; + return local_browser->AddTabWithURL( + extension->GetFullLaunchURL(), GURL(), transition, -1, + TabStripModel::ADD_PINNED | TabStripModel::ADD_SELECTED, + NULL, "", browser); } // static diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index dbc3b6e..e6f2e0d 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -696,8 +696,6 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { int app_tab_index = browser()->selected_index(); ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; - ASSERT_EQ(browser()->GetTabContentsAt(0), - Browser::FindAppTab(browser(), extension_app_)); // Open the same app. The existing tab should stay focused. tab = Browser::OpenApplication(profile_, extension_app_->id()); @@ -705,37 +703,19 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { // No need to wait for navigation, because the tab already exists, // and no navigation should take place. ASSERT_TRUE(tab != NULL); - ASSERT_EQ(2, browser()->tab_count()); - ASSERT_EQ(app_tab_index, browser()->selected_index()); - - // Focus the other tab, and reopen the app. The existing tab should - // be refocused. - browser()->SelectTabContentsAt(1, false); - Browser::OpenApplication(profile_, extension_app_->id()); - - tab = Browser::OpenApplication(profile_, extension_app_->id()); - ASSERT_TRUE(tab != NULL); - - ASSERT_EQ(2, browser()->tab_count()); - ASSERT_EQ(app_tab_index, browser()->selected_index()); + ASSERT_EQ(3, browser()->tab_count()); + ASSERT_EQ(app_tab_index + 1, browser()->selected_index()); // Open a second browser window, and open the app in a tab. Browser* second_browser = CreateBrowser(profile_); second_browser->window()->Show(); - ASSERT_EQ(NULL, Browser::FindAppTab(second_browser, extension_app_)) << - "Browser::FindAppTab() should not find an app tab in the second " << - "window, beacuse it has not been added yet."; - Browser::OpenApplication(profile_, extension_app_, Extension::LAUNCH_TAB); ASSERT_EQ(2, second_browser->tab_count()) << "Expect the app to open in a tab under |second_browser|."; int second_app_tab_index = second_browser->selected_index(); ASSERT_EQ(0, second_app_tab_index) << "Second app tab should be the left most tab."; - ASSERT_EQ(second_browser->GetTabContentsAt(0), - Browser::FindAppTab(second_browser, extension_app_)) << - "Browser::FindAppTab() should look at the focused window."; } // Test that launching an app refocuses a panel running the app. @@ -859,40 +839,6 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) { ASSERT_EQ(app_panel, BrowserList::GetLastActive()); } -// Test that if multiple tabs host an app, and that app is opened, -// the tab in the current window gets focus. -IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_TabInFocusedWindow) { - SetUpExtensionApp(); - - ASSERT_EQ(1, browser()->tab_count()); - - Browser::OpenApplicationTab(profile_, extension_app_, NULL); - ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); - ASSERT_EQ(2, browser()->tab_count()); - int app_tab_index = browser()->selected_index(); - ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab."; - - // Open a new browser window, add an app tab. - Browser* extra_browser = CreateBrowser(profile_); - ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); - - Browser::OpenApplicationTab(profile_, extension_app_, NULL); - ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(extra_browser)); - ASSERT_EQ(2, extra_browser->tab_count()); - app_tab_index = extra_browser->selected_index(); - ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab"; - - // Open the app. Focus should move to the panel. - Browser::OpenApplication(profile_, extension_app_->id()); - ASSERT_EQ(extra_browser, BrowserList::GetLastActive()); - ASSERT_EQ(2, extra_browser->tab_count()); - - browser()->window()->Show(); - Browser::OpenApplication(profile_, extension_app_->id()); - ASSERT_EQ(browser(), BrowserList::GetLastActive()); - ASSERT_EQ(2, browser()->tab_count()); -} - // TODO(ben): this test was never enabled. It has bit-rotted since being added. // It originally lived in browser_unittest.cc, but has been moved here to make // room for real browser unit tests. |