forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeyboard_ui.h
99 lines (76 loc) · 3.47 KB
/
keyboard_ui.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
92
93
94
95
96
97
98
99
// Copyright 2015 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 UI_KEYBOARD_KEYBOARD_UI_H_
#define UI_KEYBOARD_KEYBOARD_UI_H_
#include "base/macros.h"
#include "ui/base/ime/text_input_type.h"
#include "ui/keyboard/keyboard_export.h"
namespace aura {
class Window;
}
namespace gfx {
class Rect;
}
namespace ui {
class InputMethod;
}
namespace keyboard {
class KeyboardController;
// An interface implemented by an object that implements a keyboard UI.
class KEYBOARD_EXPORT KeyboardUI {
public:
KeyboardUI();
virtual ~KeyboardUI();
// Gets the virtual keyboard window. May return null if the window has not yet
// been created.
virtual aura::Window* GetKeyboardWindow() = 0;
// Whether the keyboard window has been created.
virtual bool HasKeyboardWindow() const = 0;
// Whether this window should do an overscroll to avoid occlusion by the
// virtual keyboard. IME windows and virtual keyboard windows should always
// avoid overscroll.
virtual bool ShouldWindowOverscroll(aura::Window* window) const = 0;
// Gets the InputMethod that will provide notifications about changes in the
// text input context.
virtual ui::InputMethod* GetInputMethod() = 0;
// Shows the container window of the keyboard. The default implementation
// simply shows the container. An overridden implementation can set up
// necessary animation, or delay the visibility change as it desires.
virtual void ShowKeyboardContainer(aura::Window* container);
// Hides the container window of the keyboard. The default implementation
// simply hides the container. An overridden implementation can set up
// necesasry animation, or delay the visibility change as it desires.
virtual void HideKeyboardContainer(aura::Window* container);
// Updates the type of the focused text input box.
virtual void SetUpdateInputType(ui::TextInputType type) = 0;
// Ensures caret in current work area (not occluded by virtual keyboard
// window).
virtual void EnsureCaretInWorkArea();
// KeyboardController owns the KeyboardUI instance so KeyboardUI subclasses
// should not take ownership of the |controller|. |controller| can be null
// when KeyboardController is destroying.
virtual void SetController(KeyboardController* controller);
// Reloads virtual keyboard URL if the current keyboard's web content URL is
// different. The URL can be different if user switch from password field to
// any other type input field.
// At password field, the system virtual keyboard is forced to load even if
// the current IME provides a customized virtual keyboard. This is needed to
// prevent IME virtual keyboard logging user's password. Once user switch to
// other input fields, the virtual keyboard should switch back to the IME
// provided keyboard, or keep using the system virtual keyboard if IME doesn't
// provide one.
virtual void ReloadKeyboardIfNeeded() = 0;
// When the embedder changes the keyboard bounds, asks the keyboard to adjust
// insets for windows affected by this.
virtual void InitInsets(const gfx::Rect& keyboard_bounds) = 0;
// Resets insets for affected windows.
virtual void ResetInsets() = 0;
protected:
KeyboardController* keyboard_controller() { return keyboard_controller_; }
private:
keyboard::KeyboardController* keyboard_controller_;
DISALLOW_COPY_AND_ASSIGN(KeyboardUI);
};
} // namespace keyboard
#endif // UI_KEYBOARD_KEYBOARD_UI_H_