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 14 matching lines...) Expand all Loading... |
25 // A scoper class that opens and closes the clipboard. | 25 // A scoper class that opens and closes the clipboard. |
26 // This class was adapted from the ScopedClipboard class in | 26 // This class was adapted from the ScopedClipboard class in |
27 // ui/base/clipboard/clipboard_win.cc. | 27 // ui/base/clipboard/clipboard_win.cc. |
28 class ScopedClipboard { | 28 class ScopedClipboard { |
29 public: | 29 public: |
30 ScopedClipboard() : opened_(false) { | 30 ScopedClipboard() : opened_(false) { |
31 } | 31 } |
32 | 32 |
33 ~ScopedClipboard() { | 33 ~ScopedClipboard() { |
34 if (opened_) { | 34 if (opened_) { |
| 35 // CloseClipboard() must be called with anonymous access token. See |
| 36 // crbug.com/441834 . |
| 37 BOOL result = ::ImpersonateAnonymousToken(::GetCurrentThread()); |
| 38 CHECK(result); |
35 ::CloseClipboard(); | 39 ::CloseClipboard(); |
| 40 result = ::RevertToSelf(); |
| 41 CHECK(result); |
36 } | 42 } |
37 } | 43 } |
38 | 44 |
39 bool Init(HWND owner) { | 45 bool Init(HWND owner) { |
40 const int kMaxAttemptsToOpenClipboard = 5; | 46 const int kMaxAttemptsToOpenClipboard = 5; |
41 const base::TimeDelta kSleepTimeBetweenAttempts = | 47 const base::TimeDelta kSleepTimeBetweenAttempts = |
42 base::TimeDelta::FromMilliseconds(5); | 48 base::TimeDelta::FromMilliseconds(5); |
43 | 49 |
44 if (opened_) { | 50 if (opened_) { |
45 NOTREACHED(); | 51 NOTREACHED(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 275 } |
270 | 276 |
271 return false; | 277 return false; |
272 } | 278 } |
273 | 279 |
274 scoped_ptr<Clipboard> Clipboard::Create() { | 280 scoped_ptr<Clipboard> Clipboard::Create() { |
275 return make_scoped_ptr(new ClipboardWin()); | 281 return make_scoped_ptr(new ClipboardWin()); |
276 } | 282 } |
277 | 283 |
278 } // namespace remoting | 284 } // namespace remoting |
OLD | NEW |