OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_BROWSER_INPUT_EVENT_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_BROWSER_INPUT_EVENT_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_vector.h" |
| 12 #include "content/common/input/input_event.h" |
| 13 #include "content/common/input/input_event_disposition.h" |
| 14 |
| 15 namespace content { |
| 16 |
| 17 class BrowserInputEvent; |
| 18 |
| 19 // Provides customized dispatch response for BrowserInputEvents. |
| 20 class BrowserInputEventClient { |
| 21 public: |
| 22 virtual ~BrowserInputEventClient() {} |
| 23 |
| 24 virtual void OnDispatched(const BrowserInputEvent& event, |
| 25 InputEventDisposition disposition) {} |
| 26 |
| 27 // Called if the event went unconsumed and can create followup events. Any |
| 28 // events added to |followup| by the client will be inserted into the |
| 29 // current input event stream. |followup| will never be NULL. |
| 30 virtual void OnDispatched(const BrowserInputEvent& event, |
| 31 InputEventDisposition disposition, |
| 32 ScopedVector<BrowserInputEvent>* followup) {} |
| 33 }; |
| 34 |
| 35 // Augmented InputEvent allowing customized dispatch response in the browser. |
| 36 class CONTENT_EXPORT BrowserInputEvent : public InputEvent { |
| 37 public: |
| 38 // |client| is assumed to be non-NULL. |
| 39 static scoped_ptr<BrowserInputEvent> Create( |
| 40 int64 id, |
| 41 scoped_ptr<InputEvent::Payload> payload, |
| 42 BrowserInputEventClient* client); |
| 43 |
| 44 template <typename PayloadType> |
| 45 static scoped_ptr<BrowserInputEvent> Create(int64 id, |
| 46 scoped_ptr<PayloadType> payload, |
| 47 BrowserInputEventClient* client) { |
| 48 return Create(id, payload.template PassAs<InputEvent::Payload>(), client); |
| 49 } |
| 50 |
| 51 virtual ~BrowserInputEvent(); |
| 52 |
| 53 // |followup_events| must not be NULL, and will only be modified if the |
| 54 // event went unconsumed and can create followup events. |
| 55 void OnDispatched(InputEventDisposition disposition, |
| 56 ScopedVector<BrowserInputEvent>* followup_events); |
| 57 |
| 58 protected: |
| 59 explicit BrowserInputEvent(BrowserInputEventClient* client); |
| 60 |
| 61 bool CanCreateFollowupEvents() const; |
| 62 |
| 63 private: |
| 64 BrowserInputEventClient* client_; |
| 65 }; |
| 66 |
| 67 } // namespace content |
| 68 |
| 69 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_BROWSER_INPUT_EVENT_H_ |
OLD | NEW |