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 "ui/chromeos/touch_exploration_controller.h" | 5 #include "ui/chromeos/touch_exploration_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "ui/aura/client/cursor_client.h" | 9 #include "ui/aura/client/cursor_client.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 : root_window_(root_window), | 28 : root_window_(root_window), |
29 state_(NO_FINGERS_DOWN), | 29 state_(NO_FINGERS_DOWN), |
30 event_handler_for_testing_(NULL), | 30 event_handler_for_testing_(NULL), |
31 gesture_provider_(this), | 31 gesture_provider_(this), |
32 prev_state_(NO_FINGERS_DOWN), | 32 prev_state_(NO_FINGERS_DOWN), |
33 VLOG_on_(true) { | 33 VLOG_on_(true) { |
34 CHECK(root_window); | 34 CHECK(root_window); |
35 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); | 35 root_window->GetHost()->GetEventSource()->AddEventRewriter(this); |
36 } | 36 } |
37 | 37 |
| 38 |
38 TouchExplorationController::~TouchExplorationController() { | 39 TouchExplorationController::~TouchExplorationController() { |
39 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 40 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
40 } | 41 } |
41 | 42 |
| 43 void TouchExplorationController::CallTapTimerNowForTesting() { |
| 44 DCHECK(tap_timer_.IsRunning()); |
| 45 tap_timer_.Stop(); |
| 46 OnTapTimerFired(); |
| 47 } |
| 48 |
| 49 void TouchExplorationController::CallTapTimerNowIfRunningForTesting() { |
| 50 if (tap_timer_.IsRunning()) { |
| 51 tap_timer_.Stop(); |
| 52 OnTapTimerFired(); |
| 53 } |
| 54 } |
| 55 |
| 56 void TouchExplorationController::SetEventHandlerForTesting( |
| 57 ui::EventHandler* event_handler_for_testing) { |
| 58 event_handler_for_testing_ = event_handler_for_testing; |
| 59 } |
| 60 |
| 61 bool TouchExplorationController::IsInNoFingersDownStateForTesting() const { |
| 62 return state_ == NO_FINGERS_DOWN; |
| 63 } |
| 64 |
| 65 bool TouchExplorationController::IsInGestureInProgressStateForTesting() const { |
| 66 return state_ == GESTURE_IN_PROGRESS; |
| 67 } |
| 68 |
| 69 void TouchExplorationController::SuppressVLOGsForTesting(bool suppress) { |
| 70 VLOG_on_ = !suppress; |
| 71 } |
| 72 |
42 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 73 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
43 const ui::Event& event, | 74 const ui::Event& event, |
44 scoped_ptr<ui::Event>* rewritten_event) { | 75 scoped_ptr<ui::Event>* rewritten_event) { |
45 if (!event.IsTouchEvent()) { | 76 if (!event.IsTouchEvent()) { |
46 if (event.IsKeyEvent()) { | 77 if (event.IsKeyEvent()) { |
47 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 78 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
48 VLOG(0) << "\nKeyboard event: " << key_event.name() | 79 VLOG(0) << "\nKeyboard event: " << key_event.name() |
49 << "\n Key code: " << key_event.key_code() | 80 << "\n Key code: " << key_event.key_code() |
50 << ", Flags: " << key_event.flags() | 81 << ", Flags: " << key_event.flags() |
51 << ", Is char: " << key_event.is_char(); | 82 << ", Is char: " << key_event.is_char(); |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 return "TWO_TO_ONE_FINGER"; | 723 return "TWO_TO_ONE_FINGER"; |
693 case PASSTHROUGH: | 724 case PASSTHROUGH: |
694 return "PASSTHROUGH"; | 725 return "PASSTHROUGH"; |
695 case WAIT_FOR_RELEASE: | 726 case WAIT_FOR_RELEASE: |
696 return "WAIT_FOR_RELEASE"; | 727 return "WAIT_FOR_RELEASE"; |
697 } | 728 } |
698 return "Not a state"; | 729 return "Not a state"; |
699 } | 730 } |
700 | 731 |
701 } // namespace ui | 732 } // namespace ui |
OLD | NEW |