diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-20 16:24:52 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-20 16:24:52 +0000 |
commit | dea1d7d21976d078a41b2d321e8d626379c7a1fd (patch) | |
tree | 02587faedfbf8242cc8b557874d3c37a435739de /chrome/installer/util/shell_util.cc | |
parent | 6c2e391ce50adde6f5080245b1256838656063d3 (diff) | |
download | chromium_src-dea1d7d21976d078a41b2d321e8d626379c7a1fd.zip chromium_src-dea1d7d21976d078a41b2d321e8d626379c7a1fd.tar.gz chromium_src-dea1d7d21976d078a41b2d321e8d626379c7a1fd.tar.bz2 |
Add new PathService paths for Windows' All Users Desktop and Quick Launch folders.
Re-commit, reverted in http://crrev.com/157680 (original commit in http://crrev.com/157667).
This allows usage of PathService to cache the shortcut install paths and more importantly to mock them in shortcut tests!
Also move chrome::DIR_USER_DESKTOP to base::DIR_USER_DESKTOP; this is really where it belongs. In fact it is only in chrome_paths.h because it used to be called DIR_DEFAULT_DOWNLOAD and cpu@ renamed it to DIR_USER_DESKTOP in http://crrev.com/1753 (early days!) after that it started to be used all over the place as the Desktop path. Finally bringing it to base_paths.h, beside DIR_START_MENU and friends, is the right thing to do imo.
TBR=brettw@chromium.org
BUG=148539
TEST=Quick Launch shortcut installed in the right place on XP (both Default and current user)
Desktop shortcuts installed in the right place (both All Users and per-user installs).
installer_util_unittests.exe --gtest_filter=ShellUtilShortcutTest*
unit_tests.exe --gtest_filter=ProfileShortcutManagerTest*
base_unittests --gtest_filter=PathServiceTest*
Review URL: https://chromiumcodereview.appspot.com/10964007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157779 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/util/shell_util.cc')
-rw-r--r-- | chrome/installer/util/shell_util.cc | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index f6e696c..3e2d19a 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -1098,43 +1098,15 @@ bool ShellUtil::GetChromeShortcutName(BrowserDistribution* dist, } bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { - wchar_t desktop[MAX_PATH]; - int dir = system_level ? CSIDL_COMMON_DESKTOPDIRECTORY : - CSIDL_DESKTOPDIRECTORY; - if (FAILED(SHGetFolderPath(NULL, dir, NULL, SHGFP_TYPE_CURRENT, desktop))) - return false; - *path = FilePath(desktop); - return true; + int dir_key = system_level ? base::DIR_COMMON_DESKTOP : + base::DIR_USER_DESKTOP; + return PathService::Get(dir_key, path); } bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { - if (system_level) { - wchar_t qlaunch[MAX_PATH]; - // We are accessing GetDefaultUserProfileDirectory this way so that we do - // not have to declare dependency to Userenv.lib for chrome.exe - typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD); - HMODULE module = LoadLibrary(L"Userenv.dll"); - PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module, - "GetDefaultUserProfileDirectoryW")); - DWORD size = _countof(qlaunch); - if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) - return false; - *path = FilePath(qlaunch); - if (base::win::GetVersion() >= base::win::VERSION_VISTA) { - *path = path->AppendASCII("AppData"); - *path = path->AppendASCII("Roaming"); - } else { - *path = path->AppendASCII("Application Data"); - } - } else { - if (!PathService::Get(base::DIR_APP_DATA, path)) { - return false; - } - } - *path = path->AppendASCII("Microsoft"); - *path = path->AppendASCII("Internet Explorer"); - *path = path->AppendASCII("Quick Launch"); - return true; + int dir_key = system_level ? base::DIR_DEFAULT_USER_QUICK_LAUNCH : + base::DIR_USER_QUICK_LAUNCH; + return PathService::Get(dir_key, path); } void ShellUtil::GetRegisteredBrowsers( |