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,
const gfx::Rect& initial_rect,
bool user_gesture,
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
// the same logic for determining if the popup tracker needs to be attached.
if (source && PopupBlockerTabHelper::ConsiderForPopupBlocking(disposition))
......
......@@ -464,13 +464,6 @@ void Navigate(NavigateParams* params) {
params->url = GURL(chrome::kExtensionInvalidRequestURL);
#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
// focusing a regular browser window an opening a tab in the background
// of that window. Change the disposition to NEW_FOREGROUND_TAB so that
......
......@@ -59,7 +59,6 @@ class Extension;
}
namespace gfx {
class Rect;
class Size;
}
......@@ -323,10 +322,6 @@ class BrowserWindow : public ui::BaseWindow {
// Clipboard commands applied to the whole browser window.
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|.
virtual FindBar* CreateFindBar() = 0;
......
......@@ -133,8 +133,6 @@ class BrowserWindowCocoa
void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
void CutCopyPaste(int command_id) override;
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override;
......
......@@ -636,14 +636,6 @@ void BrowserWindowCocoa::CutCopyPaste(int command_id) {
[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() {
// We could push the AddFindBar() call into the FindBarBridge
// constructor or the FindBarCocoaController init, but that makes
......
......@@ -1498,11 +1498,6 @@ void BrowserView::CutCopyPaste(int command_id) {
#endif // defined(OS_MACOSX)
}
WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
const gfx::Rect& bounds) {
return WindowOpenDisposition::NEW_POPUP;
}
FindBar* BrowserView::CreateFindBar() {
return new FindBarHost(this);
}
......
......@@ -375,8 +375,6 @@ class BrowserView : public BrowserWindow,
void HandleKeyboardEvent(
const content::NativeWebKeyboardEvent& event) override;
void CutCopyPaste(int command_id) override;
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
override;
......
......@@ -180,11 +180,6 @@ DownloadShelf* TestBrowserWindow::GetDownloadShelf() {
return &download_shelf_;
}
WindowOpenDisposition TestBrowserWindow::GetDispositionForPopupBounds(
const gfx::Rect& bounds) {
return WindowOpenDisposition::NEW_POPUP;
}
FindBar* TestBrowserWindow::CreateFindBar() {
return NULL;
}
......
......@@ -135,8 +135,6 @@ class TestBrowserWindow : public BrowserWindow {
const base::Callback<void(bool)>& callback) override {}
void UserChangedTheme() override {}
void CutCopyPaste(int command_id) override {}
WindowOpenDisposition GetDispositionForPopupBounds(
const gfx::Rect& bounds) override;
FindBar* CreateFindBar() override;
web_modal::WebContentsModalDialogHost* GetWebContentsModalDialogHost()
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