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

Side by Side Diff: base/base_paths_win.cc

Issue 10910209: Add new PathService paths for Windows' All Users Desktop and Quick Launch folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to fix git cl upload Created 8 years, 3 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) 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 "base/base_paths_win.h"
6 5
7 #include <windows.h> 6 #include <windows.h>
8 #include <shlobj.h> 7 #include <shlobj.h>
9 8
9 #include "base/base_paths.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/win/scoped_co_mem.h" 13 #include "base/win/scoped_co_mem.h"
14 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
15 15
16 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx 16 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
17 extern "C" IMAGE_DOS_HEADER __ImageBase; 17 extern "C" IMAGE_DOS_HEADER __ImageBase;
18 18
19 namespace {
20
21 bool GetQuickLaunchPath(bool default_user, FilePath* result) {
22 if (default_user) {
23 wchar_t system_buffer[MAX_PATH];
24 system_buffer[0] = 0;
25 // As per MSDN (http://goo.gl/U8Wcp) passing -1 for |hToken| indicates the
26 // Default user.
27 if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA,
28 reinterpret_cast<HANDLE>(-1), SHGFP_TYPE_CURRENT,
29 system_buffer))) {
30 return false;
31 }
32 *result = FilePath(system_buffer);
33 } else if (!PathService::Get(base::DIR_APP_DATA, result)) {
34 // For the current user, grab the APPDATA directory directly from the
35 // PathService cache.
36 return false;
37 }
38 // According to various sources (http://goo.gl/3MFtg and http://goo.gl/GxLRL):
39 // appending "Microsoft\Internet Explorer\Quick Launch" to %appdata% is the
40 // only reliable way to get the quick launch folder across all versions of
41 // Windows.
42 *result = result->AppendASCII("Microsoft");
43 *result = result->AppendASCII("Internet Explorer");
44 *result = result->AppendASCII("Quick Launch");
45 return true;
46 }
47
48 } // namespace
49
19 namespace base { 50 namespace base {
20 51
21 bool PathProviderWin(int key, FilePath* result) { 52 bool PathProviderWin(int key, FilePath* result) {
22 53
23 // We need to go compute the value. It would be nice to support paths with 54 // We need to go compute the value. It would be nice to support paths with
24 // names longer than MAX_PATH, but the system functions don't seem to be 55 // names longer than MAX_PATH, but the system functions don't seem to be
25 // designed for it either, with the exception of GetTempPath (but other 56 // designed for it either, with the exception of GetTempPath (but other
26 // things will surely break if the temp path is too long, so we don't bother 57 // things will surely break if the temp path is too long, so we don't bother
27 // handling it. 58 // handling it.
28 wchar_t system_buffer[MAX_PATH]; 59 wchar_t system_buffer[MAX_PATH];
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 return false; 162 return false;
132 163
133 base::win::ScopedCoMem<wchar_t> path_buf; 164 base::win::ScopedCoMem<wchar_t> path_buf;
134 if (FAILED(SHGetKnownFolderPath(FOLDERID_ApplicationShortcuts, 0, NULL, 165 if (FAILED(SHGetKnownFolderPath(FOLDERID_ApplicationShortcuts, 0, NULL,
135 &path_buf))) 166 &path_buf)))
136 return false; 167 return false;
137 168
138 cur = FilePath(string16(path_buf)); 169 cur = FilePath(string16(path_buf));
139 break; 170 break;
140 } 171 }
172 case base::DIR_USER_DESKTOP: {
173 if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
174 SHGFP_TYPE_CURRENT, system_buffer))) {
175 return false;
176 }
177 cur = FilePath(system_buffer);
178 break;
179 }
180 case base::DIR_COMMON_DESKTOP: {
181 if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, NULL,
182 SHGFP_TYPE_CURRENT, system_buffer))) {
183 return false;
184 }
185 cur = FilePath(system_buffer);
186 break;
187 }
188 case base::DIR_USER_QUICK_LAUNCH: {
189 if (!GetQuickLaunchPath(false, &cur))
190 return false;
191 break;
192 }
193 case base::DIR_DEFAULT_USER_QUICK_LAUNCH: {
194 if (!GetQuickLaunchPath(true, &cur))
195 return false;
196 break;
197 }
141 default: 198 default:
142 return false; 199 return false;
143 } 200 }
144 201
145 *result = cur; 202 *result = cur;
146 return true; 203 return true;
147 } 204 }
148 205
149 } // namespace base 206 } // namespace base
OLDNEW
« base/base_paths_posix.h ('K') | « base/base_paths_win.h ('k') | base/path_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698