| 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/common/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/hover_highlight_view.h" | 10 #include "ash/common/system/tray/hover_highlight_view.h" |
| 11 #include "ash/common/system/tray/system_tray_delegate.h" | 11 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/system/tray/tray_constants.h" | 12 #include "ash/common/system/tray/tray_constants.h" |
| 13 #include "ash/common/system/tray/tray_details_view.h" | 13 #include "ash/common/system/tray/tray_details_view.h" |
| 14 #include "ash/common/system/tray/tray_item_more.h" | 14 #include "ash/common/system/tray/tray_item_more.h" |
| 15 #include "ash/common/system/tray/tray_item_view.h" | 15 #include "ash/common/system/tray/tray_item_view.h" |
| 16 #include "ash/common/system/tray/tray_utils.h" | 16 #include "ash/common/system/tray/tray_utils.h" |
| 17 #include "ash/common/system/tray/wm_system_tray_notifier.h" | 17 #include "ash/common/system/tray/wm_system_tray_notifier.h" |
| 18 #include "ash/common/system/tray_accessibility.h" | 18 #include "ash/common/system/tray_accessibility.h" |
| 19 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 20 #include "ash/metrics/user_metrics_recorder.h" | |
| 21 #include "ash/root_window_controller.h" | |
| 22 #include "ash/shell.h" | |
| 23 #include "ash/system/tray/system_tray.h" | 20 #include "ash/system/tray/system_tray.h" |
| 24 #include "ash/system/tray/system_tray_notifier.h" | |
| 25 #include "ash/virtual_keyboard_controller.h" | |
| 26 #include "base/logging.h" | 21 #include "base/logging.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 28 #include "grit/ash_resources.h" | 23 #include "grit/ash_resources.h" |
| 29 #include "grit/ash_strings.h" | 24 #include "grit/ash_strings.h" |
| 30 #include "ui/accessibility/ax_enums.h" | 25 #include "ui/accessibility/ax_enums.h" |
| 31 #include "ui/accessibility/ax_view_state.h" | 26 #include "ui/accessibility/ax_view_state.h" |
| 32 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 33 #include "ui/gfx/font.h" | 28 #include "ui/gfx/font.h" |
| 34 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 35 #include "ui/keyboard/keyboard_util.h" | 30 #include "ui/keyboard/keyboard_util.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 AppendIMEList(list); | 112 AppendIMEList(list); |
| 118 if (!property_list.empty()) | 113 if (!property_list.empty()) |
| 119 AppendIMEProperties(property_list); | 114 AppendIMEProperties(property_list); |
| 120 | 115 |
| 121 if (show_keyboard_toggle) { | 116 if (show_keyboard_toggle) { |
| 122 if (list.size() > 1 || !property_list.empty()) | 117 if (list.size() > 1 || !property_list.empty()) |
| 123 AddScrollSeparator(); | 118 AddScrollSeparator(); |
| 124 AppendKeyboardStatus(); | 119 AppendKeyboardStatus(); |
| 125 } | 120 } |
| 126 | 121 |
| 127 bool userAddingRunning = ash::Shell::GetInstance() | |
| 128 ->session_state_delegate() | |
| 129 ->IsInSecondaryLoginScreen(); | |
| 130 if (login_ != LoginStatus::NOT_LOGGED_IN && login_ != LoginStatus::LOCKED && | 122 if (login_ != LoginStatus::NOT_LOGGED_IN && login_ != LoginStatus::LOCKED && |
| 131 !userAddingRunning) | 123 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) |
| 132 AppendSettings(); | 124 AppendSettings(); |
| 133 AppendHeaderEntry(); | 125 AppendHeaderEntry(); |
| 134 | 126 |
| 135 Layout(); | 127 Layout(); |
| 136 SchedulePaint(); | 128 SchedulePaint(); |
| 137 } | 129 } |
| 138 | 130 |
| 139 private: | 131 private: |
| 140 void AppendHeaderEntry() { CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); } | 132 void AppendHeaderEntry() { CreateSpecialRow(IDS_ASH_STATUS_TRAY_IME, this); } |
| 141 | 133 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 AddChildView(container); | 178 AddChildView(container); |
| 187 settings_ = container; | 179 settings_ = container; |
| 188 } | 180 } |
| 189 | 181 |
| 190 // Overridden from ViewClickListener. | 182 // Overridden from ViewClickListener. |
| 191 void OnViewClicked(views::View* sender) override { | 183 void OnViewClicked(views::View* sender) override { |
| 192 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 184 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
| 193 if (sender == footer()->content()) { | 185 if (sender == footer()->content()) { |
| 194 TransitionToDefaultView(); | 186 TransitionToDefaultView(); |
| 195 } else if (sender == settings_) { | 187 } else if (sender == settings_) { |
| 196 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 188 WmShell::Get()->RecordUserMetricsAction( |
| 197 ash::UMA_STATUS_AREA_IME_SHOW_DETAILED); | 189 UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 198 delegate->ShowIMESettings(); | 190 delegate->ShowIMESettings(); |
| 199 } else if (sender == keyboard_status_) { | 191 } else if (sender == keyboard_status_) { |
| 200 Shell::GetInstance()->virtual_keyboard_controller() | 192 WmShell::Get()->ToggleIgnoreExternalKeyboard(); |
| 201 ->ToggleIgnoreExternalKeyboard(); | |
| 202 } else { | 193 } else { |
| 203 std::map<views::View*, std::string>::const_iterator ime_find; | 194 std::map<views::View*, std::string>::const_iterator ime_find; |
| 204 ime_find = ime_map_.find(sender); | 195 ime_find = ime_map_.find(sender); |
| 205 if (ime_find != ime_map_.end()) { | 196 if (ime_find != ime_map_.end()) { |
| 206 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 197 WmShell::Get()->RecordUserMetricsAction( |
| 207 ash::UMA_STATUS_AREA_IME_SWITCH_MODE); | 198 UMA_STATUS_AREA_IME_SWITCH_MODE); |
| 208 std::string ime_id = ime_find->second; | 199 std::string ime_id = ime_find->second; |
| 209 delegate->SwitchIME(ime_id); | 200 delegate->SwitchIME(ime_id); |
| 210 GetWidget()->Close(); | 201 GetWidget()->Close(); |
| 211 } else { | 202 } else { |
| 212 std::map<views::View*, std::string>::const_iterator prop_find; | 203 std::map<views::View*, std::string>::const_iterator prop_find; |
| 213 prop_find = property_map_.find(sender); | 204 prop_find = property_map_.find(sender); |
| 214 if (prop_find != property_map_.end()) { | 205 if (prop_find != property_map_.end()) { |
| 215 const std::string key = prop_find->second; | 206 const std::string key = prop_find->second; |
| 216 delegate->ActivateIMEProperty(key); | 207 delegate->ActivateIMEProperty(key); |
| 217 GetWidget()->Close(); | 208 GetWidget()->Close(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 232 | 223 |
| 233 } // namespace tray | 224 } // namespace tray |
| 234 | 225 |
| 235 TrayIME::TrayIME(SystemTray* system_tray) | 226 TrayIME::TrayIME(SystemTray* system_tray) |
| 236 : SystemTrayItem(system_tray), | 227 : SystemTrayItem(system_tray), |
| 237 tray_label_(NULL), | 228 tray_label_(NULL), |
| 238 default_(NULL), | 229 default_(NULL), |
| 239 detailed_(NULL), | 230 detailed_(NULL), |
| 240 keyboard_suppressed_(false), | 231 keyboard_suppressed_(false), |
| 241 is_visible_(true) { | 232 is_visible_(true) { |
| 242 Shell::GetInstance()->system_tray_notifier()->AddIMEObserver(this); | 233 WmSystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); |
| 243 Shell::GetInstance()->system_tray_notifier()->AddVirtualKeyboardObserver( | 234 tray_notifier->AddVirtualKeyboardObserver(this); |
| 244 this); | 235 tray_notifier->AddAccessibilityObserver(this); |
| 245 WmShell::Get()->system_tray_notifier()->AddAccessibilityObserver(this); | 236 tray_notifier->AddIMEObserver(this); |
| 246 } | 237 } |
| 247 | 238 |
| 248 TrayIME::~TrayIME() { | 239 TrayIME::~TrayIME() { |
| 249 Shell::GetInstance()->system_tray_notifier()->RemoveIMEObserver(this); | 240 WmSystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); |
| 250 WmShell::Get()->system_tray_notifier()->RemoveAccessibilityObserver(this); | 241 tray_notifier->RemoveIMEObserver(this); |
| 251 Shell::GetInstance()->system_tray_notifier()->RemoveVirtualKeyboardObserver( | 242 tray_notifier->RemoveAccessibilityObserver(this); |
| 252 this); | 243 tray_notifier->RemoveVirtualKeyboardObserver(this); |
| 253 } | 244 } |
| 254 | 245 |
| 255 void TrayIME::OnKeyboardSuppressionChanged(bool suppressed) { | 246 void TrayIME::OnKeyboardSuppressionChanged(bool suppressed) { |
| 256 keyboard_suppressed_ = suppressed; | 247 keyboard_suppressed_ = suppressed; |
| 257 Update(); | 248 Update(); |
| 258 } | 249 } |
| 259 | 250 |
| 260 void TrayIME::OnAccessibilityModeChanged( | 251 void TrayIME::OnAccessibilityModeChanged( |
| 261 AccessibilityNotificationVisibility notify) { | 252 AccessibilityNotificationVisibility notify) { |
| 262 Update(); | 253 Update(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 285 } else { | 276 } else { |
| 286 tray_label_->label()->SetText(current.short_name); | 277 tray_label_->label()->SetText(current.short_name); |
| 287 } | 278 } |
| 288 SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment()); | 279 SetTrayLabelItemBorder(tray_label_, system_tray()->shelf_alignment()); |
| 289 tray_label_->Layout(); | 280 tray_label_->Layout(); |
| 290 } | 281 } |
| 291 } | 282 } |
| 292 | 283 |
| 293 bool TrayIME::ShouldShowKeyboardToggle() { | 284 bool TrayIME::ShouldShowKeyboardToggle() { |
| 294 return keyboard_suppressed_ && | 285 return keyboard_suppressed_ && |
| 295 !Shell::GetInstance() | 286 !WmShell::Get() |
| 296 ->accessibility_delegate() | 287 ->GetAccessibilityDelegate() |
| 297 ->IsVirtualKeyboardEnabled(); | 288 ->IsVirtualKeyboardEnabled(); |
| 298 } | 289 } |
| 299 | 290 |
| 300 base::string16 TrayIME::GetDefaultViewLabel(bool show_ime_label) { | 291 base::string16 TrayIME::GetDefaultViewLabel(bool show_ime_label) { |
| 301 if (show_ime_label) { | 292 if (show_ime_label) { |
| 302 IMEInfo current; | 293 IMEInfo current; |
| 303 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t); | 294 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t); |
| 304 return current.name; | 295 return current.name; |
| 305 } else { | 296 } else { |
| 306 // Display virtual keyboard status instead. | 297 // Display virtual keyboard status instead. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 else | 366 else |
| 376 Update(); | 367 Update(); |
| 377 } | 368 } |
| 378 | 369 |
| 379 bool TrayIME::ShouldDefaultViewBeVisible() { | 370 bool TrayIME::ShouldDefaultViewBeVisible() { |
| 380 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || | 371 return is_visible_ && (ime_list_.size() > 1 || property_list_.size() > 1 || |
| 381 ShouldShowKeyboardToggle()); | 372 ShouldShowKeyboardToggle()); |
| 382 } | 373 } |
| 383 | 374 |
| 384 } // namespace ash | 375 } // namespace ash |
| OLD | NEW |