| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_menu/ime_menu_tray.h" | 5 #include "ash/system/ime_menu/ime_menu_tray.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 }; | 280 }; |
| 281 | 281 |
| 282 } // namespace | 282 } // namespace |
| 283 | 283 |
| 284 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) | 284 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) |
| 285 : TrayBackgroundView(wm_shelf), | 285 : TrayBackgroundView(wm_shelf), |
| 286 label_(new ImeMenuLabel()), | 286 label_(new ImeMenuLabel()), |
| 287 show_keyboard_(false), | 287 show_keyboard_(false), |
| 288 force_show_keyboard_(false), | 288 force_show_keyboard_(false), |
| 289 keyboard_suppressed_(false), | 289 keyboard_suppressed_(false), |
| 290 show_bubble_after_keyboard_hidden_(false) { | 290 show_bubble_after_keyboard_hidden_(false), |
| 291 weak_ptr_factory_(this) { |
| 291 SetInkDropMode(InkDropMode::ON); | 292 SetInkDropMode(InkDropMode::ON); |
| 292 SetupLabelForTray(label_); | 293 SetupLabelForTray(label_); |
| 293 label_->SetElideBehavior(gfx::TRUNCATE); | 294 label_->SetElideBehavior(gfx::TRUNCATE); |
| 294 tray_container()->AddChildView(label_); | 295 tray_container()->AddChildView(label_); |
| 295 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); | 296 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); |
| 296 tray_notifier->AddIMEObserver(this); | 297 tray_notifier->AddIMEObserver(this); |
| 297 tray_notifier->AddVirtualKeyboardObserver(this); | 298 tray_notifier->AddVirtualKeyboardObserver(this); |
| 298 } | 299 } |
| 299 | 300 |
| 300 ImeMenuTray::~ImeMenuTray() { | 301 ImeMenuTray::~ImeMenuTray() { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 // If the keyboard is forced to be shown by IME menu for once, we need to | 525 // If the keyboard is forced to be shown by IME menu for once, we need to |
| 525 // disable the keyboard when it's hidden. | 526 // disable the keyboard when it's hidden. |
| 526 keyboard::KeyboardController* keyboard_controller = | 527 keyboard::KeyboardController* keyboard_controller = |
| 527 keyboard::KeyboardController::GetInstance(); | 528 keyboard::KeyboardController::GetInstance(); |
| 528 if (keyboard_controller) | 529 if (keyboard_controller) |
| 529 keyboard_controller->RemoveObserver(this); | 530 keyboard_controller->RemoveObserver(this); |
| 530 | 531 |
| 531 if (!force_show_keyboard_) | 532 if (!force_show_keyboard_) |
| 532 return; | 533 return; |
| 533 | 534 |
| 534 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); | 535 // Posts a task to disable the virtual keyboard. |
| 535 force_show_keyboard_ = false; | 536 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 537 FROM_HERE, base::Bind(&ImeMenuTray::DisableVirtualKeyboard, |
| 538 weak_ptr_factory_.GetWeakPtr())); |
| 536 } | 539 } |
| 537 | 540 |
| 538 void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) { | 541 void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) { |
| 539 if (suppressed != keyboard_suppressed_ && bubble_) | 542 if (suppressed != keyboard_suppressed_ && bubble_) |
| 540 HideImeMenuBubble(); | 543 HideImeMenuBubble(); |
| 541 keyboard_suppressed_ = suppressed; | 544 keyboard_suppressed_ = suppressed; |
| 542 } | 545 } |
| 543 | 546 |
| 544 void ImeMenuTray::UpdateTrayLabel() { | 547 void ImeMenuTray::UpdateTrayLabel() { |
| 545 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 548 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 546 | 549 |
| 547 // Updates the tray label based on the current input method. | 550 // Updates the tray label based on the current input method. |
| 548 if (current_ime_.third_party) | 551 if (current_ime_.third_party) |
| 549 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 552 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 550 else | 553 else |
| 551 label_->SetText(current_ime_.short_name); | 554 label_->SetText(current_ime_.short_name); |
| 552 } | 555 } |
| 553 | 556 |
| 557 void ImeMenuTray::DisableVirtualKeyboard() { |
| 558 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); |
| 559 force_show_keyboard_ = false; |
| 560 } |
| 561 |
| 554 } // namespace ash | 562 } // namespace ash |
| OLD | NEW |