Commit 090352b9 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

remove highlighter_controller.mojom

TBR=tsepez@chromium.org

Bug: 958201
Test: trybot
Change-Id: Ic3150a3c42b4956b64f5de62833d80c2237b23cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1623587
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663993}
parent 3c42f0e9
...@@ -59,8 +59,7 @@ float GetScreenshotScale(aura::Window* window) { ...@@ -59,8 +59,7 @@ float GetScreenshotScale(aura::Window* window) {
} // namespace } // namespace
HighlighterController::HighlighterController() HighlighterController::HighlighterController() : weak_factory_(this) {
: binding_(this), weak_factory_(this) {
Shell::Get()->AddPreTargetHandler(this); Shell::Get()->AddPreTargetHandler(this);
} }
...@@ -100,19 +99,6 @@ void HighlighterController::AbortSession() { ...@@ -100,19 +99,6 @@ void HighlighterController::AbortSession() {
UpdateEnabledState(HighlighterEnabledState::kDisabledBySessionAbort); UpdateEnabledState(HighlighterEnabledState::kDisabledBySessionAbort);
} }
void HighlighterController::BindRequest(
mojom::HighlighterControllerRequest request) {
binding_.Bind(std::move(request));
}
void HighlighterController::SetClient(
mojom::HighlighterControllerClientPtr client) {
client_ = std::move(client);
client_.set_connection_error_handler(
base::BindOnce(&HighlighterController::OnClientConnectionLost,
weak_factory_.GetWeakPtr()));
}
void HighlighterController::SetEnabled(bool enabled) { void HighlighterController::SetEnabled(bool enabled) {
FastInkPointerController::SetEnabled(enabled); FastInkPointerController::SetEnabled(enabled);
if (enabled) { if (enabled) {
...@@ -132,13 +118,6 @@ void HighlighterController::SetEnabled(bool enabled) { ...@@ -132,13 +118,6 @@ void HighlighterController::SetEnabled(bool enabled) {
if (highlighter_view_ && !highlighter_view_->animating()) if (highlighter_view_ && !highlighter_view_->animating())
DestroyPointerView(); DestroyPointerView();
} }
if (client_)
client_->HandleEnabledStateChange(enabled);
}
void HighlighterController::ExitHighlighterMode() {
CallExitCallback();
} }
views::View* HighlighterController::GetPointerView() const { views::View* HighlighterController::GetPointerView() const {
...@@ -241,9 +220,6 @@ void HighlighterController::RecognizeGesture() { ...@@ -241,9 +220,6 @@ void HighlighterController::RecognizeGesture() {
? gfx::ToEnclosingRect(box) ? gfx::ToEnclosingRect(box)
: gfx::ToEnclosingRect( : gfx::ToEnclosingRect(
gfx::ScaleRect(box, GetScreenshotScale(current_window))); gfx::ScaleRect(box, GetScreenshotScale(current_window)));
if (client_)
client_->HandleSelection(selection_rect);
for (auto& observer : observers_) for (auto& observer : observers_)
observer.OnHighlighterSelectionRecognized(selection_rect); observer.OnHighlighterSelectionRecognized(selection_rect);
...@@ -302,21 +278,9 @@ void HighlighterController::DestroyResultView() { ...@@ -302,21 +278,9 @@ void HighlighterController::DestroyResultView() {
result_view_.reset(); result_view_.reset();
} }
void HighlighterController::OnClientConnectionLost() {
client_.reset();
binding_.Close();
// The client has detached, force-exit the highlighter mode.
CallExitCallback();
}
void HighlighterController::CallExitCallback() { void HighlighterController::CallExitCallback() {
if (!exit_callback_.is_null()) if (!exit_callback_.is_null())
std::move(exit_callback_).Run(); std::move(exit_callback_).Run();
} }
void HighlighterController::FlushMojoForTesting() {
if (client_)
client_.FlushForTesting();
}
} // namespace ash } // namespace ash
...@@ -9,16 +9,18 @@ ...@@ -9,16 +9,18 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/components/fast_ink/fast_ink_pointer_controller.h" #include "ash/components/fast_ink/fast_ink_pointer_controller.h"
#include "ash/public/interfaces/highlighter_controller.mojom.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "mojo/public/cpp/bindings/binding.h"
namespace base { namespace base {
class OneShotTimer; class OneShotTimer;
} }
namespace gfx {
class Rect;
}
namespace ash { namespace ash {
class HighlighterResultView; class HighlighterResultView;
...@@ -42,8 +44,7 @@ enum class HighlighterEnabledState { ...@@ -42,8 +44,7 @@ enum class HighlighterEnabledState {
// Enables/disables highlighter as well as receives points // Enables/disables highlighter as well as receives points
// and passes them off to be rendered. // and passes them off to be rendered.
class ASH_EXPORT HighlighterController class ASH_EXPORT HighlighterController
: public fast_ink::FastInkPointerController, : public fast_ink::FastInkPointerController {
public mojom::HighlighterController {
public: public:
// Interface for classes that wish to be notified with highlighter status. // Interface for classes that wish to be notified with highlighter status.
class Observer { class Observer {
...@@ -79,12 +80,6 @@ class ASH_EXPORT HighlighterController ...@@ -79,12 +80,6 @@ class ASH_EXPORT HighlighterController
// calling this method is a no-op. // calling this method is a no-op.
void AbortSession(); void AbortSession();
void BindRequest(mojom::HighlighterControllerRequest request);
// mojom::HighlighterController:
void SetClient(mojom::HighlighterControllerClientPtr client) override;
void ExitHighlighterMode() override;
private: private:
friend class HighlighterControllerTestApi; friend class HighlighterControllerTestApi;
...@@ -107,14 +102,9 @@ class ASH_EXPORT HighlighterController ...@@ -107,14 +102,9 @@ class ASH_EXPORT HighlighterController
// Destroys |result_view_|, if it exists. // Destroys |result_view_|, if it exists.
void DestroyResultView(); void DestroyResultView();
// Called when the mojo connection with the client is closed.
void OnClientConnectionLost();
// Calls and clears the mode exit callback, if it is set. // Calls and clears the mode exit callback, if it is set.
void CallExitCallback(); void CallExitCallback();
void FlushMojoForTesting();
// Caches the highlighter enabled state. // Caches the highlighter enabled state.
HighlighterEnabledState enabled_state_ = HighlighterEnabledState enabled_state_ =
HighlighterEnabledState::kDisabledByUser; HighlighterEnabledState::kDisabledByUser;
...@@ -151,12 +141,6 @@ class ASH_EXPORT HighlighterController ...@@ -151,12 +141,6 @@ class ASH_EXPORT HighlighterController
// If true, the mode is not exited until a valid selection is made. // If true, the mode is not exited until a valid selection is made.
bool require_success_ = true; bool require_success_ = true;
// Binding for mojom::HighlighterController interface.
mojo::Binding<ash::mojom::HighlighterController> binding_;
// Interface to highlighter controller client (chrome).
mojom::HighlighterControllerClientPtr client_;
base::ObserverList<Observer>::Unchecked observers_; base::ObserverList<Observer>::Unchecked observers_;
base::WeakPtrFactory<HighlighterController> weak_factory_; base::WeakPtrFactory<HighlighterController> weak_factory_;
......
...@@ -13,12 +13,12 @@ namespace ash { ...@@ -13,12 +13,12 @@ namespace ash {
HighlighterControllerTestApi::HighlighterControllerTestApi( HighlighterControllerTestApi::HighlighterControllerTestApi(
HighlighterController* instance) HighlighterController* instance)
: binding_(this), instance_(instance) { : instance_(instance) {
AttachClient(); AttachClient();
} }
HighlighterControllerTestApi::~HighlighterControllerTestApi() { HighlighterControllerTestApi::~HighlighterControllerTestApi() {
if (binding_.is_bound()) if (scoped_observer_)
DetachClient(); DetachClient();
if (instance_->enabled()) if (instance_->enabled())
instance_->SetEnabled(false); instance_->SetEnabled(false);
...@@ -26,25 +26,19 @@ HighlighterControllerTestApi::~HighlighterControllerTestApi() { ...@@ -26,25 +26,19 @@ HighlighterControllerTestApi::~HighlighterControllerTestApi() {
} }
void HighlighterControllerTestApi::AttachClient() { void HighlighterControllerTestApi::AttachClient() {
DCHECK(!binding_.is_bound()); scoped_observer_ = std::make_unique<ScopedObserver>(this);
DCHECK(!highlighter_controller_); scoped_observer_->Add(instance_);
instance_->BindRequest(mojo::MakeRequest(&highlighter_controller_));
ash::mojom::HighlighterControllerClientPtr client;
binding_.Bind(mojo::MakeRequest(&client));
highlighter_controller_->SetClient(std::move(client));
highlighter_controller_.FlushForTesting();
} }
void HighlighterControllerTestApi::DetachClient() { void HighlighterControllerTestApi::DetachClient() {
DCHECK(binding_.is_bound()); scoped_observer_.reset();
DCHECK(highlighter_controller_); instance_->CallExitCallback();
highlighter_controller_ = nullptr;
binding_.Close();
instance_->FlushMojoForTesting();
} }
void HighlighterControllerTestApi::SetEnabled(bool enabled) { void HighlighterControllerTestApi::SetEnabled(bool enabled) {
instance_->SetEnabled(enabled); instance_->UpdateEnabledState(
enabled ? HighlighterEnabledState::kEnabled
: HighlighterEnabledState::kDisabledBySessionComplete);
} }
void HighlighterControllerTestApi::DestroyPointerView() { void HighlighterControllerTestApi::DestroyPointerView() {
...@@ -85,21 +79,22 @@ const fast_ink::FastInkPoints& HighlighterControllerTestApi::predicted_points() ...@@ -85,21 +79,22 @@ const fast_ink::FastInkPoints& HighlighterControllerTestApi::predicted_points()
} }
bool HighlighterControllerTestApi::HandleEnabledStateChangedCalled() { bool HighlighterControllerTestApi::HandleEnabledStateChangedCalled() {
instance_->FlushMojoForTesting();
return handle_enabled_state_changed_called_; return handle_enabled_state_changed_called_;
} }
bool HighlighterControllerTestApi::HandleSelectionCalled() { bool HighlighterControllerTestApi::HandleSelectionCalled() {
instance_->FlushMojoForTesting();
return handle_selection_called_; return handle_selection_called_;
} }
void HighlighterControllerTestApi::HandleSelection(const gfx::Rect& rect) { void HighlighterControllerTestApi::OnHighlighterSelectionRecognized(
const gfx::Rect& rect) {
handle_selection_called_ = true; handle_selection_called_ = true;
selection_ = rect; selection_ = rect;
} }
void HighlighterControllerTestApi::HandleEnabledStateChange(bool enabled) { void HighlighterControllerTestApi::OnHighlighterEnabledChanged(
HighlighterEnabledState state) {
const bool enabled = (state == HighlighterEnabledState::kEnabled);
handle_enabled_state_changed_called_ = true; handle_enabled_state_changed_called_ = true;
enabled_ = enabled; enabled_ = enabled;
} }
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#ifndef ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_ #ifndef ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_
#define ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_ #define ASH_HIGHLIGHTER_HIGHLIGHTER_CONTROLLER_TEST_API_H_
#include "ash/public/interfaces/highlighter_controller.mojom.h" #include "ash/highlighter/highlighter_controller.h"
#include "base/macros.h" #include "base/macros.h"
#include "mojo/public/cpp/bindings/binding.h" #include "base/scoped_observer.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
namespace fast_ink { namespace fast_ink {
...@@ -16,13 +16,11 @@ class FastInkPoints; ...@@ -16,13 +16,11 @@ class FastInkPoints;
namespace ash { namespace ash {
class HighlighterController;
// An api for testing the HighlighterController class. // An api for testing the HighlighterController class.
// Implements ash::mojom::HighlighterControllerClient and binds itself as the // Implements ash::mojom::HighlighterControllerClient and binds itself as the
// client to provide the tests with access to gesture recognition results. // client to provide the tests with access to gesture recognition results.
class HighlighterControllerTestApi class HighlighterControllerTestApi
: public ash::mojom::HighlighterControllerClient { : public ash::HighlighterController::Observer {
public: public:
explicit HighlighterControllerTestApi(HighlighterController* instance); explicit HighlighterControllerTestApi(HighlighterController* instance);
~HighlighterControllerTestApi() override; ~HighlighterControllerTestApi() override;
...@@ -46,28 +44,22 @@ class HighlighterControllerTestApi ...@@ -46,28 +44,22 @@ class HighlighterControllerTestApi
const fast_ink::FastInkPoints& predicted_points() const; const fast_ink::FastInkPoints& predicted_points() const;
void ResetEnabledState() { handle_enabled_state_changed_called_ = false; } void ResetEnabledState() { handle_enabled_state_changed_called_ = false; }
// Flushes the mojo connection, then checks whether HandleEnabledStateChange
// has been called on the client since the last call to ResetEnabledState.
bool HandleEnabledStateChangedCalled(); bool HandleEnabledStateChangedCalled();
bool enabled() const { return enabled_; } bool enabled() const { return enabled_; }
void ResetSelection() { handle_selection_called_ = false; } void ResetSelection() { handle_selection_called_ = false; }
// Flushes the mojo connection, then checks whether HandleSelection
// has been called on the client since the last call to ResetSelection.
bool HandleSelectionCalled(); bool HandleSelectionCalled();
const gfx::Rect& selection() const { return selection_; } const gfx::Rect& selection() const { return selection_; }
private: private:
// HighlighterSelectionObserver: using ScopedObserver =
void HandleSelection(const gfx::Rect& rect) override; ScopedObserver<HighlighterController, HighlighterController::Observer>;
void HandleEnabledStateChange(bool enabled) override;
// Binds to the client interface. // HighlighterSelectionObserver:
mojo::Binding<ash::mojom::HighlighterControllerClient> binding_; void OnHighlighterSelectionRecognized(const gfx::Rect& rect) override;
void OnHighlighterEnabledChanged(HighlighterEnabledState state) override;
// HighlighterController interface.
ash::mojom::HighlighterControllerPtr highlighter_controller_;
std::unique_ptr<ScopedObserver> scoped_observer_;
HighlighterController* instance_; HighlighterController* instance_;
bool handle_selection_called_ = false; bool handle_selection_called_ = false;
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "ash/autotest/shelf_integration_test_api.h" #include "ash/autotest/shelf_integration_test_api.h"
#include "ash/display/cros_display_config.h" #include "ash/display/cros_display_config.h"
#include "ash/events/event_rewriter_controller.h" #include "ash/events/event_rewriter_controller.h"
#include "ash/highlighter/highlighter_controller.h"
#include "ash/ime/ime_controller.h" #include "ash/ime/ime_controller.h"
#include "ash/keyboard/ash_keyboard_controller.h" #include "ash/keyboard/ash_keyboard_controller.h"
#include "ash/keyboard/ui/keyboard_controller.h" #include "ash/keyboard/ui/keyboard_controller.h"
...@@ -111,11 +110,6 @@ void BindEventRewriterControllerRequestOnMainThread( ...@@ -111,11 +110,6 @@ void BindEventRewriterControllerRequestOnMainThread(
Shell::Get()->event_rewriter_controller()->BindRequest(std::move(request)); Shell::Get()->event_rewriter_controller()->BindRequest(std::move(request));
} }
void BindHighlighterControllerRequestOnMainThread(
mojom::HighlighterControllerRequest request) {
Shell::Get()->highlighter_controller()->BindRequest(std::move(request));
}
void BindImeControllerRequestOnMainThread(mojom::ImeControllerRequest request) { void BindImeControllerRequestOnMainThread(mojom::ImeControllerRequest request) {
Shell::Get()->ime_controller()->BindRequest(std::move(request)); Shell::Get()->ime_controller()->BindRequest(std::move(request));
} }
...@@ -226,9 +220,6 @@ void RegisterInterfaces( ...@@ -226,9 +220,6 @@ void RegisterInterfaces(
registry->AddInterface( registry->AddInterface(
base::BindRepeating(&BindEventRewriterControllerRequestOnMainThread), base::BindRepeating(&BindEventRewriterControllerRequestOnMainThread),
main_thread_task_runner); main_thread_task_runner);
registry->AddInterface(
base::BindRepeating(&BindHighlighterControllerRequestOnMainThread),
main_thread_task_runner);
registry->AddInterface( registry->AddInterface(
base::BindRepeating(&BindImeControllerRequestOnMainThread), base::BindRepeating(&BindImeControllerRequestOnMainThread),
main_thread_task_runner); main_thread_task_runner);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ash/public/interfaces/constants.mojom.h" #include "ash/public/interfaces/constants.mojom.h"
#include "ash/public/interfaces/cros_display_config.mojom.h" #include "ash/public/interfaces/cros_display_config.mojom.h"
#include "ash/public/interfaces/event_rewriter_controller.mojom.h" #include "ash/public/interfaces/event_rewriter_controller.mojom.h"
#include "ash/public/interfaces/highlighter_controller.mojom.h"
#include "ash/public/interfaces/ime_controller.mojom.h" #include "ash/public/interfaces/ime_controller.mojom.h"
#include "ash/public/interfaces/keyboard_controller.mojom.h" #include "ash/public/interfaces/keyboard_controller.mojom.h"
#include "ash/public/interfaces/kiosk_next_shell.mojom.h" #include "ash/public/interfaces/kiosk_next_shell.mojom.h"
...@@ -68,13 +67,12 @@ const service_manager::Manifest& GetManifest() { ...@@ -68,13 +67,12 @@ const service_manager::Manifest& GetManifest() {
mojom::AssistantVolumeControl, mojom::AssistantVolumeControl,
mojom::KioskNextShellController, mojom::KioskNextShellController,
mojom::CrosDisplayConfigController, mojom::CrosDisplayConfigController,
mojom::EventRewriterController, mojom::HighlighterController, mojom::EventRewriterController, mojom::ImeController,
mojom::ImeController, mojom::KeyboardController, mojom::KeyboardController, mojom::LocaleUpdateController,
mojom::LocaleUpdateController, mojom::LoginScreen, mojom::LoginScreen, mojom::MediaController,
mojom::MediaController, mojom::NightLightController, mojom::NightLightController, mojom::ShutdownController,
mojom::ShutdownController, mojom::TabletModeController, mojom::TabletModeController, mojom::TrayAction,
mojom::TrayAction, mojom::VoiceInteractionController, mojom::VoiceInteractionController, mojom::VpnList>())
mojom::VpnList>())
.ExposeCapability("test", service_manager::Manifest::InterfaceList< .ExposeCapability("test", service_manager::Manifest::InterfaceList<
mojom::ShelfIntegrationTestApi>()) mojom::ShelfIntegrationTestApi>())
.RequireCapability("*", "accessibility") .RequireCapability("*", "accessibility")
......
...@@ -27,7 +27,6 @@ mojom("interfaces_internal") { ...@@ -27,7 +27,6 @@ mojom("interfaces_internal") {
"constants.mojom", "constants.mojom",
"cros_display_config.mojom", "cros_display_config.mojom",
"event_rewriter_controller.mojom", "event_rewriter_controller.mojom",
"highlighter_controller.mojom",
"ime_controller.mojom", "ime_controller.mojom",
"ime_info.mojom", "ime_info.mojom",
"keyboard_config.mojom", "keyboard_config.mojom",
......
// Copyright 2017 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.
module ash.mojom;
import "ui/gfx/geometry/mojo/geometry.mojom";
// Interface for ash client (e.g. Chrome) to connect to the highlighter
// controller, the component implementing on-screen content selection
// with a stylus.
interface HighlighterController {
// Sets the client interface.
SetClient(HighlighterControllerClient client);
// Exits the highlighter mode if it is currently enabled.
ExitHighlighterMode();
};
// Interface for ash to notify the client (e.g. Chrome) about the highlighter
// selection and state.
interface HighlighterControllerClient {
// Called when when a valid selection is made. Selected rectangle is in
// screen coordinates, clipped to screen bounds if necessary.
HandleSelection(gfx.mojom.Rect rect);
// Called when the highlighter tool becomes enabled or disabled.
HandleEnabledStateChange(bool enabled);
};
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