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 "remoting/host/chromeos/clipboard_aura.h" | 5 #include "remoting/host/chromeos/clipboard_aura.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
8 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
9 #include "remoting/proto/event.pb.h" | 11 #include "remoting/proto/event.pb.h" |
10 #include "remoting/protocol/clipboard_stub.h" | 12 #include "remoting/protocol/clipboard_stub.h" |
11 #include "ui/base/clipboard/clipboard.h" | 13 #include "ui/base/clipboard/clipboard.h" |
12 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 14 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 // Clipboard polling interval in milliseconds. | 18 // Clipboard polling interval in milliseconds. |
17 const int64_t kClipboardPollingIntervalMs = 500; | 19 const int64_t kClipboardPollingIntervalMs = 500; |
18 | 20 |
19 } // namespace | 21 } // namespace |
20 | 22 |
21 namespace remoting { | 23 namespace remoting { |
22 | 24 |
23 ClipboardAura::ClipboardAura() | 25 ClipboardAura::ClipboardAura() |
24 : current_change_count_(0), | 26 : current_change_count_(0), |
25 polling_interval_( | 27 polling_interval_( |
26 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) { | 28 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) { |
27 } | 29 } |
28 | 30 |
29 ClipboardAura::~ClipboardAura() { | 31 ClipboardAura::~ClipboardAura() { |
30 } | 32 } |
31 | 33 |
32 void ClipboardAura::Start( | 34 void ClipboardAura::Start( |
33 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 35 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
34 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
35 | 37 |
36 client_clipboard_ = client_clipboard.Pass(); | 38 client_clipboard_ = std::move(client_clipboard); |
37 | 39 |
38 // Aura doesn't provide a clipboard-changed notification. The only way to | 40 // Aura doesn't provide a clipboard-changed notification. The only way to |
39 // detect clipboard changes is by polling. | 41 // detect clipboard changes is by polling. |
40 clipboard_polling_timer_.Start(FROM_HERE, polling_interval_, this, | 42 clipboard_polling_timer_.Start(FROM_HERE, polling_interval_, this, |
41 &ClipboardAura::CheckClipboardForChanges); | 43 &ClipboardAura::CheckClipboardForChanges); |
42 } | 44 } |
43 | 45 |
44 void ClipboardAura::InjectClipboardEvent( | 46 void ClipboardAura::InjectClipboardEvent( |
45 const protocol::ClipboardEvent& event) { | 47 const protocol::ClipboardEvent& event) { |
46 DCHECK(thread_checker_.CalledOnValidThread()); | 48 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 event.set_data(data); | 88 event.set_data(data); |
87 | 89 |
88 client_clipboard_->InjectClipboardEvent(event); | 90 client_clipboard_->InjectClipboardEvent(event); |
89 } | 91 } |
90 | 92 |
91 scoped_ptr<Clipboard> Clipboard::Create() { | 93 scoped_ptr<Clipboard> Clipboard::Create() { |
92 return make_scoped_ptr(new ClipboardAura()); | 94 return make_scoped_ptr(new ClipboardAura()); |
93 } | 95 } |
94 | 96 |
95 } // namespace remoting | 97 } // namespace remoting |
OLD | NEW |