| 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" | |
| 10 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 11 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 11 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" | 12 #include "ash/common/system/chromeos/ime_menu/ime_list_view.h" |
| 14 #include "ash/common/system/tray/hover_highlight_view.h" | |
| 15 #include "ash/common/system/tray/system_menu_button.h" | 13 #include "ash/common/system/tray/system_menu_button.h" |
| 16 #include "ash/common/system/tray/system_tray_controller.h" | 14 #include "ash/common/system/tray/system_tray_controller.h" |
| 17 #include "ash/common/system/tray/system_tray_delegate.h" | 15 #include "ash/common/system/tray/system_tray_delegate.h" |
| 18 #include "ash/common/system/tray/system_tray_notifier.h" | 16 #include "ash/common/system/tray/system_tray_notifier.h" |
| 19 #include "ash/common/system/tray/tray_constants.h" | 17 #include "ash/common/system/tray/tray_constants.h" |
| 20 #include "ash/common/system/tray/tray_popup_item_style.h" | 18 #include "ash/common/system/tray/tray_popup_item_style.h" |
| 21 #include "ash/common/system/tray/tray_popup_utils.h" | 19 #include "ash/common/system/tray/tray_popup_utils.h" |
| 22 #include "ash/common/system/tray/tray_utils.h" | 20 #include "ash/common/system/tray/tray_utils.h" |
| 23 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 24 #include "ash/common/wm_window.h" | 22 #include "ash/common/wm_window.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 50 | 48 |
| 51 namespace { | 49 namespace { |
| 52 // Returns the height range of ImeListView. | 50 // Returns the height range of ImeListView. |
| 53 gfx::Range GetImeListViewRange() { | 51 gfx::Range GetImeListViewRange() { |
| 54 const int max_items = 5; | 52 const int max_items = 5; |
| 55 const int min_items = 1; | 53 const int min_items = 1; |
| 56 const int tray_item_height = kTrayPopupItemMinHeight; | 54 const int tray_item_height = kTrayPopupItemMinHeight; |
| 57 return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); | 55 return gfx::Range(tray_item_height * min_items, tray_item_height * max_items); |
| 58 } | 56 } |
| 59 | 57 |
| 60 // Returns the minimum with of IME menu. | |
| 61 int GetMinimumMenuWidth() { | |
| 62 return MaterialDesignController::IsSystemTrayMenuMaterial() | |
| 63 ? kTrayMenuMinimumWidthMd | |
| 64 : kTrayMenuMinimumWidth; | |
| 65 } | |
| 66 | |
| 67 // Shows language and input settings page. | 58 // Shows language and input settings page. |
| 68 void ShowIMESettings() { | 59 void ShowIMESettings() { |
| 69 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); | 60 WmShell::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_IME_SHOW_DETAILED); |
| 70 Shell::Get()->system_tray_controller()->ShowIMESettings(); | 61 Shell::Get()->system_tray_controller()->ShowIMESettings(); |
| 71 } | 62 } |
| 72 | 63 |
| 73 // Records the number of times users click buttons in opt-in IME menu. | 64 // Records the number of times users click buttons in opt-in IME menu. |
| 74 void RecordButtonsClicked(const std::string& button_name) { | 65 void RecordButtonsClicked(const std::string& button_name) { |
| 75 enum { | 66 enum { |
| 76 UNKNOWN = 0, | 67 UNKNOWN = 0, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 int GetHeightForWidth(int width) const override { return kTrayItemSize; } | 108 int GetHeightForWidth(int width) const override { return kTrayItemSize; } |
| 118 | 109 |
| 119 private: | 110 private: |
| 120 DISALLOW_COPY_AND_ASSIGN(ImeMenuLabel); | 111 DISALLOW_COPY_AND_ASSIGN(ImeMenuLabel); |
| 121 }; | 112 }; |
| 122 | 113 |
| 123 SystemMenuButton* CreateImeMenuButton(views::ButtonListener* listener, | 114 SystemMenuButton* CreateImeMenuButton(views::ButtonListener* listener, |
| 124 const gfx::VectorIcon& icon, | 115 const gfx::VectorIcon& icon, |
| 125 int accessible_name_id, | 116 int accessible_name_id, |
| 126 int right_border) { | 117 int right_border) { |
| 127 SystemMenuButton* button = new SystemMenuButton( | 118 return new SystemMenuButton(listener, TrayPopupInkDropStyle::HOST_CENTERED, |
| 128 listener, TrayPopupInkDropStyle::HOST_CENTERED, icon, accessible_name_id); | 119 icon, accessible_name_id); |
| 129 if (!MaterialDesignController::IsShelfMaterial()) { | |
| 130 button->SetBorder( | |
| 131 views::CreateSolidSidedBorder(0, 0, 0, right_border, kBorderDarkColor)); | |
| 132 } | |
| 133 return button; | |
| 134 } | 120 } |
| 135 | 121 |
| 136 // The view that contains IME menu title in the material design. | 122 // The view that contains IME menu title. |
| 137 class ImeTitleView : public views::View, public views::ButtonListener { | 123 class ImeTitleView : public views::View, public views::ButtonListener { |
| 138 public: | 124 public: |
| 139 explicit ImeTitleView(bool show_settings_button) : settings_button_(nullptr) { | 125 explicit ImeTitleView(bool show_settings_button) : settings_button_(nullptr) { |
| 140 SetBorder(views::CreatePaddedBorder( | 126 SetBorder(views::CreatePaddedBorder( |
| 141 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, | 127 views::CreateSolidSidedBorder(0, 0, kSeparatorWidth, 0, |
| 142 kMenuSeparatorColor), | 128 kMenuSeparatorColor), |
| 143 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); | 129 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, 0))); |
| 144 auto* box_layout = | 130 auto* box_layout = |
| 145 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 131 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 146 box_layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); | 132 box_layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 167 | 153 |
| 168 // views::ButtonListener: | 154 // views::ButtonListener: |
| 169 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 155 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 170 DCHECK_EQ(sender, settings_button_); | 156 DCHECK_EQ(sender, settings_button_); |
| 171 ShowIMESettings(); | 157 ShowIMESettings(); |
| 172 } | 158 } |
| 173 | 159 |
| 174 ~ImeTitleView() override {} | 160 ~ImeTitleView() override {} |
| 175 | 161 |
| 176 private: | 162 private: |
| 177 // Settings button that is only used in material design, and only if the | 163 // Settings button that is only used if the emoji, handwriting and voice |
| 178 // emoji, handwriting and voice buttons are not available. | 164 // buttons are not available. |
| 179 SystemMenuButton* settings_button_; | 165 SystemMenuButton* settings_button_; |
| 180 | 166 |
| 181 DISALLOW_COPY_AND_ASSIGN(ImeTitleView); | 167 DISALLOW_COPY_AND_ASSIGN(ImeTitleView); |
| 182 }; | 168 }; |
| 183 | 169 |
| 184 // The view that contains buttons shown on the bottom of IME menu. | 170 // The view that contains buttons shown on the bottom of IME menu. |
| 185 class ImeButtonsView : public views::View, | 171 class ImeButtonsView : public views::View, public views::ButtonListener { |
| 186 public views::ButtonListener, | |
| 187 public ViewClickListener { | |
| 188 public: | 172 public: |
| 189 ImeButtonsView(ImeMenuTray* ime_menu_tray, | 173 explicit ImeButtonsView(ImeMenuTray* ime_menu_tray) |
| 190 bool show_emoji_button, | |
| 191 bool show_voice_button, | |
| 192 bool show_handwriting_button, | |
| 193 bool show_settings_button) | |
| 194 : ime_menu_tray_(ime_menu_tray) { | 174 : ime_menu_tray_(ime_menu_tray) { |
| 195 DCHECK(ime_menu_tray_); | 175 DCHECK(ime_menu_tray_); |
| 196 | 176 |
| 197 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) | 177 Init(); |
| 198 SetBorder(views::CreateSolidSidedBorder(1, 0, 0, 0, kBorderDarkColor)); | |
| 199 | |
| 200 // If there's only one settings button, the bottom should be a label with | |
| 201 // normal background. Otherwise, show button icons with header background. | |
| 202 if (show_settings_button && !show_emoji_button && | |
| 203 !show_handwriting_button && !show_voice_button) { | |
| 204 DCHECK(!MaterialDesignController::IsSystemTrayMenuMaterial()); | |
| 205 ShowOneSettingButton(); | |
| 206 } else { | |
| 207 ShowButtons(show_emoji_button, show_handwriting_button, show_voice_button, | |
| 208 show_settings_button); | |
| 209 } | |
| 210 } | 178 } |
| 211 | 179 |
| 212 ~ImeButtonsView() override {} | 180 ~ImeButtonsView() override {} |
| 213 | 181 |
| 214 // views::ButtonListener: | 182 // views::ButtonListener: |
| 215 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 183 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 216 if (sender == settings_button_) { | 184 if (sender == settings_button_) { |
| 217 ime_menu_tray_->HideImeMenuBubble(); | 185 ime_menu_tray_->HideImeMenuBubble(); |
| 218 ShowIMESettings(); | 186 ShowIMESettings(); |
| 219 return; | 187 return; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 232 } else if (sender == handwriting_button_) { | 200 } else if (sender == handwriting_button_) { |
| 233 keyset = "hwt"; | 201 keyset = "hwt"; |
| 234 RecordButtonsClicked(keyset); | 202 RecordButtonsClicked(keyset); |
| 235 } else { | 203 } else { |
| 236 NOTREACHED(); | 204 NOTREACHED(); |
| 237 } | 205 } |
| 238 | 206 |
| 239 ime_menu_tray_->ShowKeyboardWithKeyset(keyset); | 207 ime_menu_tray_->ShowKeyboardWithKeyset(keyset); |
| 240 } | 208 } |
| 241 | 209 |
| 242 // ViewClickListener: | |
| 243 void OnViewClicked(views::View* sender) override { | |
| 244 if (one_settings_button_view_ && sender == one_settings_button_view_) { | |
| 245 ime_menu_tray_->HideImeMenuBubble(); | |
| 246 ShowIMESettings(); | |
| 247 } | |
| 248 } | |
| 249 | |
| 250 private: | 210 private: |
| 251 // Shows the UI of one settings button. | 211 void Init() { |
| 252 void ShowOneSettingButton() { | |
| 253 auto* box_layout = | 212 auto* box_layout = |
| 254 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | 213 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| 255 box_layout->SetDefaultFlex(1); | 214 box_layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); |
| 256 SetLayoutManager(box_layout); | 215 SetLayoutManager(box_layout); |
| 257 one_settings_button_view_ = new HoverHighlightView(this); | 216 SetBorder(views::CreatePaddedBorder( |
| 258 one_settings_button_view_->AddLabel( | 217 views::CreateSolidSidedBorder(kSeparatorWidth, 0, 0, 0, |
| 259 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 218 kMenuSeparatorColor), |
| 260 IDS_ASH_STATUS_TRAY_IME_SETTINGS), | 219 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, |
| 261 gfx::ALIGN_LEFT, false /* highlight */); | 220 kMenuExtraMarginFromLeftEdge))); |
| 262 if (IsInLoginOrLockScreen()) | |
| 263 one_settings_button_view_->SetEnabled(false); | |
| 264 AddChildView(one_settings_button_view_); | |
| 265 } | |
| 266 | |
| 267 // Shows the UI of more than one buttons. | |
| 268 void ShowButtons(bool show_emoji_button, | |
| 269 bool show_handwriting_button, | |
| 270 bool show_voice_button, | |
| 271 bool show_settings_button) { | |
| 272 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
| 273 auto* box_layout = | |
| 274 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); | |
| 275 box_layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); | |
| 276 SetLayoutManager(box_layout); | |
| 277 SetBorder(views::CreatePaddedBorder( | |
| 278 views::CreateSolidSidedBorder(kSeparatorWidth, 0, 0, 0, | |
| 279 kMenuSeparatorColor), | |
| 280 gfx::Insets(kMenuSeparatorVerticalPadding - kSeparatorWidth, | |
| 281 kMenuExtraMarginFromLeftEdge))); | |
| 282 } else { | |
| 283 auto* box_layout = | |
| 284 new views::BoxLayout(views::BoxLayout::kHorizontal, 4, 4, 0); | |
| 285 set_background( | |
| 286 views::Background::CreateSolidBackground(kHeaderBackgroundColor)); | |
| 287 box_layout->SetDefaultFlex(1); | |
| 288 SetLayoutManager(box_layout); | |
| 289 } | |
| 290 | 221 |
| 291 const int right_border = 1; | 222 const int right_border = 1; |
| 292 if (show_emoji_button) { | 223 emoji_button_ = |
| 293 emoji_button_ = | 224 CreateImeMenuButton(this, kImeMenuEmoticonIcon, |
| 294 CreateImeMenuButton(this, kImeMenuEmoticonIcon, | 225 IDS_ASH_STATUS_TRAY_IME_EMOJI, right_border); |
| 295 IDS_ASH_STATUS_TRAY_IME_EMOJI, right_border); | 226 AddChildView(emoji_button_); |
| 296 AddChildView(emoji_button_); | |
| 297 } | |
| 298 | 227 |
| 299 if (show_handwriting_button) { | 228 handwriting_button_ = |
| 300 handwriting_button_ = CreateImeMenuButton( | 229 CreateImeMenuButton(this, kImeMenuWriteIcon, |
| 301 this, kImeMenuWriteIcon, IDS_ASH_STATUS_TRAY_IME_HANDWRITING, | 230 IDS_ASH_STATUS_TRAY_IME_HANDWRITING, right_border); |
| 302 right_border); | 231 AddChildView(handwriting_button_); |
| 303 AddChildView(handwriting_button_); | |
| 304 } | |
| 305 | 232 |
| 306 if (show_voice_button) { | 233 voice_button_ = |
| 307 voice_button_ = | 234 CreateImeMenuButton(this, kImeMenuMicrophoneIcon, |
| 308 CreateImeMenuButton(this, kImeMenuMicrophoneIcon, | 235 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); |
| 309 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); | 236 AddChildView(voice_button_); |
| 310 AddChildView(voice_button_); | |
| 311 } | |
| 312 | 237 |
| 313 if (show_settings_button) { | 238 settings_button_ = CreateImeMenuButton(this, kSystemMenuSettingsIcon, |
| 314 settings_button_ = CreateImeMenuButton( | 239 IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
| 315 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 240 AddChildView(settings_button_); |
| 316 AddChildView(settings_button_); | |
| 317 } | |
| 318 } | 241 } |
| 319 | 242 |
| 320 ImeMenuTray* ime_menu_tray_; | 243 ImeMenuTray* ime_menu_tray_; |
| 321 SystemMenuButton* emoji_button_; | 244 SystemMenuButton* emoji_button_; |
| 322 SystemMenuButton* handwriting_button_; | 245 SystemMenuButton* handwriting_button_; |
| 323 SystemMenuButton* voice_button_; | 246 SystemMenuButton* voice_button_; |
| 324 SystemMenuButton* settings_button_; | 247 SystemMenuButton* settings_button_; |
| 325 HoverHighlightView* one_settings_button_view_; | |
| 326 | 248 |
| 327 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); | 249 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); |
| 328 }; | 250 }; |
| 329 | 251 |
| 330 // The list view that contains the selected IME and property items. | 252 // The list view that contains the selected IME and property items. |
| 331 class ImeMenuListView : public ImeListView { | 253 class ImeMenuListView : public ImeListView { |
| 332 public: | 254 public: |
| 333 ImeMenuListView(SystemTrayItem* owner) : ImeListView(owner) { | 255 ImeMenuListView(SystemTrayItem* owner) : ImeListView(owner) { |
| 334 set_should_focus_ime_after_selection_with_keyboard(true); | 256 set_should_focus_ime_after_selection_with_keyboard(true); |
| 335 } | 257 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 349 } // namespace | 271 } // namespace |
| 350 | 272 |
| 351 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) | 273 ImeMenuTray::ImeMenuTray(WmShelf* wm_shelf) |
| 352 : TrayBackgroundView(wm_shelf, true), | 274 : TrayBackgroundView(wm_shelf, true), |
| 353 label_(new ImeMenuLabel()), | 275 label_(new ImeMenuLabel()), |
| 354 show_keyboard_(false), | 276 show_keyboard_(false), |
| 355 force_show_keyboard_(false), | 277 force_show_keyboard_(false), |
| 356 should_block_shelf_auto_hide_(false), | 278 should_block_shelf_auto_hide_(false), |
| 357 keyboard_suppressed_(false), | 279 keyboard_suppressed_(false), |
| 358 show_bubble_after_keyboard_hidden_(false) { | 280 show_bubble_after_keyboard_hidden_(false) { |
| 359 if (MaterialDesignController::IsShelfMaterial()) | 281 SetInkDropMode(InkDropMode::ON); |
| 360 SetInkDropMode(InkDropMode::ON); | |
| 361 SetupLabelForTray(label_); | 282 SetupLabelForTray(label_); |
| 362 tray_container()->AddChildView(label_); | 283 tray_container()->AddChildView(label_); |
| 363 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); | 284 SystemTrayNotifier* tray_notifier = Shell::Get()->system_tray_notifier(); |
| 364 tray_notifier->AddIMEObserver(this); | 285 tray_notifier->AddIMEObserver(this); |
| 365 tray_notifier->AddVirtualKeyboardObserver(this); | 286 tray_notifier->AddVirtualKeyboardObserver(this); |
| 366 } | 287 } |
| 367 | 288 |
| 368 ImeMenuTray::~ImeMenuTray() { | 289 ImeMenuTray::~ImeMenuTray() { |
| 369 if (bubble_) | 290 if (bubble_) |
| 370 bubble_->bubble_view()->reset_delegate(); | 291 bubble_->bubble_view()->reset_delegate(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 384 show_bubble_after_keyboard_hidden_ = true; | 305 show_bubble_after_keyboard_hidden_ = true; |
| 385 keyboard_controller->AddObserver(this); | 306 keyboard_controller->AddObserver(this); |
| 386 keyboard_controller->HideKeyboard( | 307 keyboard_controller->HideKeyboard( |
| 387 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); | 308 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); |
| 388 } else { | 309 } else { |
| 389 ShowImeMenuBubbleInternal(); | 310 ShowImeMenuBubbleInternal(); |
| 390 } | 311 } |
| 391 } | 312 } |
| 392 | 313 |
| 393 void ImeMenuTray::ShowImeMenuBubbleInternal() { | 314 void ImeMenuTray::ShowImeMenuBubbleInternal() { |
| 394 int minimum_menu_width = GetMinimumMenuWidth(); | |
| 395 should_block_shelf_auto_hide_ = true; | 315 should_block_shelf_auto_hide_ = true; |
| 396 views::TrayBubbleView::InitParams init_params( | 316 views::TrayBubbleView::InitParams init_params( |
| 397 GetAnchorAlignment(), minimum_menu_width, minimum_menu_width); | 317 GetAnchorAlignment(), kTrayMenuMinimumWidth, kTrayMenuMinimumWidth); |
| 398 init_params.can_activate = true; | 318 init_params.can_activate = true; |
| 399 init_params.close_on_deactivate = true; | 319 init_params.close_on_deactivate = true; |
| 400 | 320 |
| 401 views::TrayBubbleView* bubble_view = | 321 views::TrayBubbleView* bubble_view = |
| 402 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); | 322 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); |
| 403 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 323 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
| 404 | 324 |
| 405 // In the material design, we will add a title item with a separator on the | 325 // Add a title item with a separator on the top of the IME menu. |
| 406 // top of the IME menu. | 326 bubble_view->AddChildView( |
| 407 if (MaterialDesignController::IsSystemTrayMenuMaterial()) { | 327 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons())); |
| 408 bubble_view->AddChildView( | |
| 409 new ImeTitleView(!ShouldShowEmojiHandwritingVoiceButtons())); | |
| 410 } else { | |
| 411 bubble_view->set_margins(gfx::Insets(7, 0, 0, 0)); | |
| 412 } | |
| 413 | 328 |
| 414 // Adds IME list to the bubble. | 329 // Adds IME list to the bubble. |
| 415 ime_list_view_ = new ImeMenuListView(nullptr); | 330 ime_list_view_ = new ImeMenuListView(nullptr); |
| 416 ime_list_view_->Init(ShouldShowKeyboardToggle(), | 331 ime_list_view_->Init(ShouldShowKeyboardToggle(), |
| 417 ImeListView::SHOW_SINGLE_IME); | 332 ImeListView::SHOW_SINGLE_IME); |
| 418 bubble_view->AddChildView(ime_list_view_); | 333 bubble_view->AddChildView(ime_list_view_); |
| 419 | 334 |
| 420 if (ShouldShowEmojiHandwritingVoiceButtons()) { | 335 if (ShouldShowEmojiHandwritingVoiceButtons()) |
| 421 bubble_view->AddChildView(new ImeButtonsView(this, true, true, true, true)); | 336 bubble_view->AddChildView(new ImeButtonsView(this)); |
| 422 } else if (!MaterialDesignController::IsSystemTrayMenuMaterial()) { | |
| 423 // For MD, we don't need |ImeButtonsView| as the settings button will be | |
| 424 // shown in the title row. | |
| 425 bubble_view->AddChildView( | |
| 426 new ImeButtonsView(this, false, false, false, true)); | |
| 427 } | |
| 428 | 337 |
| 429 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); | 338 bubble_.reset(new TrayBubbleWrapper(this, bubble_view)); |
| 430 SetIsActive(true); | 339 SetIsActive(true); |
| 431 } | 340 } |
| 432 | 341 |
| 433 void ImeMenuTray::HideImeMenuBubble() { | 342 void ImeMenuTray::HideImeMenuBubble() { |
| 434 bubble_.reset(); | 343 bubble_.reset(); |
| 435 ime_list_view_ = nullptr; | 344 ime_list_view_ = nullptr; |
| 436 SetIsActive(false); | 345 SetIsActive(false); |
| 437 should_block_shelf_auto_hide_ = false; | 346 should_block_shelf_auto_hide_ = false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 !current_ime_.third_party && !IsInLoginOrLockScreen() && | 407 !current_ime_.third_party && !IsInLoginOrLockScreen() && |
| 499 !IsInPasswordInputContext(); | 408 !IsInPasswordInputContext(); |
| 500 } | 409 } |
| 501 | 410 |
| 502 bool ImeMenuTray::ShouldShowKeyboardToggle() const { | 411 bool ImeMenuTray::ShouldShowKeyboardToggle() const { |
| 503 return keyboard_suppressed_ && !Shell::GetInstance() | 412 return keyboard_suppressed_ && !Shell::GetInstance() |
| 504 ->accessibility_delegate() | 413 ->accessibility_delegate() |
| 505 ->IsVirtualKeyboardEnabled(); | 414 ->IsVirtualKeyboardEnabled(); |
| 506 } | 415 } |
| 507 | 416 |
| 508 void ImeMenuTray::SetShelfAlignment(ShelfAlignment alignment) { | |
| 509 TrayBackgroundView::SetShelfAlignment(alignment); | |
| 510 if (!MaterialDesignController::IsShelfMaterial()) | |
| 511 tray_container()->SetBorder(views::NullBorder()); | |
| 512 } | |
| 513 | |
| 514 base::string16 ImeMenuTray::GetAccessibleNameForTray() { | 417 base::string16 ImeMenuTray::GetAccessibleNameForTray() { |
| 515 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); | 418 return l10n_util::GetStringUTF16(IDS_ASH_IME_MENU_ACCESSIBLE_NAME); |
| 516 } | 419 } |
| 517 | 420 |
| 518 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { | 421 void ImeMenuTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { |
| 519 if (bubble_->bubble_view() == bubble_view) | 422 if (bubble_->bubble_view() == bubble_view) |
| 520 HideImeMenuBubble(); | 423 HideImeMenuBubble(); |
| 521 } | 424 } |
| 522 | 425 |
| 523 void ImeMenuTray::ClickedOutsideBubble() { | 426 void ImeMenuTray::ClickedOutsideBubble() { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 542 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 640 | 543 |
| 641 // Updates the tray label based on the current input method. | 544 // Updates the tray label based on the current input method. |
| 642 if (current_ime_.third_party) | 545 if (current_ime_.third_party) |
| 643 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 546 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 644 else | 547 else |
| 645 label_->SetText(current_ime_.short_name); | 548 label_->SetText(current_ime_.short_name); |
| 646 } | 549 } |
| 647 | 550 |
| 648 } // namespace ash | 551 } // namespace ash |
| OLD | NEW |