Chromium Code Reviews| 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/common/system/chromeos/ime_menu/ime_menu_tray.h" | 5 #include "ash/common/system/chromeos/ime_menu/ime_menu_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/accessibility_delegate.h" | 7 #include "ash/common/accessibility_delegate.h" |
| 8 #include "ash/common/ash_constants.h" | 8 #include "ash/common/ash_constants.h" |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 tray_notifier->AddIMEObserver(this); | 356 tray_notifier->AddIMEObserver(this); |
| 357 tray_notifier->AddVirtualKeyboardObserver(this); | 357 tray_notifier->AddVirtualKeyboardObserver(this); |
| 358 } | 358 } |
| 359 | 359 |
| 360 ImeMenuTray::~ImeMenuTray() { | 360 ImeMenuTray::~ImeMenuTray() { |
| 361 if (bubble_) | 361 if (bubble_) |
| 362 bubble_->bubble_view()->reset_delegate(); | 362 bubble_->bubble_view()->reset_delegate(); |
| 363 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); | 363 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); |
| 364 tray_notifier->RemoveIMEObserver(this); | 364 tray_notifier->RemoveIMEObserver(this); |
| 365 tray_notifier->RemoveVirtualKeyboardObserver(this); | 365 tray_notifier->RemoveVirtualKeyboardObserver(this); |
| 366 keyboard::KeyboardController* keyboard_controller = | |
| 367 keyboard::KeyboardController::GetInstance(); | |
| 368 if (keyboard_controller) { | |
| 369 keyboard_controller->RemoveObserver(this); | |
| 370 } | |
|
stevenjb
2017/01/06 16:59:39
nit: no {}
Azure Wei
2017/01/07 07:03:32
Done.
| |
| 366 } | 371 } |
| 367 | 372 |
| 368 void ImeMenuTray::ShowImeMenuBubble() { | 373 void ImeMenuTray::ShowImeMenuBubble() { |
| 369 keyboard::KeyboardController* keyboard_controller = | 374 keyboard::KeyboardController* keyboard_controller = |
| 370 keyboard::KeyboardController::GetInstance(); | 375 keyboard::KeyboardController::GetInstance(); |
| 371 if (keyboard_controller && keyboard_controller->keyboard_visible()) { | 376 if (keyboard_controller && keyboard_controller->keyboard_visible()) { |
| 372 show_bubble_after_keyboard_hidden_ = true; | 377 show_bubble_after_keyboard_hidden_ = true; |
| 373 keyboard_controller->AddObserver(this); | 378 keyboard_controller->AddObserver(this); |
| 374 keyboard_controller->HideKeyboard( | 379 keyboard_controller->HideKeyboard( |
| 375 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 380 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 // Overrides the keyboard url ref to make it shown with the given keyset. | 445 // Overrides the keyboard url ref to make it shown with the given keyset. |
| 441 if (InputMethodManager::Get()) | 446 if (InputMethodManager::Get()) |
| 442 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); | 447 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); |
| 443 | 448 |
| 444 // If onscreen keyboard has been enabled, shows the keyboard directly. | 449 // If onscreen keyboard has been enabled, shows the keyboard directly. |
| 445 keyboard::KeyboardController* keyboard_controller = | 450 keyboard::KeyboardController* keyboard_controller = |
| 446 keyboard::KeyboardController::GetInstance(); | 451 keyboard::KeyboardController::GetInstance(); |
| 447 show_keyboard_ = true; | 452 show_keyboard_ = true; |
| 448 if (keyboard_controller) { | 453 if (keyboard_controller) { |
| 449 keyboard_controller->AddObserver(this); | 454 keyboard_controller->AddObserver(this); |
| 450 keyboard_controller->ShowKeyboard(false); | 455 // If the keyboard window hasn't been created yet, it means the extension |
| 456 // cannot receive anything to show the keyboard. Therefore, instead of | |
| 457 // relying the extension to show the keyboard, forcibly show the keyboard | |
| 458 // window here (which will cause the keyboard window created). | |
|
stevenjb
2017/01/06 16:59:39
window to be created
Azure Wei
2017/01/07 07:03:32
Done.
| |
| 459 // Otherwise, the extension will show keyboard by calling private api. The | |
| 460 // native side could just skip to show keyboard. | |
|
stevenjb
2017/01/06 16:59:39
skip showing the keyboard
Azure Wei
2017/01/07 07:03:32
Done.
| |
| 461 if (!keyboard_controller->IsKeyboardWindowCreated()) { | |
| 462 keyboard_controller->ShowKeyboard(false); | |
| 463 } | |
|
stevenjb
2017/01/06 16:59:39
nit: no {}
Azure Wei
2017/01/07 07:03:32
Done.
| |
| 451 return; | 464 return; |
| 452 } | 465 } |
| 453 | 466 |
| 454 AccessibilityDelegate* accessibility_delegate = | 467 AccessibilityDelegate* accessibility_delegate = |
| 455 WmShell::Get()->accessibility_delegate(); | 468 WmShell::Get()->accessibility_delegate(); |
| 456 // Fails to show the keyboard. | 469 // Fails to show the keyboard. |
| 457 if (accessibility_delegate->IsVirtualKeyboardEnabled()) | 470 if (accessibility_delegate->IsVirtualKeyboardEnabled()) |
| 458 return; | 471 return; |
| 459 | 472 |
| 460 // Onscreen keyboard has not been enabled yet, forces to bring out the | 473 // Onscreen keyboard has not been enabled yet, forces to bring out the |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 | 569 |
| 557 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 570 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 558 HideBubbleWithView(bubble_view); | 571 HideBubbleWithView(bubble_view); |
| 559 } | 572 } |
| 560 | 573 |
| 561 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} | 574 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} |
| 562 | 575 |
| 563 void ImeMenuTray::OnKeyboardClosed() { | 576 void ImeMenuTray::OnKeyboardClosed() { |
| 564 if (InputMethodManager::Get()) | 577 if (InputMethodManager::Get()) |
| 565 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); | 578 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); |
| 579 keyboard::KeyboardController* keyboard_controller = | |
| 580 keyboard::KeyboardController::GetInstance(); | |
| 581 if (keyboard_controller) | |
| 582 keyboard_controller->RemoveObserver(this); | |
| 583 | |
| 566 show_keyboard_ = false; | 584 show_keyboard_ = false; |
| 567 force_show_keyboard_ = false; | 585 force_show_keyboard_ = false; |
| 568 } | 586 } |
| 569 | 587 |
| 570 void ImeMenuTray::OnKeyboardHidden() { | 588 void ImeMenuTray::OnKeyboardHidden() { |
| 571 if (show_bubble_after_keyboard_hidden_) { | 589 if (show_bubble_after_keyboard_hidden_) { |
| 572 show_bubble_after_keyboard_hidden_ = false; | 590 show_bubble_after_keyboard_hidden_ = false; |
| 573 keyboard::KeyboardController* keyboard_controller = | 591 keyboard::KeyboardController* keyboard_controller = |
| 574 keyboard::KeyboardController::GetInstance(); | 592 keyboard::KeyboardController::GetInstance(); |
| 575 if (keyboard_controller) | 593 if (keyboard_controller) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 630 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 613 | 631 |
| 614 // Updates the tray label based on the current input method. | 632 // Updates the tray label based on the current input method. |
| 615 if (current_ime_.third_party) | 633 if (current_ime_.third_party) |
| 616 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 634 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 617 else | 635 else |
| 618 label_->SetText(current_ime_.short_name); | 636 label_->SetText(current_ime_.short_name); |
| 619 } | 637 } |
| 620 | 638 |
| 621 } // namespace ash | 639 } // namespace ash |
| OLD | NEW |