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

Side by Side Diff: ash/common/accelerators/accelerator_controller.cc

Issue 2658853003: Remove the deprecated Alt+Shift shortcut completely (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/accelerators/accelerator_controller.h" 5 #include "ash/common/accelerators/accelerator_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/accelerators/accelerator_commands.h" 9 #include "ash/common/accelerators/accelerator_commands.h"
10 #include "ash/common/accelerators/accelerator_controller_delegate.h" 10 #include "ash/common/accelerators/accelerator_controller_delegate.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Touchscreen users have better window switching options. It would be 166 // Touchscreen users have better window switching options. It would be
167 // preferable if we could tell whether this event actually came from a virtual 167 // preferable if we could tell whether this event actually came from a virtual
168 // keyboard, but there's no easy way to do so, thus we block Alt+Tab when the 168 // keyboard, but there's no easy way to do so, thus we block Alt+Tab when the
169 // virtual keyboard is showing, even if it came from a real keyboard. See 169 // virtual keyboard is showing, even if it came from a real keyboard. See
170 // http://crbug.com/638269 170 // http://crbug.com/638269
171 keyboard::KeyboardController* keyboard_controller = 171 keyboard::KeyboardController* keyboard_controller =
172 keyboard::KeyboardController::GetInstance(); 172 keyboard::KeyboardController::GetInstance();
173 return !(keyboard_controller && keyboard_controller->keyboard_visible()); 173 return !(keyboard_controller && keyboard_controller->keyboard_visible());
174 } 174 }
175 175
176 // We must avoid showing the Deprecated NEXT_IME notification erronously.
177 bool ShouldShowDeprecatedNextImeNotification(
178 const ui::Accelerator& previous_accelerator) {
179 // We only show the deprecation notification if the previous accelerator key
180 // is ONLY either Shift, or Alt.
181 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
182 switch (previous_key_code) {
183 case ui::VKEY_SHIFT:
184 case ui::VKEY_LSHIFT:
185 case ui::VKEY_RSHIFT:
186 case ui::VKEY_MENU:
187 case ui::VKEY_LMENU:
188 case ui::VKEY_RMENU:
189 return true;
190
191 default:
192 return false;
193 }
194 }
195
196 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { 176 void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
197 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); 177 base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
198 ime_control_delegate->HandleNextIme(); 178 ime_control_delegate->HandleNextIme();
199 } 179 }
200 180
201 void HandleOpenFeedbackPage() { 181 void HandleOpenFeedbackPage() {
202 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); 182 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
203 WmShell::Get()->new_window_controller()->OpenFeedbackPage(); 183 WmShell::Get()->new_window_controller()->OpenFeedbackPage();
204 } 184 }
205 185
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 auto itr = actions_with_deprecations_.find(action); 621 auto itr = actions_with_deprecations_.find(action);
642 if (itr != actions_with_deprecations_.end()) { 622 if (itr != actions_with_deprecations_.end()) {
643 const DeprecatedAcceleratorData* data = itr->second; 623 const DeprecatedAcceleratorData* data = itr->second;
644 if (deprecated_accelerators_.count(accelerator)) { 624 if (deprecated_accelerators_.count(accelerator)) {
645 // This accelerator has been deprecated and should be treated according 625 // This accelerator has been deprecated and should be treated according
646 // to its |DeprecatedAcceleratorData|. 626 // to its |DeprecatedAcceleratorData|.
647 627
648 // Record UMA stats. 628 // Record UMA stats.
649 RecordUmaHistogram(data->uma_histogram_name, DEPRECATED_USED); 629 RecordUmaHistogram(data->uma_histogram_name, DEPRECATED_USED);
650 630
651 // We always display the notification as long as this entry exists, 631 if (delegate_) {
James Cook 2017/01/26 22:24:52 It's not your fault, but this function is deeply n
afakhry 2017/01/27 03:35:06 Actually, it is my fault, I'm the one who wrote th
652 // except for NEXT_IME, we must check to avoid showing it for the wrong 632 // We always display the notification as long as this entry exists.
653 // shortcut, as Alt+Shift is tricky and trigger the action on release.
654 if (delegate_ &&
655 (action != NEXT_IME ||
656 (action == NEXT_IME &&
657 ShouldShowDeprecatedNextImeNotification(
658 accelerator_history_->previous_accelerator())))) {
659 delegate_->ShowDeprecatedAcceleratorNotification( 633 delegate_->ShowDeprecatedAcceleratorNotification(
660 data->uma_histogram_name, data->notification_message_id, 634 data->uma_histogram_name, data->notification_message_id,
661 data->old_shortcut_id, data->new_shortcut_id); 635 data->old_shortcut_id, data->new_shortcut_id);
662 } 636 }
663 637
664 if (!data->deprecated_enabled) 638 if (!data->deprecated_enabled)
665 return false; 639 return false;
666 } else { 640 } else {
667 // This is a new accelerator replacing the old deprecated one. 641 // This is a new accelerator replacing the old deprecated one.
668 // Record UMA stats and proceed normally. 642 // Record UMA stats and proceed normally.
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() && 1141 if (wm_shell->mru_window_tracker()->BuildMruWindowList().empty() &&
1168 actions_needing_window_.find(action) != actions_needing_window_.end()) { 1142 actions_needing_window_.find(action) != actions_needing_window_.end()) {
1169 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert( 1143 wm_shell->accessibility_delegate()->TriggerAccessibilityAlert(
1170 A11Y_ALERT_WINDOW_NEEDED); 1144 A11Y_ALERT_WINDOW_NEEDED);
1171 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; 1145 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
1172 } 1146 }
1173 return RESTRICTION_NONE; 1147 return RESTRICTION_NONE;
1174 } 1148 }
1175 1149
1176 } // namespace ash 1150 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698