Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/chromeos/input_method/candidate_window_controller_impl.cc

Issue 132453002: Moves CandidateWindow model to ui/base/ime (2nd) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl. h" 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl. h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/wm/window_animations.h" 12 #include "ash/wm/window_animations.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" 16 #include "chrome/browser/chromeos/input_method/candidate_window_view.h"
17 #include "chrome/browser/chromeos/input_method/infolist_window.h" 17 #include "chrome/browser/chromeos/input_method/infolist_window.h"
18 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h" 18 #include "chrome/browser/chromeos/input_method/mode_indicator_controller.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
22
23 namespace chromeos { 22 namespace chromeos {
24 namespace input_method { 23 namespace input_method {
25 24
26 namespace { 25 namespace {
27 26
28 } // namespace 27 } // namespace
29 28
30 CandidateWindowControllerImpl::CandidateWindowControllerImpl() 29 CandidateWindowControllerImpl::CandidateWindowControllerImpl()
31 : candidate_window_view_(NULL), 30 : candidate_window_view_(NULL),
32 infolist_window_(NULL) { 31 infolist_window_(NULL) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Mode indicator controller also needs the cursor bounds. 93 // Mode indicator controller also needs the cursor bounds.
95 mode_indicator_controller_->SetCursorBounds(cursor_bounds); 94 mode_indicator_controller_->SetCursorBounds(cursor_bounds);
96 } 95 }
97 96
98 void CandidateWindowControllerImpl::FocusStateChanged(bool is_focused) { 97 void CandidateWindowControllerImpl::FocusStateChanged(bool is_focused) {
99 mode_indicator_controller_->FocusStateChanged(is_focused); 98 mode_indicator_controller_->FocusStateChanged(is_focused);
100 } 99 }
101 100
102 // static 101 // static
103 void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( 102 void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry(
104 const CandidateWindow& candidate_window, 103 const ui::CandidateWindow& candidate_window,
105 std::vector<InfolistEntry>* infolist_entries, 104 std::vector<InfolistEntry>* infolist_entries,
106 bool* has_highlighted) { 105 bool* has_highlighted) {
107 DCHECK(infolist_entries); 106 DCHECK(infolist_entries);
108 DCHECK(has_highlighted); 107 DCHECK(has_highlighted);
109 infolist_entries->clear(); 108 infolist_entries->clear();
110 *has_highlighted = false; 109 *has_highlighted = false;
111 110
112 const size_t cursor_index_in_page = 111 const size_t cursor_index_in_page =
113 candidate_window.cursor_position() % candidate_window.page_size(); 112 candidate_window.cursor_position() % candidate_window.page_size();
114 113
115 for (size_t i = 0; i < candidate_window.candidates().size(); ++i) { 114 for (size_t i = 0; i < candidate_window.candidates().size(); ++i) {
116 const CandidateWindow::Entry& ibus_entry = 115 const ui::CandidateWindow::Entry& ibus_entry =
117 candidate_window.candidates()[i]; 116 candidate_window.candidates()[i];
118 if (ibus_entry.description_title.empty() && 117 if (ibus_entry.description_title.empty() &&
119 ibus_entry.description_body.empty()) 118 ibus_entry.description_body.empty())
120 continue; 119 continue;
121 InfolistEntry entry(base::UTF8ToUTF16(ibus_entry.description_title), 120 InfolistEntry entry(base::UTF8ToUTF16(ibus_entry.description_title),
122 base::UTF8ToUTF16(ibus_entry.description_body)); 121 base::UTF8ToUTF16(ibus_entry.description_body));
123 if (i == cursor_index_in_page) { 122 if (i == cursor_index_in_page) {
124 entry.highlighted = true; 123 entry.highlighted = true;
125 *has_highlighted = true; 124 *has_highlighted = true;
126 } 125 }
127 infolist_entries->push_back(entry); 126 infolist_entries->push_back(entry);
128 } 127 }
129 } 128 }
130 129
131 void CandidateWindowControllerImpl::UpdateLookupTable( 130 void CandidateWindowControllerImpl::UpdateLookupTable(
132 const CandidateWindow& candidate_window, 131 const ui::CandidateWindow& candidate_window,
133 bool visible) { 132 bool visible) {
134 // If it's not visible, hide the lookup table and return. 133 // If it's not visible, hide the lookup table and return.
135 if (!visible) { 134 if (!visible) {
136 if (candidate_window_view_) 135 if (candidate_window_view_)
137 candidate_window_view_->HideLookupTable(); 136 candidate_window_view_->HideLookupTable();
138 if (infolist_window_) 137 if (infolist_window_)
139 infolist_window_->HideImmediately(); 138 infolist_window_->HideImmediately();
140 // TODO(nona): Introduce unittests for crbug.com/170036. 139 // TODO(nona): Introduce unittests for crbug.com/170036.
141 latest_infolist_entries_.clear(); 140 latest_infolist_entries_.clear();
142 return; 141 return;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 observers_.AddObserver(observer); 219 observers_.AddObserver(observer);
221 } 220 }
222 221
223 void CandidateWindowControllerImpl::RemoveObserver( 222 void CandidateWindowControllerImpl::RemoveObserver(
224 CandidateWindowController::Observer* observer) { 223 CandidateWindowController::Observer* observer) {
225 observers_.RemoveObserver(observer); 224 observers_.RemoveObserver(observer);
226 } 225 }
227 226
228 } // namespace input_method 227 } // namespace input_method
229 } // namespace chromeos 228 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698