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" |
11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
13 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" | 13 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" |
14 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 14 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
15 #include "ash/common/system/tray/hover_highlight_view.h" | 15 #include "ash/common/system/tray/hover_highlight_view.h" |
16 #include "ash/common/system/tray/system_menu_button.h" | 16 #include "ash/common/system/tray/system_menu_button.h" |
17 #include "ash/common/system/tray/system_tray_controller.h" | 17 #include "ash/common/system/tray/system_tray_controller.h" |
18 #include "ash/common/system/tray/system_tray_delegate.h" | 18 #include "ash/common/system/tray/system_tray_delegate.h" |
19 #include "ash/common/system/tray/system_tray_notifier.h" | 19 #include "ash/common/system/tray/system_tray_notifier.h" |
20 #include "ash/common/system/tray/tray_constants.h" | 20 #include "ash/common/system/tray/tray_constants.h" |
21 #include "ash/common/system/tray/tray_popup_item_style.h" | 21 #include "ash/common/system/tray/tray_popup_item_style.h" |
22 #include "ash/common/system/tray/tray_popup_utils.h" | 22 #include "ash/common/system/tray/tray_popup_utils.h" |
23 #include "ash/common/system/tray/tray_utils.h" | 23 #include "ash/common/system/tray/tray_utils.h" |
24 #include "ash/common/wm_lookup.h" | 24 #include "ash/common/wm_lookup.h" |
25 #include "ash/common/wm_root_window_controller.h" | 25 #include "ash/common/wm_root_window_controller.h" |
26 #include "ash/common/wm_shell.h" | 26 #include "ash/common/wm_shell.h" |
27 #include "ash/common/wm_window.h" | 27 #include "ash/common/wm_window.h" |
28 #include "ash/public/cpp/shell_window_ids.h" | 28 #include "ash/public/cpp/shell_window_ids.h" |
| 29 #include "base/metrics/histogram_macros.h" |
29 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
30 #include "grit/ash_resources.h" | 31 #include "grit/ash_resources.h" |
31 #include "grit/ash_strings.h" | 32 #include "grit/ash_strings.h" |
32 #include "ui/base/ime/chromeos/input_method_manager.h" | 33 #include "ui/base/ime/chromeos/input_method_manager.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
35 #include "ui/gfx/paint_vector_icon.h" | 36 #include "ui/gfx/paint_vector_icon.h" |
36 #include "ui/gfx/range/range.h" | 37 #include "ui/gfx/range/range.h" |
37 #include "ui/gfx/vector_icons_public.h" | 38 #include "ui/gfx/vector_icons_public.h" |
38 #include "ui/keyboard/keyboard_controller.h" | 39 #include "ui/keyboard/keyboard_controller.h" |
(...skipping 22 matching lines...) Expand all Loading... |
61 ? kTrayMenuMinimumWidthMd | 62 ? kTrayMenuMinimumWidthMd |
62 : kTrayMenuMinimumWidth; | 63 : kTrayMenuMinimumWidth; |
63 } | 64 } |
64 | 65 |
65 // Shows language and input settings page. | 66 // Shows language and input settings page. |
66 void ShowIMESettings() { | 67 void ShowIMESettings() { |
67 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); | 68 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); |
68 WmShell::Get()->system_tray_controller()->ShowIMESettings(); | 69 WmShell::Get()->system_tray_controller()->ShowIMESettings(); |
69 } | 70 } |
70 | 71 |
| 72 // Records the number of times users click buttons in opt-in IME menu. |
| 73 void RecordButtonsClicked(const std::string& button_name) { |
| 74 enum { |
| 75 UNKNOWN = 0, |
| 76 EMOJI = 1, |
| 77 HANDWRITING = 2, |
| 78 VOICE = 3, |
| 79 // SETTINGS is not used for now. |
| 80 SETTINGS = 4, |
| 81 BUTTON_MAX |
| 82 } button = UNKNOWN; |
| 83 if (button_name == "emoji") { |
| 84 button = EMOJI; |
| 85 } else if (button_name == "hwt") { |
| 86 button = HANDWRITING; |
| 87 } else if (button_name == "voice") { |
| 88 button = VOICE; |
| 89 } |
| 90 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", |
| 91 button, BUTTON_MAX); |
| 92 } |
| 93 |
71 // Returns true if the current screen is login or lock screen. | 94 // Returns true if the current screen is login or lock screen. |
72 bool IsInLoginOrLockScreen() { | 95 bool IsInLoginOrLockScreen() { |
73 LoginStatus login = | 96 LoginStatus login = |
74 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 97 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
75 return !TrayPopupUtils::CanOpenWebUISettings(login); | 98 return !TrayPopupUtils::CanOpenWebUISettings(login); |
76 } | 99 } |
77 | 100 |
78 class ImeMenuLabel : public views::Label { | 101 class ImeMenuLabel : public views::Label { |
79 public: | 102 public: |
80 ImeMenuLabel() {} | 103 ImeMenuLabel() {} |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if (sender == settings_button_) { | 218 if (sender == settings_button_) { |
196 ime_menu_tray_->HideImeMenuBubble(); | 219 ime_menu_tray_->HideImeMenuBubble(); |
197 ShowIMESettings(); | 220 ShowIMESettings(); |
198 return; | 221 return; |
199 } | 222 } |
200 | 223 |
201 // The |keyset| will be used for drawing input view keyset in IME | 224 // The |keyset| will be used for drawing input view keyset in IME |
202 // extensions. InputMethodManager::ShowKeyboardWithKeyset() will deal with | 225 // extensions. InputMethodManager::ShowKeyboardWithKeyset() will deal with |
203 // the |keyset| string to generate the right input view url. | 226 // the |keyset| string to generate the right input view url. |
204 std::string keyset; | 227 std::string keyset; |
205 if (sender == emoji_button_) | 228 if (sender == emoji_button_) { |
206 keyset = "emoji"; | 229 keyset = "emoji"; |
207 else if (sender == voice_button_) | 230 RecordButtonsClicked(keyset); |
| 231 } else if (sender == voice_button_) { |
208 keyset = "voice"; | 232 keyset = "voice"; |
209 else if (sender == handwriting_button_) | 233 RecordButtonsClicked(keyset); |
| 234 } else if (sender == handwriting_button_) { |
210 keyset = "hwt"; | 235 keyset = "hwt"; |
211 else | 236 RecordButtonsClicked(keyset); |
| 237 } else { |
212 NOTREACHED(); | 238 NOTREACHED(); |
| 239 } |
213 | 240 |
214 ime_menu_tray_->ShowKeyboardWithKeyset(keyset); | 241 ime_menu_tray_->ShowKeyboardWithKeyset(keyset); |
215 } | 242 } |
216 | 243 |
217 // ViewClickListener: | 244 // ViewClickListener: |
218 void OnViewClicked(views::View* sender) override { | 245 void OnViewClicked(views::View* sender) override { |
219 if (one_settings_button_view_ && sender == one_settings_button_view_) { | 246 if (one_settings_button_view_ && sender == one_settings_button_view_) { |
220 ime_menu_tray_->HideImeMenuBubble(); | 247 ime_menu_tray_->HideImeMenuBubble(); |
221 ShowIMESettings(); | 248 ShowIMESettings(); |
222 } | 249 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 639 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
613 | 640 |
614 // Updates the tray label based on the current input method. | 641 // Updates the tray label based on the current input method. |
615 if (current_ime_.third_party) | 642 if (current_ime_.third_party) |
616 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 643 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
617 else | 644 else |
618 label_->SetText(current_ime_.short_name); | 645 label_->SetText(current_ime_.short_name); |
619 } | 646 } |
620 | 647 |
621 } // namespace ash | 648 } // namespace ash |
OLD | NEW |