OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "sandbox/win/src/window.h" | 5 #include "sandbox/win/src/window.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 // Get the size of the name. | 104 // Get the size of the name. |
105 DWORD size = 0; | 105 DWORD size = 0; |
106 ::GetUserObjectInformation(handle, UOI_NAME, NULL, 0, &size); | 106 ::GetUserObjectInformation(handle, UOI_NAME, NULL, 0, &size); |
107 | 107 |
108 if (!size) { | 108 if (!size) { |
109 NOTREACHED(); | 109 NOTREACHED(); |
110 return std::wstring(); | 110 return std::wstring(); |
111 } | 111 } |
112 | 112 |
113 // Create the buffer that will hold the name. | 113 // Create the buffer that will hold the name. |
114 scoped_array<wchar_t> name_buffer(new wchar_t[size]); | 114 scoped_ptr<wchar_t[]> name_buffer(new wchar_t[size]); |
115 | 115 |
116 // Query the name of the object. | 116 // Query the name of the object. |
117 if (!::GetUserObjectInformation(handle, UOI_NAME, name_buffer.get(), size, | 117 if (!::GetUserObjectInformation(handle, UOI_NAME, name_buffer.get(), size, |
118 &size)) { | 118 &size)) { |
119 NOTREACHED(); | 119 NOTREACHED(); |
120 return std::wstring(); | 120 return std::wstring(); |
121 } | 121 } |
122 | 122 |
123 return std::wstring(name_buffer.get()); | 123 return std::wstring(name_buffer.get()); |
124 } | 124 } |
125 | 125 |
126 std::wstring GetFullDesktopName(HWINSTA winsta, HDESK desktop) { | 126 std::wstring GetFullDesktopName(HWINSTA winsta, HDESK desktop) { |
127 if (!desktop) { | 127 if (!desktop) { |
128 NOTREACHED(); | 128 NOTREACHED(); |
129 return std::wstring(); | 129 return std::wstring(); |
130 } | 130 } |
131 | 131 |
132 std::wstring name; | 132 std::wstring name; |
133 if (winsta) { | 133 if (winsta) { |
134 name = GetWindowObjectName(winsta); | 134 name = GetWindowObjectName(winsta); |
135 name += L'\\'; | 135 name += L'\\'; |
136 } | 136 } |
137 | 137 |
138 name += GetWindowObjectName(desktop); | 138 name += GetWindowObjectName(desktop); |
139 return name; | 139 return name; |
140 } | 140 } |
141 | 141 |
142 } // namespace sandbox | 142 } // namespace sandbox |
OLD | NEW |