Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / chromeos / input_method / mode_indicator_controller.h
blob0c7c196f88d781de49c50450a04cd6248828e539
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/base/ime/chromeos/input_method_manager.h"
10 #include "ui/gfx/geometry/rect.h"
11 #include "ui/views/widget/widget_observer.h"
13 namespace chromeos {
14 namespace input_method {
16 class ModeIndicatorObserverInterface : public views::WidgetObserver {
17 public:
18 ModeIndicatorObserverInterface() {}
19 ~ModeIndicatorObserverInterface() override {}
21 virtual void AddModeIndicatorWidget(views::Widget* widget) = 0;
25 // ModeIndicatorController is the controller of ModeIndicatiorDelegateView
26 // on the MVC model.
27 class ModeIndicatorController
28 : public InputMethodManager::Observer {
29 public:
30 // This class takes the ownership of |mi_widget|.
31 explicit ModeIndicatorController(InputMethodManager* imm);
32 ~ModeIndicatorController() override;
34 // Set cursor bounds, which is the base point to display this indicator.
35 // Bacisally this indicator is displayed underneath the cursor.
36 void SetCursorBounds(const gfx::Rect& cursor_location);
38 // Notify the focus state to the mode indicator.
39 void FocusStateChanged(bool is_focused);
41 // Accessor of the widget observer for testing. The caller keeps the
42 // ownership of the observer object.
43 static void SetModeIndicatorObserverForTesting(
44 ModeIndicatorObserverInterface* observer);
45 static ModeIndicatorObserverInterface* GetModeIndicatorObserverForTesting();
47 private:
48 // InputMethodManager::Observer implementation.
49 void InputMethodChanged(InputMethodManager* manager,
50 Profile* profile,
51 bool show_message) override;
53 // Show the mode inidicator with the current ime's short name if all
54 // the conditions are cleared.
55 void ShowModeIndicator();
57 InputMethodManager* imm_;
59 // Cursor bounds representing the anchor rect of the mode indicator.
60 gfx::Rect cursor_bounds_;
62 // True on a text field is focused.
63 bool is_focused_;
65 // Observer of the widgets created by BubbleDelegateView. This is used to
66 // close the previous widget when a new widget is created.
67 scoped_ptr<ModeIndicatorObserverInterface> mi_observer_;
69 DISALLOW_COPY_AND_ASSIGN(ModeIndicatorController);
72 } // namespace input_method
73 } // namespace chromeos
75 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_MODE_INDICATOR_CONTROLLER_H_