Chromium Code Reviews| 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 BrowserInputEvent : public InputEvent { | |
| 37 public: | |
| 38 // |client| may be NULL. | |
| 
 
aelias_OOO_until_Jul13
2013/09/09 22:31:14
I don't think we should allow NULL clients.  Pleas
 
jdduke (slow)
2013/09/10 19:41:16
Done.
 
 | |
| 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( | |
| 46 int64 id, | |
| 47 scoped_ptr<PayloadType> payload, | |
| 48 BrowserInputEventClient* client) { | |
| 49 return Create(id, payload.template PassAs<InputEvent::Payload>(), client); | |
| 50 } | |
| 51 | |
| 52 virtual ~BrowserInputEvent(); | |
| 53 | |
| 54 // |followup_events| must not be NULL, and will only be modified if the | |
| 55 // event went unconsumed and can create followup events. | |
| 56 void OnDispatched(InputEventDisposition disposition, | |
| 57 ScopedVector<BrowserInputEvent>* followup_events); | |
| 58 | |
| 59 protected: | |
| 60 BrowserInputEvent(BrowserInputEventClient* client); | |
| 61 | |
| 62 bool CanCreateFollowupEvents() const; | |
| 63 | |
| 64 private: | |
| 65 BrowserInputEventClient* client_; | |
| 66 }; | |
| 67 | |
| 68 } // namespace content | |
| 69 | |
| 70 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_BROWSER_INPUT_EVENT_H_ | |
| OLD | NEW |