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/key_hold_detector.h" | 5 #include "ash/accelerators/key_hold_detector.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "ash/shell.h" | 9 #include "ash/shell.h" |
8 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
9 #include "ui/aura/window_tracker.h" | 11 #include "ui/aura/window_tracker.h" |
10 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
11 #include "ui/events/event_dispatcher.h" | 13 #include "ui/events/event_dispatcher.h" |
12 #include "ui/events/event_processor.h" | 14 #include "ui/events/event_processor.h" |
13 | 15 |
14 namespace ash { | 16 namespace ash { |
15 namespace { | 17 namespace { |
16 | 18 |
(...skipping 19 matching lines...) Expand all Loading... |
36 tracker->Add(static_cast<aura::Window*>(event->target())); | 38 tracker->Add(static_cast<aura::Window*>(event->target())); |
37 | 39 |
38 base::MessageLoopForUI::current()->PostTask( | 40 base::MessageLoopForUI::current()->PostTask( |
39 FROM_HERE, | 41 FROM_HERE, |
40 base::Bind(&DispatchPressedEvent, pressed_event, base::Passed(&tracker))); | 42 base::Bind(&DispatchPressedEvent, pressed_event, base::Passed(&tracker))); |
41 } | 43 } |
42 | 44 |
43 } // namespace | 45 } // namespace |
44 | 46 |
45 KeyHoldDetector::KeyHoldDetector(scoped_ptr<Delegate> delegate) | 47 KeyHoldDetector::KeyHoldDetector(scoped_ptr<Delegate> delegate) |
46 : state_(INITIAL), | 48 : state_(INITIAL), delegate_(std::move(delegate)) {} |
47 delegate_(delegate.Pass()) {} | |
48 | 49 |
49 KeyHoldDetector::~KeyHoldDetector() {} | 50 KeyHoldDetector::~KeyHoldDetector() {} |
50 | 51 |
51 void KeyHoldDetector::OnKeyEvent(ui::KeyEvent* event) { | 52 void KeyHoldDetector::OnKeyEvent(ui::KeyEvent* event) { |
52 if (!delegate_->ShouldProcessEvent(event)) | 53 if (!delegate_->ShouldProcessEvent(event)) |
53 return; | 54 return; |
54 | 55 |
55 if (delegate_->IsStartEvent(event)) { | 56 if (delegate_->IsStartEvent(event)) { |
56 switch (state_) { | 57 switch (state_) { |
57 case INITIAL: | 58 case INITIAL: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (delegate_->ShouldStopEventPropagation()) | 93 if (delegate_->ShouldStopEventPropagation()) |
93 event->StopPropagation(); | 94 event->StopPropagation(); |
94 break; | 95 break; |
95 } | 96 } |
96 } | 97 } |
97 state_ = INITIAL; | 98 state_ = INITIAL; |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 } // namespace ash | 102 } // namespace ash |
OLD | NEW |