Commit 6c1e2ba5 authored by Leonard Grey's avatar Leonard Grey Committed by Commit Bot

Reland "Mac: Disallow dragging tab into blocked tabstrip"

This is a reland of 002dfaef

Original change's description:
> Mac: Disallow dragging tab into blocked tabstrip
> 
> This is a really longwinded way for me to fix some NOTIMPLEMENTED spam,
> though I'm pretty sure the thing that happens right now when you open
> a certificate prompt and drag a tab into the parent window is bad.
> 
> This introduces a new method because we're not sure if it matches the
> Aura semantics, and this is better than the nothing we were doing previously.
> 
> Bug: 825834
> Change-Id: I316ca4fbaa7a27dacb09bce0866203b79567016d
> Reviewed-on: https://chromium-review.googlesource.com/c/1315956
> Commit-Queue: Leonard Grey <lgrey@chromium.org>
> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#606619}

Bug: 825834
Change-Id: Ice8fa3f991e3e672a2266c444e281bbad1b47819
Reviewed-on: https://chromium-review.googlesource.com/c/1329350Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607224}
parent c2b92742
......@@ -181,17 +181,6 @@ bool CanDetachFromTabStrip(TabStrip* tabstrip) {
#endif // #if defined(OS_CHROMEOS)
#if defined(USE_AURA)
gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) {
return wm::GetModalTransient(window);
}
#else
gfx::NativeWindow GetModalTransient(gfx::NativeWindow window) {
NOTIMPLEMENTED();
return NULL;
}
#endif
// Returns true if |bounds| contains the y-coordinate |y|. The y-coordinate
// of |bounds| is adjusted by |vertical_adjustment|.
bool DoesRectContainVerticalPointExpanded(
......@@ -1028,18 +1017,19 @@ TabDragController::Liveness TabDragController::GetTargetTabStripForPoint(
// Do not allow dragging into a window with a modal dialog, it causes a weird
// behavior. See crbug.com/336691
if (!GetModalTransient(local_window)) {
TabStrip* result = GetTabStripForWindow(local_window);
if (ShouldAttachOnEnd(result)) {
if (local_window && !ShouldDisallowDrag(local_window)) {
TabStrip* destination_tab_strip = GetTabStripForWindow(local_window);
if (ShouldAttachOnEnd(destination_tab_strip)) {
// No need to check if the specified screen point is within the bounds of
// the tabstrip as arriving here we know that the window is currently
// showing in overview mode in Chrome OS and its bounds contain the
// specified screen point, and these two conditions are enough for a
// window to be a valid target window to attach the dragged tabs.
*tab_strip = result;
*tab_strip = destination_tab_strip;
return Liveness::ALIVE;
} else if (result && DoesTabStripContain(result, point_in_screen)) {
*tab_strip = result;
} else if (destination_tab_strip &&
DoesTabStripContain(destination_tab_strip, point_in_screen)) {
*tab_strip = destination_tab_strip;
return Liveness::ALIVE;
}
}
......@@ -2004,6 +1994,19 @@ void TabDragController::ClearTabDraggingInfo() {
#endif
}
bool TabDragController::ShouldDisallowDrag(gfx::NativeWindow window) {
#if defined(USE_AURA)
return wm::GetModalTransient(window) != nullptr;
#else
TabStrip* tab_strip = GetTabStripForWindow(window);
if (!tab_strip)
return true;
TabStripModel* model = GetModel(tab_strip);
DCHECK(model);
return model->IsTabBlocked(model->active_index());
#endif
}
void TabDragController::SetDeferredTargetTabstrip(
TabStrip* deferred_target_tabstrip) {
#if defined(OS_CHROMEOS)
......
......@@ -470,6 +470,10 @@ class TabDragController : public views::WidgetObserver,
// property.
void SetDeferredTargetTabstrip(TabStrip* deferred_target_tabstrip);
// Whether a drag to |window| should be blocked (for example, if the window
// is showing a modal).
bool ShouldDisallowDrag(gfx::NativeWindow window);
EventSource event_source_;
// The TabStrip the drag originated from. This is set to null if destroyed
......
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