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

Side by Side Diff: base/win_util.cc

Issue 4222005: Turn on file access checks on Win. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Second try 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"
20 #include "base/win/windows_version.h" 21 #include "base/win/windows_version.h"
21 22
22 namespace win_util { 23 namespace win_util {
23 24
24 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ 25 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \
25 offsetof(struct_name, member) + \ 26 offsetof(struct_name, member) + \
26 (sizeof static_cast<struct_name*>(NULL)->member) 27 (sizeof static_cast<struct_name*>(NULL)->member)
27 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \ 28 #define NONCLIENTMETRICS_SIZE_PRE_VISTA \
28 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont) 29 SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(NONCLIENTMETRICS, lfMessageFont)
29 30
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 if (size_ret < (buffer_size - 1)) { 121 if (size_ret < (buffer_size - 1)) {
121 output.resize(size_ret); 122 output.resize(size_ret);
122 return output; 123 return output;
123 } 124 }
124 buffer_size *= 2; 125 buffer_size *= 2;
125 } 126 }
126 return std::wstring(); // error 127 return std::wstring(); // error
127 } 128 }
128 129
129 bool UserAccountControlIsEnabled() { 130 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
130 base::win::RegKey key(HKEY_LOCAL_MACHINE, 136 base::win::RegKey key(HKEY_LOCAL_MACHINE,
131 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 137 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",
132 KEY_READ); 138 KEY_READ);
133 DWORD uac_enabled; 139 DWORD uac_enabled;
134 if (!key.ReadValueDW(L"EnableLUA", &uac_enabled)) 140 if (!key.ReadValueDW(L"EnableLUA", &uac_enabled))
135 return true; 141 return true;
136 // Users can set the EnableLUA value to something arbitrary, like 2, which 142 // Users can set the EnableLUA value to something arbitrary, like 2, which
137 // Vista will treat as UAC enabled, so we make sure it is not set to 0. 143 // Vista will treat as UAC enabled, so we make sure it is not set to 0.
138 return (uac_enabled != 0); 144 return (uac_enabled != 0);
139 } 145 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 218
213 #ifndef COPY_FILE_COPY_SYMLINK 219 #ifndef COPY_FILE_COPY_SYMLINK
214 #error You must install the Windows 2008 or Vista Software Development Kit and \ 220 #error You must install the Windows 2008 or Vista Software Development Kit and \
215 set it as your default include path to build this library. You can grab it by \ 221 set it as your default include path to build this library. You can grab it by \
216 searching for "download windows sdk 2008" in your favorite web search engine. \ 222 searching for "download windows sdk 2008" in your favorite web search engine. \
217 Also make sure you register the SDK with Visual Studio, by selecting \ 223 Also make sure you register the SDK with Visual Studio, by selecting \
218 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \ 224 "Integrate Windows SDK with Visual Studio 2005" from the Windows SDK \
219 menu (see Start - All Programs - Microsoft Windows SDK - \ 225 menu (see Start - All Programs - Microsoft Windows SDK - \
220 Visual Studio Registration). 226 Visual Studio Registration).
221 #endif 227 #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