| 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/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/system/tray/tray_constants.h" | 11 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/wm_shell.h" |
| 12 #include "ash/metrics/user_metrics_recorder.h" | 13 #include "ash/metrics/user_metrics_recorder.h" |
| 13 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 14 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 16 #include "ash/system/tray/hover_highlight_view.h" | 17 #include "ash/system/tray/hover_highlight_view.h" |
| 17 #include "ash/system/tray/system_tray.h" | 18 #include "ash/system/tray/system_tray.h" |
| 18 #include "ash/system/tray/system_tray_notifier.h" | 19 #include "ash/system/tray/system_tray_notifier.h" |
| 19 #include "ash/system/tray/tray_details_view.h" | 20 #include "ash/system/tray/tray_details_view.h" |
| 20 #include "ash/system/tray/tray_item_more.h" | 21 #include "ash/system/tray/tray_item_more.h" |
| 21 #include "ash/system/tray/tray_item_view.h" | 22 #include "ash/system/tray/tray_item_view.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 private: | 88 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); | 89 DISALLOW_COPY_AND_ASSIGN(IMEDefaultView); |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 class IMEDetailedView : public TrayDetailsView, public ViewClickListener { | 92 class IMEDetailedView : public TrayDetailsView, public ViewClickListener { |
| 92 public: | 93 public: |
| 93 IMEDetailedView(SystemTrayItem* owner, | 94 IMEDetailedView(SystemTrayItem* owner, |
| 94 LoginStatus login, | 95 LoginStatus login, |
| 95 bool show_keyboard_toggle) | 96 bool show_keyboard_toggle) |
| 96 : TrayDetailsView(owner), login_(login) { | 97 : TrayDetailsView(owner), login_(login) { |
| 97 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 98 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 98 IMEInfoList list; | 99 IMEInfoList list; |
| 99 delegate->GetAvailableIMEList(&list); | 100 delegate->GetAvailableIMEList(&list); |
| 100 IMEPropertyInfoList property_list; | 101 IMEPropertyInfoList property_list; |
| 101 delegate->GetCurrentIMEProperties(&property_list); | 102 delegate->GetCurrentIMEProperties(&property_list); |
| 102 Update(list, property_list, show_keyboard_toggle); | 103 Update(list, property_list, show_keyboard_toggle); |
| 103 } | 104 } |
| 104 | 105 |
| 105 ~IMEDetailedView() override {} | 106 ~IMEDetailedView() override {} |
| 106 | 107 |
| 107 void Update(const IMEInfoList& list, | 108 void Update(const IMEInfoList& list, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 container->AddLabel( | 182 container->AddLabel( |
| 182 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 183 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( |
| 183 IDS_ASH_STATUS_TRAY_IME_SETTINGS), | 184 IDS_ASH_STATUS_TRAY_IME_SETTINGS), |
| 184 gfx::ALIGN_LEFT, false /* highlight */); | 185 gfx::ALIGN_LEFT, false /* highlight */); |
| 185 AddChildView(container); | 186 AddChildView(container); |
| 186 settings_ = container; | 187 settings_ = container; |
| 187 } | 188 } |
| 188 | 189 |
| 189 // Overridden from ViewClickListener. | 190 // Overridden from ViewClickListener. |
| 190 void OnViewClicked(views::View* sender) override { | 191 void OnViewClicked(views::View* sender) override { |
| 191 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 192 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 192 if (sender == footer()->content()) { | 193 if (sender == footer()->content()) { |
| 193 TransitionToDefaultView(); | 194 TransitionToDefaultView(); |
| 194 } else if (sender == settings_) { | 195 } else if (sender == settings_) { |
| 195 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 196 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
| 196 ash::UMA_STATUS_AREA_IME_SHOW_DETAILED); | 197 ash::UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 197 delegate->ShowIMESettings(); | 198 delegate->ShowIMESettings(); |
| 198 } else if (sender == keyboard_status_) { | 199 } else if (sender == keyboard_status_) { |
| 199 Shell::GetInstance()->virtual_keyboard_controller() | 200 Shell::GetInstance()->virtual_keyboard_controller() |
| 200 ->ToggleIgnoreExternalKeyboard(); | 201 ->ToggleIgnoreExternalKeyboard(); |
| 201 } else { | 202 } else { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 bool TrayIME::ShouldShowKeyboardToggle() { | 294 bool TrayIME::ShouldShowKeyboardToggle() { |
| 294 return keyboard_suppressed_ && | 295 return keyboard_suppressed_ && |
| 295 !Shell::GetInstance() | 296 !Shell::GetInstance() |
| 296 ->accessibility_delegate() | 297 ->accessibility_delegate() |
| 297 ->IsVirtualKeyboardEnabled(); | 298 ->IsVirtualKeyboardEnabled(); |
| 298 } | 299 } |
| 299 | 300 |
| 300 base::string16 TrayIME::GetDefaultViewLabel(bool show_ime_label) { | 301 base::string16 TrayIME::GetDefaultViewLabel(bool show_ime_label) { |
| 301 if (show_ime_label) { | 302 if (show_ime_label) { |
| 302 IMEInfo current; | 303 IMEInfo current; |
| 303 Shell::GetInstance()->system_tray_delegate()->GetCurrentIME(¤t); | 304 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t); |
| 304 return current.name; | 305 return current.name; |
| 305 } else { | 306 } else { |
| 306 // Display virtual keyboard status instead. | 307 // Display virtual keyboard status instead. |
| 307 int id = keyboard::IsKeyboardEnabled() | 308 int id = keyboard::IsKeyboardEnabled() |
| 308 ? IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED | 309 ? IDS_ASH_STATUS_TRAY_KEYBOARD_ENABLED |
| 309 : IDS_ASH_STATUS_TRAY_KEYBOARD_DISABLED; | 310 : IDS_ASH_STATUS_TRAY_KEYBOARD_DISABLED; |
| 310 return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id); | 311 return ui::ResourceBundle::GetSharedInstance().GetLocalizedString(id); |
| 311 } | 312 } |
| 312 } | 313 } |
| 313 | 314 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 352 |
| 352 void TrayIME::UpdateAfterLoginStatusChange(LoginStatus status) {} | 353 void TrayIME::UpdateAfterLoginStatusChange(LoginStatus status) {} |
| 353 | 354 |
| 354 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 355 void TrayIME::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| 355 SetTrayLabelItemBorder(tray_label_, alignment); | 356 SetTrayLabelItemBorder(tray_label_, alignment); |
| 356 tray_label_->Layout(); | 357 tray_label_->Layout(); |
| 357 } | 358 } |
| 358 | 359 |
| 359 void TrayIME::OnIMERefresh() { | 360 void TrayIME::OnIMERefresh() { |
| 360 // Caches the current ime state. | 361 // Caches the current ime state. |
| 361 SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); | 362 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 362 ime_list_.clear(); | 363 ime_list_.clear(); |
| 363 property_list_.clear(); | 364 property_list_.clear(); |
| 364 delegate->GetCurrentIME(¤t_ime_); | 365 delegate->GetCurrentIME(¤t_ime_); |
| 365 delegate->GetAvailableIMEList(&ime_list_); | 366 delegate->GetAvailableIMEList(&ime_list_); |
| 366 delegate->GetCurrentIMEProperties(&property_list_); | 367 delegate->GetCurrentIMEProperties(&property_list_); |
| 367 | 368 |
| 368 Update(); | 369 Update(); |
| 369 } | 370 } |
| 370 | 371 |
| 371 void TrayIME::OnIMEMenuActivationChanged(bool is_active) { | 372 void TrayIME::OnIMEMenuActivationChanged(bool is_active) { |
| 372 is_visible_ = !is_active; | 373 is_visible_ = !is_active; |
| 373 if (is_visible_) | 374 if (is_visible_) |
| 374 OnIMERefresh(); | 375 OnIMERefresh(); |
| 375 else | 376 else |
| 376 Update(); | 377 Update(); |
| 377 } | 378 } |
| 378 | 379 |
| 379 bool TrayIME::ShouldDefaultViewBeVisible() { | 380 bool TrayIME::ShouldDefaultViewBeVisible() { |
| 380 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || | 381 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || |
| 381 ShouldShowKeyboardToggle()); | 382 ShouldShowKeyboardToggle()); |
| 382 } | 383 } |
| 383 | 384 |
| 384 } // namespace ash | 385 } // namespace ash |
| OLD | NEW |