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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 tray_notifier->AddIMEObserver(this); | 355 tray_notifier->AddIMEObserver(this); |
| 356 tray_notifier->AddVirtualKeyboardObserver(this); | 356 tray_notifier->AddVirtualKeyboardObserver(this); |
| 357 } | 357 } |
| 358 | 358 |
| 359 ImeMenuTray::~ImeMenuTray() { | 359 ImeMenuTray::~ImeMenuTray() { |
| 360 if (bubble_) | 360 if (bubble_) |
| 361 bubble_->bubble_view()->reset_delegate(); | 361 bubble_->bubble_view()->reset_delegate(); |
| 362 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); | 362 SystemTrayNotifier* tray_notifier = WmShell::Get()->system_tray_notifier(); |
| 363 tray_notifier->RemoveIMEObserver(this); | 363 tray_notifier->RemoveIMEObserver(this); |
| 364 tray_notifier->RemoveVirtualKeyboardObserver(this); | 364 tray_notifier->RemoveVirtualKeyboardObserver(this); |
| 365 keyboard::KeyboardController* keyboard_controller = | |
| 366 keyboard::KeyboardController::GetInstance(); | |
| 367 if (keyboard_controller) { | |
| 368 keyboard_controller->RemoveObserver(this); | |
| 369 } | |
| 365 } | 370 } |
| 366 | 371 |
| 367 void ImeMenuTray::ShowImeMenuBubble() { | 372 void ImeMenuTray::ShowImeMenuBubble() { |
| 368 int minimum_menu_width = GetMinimumMenuWidth(); | 373 int minimum_menu_width = GetMinimumMenuWidth(); |
| 369 should_block_shelf_auto_hide_ = true; | 374 should_block_shelf_auto_hide_ = true; |
| 370 views::TrayBubbleView::InitParams init_params( | 375 views::TrayBubbleView::InitParams init_params( |
| 371 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width); | 376 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width); |
| 372 init_params.can_activate = true; | 377 init_params.can_activate = true; |
| 373 init_params.close_on_deactivate = true; | 378 init_params.close_on_deactivate = true; |
| 374 | 379 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 // Overrides the keyboard url ref to make it shown with the given keyset. | 431 // Overrides the keyboard url ref to make it shown with the given keyset. |
| 427 if (InputMethodManager::Get()) | 432 if (InputMethodManager::Get()) |
| 428 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); | 433 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); |
| 429 | 434 |
| 430 // If onscreen keyboard has been enabled, shows the keyboard directly. | 435 // If onscreen keyboard has been enabled, shows the keyboard directly. |
| 431 keyboard::KeyboardController* keyboard_controller = | 436 keyboard::KeyboardController* keyboard_controller = |
| 432 keyboard::KeyboardController::GetInstance(); | 437 keyboard::KeyboardController::GetInstance(); |
| 433 show_keyboard_ = true; | 438 show_keyboard_ = true; |
| 434 if (keyboard_controller) { | 439 if (keyboard_controller) { |
| 435 keyboard_controller->AddObserver(this); | 440 keyboard_controller->AddObserver(this); |
| 436 keyboard_controller->ShowKeyboard(false); | 441 // If the keyboard window hasn't been created yet, it means the extension |
| 442 // cannot receive anything to show the keyboard. Therefore, instead of | |
| 443 // relying the extension to show the keyboard, forcibly show the keyboard | |
| 444 // window here (which will cause the keyboard window created). | |
|
bshe
2016/12/29 19:22:15
The comment here is not very clear. It looks like
Azure Wei
2017/01/03 03:37:40
Updated the comment here.
| |
| 445 if (!keyboard_controller->IsKeyboardWindowCreated()) { | |
| 446 keyboard_controller->ShowKeyboard(false); | |
| 447 } | |
| 437 return; | 448 return; |
| 438 } | 449 } |
| 439 | 450 |
| 440 AccessibilityDelegate* accessibility_delegate = | 451 AccessibilityDelegate* accessibility_delegate = |
| 441 WmShell::Get()->accessibility_delegate(); | 452 WmShell::Get()->accessibility_delegate(); |
| 442 // Fails to show the keyboard. | 453 // Fails to show the keyboard. |
| 443 if (accessibility_delegate->IsVirtualKeyboardEnabled()) | 454 if (accessibility_delegate->IsVirtualKeyboardEnabled()) |
| 444 return; | 455 return; |
| 445 | 456 |
| 446 // Onscreen keyboard has not been enabled yet, forces to bring out the | 457 // 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... | |
| 542 | 553 |
| 543 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 554 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 544 HideBubbleWithView(bubble_view); | 555 HideBubbleWithView(bubble_view); |
| 545 } | 556 } |
| 546 | 557 |
| 547 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} | 558 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} |
| 548 | 559 |
| 549 void ImeMenuTray::OnKeyboardClosed() { | 560 void ImeMenuTray::OnKeyboardClosed() { |
| 550 if (InputMethodManager::Get()) | 561 if (InputMethodManager::Get()) |
| 551 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); | 562 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); |
| 563 keyboard::KeyboardController* keyboard_controller = | |
| 564 keyboard::KeyboardController::GetInstance(); | |
| 565 if (keyboard_controller) | |
| 566 keyboard_controller->RemoveObserver(this); | |
| 567 | |
| 552 show_keyboard_ = false; | 568 show_keyboard_ = false; |
| 553 force_show_keyboard_ = false; | 569 force_show_keyboard_ = false; |
| 554 } | 570 } |
| 555 | 571 |
| 556 void ImeMenuTray::OnKeyboardHidden() { | 572 void ImeMenuTray::OnKeyboardHidden() { |
| 557 if (!show_keyboard_) | 573 if (!show_keyboard_) |
| 558 return; | 574 return; |
| 559 | 575 |
| 560 // If the the IME menu has overriding the input view url, we should write it | 576 // If the the IME menu has overriding the input view url, we should write it |
| 561 // back to normal keyboard when hiding the input view. | 577 // back to normal keyboard when hiding the input view. |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 587 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 603 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 588 | 604 |
| 589 // Updates the tray label based on the current input method. | 605 // Updates the tray label based on the current input method. |
| 590 if (current_ime_.third_party) | 606 if (current_ime_.third_party) |
| 591 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 607 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 592 else | 608 else |
| 593 label_->SetText(current_ime_.short_name); | 609 label_->SetText(current_ime_.short_name); |
| 594 } | 610 } |
| 595 | 611 |
| 596 } // namespace ash | 612 } // namespace ash |
| OLD | NEW |