Commit 83e3b96c authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Add BridgedNativeWidgetHost[Impl]

Add an empty BridgedNativeWidgetHost interface and a largely-empty
BridgedNativeWidgetHostImpl implementation. These will be the browser
process part of BridgedNativeWidget.

Update NativeWidgetMac to have a BridgedNativeWidgetHost instead of a
BridgedNativeWidget, but still allow calls through the old interface.

The next steps will be a long process of shuffling members and methods
to these interfaces.

Bug: 859152
Change-Id: Id8be908302a32e52dc0ae1bf54fe19a285adccef
Reviewed-on: https://chromium-review.googlesource.com/1162875Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581146}
parent 5c568461
......@@ -434,6 +434,9 @@ jumbo_component("views") {
"cocoa/bridged_content_view.h",
"cocoa/bridged_content_view.mm",
"cocoa/bridged_content_view_touch_bar.mm",
"cocoa/bridged_native_widget_host.h",
"cocoa/bridged_native_widget_host_impl.h",
"cocoa/bridged_native_widget_host_impl.mm",
"cocoa/bridged_native_widget_owner.h",
"cocoa/cocoa_mouse_capture.h",
"cocoa/cocoa_mouse_capture.mm",
......
// Copyright 2018 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.
#ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
#define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
#include "ui/views/views_export.h"
namespace views {
// The interface through which the app shim (BridgedNativeWidgetImpl)
// communicates with the browser process (BridgedNativeWidgetHostImpl).
class VIEWS_EXPORT BridgedNativeWidgetHost {
public:
virtual ~BridgedNativeWidgetHost() = default;
};
} // namespace views
#endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
// Copyright 2018 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.
#ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
#define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
#include <memory>
#include "base/macros.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views/views_export.h"
namespace views {
class BridgedNativeWidget;
class NativeWidgetMac;
// The portion of NativeWidgetMac that lives in the browser process. This
// communicates to the BridgedNativeWidget, which interacts with the Cocoa
// APIs, and which may live in an app shim process.
class VIEWS_EXPORT BridgedNativeWidgetHostImpl
: public BridgedNativeWidgetHost {
public:
// Creates one side of the bridge. |parent| must not be NULL.
explicit BridgedNativeWidgetHostImpl(NativeWidgetMac* parent);
~BridgedNativeWidgetHostImpl() override;
// Provide direct access to the BridgedNativeWidget that this is hosting.
// TODO(ccameron): Remove all accesses to this member, and replace them
// with methods that may be sent across processes.
BridgedNativeWidget* bridge() const { return bridge_.get(); }
private:
// TODO(ccameron): Rather than instantiate a BridgedNativeWidget here,
// we will instantiate a mojo BridgedNativeWidget interface to a Cocoa
// instance that may be in another process.
std::unique_ptr<BridgedNativeWidget> bridge_;
DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidgetHostImpl);
};
} // namespace views
#endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
// Copyright 2018 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 "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/cocoa/bridged_native_widget.h"
namespace views {
BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl(
NativeWidgetMac* parent)
: bridge_(new BridgedNativeWidget(parent)) {}
BridgedNativeWidgetHostImpl::~BridgedNativeWidgetHostImpl() {}
} // namespace views
......@@ -15,6 +15,7 @@
#include "ui/base/test/ui_controls.h"
#import "ui/base/test/windowed_nsnotification_observer.h"
#import "ui/events/test/cocoa_test_event_utils.h"
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/test/views_interactive_ui_test_base.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/widget/native_widget_mac.h"
......@@ -256,7 +257,7 @@ class HitTestNativeWidgetMac : public NativeWidgetMac {
HitTestNativeWidgetMac(internal::NativeWidgetDelegate* delegate,
NativeFrameView* native_frame_view)
: NativeWidgetMac(delegate), native_frame_view_(native_frame_view) {
NativeWidgetMac::bridge_.reset(new BridgedNativeWidget(this));
bridge_host_ = std::make_unique<BridgedNativeWidgetHostImpl>(this);
}
// internal::NativeWidgetPrivate:
......
......@@ -288,9 +288,7 @@ class MockNativeWidgetMac : public NativeWidgetMac {
public:
explicit MockNativeWidgetMac(internal::NativeWidgetDelegate* delegate)
: NativeWidgetMac(delegate) {}
// Expose a reference, so that it can be reset() independently.
std::unique_ptr<BridgedNativeWidget>& bridge() { return bridge_; }
using NativeWidgetMac::bridge;
// internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override {
......@@ -301,7 +299,7 @@ class MockNativeWidgetMac : public NativeWidgetMac {
delegate()->OnNativeWidgetCreated(true);
// To allow events to dispatch to a view, it needs a way to get focus.
bridge_->SetFocusManager(GetWidget()->GetFocusManager());
bridge()->SetFocusManager(GetWidget()->GetFocusManager());
}
void ReorderNativeViews() override {
......@@ -324,9 +322,7 @@ class BridgedNativeWidgetTestBase : public ui::CocoaTest {
explicit BridgedNativeWidgetTestBase(SkipInitialization tag)
: native_widget_mac_(nullptr) {}
std::unique_ptr<BridgedNativeWidget>& bridge() {
return native_widget_mac_->bridge();
}
BridgedNativeWidget* bridge() { return native_widget_mac_->bridge(); }
// Overridden from testing::Test:
void SetUp() override {
......
......@@ -22,6 +22,7 @@ class MockNativeWidgetMac;
}
class BridgedNativeWidget;
class BridgedNativeWidgetHostImpl;
class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
public:
......@@ -152,13 +153,14 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
virtual void OnWindowDestroying(NSWindow* window) {}
internal::NativeWidgetDelegate* delegate() { return delegate_; }
BridgedNativeWidget* bridge() const;
private:
friend class test::MockNativeWidgetMac;
friend class test::HitTestNativeWidgetMac;
internal::NativeWidgetDelegate* delegate_;
std::unique_ptr<BridgedNativeWidget> bridge_;
std::unique_ptr<BridgedNativeWidgetHostImpl> bridge_host_;
Widget::InitParams::Ownership ownership_;
......
This diff is collapsed.
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