Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); | 544 base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User")); |
| 545 break; | 545 break; |
| 546 } | 546 } |
| 547 Shell::Get()->session_controller()->CycleActiveUser(direction); | 547 Shell::Get()->session_controller()->CycleActiveUser(direction); |
| 548 } | 548 } |
| 549 | 549 |
| 550 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, | 550 bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator, |
| 551 const ui::Accelerator& previous_accelerator) { | 551 const ui::Accelerator& previous_accelerator) { |
| 552 chromeos::input_method::InputMethodManager* ime = | 552 chromeos::input_method::InputMethodManager* ime = |
| 553 chromeos::input_method::InputMethodManager::Get(); | 553 chromeos::input_method::InputMethodManager::Get(); |
| 554 if (!ime) | |
| 555 return false; | |
|
oshima
2017/04/11 19:04:47
when ime is null?
weidongg
2017/04/11 22:55:43
|ime| is checked below at |return| multiple times.
| |
| 554 | 556 |
| 555 // This shortcust is set to be trigger on release. Either the current | 557 // This shortcust is set to be trigger on release. Either the current |
| 556 // accelerator is a Search release or Alt release. | 558 // accelerator is a Search release or Alt release. |
| 557 if (accelerator.key_code() == ui::VKEY_LWIN && | 559 if (accelerator.key_code() == ui::VKEY_LWIN && |
| 558 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { | 560 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { |
| 559 // The previous must be either an Alt press or Search press: | 561 // The previous must be either an Alt press or Search press: |
| 560 // 1. Press Alt, Press Search, Release Search, Release Alt. | 562 // 1. Press Alt, Press Search, Release Search, Release Alt. |
| 561 // 2. Press Search, Press Alt, Release Search, Release Alt. | 563 // 2. Press Search, Press Alt, Release Search, Release Alt. |
| 562 if (previous_accelerator.key_state() == | 564 if (previous_accelerator.key_state() == |
| 563 ui::Accelerator::KeyState::PRESSED && | 565 ui::Accelerator::KeyState::PRESSED && |
| 564 (previous_accelerator.key_code() == ui::VKEY_LWIN || | 566 (previous_accelerator.key_code() == ui::VKEY_LWIN || |
| 565 previous_accelerator.key_code() == ui::VKEY_MENU)) { | 567 previous_accelerator.key_code() == ui::VKEY_MENU)) { |
| 566 return ime && ime->GetImeKeyboard(); | 568 return ime->GetImeKeyboard(); |
| 567 } | 569 } |
| 568 } | 570 } |
| 569 | 571 |
| 570 // Alt release. | 572 // Alt release. |
| 571 if (accelerator.key_code() == ui::VKEY_MENU && | 573 if (accelerator.key_code() == ui::VKEY_MENU && |
| 572 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { | 574 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { |
| 573 // The previous must be either an Alt press or Search press: | 575 // The previous must be either an Alt press or Search press: |
| 574 // 3. Press Alt, Press Search, Release Alt, Release Search. | 576 // 3. Press Alt, Press Search, Release Alt, Release Search. |
| 575 // 4. Press Search, Press Alt, Release Alt, Release Search. | 577 // 4. Press Search, Press Alt, Release Alt, Release Search. |
| 576 if (previous_accelerator.key_state() == | 578 if (previous_accelerator.key_state() == |
| 577 ui::Accelerator::KeyState::PRESSED && | 579 ui::Accelerator::KeyState::PRESSED && |
| 578 (previous_accelerator.key_code() == ui::VKEY_LWIN || | 580 (previous_accelerator.key_code() == ui::VKEY_LWIN || |
| 579 previous_accelerator.key_code() == ui::VKEY_MENU)) { | 581 previous_accelerator.key_code() == ui::VKEY_MENU)) { |
| 580 return ime && ime->GetImeKeyboard(); | 582 return ime->GetImeKeyboard(); |
| 581 } | 583 } |
| 582 } | 584 } |
| 583 | 585 |
| 586 // Caps Lock release | |
| 587 if (accelerator.key_code() == ui::VKEY_CAPITAL && | |
| 588 accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { | |
| 589 return ime->GetImeKeyboard(); | |
| 590 } | |
| 591 | |
| 584 return false; | 592 return false; |
| 585 } | 593 } |
| 586 | 594 |
| 587 void HandleToggleCapsLock() { | 595 void HandleToggleCapsLock() { |
| 588 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); | 596 base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock")); |
| 589 chromeos::input_method::InputMethodManager* ime = | 597 chromeos::input_method::InputMethodManager* ime = |
| 590 chromeos::input_method::InputMethodManager::Get(); | 598 chromeos::input_method::InputMethodManager::Get(); |
| 591 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); | 599 chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard(); |
| 592 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); | 600 keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled()); |
| 593 } | 601 } |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1295 data->uma_histogram_name, data->notification_message_id, | 1303 data->uma_histogram_name, data->notification_message_id, |
| 1296 data->old_shortcut_id, data->new_shortcut_id); | 1304 data->old_shortcut_id, data->new_shortcut_id); |
| 1297 | 1305 |
| 1298 if (!data->deprecated_enabled) | 1306 if (!data->deprecated_enabled) |
| 1299 return AcceleratorProcessingStatus::STOP; | 1307 return AcceleratorProcessingStatus::STOP; |
| 1300 | 1308 |
| 1301 return AcceleratorProcessingStatus::PROCEED; | 1309 return AcceleratorProcessingStatus::PROCEED; |
| 1302 } | 1310 } |
| 1303 | 1311 |
| 1304 } // namespace ash | 1312 } // namespace ash |
| OLD | NEW |