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 "base/memory/scoped_ptr.h"
11 #include "base/observer_list.h"
12 #include "ui/base/ime/chromeos/ime_bridge.h"
13 #include "ui/base/ime/infolist_entry.h"
14 #include "ui/chromeos/ime/candidate_window_view.h"
15 #include "ui/views/widget/widget_observer.h"
18 class CandidateWindow
;
30 namespace input_method
{
32 class DelayableWidget
;
33 class ModeIndicatorController
;
35 // The implementation of CandidateWindowController.
36 // CandidateWindowController controls the CandidateWindow.
37 class CandidateWindowControllerImpl
38 : public CandidateWindowController
,
39 public ui::ime::CandidateWindowView::Observer
,
40 public views::WidgetObserver
,
41 public IMECandidateWindowHandlerInterface
{
43 CandidateWindowControllerImpl();
44 ~CandidateWindowControllerImpl() override
;
46 // CandidateWindowController overrides:
47 void AddObserver(CandidateWindowController::Observer
* observer
) override
;
48 void RemoveObserver(CandidateWindowController::Observer
* observer
) override
;
52 static void ConvertLookupTableToInfolistEntry(
53 const ui::CandidateWindow
& candidate_window
,
54 std::vector
<ui::InfolistEntry
>* infolist_entries
,
55 bool* has_highlighted
);
58 // ui::ime::CandidateWindowView::Observer implementation.
59 void OnCandidateCommitted(int index
) override
;
61 // views::WidgetObserver implementation.
62 void OnWidgetClosing(views::Widget
* widget
) override
;
64 // IMECandidateWindowHandlerInterface implementation.
65 void SetCursorBounds(const gfx::Rect
& cursor_bounds
,
66 const gfx::Rect
& composition_head
) override
;
67 void UpdateLookupTable(const ui::CandidateWindow
& candidate_window
,
68 bool visible
) override
;
69 void UpdatePreeditText(const base::string16
& text
,
71 bool visible
) override
;
72 void FocusStateChanged(bool is_focused
) override
;
74 void InitCandidateWindowView();
76 // The candidate window view.
77 ui::ime::CandidateWindowView
* candidate_window_view_
;
79 // This is the outer frame of the infolist window view. Owned by the widget.
80 ui::ime::InfolistWindow
* infolist_window_
;
82 gfx::Rect cursor_bounds_
;
83 gfx::Rect composition_head_
;
85 // This is the controller of the IME mode indicator.
86 scoped_ptr
<ModeIndicatorController
> mode_indicator_controller_
;
88 // The infolist entries and its focused index which currently shown in
90 std::vector
<ui::InfolistEntry
> latest_infolist_entries_
;
92 ObserverList
<CandidateWindowController::Observer
> observers_
;
94 DISALLOW_COPY_AND_ASSIGN(CandidateWindowControllerImpl
);
97 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_CANDIDATE_WINDOW_CONTROLLER_IMPL_H_
99 } // namespace input_method
100 } // namespace chromeos