| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/clipboard.h" | 5 #include "remoting/host/clipboard.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 16 #include "base/timer/timer.h" | 17 #include "base/timer/timer.h" |
| 17 #include "remoting/base/constants.h" | 18 #include "remoting/base/constants.h" |
| 18 #include "remoting/base/util.h" | 19 #include "remoting/base/util.h" |
| 19 #include "remoting/proto/event.pb.h" | 20 #include "remoting/proto/event.pb.h" |
| 20 #include "remoting/protocol/clipboard_stub.h" | 21 #include "remoting/protocol/clipboard_stub.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(ClipboardMac); | 48 DISALLOW_COPY_AND_ASSIGN(ClipboardMac); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 ClipboardMac::ClipboardMac() : current_change_count_(0) {} | 51 ClipboardMac::ClipboardMac() : current_change_count_(0) {} |
| 51 | 52 |
| 52 ClipboardMac::~ClipboardMac() {} | 53 ClipboardMac::~ClipboardMac() {} |
| 53 | 54 |
| 54 void ClipboardMac::Start( | 55 void ClipboardMac::Start( |
| 55 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { | 56 std::unique_ptr<protocol::ClipboardStub> client_clipboard) { |
| 56 client_clipboard_.reset(client_clipboard.release()); | 57 client_clipboard_ = std::move(client_clipboard); |
| 57 | 58 |
| 58 // Synchronize local change-count with the pasteboard's. The change-count is | 59 // Synchronize local change-count with the pasteboard's. The change-count is |
| 59 // used to detect clipboard changes. | 60 // used to detect clipboard changes. |
| 60 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount]; | 61 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount]; |
| 61 | 62 |
| 62 // OS X doesn't provide a clipboard-changed notification. The only way to | 63 // OS X doesn't provide a clipboard-changed notification. The only way to |
| 63 // detect clipboard changes is by polling. | 64 // detect clipboard changes is by polling. |
| 64 clipboard_polling_timer_.reset(new base::RepeatingTimer()); | 65 clipboard_polling_timer_.reset(new base::RepeatingTimer()); |
| 65 clipboard_polling_timer_->Start(FROM_HERE, | 66 clipboard_polling_timer_->Start(FROM_HERE, |
| 66 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs), | 67 base::TimeDelta::FromMilliseconds(kClipboardPollingIntervalMs), |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 event.set_mime_type(kMimeTypeTextUtf8); | 106 event.set_mime_type(kMimeTypeTextUtf8); |
| 106 event.set_data(base::SysNSStringToUTF8(data)); | 107 event.set_data(base::SysNSStringToUTF8(data)); |
| 107 client_clipboard_->InjectClipboardEvent(event); | 108 client_clipboard_->InjectClipboardEvent(event); |
| 108 } | 109 } |
| 109 | 110 |
| 110 std::unique_ptr<Clipboard> Clipboard::Create() { | 111 std::unique_ptr<Clipboard> Clipboard::Create() { |
| 111 return base::WrapUnique(new ClipboardMac()); | 112 return base::WrapUnique(new ClipboardMac()); |
| 112 } | 113 } |
| 113 | 114 |
| 114 } // namespace remoting | 115 } // namespace remoting |
| OLD | NEW |