| 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 | 10 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return true; | 152 return true; |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Magnify the screen | 155 // Magnify the screen |
| 156 bool HandleMagnifyScreen(int delta_index) { | 156 bool HandleMagnifyScreen(int delta_index) { |
| 157 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { | 157 if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) { |
| 158 // TODO(yoshiki): Move the following logic to MagnificationController. | 158 // TODO(yoshiki): Move the following logic to MagnificationController. |
| 159 float scale = | 159 float scale = |
| 160 ash::Shell::GetInstance()->magnification_controller()->GetScale(); | 160 ash::Shell::GetInstance()->magnification_controller()->GetScale(); |
| 161 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. | 161 // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale. |
| 162 int scale_index = | 162 int scale_index = std::floor( |
| 163 std::floor(std::log(scale) / std::log(kMagnificationScaleFactor) + 0.5); | 163 std::log(scale) / std::log(ui::kMagnificationScaleFactor) + 0.5); |
| 164 | 164 |
| 165 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); | 165 int new_scale_index = std::max(0, std::min(8, scale_index + delta_index)); |
| 166 | 166 |
| 167 ash::Shell::GetInstance()->magnification_controller()-> | 167 ash::Shell::GetInstance()->magnification_controller()->SetScale( |
| 168 SetScale(std::pow(kMagnificationScaleFactor, new_scale_index), true); | 168 std::pow(ui::kMagnificationScaleFactor, new_scale_index), true); |
| 169 return true; | 169 return true; |
| 170 } else if (ash::Shell::GetInstance()-> | 170 } else if (ash::Shell::GetInstance()-> |
| 171 partial_magnification_controller()->is_enabled()) { | 171 partial_magnification_controller()->is_enabled()) { |
| 172 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; | 172 float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1; |
| 173 ash::Shell::GetInstance()->partial_magnification_controller()-> | 173 ash::Shell::GetInstance()->partial_magnification_controller()-> |
| 174 SetScale(scale); | 174 SetScale(scale); |
| 175 return true; | 175 return true; |
| 176 } | 176 } |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 bool HandleToggleMirrorMode() { | 566 bool HandleToggleMirrorMode() { |
| 567 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); | 567 base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode")); |
| 568 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); | 568 Shell::GetInstance()->display_controller()->ToggleMirrorMode(); |
| 569 return true; | 569 return true; |
| 570 } | 570 } |
| 571 | 571 |
| 572 bool HandleToggleSpokenFeedback() { | 572 bool HandleToggleSpokenFeedback() { |
| 573 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); | 573 base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback")); |
| 574 | 574 |
| 575 Shell::GetInstance()->accessibility_delegate()-> | 575 Shell::GetInstance()->accessibility_delegate()-> |
| 576 ToggleSpokenFeedback(A11Y_NOTIFICATION_SHOW); | 576 ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_SHOW); |
| 577 return true; | 577 return true; |
| 578 } | 578 } |
| 579 | 579 |
| 580 bool HandleToggleTouchViewTesting() { | 580 bool HandleToggleTouchViewTesting() { |
| 581 // TODO(skuhne): This is only temporary! Remove this! | 581 // TODO(skuhne): This is only temporary! Remove this! |
| 582 if (CommandLine::ForCurrentProcess()->HasSwitch( | 582 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 583 switches::kAshEnableTouchViewTesting)) { | 583 switches::kAshEnableTouchViewTesting)) { |
| 584 MaximizeModeController* controller = Shell::GetInstance()-> | 584 MaximizeModeController* controller = Shell::GetInstance()-> |
| 585 maximize_mode_controller(); | 585 maximize_mode_controller(); |
| 586 controller->EnableMaximizeModeWindowManager( | 586 controller->EnableMaximizeModeWindowManager( |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1051 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1052 } | 1052 } |
| 1053 if (shell->delegate()->IsRunningInForcedAppMode() && | 1053 if (shell->delegate()->IsRunningInForcedAppMode() && |
| 1054 actions_allowed_in_app_mode_.find(action) == | 1054 actions_allowed_in_app_mode_.find(action) == |
| 1055 actions_allowed_in_app_mode_.end()) { | 1055 actions_allowed_in_app_mode_.end()) { |
| 1056 return RESTRICTION_PREVENT_PROCESSING; | 1056 return RESTRICTION_PREVENT_PROCESSING; |
| 1057 } | 1057 } |
| 1058 if (MruWindowTracker::BuildWindowList(false).empty() && | 1058 if (MruWindowTracker::BuildWindowList(false).empty() && |
| 1059 actions_needing_window_.find(action) != actions_needing_window_.end()) { | 1059 actions_needing_window_.find(action) != actions_needing_window_.end()) { |
| 1060 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( | 1060 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( |
| 1061 A11Y_ALERT_WINDOW_NEEDED); | 1061 ui::A11Y_ALERT_WINDOW_NEEDED); |
| 1062 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; | 1062 return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION; |
| 1063 } | 1063 } |
| 1064 return RESTRICTION_NONE; | 1064 return RESTRICTION_NONE; |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 void AcceleratorController::SetBrightnessControlDelegate( | 1067 void AcceleratorController::SetBrightnessControlDelegate( |
| 1068 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { | 1068 scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) { |
| 1069 brightness_control_delegate_ = brightness_control_delegate.Pass(); | 1069 brightness_control_delegate_ = brightness_control_delegate.Pass(); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 keyboard_brightness_control_delegate) { | 1109 keyboard_brightness_control_delegate) { |
| 1110 keyboard_brightness_control_delegate_ = | 1110 keyboard_brightness_control_delegate_ = |
| 1111 keyboard_brightness_control_delegate.Pass(); | 1111 keyboard_brightness_control_delegate.Pass(); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 bool AcceleratorController::CanHandleAccelerators() const { | 1114 bool AcceleratorController::CanHandleAccelerators() const { |
| 1115 return true; | 1115 return true; |
| 1116 } | 1116 } |
| 1117 | 1117 |
| 1118 } // namespace ash | 1118 } // namespace ash |
| OLD | NEW |