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/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
8 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
9 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
10 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
11 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" | 12 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" |
12 #include "ash/common/system/tray/fixed_sized_scroll_view.h" | 13 #include "ash/common/system/tray/fixed_sized_scroll_view.h" |
13 #include "ash/common/system/tray/hover_highlight_view.h" | 14 #include "ash/common/system/tray/hover_highlight_view.h" |
14 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
15 #include "ash/common/system/tray/system_tray_notifier.h" | 16 #include "ash/common/system/tray/system_tray_notifier.h" |
16 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
17 #include "ash/common/system/tray/tray_popup_header_button.h" | 18 #include "ash/common/system/tray/tray_popup_header_button.h" |
18 #include "ash/common/system/tray/tray_utils.h" | 19 #include "ash/common/system/tray/tray_utils.h" |
19 #include "ash/common/wm_lookup.h" | 20 #include "ash/common/wm_lookup.h" |
20 #include "ash/common/wm_root_window_controller.h" | 21 #include "ash/common/wm_root_window_controller.h" |
21 #include "ash/common/wm_shell.h" | 22 #include "ash/common/wm_shell.h" |
22 #include "ash/common/wm_window.h" | 23 #include "ash/common/wm_window.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "grit/ash_resources.h" | 25 #include "grit/ash_resources.h" |
25 #include "grit/ash_strings.h" | 26 #include "grit/ash_strings.h" |
| 27 #include "ui/base/ime/chromeos/input_method_manager.h" |
26 #include "ui/base/l10n/l10n_util.h" | 28 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/keyboard/keyboard_controller.h" |
| 31 #include "ui/keyboard/keyboard_util.h" |
28 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
29 #include "ui/views/layout/box_layout.h" | 33 #include "ui/views/layout/box_layout.h" |
30 | 34 |
| 35 using chromeos::input_method::InputMethodManager; |
| 36 |
31 namespace ash { | 37 namespace ash { |
32 | 38 |
33 namespace { | 39 namespace { |
34 | 40 |
| 41 // The border width between buttons. |
| 42 const int kButtonRightBorder = 1; |
| 43 |
35 // Returns the max height of ImeListView. | 44 // Returns the max height of ImeListView. |
36 int GetImeListViewMaxHeight() { | 45 int GetImeListViewMaxHeight() { |
37 const int max_items = 7; | 46 const int max_items = 7; |
38 return GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT) * max_items; | 47 return GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT) * max_items; |
39 } | 48 } |
40 | 49 |
41 // Shows language and input settings page. | 50 // Shows language and input settings page. |
42 void ShowIMESettings() { | 51 void ShowIMESettings() { |
43 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); | 52 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); |
44 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); | 53 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 button->SetBorder(views::Border::CreateSolidSidedBorder(0, 0, 0, right_border, | 85 button->SetBorder(views::Border::CreateSolidSidedBorder(0, 0, 0, right_border, |
77 kBorderDarkColor)); | 86 kBorderDarkColor)); |
78 return button; | 87 return button; |
79 } | 88 } |
80 | 89 |
81 // The view that contains buttons shown on the bottom of IME menu. | 90 // The view that contains buttons shown on the bottom of IME menu. |
82 class ImeButtonsView : public views::View, | 91 class ImeButtonsView : public views::View, |
83 public views::ButtonListener, | 92 public views::ButtonListener, |
84 public ViewClickListener { | 93 public ViewClickListener { |
85 public: | 94 public: |
86 ImeButtonsView(bool show_emoji_button, | 95 ImeButtonsView(ImeMenuTray* ime_menu_tray, |
| 96 bool show_emoji_button, |
87 bool show_voice_button, | 97 bool show_voice_button, |
88 bool show_handwriting_button, | 98 bool show_handwriting_button, |
89 bool show_settings_button) { | 99 bool show_settings_button) |
| 100 : ime_menu_tray_(ime_menu_tray) { |
| 101 DCHECK(ime_menu_tray_); |
| 102 |
90 SetBorder( | 103 SetBorder( |
91 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor)); | 104 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor)); |
92 | 105 |
93 // If there's only one settings button, the bottom should be a label with | 106 // If there's only one settings button, the bottom should be a label with |
94 // normal background. Otherwise, show button icons with header background. | 107 // normal background. Otherwise, show button icons with header background. |
95 if (show_settings_button && !show_emoji_button && !show_voice_button && | 108 if (show_settings_button && !show_emoji_button && !show_voice_button && |
96 !show_handwriting_button) { | 109 !show_handwriting_button) { |
97 ShowOneSettingButton(); | 110 ShowOneSettingButton(); |
98 } else { | 111 } else { |
99 ShowButtons(show_emoji_button, show_voice_button, show_handwriting_button, | 112 ShowButtons(show_emoji_button, show_voice_button, show_handwriting_button, |
100 show_settings_button); | 113 show_settings_button); |
101 } | 114 } |
102 // TODO(azurewei): Add logic of switching between the two states when the | 115 // TODO(azurewei): Add logic of switching between the two states when the |
103 // menu is shown. | 116 // menu is shown. |
104 } | 117 } |
105 | 118 |
106 ~ImeButtonsView() override {} | 119 ~ImeButtonsView() override {} |
107 | 120 |
108 // views::View: | 121 // views::View: |
109 gfx::Size GetPreferredSize() const override { | 122 gfx::Size GetPreferredSize() const override { |
110 int size = GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT); | 123 int size = GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT); |
111 return gfx::Size(size, size); | 124 return gfx::Size(size, size); |
112 } | 125 } |
113 int GetHeightForWidth(int width) const override { | 126 int GetHeightForWidth(int width) const override { |
114 return GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT); | 127 return GetTrayConstant(TRAY_POPUP_ITEM_HEIGHT); |
115 } | 128 } |
116 | 129 |
117 // views::ButtonListener: | 130 // views::ButtonListener: |
118 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 131 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
119 if (emoji_button_ && sender == emoji_button_) { | 132 if (sender == settings_button_) { |
120 // TODO(azurewei): Opens emoji palette. | 133 ime_menu_tray_->HideImeMenuBubble(); |
121 } else if (voice_button_ && sender == voice_button_) { | |
122 // TODO(azurewei): Brings virtual keyboard for emoji input. | |
123 } else if (handwriting_button_ && sender == handwriting_button_) { | |
124 // TODO(azurewei): Brings virtual keyboard for handwriting input. | |
125 } else if (settings_button_ && sender == settings_button_) { | |
126 ShowIMESettings(); | 134 ShowIMESettings(); |
| 135 return; |
127 } | 136 } |
| 137 |
| 138 // The |keyset| will be used for drawing input view keyset in IME |
| 139 // extensions. InputMethodManager::ShowKeyboardWithKeyset() will deal with |
| 140 // the |keyset| string to generate the right input view url. |
| 141 std::string keyset; |
| 142 if (sender == emoji_button_) |
| 143 keyset = "emoji"; |
| 144 else if (sender == voice_button_) |
| 145 keyset = "voice"; |
| 146 else if (sender == handwriting_button_) |
| 147 keyset = "hwt"; |
| 148 else |
| 149 NOTREACHED(); |
| 150 |
| 151 ime_menu_tray_->ShowKeyboardWithKeyset(keyset); |
128 } | 152 } |
129 | 153 |
130 // ViewClickListener: | 154 // ViewClickListener: |
131 void OnViewClicked(views::View* sender) override { | 155 void OnViewClicked(views::View* sender) override { |
132 if (one_settings_button_view_ && sender == one_settings_button_view_) { | 156 if (one_settings_button_view_ && sender == one_settings_button_view_) { |
| 157 ime_menu_tray_->HideImeMenuBubble(); |
133 ShowIMESettings(); | 158 ShowIMESettings(); |
134 } | 159 } |
135 } | 160 } |
136 | 161 |
137 private: | 162 private: |
138 // Shows the UI of one settings button. | 163 // Shows the UI of one settings button. |
139 void ShowOneSettingButton() { | 164 void ShowOneSettingButton() { |
140 auto* box_layout = | 165 auto* box_layout = |
141 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 166 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
142 box_layout->SetDefaultFlex(1); | 167 box_layout->SetDefaultFlex(1); |
(...skipping 14 matching lines...) Expand all Loading... |
157 set_background( | 182 set_background( |
158 views::Background::CreateSolidBackground(kHeaderBackgroundColor)); | 183 views::Background::CreateSolidBackground(kHeaderBackgroundColor)); |
159 auto* box_layout = new views::BoxLayout( | 184 auto* box_layout = new views::BoxLayout( |
160 views::BoxLayout::kHorizontal, kTrayImeBottomRowPadding, | 185 views::BoxLayout::kHorizontal, kTrayImeBottomRowPadding, |
161 kTrayImeBottomRowPadding, kTrayImeBottomRowPaddingBetweenItems); | 186 kTrayImeBottomRowPadding, kTrayImeBottomRowPaddingBetweenItems); |
162 box_layout->SetDefaultFlex(1); | 187 box_layout->SetDefaultFlex(1); |
163 SetLayoutManager(box_layout); | 188 SetLayoutManager(box_layout); |
164 | 189 |
165 if (show_emoji_button) { | 190 if (show_emoji_button) { |
166 // TODO(azurewei): Creates the proper button with icons. | 191 // TODO(azurewei): Creates the proper button with icons. |
| 192 emoji_button_ = CreateImeMenuButton( |
| 193 this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 194 IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 195 IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
| 196 kButtonRightBorder); |
| 197 AddChildView(emoji_button_); |
167 } | 198 } |
168 | 199 |
169 if (show_voice_button) { | 200 if (show_voice_button) { |
170 // TODO(azurewei): Creates the proper button with icons. | 201 // TODO(azurewei): Creates the proper button with icons. |
| 202 voice_button_ = CreateImeMenuButton( |
| 203 this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 204 IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 205 IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
| 206 kButtonRightBorder); |
| 207 AddChildView(voice_button_); |
171 } | 208 } |
172 | 209 |
173 if (show_handwriting_button) { | 210 if (show_handwriting_button) { |
174 // TODO(azurewei): Creates the proper button with icons. | 211 // TODO(azurewei): Creates the proper button with icons. |
| 212 handwriting_button_ = CreateImeMenuButton( |
| 213 this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 214 IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
| 215 IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, |
| 216 kButtonRightBorder); |
| 217 AddChildView(handwriting_button_); |
175 } | 218 } |
176 | 219 |
177 if (show_settings_button) { | 220 if (show_settings_button) { |
178 settings_button_ = CreateImeMenuButton( | 221 settings_button_ = CreateImeMenuButton( |
179 this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, | 222 this, IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
180 IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, | 223 IDR_AURA_UBER_TRAY_SETTINGS, IDR_AURA_UBER_TRAY_SETTINGS, |
181 IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, 0); | 224 IDS_ASH_STATUS_TRAY_SETTINGS, IDS_ASH_STATUS_TRAY_SETTINGS, 0); |
182 AddChildView(settings_button_); | 225 AddChildView(settings_button_); |
183 } | 226 } |
184 } | 227 } |
185 | 228 |
| 229 ImeMenuTray* ime_menu_tray_; |
186 TrayPopupHeaderButton* emoji_button_; | 230 TrayPopupHeaderButton* emoji_button_; |
187 TrayPopupHeaderButton* voice_button_; | 231 TrayPopupHeaderButton* voice_button_; |
188 TrayPopupHeaderButton* handwriting_button_; | 232 TrayPopupHeaderButton* handwriting_button_; |
189 TrayPopupHeaderButton* settings_button_; | 233 TrayPopupHeaderButton* settings_button_; |
190 HoverHighlightView* one_settings_button_view_; | 234 HoverHighlightView* one_settings_button_view_; |
191 | 235 |
192 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); | 236 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); |
193 }; | 237 }; |
194 | 238 |
195 } // namespace | 239 } // namespace |
196 | 240 |
197 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) | 241 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) |
198 : TrayBackgroundView(wm_shelf), label_(new ImeMenuLabel()) { | 242 : TrayBackgroundView(wm_shelf), |
| 243 label_(new ImeMenuLabel()), |
| 244 show_keyboard_(false), |
| 245 force_show_keyboard_(false) { |
199 SetupLabelForTray(label_); | 246 SetupLabelForTray(label_); |
200 tray_container()->AddChildView(label_); | 247 tray_container()->AddChildView(label_); |
201 SetContentsBackground(); | 248 SetContentsBackground(); |
202 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this); | 249 WmShell::Get()->system_tray_notifier()->AddIMEObserver(this); |
203 } | 250 } |
204 | 251 |
205 ImeMenuTray::~ImeMenuTray() { | 252 ImeMenuTray::~ImeMenuTray() { |
206 if (bubble_) | 253 if (bubble_) |
207 bubble_->bubble_view()->reset_delegate(); | 254 bubble_->bubble_view()->reset_delegate(); |
208 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this); | 255 WmShell::Get()->system_tray_notifier()->RemoveIMEObserver(this); |
(...skipping 18 matching lines...) Expand all Loading... |
227 if (ime_list_view_->scroll_content()->height() > GetImeListViewMaxHeight()) { | 274 if (ime_list_view_->scroll_content()->height() > GetImeListViewMaxHeight()) { |
228 ime_list_view_->scroller()->SetFixedSize( | 275 ime_list_view_->scroller()->SetFixedSize( |
229 gfx::Size(kTrayPopupMaxWidth, GetImeListViewMaxHeight())); | 276 gfx::Size(kTrayPopupMaxWidth, GetImeListViewMaxHeight())); |
230 } | 277 } |
231 bubble_view->AddChildView(ime_list_view_); | 278 bubble_view->AddChildView(ime_list_view_); |
232 | 279 |
233 // Adds IME buttons to the bubble if needed. | 280 // Adds IME buttons to the bubble if needed. |
234 LoginStatus login = | 281 LoginStatus login = |
235 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 282 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus(); |
236 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED && | 283 if (login != LoginStatus::NOT_LOGGED_IN && login != LoginStatus::LOCKED && |
237 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) | 284 !WmShell::Get()->GetSessionStateDelegate()->IsInSecondaryLoginScreen()) { |
238 bubble_view->AddChildView(new ImeButtonsView(false, false, false, true)); | 285 if (InputMethodManager::Get() && |
| 286 InputMethodManager::Get()->IsEmojiHandwritingVoiceOnImeMenuEnabled() && |
| 287 !current_ime_.third_party) { |
| 288 bubble_view->AddChildView( |
| 289 new ImeButtonsView(this, true, true, true, true)); |
| 290 } else { |
| 291 bubble_view->AddChildView( |
| 292 new ImeButtonsView(this, false, false, false, true)); |
| 293 } |
| 294 } |
239 | 295 |
240 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); | 296 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); |
241 SetDrawBackgroundAsActive(true); | 297 SetDrawBackgroundAsActive(true); |
242 } | 298 } |
243 | 299 |
| 300 void ImeMenuTray::HideImeMenuBubble() { |
| 301 bubble_.reset(); |
| 302 ime_list_view_ = nullptr; |
| 303 SetDrawBackgroundAsActive(false); |
| 304 } |
| 305 |
244 bool ImeMenuTray::IsImeMenuBubbleShown() { | 306 bool ImeMenuTray::IsImeMenuBubbleShown() { |
245 return !!bubble_; | 307 return !!bubble_; |
246 } | 308 } |
247 | 309 |
| 310 void ImeMenuTray::ShowKeyboardWithKeyset(const std::string& keyset) { |
| 311 HideImeMenuBubble(); |
| 312 |
| 313 // Overrides the keyboard url ref to make it shown with the given keyset. |
| 314 if (InputMethodManager::Get()) |
| 315 InputMethodManager::Get()->OverrideKeyboardUrlRef(keyset); |
| 316 |
| 317 // If onscreen keyboard has been enabled, shows the keyboard directly. |
| 318 keyboard::KeyboardController* keyboard_controller = |
| 319 keyboard::KeyboardController::GetInstance(); |
| 320 show_keyboard_ = true; |
| 321 if (keyboard_controller) { |
| 322 keyboard_controller->AddObserver(this); |
| 323 keyboard_controller->ShowKeyboard(false); |
| 324 return; |
| 325 } |
| 326 |
| 327 AccessibilityDelegate* accessibility_delegate = |
| 328 WmShell::Get()->accessibility_delegate(); |
| 329 // Fails to show the keyboard. |
| 330 if (accessibility_delegate->IsVirtualKeyboardEnabled()) |
| 331 return; |
| 332 |
| 333 // Onscreen keyboard has not been enabled yet, forces to bring out the |
| 334 // keyboard for one time. |
| 335 force_show_keyboard_ = true; |
| 336 accessibility_delegate->SetVirtualKeyboardEnabled(true); |
| 337 keyboard_controller = keyboard::KeyboardController::GetInstance(); |
| 338 if (keyboard_controller) { |
| 339 keyboard_controller->AddObserver(this); |
| 340 keyboard_controller->ShowKeyboard(false); |
| 341 } |
| 342 } |
| 343 |
248 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { | 344 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { |
249 TrayBackgroundView::SetShelfAlignment(alignment); | 345 TrayBackgroundView::SetShelfAlignment(alignment); |
250 if (!MaterialDesignController::IsShelfMaterial()) | 346 if (!MaterialDesignController::IsShelfMaterial()) |
251 tray_container()->SetBorder(views::Border::NullBorder()); | 347 tray_container()->SetBorder(views::Border::NullBorder()); |
252 } | 348 } |
253 | 349 |
254 base::string16 ImeMenuTray::GetAccessibleNameForTray() { | 350 base::string16 ImeMenuTray::GetAccessibleNameForTray() { |
255 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); | 351 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); |
256 } | 352 } |
257 | 353 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 ->GetWindowForWidget(anchor_widget) | 429 ->GetWindowForWidget(anchor_widget) |
334 ->GetRootWindowController() | 430 ->GetRootWindowController() |
335 ->ConfigureWidgetInitParamsForContainer( | 431 ->ConfigureWidgetInitParamsForContainer( |
336 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | 432 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
337 } | 433 } |
338 | 434 |
339 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 435 void ImeMenuTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
340 HideBubbleWithView(bubble_view); | 436 HideBubbleWithView(bubble_view); |
341 } | 437 } |
342 | 438 |
| 439 void ImeMenuTray::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) {} |
| 440 |
| 441 void ImeMenuTray::OnKeyboardClosed() { |
| 442 if (InputMethodManager::Get()) |
| 443 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); |
| 444 show_keyboard_ = false; |
| 445 force_show_keyboard_ = false; |
| 446 } |
| 447 |
| 448 void ImeMenuTray::OnKeyboardHidden() { |
| 449 if (!show_keyboard_) |
| 450 return; |
| 451 |
| 452 // If the the IME menu has overriding the input view url, we should write it |
| 453 // back to normal keyboard when hiding the input view. |
| 454 if (InputMethodManager::Get()) |
| 455 InputMethodManager::Get()->OverrideKeyboardUrlRef(std::string()); |
| 456 show_keyboard_ = false; |
| 457 |
| 458 // If the keyboard is forced to be shown by IME menu for once, we need to |
| 459 // disable the keyboard when it's hidden. |
| 460 keyboard::KeyboardController* keyboard_controller = |
| 461 keyboard::KeyboardController::GetInstance(); |
| 462 if (keyboard_controller) |
| 463 keyboard_controller->RemoveObserver(this); |
| 464 |
| 465 if (!force_show_keyboard_) |
| 466 return; |
| 467 |
| 468 WmShell::Get()->accessibility_delegate()->SetVirtualKeyboardEnabled(false); |
| 469 force_show_keyboard_ = false; |
| 470 } |
| 471 |
343 void ImeMenuTray::UpdateTrayLabel() { | 472 void ImeMenuTray::UpdateTrayLabel() { |
344 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 473 WmShell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
345 | 474 |
346 // Updates the tray label based on the current input method. | 475 // Updates the tray label based on the current input method. |
347 if (current_ime_.third_party) | 476 if (current_ime_.third_party) |
348 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 477 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
349 else | 478 else |
350 label_->SetText(current_ime_.short_name); | 479 label_->SetText(current_ime_.short_name); |
351 } | 480 } |
352 | 481 |
353 void ImeMenuTray::HideImeMenuBubble() { | |
354 bubble_.reset(); | |
355 ime_list_view_ = nullptr; | |
356 SetDrawBackgroundAsActive(false); | |
357 } | |
358 | |
359 } // namespace ash | 482 } // namespace ash |
OLD | NEW |