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

Revert "views: random cleanup from removing support for mus"

This reverts commit f19a4c81.

Reason for revert:

Breaks https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/linux-chromeos-dbg

Sample failure line:
[ RUN      ] AppMenuModelTest.Basics
[31511:31511:0513/150125.044037:3461088700:FATAL:window.cc(91)] Check failed: env || !g_env_arg_required_string. Within ash you must supply a non-null aura::Env when creating a Window, use window_factory, or supply the Env obtained from Shell::Get()->aura_env()

Causes ~1000 tests to fail.

Original change's description:
> views: random cleanup from removing support for mus
> 
> This functionality was added purely for mus and is no longer necessary.
> 
> BUG=958241
> TEST=purely dead code removal
> 
> Change-Id: I856576f9adef9728d837d56e82f94a87aeea040b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610497
> Commit-Queue: Scott Violet <sky@chromium.org>
> Reviewed-by: Evan Stade <estade@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#659207}

TBR=sky@chromium.org,estade@chromium.org

Change-Id: I7bbf97863986000679890e2076dbb2b0e5fdaf46
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 958241
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1610709Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659498}
parent ba8d065b
......@@ -40,6 +40,8 @@ class NonClientFrameView;
class Widget;
#if defined(USE_AURA)
class DesktopNativeWidgetAura;
class DesktopWindowTreeHost;
class TouchSelectionMenuRunnerViews;
#endif
......@@ -58,6 +60,14 @@ class VIEWS_EXPORT ViewsDelegate {
using NativeWidgetFactory =
base::RepeatingCallback<NativeWidget*(const Widget::InitParams&,
internal::NativeWidgetDelegate*)>;
#if defined(USE_AURA)
using DesktopWindowTreeHostFactory =
base::RepeatingCallback<std::unique_ptr<DesktopWindowTreeHost>(
const Widget::InitParams&,
internal::NativeWidgetDelegate*,
DesktopNativeWidgetAura*)>;
#endif
#if defined(OS_WIN)
enum AppbarAutohideEdge {
EDGE_TOP = 1 << 0,
......@@ -93,6 +103,15 @@ class VIEWS_EXPORT ViewsDelegate {
return native_widget_factory_;
}
#if defined(USE_AURA)
void set_desktop_window_tree_host_factory(
DesktopWindowTreeHostFactory factory) {
desktop_window_tree_host_factory_ = std::move(factory);
}
const DesktopWindowTreeHostFactory& desktop_window_tree_host_factory() const {
return desktop_window_tree_host_factory_;
}
#endif
// Saves the position, size and "show" state for the window with the
// specified name.
virtual void SaveWindowPlacement(const Widget* widget,
......@@ -191,6 +210,8 @@ class VIEWS_EXPORT ViewsDelegate {
#if defined(USE_AURA)
std::unique_ptr<TouchSelectionMenuRunnerViews> touch_selection_menu_runner_;
DesktopWindowTreeHostFactory desktop_window_tree_host_factory_;
#endif
NativeWidgetFactory native_widget_factory_;
......
......@@ -447,6 +447,14 @@ void DesktopNativeWidgetAura::InitNativeWidget(
if (!desktop_window_tree_host_) {
if (params.desktop_window_tree_host) {
desktop_window_tree_host_ = params.desktop_window_tree_host;
} else if (!ViewsDelegate::GetInstance()
->desktop_window_tree_host_factory()
.is_null()) {
desktop_window_tree_host_ =
ViewsDelegate::GetInstance()
->desktop_window_tree_host_factory()
.Run(params, native_widget_delegate_, this)
.release();
} else {
desktop_window_tree_host_ =
DesktopWindowTreeHost::Create(native_widget_delegate_, this);
......
......@@ -102,9 +102,13 @@ void SetIcon(aura::Window* window,
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetAura, public:
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
bool is_parallel_widget_in_window_manager,
aura::Env* env)
: delegate_(delegate),
window_(new aura::Window(this, aura::client::WINDOW_TYPE_UNKNOWN)),
is_parallel_widget_in_window_manager_(
is_parallel_widget_in_window_manager),
window_(new aura::Window(this, aura::client::WINDOW_TYPE_UNKNOWN, env)),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
destroying_(false),
cursor_(gfx::kNullCursor),
......@@ -353,7 +357,7 @@ ui::InputMethod* NativeWidgetAura::GetInputMethod() {
}
void NativeWidgetAura::CenterWindow(const gfx::Size& size) {
if (!window_)
if (!window_ || is_parallel_widget_in_window_manager_)
return;
window_->SetProperty(aura::client::kPreferredSize, new gfx::Size(size));
......@@ -415,7 +419,7 @@ void NativeWidgetAura::GetWindowPlacement(
}
bool NativeWidgetAura::SetWindowTitle(const base::string16& title) {
if (!window_)
if (!window_ || is_parallel_widget_in_window_manager_)
return false;
if (window_->GetTitle() == title)
return false;
......@@ -425,7 +429,8 @@ bool NativeWidgetAura::SetWindowTitle(const base::string16& title) {
void NativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) {
AssignIconToAuraWindow(window_, window_icon, app_icon);
if (!is_parallel_widget_in_window_manager_)
AssignIconToAuraWindow(window_, window_icon, app_icon);
}
void NativeWidgetAura::InitModalType(ui::ModalType modal_type) {
......@@ -605,7 +610,7 @@ bool NativeWidgetAura::IsActive() const {
}
void NativeWidgetAura::SetAlwaysOnTop(bool on_top) {
if (window_)
if (window_ && !is_parallel_widget_in_window_manager_)
window_->SetProperty(aura::client::kAlwaysOnTopKey, on_top);
}
......@@ -808,6 +813,9 @@ ui::GestureRecognizer* NativeWidgetAura::GetGestureRecognizer() {
}
void NativeWidgetAura::OnSizeConstraintsChanged() {
if (is_parallel_widget_in_window_manager_)
return;
int32_t behavior = ws::mojom::kResizeBehaviorNone;
if (GetWidget()->widget_delegate())
behavior = GetWidget()->widget_delegate()->GetResizeBehavior();
......@@ -1115,8 +1123,15 @@ namespace internal {
// static
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetAura(delegate);
aura::Env* env = nullptr;
if (init_params.parent)
env = init_params.parent->env();
else if (init_params.context)
env = init_params.context->env();
return new NativeWidgetAura(
delegate, /*is_parallel_widget_in_window_manager*/ false, env);
}
// static
......
......@@ -21,6 +21,7 @@
#include "ui/wm/public/activation_delegate.h"
namespace aura {
class Env;
class Window;
}
......@@ -39,7 +40,12 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
public aura::client::FocusChangeObserver,
public aura::client::DragDropDelegate {
public:
explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate);
// |is_parallel_widget_in_window_manager| is true only when this
// NativeWidgetAura is created in the window manager to represent a client
// window, in all other cases it's false.
explicit NativeWidgetAura(internal::NativeWidgetDelegate* delegate,
bool is_parallel_widget_in_window_manager = false,
aura::Env* env = nullptr);
// Called internally by NativeWidgetAura and DesktopNativeWidgetAura to
// associate |native_widget| with |window|.
......@@ -211,6 +217,10 @@ class VIEWS_EXPORT NativeWidgetAura : public internal::NativeWidgetPrivate,
internal::NativeWidgetDelegate* delegate_;
// True if the Widget is created in the window-manager and another client is
// embedded in it. When true certain operations are not performed.
const bool is_parallel_widget_in_window_manager_;
// WARNING: set to NULL when destroyed. As the Widget is not necessarily
// destroyed along with |window_| all usage of |window_| should first verify
// non-NULL.
......
......@@ -764,6 +764,7 @@ namespace internal {
// static
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetMac(delegate);
}
......
......@@ -51,6 +51,7 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
// Creates an appropriate default NativeWidgetPrivate implementation for the
// current OS/circumstance.
static NativeWidgetPrivate* CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate);
static NativeWidgetPrivate* GetNativeWidgetForNativeView(
......
......@@ -76,7 +76,7 @@ NativeWidget* CreateNativeWidget(const Widget::InitParams& params,
if (native_widget)
return native_widget;
}
return internal::NativeWidgetPrivate::CreateNativeWidget(delegate);
return internal::NativeWidgetPrivate::CreateNativeWidget(params, delegate);
}
void NotifyCaretBoundsChanged(ui::InputMethod* input_method) {
......
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