OLD | NEW |
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_chromeos.h" | 5 #include "ash/system/ime/tray_ime_chromeos.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 SetAccessibleName(label); | 84 SetAccessibleName(label); |
85 } | 85 } |
86 | 86 |
87 private: | 87 private: |
88 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 88 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
89 }; | 89 }; |
90 | 90 |
91 class IMEDetailedView : public TrayDetailsView, public ViewClickListener { | 91 class IMEDetailedView : public TrayDetailsView, public ViewClickListener { |
92 public: | 92 public: |
93 IMEDetailedView(SystemTrayItem* owner, | 93 IMEDetailedView(SystemTrayItem* owner, |
94 user::LoginStatus login, | 94 LoginStatus login, |
95 bool show_keyboard_toggle) | 95 bool show_keyboard_toggle) |
96 : TrayDetailsView(owner), login_(login) { | 96 : TrayDetailsView(owner), login_(login) { |
97 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 97 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
98 IMEInfoList list; | 98 IMEInfoList list; |
99 delegate->GetAvailableIMEList(&list); | 99 delegate->GetAvailableIMEList(&list); |
100 IMEPropertyInfoList property_list; | 100 IMEPropertyInfoList property_list; |
101 delegate->GetCurrentIMEProperties(&property_list); | 101 delegate->GetCurrentIMEProperties(&property_list); |
102 Update(list, property_list, show_keyboard_toggle); | 102 Update(list, property_list, show_keyboard_toggle); |
103 } | 103 } |
104 | 104 |
(...skipping 14 matching lines...) Expand all Loading... |
119 | 119 |
120 if (show_keyboard_toggle) { | 120 if (show_keyboard_toggle) { |
121 if (list.size() > 1 || !property_list.empty()) | 121 if (list.size() > 1 || !property_list.empty()) |
122 AddScrollSeparator(); | 122 AddScrollSeparator(); |
123 AppendKeyboardStatus(); | 123 AppendKeyboardStatus(); |
124 } | 124 } |
125 | 125 |
126 bool userAddingRunning = ash::Shell::GetInstance() | 126 bool userAddingRunning = ash::Shell::GetInstance() |
127 ->session_state_delegate() | 127 ->session_state_delegate() |
128 ->IsInSecondaryLoginScreen(); | 128 ->IsInSecondaryLoginScreen(); |
129 if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED && | 129 if (login_ != LoginStatus::NOT_LOGGED_IN && login_ != LoginStatus::LOCKED && |
130 !userAddingRunning) | 130 !userAddingRunning) |
131 AppendSettings(); | 131 AppendSettings(); |
132 AppendHeaderEntry(); | 132 AppendHeaderEntry(); |
133 | 133 |
134 Layout(); | 134 Layout(); |
135 SchedulePaint(); | 135 SchedulePaint(); |
136 } | 136 } |
137 | 137 |
138 private: | 138 private: |
139 void AppendHeaderEntry() { CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); } | 139 void AppendHeaderEntry() { CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 prop_find = property_map_.find(sender); | 212 prop_find = property_map_.find(sender); |
213 if (prop_find != property_map_.end()) { | 213 if (prop_find != property_map_.end()) { |
214 const std::string key = prop_find->second; | 214 const std::string key = prop_find->second; |
215 delegate->ActivateIMEProperty(key); | 215 delegate->ActivateIMEProperty(key); |
216 GetWidget()->Close(); | 216 GetWidget()->Close(); |
217 } | 217 } |
218 } | 218 } |
219 } | 219 } |
220 } | 220 } |
221 | 221 |
222 user::LoginStatus login_; | 222 LoginStatus login_; |
223 | 223 |
224 std::map<views::View*, std::string> ime_map_; | 224 std::map<views::View*, std::string> ime_map_; |
225 std::map<views::View*, std::string> property_map_; | 225 std::map<views::View*, std::string> property_map_; |
226 views::View* settings_; | 226 views::View* settings_; |
227 views::View* keyboard_status_; | 227 views::View* keyboard_status_; |
228 | 228 |
229 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); | 229 DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); |
230 }; | 230 }; |
231 | 231 |
232 } // namespace tray | 232 } // namespace tray |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return current.name; | 304 return current.name; |
305 } else { | 305 } else { |
306 // Display virtual keyboard status instead. | 306 // Display virtual keyboard status instead. |
307 int id = keyboard::IsKeyboardEnabled() | 307 int id = keyboard::IsKeyboardEnabled() |
308 ? IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED | 308 ? IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED |
309 : IDS_ASH_STATUS_TRAY_KEYBOARD_DISABLED; | 309 : IDS_ASH_STATUS_TRAY_KEYBOARD_DISABLED; |
310 return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id); | 310 return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id); |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 views::View* TrayIME::CreateTrayView(user::LoginStatus status) { | 314 views::View* TrayIME::CreateTrayView(LoginStatus status) { |
315 CHECK(tray_label_ == NULL); | 315 CHECK(tray_label_ == NULL); |
316 tray_label_ = new TrayItemView(this); | 316 tray_label_ = new TrayItemView(this); |
317 tray_label_->CreateLabel(); | 317 tray_label_->CreateLabel(); |
318 SetupLabelForTray(tray_label_->label()); | 318 SetupLabelForTray(tray_label_->label()); |
319 // Hide IME tray when it is created, it will be updated when it is notified | 319 // Hide IME tray when it is created, it will be updated when it is notified |
320 // of the IME refresh event. | 320 // of the IME refresh event. |
321 tray_label_->SetVisible(false); | 321 tray_label_->SetVisible(false); |
322 return tray_label_; | 322 return tray_label_; |
323 } | 323 } |
324 | 324 |
325 views::View* TrayIME::CreateDefaultView(user::LoginStatus status) { | 325 views::View* TrayIME::CreateDefaultView(LoginStatus status) { |
326 CHECK(default_ == NULL); | 326 CHECK(default_ == NULL); |
327 default_ = | 327 default_ = |
328 new tray::IMEDefaultView(this, GetDefaultViewLabel(ime_list_.size() > 1)); | 328 new tray::IMEDefaultView(this, GetDefaultViewLabel(ime_list_.size() > 1)); |
329 default_->SetVisible(ShouldDefaultViewBeVisible()); | 329 default_->SetVisible(ShouldDefaultViewBeVisible()); |
330 return default_; | 330 return default_; |
331 } | 331 } |
332 | 332 |
333 views::View* TrayIME::CreateDetailedView(user::LoginStatus status) { | 333 views::View* TrayIME::CreateDetailedView(LoginStatus status) { |
334 CHECK(detailed_ == NULL); | 334 CHECK(detailed_ == NULL); |
335 detailed_ = | 335 detailed_ = |
336 new tray::IMEDetailedView(this, status, ShouldShowKeyboardToggle()); | 336 new tray::IMEDetailedView(this, status, ShouldShowKeyboardToggle()); |
337 return detailed_; | 337 return detailed_; |
338 } | 338 } |
339 | 339 |
340 void TrayIME::DestroyTrayView() { | 340 void TrayIME::DestroyTrayView() { |
341 tray_label_ = NULL; | 341 tray_label_ = NULL; |
342 } | 342 } |
343 | 343 |
344 void TrayIME::DestroyDefaultView() { | 344 void TrayIME::DestroyDefaultView() { |
345 default_ = NULL; | 345 default_ = NULL; |
346 } | 346 } |
347 | 347 |
348 void TrayIME::DestroyDetailedView() { | 348 void TrayIME::DestroyDetailedView() { |
349 detailed_ = NULL; | 349 detailed_ = NULL; |
350 } | 350 } |
351 | 351 |
352 void TrayIME::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 352 void TrayIME::UpdateAfterLoginStatusChange(LoginStatus status) {} |
353 } | |
354 | 353 |
355 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 354 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
356 SetTrayLabelItemBorder(tray_label_, alignment); | 355 SetTrayLabelItemBorder(tray_label_, alignment); |
357 tray_label_->Layout(); | 356 tray_label_->Layout(); |
358 } | 357 } |
359 | 358 |
360 void TrayIME::OnIMERefresh() { | 359 void TrayIME::OnIMERefresh() { |
361 // Caches the current ime state. | 360 // Caches the current ime state. |
362 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 361 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); |
363 ime_list_.clear(); | 362 ime_list_.clear(); |
(...skipping 12 matching lines...) Expand all Loading... |
376 else | 375 else |
377 Update(); | 376 Update(); |
378 } | 377 } |
379 | 378 |
380 bool TrayIME::ShouldDefaultViewBeVisible() { | 379 bool TrayIME::ShouldDefaultViewBeVisible() { |
381 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || | 380 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || |
382 ShouldShowKeyboardToggle()); | 381 ShouldShowKeyboardToggle()); |
383 } | 382 } |
384 | 383 |
385 } // namespace ash | 384 } // namespace ash |
OLD | NEW |