-
Notifications
You must be signed in to change notification settings - Fork 6.6k
/
assistive_window_controller.h
91 lines (74 loc) · 3.53 KB
/
assistive_window_controller.h
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
// Copyright (c) 2020 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.
#ifndef CHROME_BROWSER_ASH_INPUT_METHOD_ASSISTIVE_WINDOW_CONTROLLER_H_
#define CHROME_BROWSER_ASH_INPUT_METHOD_ASSISTIVE_WINDOW_CONTROLLER_H_
#include <memory>
#include "chrome/browser/ash/input_method/assistive_window_properties.h"
#include "chrome/browser/ash/input_method/ui/assistive_accessibility_view.h"
#include "chrome/browser/ash/input_method/ui/assistive_delegate.h"
#include "chrome/browser/ash/input_method/ui/grammar_suggestion_window.h"
#include "chrome/browser/ash/input_method/ui/suggestion_window_view.h"
#include "chrome/browser/ash/input_method/ui/undo_window.h"
#include "ui/base/ime/ash/ime_assistive_window_handler_interface.h"
#include "ui/gfx/native_widget_types.h"
class Profile;
namespace views {
class Widget;
} // namespace views
namespace ash {
namespace input_method {
class AssistiveWindowControllerDelegate;
// AssistiveWindowController controls different assistive windows.
class AssistiveWindowController : public views::WidgetObserver,
public IMEAssistiveWindowHandlerInterface,
public ui::ime::AssistiveDelegate {
public:
explicit AssistiveWindowController(
AssistiveWindowControllerDelegate* delegate,
Profile* profile,
ui::ime::AssistiveAccessibilityView* accessibility_view = nullptr);
AssistiveWindowController(const AssistiveWindowController&) = delete;
AssistiveWindowController& operator=(const AssistiveWindowController&) =
delete;
~AssistiveWindowController() override;
ui::ime::SuggestionWindowView* GetSuggestionWindowViewForTesting();
ui::ime::UndoWindow* GetUndoWindowForTesting() const;
// IMEAssistiveWindowHandlerInterface implementation.
void SetBounds(const Bounds& bounds) override;
void SetAssistiveWindowProperties(
const AssistiveWindowProperties& window) override;
void ShowSuggestion(const ui::ime::SuggestionDetails& details) override;
void SetButtonHighlighted(const ui::ime::AssistiveWindowButton& button,
bool highlighted) override;
void AcceptSuggestion(const std::u16string& suggestion) override;
void HideSuggestion() override;
std::u16string GetSuggestionText() const override;
size_t GetConfirmedLength() const override;
void FocusStateChanged() override;
void OnWidgetDestroying(views::Widget* widget) override;
void Announce(const std::u16string& message) override;
// ui::ime::AssistiveDelegate implementation.
void AssistiveWindowButtonClicked(
const ui::ime::AssistiveWindowButton& button) const override;
private:
ui::ime::SuggestionWindowView::Orientation WindowOrientationFor(
ui::ime::AssistiveWindowType window_type);
void InitSuggestionWindow(
ui::ime::SuggestionWindowView::Orientation orientation);
void InitUndoWindow();
void InitGrammarSuggestionWindow();
void InitAccessibilityView();
const AssistiveWindowControllerDelegate* delegate_;
AssistiveWindowProperties window_;
ui::ime::SuggestionWindowView* suggestion_window_view_ = nullptr;
ui::ime::UndoWindow* undo_window_ = nullptr;
ui::ime::GrammarSuggestionWindow* grammar_suggestion_window_ = nullptr;
ui::ime::AssistiveAccessibilityView* accessibility_view_ = nullptr;
std::u16string suggestion_text_;
size_t confirmed_length_ = 0;
Bounds bounds_;
};
} // namespace input_method
} // namespace ash
#endif // CHROME_BROWSER_ASH_INPUT_METHOD_ASSISTIVE_WINDOW_CONTROLLER_H_