Deprecate chrome.usb.requestAccess.
[chromium-blink-merge.git] / athena / screen / screen_accelerator_handler.cc
blob90d990f278698f29ddc7a58399906d0efc7bfe24
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "athena/screen/screen_accelerator_handler.h"
7 #include "athena/input/public/accelerator_manager.h"
8 #include "athena/screen/public/screen_manager.h"
9 #include "ui/events/event_constants.h"
10 #include "ui/gfx/display.h"
11 #include "ui/gfx/screen.h"
13 namespace athena {
14 namespace {
16 enum Command {
17 CMD_ROTATE_SCREEN,
20 const AcceleratorData accelerator_data[] = {
21 {TRIGGER_ON_PRESS, ui::VKEY_F3,
22 ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN,
23 CMD_ROTATE_SCREEN, AF_NONE},
26 void HandleRotateScreen() {
27 ScreenManager* screen_manager = ScreenManager::Get();
28 gfx::Display::Rotation current_rotation =
29 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().rotation();
30 if (current_rotation == gfx::Display::ROTATE_0)
31 screen_manager->SetRotation(gfx::Display::ROTATE_90);
32 else if (current_rotation == gfx::Display::ROTATE_90)
33 screen_manager->SetRotation(gfx::Display::ROTATE_180);
34 else if (current_rotation == gfx::Display::ROTATE_180)
35 screen_manager->SetRotation(gfx::Display::ROTATE_270);
36 else if (current_rotation == gfx::Display::ROTATE_270)
37 screen_manager->SetRotation(gfx::Display::ROTATE_0);
40 } // namespace
42 ScreenAcceleratorHandler::ScreenAcceleratorHandler() {
43 AcceleratorManager::Get()->RegisterAccelerators(
44 accelerator_data, arraysize(accelerator_data), this);
47 ScreenAcceleratorHandler::~ScreenAcceleratorHandler() {
50 bool ScreenAcceleratorHandler::IsCommandEnabled(int command_id) const {
51 return true;
54 bool ScreenAcceleratorHandler::OnAcceleratorFired(
55 int command_id,
56 const ui::Accelerator& accelerator) {
57 switch (command_id) {
58 case CMD_ROTATE_SCREEN:
59 HandleRotateScreen();
60 return true;
62 return false;
65 } // namesapce athena