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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_DELEGATE_H_
#define EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_DELEGATE_H_
#include <optional>
#include <set>
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/values.h"
#include "extensions/common/api/virtual_keyboard.h"
#include "extensions/common/api/virtual_keyboard_private.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
class ClipboardHistoryItem;
} // namespace ash
namespace extensions {
class VirtualKeyboardDelegate {
public:
virtual ~VirtualKeyboardDelegate() = default;
using OnKeyboardSettingsCallback =
base::OnceCallback<void(std::optional<base::Value::Dict> settings)>;
using OnSetModeCallback = base::OnceCallback<void(bool success)>;
using OnGetClipboardHistoryCallback =
base::OnceCallback<void(std::vector<ash::ClipboardHistoryItem> history)>;
using OnRestrictFeaturesCallback = base::OnceCallback<void(
api::virtual_keyboard::FeatureRestrictions update)>;
// Fetch information about the preferred configuration of the keyboard. On
// exit, |settings| is populated with the keyboard configuration if execution
// is successful, otherwise it's set to nullptr.
virtual void GetKeyboardConfig(
OnKeyboardSettingsCallback on_settings_callback) = 0;
// Notify keyboard config change through
// |chrome.virtualKeyboard.onKeyboardConfigChanged| event.
virtual void OnKeyboardConfigChanged() = 0;
// Dismiss the virtual keyboard without changing input focus. Returns true if
// successful.
virtual bool HideKeyboard() = 0;
// Insert |text| verbatim into a text area. Returns true if successful.
virtual bool InsertText(const std::u16string& text) = 0;
// Notifiy system that keyboard loading is complete. Used in UMA stats to
// track loading performance. Returns true if the notification was handled.
virtual bool OnKeyboardLoaded() = 0;
// Indicate if settings are accessible and enabled based on current state.
// For example, settings should be blocked when the session is locked.
virtual bool IsSettingsEnabled() = 0;
// Sets the state of the hotrod virtual keyboad.
virtual void SetHotrodKeyboard(bool enable) = 0;
// Activate and lock the virtual keyboad on screen or dismiss the keyboard
// regardless of the state of text focus. Used in a11y mode to allow typing
// hotkeys without the need for text focus. Returns true if successful.
virtual bool LockKeyboard(bool state) = 0;
// Dispatches a virtual key event. |type| indicates if the event is a keydown
// or keyup event. |char_value| is the unicode value for the key. |key_code|
// is the code assigned to the key, which is independent of the state of
// modifier keys. |key_name| is the standardized w3c name for the key.
// |modifiers| indicates which modifier keys are active. Returns true if
// successful.
virtual bool SendKeyEvent(const std::string& type,
int char_value,
int key_code,
const std::string& key_name,
int modifiers) = 0;
// Launches the settings app. Returns true if successful.
virtual bool ShowLanguageSettings() = 0;
// Launches Suggestions page in settings app. Retusn true is successful.
virtual bool ShowSuggestionSettings() = 0;
// Sets virtual keyboard window mode.
virtual bool SetVirtualKeyboardMode(
api::virtual_keyboard_private::KeyboardMode mode_enum,
gfx::Rect target_bounds,
OnSetModeCallback on_set_mode_callback) = 0;
// Sets virtual keyboard draggable area bounds.
// Returns whether the draggable area is set successful.
virtual bool SetDraggableArea(
const api::virtual_keyboard_private::Bounds& bounds) = 0;
// Sets requested virtual keyboard state.
virtual bool SetRequestedKeyboardState(
api::virtual_keyboard_private::KeyboardState state) = 0;
// Sets the area on the screen that is occluded by the keyboard.
virtual bool SetOccludedBounds(const std::vector<gfx::Rect>& bounds) = 0;
// Sets the areas on the keyboard window where events are handled.
virtual bool SetHitTestBounds(const std::vector<gfx::Rect>& bounds) = 0;
// Sets the area of the keyboard window that should remain on screen
// whenever the user moves the keyboard around their screen.
virtual bool SetAreaToRemainOnScreen(const gfx::Rect& bounds) = 0;
// Sets the bounds of the keyboard window in screen coordinates.
virtual bool SetWindowBoundsInScreen(const gfx::Rect& bounds_in_screen) = 0;
// Calls the |get_history_callback| function and passes a value containing the
// current cipboard history items.
virtual void GetClipboardHistory(
OnGetClipboardHistoryCallback get_history_callback) = 0;
// Paste a clipboard item from the clipboard history. Returns whether the
// paste is successful.
virtual bool PasteClipboardItem(const std::string& clipboard_item_id) = 0;
// Delete a clipboard item from the clipboard history. Returns whether the
// deletion is successful.
virtual bool DeleteClipboardItem(const std::string& clipboard_item_id) = 0;
// Restricts the virtual keyboard IME features.
// callback is called with the values which were updated.
virtual void RestrictFeatures(
const api::virtual_keyboard::RestrictFeatures::Params& params,
OnRestrictFeaturesCallback callback) = 0;
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_DELEGATE_H_
|