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

Side by Side Diff: ash/system/ime/tray_ime_chromeos.cc

Issue 843603004: Moves smart deploy UI into the IME tray. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unsplit. Remove IME tray in Linux. Created 5 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
« no previous file with comments | « ash/system/ime/tray_ime_chromeos.h ('k') | ash/system/ime/tray_ime_chromeos_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ash/system/ime/tray_ime.h" 5 #include "ash/system/ime/tray_ime_chromeos.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/metrics/user_metrics_recorder.h" 9 #include "ash/metrics/user_metrics_recorder.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/session/session_state_delegate.h" 11 #include "ash/session/session_state_delegate.h"
12 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/system/tray/hover_highlight_view.h" 14 #include "ash/system/tray/hover_highlight_view.h"
15 #include "ash/system/tray/system_tray.h" 15 #include "ash/system/tray/system_tray.h"
16 #include "ash/system/tray/system_tray_delegate.h" 16 #include "ash/system/tray/system_tray_delegate.h"
17 #include "ash/system/tray/system_tray_notifier.h" 17 #include "ash/system/tray/system_tray_notifier.h"
18 #include "ash/system/tray/tray_constants.h" 18 #include "ash/system/tray/tray_constants.h"
19 #include "ash/system/tray/tray_details_view.h" 19 #include "ash/system/tray/tray_details_view.h"
20 #include "ash/system/tray/tray_item_more.h" 20 #include "ash/system/tray/tray_item_more.h"
21 #include "ash/system/tray/tray_item_view.h" 21 #include "ash/system/tray/tray_item_view.h"
22 #include "ash/system/tray/tray_utils.h" 22 #include "ash/system/tray/tray_utils.h"
23 #include "ash/system/tray_accessibility.h"
24 #include "ash/virtual_keyboard_controller.h"
23 #include "base/logging.h" 25 #include "base/logging.h"
24 #include "base/strings/utf_string_conversions.h" 26 #include "base/strings/utf_string_conversions.h"
25 #include "grit/ash_resources.h" 27 #include "grit/ash_resources.h"
26 #include "grit/ash_strings.h" 28 #include "grit/ash_strings.h"
27 #include "ui/accessibility/ax_enums.h" 29 #include "ui/accessibility/ax_enums.h"
28 #include "ui/accessibility/ax_view_state.h" 30 #include "ui/accessibility/ax_view_state.h"
29 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
30 #include "ui/gfx/font.h" 32 #include "ui/gfx/font.h"
31 #include "ui/gfx/image/image.h" 33 #include "ui/gfx/image/image.h"
34 #include "ui/keyboard/keyboard_util.h"
32 #include "ui/views/controls/label.h" 35 #include "ui/views/controls/label.h"
33 #include "ui/views/layout/box_layout.h" 36 #include "ui/views/layout/box_layout.h"
34 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
35 38
36 namespace ash { 39 namespace ash {
37 namespace tray { 40 namespace tray {
38 41
39 // A |HoverHighlightView| that uses bold or normal font depending on whetehr 42 // A |HoverHighlightView| that uses bold or normal font depending on whether
40 // it is selected. This view exposes itself as a checkbox to the accessibility 43 // it is selected. This view exposes itself as a checkbox to the accessibility
41 // framework. 44 // framework.
42 class SelectableHoverHighlightView : public HoverHighlightView { 45 class SelectableHoverHighlightView : public HoverHighlightView {
43 public: 46 public:
44 SelectableHoverHighlightView(ViewClickListener* listener, 47 SelectableHoverHighlightView(ViewClickListener* listener,
45 const base::string16& label, 48 const base::string16& label,
46 bool selected) 49 bool selected)
47 : HoverHighlightView(listener), selected_(selected) { 50 : HoverHighlightView(listener), selected_(selected) {
48 AddLabel( 51 AddLabel(label,
49 label, gfx::ALIGN_LEFT, selected ? gfx::Font::BOLD : gfx::Font::NORMAL); 52 gfx::ALIGN_LEFT,
53 selected ? gfx::Font::BOLD : gfx::Font::NORMAL);
50 } 54 }
51 55
52 ~SelectableHoverHighlightView() override {} 56 ~SelectableHoverHighlightView() override {}
53 57
54 protected: 58 protected:
55 // Overridden from views::View. 59 // Overridden from views::View.
56 void GetAccessibleState(ui::AXViewState* state) override { 60 void GetAccessibleState(ui::AXViewState* state) override {
57 HoverHighlightView::GetAccessibleState(state); 61 HoverHighlightView::GetAccessibleState(state);
58 state->role = ui::AX_ROLE_CHECK_BOX; 62 state->role = ui::AX_ROLE_CHECK_BOX;
59 if (selected_) 63 if (selected_)
60 state->AddStateFlag(ui::AX_STATE_CHECKED); 64 state->AddStateFlag(ui::AX_STATE_CHECKED);
61 } 65 }
62 66
63 private: 67 private:
64 bool selected_; 68 bool selected_;
65 69
66 DISALLOW_COPY_AND_ASSIGN(SelectableHoverHighlightView); 70 DISALLOW_COPY_AND_ASSIGN(SelectableHoverHighlightView);
67 }; 71 };
68 72
69 class IMEDefaultView : public TrayItemMore { 73 class IMEDefaultView : public TrayItemMore {
70 public: 74 public:
71 explicit IMEDefaultView(SystemTrayItem* owner) 75 explicit IMEDefaultView(SystemTrayItem* owner, const base::string16& label)
72 : TrayItemMore(owner, true) { 76 : TrayItemMore(owner, true) {
73 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 77 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
74 78 SetImage(bundle.GetImageNamed(IDR_AURA_UBER_TRAY_IME).ToImageSkia());
75 SetImage(bundle.GetImageNamed( 79 UpdateLabel(label);
76 IDR_AURA_UBER_TRAY_IME).ToImageSkia());
77
78 IMEInfo info;
79 Shell::GetInstance()->system_tray_delegate()->GetCurrentIME(&info);
80 UpdateLabel(info);
81 } 80 }
82 81
83 ~IMEDefaultView() override {} 82 ~IMEDefaultView() override {}
84 83
85 void UpdateLabel(const IMEInfo& info) { 84 void UpdateLabel(const base::string16& label) {
86 SetLabel(info.name); 85 SetLabel(label);
87 SetAccessibleName(info.name); 86 SetAccessibleName(label);
88 } 87 }
89 88
90 private: 89 private:
91 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); 90 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView);
92 }; 91 };
93 92
94 class IMEDetailedView : public TrayDetailsView, 93 class IMEDetailedView : public TrayDetailsView, public ViewClickListener {
95 public ViewClickListener {
96 public: 94 public:
97 IMEDetailedView(SystemTrayItem* owner, user::LoginStatus login) 95 IMEDetailedView(SystemTrayItem* owner,
98 : TrayDetailsView(owner), 96 user::LoginStatus login,
99 login_(login) { 97 bool show_keyboard_toggle)
98 : TrayDetailsView(owner), login_(login) {
100 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); 99 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
101 IMEInfoList list; 100 IMEInfoList list;
102 delegate->GetAvailableIMEList(&list); 101 delegate->GetAvailableIMEList(&list);
103 IMEPropertyInfoList property_list; 102 IMEPropertyInfoList property_list;
104 delegate->GetCurrentIMEProperties(&property_list); 103 delegate->GetCurrentIMEProperties(&property_list);
105 Update(list, property_list); 104 Update(list, property_list, show_keyboard_toggle);
106 } 105 }
107 106
108 ~IMEDetailedView() override {} 107 ~IMEDetailedView() override {}
109 108
110 void Update(const IMEInfoList& list, 109 void Update(const IMEInfoList& list,
111 const IMEPropertyInfoList& property_list) { 110 const IMEPropertyInfoList& property_list,
111 bool show_keyboard_toggle) {
112 Reset(); 112 Reset();
113 ime_map_.clear();
114 property_map_.clear();
115 CreateScrollableList();
113 116
114 AppendIMEList(list); 117 if (list.size() > 1)
115 if (!property_list.empty()) 118 AppendIMEList(list);
119 if (property_list.size() > 1)
116 AppendIMEProperties(property_list); 120 AppendIMEProperties(property_list);
121
122 if (show_keyboard_toggle) {
123 if (list.size() > 1 || property_list.size() > 1)
124 AddScrollSeparator();
125 AppendKeyboardStatus();
126 }
127
117 bool userAddingRunning = ash::Shell::GetInstance() 128 bool userAddingRunning = ash::Shell::GetInstance()
118 ->session_state_delegate() 129 ->session_state_delegate()
119 ->IsInSecondaryLoginScreen(); 130 ->IsInSecondaryLoginScreen();
120
121 if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED && 131 if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED &&
122 !userAddingRunning) 132 !userAddingRunning)
123 AppendSettings(); 133 AppendSettings();
124 AppendHeaderEntry(); 134 AppendHeaderEntry();
125 135
126 Layout(); 136 Layout();
127 SchedulePaint(); 137 SchedulePaint();
128 } 138 }
129 139
130 private: 140 private:
131 void AppendHeaderEntry() { 141 void AppendHeaderEntry() { CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); }
132 CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this);
133 }
134 142
143 // Appends the IMEs to the scrollable area of the detailed view.
135 void AppendIMEList(const IMEInfoList& list) { 144 void AppendIMEList(const IMEInfoList& list) {
136 ime_map_.clear(); 145 DCHECK(ime_map_.empty());
137 CreateScrollableList();
138 for (size_t i = 0; i < list.size(); i++) { 146 for (size_t i = 0; i < list.size(); i++) {
139 HoverHighlightView* container = new SelectableHoverHighlightView( 147 HoverHighlightView* container = new SelectableHoverHighlightView(
140 this, list[i].name, list[i].selected); 148 this, list[i].name, list[i].selected);
141 scroll_content()->AddChildView(container); 149 scroll_content()->AddChildView(container);
142 ime_map_[container] = list[i].id; 150 ime_map_[container] = list[i].id;
143 } 151 }
144 } 152 }
145 153
154 // Appends the IME listed to the scrollable area of the detailed
155 // view.
146 void AppendIMEProperties(const IMEPropertyInfoList& property_list) { 156 void AppendIMEProperties(const IMEPropertyInfoList& property_list) {
147 property_map_.clear(); 157 DCHECK(property_map_.empty());
148 for (size_t i = 0; i < property_list.size(); i++) { 158 for (size_t i = 0; i < property_list.size(); i++) {
149 HoverHighlightView* container = new SelectableHoverHighlightView( 159 HoverHighlightView* container = new SelectableHoverHighlightView(
150 this, property_list[i].name, property_list[i].selected); 160 this, property_list[i].name, property_list[i].selected);
151 if (i == 0) 161 if (i == 0)
152 container->SetBorder(views::Border::CreateSolidSidedBorder( 162 container->SetBorder(views::Border::CreateSolidSidedBorder(
153 1, 0, 0, 0, kBorderLightColor)); 163 1, 0, 0, 0, kBorderLightColor));
154 scroll_content()->AddChildView(container); 164 scroll_content()->AddChildView(container);
155 property_map_[container] = property_list[i].key; 165 property_map_[container] = property_list[i].key;
156 } 166 }
157 } 167 }
158 168
169 void AppendKeyboardStatus() {
170 HoverHighlightView* container = new HoverHighlightView(this);
171 int id = keyboard::IsKeyboardEnabled()
172 ? IDS_ASH_STATUS_TRAY_DISABLE_KEYBOARD
173 : IDS_ASH_STATUS_TRAY_ENABLE_KEYBOARD;
174 container->AddLabel(
175 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id),
176 gfx::ALIGN_LEFT,
177 gfx::Font::NORMAL);
178 scroll_content()->AddChildView(container);
179 keyboard_status_ = container;
180 }
181
159 void AppendSettings() { 182 void AppendSettings() {
160 HoverHighlightView* container = new HoverHighlightView(this); 183 HoverHighlightView* container = new HoverHighlightView(this);
161 container->AddLabel( 184 container->AddLabel(
162 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 185 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
163 IDS_ASH_STATUS_TRAY_IME_SETTINGS), 186 IDS_ASH_STATUS_TRAY_IME_SETTINGS),
164 gfx::ALIGN_LEFT, 187 gfx::ALIGN_LEFT,
165 gfx::Font::NORMAL); 188 gfx::Font::NORMAL);
166 AddChildView(container); 189 AddChildView(container);
167 settings_ = container; 190 settings_ = container;
168 } 191 }
169 192
170 // Overridden from ViewClickListener. 193 // Overridden from ViewClickListener.
171 void OnViewClicked(views::View* sender) override { 194 void OnViewClicked(views::View* sender) override {
172 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); 195 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
173 if (sender == footer()->content()) { 196 if (sender == footer()->content()) {
174 TransitionToDefaultView(); 197 TransitionToDefaultView();
175 } else if (sender == settings_) { 198 } else if (sender == settings_) {
176 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 199 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
177 ash::UMA_STATUS_AREA_IME_SHOW_DETAILED); 200 ash::UMA_STATUS_AREA_IME_SHOW_DETAILED);
178 delegate->ShowIMESettings(); 201 delegate->ShowIMESettings();
202 } else if (sender == keyboard_status_) {
203 Shell::GetInstance()->virtual_keyboard_controller()
204 ->ToggleIgnoreExternalKeyboard();
179 } else { 205 } else {
180 std::map<views::View*, std::string>::const_iterator ime_find; 206 std::map<views::View*, std::string>::const_iterator ime_find;
181 ime_find = ime_map_.find(sender); 207 ime_find = ime_map_.find(sender);
182 if (ime_find != ime_map_.end()) { 208 if (ime_find != ime_map_.end()) {
183 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 209 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
184 ash::UMA_STATUS_AREA_IME_SWITCH_MODE); 210 ash::UMA_STATUS_AREA_IME_SWITCH_MODE);
185 std::string ime_id = ime_find->second; 211 std::string ime_id = ime_find->second;
186 delegate->SwitchIME(ime_id); 212 delegate->SwitchIME(ime_id);
187 GetWidget()->Close(); 213 GetWidget()->Close();
188 } else { 214 } else {
189 std::map<views::View*, std::string>::const_iterator prop_find; 215 std::map<views::View*, std::string>::const_iterator prop_find;
190 prop_find = property_map_.find(sender); 216 prop_find = property_map_.find(sender);
191 if (prop_find != property_map_.end()) { 217 if (prop_find != property_map_.end()) {
192 const std::string key = prop_find->second; 218 const std::string key = prop_find->second;
193 delegate->ActivateIMEProperty(key); 219 delegate->ActivateIMEProperty(key);
194 GetWidget()->Close(); 220 GetWidget()->Close();
195 } 221 }
196 } 222 }
197 } 223 }
198 } 224 }
199 225
200 user::LoginStatus login_; 226 user::LoginStatus login_;
201 227
202 std::map<views::View*, std::string> ime_map_; 228 std::map<views::View*, std::string> ime_map_;
203 std::map<views::View*, std::string> property_map_; 229 std::map<views::View*, std::string> property_map_;
204 views::View* settings_; 230 views::View* settings_;
231 views::View* keyboard_status_;
205 232
206 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); 233 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView);
207 }; 234 };
208 235
209 } // namespace tray 236 } // namespace tray
210 237
211 TrayIME::TrayIME(SystemTray* system_tray) 238 TrayIME::TrayIME(SystemTray* system_tray)
212 : SystemTrayItem(system_tray), 239 : SystemTrayItem(system_tray),
213 tray_label_(NULL), 240 tray_label_(NULL),
214 default_(NULL), 241 default_(NULL),
215 detailed_(NULL) { 242 detailed_(NULL),
243 keyboard_suppressed_(false) {
216 Shell::GetInstance()->system_tray_notifier()->AddIMEObserver(this); 244 Shell::GetInstance()->system_tray_notifier()->AddIMEObserver(this);
245 Shell::GetInstance()->system_tray_notifier()->AddVirtualKeyboardObserver(
246 this);
247 Shell::GetInstance()->system_tray_notifier()->AddAccessibilityObserver(this);
217 } 248 }
218 249
219 TrayIME::~TrayIME() { 250 TrayIME::~TrayIME() {
220 Shell::GetInstance()->system_tray_notifier()->RemoveIMEObserver(this); 251 Shell::GetInstance()->system_tray_notifier()->RemoveIMEObserver(this);
252 Shell::GetInstance()->system_tray_notifier()->RemoveAccessibilityObserver(
253 this);
254 Shell::GetInstance()->system_tray_notifier()->RemoveVirtualKeyboardObserver(
255 this);
256 }
257
258 void TrayIME::OnKeyboardSuppressionChanged(bool suppressed) {
259 keyboard_suppressed_ = suppressed;
260 Update();
261 }
262
263 void TrayIME::OnAccessibilityModeChanged(
264 ui::AccessibilityNotificationVisibility notify) {
265 Update();
266 }
267
268 void TrayIME::Update() {
269 UpdateTrayLabel(current_ime_, ime_list_.size());
270 if (default_) {
271 default_->SetVisible(ShouldDefaultViewBeVisible());
272 default_->UpdateLabel(GetDefaultViewLabel(ime_list_.size() > 1));
273 }
274 if (detailed_)
275 detailed_->Update(ime_list_, property_list_, ShouldShowKeyboardToggle());
221 } 276 }
222 277
223 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) { 278 void TrayIME::UpdateTrayLabel(const IMEInfo& current, size_t count) {
224 if (tray_label_) { 279 if (tray_label_) {
225 bool visible = count > 1; 280 bool visible = count > 1;
226 tray_label_->SetVisible(visible); 281 tray_label_->SetVisible(visible);
227 // Do not change label before hiding because this change is noticeable. 282 // Do not change label before hiding because this change is noticeable.
228 if (!visible) 283 if (!visible)
229 return; 284 return;
230 if (current.third_party) { 285 if (current.third_party) {
231 tray_label_->label()->SetText( 286 tray_label_->label()->SetText(current.short_name +
232 current.short_name + base::UTF8ToUTF16("*")); 287 base::UTF8ToUTF16("*"));
233 } else { 288 } else {
234 tray_label_->label()->SetText(current.short_name); 289 tray_label_->label()->SetText(current.short_name);
235 } 290 }
236 SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment()); 291 SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment());
237 tray_label_->Layout(); 292 tray_label_->Layout();
238 } 293 }
239 } 294 }
240 295
296 bool TrayIME::ShouldShowKeyboardToggle() {
297 return keyboard_suppressed_ &&
298 !Shell::GetInstance()
299 ->accessibility_delegate()
300 ->IsVirtualKeyboardEnabled();
301 }
302
303 base::string16 TrayIME::GetDefaultViewLabel(bool show_ime_label) {
304 if (show_ime_label) {
305 IMEInfo current;
306 Shell::GetInstance()->system_tray_delegate()->GetCurrentIME(&current);
307 return current.name;
308 } else {
309 // Display virtual keyboard status instead.
310 int id = keyboard::IsKeyboardEnabled()
311 ? IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED
312 : IDS_ASH_STATUS_TRAY_KEYBOARD_DISABLED;
313 return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id);
314 }
315 }
316
241 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { 317 views::View* TrayIME::CreateTrayView(user::LoginStatus status) {
242 CHECK(tray_label_ == NULL); 318 CHECK(tray_label_ == NULL);
243 tray_label_ = new TrayItemView(this); 319 tray_label_ = new TrayItemView(this);
244 tray_label_->CreateLabel(); 320 tray_label_->CreateLabel();
245 SetupLabelForTray(tray_label_->label()); 321 SetupLabelForTray(tray_label_->label());
246 // Hide IME tray when it is created, it will be updated when it is notified 322 // Hide IME tray when it is created, it will be updated when it is notified
247 // for IME refresh event. 323 // of the IME refresh event.
248 tray_label_->SetVisible(false); 324 tray_label_->SetVisible(false);
249 return tray_label_; 325 return tray_label_;
250 } 326 }
251 327
252 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { 328 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) {
253 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
254 IMEInfoList list;
255 IMEPropertyInfoList property_list;
256 delegate->GetAvailableIMEList(&list);
257 delegate->GetCurrentIMEProperties(&property_list);
258 if (list.size() <= 1 && property_list.size() <= 1)
259 return NULL;
260 CHECK(default_ == NULL); 329 CHECK(default_ == NULL);
261 default_ = new tray::IMEDefaultView(this); 330 default_ =
331 new tray::IMEDefaultView(this, GetDefaultViewLabel(ime_list_.size() > 1));
332 default_->SetVisible(ShouldDefaultViewBeVisible());
262 return default_; 333 return default_;
263 } 334 }
264 335
265 views::View* TrayIME::CreateDetailedView(user::LoginStatus status) { 336 views::View* TrayIME::CreateDetailedView(user::LoginStatus status) {
266 CHECK(detailed_ == NULL); 337 CHECK(detailed_ == NULL);
267 detailed_ = new tray::IMEDetailedView(this, status); 338 detailed_ =
339 new tray::IMEDetailedView(this, status, ShouldShowKeyboardToggle());
268 return detailed_; 340 return detailed_;
269 } 341 }
270 342
271 void TrayIME::DestroyTrayView() { 343 void TrayIME::DestroyTrayView() {
272 tray_label_ = NULL; 344 tray_label_ = NULL;
273 } 345 }
274 346
275 void TrayIME::DestroyDefaultView() { 347 void TrayIME::DestroyDefaultView() {
276 default_ = NULL; 348 default_ = NULL;
277 } 349 }
278 350
279 void TrayIME::DestroyDetailedView() { 351 void TrayIME::DestroyDetailedView() {
280 detailed_ = NULL; 352 detailed_ = NULL;
281 } 353 }
282 354
283 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { 355 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) {
284 } 356 }
285 357
286 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 358 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
287 SetTrayLabelItemBorder(tray_label_, alignment); 359 SetTrayLabelItemBorder(tray_label_, alignment);
288 tray_label_->Layout(); 360 tray_label_->Layout();
289 } 361 }
290 362
291 void TrayIME::OnIMERefresh() { 363 void TrayIME::OnIMERefresh() {
364 // Caches the current ime state.
292 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); 365 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate();
293 IMEInfoList list; 366 ime_list_.clear();
294 IMEInfo current; 367 property_list_.clear();
295 IMEPropertyInfoList property_list; 368 delegate->GetCurrentIME(&current_ime_);
296 delegate->GetCurrentIME(&current); 369 delegate->GetAvailableIMEList(&ime_list_);
297 delegate->GetAvailableIMEList(&list); 370 delegate->GetCurrentIMEProperties(&property_list_);
298 delegate->GetCurrentIMEProperties(&property_list);
299 371
300 UpdateTrayLabel(current, list.size()); 372 Update();
373 }
301 374
302 if (default_) 375 bool TrayIME::ShouldDefaultViewBeVisible() {
303 default_->UpdateLabel(current); 376 return ime_list_.size() > 1 || property_list_.size() > 1 ||
304 if (detailed_) 377 ShouldShowKeyboardToggle();
305 detailed_->Update(list, property_list);
306 } 378 }
307 379
308 } // namespace ash 380 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/ime/tray_ime_chromeos.h ('k') | ash/system/ime/tray_ime_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698