diff options
-rw-r--r-- | base/file_util_deprecated.h | 5 | ||||
-rw-r--r-- | chrome/installer/setup/setup_main.cc | 9 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.cc | 52 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.h | 6 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 18 |
5 files changed, 48 insertions, 42 deletions
diff --git a/base/file_util_deprecated.h b/base/file_util_deprecated.h index e0ebbe0..4b3238d 100644 --- a/base/file_util_deprecated.h +++ b/base/file_util_deprecated.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -36,7 +36,6 @@ BASE_EXPORT void AppendToPath(std::wstring* path, BASE_EXPORT std::wstring GetFileExtensionFromPath(const std::wstring& path); // Use version that takes a FilePath. -BASE_EXPORT bool Delete(const std::wstring& path, bool recursive); BASE_EXPORT bool CopyDirectory(const std::wstring& from_path, const std::wstring& to_path, bool recursive); @@ -44,7 +43,7 @@ BASE_EXPORT int ReadFile(const std::wstring& filename, char* data, int size); BASE_EXPORT int WriteFile(const std::wstring& filename, const char* data, int size); -} +} // namespace file_util #endif // OS_WIN diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc index c6d6b8a..cb4cf7d 100644 --- a/chrome/installer/setup/setup_main.cc +++ b/chrome/installer/setup/setup_main.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -756,12 +756,13 @@ installer::InstallStatus InstallProductsHelper( // rollback here and we schedule for deletion on reboot if the delete fails. // As such, we do not use DeleteTreeWorkItem. if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { - std::wstring prefs_path(cmd_line.GetSwitchValueNative( + FilePath prefs_path(cmd_line.GetSwitchValuePath( installer::switches::kInstallerData)); if (!file_util::Delete(prefs_path, true)) { - LOG(ERROR) << "Failed deleting master preferences file " << prefs_path + LOG(ERROR) << "Failed deleting master preferences file " + << prefs_path.value() << ", scheduling for deletion after reboot."; - ScheduleFileSystemEntityForDeletion(prefs_path.c_str()); + ScheduleFileSystemEntityForDeletion(prefs_path.value().c_str()); } } diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index cafe21e..6af90f6 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -12,11 +12,14 @@ #include <windows.h> #include <shlobj.h> +#include <list> + #include "base/command_line.h" #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" +#include "base/path_service.h" #include "base/stl_util.h" #include "base/string_number_conversions.h" #include "base/string_split.h" @@ -303,8 +306,6 @@ class RegistryEntry { } private: - DISALLOW_COPY_AND_ASSIGN(RegistryEntry); - // Create a object that represent default value of a key RegistryEntry(const std::wstring& key_path, const std::wstring& value) : _key_path(key_path), _name(), @@ -330,6 +331,8 @@ class RegistryEntry { bool _is_string; // true if current registry entry is of type REG_SZ std::wstring _value; // string value (useful if _is_string = true) DWORD _int_value; // integer value (useful if _is_string = false) + + DISALLOW_COPY_AND_ASSIGN(RegistryEntry); }; // class RegistryEntry @@ -622,10 +625,11 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, bool ret = true; // First create shortcut for the current user. if (shell_change & ShellUtil::CURRENT_USER) { - std::wstring user_ql_path; + FilePath user_ql_path; if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) { - file_util::AppendToPath(&user_ql_path, shortcut_name); - ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, user_ql_path, + user_ql_path = user_ql_path.Append(shortcut_name); + ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, + user_ql_path.value(), L"", L"", chrome_exe, dist->GetIconIndex(), create_new); @@ -637,10 +641,11 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, // Add a shortcut to Default User's profile so that all new user profiles // get it. if (shell_change & ShellUtil::SYSTEM_LEVEL) { - std::wstring default_ql_path; + FilePath default_ql_path; if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) { - file_util::AppendToPath(&default_ql_path, shortcut_name); - ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, default_ql_path, + default_ql_path = default_ql_path.Append(shortcut_name); + ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, + default_ql_path.value(), L"", L"", chrome_exe, dist->GetIconIndex(), create_new) && ret; @@ -689,11 +694,9 @@ bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { return true; } -bool ShellUtil::GetQuickLaunchPath(bool system_level, std::wstring* path) { - static const wchar_t* kQuickLaunchPath = - L"Microsoft\\Internet Explorer\\Quick Launch"; - wchar_t qlaunch[MAX_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); @@ -703,19 +706,21 @@ bool ShellUtil::GetQuickLaunchPath(bool system_level, std::wstring* path) { DWORD size = _countof(qlaunch); if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) return false; - *path = qlaunch; + *path = FilePath(qlaunch); if (base::win::GetVersion() >= base::win::VERSION_VISTA) { - file_util::AppendToPath(path, L"AppData\\Roaming"); + *path = path->AppendASCII("AppData"); + *path = path->AppendASCII("Roaming"); } else { - file_util::AppendToPath(path, L"Application Data"); + *path = path->AppendASCII("Application Data"); } } else { - if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, - SHGFP_TYPE_CURRENT, qlaunch))) + if (!PathService::Get(base::DIR_APP_DATA, path)) { return false; - *path = qlaunch; + } } - file_util::AppendToPath(path, kQuickLaunchPath); + *path = path->AppendASCII("Microsoft"); + *path = path->AppendASCII("Internet Explorer"); + *path = path->AppendASCII("Quick Launch"); return true; } @@ -767,7 +772,6 @@ bool ShellUtil::MakeChromeDefault(BrowserDistribution* dist, int shell_change, const std::wstring& chrome_exe, bool elevate_if_not_admin) { - if (!dist->CanSetAsDefault()) return false; @@ -1059,9 +1063,9 @@ bool ShellUtil::RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, bool ret = true; // First remove shortcut for the current user. if (shell_change & ShellUtil::CURRENT_USER) { - std::wstring user_ql_path; + FilePath user_ql_path; if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) { - file_util::AppendToPath(&user_ql_path, shortcut_name); + user_ql_path = user_ql_path.Append(shortcut_name); ret = file_util::Delete(user_ql_path, false); } else { ret = false; @@ -1070,9 +1074,9 @@ bool ShellUtil::RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist, // Delete shortcut in Default User's profile if (shell_change & ShellUtil::SYSTEM_LEVEL) { - std::wstring default_ql_path; + FilePath default_ql_path; if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) { - file_util::AppendToPath(&default_ql_path, shortcut_name); + default_ql_path = default_ql_path.Append(shortcut_name); ret = file_util::Delete(default_ql_path, false) && ret; } else { ret = false; diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index fb96771..31b2f8b 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -11,8 +11,10 @@ #pragma once #include <windows.h> + #include <map> #include <string> +#include <vector> #include "base/basictypes.h" #include "chrome/installer/util/work_item_list.h" @@ -164,7 +166,7 @@ class ShellUtil { // returns false. If system_level is true this function returns the path // to Default Users Quick Launch shortcuts path. Adding a shortcut to Default // User's profile only affects any new user profiles (not existing ones). - static bool GetQuickLaunchPath(bool system_level, std::wstring* path); + static bool GetQuickLaunchPath(bool system_level, FilePath* path); // Gets a mapping of all registered browser (on local machine) names and // their reinstall command (which usually sets browser as default). diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 3ce5824..7175eb8 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -192,10 +192,9 @@ base::ProcessHandle LaunchChrome(const std::wstring& url) { } base::ProcessHandle LaunchIEOnVista(const std::wstring& url) { - typedef HRESULT (WINAPI* IELaunchURLPtr)( - const wchar_t* url, - PROCESS_INFORMATION *pi, - VOID *info); + typedef HRESULT (WINAPI* IELaunchURLPtr)(const wchar_t* url, + PROCESS_INFORMATION* pi, + VOID* info); IELaunchURLPtr launch; PROCESS_INFORMATION pi = {0}; @@ -661,12 +660,13 @@ ScopedChromeFrameRegistrar::RegistrationType GetTestBedType() { } void ClearIESessionHistory() { - wchar_t local_app_data_path[MAX_PATH + 1] = {0}; - SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, - local_app_data_path); + FilePath session_history_path; + if (!PathService::Get(base::DIR_LOCAL_APP_DATA, &session_history_path)) + return; - std::wstring session_history_path = local_app_data_path; - session_history_path += L"\\Microsoft\\Internet Explorer\\Recovery"; + session_history_path = session_history_path.AppendASCII("Microsoft"); + session_history_path = session_history_path.AppendASCII("Internet Explorer"); + session_history_path = session_history_path.AppendASCII("Recovery"); file_util::Delete(session_history_path, true); } |