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