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/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 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 void HandleFileManager() { | 618 void HandleFileManager() { |
619 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); | 619 base::RecordAction(UserMetricsAction("Accel_Open_File_Manager")); |
620 | 620 |
621 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); | 621 Shell::GetInstance()->new_window_delegate()->OpenFileManager(); |
622 } | 622 } |
623 | 623 |
624 void HandleGetHelp() { | 624 void HandleGetHelp() { |
625 Shell::GetInstance()->new_window_delegate()->OpenGetHelp(); | 625 Shell::GetInstance()->new_window_delegate()->OpenGetHelp(); |
626 } | 626 } |
627 | 627 |
628 bool CanHandleSilenceSpokenFeedback() { | |
629 AccessibilityDelegate* delegate = | |
630 Shell::GetInstance()->accessibility_delegate(); | |
631 return delegate->IsSpokenFeedbackEnabled(); | |
632 } | |
633 | |
634 void HandleSilenceSpokenFeedback() { | |
635 base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback")); | |
636 Shell::GetInstance()->accessibility_delegate()->SilenceSpokenFeedback(); | |
637 } | |
638 | |
639 void HandleSwapPrimaryDisplay() { | 628 void HandleSwapPrimaryDisplay() { |
640 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); | 629 base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display")); |
641 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId( | 630 Shell::GetInstance()->display_configuration_controller()->SetPrimaryDisplayId( |
642 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */); | 631 ScreenUtil::GetSecondaryDisplay().id(), true /* user_action */); |
643 } | 632 } |
644 | 633 |
645 bool CanHandleCycleUser() { | 634 bool CanHandleCycleUser() { |
646 Shell* shell = Shell::GetInstance(); | 635 Shell* shell = Shell::GetInstance(); |
647 return shell->delegate()->IsMultiProfilesEnabled() && | 636 return shell->delegate()->IsMultiProfilesEnabled() && |
648 shell->session_state_delegate()->NumberOfLoggedInUsers() > 1; | 637 shell->session_state_delegate()->NumberOfLoggedInUsers() > 1; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 #if defined(OS_CHROMEOS) | 1033 #if defined(OS_CHROMEOS) |
1045 case DEBUG_ADD_REMOVE_DISPLAY: | 1034 case DEBUG_ADD_REMOVE_DISPLAY: |
1046 case DEBUG_TOGGLE_TOUCH_PAD: | 1035 case DEBUG_TOGGLE_TOUCH_PAD: |
1047 case DEBUG_TOGGLE_TOUCH_SCREEN: | 1036 case DEBUG_TOGGLE_TOUCH_SCREEN: |
1048 case DEBUG_TOGGLE_UNIFIED_DESKTOP: | 1037 case DEBUG_TOGGLE_UNIFIED_DESKTOP: |
1049 return debug::DebugAcceleratorsEnabled(); | 1038 return debug::DebugAcceleratorsEnabled(); |
1050 case DISABLE_CAPS_LOCK: | 1039 case DISABLE_CAPS_LOCK: |
1051 return CanHandleDisableCapsLock(previous_accelerator); | 1040 return CanHandleDisableCapsLock(previous_accelerator); |
1052 case LOCK_SCREEN: | 1041 case LOCK_SCREEN: |
1053 return CanHandleLock(); | 1042 return CanHandleLock(); |
1054 case SILENCE_SPOKEN_FEEDBACK: | |
1055 return CanHandleSilenceSpokenFeedback(); | |
1056 case SWITCH_TO_PREVIOUS_USER: | 1043 case SWITCH_TO_PREVIOUS_USER: |
1057 case SWITCH_TO_NEXT_USER: | 1044 case SWITCH_TO_NEXT_USER: |
1058 return CanHandleCycleUser(); | 1045 return CanHandleCycleUser(); |
1059 case TOGGLE_CAPS_LOCK: | 1046 case TOGGLE_CAPS_LOCK: |
1060 return CanHandleToggleCapsLock(accelerator, previous_accelerator); | 1047 return CanHandleToggleCapsLock(accelerator, previous_accelerator); |
1061 case TOGGLE_TOUCH_VIEW_TESTING: | 1048 case TOGGLE_TOUCH_VIEW_TESTING: |
1062 return CanHandleToggleTouchViewTesting(); | 1049 return CanHandleToggleTouchViewTesting(); |
1063 case TOUCH_HUD_CLEAR: | 1050 case TOUCH_HUD_CLEAR: |
1064 case TOUCH_HUD_MODE_CHANGE: | 1051 case TOUCH_HUD_MODE_CHANGE: |
1065 return CanHandleTouchHud(); | 1052 return CanHandleTouchHud(); |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 // There is no powerd, the Chrome OS power manager, in linux desktop, | 1330 // There is no powerd, the Chrome OS power manager, in linux desktop, |
1344 // so call the PowerButtonController here. | 1331 // so call the PowerButtonController here. |
1345 Shell::GetInstance()->power_button_controller()-> | 1332 Shell::GetInstance()->power_button_controller()-> |
1346 OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); | 1333 OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks()); |
1347 } | 1334 } |
1348 // We don't do anything with these at present on the device, | 1335 // We don't do anything with these at present on the device, |
1349 // (power button events are reported to us from powerm via | 1336 // (power button events are reported to us from powerm via |
1350 // D-BUS), but we consume them to prevent them from getting | 1337 // D-BUS), but we consume them to prevent them from getting |
1351 // passed to apps -- see http://crbug.com/146609. | 1338 // passed to apps -- see http://crbug.com/146609. |
1352 break; | 1339 break; |
1353 case SILENCE_SPOKEN_FEEDBACK: | |
1354 HandleSilenceSpokenFeedback(); | |
1355 break; | |
1356 case SWAP_PRIMARY_DISPLAY: | 1340 case SWAP_PRIMARY_DISPLAY: |
1357 HandleSwapPrimaryDisplay(); | 1341 HandleSwapPrimaryDisplay(); |
1358 break; | 1342 break; |
1359 case SWITCH_TO_NEXT_USER: | 1343 case SWITCH_TO_NEXT_USER: |
1360 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); | 1344 HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER); |
1361 break; | 1345 break; |
1362 case SWITCH_TO_PREVIOUS_USER: | 1346 case SWITCH_TO_PREVIOUS_USER: |
1363 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); | 1347 HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER); |
1364 break; | 1348 break; |
1365 case TOGGLE_CAPS_LOCK: | 1349 case TOGGLE_CAPS_LOCK: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 #else | 1382 #else |
1399 case DUMMY_FOR_RESERVED: | 1383 case DUMMY_FOR_RESERVED: |
1400 NOTREACHED(); | 1384 NOTREACHED(); |
1401 break; | 1385 break; |
1402 #endif | 1386 #endif |
1403 } | 1387 } |
1404 } | 1388 } |
1405 | 1389 |
1406 bool AcceleratorController::ShouldActionConsumeKeyEvent( | 1390 bool AcceleratorController::ShouldActionConsumeKeyEvent( |
1407 AcceleratorAction action) { | 1391 AcceleratorAction action) { |
1408 #if defined(OS_CHROMEOS) | |
1409 if (action == SILENCE_SPOKEN_FEEDBACK) | |
1410 return false; | |
1411 #endif | |
1412 | |
1413 // Adding new exceptions is *STRONGLY* discouraged. | 1392 // Adding new exceptions is *STRONGLY* discouraged. |
1414 return true; | 1393 return true; |
1415 } | 1394 } |
1416 | 1395 |
1417 AcceleratorController::AcceleratorProcessingRestriction | 1396 AcceleratorController::AcceleratorProcessingRestriction |
1418 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { | 1397 AcceleratorController::GetAcceleratorProcessingRestriction(int action) { |
1419 ash::Shell* shell = ash::Shell::GetInstance(); | 1398 ash::Shell* shell = ash::Shell::GetInstance(); |
1420 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && | 1399 if (!shell->session_state_delegate()->IsActiveUserSessionStarted() && |
1421 actions_allowed_at_login_screen_.find(action) == | 1400 actions_allowed_at_login_screen_.find(action) == |
1422 actions_allowed_at_login_screen_.end()) { | 1401 actions_allowed_at_login_screen_.end()) { |
(...skipping 28 matching lines...) Expand all Loading... |
1451 } | 1430 } |
1452 | 1431 |
1453 void AcceleratorController::SetKeyboardBrightnessControlDelegate( | 1432 void AcceleratorController::SetKeyboardBrightnessControlDelegate( |
1454 scoped_ptr<KeyboardBrightnessControlDelegate> | 1433 scoped_ptr<KeyboardBrightnessControlDelegate> |
1455 keyboard_brightness_control_delegate) { | 1434 keyboard_brightness_control_delegate) { |
1456 keyboard_brightness_control_delegate_ = | 1435 keyboard_brightness_control_delegate_ = |
1457 std::move(keyboard_brightness_control_delegate); | 1436 std::move(keyboard_brightness_control_delegate); |
1458 } | 1437 } |
1459 | 1438 |
1460 } // namespace ash | 1439 } // namespace ash |
OLD | NEW |