Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: ash/system/ime_menu/ime_menu_tray.cc

Issue 2821363002: cros: Disable system tray help/lock buttons during supervised user creation (Closed)
Patch Set: tweak ime menu Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/ime/tray_ime_chromeos.cc ('k') | ash/system/tiles/tiles_default_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } else if (button_name == "hwt") { 78 } else if (button_name == "hwt") {
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() {
James Cook 2017/04/18 17:50:20 It's unclear to me exactly how the IME menu should
xiyuan 2017/04/18 18:34:26 Acknowledged.
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 141 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
139 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE); 142 TrayPopupItemStyle style(TrayPopupItemStyle::FontStyle::TITLE);
140 style.SetupLabel(title_label); 143 style.SetupLabel(title_label);
141 144
142 AddChildView(title_label); 145 AddChildView(title_label);
143 box_layout->SetFlexForView(title_label, 1); 146 box_layout->SetFlexForView(title_label, 1);
144 147
145 if (show_settings_button) { 148 if (show_settings_button) {
146 settings_button_ = CreateImeMenuButton( 149 settings_button_ = CreateImeMenuButton(
147 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); 150 this, kSystemMenuSettingsIcon, IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0);
148 if (IsInLoginOrLockScreen()) 151 if (!TrayPopupUtils::CanOpenWebUISettings())
149 settings_button_->SetEnabled(false); 152 settings_button_->SetEnabled(false);
150 AddChildView(settings_button_); 153 AddChildView(settings_button_);
151 } 154 }
152 } 155 }
153 156
154 // views::ButtonListener: 157 // views::ButtonListener:
155 void ButtonPressed(views::Button* sender, const ui::Event& event) override { 158 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
156 DCHECK_EQ(sender, settings_button_); 159 DCHECK_EQ(sender, settings_button_);
157 ShowIMESettings(); 160 ShowIMESettings();
158 } 161 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 AddChildView(handwriting_button_); 234 AddChildView(handwriting_button_);
232 235
233 voice_button_ = 236 voice_button_ =
234 CreateImeMenuButton(this, kImeMenuMicrophoneIcon, 237 CreateImeMenuButton(this, kImeMenuMicrophoneIcon,
235 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border); 238 IDS_ASH_STATUS_TRAY_IME_VOICE, right_border);
236 AddChildView(voice_button_); 239 AddChildView(voice_button_);
237 240
238 settings_button_ = CreateImeMenuButton(this, kSystemMenuSettingsIcon, 241 settings_button_ = CreateImeMenuButton(this, kSystemMenuSettingsIcon,
239 IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0); 242 IDS_ASH_STATUS_TRAY_IME_SETTINGS, 0);
240 AddChildView(settings_button_); 243 AddChildView(settings_button_);
244 if (!TrayPopupUtils::CanOpenWebUISettings())
245 settings_button_->SetEnabled(false);
241 } 246 }
242 247
243 ImeMenuTray* ime_menu_tray_; 248 ImeMenuTray* ime_menu_tray_;
244 SystemMenuButton* emoji_button_; 249 SystemMenuButton* emoji_button_;
245 SystemMenuButton* handwriting_button_; 250 SystemMenuButton* handwriting_button_;
246 SystemMenuButton* voice_button_; 251 SystemMenuButton* voice_button_;
247 SystemMenuButton* settings_button_; 252 SystemMenuButton* settings_button_;
248 253
249 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView); 254 DISALLOW_COPY_AND_ASSIGN(ImeButtonsView);
250 }; 255 };
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 Shell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_); 546 Shell::Get()->system_tray_delegate()->GetCurrentIME(&current_ime_);
542 547
543 // Updates the tray label based on the current input method. 548 // Updates the tray label based on the current input method.
544 if (current_ime_.third_party) 549 if (current_ime_.third_party)
545 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*")); 550 label_->SetText(current_ime_.short_name + base::UTF8ToUTF16("*"));
546 else 551 else
547 label_->SetText(current_ime_.short_name); 552 label_->SetText(current_ime_.short_name);
548 } 553 }
549 554
550 } // namespace ash 555 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/ime/tray_ime_chromeos.cc ('k') | ash/system/tiles/tiles_default_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698