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 "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "remoting/base/constants.h" | 8 #include "remoting/base/constants.h" |
9 #include "remoting/proto/event.pb.h" | 9 #include "remoting/proto/event.pb.h" |
10 #include "remoting/protocol/clipboard_stub.h" | 10 #include "remoting/protocol/clipboard_stub.h" |
11 #include "ui/base/clipboard/clipboard.h" | 11 #include "ui/base/clipboard/clipboard.h" |
12 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 12 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // Clipboard polling interval in milliseconds. | 16 // Clipboard polling interval in milliseconds. |
17 const int64 kClipboardPollingIntervalMs = 500; | 17 const int64_t kClipboardPollingIntervalMs = 500; |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 namespace remoting { | 21 namespace remoting { |
22 | 22 |
23 ClipboardAura::ClipboardAura() | 23 ClipboardAura::ClipboardAura() |
24 : current_change_count_(0), | 24 : current_change_count_(0), |
25 polling_interval_( | 25 polling_interval_( |
26 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) { | 26 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs)) { |
27 } | 27 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 base::TimeDelta polling_interval) { | 62 base::TimeDelta polling_interval) { |
63 DCHECK(thread_checker_.CalledOnValidThread()); | 63 DCHECK(thread_checker_.CalledOnValidThread()); |
64 | 64 |
65 polling_interval_ = polling_interval; | 65 polling_interval_ = polling_interval; |
66 } | 66 } |
67 | 67 |
68 void ClipboardAura::CheckClipboardForChanges() { | 68 void ClipboardAura::CheckClipboardForChanges() { |
69 DCHECK(thread_checker_.CalledOnValidThread()); | 69 DCHECK(thread_checker_.CalledOnValidThread()); |
70 | 70 |
71 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 71 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
72 uint64 change_count = | 72 uint64_t change_count = |
73 clipboard->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE); | 73 clipboard->GetSequenceNumber(ui::CLIPBOARD_TYPE_COPY_PASTE); |
74 | 74 |
75 if (change_count == current_change_count_) { | 75 if (change_count == current_change_count_) { |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
79 current_change_count_ = change_count; | 79 current_change_count_ = change_count; |
80 | 80 |
81 protocol::ClipboardEvent event; | 81 protocol::ClipboardEvent event; |
82 std::string data; | 82 std::string data; |
83 | 83 |
84 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &data); | 84 clipboard->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &data); |
85 event.set_mime_type(kMimeTypeTextUtf8); | 85 event.set_mime_type(kMimeTypeTextUtf8); |
86 event.set_data(data); | 86 event.set_data(data); |
87 | 87 |
88 client_clipboard_->InjectClipboardEvent(event); | 88 client_clipboard_->InjectClipboardEvent(event); |
89 } | 89 } |
90 | 90 |
91 scoped_ptr<Clipboard> Clipboard::Create() { | 91 scoped_ptr<Clipboard> Clipboard::Create() { |
92 return make_scoped_ptr(new ClipboardAura()); | 92 return make_scoped_ptr(new ClipboardAura()); |
93 } | 93 } |
94 | 94 |
95 } // namespace remoting | 95 } // namespace remoting |
OLD | NEW |