Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ash/common/system/chromeos/ime_menu/ime_menu_tray.cc

Issue 2603663002: Make IME extensions decide when to show the keyboard. (Closed)
Patch Set: Addressed comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/input_method_manager_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
366 } 370 }
367 371
368 void ImeMenuTray::ShowImeMenuBubble() { 372 void ImeMenuTray::ShowImeMenuBubble() {
369 keyboard::KeyboardController* keyboard_controller = 373 keyboard::KeyboardController* keyboard_controller =
370 keyboard::KeyboardController::GetInstance(); 374 keyboard::KeyboardController::GetInstance();
371 if (keyboard_controller && keyboard_controller->keyboard_visible()) { 375 if (keyboard_controller && keyboard_controller->keyboard_visible()) {
372 show_bubble_after_keyboard_hidden_ = true; 376 show_bubble_after_keyboard_hidden_ = true;
373 keyboard_controller->AddObserver(this); 377 keyboard_controller->AddObserver(this);
374 keyboard_controller->HideKeyboard( 378 keyboard_controller->HideKeyboard(
375 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 379 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // Overrides the keyboard url ref to make it shown with the given keyset. 444 // Overrides the keyboard url ref to make it shown with the given keyset.
441 if (InputMethodManager::Get()) 445 if (InputMethodManager::Get())
442 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); 446 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset);
443 447
444 // If onscreen keyboard has been enabled, shows the keyboard directly. 448 // If onscreen keyboard has been enabled, shows the keyboard directly.
445 keyboard::KeyboardController* keyboard_controller = 449 keyboard::KeyboardController* keyboard_controller =
446 keyboard::KeyboardController::GetInstance(); 450 keyboard::KeyboardController::GetInstance();
447 show_keyboard_ = true; 451 show_keyboard_ = true;
448 if (keyboard_controller) { 452 if (keyboard_controller) {
449 keyboard_controller->AddObserver(this); 453 keyboard_controller->AddObserver(this);
450 keyboard_controller->ShowKeyboard(false); 454 // If the keyboard window hasn't been created yet, it means the extension
455 // cannot receive anything to show the keyboard. Therefore, instead of
456 // relying the extension to show the keyboard, forcibly show the keyboard
457 // window here (which will cause the keyboard window to be created).
458 // Otherwise, the extension will show keyboard by calling private api. The
459 // native side could just skip showing the keyboard.
460 if (!keyboard_controller->IsKeyboardWindowCreated())
461 keyboard_controller->ShowKeyboard(false);
451 return; 462 return;
452 } 463 }
453 464
454 AccessibilityDelegate* accessibility_delegate = 465 AccessibilityDelegate* accessibility_delegate =
455 WmShell::Get()->accessibility_delegate(); 466 WmShell::Get()->accessibility_delegate();
456 // Fails to show the keyboard. 467 // Fails to show the keyboard.
457 if (accessibility_delegate->IsVirtualKeyboardEnabled()) 468 if (accessibility_delegate->IsVirtualKeyboardEnabled())
458 return; 469 return;
459 470
460 // Onscreen keyboard has not been enabled yet, forces to bring out the 471 // Onscreen keyboard has not been enabled yet, forces to bring out the
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 567
557 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { 568 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) {
558 HideBubbleWithView(bubble_view); 569 HideBubbleWithView(bubble_view);
559 } 570 }
560 571
561 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} 572 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {}
562 573
563 void ImeMenuTray::OnKeyboardClosed() { 574 void ImeMenuTray::OnKeyboardClosed() {
564 if (InputMethodManager::Get()) 575 if (InputMethodManager::Get())
565 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); 576 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string());
577 keyboard::KeyboardController* keyboard_controller =
578 keyboard::KeyboardController::GetInstance();
579 if (keyboard_controller)
580 keyboard_controller->RemoveObserver(this);
581
566 show_keyboard_ = false; 582 show_keyboard_ = false;
567 force_show_keyboard_ = false; 583 force_show_keyboard_ = false;
568 } 584 }
569 585
570 void ImeMenuTray::OnKeyboardHidden() { 586 void ImeMenuTray::OnKeyboardHidden() {
571 if (show_bubble_after_keyboard_hidden_) { 587 if (show_bubble_after_keyboard_hidden_) {
572 show_bubble_after_keyboard_hidden_ = false; 588 show_bubble_after_keyboard_hidden_ = false;
573 keyboard::KeyboardController* keyboard_controller = 589 keyboard::KeyboardController* keyboard_controller =
574 keyboard::KeyboardController::GetInstance(); 590 keyboard::KeyboardController::GetInstance();
575 if (keyboard_controller) 591 if (keyboard_controller)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 628 WmShell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
613 629
614 // Updates the tray label based on the current input method. 630 // Updates the tray label based on the current input method.
615 if (current_ime_.third_party) 631 if (current_ime_.third_party)
616 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 632 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
617 else 633 else
618 label_->SetText(current_ime_.short_name); 634 label_->SetText(current_ime_.short_name);
619 } 635 }
620 636
621 } // namespace ash 637 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/input_method_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698