Skip to content

Commit

Permalink
Revert "views: random cleanup from removing support for mus"
Browse files Browse the repository at this point in the history
This reverts commit f19a4c8.

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/+/1610709
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659498}
  • Loading branch information
Avi Drissman authored and Commit Bot committed May 14, 2019
1 parent ba8d065 commit 2949140
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 9 deletions.
21 changes: 21 additions & 0 deletions ui/views/views_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class NonClientFrameView;
class Widget;

#if defined(USE_AURA)
class DesktopNativeWidgetAura;
class DesktopWindowTreeHost;
class TouchSelectionMenuRunnerViews;
#endif

Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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_;
Expand Down
8 changes: 8 additions & 0 deletions ui/views/widget/desktop_aura/desktop_native_widget_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 22 additions & 7 deletions ui/views/widget/native_widget_aura.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion ui/views/widget/native_widget_aura.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "ui/wm/public/activation_delegate.h"

namespace aura {
class Env;
class Window;
}

Expand All @@ -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|.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions ui/views/widget/native_widget_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ NSInteger StyleMaskForParams(const Widget::InitParams& params) {

// static
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
const Widget::InitParams& init_params,
internal::NativeWidgetDelegate* delegate) {
return new NativeWidgetMac(delegate);
}
Expand Down
1 change: 1 addition & 0 deletions ui/views/widget/native_widget_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion ui/views/widget/widget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 2949140

Please sign in to comment.