blob: 011015e56ae1402a8defb0580c5c4d51cb4061b9 (
plain)
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
|
// Copyright 2016 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_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_
#define CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_
#include "chrome/browser/extensions/api/input_ime/input_ime_event_router_base.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/extension_function.h"
class Profile;
namespace input_method {
class InputMethodEngine;
} // namespace input_method
// The status indicates whether the permission has been granted or denied when
// the IME warning bubble has been closed.
enum class ImeWarningBubblePermissionStatus {
GRANTED,
GRANTED_AND_NEVER_SHOW,
DENIED,
ABORTED
};
namespace extensions {
class InputImeEventRouterBase;
class InputImeEventRouter : public InputImeEventRouterBase {
public:
explicit InputImeEventRouter(Profile* profile);
~InputImeEventRouter() override;
// Gets the input method engine if the extension is active.
input_method::InputMethodEngineBase* GetActiveEngine(
const std::string& extension_id) override;
// Actives the extension with new input method engine, and deletes the
// previous engine if another extension was active.
void SetActiveEngine(const std::string& extension_id);
// Deletes the current input method engine of the specific extension.
void DeleteInputMethodEngine(const std::string& extension_id);
private:
// The active input method engine.
input_method::InputMethodEngine* active_engine_;
DISALLOW_COPY_AND_ASSIGN(InputImeEventRouter);
};
class InputImeCreateWindowFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.createWindow", INPUT_IME_CREATEWINDOW)
protected:
~InputImeCreateWindowFunction() override {}
// ExtensionFunction:
ExtensionFunction::ResponseAction Run() override;
};
class InputImeShowWindowFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.showWindow", INPUT_IME_SHOWWINDOW)
protected:
~InputImeShowWindowFunction() override {}
// ExtensionFunction:
ExtensionFunction::ResponseAction Run() override;
};
class InputImeHideWindowFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.hideWindow", INPUT_IME_HIDEWINDOW)
protected:
~InputImeHideWindowFunction() override {}
// ExtensionFunction:
ExtensionFunction::ResponseAction Run() override;
};
class InputImeActivateFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.activate", INPUT_IME_ACTIVATE)
// During testing we can disable showing a warning bubble by setting this flag
// to true, so that the extension can be activated directly.
static bool disable_bubble_for_testing_;
protected:
~InputImeActivateFunction() override {}
// UIThreadExtensionFunction:
ResponseAction Run() override;
private:
// Called when the user finishes interacting with the warning bubble.
// |status| indicates whether the user allows or denies to activate the
// extension.
void OnPermissionBubbleFinished(ImeWarningBubblePermissionStatus status);
};
class InputImeDeactivateFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("input.ime.deactivate", INPUT_IME_DEACTIVATE)
protected:
~InputImeDeactivateFunction() override {}
// UIThreadExtensionFunction:
ResponseAction Run() override;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_INPUT_IME_INPUT_IME_API_NONCHROMEOS_H_
|