Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Side by Side Diff: remoting/host/clipboard_win.cc

Issue 798943003: Call CloseClipboard() with anonymous access token. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698