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

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

Issue 2763483002: Fix Caps Lock bug (Closed)
Patch Set: Add unit test for Caps Lock in accelerator. 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
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 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 // 3. Press Alt, Press Search, Release Alt, Release Search. 576 // 3. Press Alt, Press Search, Release Alt, Release Search.
577 // 4. Press Search, Press Alt, Release Alt, Release Search. 577 // 4. Press Search, Press Alt, Release Alt, Release Search.
578 if (previous_accelerator.key_state() == 578 if (previous_accelerator.key_state() ==
579 ui::Accelerator::KeyState::PRESSED && 579 ui::Accelerator::KeyState::PRESSED &&
580 (previous_accelerator.key_code() == ui::VKEY_LWIN || 580 (previous_accelerator.key_code() == ui::VKEY_LWIN ||
581 previous_accelerator.key_code() == ui::VKEY_MENU)) { 581 previous_accelerator.key_code() == ui::VKEY_MENU)) {
582 return ime && ime->GetImeKeyboard(); 582 return ime && ime->GetImeKeyboard();
583 } 583 }
584 } 584 }
585 585
586 // Caps Lock release
587 if (accelerator.key_code() == ui::VKEY_CAPITAL &&
588 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) {
589 return ime && ime->GetImeKeyboard();
afakhry 2017/04/07 23:31:42 Can we move the check for |ime| is not null up to
weidongg 2017/04/08 00:15:07 Sure, you are right.
590 }
591
586 return false; 592 return false;
587 } 593 }
588 594
589 void HandleToggleCapsLock() { 595 void HandleToggleCapsLock() {
590 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); 596 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock"));
591 chromeos::input_method::InputMethodManager* ime = 597 chromeos::input_method::InputMethodManager* ime =
592 chromeos::input_method::InputMethodManager::Get(); 598 chromeos::input_method::InputMethodManager::Get();
593 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); 599 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard();
594 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); 600 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
595 } 601 }
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 data->uma_histogram_name, data->notification_message_id, 1303 data->uma_histogram_name, data->notification_message_id,
1298 data->old_shortcut_id, data->new_shortcut_id); 1304 data->old_shortcut_id, data->new_shortcut_id);
1299 1305
1300 if (!data->deprecated_enabled) 1306 if (!data->deprecated_enabled)
1301 return AcceleratorProcessingStatus::STOP; 1307 return AcceleratorProcessingStatus::STOP;
1302 1308
1303 return AcceleratorProcessingStatus::PROCEED; 1309 return AcceleratorProcessingStatus::PROCEED;
1304 } 1310 }
1305 1311
1306 } // namespace ash 1312 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698