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

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

Issue 2958693002: Reland with a fix: Do not activate TrayBubbleView by default (Closed)
Patch Set: Add a fix. Created 3 years, 6 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
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/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"
7 #include "ash/accessibility_delegate.h" 8 #include "ash/accessibility_delegate.h"
8 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
9 #include "ash/ime/ime_controller.h" 10 #include "ash/ime/ime_controller.h"
10 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
11 #include "ash/session/session_controller.h" 12 #include "ash/session/session_controller.h"
12 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/shell_port.h" 15 #include "ash/shell_port.h"
15 #include "ash/strings/grit/ash_strings.h" 16 #include "ash/strings/grit/ash_strings.h"
16 #include "ash/system/ime_menu/ime_list_view.h" 17 #include "ash/system/ime_menu/ime_list_view.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 SetupLabelForTray(label_); 292 SetupLabelForTray(label_);
292 label_->SetElideBehavior(gfx::TRUNCATE); 293 label_->SetElideBehavior(gfx::TRUNCATE);
293 tray_container()->AddChildView(label_); 294 tray_container()->AddChildView(label_);
294 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); 295 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
295 tray_notifier->AddIMEObserver(this); 296 tray_notifier->AddIMEObserver(this);
296 tray_notifier->AddVirtualKeyboardObserver(this); 297 tray_notifier->AddVirtualKeyboardObserver(this);
297 } 298 }
298 299
299 ImeMenuTray::~ImeMenuTray() { 300 ImeMenuTray::~ImeMenuTray() {
300 if (bubble_) 301 if (bubble_)
301 bubble_->bubble_view()->reset_delegate(); 302 bubble_->bubble_view()->ResetDelegate();
302 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); 303 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier();
303 tray_notifier->RemoveIMEObserver(this); 304 tray_notifier->RemoveIMEObserver(this);
304 tray_notifier->RemoveVirtualKeyboardObserver(this); 305 tray_notifier->RemoveVirtualKeyboardObserver(this);
305 keyboard::KeyboardController* keyboard_controller = 306 keyboard::KeyboardController* keyboard_controller =
306 keyboard::KeyboardController::GetInstance(); 307 keyboard::KeyboardController::GetInstance();
307 if (keyboard_controller) 308 if (keyboard_controller)
308 keyboard_controller->RemoveObserver(this); 309 keyboard_controller->RemoveObserver(this);
309 } 310 }
310 311
311 void ImeMenuTray::ShowImeMenuBubble() { 312 void ImeMenuTray::ShowImeMenuBubble() {
(...skipping 10 matching lines...) Expand all
322 } 323 }
323 324
324 void ImeMenuTray::ShowImeMenuBubbleInternal() { 325 void ImeMenuTray::ShowImeMenuBubbleInternal() {
325 views::TrayBubbleView::InitParams init_params; 326 views::TrayBubbleView::InitParams init_params;
326 init_params.delegate = this; 327 init_params.delegate = this;
327 init_params.parent_window = GetBubbleWindowContainer(); 328 init_params.parent_window = GetBubbleWindowContainer();
328 init_params.anchor_view = GetBubbleAnchor(); 329 init_params.anchor_view = GetBubbleAnchor();
329 init_params.anchor_alignment = GetAnchorAlignment(); 330 init_params.anchor_alignment = GetAnchorAlignment();
330 init_params.min_width = kTrayMenuMinimumWidth; 331 init_params.min_width = kTrayMenuMinimumWidth;
331 init_params.max_width = kTrayMenuMinimumWidth; 332 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 HideImeMenuBubble(); 460 HideImeMenuBubble();
461 } 461 }
462 462
463 void ImeMenuTray::BubbleViewDestroyed() { 463 void ImeMenuTray::BubbleViewDestroyed() {
464 } 464 }
465 465
466 void ImeMenuTray::OnMouseEnteredView() {} 466 void ImeMenuTray::OnMouseEnteredView() {}
467 467
468 void ImeMenuTray::OnMouseExitedView() {} 468 void ImeMenuTray::OnMouseExitedView() {}
469 469
470 void ImeMenuTray::RegisterAccelerators(
471 const std::vector<ui::Accelerator>& accelerators,
472 views::TrayBubbleView* tray_bubble_view) {
473 Shell::Get()->accelerator_controller()->Register(accelerators,
474 tray_bubble_view);
475 }
476
477 void ImeMenuTray::UnregisterAllAccelerators(
478 views::TrayBubbleView* tray_bubble_view) {
479 Shell::Get()->accelerator_controller()->UnregisterAll(tray_bubble_view);
480 }
481
470 base::string16 ImeMenuTray::GetAccessibleNameForBubble() { 482 base::string16 ImeMenuTray::GetAccessibleNameForBubble() {
471 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); 483 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME);
472 } 484 }
473 485
486 bool ImeMenuTray::ShouldEnableExtraKeyboardAccessibility() {
487 return Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled();
488 }
489
474 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { 490 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) {
475 HideBubbleWithView(bubble_view); 491 HideBubbleWithView(bubble_view);
476 } 492 }
477 493
478 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} 494 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {}
479 495
480 void ImeMenuTray::OnKeyboardClosed() { 496 void ImeMenuTray::OnKeyboardClosed() {
481 if (InputMethodManager::Get()) 497 if (InputMethodManager::Get())
482 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); 498 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string());
483 keyboard::KeyboardController* keyboard_controller = 499 keyboard::KeyboardController* keyboard_controller =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 else 557 else
542 label_->SetText(current_ime.short_name); 558 label_->SetText(current_ime.short_name);
543 } 559 }
544 560
545 void ImeMenuTray::DisableVirtualKeyboard() { 561 void ImeMenuTray::DisableVirtualKeyboard() {
546 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); 562 Shell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false);
547 force_show_keyboard_ = false; 563 force_show_keyboard_ = false;
548 } 564 }
549 565
550 } // namespace ash 566 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698