summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser.cc58
-rw-r--r--chrome/browser/browser.h22
-rw-r--r--chrome/browser/browser_browsertest.cc3
-rw-r--r--chrome/browser/browser_init_browsertest.cc3
-rw-r--r--chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc3
-rw-r--r--chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm2
-rw-r--r--chrome/browser/cocoa/browser_window_controller_unittest.mm3
-rw-r--r--chrome/browser/extensions/extension_host.cc56
-rw-r--r--chrome/browser/extensions/window_open_apitest.cc3
-rw-r--r--chrome/browser/external_tab_container_win.cc4
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc3
-rw-r--r--chrome/test/in_process_browser_test.cc2
12 files changed, 76 insertions, 86 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index ed75b91..4d318a0 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -314,8 +314,15 @@ Browser* Browser::Create(Profile* profile) {
}
// static
-Browser* Browser::CreateForPopup(Profile* profile) {
- Browser* browser = CreateForType(TYPE_POPUP, profile);
+Browser* Browser::CreateForPopup(Type type,
+ Profile* profile,
+ TabContents* new_contents,
+ const gfx::Rect& initial_bounds) {
+ DCHECK(type & TYPE_POPUP);
+ Browser* browser = new Browser(type, profile);
+ browser->set_override_bounds(initial_bounds);
+ browser->CreateBrowserWindow();
+ browser->tabstrip_model()->AppendTabContents(new_contents, true);
return browser;
}
@@ -2411,7 +2418,7 @@ void Browser::DuplicateContentsAt(int index) {
browser = Browser::CreateForApp(app_name_, extension_app_, profile_,
false);
} else if (type_ == TYPE_POPUP) {
- browser = Browser::CreateForPopup(profile_);
+ browser = Browser::CreateForType(TYPE_POPUP, profile_);
}
// Preserve the size of the original window. The new window has already
@@ -2730,7 +2737,19 @@ void Browser::AddNewContents(TabContents* source,
}
if (disposition == NEW_POPUP) {
- BuildPopupWindow(source, new_contents, initial_pos);
+ Type browser_type;
+ if ((type_ & TYPE_APP) || (source && source->is_app())) {
+ // New app popup, or an app is creating a popup.
+ browser_type = TYPE_APP_POPUP;
+ } else {
+ browser_type = TYPE_POPUP;
+ }
+ Browser* browser = Browser::CreateForPopup(browser_type,
+ profile_,
+ new_contents,
+ initial_pos);
+ browser->window()->Show();
+
} else if (disposition == NEW_WINDOW) {
Browser* browser = Browser::Create(profile_);
browser->AddNewContents(source, new_contents, NEW_FOREGROUND_TAB,
@@ -4022,37 +4041,6 @@ void Browser::OpenURLAtIndex(TabContents* source,
}
}
-void Browser::BuildPopupWindow(TabContents* source,
- TabContents* new_contents,
- const gfx::Rect& initial_pos) {
- Browser::Type browser_type;
- if ((type_ & TYPE_APP) || // New app popup
- (source && source->is_app())) // App is creating a popup
- browser_type = TYPE_APP_POPUP;
- else
- browser_type = TYPE_POPUP;
- BuildPopupWindowHelper(source, new_contents, initial_pos,
- browser_type,
- profile_, false);
-}
-
-void Browser::BuildPopupWindowHelper(TabContents* source,
- TabContents* new_contents,
- const gfx::Rect& initial_pos,
- Browser::Type browser_type,
- Profile* profile,
- bool start_restored) {
- Browser* browser = new Browser(browser_type, profile);
- browser->set_override_bounds(initial_pos);
-
- if (start_restored)
- browser->set_maximized_state(MAXIMIZED_STATE_UNMAXIMIZED);
-
- browser->CreateBrowserWindow();
- browser->tabstrip_model()->AppendTabContents(new_contents, true);
- browser->window()->Show();
-}
-
GURL Browser::GetHomePage() const {
// --homepage overrides any preferences.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index b1cdce2..6b894b2 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -131,8 +131,11 @@ class Browser : public TabHandlerDelegate,
// window is created by this function call.
static Browser* Create(Profile* profile);
- // Like Create, but creates a tabstrip-less popup window.
- static Browser* CreateForPopup(Profile* profile);
+ // Like Create, but creates a browser of the specified (popup) type, with the
+ // specified contents, in a popup window of the specified size/position.
+ static Browser* CreateForPopup(Type type, Profile* profile,
+ TabContents* new_contents,
+ const gfx::Rect& initial_bounds);
// Like Create, but creates a browser of the specified type.
static Browser* CreateForType(Type type, Profile* profile);
@@ -603,14 +606,6 @@ class Browser : public TabHandlerDelegate,
// Creates a new Browser if none are available.
static Browser* GetOrCreateTabbedBrowser(Profile* profile);
- // Helper function to create a new popup window.
- static void BuildPopupWindowHelper(TabContents* source,
- TabContents* new_contents,
- const gfx::Rect& initial_pos,
- Browser::Type browser_type,
- Profile* profile,
- bool honor_saved_maximized_state);
-
// Calls ExecuteCommandWithDisposition with the given disposition.
void ExecuteCommandWithDisposition(int id, WindowOpenDisposition);
@@ -918,13 +913,6 @@ class Browser : public TabHandlerDelegate,
int index,
int add_types);
- // Creates a new popup window with its own Browser object with the
- // incoming sizing information. |initial_pos|'s origin() is the
- // window origin, and its size() is the size of the content area.
- void BuildPopupWindow(TabContents* source,
- TabContents* new_contents,
- const gfx::Rect& initial_pos);
-
// Returns what the user's home page is, or the new tab page if the home page
// has not been set.
GURL GetHomePage() const;
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index ecf2692..5dab3bf 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -599,7 +599,8 @@ IN_PROC_BROWSER_TEST_F(BrowserTest2, NoTabsInPopups) {
EXPECT_EQ(1, browser()->tab_count());
// Open a popup browser with a single blank foreground tab.
- Browser* popup_browser = browser()->CreateForPopup(browser()->profile());
+ Browser* popup_browser = browser()->CreateForType(Browser::TYPE_POPUP,
+ browser()->profile());
popup_browser->AddBlankTab(true);
EXPECT_EQ(1, popup_browser->tab_count());
diff --git a/chrome/browser/browser_init_browsertest.cc b/chrome/browser/browser_init_browsertest.cc
index f5ad83c..ba86276f 100644
--- a/chrome/browser/browser_init_browsertest.cc
+++ b/chrome/browser/browser_init_browsertest.cc
@@ -46,7 +46,8 @@ IN_PROC_BROWSER_TEST_F(BrowserInitTest, OpenURLsPopup) {
OpenURLsPopupObserver observer;
BrowserList::AddObserver(&observer);
- Browser* popup = Browser::CreateForPopup(browser()->profile());
+ Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP,
+ browser()->profile());
ASSERT_EQ(popup->type(), Browser::TYPE_POPUP);
ASSERT_EQ(popup, observer.added_browser_);
diff --git a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
index 211c3bdb..b9399de 100644
--- a/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
+++ b/chrome/browser/chromeos/tab_closeable_state_watcher_browsertest.cc
@@ -54,7 +54,8 @@ class TabCloseableStateWatcherTest : public InProcessBrowserTest {
Browser* CreatePopupBrowser() {
// This is mostly duplicated from InPocessBrowserTest::CreateBrowser,
// except that a popup browser is created here.
- Browser* popup_browser = Browser::CreateForPopup(browser()->profile());
+ Browser* popup_browser = Browser::CreateForType(Browser::TYPE_POPUP,
+ browser()->profile());
AddTabWithURL(popup_browser, ntp_url_);
popup_browser->window()->Show();
return popup_browser;
diff --git a/chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm b/chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm
index 2825ef2..e17d102 100644
--- a/chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm
+++ b/chrome/browser/cocoa/applescript/browsercrapplication+applescript_test.mm
@@ -19,7 +19,7 @@ typedef InProcessBrowserTest BrowserCrApplicationAppleScriptTest;
IN_PROC_BROWSER_TEST_F(BrowserCrApplicationAppleScriptTest, Creation) {
// Create additional |Browser*| objects of different type.
Profile* profile = browser()->profile();
- Browser* b1 = Browser::CreateForPopup(profile);
+ Browser* b1 = Browser::CreateForType(Browser::TYPE_POPUP, profile);
Browser* b2 = Browser::CreateForApp("", NULL, profile, true);
Browser* b3 = Browser::CreateForApp("", NULL, profile, false);
diff --git a/chrome/browser/cocoa/browser_window_controller_unittest.mm b/chrome/browser/cocoa/browser_window_controller_unittest.mm
index 17886c2..a6fda62 100644
--- a/chrome/browser/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/cocoa/browser_window_controller_unittest.mm
@@ -117,7 +117,8 @@ TEST_F(BrowserWindowControllerTest, TestNormal) {
// And make sure a controller for a pop-up window is not normal.
// popup_browser will be owned by its window.
- Browser *popup_browser(Browser::CreateForPopup(browser_helper_.profile()));
+ Browser *popup_browser(Browser::CreateForType(Browser::TYPE_POPUP,
+ browser_helper_.profile()));
NSWindow *cocoaWindow = popup_browser->window()->GetNativeHandle();
BrowserWindowController* controller =
static_cast<BrowserWindowController*>([cocoaWindow windowController]);
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index b2ea7f4..a2f119b 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -547,31 +547,41 @@ void ExtensionHost::ShowCreatedWindow(int route_id,
if (!contents)
return;
- Browser* browser = BrowserList::FindBrowserWithType(
- contents->profile(),
- Browser::TYPE_NORMAL,
- false); // Match incognito exactly.
- if (!browser) {
- // If no browser is associated with the created TabContents, then the
- // created TabContents may be an intermediate structure used during topmost
- // url navigation from within an experimental extension popup view.
- //
- // If the ExtensionHost has an associated TabContents, then register the
- // new contents with this contents. This will allow top-level link
- // navigation within the new contents to function just as navigation
- // within the current host.
- TabContents* associated_contents = associated_tab_contents();
- if (associated_contents) {
- associated_contents->AddNewContents(contents, disposition, initial_pos,
- user_gesture);
- } else {
- browser = Browser::Create(contents->profile());
- browser->window()->Show();
+ if (disposition == NEW_POPUP) {
+ // Create a new Browser window of type TYPE_APP_POPUP.
+ // (AddTabContents would otherwise create a window of type TYPE_POPUP).
+ Browser* browser = Browser::CreateForPopup(Browser::TYPE_APP_POPUP,
+ contents->profile(),
+ contents,
+ initial_pos);
+ browser->window()->Show();
+ } else {
+ Browser* browser = BrowserList::FindBrowserWithType(
+ contents->profile(),
+ Browser::TYPE_NORMAL,
+ false); // Match incognito exactly.
+ if (!browser) {
+ // If no browser is associated with the created TabContents, then the
+ // created TabContents may be an intermediate struct used during topmost
+ // url navigation from within an experimental extension popup view.
+ //
+ // If the ExtensionHost has an associated TabContents, then register the
+ // new contents with this contents. This will allow top-level link
+ // navigation within the new contents to function just as navigation
+ // within the current host.
+ TabContents* associated_contents = associated_tab_contents();
+ if (associated_contents) {
+ associated_contents->AddNewContents(contents, disposition, initial_pos,
+ user_gesture);
+ } else {
+ browser = Browser::Create(contents->profile());
+ browser->window()->Show();
+ }
}
- }
- if (browser)
- browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
+ if (browser)
+ browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
+ }
}
void ExtensionHost::ShowCreatedWidget(int route_id,
diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc
index 931a83a..9d678bbd 100644
--- a/chrome/browser/extensions/window_open_apitest.cc
+++ b/chrome/browser/extensions/window_open_apitest.cc
@@ -41,7 +41,8 @@ void WaitForTabsAndPopups(Browser* browser, int num_tabs, int num_popups) {
if (*iter == browser)
continue;
- ASSERT_EQ(Browser::TYPE_POPUP, (*iter)->type());
+ // Check for TYPE_POPUP or TYPE_APP_POPUP/PANEL.
+ ASSERT_TRUE((*iter)->type() & Browser::TYPE_POPUP);
}
break;
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index e591f94..a1e3dd2 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -627,7 +627,8 @@ void ExternalTabContainer::HandleKeyboardEvent(
void ExternalTabContainer::ShowHtmlDialog(HtmlDialogUIDelegate* delegate,
gfx::NativeWindow parent_window) {
if (!browser_.get()) {
- browser_.reset(Browser::CreateForPopup(tab_contents_->profile()));
+ browser_.reset(Browser::CreateForType(Browser::TYPE_POPUP,
+ tab_contents_->profile()));
}
gfx::NativeWindow parent = parent_window ? parent_window
@@ -1066,4 +1067,3 @@ void TemporaryPopupExternalTabContainer::OpenURLFromTab(
// support only one navigation for a dummy tab before it is killed.
::DestroyWindow(GetNativeView());
}
-
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index 8bc0c2d..8ec1281 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -43,7 +43,7 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest,
// Create a new popup.
Profile* profile = browser()->profile();
- Browser* popup = Browser::CreateForPopup(profile);
+ Browser* popup = Browser::CreateForType(Browser::TYPE_POPUP, profile);
popup->window()->Show();
// Close the browser.
@@ -117,4 +117,3 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) {
window = static_cast<TabRestoreService::Window*>(service->entries().front());
EXPECT_EQ(2U, window->tabs.size());
}
-
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 725e194..0c9b957 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -271,7 +271,7 @@ Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
}
Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
- Browser* browser = Browser::CreateForPopup(profile);
+ Browser* browser = Browser::CreateForType(Browser::TYPE_POPUP, profile);
InitializeBrowser(browser);
return browser;
}