Commit c552cd7b authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Mac: turn popups into new tabs while in fullscreen.

It's platform convention to show popups as new tabs while in
non-HTML5 fullscreen. (Popups cause tabs to lose HTML5 fullscreen.)

This was implemented for Cocoa in a BrowserWindow override, but
it makes sense to just stick it into Browser and remove a ton
of override code put in just to support this.

BUG=858929, 868416
TEST=as in bugs

Change-Id: I43471f242813ec1159d9c690bab73dab3e610b7d
Reviewed-on: https://chromium-review.googlesource.com/1153455Reviewed-by: default avatarSidney San Martín <sdy@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578755}
parent f2d4f9d4
...@@ -1532,6 +1532,17 @@ void Browser::AddNewContents(WebContents* source, ...@@ -1532,6 +1532,17 @@ void Browser::AddNewContents(WebContents* source,
const gfx::Rect& initial_rect, const gfx::Rect& initial_rect,
bool user_gesture, bool user_gesture,
bool* was_blocked) { bool* was_blocked) {
#if defined(OS_MACOSX)
// On the Mac, the convention is to turn popups into new tabs when in
// fullscreen mode. Only worry about user-initiated fullscreen as showing a
// popup in HTML5 fullscreen would have kicked the page out of fullscreen.
if (disposition == WindowOpenDisposition::NEW_POPUP &&
exclusive_access_manager_->fullscreen_controller()
->IsFullscreenForBrowser()) {
disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
}
#endif
// At this point the |new_contents| is beyond the popup blocker, but we use // At this point the |new_contents| is beyond the popup blocker, but we use
// the same logic for determining if the popup tracker needs to be attached. // the same logic for determining if the popup tracker needs to be attached.
if (source && PopupBlockerTabHelper::ConsiderForPopupBlocking(disposition)) if (source && PopupBlockerTabHelper::ConsiderForPopupBlocking(disposition))
......
...@@ -464,13 +464,6 @@ void Navigate(NavigateParams* params) { ...@@ -464,13 +464,6 @@ void Navigate(NavigateParams* params) {
params->url = GURL(chrome::kExtensionInvalidRequestURL); params->url = GURL(chrome::kExtensionInvalidRequestURL);
#endif #endif
// The browser window may want to adjust the disposition.
if (params->disposition == WindowOpenDisposition::NEW_POPUP &&
source_browser && source_browser->window()) {
params->disposition =
source_browser->window()->GetDispositionForPopupBounds(
params->window_bounds);
}
// Trying to open a background tab when in an app browser results in // Trying to open a background tab when in an app browser results in
// focusing a regular browser window an opening a tab in the background // focusing a regular browser window an opening a tab in the background
// of that window. Change the disposition to NEW_FOREGROUND_TAB so that // of that window. Change the disposition to NEW_FOREGROUND_TAB so that
......
...@@ -59,7 +59,6 @@ class Extension; ...@@ -59,7 +59,6 @@ class Extension;
} }
namespace gfx { namespace gfx {
class Rect;
class Size; class Size;
} }
...@@ -323,10 +322,6 @@ class BrowserWindow : public ui::BaseWindow { ...@@ -323,10 +322,6 @@ class BrowserWindow : public ui::BaseWindow {
// Clipboard commands applied to the whole browser window. // Clipboard commands applied to the whole browser window.
virtual void CutCopyPaste(int command_id) = 0; virtual void CutCopyPaste(int command_id) = 0;
// Return the correct disposition for a popup window based on |bounds|.
virtual WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) = 0;
// Construct a FindBar implementation for the |browser|. // Construct a FindBar implementation for the |browser|.
virtual FindBar* CreateFindBar() = 0; virtual FindBar* CreateFindBar() = 0;
......
...@@ -133,8 +133,6 @@ class BrowserWindowCocoa ...@@ -133,8 +133,6 @@ class BrowserWindowCocoa
void HandleKeyboardEvent( void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void CutCopyPaste(int command_id) override; void CutCopyPaste(int command_id) override;
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
......
...@@ -636,14 +636,6 @@ void BrowserWindowCocoa::CutCopyPaste(int command_id) { ...@@ -636,14 +636,6 @@ void BrowserWindowCocoa::CutCopyPaste(int command_id) {
[NSApp sendAction:@selector(paste:) to:nil from:nil]; [NSApp sendAction:@selector(paste:) to:nil from:nil];
} }
WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds(
const gfx::Rect& bounds) {
// When using Cocoa's System Fullscreen mode, convert popups into tabs.
if ([controller_ isInAppKitFullscreen])
return WindowOpenDisposition::NEW_FOREGROUND_TAB;
return WindowOpenDisposition::NEW_POPUP;
}
FindBar* BrowserWindowCocoa::CreateFindBar() { FindBar* BrowserWindowCocoa::CreateFindBar() {
// We could push the AddFindBar() call into the FindBarBridge // We could push the AddFindBar() call into the FindBarBridge
// constructor or the FindBarCocoaController init, but that makes // constructor or the FindBarCocoaController init, but that makes
......
...@@ -1498,11 +1498,6 @@ void BrowserView::CutCopyPaste(int command_id) { ...@@ -1498,11 +1498,6 @@ void BrowserView::CutCopyPaste(int command_id) {
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
} }
WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
const gfx::Rect& bounds) {
return WindowOpenDisposition::NEW_POPUP;
}
FindBar* BrowserView::CreateFindBar() { FindBar* BrowserView::CreateFindBar() {
return new FindBarHost(this); return new FindBarHost(this);
} }
......
...@@ -375,8 +375,6 @@ class BrowserView : public BrowserWindow, ...@@ -375,8 +375,6 @@ class BrowserView : public BrowserWindow,
void HandleKeyboardEvent( void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override; const content::NativeWebKeyboardEvent& event) override;
void CutCopyPaste(int command_id) override; void CutCopyPaste(int command_id) override;
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
......
...@@ -180,11 +180,6 @@ DownloadShelf* TestBrowserWindow::GetDownloadShelf() { ...@@ -180,11 +180,6 @@ DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
return &download_shelf_; return &download_shelf_;
} }
WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
const gfx::Rect& bounds) {
return WindowOpenDisposition::NEW_POPUP;
}
FindBar* TestBrowserWindow::CreateFindBar() { FindBar* TestBrowserWindow::CreateFindBar() {
return NULL; return NULL;
} }
......
...@@ -135,8 +135,6 @@ class TestBrowserWindow : public BrowserWindow { ...@@ -135,8 +135,6 @@ class TestBrowserWindow : public BrowserWindow {
const base::Callback<void(bool)>& callback) override {} const base::Callback<void(bool)>& callback) override {}
void UserChangedTheme() override {} void UserChangedTheme() override {}
void CutCopyPaste(int command_id) override {} void CutCopyPaste(int command_id) override {}
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override; FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost() web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override; override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment