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.
5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
8 #include "chrome/browser/chromeos/input_method/candidate_window_controller.h"
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/ibus_bridge.h"
14 #include "ui/base/ime/infolist_entry.h"
15 #include "ui/views/widget/widget_observer.h"
24 class CandidateWindow
;
32 namespace input_method
{
34 class DelayableWidget
;
35 class ModeIndicatorController
;
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 IBusPanelCandidateWindowHandlerInterface
{
45 CandidateWindowControllerImpl();
46 virtual ~CandidateWindowControllerImpl();
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
;
56 static void ConvertLookupTableToInfolistEntry(
57 const ui::CandidateWindow
& candidate_window
,
58 std::vector
<ui::InfolistEntry
>* infolist_entries
,
59 bool* has_highlighted
);
62 // ash::ime::CandidateWindowView::Observer implementation.
63 virtual void OnCandidateCommitted(int index
) OVERRIDE
;
65 // views::WidgetObserver implementation.
66 virtual void OnWidgetClosing(views::Widget
* widget
) OVERRIDE
;
68 // IBusPanelCandidateWindowHandlerInterface 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 std::string
& utf8_text
,
75 unsigned int cursor
, bool visible
) OVERRIDE
;
76 virtual void FocusStateChanged(bool is_focused
) OVERRIDE
;
78 void InitCandidateWindowView();
80 // The candidate window view.
81 ash::ime::CandidateWindowView
* candidate_window_view_
;
83 // This is the outer frame of the infolist window view. Owned by the widget.
84 ash::ime::InfolistWindow
* infolist_window_
;
86 gfx::Rect cursor_bounds_
;
87 gfx::Rect composition_head_
;
89 // This is the controller of the IME mode indicator.
90 scoped_ptr
<ModeIndicatorController
> mode_indicator_controller_
;
92 // The infolist entries and its focused index which currently shown in
94 std::vector
<ui::InfolistEntry
> latest_infolist_entries_
;
96 ObserverList
<CandidateWindowController::Observer
> observers_
;
98 DISALLOW_COPY_AND_ASSIGN(CandidateWindowControllerImpl
);
101 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
103 } // namespace input_method
104 } // namespace chromeos