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 #include "content/browser/renderer_host/input/browser_input_event.h" |
| 6 |
| 7 #include "content/common/input/web_input_event_payload.h" |
| 8 |
| 9 namespace content { |
| 10 |
| 11 BrowserInputEvent::BrowserInputEvent(BrowserInputEventClient* client) |
| 12 : client_(client) {} |
| 13 |
| 14 BrowserInputEvent::~BrowserInputEvent() {} |
| 15 |
| 16 scoped_ptr<BrowserInputEvent> BrowserInputEvent::Create( |
| 17 int64 id, |
| 18 scoped_ptr<InputEvent::Payload> payload, |
| 19 BrowserInputEventClient* client) { |
| 20 DCHECK(client); |
| 21 scoped_ptr<BrowserInputEvent> event(new BrowserInputEvent(client)); |
| 22 event->Initialize(id, payload.Pass()); |
| 23 return event.Pass(); |
| 24 } |
| 25 |
| 26 void BrowserInputEvent::OnDispatched( |
| 27 InputEventDisposition disposition, |
| 28 ScopedVector<BrowserInputEvent>* followup_events) { |
| 29 DCHECK(followup_events); |
| 30 |
| 31 bool event_consumed = |
| 32 disposition == INPUT_EVENT_MAIN_THREAD_CONSUMED || |
| 33 disposition == INPUT_EVENT_IMPL_THREAD_CONSUMED || |
| 34 disposition == INPUT_EVENT_MAIN_THREAD_PREVENT_DEFAULTED; |
| 35 |
| 36 if (!event_consumed && CanCreateFollowupEvents()) |
| 37 client_->OnDispatched(*this, disposition, followup_events); |
| 38 else |
| 39 client_->OnDispatched(*this, disposition); |
| 40 } |
| 41 |
| 42 bool BrowserInputEvent::CanCreateFollowupEvents() const { |
| 43 return payload()->GetType() == InputEvent::Payload::WEB_INPUT_EVENT && |
| 44 WebInputEventPayload::Cast(payload())->CanCreateFollowupEvents(); |
| 45 } |
| 46 |
| 47 } // namespace content |
OLD | NEW |