Commit e5c3f5be authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: makes app-list use ServerRemoteViewHost

This converts ash to using ServerRemoteViewHost now that it hosts the
WindowService. This also makes WindowServiceOwner create the WindowService
immediately.

BUG=876513
TEST=covered by tests

Change-Id: I7aba636c9e87db4ab08e1ccab97acecacdfc59f9
Reviewed-on: https://chromium-review.googlesource.com/1185796Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585269}
parent 6f1789c0
......@@ -112,6 +112,7 @@ component("app_list") {
"//mojo/public/cpp/bindings",
"//services/ui/public/cpp",
"//services/ui/public/interfaces",
"//services/ui/ws2/remote_view_host",
"//skia",
"//third_party/icu",
"//ui/accessibility",
......
......@@ -43,8 +43,10 @@ int64_t GetDisplayIdToShowAppListOn() {
namespace ash {
AppListControllerImpl::AppListControllerImpl()
: presenter_(std::make_unique<AppListPresenterDelegateImpl>(this)),
AppListControllerImpl::AppListControllerImpl(
ui::ws2::WindowService* window_service)
: window_service_(window_service),
presenter_(std::make_unique<AppListPresenterDelegateImpl>(this)),
is_home_launcher_enabled_(app_list::features::IsHomeLauncherEnabled()),
voice_interaction_binding_(this) {
model_.AddObserver(this);
......@@ -692,6 +694,10 @@ void AppListControllerImpl::ShowWallpaperContextMenu(
Shell::Get()->ShowContextMenu(onscreen_location, source_type);
}
ui::ws2::WindowService* AppListControllerImpl::GetWindowService() {
return window_service_;
}
void AppListControllerImpl::OnVisibilityChanged(bool visible) {
if (client_)
client_->OnAppListVisibilityChanged(visible);
......
......@@ -30,6 +30,10 @@
namespace ui {
class MouseWheelEvent;
namespace ws2 {
class WindowService;
} // namespace ws2
} // namespace ui
namespace app_list {
......@@ -54,7 +58,7 @@ class ASH_EXPORT AppListControllerImpl
public:
using AppListItemMetadataPtr = mojom::AppListItemMetadataPtr;
using SearchResultMetadataPtr = mojom::SearchResultMetadataPtr;
AppListControllerImpl();
explicit AppListControllerImpl(ui::ws2::WindowService* window_service);
~AppListControllerImpl() override;
// Binds the mojom::AppListController interface request to this object.
......@@ -166,6 +170,8 @@ class ASH_EXPORT AppListControllerImpl
int event_flags) override;
void ShowWallpaperContextMenu(const gfx::Point& onscreen_location,
ui::MenuSourceType source_type) override;
ui::ws2::WindowService* GetWindowService() override;
void OnVisibilityChanged(bool visible);
void OnTargetVisibilityChanged(bool visible);
void StartVoiceInteractionSession();
......@@ -221,6 +227,8 @@ class ASH_EXPORT AppListControllerImpl
// Update the visibility of Assistant functionality.
void UpdateAssistantVisibility();
ui::ws2::WindowService* window_service_;
base::string16 last_raw_query_;
mojom::AppListClientPtr client_;
......
......@@ -16,6 +16,12 @@
#include "ui/base/ui_base_types.h"
#include "ui/gfx/geometry/point.h"
namespace ui {
namespace ws2 {
class WindowService;
}
} // namespace ui
namespace app_list {
class AppListModel;
......@@ -104,6 +110,8 @@ class ASH_PUBLIC_EXPORT AppListViewDelegate {
// Show wallpaper context menu from the specified onscreen location.
virtual void ShowWallpaperContextMenu(const gfx::Point& onscreen_location,
ui::MenuSourceType source_type) = 0;
virtual ui::ws2::WindowService* GetWindowService() = 0;
};
} // namespace app_list
......
......@@ -88,6 +88,10 @@ void AppListTestViewDelegate::ShowWallpaperContextMenu(
++show_wallpaper_context_menu_count_;
}
ui::ws2::WindowService* AppListTestViewDelegate::GetWindowService() {
return nullptr;
}
void AppListTestViewDelegate::GetSearchResultContextMenuModel(
const std::string& result_id,
GetContextMenuModelCallback callback) {
......
......@@ -76,6 +76,7 @@ class AppListTestViewDelegate : public AppListViewDelegate,
int event_flags) override {}
void ShowWallpaperContextMenu(const gfx::Point& onscreen_location,
ui::MenuSourceType source_type) override;
ui::ws2::WindowService* GetWindowService() override;
// Do a bulk replacement of the items in the model.
void ReplaceTestModel(int item_count);
......
......@@ -17,6 +17,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
#include "services/ui/ws2/remote_view_host/server_remote_view_host.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/aura/window.h"
......@@ -25,7 +26,6 @@
#include "ui/views/background.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/mus/remote_view/remote_view_host.h"
namespace app_list {
......@@ -33,6 +33,7 @@ namespace {
// Helper to get/create answer card view by token.
views::View* GetViewByToken(
ui::ws2::WindowService* window_service,
const base::Optional<base::UnguessableToken>& token) {
// Bail for invalid token.
if (!token.has_value() || token->is_empty())
......@@ -44,10 +45,11 @@ views::View* GetViewByToken(
if (AnswerCardContentsRegistry::Get())
return AnswerCardContentsRegistry::Get()->GetView(token.value());
// Use RemoteViewHost to embed the answer card contents provided in the
// Use ServerRemoteViewHost to embed the answer card contents provided in the
// browser process in Mash.
if (!features::IsAshInBrowserProcess()) {
views::RemoteViewHost* view = new views::RemoteViewHost();
if (features::IsUsingWindowService()) {
ui::ws2::ServerRemoteViewHost* view =
new ui::ws2::ServerRemoteViewHost(window_service);
view->EmbedUsingToken(token.value(),
ui::mojom::kEmbedFlagEmbedderInterceptsEvents |
ui::mojom::kEmbedFlagEmbedderControlsVisibility,
......@@ -122,7 +124,8 @@ class SearchResultAnswerCardView::SearchAnswerContainerView
if (old_token != new_token) {
RemoveAllChildViews(true /* delete_children */);
result_view = GetViewByToken(new_token);
result_view =
GetViewByToken(view_delegate_->GetWindowService(), new_token);
if (result_view) {
AddChildView(result_view);
ExcludeFromEventHandlingByToken(new_token);
......
......@@ -23,8 +23,8 @@ class AssistantController;
// AssistantWebView is a child of AssistantBubbleView which allows Assistant UI
// to render remotely hosted content within its bubble. It provides a CaptionBar
// for window level controls and a WebView/RemoteViewHost for embedding web
// contents.
// for window level controls and a WebView/ServerRemoteViewHost for embedding
// web contents.
class AssistantWebView : public views::View,
public AssistantControllerObserver,
public CaptionBarDelegate {
......
......@@ -1118,9 +1118,13 @@ void Shell::Init(
voice_interaction_controller_ =
std::make_unique<VoiceInteractionController>();
window_service_owner_ =
std::make_unique<WindowServiceOwner>(std::move(gpu_interface_provider));
// |app_list_controller_| is put after |tablet_mode_controller_| as the former
// uses the latter in constructor.
app_list_controller_ = std::make_unique<AppListControllerImpl>();
app_list_controller_ = std::make_unique<AppListControllerImpl>(
window_service_owner_->window_service());
shelf_controller_ = std::make_unique<ShelfController>();
magnifier_key_scroll_handler_ = MagnifierKeyScroller::CreateHandler();
......@@ -1295,8 +1299,6 @@ void Shell::Init(
connector_->StartService(tap_visualizer::mojom::kServiceName);
}
window_service_owner_ =
std::make_unique<WindowServiceOwner>(std::move(gpu_interface_provider));
if (::features::IsAshInBrowserProcess()) {
ime_focus_handler_ = std::make_unique<ImeFocusHandler>(
focus_controller(), window_tree_host_manager_->input_method());
......
......@@ -313,6 +313,11 @@ class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
NOTIMPLEMENTED();
}
ui::ws2::WindowService* GetWindowService() override {
NOTIMPLEMENTED();
return nullptr;
}
std::unique_ptr<app_list::AppListModel> model_;
std::unique_ptr<app_list::SearchModel> search_model_;
......
......@@ -21,7 +21,21 @@ namespace ash {
WindowServiceOwner::WindowServiceOwner(
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider)
: gpu_interface_provider_(std::move(gpu_interface_provider)) {}
: window_service_delegate_(std::make_unique<WindowServiceDelegateImpl>()),
owned_window_service_(std::make_unique<ui::ws2::WindowService>(
window_service_delegate_.get(),
std::move(gpu_interface_provider),
Shell::Get()->focus_controller(),
features::IsAshInBrowserProcess(),
Shell::Get()->aura_env())),
window_service_(owned_window_service_.get()) {
window_service_->SetFrameDecorationValues(
NonClientFrameController::GetPreferredClientAreaInsets(),
NonClientFrameController::GetMaxTitleBarButtonWidth());
window_service_->SetDisplayForNewWindows(
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
RegisterWindowProperties(window_service_->property_converter());
}
WindowServiceOwner::~WindowServiceOwner() = default;
......@@ -32,21 +46,8 @@ void WindowServiceOwner::BindWindowService(
// a new WindowService to be created. That should never happen.
DCHECK(!service_context_);
window_service_delegate_ = std::make_unique<WindowServiceDelegateImpl>();
std::unique_ptr<ui::ws2::WindowService> window_service =
std::make_unique<ui::ws2::WindowService>(
window_service_delegate_.get(), std::move(gpu_interface_provider_),
Shell::Get()->focus_controller(), features::IsAshInBrowserProcess(),
Shell::Get()->aura_env());
window_service_ = window_service.get();
window_service_->SetFrameDecorationValues(
NonClientFrameController::GetPreferredClientAreaInsets(),
NonClientFrameController::GetMaxTitleBarButtonWidth());
window_service_->SetDisplayForNewWindows(
display::Screen::GetScreen()->GetDisplayForNewWindows().id());
RegisterWindowProperties(window_service_->property_converter());
service_context_ = std::make_unique<service_manager::ServiceContext>(
std::move(window_service), std::move(request));
std::move(owned_window_service_), std::move(request));
}
} // namespace ash
......@@ -40,25 +40,22 @@ class ASH_EXPORT WindowServiceOwner {
// WindowService.
void BindWindowService(service_manager::mojom::ServiceRequest request);
// Returns the WindowService, or null if BindWindowService() hasn't been
// called yet.
ui::ws2::WindowService* window_service() { return window_service_; }
private:
friend class AshTestHelper;
// Non-null until |service_context_| is created.
std::unique_ptr<ui::ws2::GpuInterfaceProvider> gpu_interface_provider_;
// The following state is created once BindWindowService() is called.
std::unique_ptr<WindowServiceDelegateImpl> window_service_delegate_;
// Handles the ServiceRequest. Owns |window_service_|.
std::unique_ptr<service_manager::ServiceContext> service_context_;
// The WindowService. This is owned by |service_context_|.
ui::ws2::WindowService* window_service_ = nullptr;
// The WindowService. The constructor creates the WindowService and assigns
// it to |owned_window_service_| and |window_service_|. When
// BindWindowService() is called |owned_window_service_| is passed to
// |service_context_|.
std::unique_ptr<ui::ws2::WindowService> owned_window_service_;
ui::ws2::WindowService* window_service_;
DISALLOW_COPY_AND_ASSIGN(WindowServiceOwner);
};
......
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