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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: base/base_paths_win.cc
diff --git a/base/base_paths_win.cc b/base/base_paths_win.cc
index 48238a4ffc2aff1c3554953d494568d7b1010b50..ae954aae3814caa3e023465706483ec8284aff01 100644
--- a/base/base_paths_win.cc
+++ b/base/base_paths_win.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/base_paths_win.h"
#include <windows.h>
#include <shlobj.h>
+#include "base/base_paths.h"
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
@@ -16,6 +16,37 @@
// http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx
extern "C" IMAGE_DOS_HEADER __ImageBase;
+namespace {
+
+bool GetQuickLaunchPath(bool default_user, FilePath* result) {
+ if (default_user) {
+ wchar_t system_buffer[MAX_PATH];
+ system_buffer[0] = 0;
+ // As per MSDN (http://goo.gl/U8Wcp) passing -1 for |hToken| indicates the
+ // Default user.
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA,
+ reinterpret_cast<HANDLE>(-1), SHGFP_TYPE_CURRENT,
+ system_buffer))) {
+ return false;
+ }
+ *result = FilePath(system_buffer);
+ } else if (!PathService::Get(base::DIR_APP_DATA, result)) {
+ // For the current user, grab the APPDATA directory directly from the
+ // PathService cache.
+ return false;
+ }
+ // According to various sources (http://goo.gl/3MFtg and http://goo.gl/GxLRL):
+ // appending "Microsoft\Internet Explorer\Quick Launch" to %appdata% is the
+ // only reliable way to get the quick launch folder across all versions of
+ // Windows.
+ *result = result->AppendASCII("Microsoft");
+ *result = result->AppendASCII("Internet Explorer");
+ *result = result->AppendASCII("Quick Launch");
+ return true;
+}
+
+} // namespace
+
namespace base {
bool PathProviderWin(int key, FilePath* result) {
@@ -138,6 +169,32 @@ bool PathProviderWin(int key, FilePath* result) {
cur = FilePath(string16(path_buf));
break;
}
+ case base::DIR_USER_DESKTOP: {
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_DESKTOPDIRECTORY, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer))) {
+ return false;
+ }
+ cur = FilePath(system_buffer);
+ break;
+ }
+ case base::DIR_COMMON_DESKTOP: {
+ if (FAILED(SHGetFolderPath(NULL, CSIDL_COMMON_DESKTOPDIRECTORY, NULL,
+ SHGFP_TYPE_CURRENT, system_buffer))) {
+ return false;
+ }
+ cur = FilePath(system_buffer);
+ break;
+ }
+ case base::DIR_USER_QUICK_LAUNCH: {
+ if (!GetQuickLaunchPath(false, &cur))
+ return false;
+ break;
+ }
+ case base::DIR_DEFAULT_USER_QUICK_LAUNCH: {
+ if (!GetQuickLaunchPath(true, &cur))
+ return false;
+ break;
+ }
default:
return false;
}
« 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