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

Side by Side Diff: base/win_util.cc

Issue 4431001: Revert 64960 - Turn on file access checks on Win.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | « base/win/registry.cc ('k') | chrome/browser/browser.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_util.h" 5 #include "base/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" 16 #include "base/scoped_handle.h"
17 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/stringprintf.h" 19 #include "base/stringprintf.h"
20 #include "base/thread_restrictions.h"
21 #include "base/win/windows_version.h" 20 #include "base/win/windows_version.h"
22 21
23 namespace win_util { 22 namespace win_util {
24 23
25 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ 24 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
26 offsetof(struct_name, member) + \ 25 offsetof(struct_name, member) + \
27 (sizeof static_cast<struct_name*>(NULL)->member) 26 (sizeof static_cast<struct_name*>(NULL)->member)
28 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ 27 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \
29 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) 28 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
30 29
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (size_ret < (buffer_size - 1)) { 120 if (size_ret < (buffer_size - 1)) {
122 output.resize(size_ret); 121 output.resize(size_ret);
123 return output; 122 return output;
124 } 123 }
125 buffer_size *= 2; 124 buffer_size *= 2;
126 } 125 }
127 return std::wstring(); // error 126 return std::wstring(); // error
128 } 127 }
129 128
130 bool UserAccountControlIsEnabled() { 129 bool UserAccountControlIsEnabled() {
131 // This can be slow if Windows ends up going to disk. Should watch this key
132 // for changes and only read it once, preferably on the file thread.
133 // http://code.google.com/p/chromium/issues/detail?id=61644
134 base::ThreadRestrictions::ScopedAllowIO allow_io;
135
136 base::win::RegKey key(HKEY_LOCAL_MACHINE, 130 base::win::RegKey key(HKEY_LOCAL_MACHINE,
137 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 131 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
138 KEY_READ); 132 KEY_READ);
139 DWORD uac_enabled; 133 DWORD uac_enabled;
140 if (!key.ReadValueDW(L"EnableLUA", &uac_enabled)) 134 if (!key.ReadValueDW(L"EnableLUA", &uac_enabled))
141 return true; 135 return true;
142 // Users can set the EnableLUA value to something arbitrary, like 2, which 136 // Users can set the EnableLUA value to something arbitrary, like 2, which
143 // Vista will treat as UAC enabled, so we make sure it is not set to 0. 137 // Vista will treat as UAC enabled, so we make sure it is not set to 0.
144 return (uac_enabled != 0); 138 return (uac_enabled != 0);
145 } 139 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 212
219 #ifndef COPY_FILE_COPY_SYMLINK 213 #ifndef COPY_FILE_COPY_SYMLINK
220 #error You must install the Windows 2008 or Vista Software Development Kit and \ 214 #error You must install the Windows 2008 or Vista Software Development Kit and \
221 set it as your default include path to build this library. You can grab it by \ 215 set it as your default include path to build this library. You can grab it by \
222 searching for "download windows sdk 2008" in your favorite web search engine. \ 216 searching for "download windows sdk 2008" in your favorite web search engine. \
223 Also make sure you register the SDK with Visual Studio, by selecting \ 217 Also make sure you register the SDK with Visual Studio, by selecting \
224 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ 218 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
225 menu (see Start - All Programs - Microsoft Windows SDK - \ 219 menu (see Start - All Programs - Microsoft Windows SDK - \
226 Visual Studio Registration). 220 Visual Studio Registration).
227 #endif 221 #endif
OLDNEW
« no previous file with comments | « base/win/registry.cc ('k') | chrome/browser/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698