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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 DISALLOW_COPY_AND_ASSIGN(ImeMenuListView); | 280 DISALLOW_COPY_AND_ASSIGN(ImeMenuListView); |
281 }; | 281 }; |
282 | 282 |
283 } // namespace | 283 } // namespace |
284 | 284 |
285 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) | 285 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) |
286 : TrayBackgroundView(wm_shelf), | 286 : TrayBackgroundView(wm_shelf), |
287 label_(new ImeMenuLabel()), | 287 label_(new ImeMenuLabel()), |
288 show_keyboard_(false), | 288 show_keyboard_(false), |
289 force_show_keyboard_(false), | 289 force_show_keyboard_(false), |
290 should_block_shelf_auto_hide_(false), | |
291 keyboard_suppressed_(false), | 290 keyboard_suppressed_(false), |
292 show_bubble_after_keyboard_hidden_(false) { | 291 show_bubble_after_keyboard_hidden_(false) { |
293 SetInkDropMode(InkDropMode::ON); | 292 SetInkDropMode(InkDropMode::ON); |
294 SetupLabelForTray(label_); | 293 SetupLabelForTray(label_); |
295 label_->SetElideBehavior(gfx::TRUNCATE); | 294 label_->SetElideBehavior(gfx::TRUNCATE); |
296 tray_container()->AddChildView(label_); | 295 tray_container()->AddChildView(label_); |
297 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); | 296 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); |
298 tray_notifier->AddIMEObserver(this); | 297 tray_notifier->AddIMEObserver(this); |
299 tray_notifier->AddVirtualKeyboardObserver(this); | 298 tray_notifier->AddVirtualKeyboardObserver(this); |
300 } | 299 } |
(...skipping 17 matching lines...) Expand all Loading... |
318 show_bubble_after_keyboard_hidden_ = true; | 317 show_bubble_after_keyboard_hidden_ = true; |
319 keyboard_controller->AddObserver(this); | 318 keyboard_controller->AddObserver(this); |
320 keyboard_controller->HideKeyboard( | 319 keyboard_controller->HideKeyboard( |
321 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 320 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
322 } else { | 321 } else { |
323 ShowImeMenuBubbleInternal(); | 322 ShowImeMenuBubbleInternal(); |
324 } | 323 } |
325 } | 324 } |
326 | 325 |
327 void ImeMenuTray::ShowImeMenuBubbleInternal() { | 326 void ImeMenuTray::ShowImeMenuBubbleInternal() { |
328 should_block_shelf_auto_hide_ = true; | |
329 views::TrayBubbleView::InitParams init_params( | 327 views::TrayBubbleView::InitParams init_params( |
330 GetAnchorAlignment(), kTrayMenuMinimumWidth, kTrayMenuMinimumWidth); | 328 GetAnchorAlignment(), kTrayMenuMinimumWidth, kTrayMenuMinimumWidth); |
331 init_params.can_activate = true; | 329 init_params.can_activate = true; |
332 init_params.close_on_deactivate = true; | 330 init_params.close_on_deactivate = true; |
333 | 331 |
334 views::TrayBubbleView* bubble_view = | 332 views::TrayBubbleView* bubble_view = |
335 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); | 333 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); |
336 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 334 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
337 | 335 |
338 // Add a title item with a separator on the top of the IME menu. | 336 // Add a title item with a separator on the top of the IME menu. |
(...skipping 10 matching lines...) Expand all Loading... |
349 bubble_view->AddChildView(new ImeButtonsView(this)); | 347 bubble_view->AddChildView(new ImeButtonsView(this)); |
350 | 348 |
351 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); | 349 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); |
352 SetIsActive(true); | 350 SetIsActive(true); |
353 } | 351 } |
354 | 352 |
355 void ImeMenuTray::HideImeMenuBubble() { | 353 void ImeMenuTray::HideImeMenuBubble() { |
356 bubble_.reset(); | 354 bubble_.reset(); |
357 ime_list_view_ = nullptr; | 355 ime_list_view_ = nullptr; |
358 SetIsActive(false); | 356 SetIsActive(false); |
359 should_block_shelf_auto_hide_ = false; | |
360 shelf()->UpdateAutoHideState(); | 357 shelf()->UpdateAutoHideState(); |
361 } | 358 } |
362 | 359 |
363 bool ImeMenuTray::IsImeMenuBubbleShown() { | 360 bool ImeMenuTray::IsImeMenuBubbleShown() { |
364 return !!bubble_; | 361 return !!bubble_; |
365 } | 362 } |
366 | 363 |
367 void ImeMenuTray::ShowKeyboardWithKeyset(const std::string& keyset) { | 364 void ImeMenuTray::ShowKeyboardWithKeyset(const std::string& keyset) { |
368 HideImeMenuBubble(); | 365 HideImeMenuBubble(); |
369 | 366 |
(...skipping 28 matching lines...) Expand all Loading... |
398 // keyboard for one time. | 395 // keyboard for one time. |
399 force_show_keyboard_ = true; | 396 force_show_keyboard_ = true; |
400 accessibility_delegate->SetVirtualKeyboardEnabled(true); | 397 accessibility_delegate->SetVirtualKeyboardEnabled(true); |
401 keyboard_controller = keyboard::KeyboardController::GetInstance(); | 398 keyboard_controller = keyboard::KeyboardController::GetInstance(); |
402 if (keyboard_controller) { | 399 if (keyboard_controller) { |
403 keyboard_controller->AddObserver(this); | 400 keyboard_controller->AddObserver(this); |
404 keyboard_controller->ShowKeyboard(false); | 401 keyboard_controller->ShowKeyboard(false); |
405 } | 402 } |
406 } | 403 } |
407 | 404 |
408 bool ImeMenuTray::ShouldBlockShelfAutoHide() const { | |
409 return should_block_shelf_auto_hide_; | |
410 } | |
411 | |
412 bool ImeMenuTray::ShouldShowEmojiHandwritingVoiceButtons() const { | 405 bool ImeMenuTray::ShouldShowEmojiHandwritingVoiceButtons() const { |
413 // Emoji, handwriting and voice input is not supported for these cases: | 406 // Emoji, handwriting and voice input is not supported for these cases: |
414 // 1) features::kEHVInputOnImeMenu is not enabled. | 407 // 1) features::kEHVInputOnImeMenu is not enabled. |
415 // 2) third party IME extensions. | 408 // 2) third party IME extensions. |
416 // 3) login/lock screen. | 409 // 3) login/lock screen. |
417 // 4) password input client. | 410 // 4) password input client. |
418 return InputMethodManager::Get() && | 411 return InputMethodManager::Get() && |
419 InputMethodManager::Get()->IsEmojiHandwritingVoiceOnImeMenuEnabled() && | 412 InputMethodManager::Get()->IsEmojiHandwritingVoiceOnImeMenuEnabled() && |
420 !current_ime_.third_party && !IsInLoginOrLockScreen() && | 413 !current_ime_.third_party && !IsInLoginOrLockScreen() && |
421 !IsInPasswordInputContext(); | 414 !IsInPasswordInputContext(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 546 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
554 | 547 |
555 // Updates the tray label based on the current input method. | 548 // Updates the tray label based on the current input method. |
556 if (current_ime_.third_party) | 549 if (current_ime_.third_party) |
557 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 550 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
558 else | 551 else |
559 label_->SetText(current_ime_.short_name); | 552 label_->SetText(current_ime_.short_name); |
560 } | 553 } |
561 | 554 |
562 } // namespace ash | 555 } // namespace ash |
OLD | NEW |