| 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 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // The caller must not close the handle that ::SetClipboardData returns. | 81 // The caller must not close the handle that ::SetClipboardData returns. |
| 82 ::SetClipboardData(uFormat, hMem); | 82 ::SetClipboardData(uFormat, hMem); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // The caller must not free the handle. The caller should lock the handle, | 85 // The caller must not free the handle. The caller should lock the handle, |
| 86 // copy the clipboard data, and unlock the handle. All this must be done | 86 // copy the clipboard data, and unlock the handle. All this must be done |
| 87 // before this ScopedClipboard is destroyed. | 87 // before this ScopedClipboard is destroyed. |
| 88 HANDLE GetData(UINT format) { | 88 HANDLE GetData(UINT format) { |
| 89 if (!opened_) { | 89 if (!opened_) { |
| 90 NOTREACHED(); | 90 NOTREACHED(); |
| 91 return NULL; | 91 return nullptr; |
| 92 } | 92 } |
| 93 return ::GetClipboardData(format); | 93 return ::GetClipboardData(format); |
| 94 } | 94 } |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 bool opened_; | 97 bool opened_; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 typedef BOOL (WINAPI AddClipboardFormatListenerFn)(HWND); | 100 typedef BOOL (WINAPI AddClipboardFormatListenerFn)(HWND); |
| 101 typedef BOOL (WINAPI RemoveClipboardFormatListenerFn)(HWND); | 101 typedef BOOL (WINAPI RemoveClipboardFormatListenerFn)(HWND); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 127 AddClipboardFormatListenerFn* add_clipboard_format_listener_; | 127 AddClipboardFormatListenerFn* add_clipboard_format_listener_; |
| 128 RemoveClipboardFormatListenerFn* remove_clipboard_format_listener_; | 128 RemoveClipboardFormatListenerFn* remove_clipboard_format_listener_; |
| 129 | 129 |
| 130 // Used to subscribe to WM_CLIPBOARDUPDATE messages. | 130 // Used to subscribe to WM_CLIPBOARDUPDATE messages. |
| 131 scoped_ptr<base::win::MessageWindow> window_; | 131 scoped_ptr<base::win::MessageWindow> window_; |
| 132 | 132 |
| 133 DISALLOW_COPY_AND_ASSIGN(ClipboardWin); | 133 DISALLOW_COPY_AND_ASSIGN(ClipboardWin); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 ClipboardWin::ClipboardWin() | 136 ClipboardWin::ClipboardWin() |
| 137 : add_clipboard_format_listener_(NULL), | 137 : add_clipboard_format_listener_(nullptr), |
| 138 remove_clipboard_format_listener_(NULL) { | 138 remove_clipboard_format_listener_(nullptr) { |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ClipboardWin::Start( | 141 void ClipboardWin::Start( |
| 142 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 142 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
| 143 DCHECK(!add_clipboard_format_listener_); | 143 DCHECK(!add_clipboard_format_listener_); |
| 144 DCHECK(!remove_clipboard_format_listener_); | 144 DCHECK(!remove_clipboard_format_listener_); |
| 145 DCHECK(!window_); | 145 DCHECK(!window_); |
| 146 | 146 |
| 147 client_clipboard_.swap(client_clipboard); | 147 client_clipboard_.swap(client_clipboard); |
| 148 | 148 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 } | 275 } |
| 276 | 276 |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| 279 | 279 |
| 280 scoped_ptr<Clipboard> Clipboard::Create() { | 280 scoped_ptr<Clipboard> Clipboard::Create() { |
| 281 return make_scoped_ptr(new ClipboardWin()); | 281 return make_scoped_ptr(new ClipboardWin()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace remoting | 284 } // namespace remoting |
| OLD | NEW |