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