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

Side by Side Diff: base/win/win_util.cc

Issue 6126002: Remove base/scoped_handle_win.h stub and fix up all callers to use the new location and namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 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 "base/win/win_util.h" 5 #include "base/win/win_util.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <shobjidl.h> // Must be before propkey. 8 #include <shobjidl.h> // Must be before propkey.
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
11 #include <sddl.h> 11 #include <sddl.h>
12 #include <shlobj.h> 12 #include <shlobj.h>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/win/registry.h" 15 #include "base/win/registry.h"
16 #include "base/scoped_handle.h"
17 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
18 #include "base/string_util.h" 17 #include "base/string_util.h"
19 #include "base/stringprintf.h" 18 #include "base/stringprintf.h"
20 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
20 #include "base/win/scoped_handle.h"
21 #include "base/win/windows_version.h" 21 #include "base/win/windows_version.h"
22 22
23 namespace base { 23 namespace base {
24 namespace win { 24 namespace win {
25 25
26 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ 26 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
27 offsetof(struct_name, member) + \ 27 offsetof(struct_name, member) + \
28 (sizeof static_cast<struct_name*>(NULL)->member) 28 (sizeof static_cast<struct_name*>(NULL)->member)
29 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ 29 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \
30 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) 30 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
31 31
32 void GetNonClientMetrics(NONCLIENTMETRICS* metrics) { 32 void GetNonClientMetrics(NONCLIENTMETRICS* metrics) {
33 DCHECK(metrics); 33 DCHECK(metrics);
34 34
35 static const UINT SIZEOF_NONCLIENTMETRICS = 35 static const UINT SIZEOF_NONCLIENTMETRICS =
36 (base::win::GetVersion() >= base::win::VERSION_VISTA) ? 36 (base::win::GetVersion() >= base::win::VERSION_VISTA) ?
37 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA; 37 sizeof(NONCLIENTMETRICS) : NONCLIENTMETRICS_SIZE_PRE_VISTA;
38 metrics->cbSize = SIZEOF_NONCLIENTMETRICS; 38 metrics->cbSize = SIZEOF_NONCLIENTMETRICS;
39 const bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 39 const bool success = !!SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
40 SIZEOF_NONCLIENTMETRICS, metrics, 40 SIZEOF_NONCLIENTMETRICS, metrics,
41 0); 41 0);
42 DCHECK(success); 42 DCHECK(success);
43 } 43 }
44 44
45 bool GetUserSidString(std::wstring* user_sid) { 45 bool GetUserSidString(std::wstring* user_sid) {
46 // Get the current token. 46 // Get the current token.
47 HANDLE token = NULL; 47 HANDLE token = NULL;
48 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) 48 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token))
49 return false; 49 return false;
50 ScopedHandle token_scoped(token); 50 base::win::ScopedHandle token_scoped(token);
51 51
52 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; 52 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
53 scoped_array<BYTE> user_bytes(new BYTE[size]); 53 scoped_array<BYTE> user_bytes(new BYTE[size]);
54 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get()); 54 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get());
55 55
56 if (!::GetTokenInformation(token, TokenUser, user, size, &size)) 56 if (!::GetTokenInformation(token, TokenUser, user, size, &size))
57 return false; 57 return false;
58 58
59 if (!user->User.Sid) 59 if (!user->User.Sid)
60 return false; 60 return false;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 #ifndef COPY_FILE_COPY_SYMLINK 154 #ifndef COPY_FILE_COPY_SYMLINK
155 #error You must install the Windows 2008 or Vista Software Development Kit and \ 155 #error You must install the Windows 2008 or Vista Software Development Kit and \
156 set it as your default include path to build this library. You can grab it by \ 156 set it as your default include path to build this library. You can grab it by \
157 searching for "download windows sdk 2008" in your favorite web search engine. \ 157 searching for "download windows sdk 2008" in your favorite web search engine. \
158 Also make sure you register the SDK with Visual Studio, by selecting \ 158 Also make sure you register the SDK with Visual Studio, by selecting \
159 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ 159 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
160 menu (see Start - All Programs - Microsoft Windows SDK - \ 160 menu (see Start - All Programs - Microsoft Windows SDK - \
161 Visual Studio Registration). 161 Visual Studio Registration).
162 #endif 162 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698