| 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/system/ime_menu/ime_menu_tray.h" | 5 #include "ash/system/ime_menu/ime_menu_tray.h" |
| 6 | 6 |
| 7 #include "ash/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
| 8 #include "ash/ash_constants.h" | 8 #include "ash/ash_constants.h" |
| 9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
| 10 #include "ash/resources/grit/ash_resources.h" | 10 #include "ash/resources/grit/ash_resources.h" |
| 11 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 12 #include "ash/session/session_state_delegate.h" | 12 #include "ash/session/session_controller.h" |
| 13 #include "ash/shelf/wm_shelf.h" | 13 #include "ash/shelf/wm_shelf.h" |
| 14 #include "ash/shelf/wm_shelf_util.h" | 14 #include "ash/shelf/wm_shelf_util.h" |
| 15 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 16 #include "ash/shell_port.h" | 16 #include "ash/shell_port.h" |
| 17 #include "ash/strings/grit/ash_strings.h" | 17 #include "ash/strings/grit/ash_strings.h" |
| 18 #include "ash/system/ime_menu/ime_list_view.h" | 18 #include "ash/system/ime_menu/ime_list_view.h" |
| 19 #include "ash/system/tray/system_menu_button.h" | 19 #include "ash/system/tray/system_menu_button.h" |
| 20 #include "ash/system/tray/system_tray_controller.h" | 20 #include "ash/system/tray/system_tray_controller.h" |
| 21 #include "ash/system/tray/system_tray_delegate.h" | 21 #include "ash/system/tray/system_tray_delegate.h" |
| 22 #include "ash/system/tray/system_tray_notifier.h" | 22 #include "ash/system/tray/system_tray_notifier.h" |
| 23 #include "ash/system/tray/tray_constants.h" | 23 #include "ash/system/tray/tray_constants.h" |
| 24 #include "ash/system/tray/tray_popup_item_style.h" | 24 #include "ash/system/tray/tray_popup_item_style.h" |
| 25 #include "ash/system/tray/tray_popup_utils.h" | 25 #include "ash/system/tray/tray_popup_utils.h" |
| 26 #include "ash/system/tray/tray_utils.h" | 26 #include "ash/system/tray/tray_utils.h" |
| 27 #include "ash/wm_window.h" | 27 #include "ash/wm_window.h" |
| 28 #include "base/metrics/histogram_macros.h" | 28 #include "base/metrics/histogram_macros.h" |
| 29 #include "base/strings/utf_string_conversions.h" | 29 #include "base/strings/utf_string_conversions.h" |
| 30 #include "components/session_manager/session_manager_types.h" |
| 30 #include "ui/base/ime/chromeos/input_method_manager.h" | 31 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 31 #include "ui/base/ime/ime_bridge.h" | 32 #include "ui/base/ime/ime_bridge.h" |
| 32 #include "ui/base/ime/text_input_client.h" | 33 #include "ui/base/ime/text_input_client.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/keyboard/keyboard_controller.h" | 38 #include "ui/keyboard/keyboard_controller.h" |
| 38 #include "ui/keyboard/keyboard_util.h" | 39 #include "ui/keyboard/keyboard_util.h" |
| 39 #include "ui/views/controls/button/button.h" | 40 #include "ui/views/controls/button/button.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 button = HANDWRITING; | 79 button = HANDWRITING; |
| 79 } else if (button_name == "voice") { | 80 } else if (button_name == "voice") { |
| 80 button = VOICE; | 81 button = VOICE; |
| 81 } | 82 } |
| 82 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", | 83 UMA_HISTOGRAM_ENUMERATION("InputMethod.ImeMenu.EmojiHandwritingVoiceButton", |
| 83 button, BUTTON_MAX); | 84 button, BUTTON_MAX); |
| 84 } | 85 } |
| 85 | 86 |
| 86 // Returns true if the current screen is login or lock screen. | 87 // Returns true if the current screen is login or lock screen. |
| 87 bool IsInLoginOrLockScreen() { | 88 bool IsInLoginOrLockScreen() { |
| 88 LoginStatus login = | 89 using session_manager::SessionState; |
| 89 Shell::Get()->system_tray_delegate()->GetUserLoginStatus(); | 90 SessionState state = Shell::Get()->session_controller()->GetSessionState(); |
| 90 return !TrayPopupUtils::CanOpenWebUISettings(login); | 91 return state == SessionState::LOGIN_PRIMARY || |
| 92 state == SessionState::LOCKED || |
| 93 state == SessionState::LOGIN_SECONDARY; |
| 91 } | 94 } |
| 92 | 95 |
| 93 // Returns true if the current input context type is password. | 96 // Returns true if the current input context type is password. |
| 94 bool IsInPasswordInputContext() { | 97 bool IsInPasswordInputContext() { |
| 95 return ui::IMEBridge::Get()->GetCurrentInputContext().type == | 98 return ui::IMEBridge::Get()->GetCurrentInputContext().type == |
| 96 ui::TEXT_INPUT_TYPE_PASSWORD; | 99 ui::TEXT_INPUT_TYPE_PASSWORD; |
| 97 } | 100 } |
| 98 | 101 |
| 99 class ImeMenuLabel : public views::Label { | 102 class ImeMenuLabel : public views::Label { |
| 100 public: | 103 public: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 146 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 144 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); | 147 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); |
| 145 style.SetupLabel(title_label); | 148 style.SetupLabel(title_label); |
| 146 | 149 |
| 147 AddChildView(title_label); | 150 AddChildView(title_label); |
| 148 box_layout->SetFlexForView(title_label, 1); | 151 box_layout->SetFlexForView(title_label, 1); |
| 149 | 152 |
| 150 if (show_settings_button) { | 153 if (show_settings_button) { |
| 151 settings_button_ = CreateImeMenuButton( | 154 settings_button_ = CreateImeMenuButton( |
| 152 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 155 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
| 153 if (IsInLoginOrLockScreen()) | 156 if (!TrayPopupUtils::CanOpenWebUISettings()) |
| 154 settings_button_->SetEnabled(false); | 157 settings_button_->SetEnabled(false); |
| 155 AddChildView(settings_button_); | 158 AddChildView(settings_button_); |
| 156 } | 159 } |
| 157 } | 160 } |
| 158 | 161 |
| 159 // views::ButtonListener: | 162 // views::ButtonListener: |
| 160 void ButtonPressed(views::Button* sender, const ui::Event& event) override { | 163 void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| 161 DCHECK_EQ(sender, settings_button_); | 164 DCHECK_EQ(sender, settings_button_); |
| 162 ShowIMESettings(); | 165 ShowIMESettings(); |
| 163 } | 166 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 AddChildView(handwriting_button_); | 239 AddChildView(handwriting_button_); |
| 237 | 240 |
| 238 voice_button_ = | 241 voice_button_ = |
| 239 CreateImeMenuButton(this, kImeMenuMicrophoneIcon, | 242 CreateImeMenuButton(this, kImeMenuMicrophoneIcon, |
| 240 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); | 243 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); |
| 241 AddChildView(voice_button_); | 244 AddChildView(voice_button_); |
| 242 | 245 |
| 243 settings_button_ = CreateImeMenuButton(this, kSystemMenuSettingsIcon, | 246 settings_button_ = CreateImeMenuButton(this, kSystemMenuSettingsIcon, |
| 244 IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); | 247 IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); |
| 245 AddChildView(settings_button_); | 248 AddChildView(settings_button_); |
| 249 if (!TrayPopupUtils::CanOpenWebUISettings()) |
| 250 settings_button_->SetEnabled(false); |
| 246 } | 251 } |
| 247 | 252 |
| 248 ImeMenuTray* ime_menu_tray_; | 253 ImeMenuTray* ime_menu_tray_; |
| 249 SystemMenuButton* emoji_button_; | 254 SystemMenuButton* emoji_button_; |
| 250 SystemMenuButton* handwriting_button_; | 255 SystemMenuButton* handwriting_button_; |
| 251 SystemMenuButton* voice_button_; | 256 SystemMenuButton* voice_button_; |
| 252 SystemMenuButton* settings_button_; | 257 SystemMenuButton* settings_button_; |
| 253 | 258 |
| 254 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); | 259 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); |
| 255 }; | 260 }; |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); | 552 Shell::Get()->system_tray_delegate()->GetCurrentIME(¤t_ime_); |
| 548 | 553 |
| 549 // Updates the tray label based on the current input method. | 554 // Updates the tray label based on the current input method. |
| 550 if (current_ime_.third_party) | 555 if (current_ime_.third_party) |
| 551 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); | 556 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); |
| 552 else | 557 else |
| 553 label_->SetText(current_ime_.short_name); | 558 label_->SetText(current_ime_.short_name); |
| 554 } | 559 } |
| 555 | 560 |
| 556 } // namespace ash | 561 } // namespace ash |
| OLD | NEW |