| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Returns the minimum with of IME menu. | 60 // Returns the minimum with of IME menu. |
| 61 int GetMinimumMenuWidth() { | 61 int GetMinimumMenuWidth() { |
| 62 return MaterialDesignController::IsSystemTrayMenuMaterial() | 62 return MaterialDesignController::IsSystemTrayMenuMaterial() |
| 63 ? kTrayMenuMinimumWidthMd | 63 ? kTrayMenuMinimumWidthMd |
| 64 : kTrayMenuMinimumWidth; | 64 : kTrayMenuMinimumWidth; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Shows language and input settings page. | 67 // Shows language and input settings page. |
| 68 void ShowIMESettings() { | 68 void ShowIMESettings() { |
| 69 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); | 69 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 70 WmShell::Get()->system_tray_controller()->ShowIMESettings(); | 70 Shell::Get()->system_tray_controller()->ShowIMESettings(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 // Records the number of times users click buttons in opt-in IME menu. | 73 // Records the number of times users click buttons in opt-in IME menu. |
| 74 void RecordButtonsClicked(const std::string& button_name) { | 74 void RecordButtonsClicked(const std::string& button_name) { |
| 75 enum { | 75 enum { |
| 76 UNKNOWN = 0, | 76 UNKNOWN = 0, |
| 77 EMOJI = 1, | 77 EMOJI = 1, |
| 78 HANDWRITING = 2, | 78 HANDWRITING = 2, |
| 79 VOICE = 3, | 79 VOICE = 3, |
| 80 // SETTINGS is not used for now. | 80 // SETTINGS is not used for now. |
| 81 SETTINGS = 4, | 81 SETTINGS = 4, |
| 82 BUTTON_MAX | 82 BUTTON_MAX |
| 83 } button = UNKNOWN; | 83 } button = UNKNOWN; |
| 84 if (button_name == "emoji") { | 84 if (button_name == "emoji") { |
| 85 button = EMOJI; | 85 button = EMOJI; |
| 86 } else if (button_name == "hwt") { | 86 } else if (button_name == "hwt") { |
| 87 button = HANDWRITING; | 87 button = HANDWRITING; |
| 88 } else if (button_name == "voice") { | 88 } else if (button_name == "voice") { |
| 89 button = VOICE; | 89 button = VOICE; |
| 90 } | 90 } |
| 91 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", | 91 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", |
| 92 button, BUTTON_MAX); | 92 button, BUTTON_MAX); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // Returns true if the current screen is login or lock screen. | 95 // Returns true if the current screen is login or lock screen. |
| 96 bool IsInLoginOrLockScreen() { | 96 bool IsInLoginOrLockScreen() { |
| 97 LoginStatus login = | 97 LoginStatus login = |
| 98 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 98 Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
| 99 return !TrayPopupUtils::CanOpenWebUISettings(login); | 99 return !TrayPopupUtils::CanOpenWebUISettings(login); |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Returns true if the current input context type is password. | 102 // Returns true if the current input context type is password. |
| 103 bool IsInPasswordInputContext() { | 103 bool IsInPasswordInputContext() { |
| 104 return ui::IMEBridge::Get()->GetCurrentInputContext().type == | 104 return ui::IMEBridge::Get()->GetCurrentInputContext().type == |
| 105 ui::TEXT_INPUT_TYPE_PASSWORD; | 105 ui::TEXT_INPUT_TYPE_PASSWORD; |
| 106 } | 106 } |
| 107 | 107 |
| 108 class ImeMenuLabel : public views::Label { | 108 class ImeMenuLabel : public views::Label { |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (bubble_) | 528 if (bubble_) |
| 529 HideImeMenuBubble(); | 529 HideImeMenuBubble(); |
| 530 else | 530 else |
| 531 ShowImeMenuBubble(); | 531 ShowImeMenuBubble(); |
| 532 return true; | 532 return true; |
| 533 } | 533 } |
| 534 | 534 |
| 535 void ImeMenuTray::OnIMERefresh() { | 535 void ImeMenuTray::OnIMERefresh() { |
| 536 UpdateTrayLabel(); | 536 UpdateTrayLabel(); |
| 537 if (bubble_ && ime_list_view_) { | 537 if (bubble_ && ime_list_view_) { |
| 538 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 538 SystemTrayDelegate* delegate = Shell::Get()->system_tray_delegate(); |
| 539 IMEInfoList list; | 539 IMEInfoList list; |
| 540 delegate->GetAvailableIMEList(&list); | 540 delegate->GetAvailableIMEList(&list); |
| 541 IMEPropertyInfoList property_list; | 541 IMEPropertyInfoList property_list; |
| 542 delegate->GetCurrentIMEProperties(&property_list); | 542 delegate->GetCurrentIMEProperties(&property_list); |
| 543 ime_list_view_->Update(list, property_list, false, | 543 ime_list_view_->Update(list, property_list, false, |
| 544 ImeListView::SHOW_SINGLE_IME); | 544 ImeListView::SHOW_SINGLE_IME); |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 | 547 |
| 548 void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) { | 548 void ImeMenuTray::OnIMEMenuActivationChanged(bool is_activated) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 force_show_keyboard_ = false; | 629 force_show_keyboard_ = false; |
| 630 } | 630 } |
| 631 | 631 |
| 632 void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) { | 632 void ImeMenuTray::OnKeyboardSuppressionChanged(bool suppressed) { |
| 633 if (suppressed != keyboard_suppressed_ && bubble_) | 633 if (suppressed != keyboard_suppressed_ && bubble_) |
| 634 HideImeMenuBubble(); | 634 HideImeMenuBubble(); |
| 635 keyboard_suppressed_ = suppressed; | 635 keyboard_suppressed_ = suppressed; |
| 636 } | 636 } |
| 637 | 637 |
| 638 void ImeMenuTray::UpdateTrayLabel() { | 638 void ImeMenuTray::UpdateTrayLabel() { |
| 639 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 639 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 640 | 640 |
| 641 // Updates the tray label based on the current input method. | 641 // Updates the tray label based on the current input method. |
| 642 if (current_ime_.third_party) | 642 if (current_ime_.third_party) |
| 643 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 643 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 644 else | 644 else |
| 645 label_->SetText(current_ime_.short_name); | 645 label_->SetText(current_ime_.short_name); |
| 646 } | 646 } |
| 647 | 647 |
| 648 } // namespace ash | 648 } // namespace ash |
| OLD | NEW |