Add Download.ShowDangerousDownloadConfirmationPrompt for Windows/CrOS
[chromium-blink-merge.git] / remoting / protocol / client_event_dispatcher.cc
blobe940f93df355022eb9fda463e66dde2ef7d9ddc5
1 // Copyright (c) 2012 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.
5 #include "remoting/protocol/client_event_dispatcher.h"
7 #include "base/message_loop/message_loop_proxy.h"
8 #include "base/time/time.h"
9 #include "net/socket/stream_socket.h"
10 #include "remoting/base/constants.h"
11 #include "remoting/proto/event.pb.h"
12 #include "remoting/proto/internal.pb.h"
13 #include "remoting/protocol/util.h"
15 namespace remoting {
16 namespace protocol {
18 ClientEventDispatcher::ClientEventDispatcher()
19 : ChannelDispatcherBase(kEventChannelName) {
22 ClientEventDispatcher::~ClientEventDispatcher() {
23 writer_.Close();
26 void ClientEventDispatcher::OnInitialized() {
27 // TODO(garykac): Set write failed callback.
28 writer_.Init(channel(),
29 BufferedSocketWriter::WriteFailedCallback());
32 void ClientEventDispatcher::InjectKeyEvent(const KeyEvent& event) {
33 DCHECK(event.has_usb_keycode());
34 DCHECK(event.has_pressed());
35 EventMessage message;
36 message.set_sequence_number(base::Time::Now().ToInternalValue());
37 message.mutable_key_event()->CopyFrom(event);
38 writer_.Write(SerializeAndFrameMessage(message), base::Closure());
41 void ClientEventDispatcher::InjectMouseEvent(const MouseEvent& event) {
42 EventMessage message;
43 message.set_sequence_number(base::Time::Now().ToInternalValue());
44 message.mutable_mouse_event()->CopyFrom(event);
45 writer_.Write(SerializeAndFrameMessage(message), base::Closure());
48 } // namespace protocol
49 } // namespace remoting