Commit 55319091 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteRWHVMac: Rename LocalClient to ClientHelper

The interface RenderWidgetHostNSViewLocalClient provides a set of helper
functions that add functionality to a RenderWidgetHostNSViewClient.
These functions may be implemented directly using that Client, or using
a side-channel.

The naming of this class is very confusing as we add the ability to have
local (in-process) and remote (out-of-process) clients. To this end,
rename this to a name that more closely mirrors the names in ui/views
and doesn't these naming ambiguities.

Move the ForwardingLocalClient from render_widget_host_view_cocoa.mm
over to a new render_widget_host_ns_view_client_helper.mm. Change
the instance which is created as a dummy pipe to always be identified
as a dummy pipe.

Bug: 821651
Change-Id: I1dd130ddbed46d4854a065fa3d629b7f9833824c
Reviewed-on: https://chromium-review.googlesource.com/1239641Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593601}
parent f75989c1
......@@ -2346,7 +2346,8 @@ jumbo_source_set("browser") {
"renderer_host/popup_window_mac.mm",
"renderer_host/render_widget_host_ns_view_bridge_local.h",
"renderer_host/render_widget_host_ns_view_bridge_local.mm",
"renderer_host/render_widget_host_ns_view_client.h",
"renderer_host/render_widget_host_ns_view_client_helper.h",
"renderer_host/render_widget_host_ns_view_client_helper.mm",
"renderer_host/render_widget_host_view_cocoa.h",
"renderer_host/render_widget_host_view_cocoa.mm",
]
......
......@@ -26,7 +26,7 @@ class RenderWidgetHostNSViewBridgeLocal
public:
RenderWidgetHostNSViewBridgeLocal(
mojom::RenderWidgetHostNSViewClient* client,
RenderWidgetHostNSViewLocalClient* local_client);
RenderWidgetHostNSViewClientHelper* client_helper);
~RenderWidgetHostNSViewBridgeLocal() override;
// TODO(ccameron): RenderWidgetHostViewMac and other functions currently use
......
......@@ -17,12 +17,12 @@ namespace content {
RenderWidgetHostNSViewBridgeLocal::RenderWidgetHostNSViewBridgeLocal(
mojom::RenderWidgetHostNSViewClient* client,
RenderWidgetHostNSViewLocalClient* local_client) {
RenderWidgetHostNSViewClientHelper* client_helper) {
display::Screen::GetScreen()->AddObserver(this);
cocoa_view_.reset([[RenderWidgetHostViewCocoa alloc]
initWithClient:client
withLocalClient:local_client]);
initWithClient:client
withClientHelper:client_helper]);
background_layer_.reset([[CALayer alloc] init]);
display_ca_layer_tree_ =
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_H_
#ifndef CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_HELPER_H_
#define CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_HELPER_H_
#include "base/macros.h"
......@@ -22,6 +22,10 @@ class LatencyInfo;
namespace content {
namespace mojom {
class RenderWidgetHostNSViewClient;
} // namespace mojom
class BrowserAccessibilityManager;
struct EditCommand;
struct NativeWebKeyboardEvent;
......@@ -32,10 +36,16 @@ struct NativeWebKeyboardEvent;
// instantiated in the local process. This is to implement functions that
// cannot be sent across mojo (e.g, GetRootBrowserAccessibilityManager), or
// to avoid unnecessary translation of event types.
class RenderWidgetHostNSViewLocalClient {
class RenderWidgetHostNSViewClientHelper {
public:
RenderWidgetHostNSViewLocalClient() {}
virtual ~RenderWidgetHostNSViewLocalClient() {}
// Create a RenderWidgetHostNSViewClientHelper that will only implement
// functionality through mojo (this is in contrast with an in-process
// RenderWidgetHostNSViewClientHelper that would use raw pointer access).
static std::unique_ptr<RenderWidgetHostNSViewClientHelper>
CreateForMojoClient(content::mojom::RenderWidgetHostNSViewClient* client);
RenderWidgetHostNSViewClientHelper() {}
virtual ~RenderWidgetHostNSViewClientHelper() {}
// Return the RenderWidget's BrowserAccessibilityManager.
// TODO(ccameron): This returns nullptr for non-local NSViews. A scheme for
......@@ -73,9 +83,9 @@ class RenderWidgetHostNSViewLocalClient {
const blink::WebGestureEvent& smart_magnify_event) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostNSViewLocalClient);
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostNSViewClientHelper);
};
} // namespace content
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_H_
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_WIDGET_HOST_NS_VIEW_CLIENT_HELPER_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 "render_widget_host_ns_view_client_helper.h"
#include "content/browser/renderer_host/input/web_input_event_builders_mac.h"
#include "content/common/render_widget_host_ns_view.mojom.h"
#include "content/public/browser/native_web_keyboard_event.h"
namespace content {
namespace {
class ForwardingClientHelper : public RenderWidgetHostNSViewClientHelper {
public:
explicit ForwardingClientHelper(mojom::RenderWidgetHostNSViewClient* client)
: client_(client) {}
private:
std::unique_ptr<InputEvent> TranslateEvent(
const blink::WebInputEvent& web_event) {
return std::make_unique<InputEvent>(web_event, ui::LatencyInfo());
}
// RenderWidgetHostNSViewClientHelper implementation.
BrowserAccessibilityManager* GetRootBrowserAccessibilityManager() override {
return nullptr;
}
void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event,
const ui::LatencyInfo& latency_info) override {
const blink::WebKeyboardEvent* web_event =
static_cast<const blink::WebKeyboardEvent*>(&key_event);
std::unique_ptr<InputEvent> input_event =
std::make_unique<InputEvent>(*web_event, latency_info);
client_->ForwardKeyboardEvent(std::move(input_event),
key_event.skip_in_browser);
}
void ForwardKeyboardEventWithCommands(
const NativeWebKeyboardEvent& key_event,
const ui::LatencyInfo& latency_info,
const std::vector<EditCommand>& commands) override {
const blink::WebKeyboardEvent* web_event =
static_cast<const blink::WebKeyboardEvent*>(&key_event);
std::unique_ptr<InputEvent> input_event =
std::make_unique<InputEvent>(*web_event, latency_info);
client_->ForwardKeyboardEventWithCommands(
std::move(input_event), key_event.skip_in_browser, commands);
}
void RouteOrProcessMouseEvent(
const blink::WebMouseEvent& web_event) override {
client_->RouteOrProcessMouseEvent(TranslateEvent(web_event));
}
void RouteOrProcessTouchEvent(
const blink::WebTouchEvent& web_event) override {
client_->RouteOrProcessTouchEvent(TranslateEvent(web_event));
}
void RouteOrProcessWheelEvent(
const blink::WebMouseWheelEvent& web_event) override {
client_->RouteOrProcessWheelEvent(TranslateEvent(web_event));
}
void ForwardMouseEvent(const blink::WebMouseEvent& web_event) override {
client_->ForwardMouseEvent(TranslateEvent(web_event));
}
void ForwardWheelEvent(const blink::WebMouseWheelEvent& web_event) override {
client_->ForwardWheelEvent(TranslateEvent(web_event));
}
void GestureBegin(blink::WebGestureEvent begin_event,
bool is_synthetically_injected) override {
// The gesture type is not yet known, but assign a type to avoid
// serialization asserts (the type will be stripped on the other side).
begin_event.SetType(blink::WebInputEvent::kGestureScrollBegin);
client_->GestureBegin(TranslateEvent(begin_event),
is_synthetically_injected);
}
void GestureUpdate(blink::WebGestureEvent update_event) override {
client_->GestureUpdate(TranslateEvent(update_event));
}
void GestureEnd(blink::WebGestureEvent end_event) override {
client_->GestureEnd(TranslateEvent(end_event));
}
void SmartMagnify(const blink::WebGestureEvent& web_event) override {
client_->SmartMagnify(TranslateEvent(web_event));
}
mojom::RenderWidgetHostNSViewClient* client_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ForwardingClientHelper);
};
} // namespace
// static
std::unique_ptr<RenderWidgetHostNSViewClientHelper>
RenderWidgetHostNSViewClientHelper::CreateForMojoClient(
content::mojom::RenderWidgetHostNSViewClient* client) {
return std::make_unique<ForwardingClientHelper>(client);
}
} // namespace content
......@@ -31,7 +31,7 @@ namespace mojom {
class RenderWidgetHostNSViewClient;
}
class RenderWidgetHostNSViewLocalClient;
class RenderWidgetHostNSViewClientHelper;
class RenderWidgetHostViewMac;
class RenderWidgetHostViewMacEditCommandHelper;
}
......@@ -68,15 +68,13 @@ struct DidOverscrollParams;
// This includes events (where the extra translation is unnecessary or loses
// information) and access to accessibility structures (only present in the
// browser process).
content::RenderWidgetHostNSViewLocalClient* localClient_;
content::RenderWidgetHostNSViewClientHelper* clientHelper_;
// An implementation of the in-process interface that will translate and
// forward messages through |client_|.
std::unique_ptr<content::RenderWidgetHostNSViewLocalClient>
forwardingLocalClient_;
// Dummy client that is always valid (see above comments about client_).
// Dummy client and client helper that are always valid (see above comments
// about client_).
content::mojom::RenderWidgetHostNSViewClientPtr dummyClient_;
std::unique_ptr<content::RenderWidgetHostNSViewClientHelper>
dummyClientHelper_;
// This ivar is the cocoa delegate of the NSResponder.
base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate>>
......@@ -251,7 +249,7 @@ struct DidOverscrollParams;
// Methods previously marked as private.
- (id)initWithClient:(content::mojom::RenderWidgetHostNSViewClient*)client
withLocalClient:(content::RenderWidgetHostNSViewLocalClient*)localClient;
withClientHelper:(content::RenderWidgetHostNSViewClientHelper*)clientHelper;
- (void)setResponderDelegate:
(NSObject<RenderWidgetHostViewMacDelegate>*)delegate;
- (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event
......
......@@ -17,7 +17,7 @@
#include "components/viz/common/surfaces/surface_id.h"
#include "content/browser/renderer_host/browser_compositor_view_mac.h"
#include "content/browser/renderer_host/input/mouse_wheel_phase_handler.h"
#include "content/browser/renderer_host/render_widget_host_ns_view_client.h"
#include "content/browser/renderer_host/render_widget_host_ns_view_client_helper.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/common/content_export.h"
......@@ -65,7 +65,7 @@ class WebCursor;
// RenderWidgetHostView class hierarchy described in render_widget_host_view.h.
class CONTENT_EXPORT RenderWidgetHostViewMac
: public RenderWidgetHostViewBase,
public RenderWidgetHostNSViewLocalClient,
public RenderWidgetHostNSViewClientHelper,
public mojom::RenderWidgetHostNSViewClient,
public BrowserCompositorMacClient,
public TextInputManager::Observer,
......@@ -300,7 +300,7 @@ class CONTENT_EXPORT RenderWidgetHostViewMac
// RenderWidgetHostImpl as well.
void UpdateNSViewAndDisplayProperties();
// RenderWidgetHostNSViewLocalClient implementation.
// RenderWidgetHostNSViewClientHelper implementation.
BrowserAccessibilityManager* GetRootBrowserAccessibilityManager() override;
void ForwardKeyboardEvent(const NativeWebKeyboardEvent& key_event,
const ui::LatencyInfo& latency_info) override;
......
......@@ -1381,7 +1381,7 @@ MouseWheelPhaseHandler* RenderWidgetHostViewMac::GetMouseWheelPhaseHandler() {
}
///////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostNSViewLocalClient and mojom::RenderWidgetHostNSViewClient
// RenderWidgetHostNSViewClientHelper and mojom::RenderWidgetHostNSViewClient
// implementation:
BrowserAccessibilityManager*
......@@ -1861,7 +1861,7 @@ void RenderWidgetHostViewMac::StopSpeaking() {
///////////////////////////////////////////////////////////////////////////////
// mojom::RenderWidgetHostNSViewClient functions that translate events and
// forward them to the RenderWidgetHostNSViewLocalClient implementation:
// forward them to the RenderWidgetHostNSViewClientHelper implementation:
void RenderWidgetHostViewMac::ForwardKeyboardEvent(
std::unique_ptr<InputEvent> input_event,
......
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