| 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 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(ClipboardMac); | 45 DISALLOW_COPY_AND_ASSIGN(ClipboardMac); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 ClipboardMac::ClipboardMac() : current_change_count_(0) { | 48 ClipboardMac::ClipboardMac() : current_change_count_(0) { |
| 49 } | 49 } |
| 50 | 50 |
| 51 ClipboardMac::~ClipboardMac() { | 51 ClipboardMac::~ClipboardMac() { |
| 52 // In it2me the destructor is not called in the same thread that the timer is | 52 // In it2me the destructor is not called in the same thread that the timer is |
| 53 // created. Thus the timer must have already been destroyed by now. | 53 // created. Thus the timer must have already been destroyed by now. |
| 54 DCHECK(clipboard_polling_timer_.get() == NULL); | 54 DCHECK(clipboard_polling_timer_.get() == nullptr); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ClipboardMac::Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 57 void ClipboardMac::Start(scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
| 58 client_clipboard_.reset(client_clipboard.release()); | 58 client_clipboard_.reset(client_clipboard.release()); |
| 59 | 59 |
| 60 // Synchronize local change-count with the pasteboard's. The change-count is | 60 // Synchronize local change-count with the pasteboard's. The change-count is |
| 61 // used to detect clipboard changes. | 61 // used to detect clipboard changes. |
| 62 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount]; | 62 current_change_count_ = [[NSPasteboard generalPasteboard] changeCount]; |
| 63 | 63 |
| 64 // OS X doesn't provide a clipboard-changed notification. The only way to | 64 // OS X doesn't provide a clipboard-changed notification. The only way to |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 event.set_mime_type(kMimeTypeTextUtf8); | 112 event.set_mime_type(kMimeTypeTextUtf8); |
| 113 event.set_data(base::SysNSStringToUTF8(data)); | 113 event.set_data(base::SysNSStringToUTF8(data)); |
| 114 client_clipboard_->InjectClipboardEvent(event); | 114 client_clipboard_->InjectClipboardEvent(event); |
| 115 } | 115 } |
| 116 | 116 |
| 117 scoped_ptr<Clipboard> Clipboard::Create() { | 117 scoped_ptr<Clipboard> Clipboard::Create() { |
| 118 return make_scoped_ptr(new ClipboardMac()); | 118 return make_scoped_ptr(new ClipboardMac()); |
| 119 } | 119 } |
| 120 | 120 |
| 121 } // namespace remoting | 121 } // namespace remoting |
| OLD | NEW |