blob: 502ff5a9e296a1e1fc71d2d0a89d3ffc65c912e8 (
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
|
// Copyright 2013 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_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_
#include "base/memory/scoped_ptr.h"
#include "chromeos/ime/input_method_manager.h"
#include "ui/gfx/rect.h"
#include "ui/views/widget/widget_observer.h"
namespace chromeos {
namespace input_method {
class ModeIndicatorObserverInterface : public views::WidgetObserver {
public:
ModeIndicatorObserverInterface() {}
virtual ~ModeIndicatorObserverInterface() {}
virtual void AddModeIndicatorWidget(views::Widget* widget) = 0;
};
// ModeIndicatorController is the controller of ModeIndicatiorDelegateView
// on the MVC model.
class ModeIndicatorController
: public InputMethodManager::Observer {
public:
// This class takes the ownership of |mi_widget|.
explicit ModeIndicatorController(InputMethodManager* imm);
virtual ~ModeIndicatorController();
// Set cursor bounds, which is the base point to display this indicator.
// Bacisally this indicator is displayed underneath the cursor.
void SetCursorBounds(const gfx::Rect& cursor_location);
// Notify the focus state to the mode indicator.
void FocusStateChanged(bool is_focused);
// Accessor of the widget observer for testing. The caller keeps the
// ownership of the observer object.
static void SetModeIndicatorObserverForTesting(
ModeIndicatorObserverInterface* observer);
static ModeIndicatorObserverInterface* GetModeIndicatorObserverForTesting();
private:
// InputMethodManager::Observer implementation.
virtual void InputMethodChanged(InputMethodManager* manager,
bool show_message) override;
// Show the mode inidicator with the current ime's short name if all
// the conditions are cleared.
void ShowModeIndicator();
InputMethodManager* imm_;
// Cursor bounds representing the anchor rect of the mode indicator.
gfx::Rect cursor_bounds_;
// True on a text field is focused.
bool is_focused_;
// Observer of the widgets created by BubbleDelegateView. This is used to
// close the previous widget when a new widget is created.
scoped_ptr<ModeIndicatorObserverInterface> mi_observer_;
DISALLOW_COPY_AND_ASSIGN(ModeIndicatorController);
};
} // namespace input_method
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_
|