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 ::ImpersonateAnonymousToken(GetCurrentThread()); | |
jschuh
2014/12/11 17:53:06
I know the impersonate *shouldn't* fail, but it's
dcheng
2014/12/11 18:18:23
Can we use a scoper to wrap this logic?
... also,
| |
35 ::CloseClipboard(); | 36 ::CloseClipboard(); |
37 ::RevertToSelf(); | |
36 } | 38 } |
37 } | 39 } |
38 | 40 |
39 bool Init(HWND owner) { | 41 bool Init(HWND owner) { |
40 const int kMaxAttemptsToOpenClipboard = 5; | 42 const int kMaxAttemptsToOpenClipboard = 5; |
41 const base::TimeDelta kSleepTimeBetweenAttempts = | 43 const base::TimeDelta kSleepTimeBetweenAttempts = |
42 base::TimeDelta::FromMilliseconds(5); | 44 base::TimeDelta::FromMilliseconds(5); |
43 | 45 |
44 if (opened_) { | 46 if (opened_) { |
45 NOTREACHED(); | 47 NOTREACHED(); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 } | 271 } |
270 | 272 |
271 return false; | 273 return false; |
272 } | 274 } |
273 | 275 |
274 scoped_ptr<Clipboard> Clipboard::Create() { | 276 scoped_ptr<Clipboard> Clipboard::Create() { |
275 return make_scoped_ptr(new ClipboardWin()); | 277 return make_scoped_ptr(new ClipboardWin()); |
276 } | 278 } |
277 | 279 |
278 } // namespace remoting | 280 } // namespace remoting |
OLD | NEW |