diff options
-rw-r--r-- | chrome/browser/browser_browsertest.cc | 49 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 12 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 1 |
3 files changed, 56 insertions, 6 deletions
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index 4b8e135..62c22d8 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -370,6 +370,55 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, CommandCreateAppShortcutInvalid) { ui_test_utils::NavigateToURL(browser(), blank_url); EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_CREATE_SHORTCUTS)); } + +// Change a tab into an application window. +IN_PROC_BROWSER_TEST_F(BrowserTest, ConvertTabToAppShortcut) { + ASSERT_TRUE(test_server()->Start()); + GURL http_url(test_server()->GetURL("")); + ASSERT_TRUE(http_url.SchemeIs(chrome::kHttpScheme)); + + ASSERT_EQ(1, browser()->tab_count()); + TabContents* initial_tab = browser()->GetTabContentsAt(0); + TabContents* app_tab = browser()->AddSelectedTabWithURL( + http_url, PageTransition::TYPED)->tab_contents(); + ASSERT_EQ(2, browser()->tab_count()); + ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); + + // Normal tabs should accept load drops. + EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); + EXPECT_TRUE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); + + // Turn |app_tab| into a tab in an app panel. + browser()->ConvertContentsToApplication(app_tab); + + // The launch should have created a new browser. + ASSERT_EQ(2u, BrowserList::GetBrowserCount(browser()->profile())); + + // Find the new browser. + Browser* app_browser = NULL; + for (BrowserList::const_iterator i = BrowserList::begin(); + i != BrowserList::end() && !app_browser; ++i) { + if (*i != browser()) + app_browser = *i; + } + ASSERT_TRUE(app_browser); + + // Check that the tab contents is in the new browser, and not in the old. + ASSERT_EQ(1, browser()->tab_count()); + ASSERT_EQ(initial_tab, browser()->GetTabContentsAt(0)); + + // Check that the appliaction browser has a single tab, and that tab contains + // the content that we app-ified. + ASSERT_EQ(1, app_browser->tab_count()); + ASSERT_EQ(app_tab, app_browser->GetTabContentsAt(0)); + + // Normal tabs should accept load drops. + EXPECT_TRUE(initial_tab->GetMutableRendererPrefs()->can_accept_load_drops); + + // The tab in an aopp window should not. + EXPECT_FALSE(app_tab->GetMutableRendererPrefs()->can_accept_load_drops); +} + #endif // !defined(OS_MACOSX) // Test RenderView correctly send back favicon url for web page that redirects diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 75e2e04..6f1e1e9 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2951,13 +2951,13 @@ void Browser::ConvertContentsToApplication(TabContents* contents) { RegisterAppPrefs(app_name); DetachContents(contents); - Browser* browser = Browser::CreateForApp(app_name, NULL, profile_, false); + Browser* app_browser = Browser::CreateForApp(app_name, NULL, profile_, false); TabContentsWrapper* wrapper = new TabContentsWrapper(contents); - browser->tabstrip_model()->AppendTabContents(wrapper, true); - TabContents* tab_contents = GetSelectedTabContents(); - tab_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; - tab_contents->render_view_host()->SyncRendererPrefs(); - browser->window()->Show(); + app_browser->tabstrip_model()->AppendTabContents(wrapper, true); + + contents->GetMutableRendererPrefs()->can_accept_load_drops = false; + contents->render_view_host()->SyncRendererPrefs(); + app_browser->window()->Show(); } bool Browser::ShouldDisplayURLField() { diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 77c2146..4331770 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -700,6 +700,7 @@ class Browser : public TabHandlerDelegate, private: FRIEND_TEST_ALL_PREFIXES(BrowserTest, NoTabsInPopups); + FRIEND_TEST_ALL_PREFIXES(BrowserTest, ConvertTabToAppShortcut); // Used to describe why a tab is being detached. This is used by // TabDetachedAtImpl. |