| 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/accelerators/accelerator_controller.h" | |
| 8 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
| 10 #include "ash/ime/ime_controller.h" | 9 #include "ash/ime/ime_controller.h" |
| 11 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 12 #include "ash/session/session_controller.h" | 11 #include "ash/session/session_controller.h" |
| 13 #include "ash/shelf/shelf.h" | 12 #include "ash/shelf/shelf.h" |
| 14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 15 #include "ash/shell_port.h" | 14 #include "ash/shell_port.h" |
| 16 #include "ash/strings/grit/ash_strings.h" | 15 #include "ash/strings/grit/ash_strings.h" |
| 17 #include "ash/system/ime_menu/ime_list_view.h" | 16 #include "ash/system/ime_menu/ime_list_view.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 SetupLabelForTray(label_); | 291 SetupLabelForTray(label_); |
| 293 label_->SetElideBehavior(gfx::TRUNCATE); | 292 label_->SetElideBehavior(gfx::TRUNCATE); |
| 294 tray_container()->AddChildView(label_); | 293 tray_container()->AddChildView(label_); |
| 295 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); | 294 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); |
| 296 tray_notifier->AddIMEObserver(this); | 295 tray_notifier->AddIMEObserver(this); |
| 297 tray_notifier->AddVirtualKeyboardObserver(this); | 296 tray_notifier->AddVirtualKeyboardObserver(this); |
| 298 } | 297 } |
| 299 | 298 |
| 300 ImeMenuTray::~ImeMenuTray() { | 299 ImeMenuTray::~ImeMenuTray() { |
| 301 if (bubble_) | 300 if (bubble_) |
| 302 bubble_->bubble_view()->ResetDelegate(); | 301 bubble_->bubble_view()->reset_delegate(); |
| 303 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); | 302 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); |
| 304 tray_notifier->RemoveIMEObserver(this); | 303 tray_notifier->RemoveIMEObserver(this); |
| 305 tray_notifier->RemoveVirtualKeyboardObserver(this); | 304 tray_notifier->RemoveVirtualKeyboardObserver(this); |
| 306 keyboard::KeyboardController* keyboard_controller = | 305 keyboard::KeyboardController* keyboard_controller = |
| 307 keyboard::KeyboardController::GetInstance(); | 306 keyboard::KeyboardController::GetInstance(); |
| 308 if (keyboard_controller) | 307 if (keyboard_controller) |
| 309 keyboard_controller->RemoveObserver(this); | 308 keyboard_controller->RemoveObserver(this); |
| 310 } | 309 } |
| 311 | 310 |
| 312 void ImeMenuTray::ShowImeMenuBubble() { | 311 void ImeMenuTray::ShowImeMenuBubble() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 323 } | 322 } |
| 324 | 323 |
| 325 void ImeMenuTray::ShowImeMenuBubbleInternal() { | 324 void ImeMenuTray::ShowImeMenuBubbleInternal() { |
| 326 views::TrayBubbleView::InitParams init_params; | 325 views::TrayBubbleView::InitParams init_params; |
| 327 init_params.delegate = this; | 326 init_params.delegate = this; |
| 328 init_params.parent_window = GetBubbleWindowContainer(); | 327 init_params.parent_window = GetBubbleWindowContainer(); |
| 329 init_params.anchor_view = GetBubbleAnchor(); | 328 init_params.anchor_view = GetBubbleAnchor(); |
| 330 init_params.anchor_alignment = GetAnchorAlignment(); | 329 init_params.anchor_alignment = GetAnchorAlignment(); |
| 331 init_params.min_width = kTrayMenuMinimumWidth; | 330 init_params.min_width = kTrayMenuMinimumWidth; |
| 332 init_params.max_width = kTrayMenuMinimumWidth; | 331 init_params.max_width = kTrayMenuMinimumWidth; |
| 332 init_params.can_activate = true; |
| 333 init_params.close_on_deactivate = true; | 333 init_params.close_on_deactivate = true; |
| 334 | 334 |
| 335 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params); | 335 views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params); |
| 336 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 336 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
| 337 | 337 |
| 338 // Add a title item with a separator on the top of the IME menu. | 338 // Add a title item with a separator on the top of the IME menu. |
| 339 bubble_view->AddChildView( | 339 bubble_view->AddChildView( |
| 340 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons())); | 340 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons())); |
| 341 | 341 |
| 342 // Adds IME list to the bubble. | 342 // Adds IME list to the bubble. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 HideImeMenuBubble(); | 461 HideImeMenuBubble(); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void ImeMenuTray::BubbleViewDestroyed() { | 464 void ImeMenuTray::BubbleViewDestroyed() { |
| 465 } | 465 } |
| 466 | 466 |
| 467 void ImeMenuTray::OnMouseEnteredView() {} | 467 void ImeMenuTray::OnMouseEnteredView() {} |
| 468 | 468 |
| 469 void ImeMenuTray::OnMouseExitedView() {} | 469 void ImeMenuTray::OnMouseExitedView() {} |
| 470 | 470 |
| 471 void ImeMenuTray::RegisterAccelerators( | |
| 472 const std::vector<ui::Accelerator>& accelerators, | |
| 473 views::TrayBubbleView* tray_bubble_view) { | |
| 474 Shell::Get()->accelerator_controller()->Register(accelerators, | |
| 475 tray_bubble_view); | |
| 476 } | |
| 477 | |
| 478 void ImeMenuTray::UnregisterAllAccelerators( | |
| 479 views::TrayBubbleView* tray_bubble_view) { | |
| 480 Shell::Get()->accelerator_controller()->UnregisterAll(tray_bubble_view); | |
| 481 } | |
| 482 | |
| 483 base::string16 ImeMenuTray::GetAccessibleNameForBubble() { | 471 base::string16 ImeMenuTray::GetAccessibleNameForBubble() { |
| 484 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); | 472 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); |
| 485 } | 473 } |
| 486 | 474 |
| 487 bool ImeMenuTray::ShouldEnableExtraKeyboardAccessibility() { | |
| 488 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled(); | |
| 489 } | |
| 490 | |
| 491 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 475 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 492 HideBubbleWithView(bubble_view); | 476 HideBubbleWithView(bubble_view); |
| 493 } | 477 } |
| 494 | 478 |
| 495 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} | 479 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} |
| 496 | 480 |
| 497 void ImeMenuTray::OnKeyboardClosed() { | 481 void ImeMenuTray::OnKeyboardClosed() { |
| 498 if (InputMethodManager::Get()) | 482 if (InputMethodManager::Get()) |
| 499 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); | 483 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); |
| 500 keyboard::KeyboardController* keyboard_controller = | 484 keyboard::KeyboardController* keyboard_controller = |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 else | 542 else |
| 559 label_->SetText(current_ime_.short_name); | 543 label_->SetText(current_ime_.short_name); |
| 560 } | 544 } |
| 561 | 545 |
| 562 void ImeMenuTray::DisableVirtualKeyboard() { | 546 void ImeMenuTray::DisableVirtualKeyboard() { |
| 563 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); | 547 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); |
| 564 force_show_keyboard_ = false; | 548 force_show_keyboard_ = false; |
| 565 } | 549 } |
| 566 | 550 |
| 567 } // namespace ash | 551 } // namespace ash |
| OLD | NEW |