| 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 | |
| 39 TouchExplorationController::~TouchExplorationController() { | 38 TouchExplorationController::~TouchExplorationController() { |
| 40 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); | 39 root_window_->GetHost()->GetEventSource()->RemoveEventRewriter(this); |
| 41 } | 40 } |
| 42 | 41 |
| 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 | |
| 73 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( | 42 ui::EventRewriteStatus TouchExplorationController::RewriteEvent( |
| 74 const ui::Event& event, | 43 const ui::Event& event, |
| 75 scoped_ptr<ui::Event>* rewritten_event) { | 44 scoped_ptr<ui::Event>* rewritten_event) { |
| 76 if (!event.IsTouchEvent()) { | 45 if (!event.IsTouchEvent()) { |
| 77 if (event.IsKeyEvent()) { | 46 if (event.IsKeyEvent()) { |
| 78 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); | 47 const ui::KeyEvent& key_event = static_cast<const ui::KeyEvent&>(event); |
| 79 VLOG(0) << "\nKeyboard event: " << key_event.name() | 48 VLOG(0) << "\nKeyboard event: " << key_event.name() |
| 80 << "\n Key code: " << key_event.key_code() | 49 << "\n Key code: " << key_event.key_code() |
| 81 << ", Flags: " << key_event.flags() | 50 << ", Flags: " << key_event.flags() |
| 82 << ", Is char: " << key_event.is_char(); | 51 << ", Is char: " << key_event.is_char(); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 return "TWO_TO_ONE_FINGER"; | 692 return "TWO_TO_ONE_FINGER"; |
| 724 case PASSTHROUGH: | 693 case PASSTHROUGH: |
| 725 return "PASSTHROUGH"; | 694 return "PASSTHROUGH"; |
| 726 case WAIT_FOR_RELEASE: | 695 case WAIT_FOR_RELEASE: |
| 727 return "WAIT_FOR_RELEASE"; | 696 return "WAIT_FOR_RELEASE"; |
| 728 } | 697 } |
| 729 return "Not a state"; | 698 return "Not a state"; |
| 730 } | 699 } |
| 731 | 700 |
| 732 } // namespace ui | 701 } // namespace ui |
| OLD | NEW |