| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/magnifier_key_scroller.h" | 5 #include "ash/accelerators/magnifier_key_scroller.h" |
| 6 | 6 |
| 7 #include <utility> |
| 8 |
| 7 #include "ash/accelerators/key_hold_detector.h" | 9 #include "ash/accelerators/key_hold_detector.h" |
| 8 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 9 #include "ash/magnifier/magnification_controller.h" | 11 #include "ash/magnifier/magnification_controller.h" |
| 10 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "ui/events/event.h" | 14 #include "ui/events/event.h" |
| 13 | 15 |
| 14 namespace ash { | 16 namespace ash { |
| 15 namespace { | 17 namespace { |
| 16 bool magnifier_key_scroller_enabled = false; | 18 bool magnifier_key_scroller_enabled = false; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 29 } | 31 } |
| 30 | 32 |
| 31 // static | 33 // static |
| 32 void MagnifierKeyScroller::SetEnabled(bool enabled) { | 34 void MagnifierKeyScroller::SetEnabled(bool enabled) { |
| 33 magnifier_key_scroller_enabled = enabled; | 35 magnifier_key_scroller_enabled = enabled; |
| 34 } | 36 } |
| 35 | 37 |
| 36 // static | 38 // static |
| 37 scoped_ptr<ui::EventHandler> MagnifierKeyScroller::CreateHandler() { | 39 scoped_ptr<ui::EventHandler> MagnifierKeyScroller::CreateHandler() { |
| 38 scoped_ptr<KeyHoldDetector::Delegate> delegate(new MagnifierKeyScroller()); | 40 scoped_ptr<KeyHoldDetector::Delegate> delegate(new MagnifierKeyScroller()); |
| 39 return scoped_ptr<ui::EventHandler>(new KeyHoldDetector(delegate.Pass())); | 41 return scoped_ptr<ui::EventHandler>(new KeyHoldDetector(std::move(delegate))); |
| 40 } | 42 } |
| 41 | 43 |
| 42 bool MagnifierKeyScroller::ShouldProcessEvent(const ui::KeyEvent* event) const { | 44 bool MagnifierKeyScroller::ShouldProcessEvent(const ui::KeyEvent* event) const { |
| 43 return IsEnabled() && | 45 return IsEnabled() && |
| 44 (event->key_code() == ui::VKEY_UP || | 46 (event->key_code() == ui::VKEY_UP || |
| 45 event->key_code() == ui::VKEY_DOWN || | 47 event->key_code() == ui::VKEY_DOWN || |
| 46 event->key_code() == ui::VKEY_LEFT || | 48 event->key_code() == ui::VKEY_LEFT || |
| 47 event->key_code() == ui::VKEY_RIGHT); | 49 event->key_code() == ui::VKEY_RIGHT); |
| 48 } | 50 } |
| 49 | 51 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 MagnificationController* controller = | 83 MagnificationController* controller = |
| 82 Shell::GetInstance()->magnification_controller(); | 84 Shell::GetInstance()->magnification_controller(); |
| 83 controller->SetScrollDirection(MagnificationController::SCROLL_NONE); | 85 controller->SetScrollDirection(MagnificationController::SCROLL_NONE); |
| 84 } | 86 } |
| 85 | 87 |
| 86 MagnifierKeyScroller::MagnifierKeyScroller() {} | 88 MagnifierKeyScroller::MagnifierKeyScroller() {} |
| 87 | 89 |
| 88 MagnifierKeyScroller::~MagnifierKeyScroller() {} | 90 MagnifierKeyScroller::~MagnifierKeyScroller() {} |
| 89 | 91 |
| 90 } // namespace ash | 92 } // namespace ash |
| OLD | NEW |