1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63

ash / public / cpp / event_rewriter_controller.h [blame]

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_PUBLIC_CPP_EVENT_REWRITER_CONTROLLER_H_
#define ASH_PUBLIC_CPP_EVENT_REWRITER_CONTROLLER_H_

#include <memory>

#include "ash/ash_export.h"
#include "ui/events/ash/event_rewriter_ash.h"

namespace ui {
class Event;
class EventRewriter;
}  // namespace ui

namespace ash {

class AccessibilityEventRewriterDelegate;

// Allows clients to toggle some event rewriting behavior.
class ASH_EXPORT EventRewriterController {
 public:
  // Returns the singleton EventRewriterController instance.
  static EventRewriterController* Get();

  // Initializes this controller after ash::Shell finishes initialization.
  virtual void Initialize(
      ui::EventRewriterAsh::Delegate* event_rewriter_delegate,
      AccessibilityEventRewriterDelegate*
          accessibility_event_rewriter_delegate) = 0;

  // Takes ownership of |rewriter| and adds it to the current event sources.
  virtual void AddEventRewriter(
      std::unique_ptr<ui::EventRewriter> rewriter) = 0;

  // Enables the KeyboardDrivenEventRewriter, which is disabled by default.
  // This only applies when the user is on the login screen.
  virtual void SetKeyboardDrivenEventRewriterEnabled(bool enabled) = 0;

  // If true, Shift + Arrow keys are rewritten to Tab/Shift-Tab keys.
  // This only applies when the KeyboardDrivenEventRewriter is active.
  virtual void SetArrowToTabRewritingEnabled(bool enabled) = 0;

  // Continue dispatch of key events that were unhandled by ChromeVox.
  // TODO(crbug.com/41386990): ChromeVox should not repost unhandled events.
  virtual void OnUnhandledSpokenFeedbackEvent(
      std::unique_ptr<ui::Event> event) = 0;

  // Discards key events and sends to spoken feedback when true.
  virtual void CaptureAllKeysForSpokenFeedback(bool capture) = 0;

  // Sends mouse events to accessibility component extensions when true.
  virtual void SetSendMouseEvents(bool value) = 0;

 protected:
  virtual ~EventRewriterController() {}
};

}  // namespace ash

#endif  // ASH_PUBLIC_CPP_EVENT_REWRITER_CONTROLLER_H_