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); | |
Wez
2014/12/12 19:25:36
nit: I think it'd be acceptable to just CHECK(ApiC
Sergey Ulanov
2014/12/12 19:34:00
Side effects inside DCHECKs are often hard to debu
| |
35 ::CloseClipboard(); | 39 ::CloseClipboard(); |
40 ::RevertToSelf(); | |
Wez
2014/12/12 19:25:36
CHECK this as well?
Sergey Ulanov
2014/12/12 19:34:00
Done.
| |
36 } | 41 } |
37 } | 42 } |
38 | 43 |
39 bool Init(HWND owner) { | 44 bool Init(HWND owner) { |
40 const int kMaxAttemptsToOpenClipboard = 5; | 45 const int kMaxAttemptsToOpenClipboard = 5; |
41 const base::TimeDelta kSleepTimeBetweenAttempts = | 46 const base::TimeDelta kSleepTimeBetweenAttempts = |
42 base::TimeDelta::FromMilliseconds(5); | 47 base::TimeDelta::FromMilliseconds(5); |
43 | 48 |
44 if (opened_) { | 49 if (opened_) { |
45 NOTREACHED(); | 50 NOTREACHED(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 } | 274 } |
270 | 275 |
271 return false; | 276 return false; |
272 } | 277 } |
273 | 278 |
274 scoped_ptr<Clipboard> Clipboard::Create() { | 279 scoped_ptr<Clipboard> Clipboard::Create() { |
275 return make_scoped_ptr(new ClipboardWin()); | 280 return make_scoped_ptr(new ClipboardWin()); |
276 } | 281 } |
277 | 282 |
278 } // namespace remoting | 283 } // namespace remoting |
OLD | NEW |