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

Side by Side Diff: remoting/host/win/desktop.cc

Issue 10832068: Moving Windows-only files: remoting/host -> remoting/host/win. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/win/desktop.h ('k') | remoting/host/win/elevated_controller.h » ('j') | 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/desktop_win.h" 5 #include "remoting/host/win/desktop.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace remoting { 11 namespace remoting {
12 12
13 DesktopWin::DesktopWin(HDESK desktop, bool own) : desktop_(desktop), own_(own) { 13 Desktop::Desktop(HDESK desktop, bool own) : desktop_(desktop), own_(own) {
14 } 14 }
15 15
16 DesktopWin::~DesktopWin() { 16 Desktop::~Desktop() {
17 if (own_ && desktop_ != NULL) { 17 if (own_ && desktop_ != NULL) {
18 if (!::CloseDesktop(desktop_)) { 18 if (!::CloseDesktop(desktop_)) {
19 LOG_GETLASTERROR(ERROR) 19 LOG_GETLASTERROR(ERROR)
20 << "Failed to close the owned desktop handle"; 20 << "Failed to close the owned desktop handle";
21 } 21 }
22 } 22 }
23 } 23 }
24 24
25 bool DesktopWin::GetName(string16* desktop_name_out) const { 25 bool Desktop::GetName(string16* desktop_name_out) const {
26 if (desktop_ == NULL) 26 if (desktop_ == NULL)
27 return false; 27 return false;
28 28
29 DWORD length; 29 DWORD length;
30 CHECK(!GetUserObjectInformationW(desktop_, UOI_NAME, NULL, 0, &length)); 30 CHECK(!GetUserObjectInformationW(desktop_, UOI_NAME, NULL, 0, &length));
31 CHECK(GetLastError() == ERROR_INSUFFICIENT_BUFFER); 31 CHECK(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
32 32
33 length /= sizeof(char16); 33 length /= sizeof(char16);
34 std::vector<char16> buffer(length); 34 std::vector<char16> buffer(length);
35 if (!GetUserObjectInformationW(desktop_, UOI_NAME, &buffer[0], 35 if (!GetUserObjectInformationW(desktop_, UOI_NAME, &buffer[0],
36 length * sizeof(char16), &length)) { 36 length * sizeof(char16), &length)) {
37 LOG_GETLASTERROR(ERROR) 37 LOG_GETLASTERROR(ERROR)
38 << "Failed to query the desktop name"; 38 << "Failed to query the desktop name";
39 return false; 39 return false;
40 } 40 }
41 41
42 desktop_name_out->assign(&buffer[0], length / sizeof(char16)); 42 desktop_name_out->assign(&buffer[0], length / sizeof(char16));
43 return true; 43 return true;
44 } 44 }
45 45
46 bool DesktopWin::IsSame(const DesktopWin& other) const { 46 bool Desktop::IsSame(const Desktop& other) const {
47 string16 name; 47 string16 name;
48 if (!GetName(&name)) 48 if (!GetName(&name))
49 return false; 49 return false;
50 50
51 string16 other_name; 51 string16 other_name;
52 if (!other.GetName(&other_name)) 52 if (!other.GetName(&other_name))
53 return false; 53 return false;
54 54
55 return name == other_name; 55 return name == other_name;
56 } 56 }
57 57
58 bool DesktopWin::SetThreadDesktop() const { 58 bool Desktop::SetThreadDesktop() const {
59 if (!::SetThreadDesktop(desktop_)) { 59 if (!::SetThreadDesktop(desktop_)) {
60 LOG_GETLASTERROR(ERROR) 60 LOG_GETLASTERROR(ERROR)
61 << "Failed to assign the desktop to the current thread"; 61 << "Failed to assign the desktop to the current thread";
62 return false; 62 return false;
63 } 63 }
64 64
65 return true; 65 return true;
66 } 66 }
67 67
68 scoped_ptr<DesktopWin> DesktopWin::GetDesktop(const wchar_t* desktop_name) { 68 scoped_ptr<Desktop> Desktop::GetDesktop(const wchar_t* desktop_name) {
69 ACCESS_MASK desired_access = 69 ACCESS_MASK desired_access =
70 DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE | 70 DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_ENUMERATE |
71 DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS | 71 DESKTOP_HOOKCONTROL | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |
72 DESKTOP_SWITCHDESKTOP | GENERIC_WRITE; 72 DESKTOP_SWITCHDESKTOP | GENERIC_WRITE;
73 HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access); 73 HDESK desktop = OpenDesktop(desktop_name, 0, FALSE, desired_access);
74 if (desktop == NULL) { 74 if (desktop == NULL) {
75 LOG_GETLASTERROR(ERROR) 75 LOG_GETLASTERROR(ERROR)
76 << "Failed to open the desktop '" << desktop_name << "'"; 76 << "Failed to open the desktop '" << desktop_name << "'";
77 return scoped_ptr<DesktopWin>(); 77 return scoped_ptr<Desktop>();
78 } 78 }
79 79
80 return scoped_ptr<DesktopWin>(new DesktopWin(desktop, true)); 80 return scoped_ptr<Desktop>(new Desktop(desktop, true));
81 } 81 }
82 82
83 scoped_ptr<DesktopWin> DesktopWin::GetInputDesktop() { 83 scoped_ptr<Desktop> Desktop::GetInputDesktop() {
84 HDESK desktop = OpenInputDesktop( 84 HDESK desktop = OpenInputDesktop(
85 0, FALSE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); 85 0, FALSE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);
86 if (desktop == NULL) { 86 if (desktop == NULL) {
87 LOG_GETLASTERROR(ERROR) 87 LOG_GETLASTERROR(ERROR)
88 << "Failed to open the desktop receiving user input"; 88 << "Failed to open the desktop receiving user input";
89 return scoped_ptr<DesktopWin>(); 89 return scoped_ptr<Desktop>();
90 } 90 }
91 91
92 return scoped_ptr<DesktopWin>(new DesktopWin(desktop, true)); 92 return scoped_ptr<Desktop>(new Desktop(desktop, true));
93 } 93 }
94 94
95 scoped_ptr<DesktopWin> DesktopWin::GetThreadDesktop() { 95 scoped_ptr<Desktop> Desktop::GetThreadDesktop() {
96 HDESK desktop = ::GetThreadDesktop(GetCurrentThreadId()); 96 HDESK desktop = ::GetThreadDesktop(GetCurrentThreadId());
97 if (desktop == NULL) { 97 if (desktop == NULL) {
98 LOG_GETLASTERROR(ERROR) 98 LOG_GETLASTERROR(ERROR)
99 << "Failed to retrieve the handle of the desktop assigned to " 99 << "Failed to retrieve the handle of the desktop assigned to "
100 "the current thread"; 100 "the current thread";
101 return scoped_ptr<DesktopWin>(); 101 return scoped_ptr<Desktop>();
102 } 102 }
103 103
104 return scoped_ptr<DesktopWin>(new DesktopWin(desktop, false)); 104 return scoped_ptr<Desktop>(new Desktop(desktop, false));
105 } 105 }
106 106
107 } // namespace remoting 107 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/desktop.h ('k') | remoting/host/win/elevated_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698