Commit c82a6998 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Clean up chrome/browser/ui/views/tabs/window_finder

Since Mash / WS is gone, the window finder class can be significantly
simplified. This CL does this simplification.

Also moves ash/wm/window_finder.h to ash/public/cpp; this file
would be helpful for others.

Bug: none
Test: trybot
Change-Id: I0dc745c3f5b5ae8d09afbea6930e6203dac29e73
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1645178Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Jun Mukai <mukai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#666607}
parent 94938046
...@@ -55,6 +55,7 @@ component("ash") { ...@@ -55,6 +55,7 @@ component("ash") {
"public/cpp/multi_user_window_manager.h", "public/cpp/multi_user_window_manager.h",
"public/cpp/multi_user_window_manager_delegate.h", "public/cpp/multi_user_window_manager_delegate.h",
"public/cpp/multi_user_window_manager_observer.h", "public/cpp/multi_user_window_manager_observer.h",
"public/cpp/window_finder.h",
"public/cpp/window_tree_host_lookup.h", "public/cpp/window_tree_host_lookup.h",
"root_window_controller.h", "root_window_controller.h",
"screenshot_delegate.h", "screenshot_delegate.h",
...@@ -83,7 +84,6 @@ component("ash") { ...@@ -83,7 +84,6 @@ component("ash") {
"wm/tablet_mode/tablet_mode_observer.h", "wm/tablet_mode/tablet_mode_observer.h",
"wm/tablet_mode/tablet_mode_window_drag_controller.h", "wm/tablet_mode/tablet_mode_window_drag_controller.h",
"wm/tablet_mode/tablet_mode_window_drag_delegate.h", "wm/tablet_mode/tablet_mode_window_drag_delegate.h",
"wm/window_finder.h",
"wm/window_positioner.h", "wm/window_positioner.h",
"wm/window_positioning_utils.h", "wm/window_positioning_utils.h",
"wm/window_properties.h", "wm/window_properties.h",
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_WM_WINDOW_FINDER_H_ #ifndef ASH_PUBLIC_CPP_WINDOW_FINDER_H_
#define ASH_WM_WINDOW_FINDER_H_ #define ASH_PUBLIC_CPP_WINDOW_FINDER_H_
#include <set> #include <set>
...@@ -18,7 +18,6 @@ class Point; ...@@ -18,7 +18,6 @@ class Point;
} }
namespace ash { namespace ash {
namespace wm {
// Finds the topmost window at |screen_point| with ignoring |ignore|. If // Finds the topmost window at |screen_point| with ignoring |ignore|. If
// |real_topmost| is not nullptr, it will be updated to the topmost visible // |real_topmost| is not nullptr, it will be updated to the topmost visible
...@@ -31,7 +30,6 @@ ASH_EXPORT aura::Window* GetTopmostWindowAtPoint( ...@@ -31,7 +30,6 @@ ASH_EXPORT aura::Window* GetTopmostWindowAtPoint(
const std::set<aura::Window*>& ignore, const std::set<aura::Window*>& ignore,
aura::Window** real_topmost); aura::Window** real_topmost);
} // namespace wm
} // namespace ash } // namespace ash
#endif // ASH_WM_WINDOW_FINDER_H_ #endif // ASH_PUBLIC_CPP_WINDOW_FINDER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/wm/window_finder.h" #include "ash/public/cpp/window_finder.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -113,14 +113,13 @@ aura::Window* GetToplevelWindowInOverviewAtPoint( ...@@ -113,14 +113,13 @@ aura::Window* GetToplevelWindowInOverviewAtPoint(
} // namespace } // namespace
namespace ash { namespace ash {
namespace wm {
aura::Window* GetTopmostWindowAtPoint(const gfx::Point& screen_point, aura::Window* GetTopmostWindowAtPoint(const gfx::Point& screen_point,
const std::set<aura::Window*>& ignore, const std::set<aura::Window*>& ignore,
aura::Window** real_topmost) { aura::Window** real_topmost) {
if (real_topmost) if (real_topmost)
*real_topmost = nullptr; *real_topmost = nullptr;
aura::Window* root = GetRootWindowAt(screen_point); aura::Window* root = wm::GetRootWindowAt(screen_point);
// GetTopmostWindowAtPointWithinWindow() always needs to be called to update // GetTopmostWindowAtPointWithinWindow() always needs to be called to update
// |real_topmost| correctly. // |real_topmost| correctly.
aura::Window* topmost_window = GetTopmostWindowAtPointWithinWindow( aura::Window* topmost_window = GetTopmostWindowAtPointWithinWindow(
...@@ -130,5 +129,4 @@ aura::Window* GetTopmostWindowAtPoint(const gfx::Point& screen_point, ...@@ -130,5 +129,4 @@ aura::Window* GetTopmostWindowAtPoint(const gfx::Point& screen_point,
return overview_window ? overview_window : topmost_window; return overview_window ? overview_window : topmost_window;
} }
} // namespace wm
} // namespace ash } // namespace ash
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/wm/window_finder.h" #include "ash/public/cpp/window_finder.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "ui/gfx/geometry/insets.h" #include "ui/gfx/geometry/insets.h"
namespace ash { namespace ash {
namespace wm {
using WindowFinderTest = AshTestBase; using WindowFinderTest = AshTestBase;
...@@ -106,5 +105,4 @@ TEST_F(WindowFinderTest, TopmostWindowWithOverviewActive) { ...@@ -106,5 +105,4 @@ TEST_F(WindowFinderTest, TopmostWindowWithOverviewActive) {
ignore, &real_topmost)); ignore, &real_topmost));
} }
} // namespace wm
} // namespace ash } // namespace ash
...@@ -3184,7 +3184,6 @@ jumbo_split_static_library("ui") { ...@@ -3184,7 +3184,6 @@ jumbo_split_static_library("ui") {
"views/sync/dice_signin_button_view.h", "views/sync/dice_signin_button_view.h",
"views/sync/one_click_signin_dialog_view.cc", "views/sync/one_click_signin_dialog_view.cc",
"views/sync/one_click_signin_dialog_view.h", "views/sync/one_click_signin_dialog_view.h",
"views/tabs/window_finder.cc",
] ]
deps += [ "//ui/views/window/vector_icons" ] deps += [ "//ui/views/window/vector_icons" ]
} }
......
specific_include_rules = { specific_include_rules = {
# mash-ok
"window_finder_chromeos\.cc": [
"+ash/wm/window_finder.h",
],
# mash-ok # mash-ok
"tab_drag_controller_interactive_uitest\.cc": [ "tab_drag_controller_interactive_uitest\.cc": [
"+ash/shell.h", "+ash/shell.h",
......
...@@ -485,8 +485,7 @@ void TabDragController::Init(TabDragContext* source_context, ...@@ -485,8 +485,7 @@ void TabDragController::Init(TabDragContext* source_context,
if (event_source == EVENT_SOURCE_TOUCH) if (event_source == EVENT_SOURCE_TOUCH)
SetCapture(source_context_); SetCapture(source_context_);
window_finder_ = WindowFinder::Create( window_finder_ = std::make_unique<WindowFinder>();
event_source, source_context->AsView()->GetWidget()->GetNativeWindow());
} }
// static // static
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/tabs/window_finder.h"
#include "base/memory/ptr_util.h"
// static
std::unique_ptr<WindowFinder> WindowFinder::Create(
TabDragController::EventSource source,
gfx::NativeWindow window) {
return base::WrapUnique(new WindowFinder());
}
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
#ifndef CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_H_ #ifndef CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_H_
#define CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_H_ #define CHROME_BROWSER_UI_VIEWS_TABS_WINDOW_FINDER_H_
#include <memory>
#include <set> #include <set>
#include "chrome/browser/ui/views/tabs/tab_drag_controller.h" #include "base/macros.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
namespace gfx { namespace gfx {
...@@ -18,13 +17,9 @@ class Point; ...@@ -18,13 +17,9 @@ class Point;
// Class used by the tabstrip to find chrome windows that we can attach tabs to. // Class used by the tabstrip to find chrome windows that we can attach tabs to.
class WindowFinder { class WindowFinder {
public: public:
WindowFinder() = default;
virtual ~WindowFinder() = default; virtual ~WindowFinder() = default;
// Creates the default implementation of WindowFinder.
static std::unique_ptr<WindowFinder> Create(
TabDragController::EventSource source,
gfx::NativeWindow window);
// Finds the topmost visible chrome window at |screen_point|. This should // Finds the topmost visible chrome window at |screen_point|. This should
// return nullptr if |screen_point| is in another program's window which // return nullptr if |screen_point| is in another program's window which
// occludes the topmost chrome window. Ignores the windows in |ignore|, which // occludes the topmost chrome window. Ignores the windows in |ignore|, which
...@@ -33,9 +28,6 @@ class WindowFinder { ...@@ -33,9 +28,6 @@ class WindowFinder {
const gfx::Point& screen_point, const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore); const std::set<gfx::NativeWindow>& ignore);
protected:
WindowFinder() = default;
private: private:
DISALLOW_COPY_AND_ASSIGN(WindowFinder); DISALLOW_COPY_AND_ASSIGN(WindowFinder);
}; };
......
...@@ -4,38 +4,10 @@ ...@@ -4,38 +4,10 @@
#include "chrome/browser/ui/views/tabs/window_finder.h" #include "chrome/browser/ui/views/tabs/window_finder.h"
#include "ash/wm/window_finder.h" #include "ash/public/cpp/window_finder.h"
#include "ui/aura/window.h"
namespace {
// The class to be used by ash to find an eligible chrome window that we can
// attach the dragged tabs into.
class AshWindowFinder : public WindowFinder {
public:
AshWindowFinder() = default;
gfx::NativeWindow GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) override {
return ash::wm::GetTopmostWindowAtPoint(screen_point, ignore, nullptr);
}
private:
DISALLOW_COPY_AND_ASSIGN(AshWindowFinder);
};
} // namespace
std::unique_ptr<WindowFinder> WindowFinder::Create(
TabDragController::EventSource source,
gfx::NativeWindow window) {
return std::make_unique<AshWindowFinder>();
}
gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint( gfx::NativeWindow WindowFinder::GetLocalProcessWindowAtPoint(
const gfx::Point& screen_point, const gfx::Point& screen_point,
const std::set<gfx::NativeWindow>& ignore) { const std::set<gfx::NativeWindow>& ignore) {
NOTREACHED(); return ash::GetTopmostWindowAtPoint(screen_point, ignore, nullptr);
return nullptr;
} }
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