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

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

Issue 2068333002: Disable the deprecated Alt+Shift for NEXT_IME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('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 (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/accelerators/accelerator_controller.h" 5 #include "ash/accelerators/accelerator_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 base::RecordAction(base::UserMetricsAction("Accel_NewTab_T")); 293 base::RecordAction(base::UserMetricsAction("Accel_NewTab_T"));
294 Shell::GetInstance()->new_window_delegate()->NewTab(); 294 Shell::GetInstance()->new_window_delegate()->NewTab();
295 } 295 }
296 296
297 void HandleNewWindow() { 297 void HandleNewWindow() {
298 base::RecordAction(base::UserMetricsAction("Accel_New_Window")); 298 base::RecordAction(base::UserMetricsAction("Accel_New_Window"));
299 Shell::GetInstance()->new_window_delegate()->NewWindow( 299 Shell::GetInstance()->new_window_delegate()->NewWindow(
300 false /* is_incognito */); 300 false /* is_incognito */);
301 } 301 }
302 302
303 #if defined(OS_CHROMEOS)
304 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate) {
305 return ime_control_delegate && ime_control_delegate->CanCycleIme();
306 }
307 #else
308 // Non-chromeos platforms still use the old NEXT_IME shortcuts.
oshima 2016/06/15 21:13:25 why we need this? ash is chromeos only and win_ash
afakhry 2016/06/16 18:40:49 Removed them entirely. Also, since Alt+Shift is
303 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate, 309 bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate,
304 const ui::Accelerator& previous_accelerator, 310 const ui::Accelerator& previous_accelerator) {
305 bool current_accelerator_is_deprecated) { 311 // We only allow next IME to be triggered if the previous is accelerator key
306 if (current_accelerator_is_deprecated) { 312 // is ONLY either Shift, Alt, Enter or Space.
307 // We only allow next IME to be triggered if the previous is accelerator key 313 // The first six cases below are to avoid conflicting accelerators that
308 // is ONLY either Shift, Alt, Enter or Space. 314 // contain Alt+Shift (like Alt+Shift+Tab or Alt+Shift+S) to trigger next IME
309 // The first six cases below are to avoid conflicting accelerators that 315 // when the wrong order of key sequences is pressed. crbug.com/527154.
310 // contain Alt+Shift (like Alt+Shift+Tab or Alt+Shift+S) to trigger next IME 316 // The latter two cases are needed for CJK IME users who tend to press Enter
311 // when the wrong order of key sequences is pressed. crbug.com/527154. 317 // (or Space) and Shift+Alt almost at the same time to commit an IME string
312 // The latter two cases are needed for CJK IME users who tend to press Enter 318 // and then switch from the IME to the English layout. This allows these
313 // (or Space) and Shift+Alt almost at the same time to commit an IME string 319 // users to trigger NEXT_IME even if they press Shift+Alt before releasing
314 // and then switch from the IME to the English layout. This allows these 320 // Enter. crbug.com/139556.
315 // users to trigger NEXT_IME even if they press Shift+Alt before releasing 321 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way.
316 // Enter. crbug.com/139556. 322 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
317 // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way. 323 switch (previous_key_code) {
318 const ui::KeyboardCode previous_key_code = previous_accelerator.key_code(); 324 case ui::VKEY_SHIFT:
319 switch (previous_key_code) { 325 case ui::VKEY_LSHIFT:
320 case ui::VKEY_SHIFT: 326 case ui::VKEY_RSHIFT:
321 case ui::VKEY_LSHIFT: 327 case ui::VKEY_MENU:
322 case ui::VKEY_RSHIFT: 328 case ui::VKEY_LMENU:
323 case ui::VKEY_MENU: 329 case ui::VKEY_RMENU:
324 case ui::VKEY_LMENU: 330 case ui::VKEY_RETURN:
325 case ui::VKEY_RMENU: 331 case ui::VKEY_SPACE:
326 case ui::VKEY_RETURN: 332 break;
327 case ui::VKEY_SPACE:
328 break;
329 333
330 default: 334 default:
331 return false; 335 return false;
332 }
333 } 336 }
334 337
335 return ime_control_delegate && ime_control_delegate->CanCycleIme(); 338 return ime_control_delegate && ime_control_delegate->CanCycleIme();
336 } 339 }
340 #endif // defined(OS_CHROMEOS)
337 341
338 void HandleNextIme(ImeControlDelegate* ime_control_delegate) { 342 void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
339 base::RecordAction(UserMetricsAction("Accel_Next_Ime")); 343 base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
340 ime_control_delegate->HandleNextIme(); 344 ime_control_delegate->HandleNextIme();
341 } 345 }
342 346
343 void HandleOpenFeedbackPage() { 347 void HandleOpenFeedbackPage() {
344 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page")); 348 base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
345 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage(); 349 ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
346 } 350 }
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 case DEBUG_TOGGLE_SHOW_FPS_COUNTER: 1013 case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
1010 case DEBUG_TOGGLE_SHOW_PAINT_RECTS: 1014 case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
1011 return debug::DebugAcceleratorsEnabled(); 1015 return debug::DebugAcceleratorsEnabled();
1012 case MAGNIFY_SCREEN_ZOOM_IN: 1016 case MAGNIFY_SCREEN_ZOOM_IN:
1013 case MAGNIFY_SCREEN_ZOOM_OUT: 1017 case MAGNIFY_SCREEN_ZOOM_OUT:
1014 return CanHandleMagnifyScreen(); 1018 return CanHandleMagnifyScreen();
1015 case NEW_INCOGNITO_WINDOW: 1019 case NEW_INCOGNITO_WINDOW:
1016 return CanHandleNewIncognitoWindow(); 1020 return CanHandleNewIncognitoWindow();
1017 case NEXT_IME: { 1021 case NEXT_IME: {
1018 #if defined(OS_CHROMEOS) 1022 #if defined(OS_CHROMEOS)
1019 bool accelerator_is_deprecated = 1023 return CanHandleNextIme(ime_control_delegate_.get());
1020 (deprecated_accelerators_.count(accelerator) != 0);
1021 #else 1024 #else
1022 // On non-chromeos, the NEXT_IME deprecated accelerators are always used. 1025 // On non-chromeos, the NEXT_IME deprecated accelerators are always used.
1023 bool accelerator_is_deprecated = true; 1026 return CanHandleNextIme(ime_control_delegate_.get(),
1027 previous_accelerator);
1024 #endif // defined(OS_CHROMEOS) 1028 #endif // defined(OS_CHROMEOS)
1025
1026 return CanHandleNextIme(ime_control_delegate_.get(), previous_accelerator,
1027 accelerator_is_deprecated);
1028 } 1029 }
1029 case PREVIOUS_IME: 1030 case PREVIOUS_IME:
1030 return CanHandlePreviousIme(ime_control_delegate_.get()); 1031 return CanHandlePreviousIme(ime_control_delegate_.get());
1031 case SCALE_UI_RESET: 1032 case SCALE_UI_RESET:
1032 case SCALE_UI_UP: 1033 case SCALE_UI_UP:
1033 case SCALE_UI_DOWN: 1034 case SCALE_UI_DOWN:
1034 return accelerators::IsInternalDisplayZoomEnabled(); 1035 return accelerators::IsInternalDisplayZoomEnabled();
1035 case SHOW_MESSAGE_CENTER_BUBBLE: 1036 case SHOW_MESSAGE_CENTER_BUBBLE:
1036 return CanHandleShowMessageCenterBubble(); 1037 return CanHandleShowMessageCenterBubble();
1037 case SWITCH_IME: 1038 case SWITCH_IME:
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 } 1452 }
1452 1453
1453 void AcceleratorController::SetKeyboardBrightnessControlDelegate( 1454 void AcceleratorController::SetKeyboardBrightnessControlDelegate(
1454 std::unique_ptr<KeyboardBrightnessControlDelegate> 1455 std::unique_ptr<KeyboardBrightnessControlDelegate>
1455 keyboard_brightness_control_delegate) { 1456 keyboard_brightness_control_delegate) {
1456 keyboard_brightness_control_delegate_ = 1457 keyboard_brightness_control_delegate_ =
1457 std::move(keyboard_brightness_control_delegate); 1458 std::move(keyboard_brightness_control_delegate);
1458 } 1459 }
1459 1460
1460 } // namespace ash 1461 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/accelerators/accelerator_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698