Commit 5e4b28b1 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Let AppShimHost create views_bridge_mac::BridgeFactorys

Add a method to chrome::mojom::AppShim that will create a
views_bridge_mac::BridgeFactory.

Add a views_bridge_mac::BridgeFactoryHost member to chrome::AppShim.
(This will be plumbed to NativeWidgetMac::InitWidgetMac via the
BrowserFrameMac sub-class, which lives in chrome).

Add myself as an OWNER for chrome/app_shim and
chrome/browser/apps/app_shim.

Bug: 859152
Change-Id: I1aaa46376599e0bf88f6f16b461c941c851c431c
Reviewed-on: https://chromium-review.googlesource.com/1229697
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592253}
parent bfa0cad2
...@@ -21,6 +21,7 @@ source_set("app_shim") { ...@@ -21,6 +21,7 @@ source_set("app_shim") {
"//ipc", "//ipc",
"//mojo/core/embedder", "//mojo/core/embedder",
"//ui/base", "//ui/base",
"//ui/views:views",
] ]
} }
......
ccameron@chromium.org
dominickn@chromium.org dominickn@chromium.org
tapted@chromium.org tapted@chromium.org
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
// those app bundles. // those app bundles.
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <utility>
#include <vector> #include <vector>
#include "base/at_exit.h" #include "base/at_exit.h"
...@@ -43,6 +44,8 @@ ...@@ -43,6 +44,8 @@
#include "mojo/public/cpp/system/isolated_connection.h" #include "mojo/public/cpp/system/isolated_connection.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/views/cocoa/bridge_factory_impl.h"
#include "ui/views_bridge_mac/mojo/bridge_factory.mojom.h"
namespace { namespace {
...@@ -126,6 +129,8 @@ class AppShimController : public chrome::mojom::AppShim { ...@@ -126,6 +129,8 @@ class AppShimController : public chrome::mojom::AppShim {
// chrome::mojom::AppShim implementation. // chrome::mojom::AppShim implementation.
void LaunchAppDone(apps::AppShimLaunchResult result) override; void LaunchAppDone(apps::AppShimLaunchResult result) override;
void CreateViewsBridgeFactory(
views_bridge_mac::mojom::BridgeFactoryRequest request) override;
void Hide() override; void Hide() override;
void UnhideWithoutActivation() override; void UnhideWithoutActivation() override;
void SetUserAttention(apps::AppShimAttentionType attention_type) override; void SetUserAttention(apps::AppShimAttentionType attention_type) override;
...@@ -303,6 +308,11 @@ void AppShimController::LaunchAppDone(apps::AppShimLaunchResult result) { ...@@ -303,6 +308,11 @@ void AppShimController::LaunchAppDone(apps::AppShimLaunchResult result) {
launch_app_done_ = true; launch_app_done_ = true;
} }
void AppShimController::CreateViewsBridgeFactory(
views_bridge_mac::mojom::BridgeFactoryRequest request) {
views_bridge_mac::BridgeFactoryImpl::Get()->BindRequest(std::move(request));
}
void AppShimController::Hide() { void AppShimController::Hide() {
[NSApp hide:nil]; [NSApp hide:nil];
} }
......
...@@ -37,5 +37,6 @@ source_set("app_shim") { ...@@ -37,5 +37,6 @@ source_set("app_shim") {
"//content/public/common", "//content/public/common",
"//extensions/browser", "//extensions/browser",
"//extensions/common", "//extensions/common",
"//ui/views:views",
] ]
} }
ccameron@chromium.org
dominickn@chromium.org dominickn@chromium.org
tapted@chromium.org tapted@chromium.org
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/apps/app_shim/app_shim_handler_mac.h" #include "chrome/browser/apps/app_shim/app_shim_handler_mac.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "ui/base/ui_base_features.h"
#include "ui/views_bridge_mac/mojo/bridge_factory.mojom.h"
AppShimHost::AppShimHost() AppShimHost::AppShimHost()
: host_binding_(this), initial_launch_finished_(false) {} : host_binding_(this), initial_launch_finished_(false) {}
...@@ -63,6 +65,15 @@ void AppShimHost::LaunchApp(chrome::mojom::AppShimPtr app_shim_ptr, ...@@ -63,6 +65,15 @@ void AppShimHost::LaunchApp(chrome::mojom::AppShimPtr app_shim_ptr,
return; return;
app_shim_ = std::move(app_shim_ptr); app_shim_ = std::move(app_shim_ptr);
// Create the interface that will be used by views::NativeWidgetMac to create
// NSWindows hosted in the app shim process.
if (features::HostWindowsInAppShimProcess()) {
views_bridge_mac::mojom::BridgeFactoryRequest views_bridge_factory_request;
views_bridge_factory_host_ = std::make_unique<views::BridgeFactoryHost>(
&views_bridge_factory_request);
app_shim_->CreateViewsBridgeFactory(
std::move(views_bridge_factory_request));
}
profile_path_ = profile_dir; profile_path_ = profile_dir;
app_id_ = app_id; app_id_ = app_id;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/system/isolated_connection.h" #include "mojo/public/cpp/system/isolated_connection.h"
#include "ui/views/cocoa/bridge_factory_host.h"
// This is the counterpart to AppShimController in // This is the counterpart to AppShimController in
// chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is // chrome/app/chrome_main_app_mode_mac.mm. The AppShimHost owns itself, and is
...@@ -61,6 +62,7 @@ class AppShimHost : public chrome::mojom::AppShimHost, ...@@ -61,6 +62,7 @@ class AppShimHost : public chrome::mojom::AppShimHost,
mojo::IsolatedConnection mojo_connection_; mojo::IsolatedConnection mojo_connection_;
chrome::mojom::AppShimPtr app_shim_; chrome::mojom::AppShimPtr app_shim_;
std::unique_ptr<views::BridgeFactoryHost> views_bridge_factory_host_;
mojo::Binding<chrome::mojom::AppShimHost> host_binding_; mojo::Binding<chrome::mojom::AppShimHost> host_binding_;
std::string app_id_; std::string app_id_;
base::FilePath profile_path_; base::FilePath profile_path_;
......
...@@ -44,6 +44,8 @@ class TestingAppShim : public chrome::mojom::AppShim { ...@@ -44,6 +44,8 @@ class TestingAppShim : public chrome::mojom::AppShim {
received_launch_done_result_ = true; received_launch_done_result_ = true;
launch_done_result_ = result; launch_done_result_ = result;
} }
void CreateViewsBridgeFactory(
views_bridge_mac::mojom::BridgeFactoryRequest request) override {}
void Hide() override {} void Hide() override {}
void UnhideWithoutActivation() override {} void UnhideWithoutActivation() override {}
void SetUserAttention(apps::AppShimAttentionType attention_type) override {} void SetUserAttention(apps::AppShimAttentionType attention_type) override {}
......
...@@ -49,6 +49,8 @@ class TestShimClient : public chrome::mojom::AppShim { ...@@ -49,6 +49,8 @@ class TestShimClient : public chrome::mojom::AppShim {
// chrome::mojom::AppShim implementation (not used in testing, but can be). // chrome::mojom::AppShim implementation (not used in testing, but can be).
void LaunchAppDone(apps::AppShimLaunchResult result) override {} void LaunchAppDone(apps::AppShimLaunchResult result) override {}
void CreateViewsBridgeFactory(
views_bridge_mac::mojom::BridgeFactoryRequest request) override {}
void Hide() override {} void Hide() override {}
void UnhideWithoutActivation() override {} void UnhideWithoutActivation() override {}
void SetUserAttention(apps::AppShimAttentionType attention_type) override {} void SetUserAttention(apps::AppShimAttentionType attention_type) override {}
......
...@@ -738,6 +738,10 @@ mojom("mojo_bindings") { ...@@ -738,6 +738,10 @@ mojom("mojo_bindings") {
"//url/mojom:url_mojom_origin", "//url/mojom:url_mojom_origin",
] ]
if (is_mac) {
public_deps += [ "//ui/views_bridge_mac:mojo" ]
}
if (safe_browsing_mode == 1) { if (safe_browsing_mode == 1) {
public_deps += [ "//chrome/services/file_util/public/mojom" ] public_deps += [ "//chrome/services/file_util/public/mojom" ]
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
module chrome.mojom; module chrome.mojom;
import "mojo/public/mojom/base/file_path.mojom"; import "mojo/public/mojom/base/file_path.mojom";
import "ui/views_bridge_mac/mojo/bridge_factory.mojom";
[Native] [Native]
enum AppShimLaunchType; enum AppShimLaunchType;
...@@ -20,6 +21,11 @@ enum AppShimAttentionType; ...@@ -20,6 +21,11 @@ enum AppShimAttentionType;
// Interface through which the browser communicates to a shim process. // Interface through which the browser communicates to a shim process.
interface AppShim { interface AppShim {
// Create the interface through which BridgedNativeWidget instances may be
// created (for views::Widgets whose NSWindows exist in the app shim process).
CreateViewsBridgeFactory(
views_bridge_mac.mojom.BridgeFactory& views_bridge_factory);
// Signals that a previous LaunchApp message has been processed, and lets the // Signals that a previous LaunchApp message has been processed, and lets the
// app shim process know whether it was registered successfully. // app shim process know whether it was registered successfully.
LaunchAppDone(AppShimLaunchResult launch_result); LaunchAppDone(AppShimLaunchResult launch_result);
......
...@@ -85,6 +85,8 @@ jumbo_component("views") { ...@@ -85,6 +85,8 @@ jumbo_component("views") {
"bubble/info_bubble.h", "bubble/info_bubble.h",
"bubble/tooltip_icon.h", "bubble/tooltip_icon.h",
"button_drag_utils.h", "button_drag_utils.h",
"cocoa/bridge_factory_host.h",
"cocoa/bridge_factory_impl.h",
"cocoa/bridged_native_widget.h", "cocoa/bridged_native_widget.h",
"cocoa/native_widget_mac_nswindow.h", "cocoa/native_widget_mac_nswindow.h",
"cocoa/window_touch_bar_delegate.h", "cocoa/window_touch_bar_delegate.h",
...@@ -439,8 +441,6 @@ jumbo_component("views") { ...@@ -439,8 +441,6 @@ jumbo_component("views") {
# public into this list, along with the implementation file. # public into this list, along with the implementation file.
sources += [ sources += [
"cocoa/bridge_factory_host.cc", "cocoa/bridge_factory_host.cc",
"cocoa/bridge_factory_host.h",
"cocoa/bridge_factory_impl.h",
"cocoa/bridge_factory_impl.mm", "cocoa/bridge_factory_impl.mm",
"cocoa/bridged_content_view.h", "cocoa/bridged_content_view.h",
"cocoa/bridged_content_view.mm", "cocoa/bridged_content_view.mm",
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojo") { mojom("mojo") {
cpp_only = true
assert(is_mac) assert(is_mac)
sources = [ sources = [
......
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