• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
7 
8 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
9 
10 #include "ash/ime/candidate_window_view.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "ui/base/ime/chromeos/ime_bridge.h"
14 #include "ui/base/ime/infolist_entry.h"
15 #include "ui/views/widget/widget_observer.h"
16 
17 namespace ash {
18 namespace ime {
19 class InfolistWindow;
20 }  // namespace ime
21 }  // namespace ash
22 
23 namespace ui {
24 class CandidateWindow;
25 }  // namespace ui
26 
27 namespace views {
28 class Widget;
29 }  // namespace views
30 
31 namespace chromeos {
32 namespace input_method {
33 
34 class DelayableWidget;
35 class ModeIndicatorController;
36 
37 // The implementation of CandidateWindowController.
38 // CandidateWindowController controls the CandidateWindow.
39 class CandidateWindowControllerImpl
40     : public CandidateWindowController,
41       public ash::ime::CandidateWindowView::Observer,
42       public views::WidgetObserver,
43       public IMECandidateWindowHandlerInterface {
44  public:
45   CandidateWindowControllerImpl();
46   virtual ~CandidateWindowControllerImpl();
47 
48   // CandidateWindowController overrides:
49   virtual void AddObserver(
50       CandidateWindowController::Observer* observer) OVERRIDE;
51   virtual void RemoveObserver(
52       CandidateWindowController::Observer* observer) OVERRIDE;
53   virtual void Hide() OVERRIDE;
54 
55  protected:
56   static void ConvertLookupTableToInfolistEntry(
57       const ui::CandidateWindow& candidate_window,
58       std::vector<ui::InfolistEntry>* infolist_entries,
59       bool* has_highlighted);
60 
61  private:
62   // ash::ime::CandidateWindowView::Observer implementation.
63   virtual void OnCandidateCommitted(int index) OVERRIDE;
64 
65   // views::WidgetObserver implementation.
66   virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;
67 
68   // IMECandidateWindowHandlerInterface implementation.
69   virtual void SetCursorBounds(const gfx::Rect& cursor_bounds,
70                                const gfx::Rect& composition_head) OVERRIDE;
71   virtual void UpdateLookupTable(
72       const ui::CandidateWindow& candidate_window,
73       bool visible) OVERRIDE;
74   virtual void UpdatePreeditText(const base::string16& text,
75                                  unsigned int cursor, bool visible) OVERRIDE;
76   virtual void FocusStateChanged(bool is_focused) OVERRIDE;
77 
78   void InitCandidateWindowView();
79 
80   // The candidate window view.
81   ash::ime::CandidateWindowView* candidate_window_view_;
82 
83   // This is the outer frame of the infolist window view. Owned by the widget.
84   ash::ime::InfolistWindow* infolist_window_;
85 
86   gfx::Rect cursor_bounds_;
87   gfx::Rect composition_head_;
88 
89   // This is the controller of the IME mode indicator.
90   scoped_ptr<ModeIndicatorController> mode_indicator_controller_;
91 
92   // The infolist entries and its focused index which currently shown in
93   // Infolist window.
94   std::vector<ui::InfolistEntry> latest_infolist_entries_;
95 
96   ObserverList<CandidateWindowController::Observer> observers_;
97 
98   DISALLOW_COPY_AND_ASSIGN(CandidateWindowControllerImpl);
99 };
100 
101 #endif  // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
102 
103 }  // namespace input_method
104 }  // namespace chromeos
105