diff options
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/setup/setup.cc | 29 | ||||
-rw-r--r-- | chrome/installer/setup/uninstall.cc | 10 | ||||
-rw-r--r-- | chrome/installer/util/copy_tree_work_item_unittest.cc | 101 | ||||
-rw-r--r-- | chrome/installer/util/create_dir_work_item_unittest.cc | 14 | ||||
-rw-r--r-- | chrome/installer/util/delete_tree_work_item_unittest.cc | 12 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 13 | ||||
-rw-r--r-- | chrome/installer/util/helper.cc | 9 | ||||
-rw-r--r-- | chrome/installer/util/helper_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/installer/util/logging_installer.cc | 9 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item_unittest.cc | 49 | ||||
-rw-r--r-- | chrome/installer/util/work_item_list_unittest.cc | 10 |
11 files changed, 138 insertions, 128 deletions
diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc index ba40b6d..e2b5647 100644 --- a/chrome/installer/setup/setup.cc +++ b/chrome/installer/setup/setup.cc @@ -37,7 +37,6 @@ void AddChromeToMediaPlayerList() { // if the operation fails we log the error but still continue if (!work_item.get()->Do()) LOG(ERROR) << "Could not add Chrome to media player inclusion list."; - } void RegisterChromeOnMachine(std::wstring install_path, int options) { @@ -89,7 +88,7 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, const std::wstring& install_path, const std::wstring& new_version) { bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0; - std::wstring shortcut_path; + FilePath shortcut_path; int dir_enum = (system_install) ? base::DIR_COMMON_START_MENU : base::DIR_START_MENU; if (!PathService::Get(dir_enum, &shortcut_path)) { @@ -101,7 +100,7 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, BrowserDistribution* dist = BrowserDistribution::GetDistribution(); const std::wstring& product_name = dist->GetApplicationName(); const std::wstring& product_desc = dist->GetAppDescription(); - file_util::AppendToPath(&shortcut_path, product_name); + shortcut_path = shortcut_path.Append(product_name); // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link // (which points to setup.exe) under this folder only if: @@ -111,8 +110,8 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, // shortcuts since our install. So on updates we only update if shortcut // already exists) bool ret = true; - std::wstring chrome_link(shortcut_path); // Chrome link (launches Chrome) - file_util::AppendToPath(&chrome_link, product_name + L".lnk"); + FilePath chrome_link(shortcut_path); // Chrome link (launches Chrome) + chrome_link = chrome_link.Append(product_name + L".lnk"); std::wstring chrome_exe(install_path); // Chrome link target file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe); @@ -121,19 +120,22 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, if (!file_util::PathExists(shortcut_path)) file_util::CreateDirectoryW(shortcut_path); - LOG(INFO) << "Creating shortcut to " << chrome_exe << " at " << chrome_link; - ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link, + LOG(INFO) << "Creating shortcut to " << chrome_exe << " at " + << chrome_link.value(); + ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, + chrome_link.value(), product_desc, true); } else if (file_util::PathExists(chrome_link)) { - LOG(INFO) << "Updating shortcut at " << chrome_link + LOG(INFO) << "Updating shortcut at " << chrome_link.value() << " to point to " << chrome_exe; - ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, chrome_link, + ret = ret && ShellUtil::UpdateChromeShortcut(chrome_exe, + chrome_link.value(), product_desc, false); } // Create/update uninstall link - std::wstring uninstall_link(shortcut_path); // Uninstall Chrome link - file_util::AppendToPath(&uninstall_link, + FilePath uninstall_link(shortcut_path); // Uninstall Chrome link + uninstall_link = uninstall_link.Append( dist->GetUninstallLinkName() + L".lnk"); if ((install_status == installer_util::FIRST_INSTALL_SUCCESS) || (install_status == installer_util::INSTALL_REPAIRED) || @@ -151,9 +153,10 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path, arguments.append(installer_util::switches::kSystemLevel); } - LOG(INFO) << "Creating/updating uninstall link at " << uninstall_link; + LOG(INFO) << "Creating/updating uninstall link at " + << uninstall_link.value(); ret = ret && file_util::CreateShortcutLink(setup_exe.c_str(), - uninstall_link.c_str(), + uninstall_link.value().c_str(), NULL, arguments.c_str(), NULL, setup_exe.c_str(), 0); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 765561a..1203125 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -67,7 +67,7 @@ void CloseAllChromeProcesses() { // to remove the alternate desktop shortcut. Only one of them should be // present in a given install but at this point we don't know which one. void DeleteChromeShortcut(bool system_uninstall) { - std::wstring shortcut_path; + FilePath shortcut_path; if (system_uninstall) { PathService::Get(base::DIR_COMMON_START_MENU, &shortcut_path); if (!ShellUtil::RemoveChromeDesktopShortcut(ShellUtil::CURRENT_USER | @@ -88,10 +88,10 @@ void DeleteChromeShortcut(bool system_uninstall) { LOG(ERROR) << "Failed to get location for shortcut."; } else { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - file_util::AppendToPath(&shortcut_path, dist->GetApplicationName()); - LOG(INFO) << "Deleting shortcut " << shortcut_path; + shortcut_path = shortcut_path.Append(dist->GetApplicationName()); + LOG(INFO) << "Deleting shortcut " << shortcut_path.value(); if (!file_util::Delete(shortcut_path, true)) - LOG(ERROR) << "Failed to delete folder: " << shortcut_path; + LOG(ERROR) << "Failed to delete folder: " << shortcut_path.value(); } } @@ -235,7 +235,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome( // Since --force-uninstall command line option is used, we are going to // do silent uninstall. Try to close all running Chrome instances. CloseAllChromeProcesses(); - } else { // no --force-uninstall so lets show some UI dialog boxes. + } else { // no --force-uninstall so lets show some UI dialog boxes. status = IsChromeActiveOrUserCancelled(system_uninstall); if (status != installer_util::UNINSTALL_CONFIRMED && status != installer_util::UNINSTALL_DELETE_PROFILE) diff --git a/chrome/installer/util/copy_tree_work_item_unittest.cc b/chrome/installer/util/copy_tree_work_item_unittest.cc index 8b33e44..70ba378 100644 --- a/chrome/installer/util/copy_tree_work_item_unittest.cc +++ b/chrome/installer/util/copy_tree_work_item_unittest.cc @@ -25,16 +25,15 @@ namespace { virtual void SetUp() { // Name a subdirectory of the user temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"CopyTreeWorkItemTest"); + test_dir_ = test_dir_.AppendASCII("CopyTreeWorkItemTest"); // Create a fresh, empty copy of this test directory. file_util::Delete(test_dir_, true); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); // Create a tempory directory under the test directory. - temp_dir_.assign(test_dir_); - file_util::AppendToPath(&temp_dir_, L"temp"); - CreateDirectory(temp_dir_.c_str(), NULL); + temp_dir_ = test_dir_.AppendASCII("temp"); + file_util::CreateDirectoryW(temp_dir_); ASSERT_TRUE(file_util::PathExists(test_dir_)); ASSERT_TRUE(file_util::PathExists(temp_dir_)); @@ -48,8 +47,8 @@ namespace { } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; - std::wstring temp_dir_; + FilePath test_dir_; + FilePath temp_dir_; }; // Simple function to dump some text into a new file. @@ -93,13 +92,13 @@ namespace { // Copy one file from source to destination. TEST_F(CopyTreeWorkItemTest, CopyFile) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From.txt"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination path - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -110,7 +109,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) { // test Do() scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::ALWAYS)); + temp_dir_.ToWStringHack(), + WorkItem::ALWAYS)); EXPECT_TRUE(work_item->Do()); @@ -130,13 +130,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFile) { // regardless since the content at destination file is different from source. TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From.txt"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -149,7 +149,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::ALWAYS)); + temp_dir_.ToWStringHack(), + WorkItem::ALWAYS)); EXPECT_TRUE(work_item->Do()); @@ -170,7 +171,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // the file is still overwritten since the content is different. work_item.reset( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_DIFFERENT)); + temp_dir_.ToWStringHack(), + WorkItem::IF_DIFFERENT)); EXPECT_TRUE(work_item->Do()); @@ -194,13 +196,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFileOverwrite) { // If always_overwrite being false, the file is unchanged. TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From.txt"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -211,13 +213,14 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To.txt"); // test Do() with always_overwrite being true. scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::ALWAYS)); + temp_dir_.ToWStringHack(), + WorkItem::ALWAYS)); EXPECT_TRUE(work_item->Do()); @@ -243,7 +246,8 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // test Do() with always_overwrite being false. nothing should change. work_item.reset( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_DIFFERENT)); + temp_dir_.ToWStringHack(), + WorkItem::IF_DIFFERENT)); EXPECT_TRUE(work_item->Do()); @@ -268,13 +272,13 @@ TEST_F(CopyTreeWorkItemTest, CopyFileSameContent) { // Copy one file and without rollback. Verify all temporary files are deleted. TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From.txt"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); // Create destination file - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -285,14 +289,15 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To.txt"); { // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_DIFFERENT)); + temp_dir_.ToWStringHack(), + WorkItem::IF_DIFFERENT)); EXPECT_TRUE(work_item->Do()); @@ -314,7 +319,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileAndCleanup) { // be moved to backup location after Do() and moved back after Rollback(). TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); @@ -324,7 +329,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); std::wstring exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -345,13 +350,14 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_DIFFERENT)); + temp_dir_.ToWStringHack(), + WorkItem::IF_DIFFERENT)); EXPECT_TRUE(work_item->Do()); @@ -388,7 +394,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUse) { // destination folder after Do() and should be rolled back after Rollback(). TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); @@ -398,7 +404,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); std::wstring exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -420,13 +426,14 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::NEW_NAME_IF_IN_USE, + temp_dir_.ToWStringHack(), + WorkItem::NEW_NAME_IF_IN_USE, alternate_to)); EXPECT_TRUE(work_item->Do()); @@ -457,8 +464,8 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { CloseHandle(pi.hThread); // Now the process has terminated, lets try overwriting the file again - work_item.reset(WorkItem::CreateCopyTreeWorkItem( - file_name_from, file_name_to, temp_dir_, WorkItem::NEW_NAME_IF_IN_USE, + work_item.reset(WorkItem::CreateCopyTreeWorkItem(file_name_from, + file_name_to, temp_dir_.ToWStringHack(), WorkItem::NEW_NAME_IF_IN_USE, alternate_to)); if (IsFileInUse(file_name_to)) PlatformThread::Sleep(2000); @@ -493,7 +500,7 @@ TEST_F(CopyTreeWorkItemTest, NewNameAndCopyTest) { // Rollback(). TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); @@ -502,7 +509,7 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { wchar_t exe_full_path_str[MAX_PATH]; ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); std::wstring exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -512,14 +519,13 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { ASSERT_TRUE(file_util::PathExists(file_name_to)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To"); // test Do(). scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_NOT_PRESENT, - L"")); + temp_dir_.ToWStringHack(), WorkItem::IF_NOT_PRESENT, L"")); EXPECT_TRUE(work_item->Do()); // verify that the source, destination have not changed and backup path @@ -544,7 +550,8 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // Now delete the destination and try copying the file again. file_util::Delete(file_name_to, true); work_item.reset(WorkItem::CreateCopyTreeWorkItem( - file_name_from, file_name_to, temp_dir_, WorkItem::IF_NOT_PRESENT, L"")); + file_name_from, file_name_to, temp_dir_.ToWStringHack(), + WorkItem::IF_NOT_PRESENT, L"")); EXPECT_TRUE(work_item->Do()); // verify that the source, destination are the same and backup path @@ -569,7 +576,7 @@ TEST_F(CopyTreeWorkItemTest, IfNotPresentTest) { // Verify it is moved to backup location and stays there. TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { // Create source file - std::wstring file_name_from(test_dir_); + std::wstring file_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&file_name_from, L"File_From"); CreateTextFile(file_name_from, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from)); @@ -579,7 +586,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { ::GetModuleFileName(NULL, exe_full_path_str, MAX_PATH); std::wstring exe_full_path(exe_full_path_str); - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"Copy_To_Subdir"); CreateDirectory(dir_name_to.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_to)); @@ -600,14 +607,15 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { NULL, NULL, &si, &pi)); // Get the path of backup file - std::wstring backup_file(temp_dir_); + std::wstring backup_file(temp_dir_.ToWStringHack()); file_util::AppendToPath(&backup_file, L"File_To"); // test Do(). { scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(file_name_from, file_name_to, - temp_dir_, WorkItem::IF_DIFFERENT)); + temp_dir_.ToWStringHack(), + WorkItem::IF_DIFFERENT)); EXPECT_TRUE(work_item->Do()); @@ -634,7 +642,7 @@ TEST_F(CopyTreeWorkItemTest, CopyFileInUseAndCleanup) { // Copy a tree from source to destination. TEST_F(CopyTreeWorkItemTest, CopyTree) { // Create source tree - std::wstring dir_name_from(test_dir_); + std::wstring dir_name_from(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_from, L"from"); CreateDirectory(dir_name_from.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_from)); @@ -659,14 +667,15 @@ TEST_F(CopyTreeWorkItemTest, CopyTree) { CreateTextFile(file_name_from_2, text_content_1); ASSERT_TRUE(file_util::PathExists(file_name_from_2)); - std::wstring dir_name_to(test_dir_); + std::wstring dir_name_to(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_to, L"to"); // test Do() { scoped_ptr<CopyTreeWorkItem> work_item( WorkItem::CreateCopyTreeWorkItem(dir_name_from, dir_name_to, - temp_dir_, WorkItem::ALWAYS)); + temp_dir_.ToWStringHack(), + WorkItem::ALWAYS)); EXPECT_TRUE(work_item->Do()); } diff --git a/chrome/installer/util/create_dir_work_item_unittest.cc b/chrome/installer/util/create_dir_work_item_unittest.cc index e179afc..2588966 100644 --- a/chrome/installer/util/create_dir_work_item_unittest.cc +++ b/chrome/installer/util/create_dir_work_item_unittest.cc @@ -19,11 +19,11 @@ namespace { virtual void SetUp() { // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"CreateDirWorkItemTest"); + test_dir_ = test_dir_.AppendASCII("CreateDirWorkItemTest"); // Create a fresh, empty copy of this directory. file_util::Delete(test_dir_, true); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); } virtual void TearDown() { // Clean up test directory @@ -32,12 +32,12 @@ namespace { } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; + FilePath test_dir_; }; }; TEST_F(CreateDirWorkItemTest, CreatePath) { - std::wstring parent_dir(test_dir_); + std::wstring parent_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&parent_dir, L"a"); CreateDirectory(parent_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(parent_dir)); @@ -64,7 +64,7 @@ TEST_F(CreateDirWorkItemTest, CreatePath) { } TEST_F(CreateDirWorkItemTest, CreateExistingPath) { - std::wstring dir_to_create(test_dir_); + std::wstring dir_to_create(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_to_create, L"aa"); CreateDirectory(dir_to_create.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_to_create)); @@ -84,7 +84,7 @@ TEST_F(CreateDirWorkItemTest, CreateExistingPath) { } TEST_F(CreateDirWorkItemTest, CreateSharedPath) { - std::wstring dir_to_create_1(test_dir_); + std::wstring dir_to_create_1(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_to_create_1, L"aaa"); std::wstring dir_to_create_2(dir_to_create_1); @@ -117,7 +117,7 @@ TEST_F(CreateDirWorkItemTest, CreateSharedPath) { } TEST_F(CreateDirWorkItemTest, RollbackWithMissingDir) { - std::wstring dir_to_create_1(test_dir_); + std::wstring dir_to_create_1(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_to_create_1, L"aaaa"); std::wstring dir_to_create_2(dir_to_create_1); diff --git a/chrome/installer/util/delete_tree_work_item_unittest.cc b/chrome/installer/util/delete_tree_work_item_unittest.cc index ec11a2e..4eea87d 100644 --- a/chrome/installer/util/delete_tree_work_item_unittest.cc +++ b/chrome/installer/util/delete_tree_work_item_unittest.cc @@ -24,11 +24,11 @@ namespace { virtual void SetUp() { // Name a subdirectory of the user temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"DeleteTreeWorkItemTest"); + test_dir_ = test_dir_.AppendASCII("DeleteTreeWorkItemTest"); // Create a fresh, empty copy of this test directory. file_util::Delete(test_dir_, true); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); ASSERT_TRUE(file_util::PathExists(test_dir_)); } @@ -40,7 +40,7 @@ namespace { } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; + FilePath test_dir_; }; // Simple function to dump some text into a new file. @@ -60,7 +60,7 @@ namespace { // Delete a tree without key path. Everything should be deleted. TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_); + std::wstring dir_name_delete(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); CreateDirectory(dir_name_delete.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); @@ -107,7 +107,7 @@ TEST_F(DeleteTreeWorkItemTest, DeleteTreeNoKeyPath) { // Rollback should bring back everything TEST_F(DeleteTreeWorkItemTest, DeleteTree) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_); + std::wstring dir_name_delete(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); CreateDirectory(dir_name_delete.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); @@ -152,7 +152,7 @@ TEST_F(DeleteTreeWorkItemTest, DeleteTree) { // Delete a tree with key_path in use. Everything should still be there. TEST_F(DeleteTreeWorkItemTest, DeleteTreeInUse) { // Create tree to be deleted - std::wstring dir_name_delete(test_dir_); + std::wstring dir_name_delete(test_dir_.ToWStringHack()); file_util::AppendToPath(&dir_name_delete, L"to_be_delete"); CreateDirectory(dir_name_delete.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(dir_name_delete)); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index f1b31b4..e3f1088 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -12,9 +12,9 @@ #include <msi.h> #include "base/file_path.h" -#include "base/file_util.h" #include "base/path_service.h" #include "base/registry.h" +#include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/wmi_util.h" #include "chrome/common/json_value_serializer.h" @@ -128,15 +128,16 @@ void GoogleChromeDistribution::DoPostUninstallOperations( version_info.dwBuildNumber); } - std::wstring iexplore; + FilePath iexplore; if (!PathService::Get(base::DIR_PROGRAM_FILES, &iexplore)) return; - file_util::AppendToPath(&iexplore, L"Internet Explorer"); - file_util::AppendToPath(&iexplore, L"iexplore.exe"); + iexplore = iexplore.AppendASCII("Internet Explorer"); + iexplore = iexplore.AppendASCII("iexplore.exe"); - std::wstring command = iexplore + L" " + GetUninstallSurveyUrl() + L"&" + - kVersionParam + L"=" + kVersion + L"&" + kOSParam + L"=" + os_version; + std::wstring command = iexplore.value() + L" " + GetUninstallSurveyUrl() + + L"&" + kVersionParam + L"=" + kVersion + L"&" + kOSParam + L"=" + + os_version; std::wstring uninstall_metrics; if (ExtractUninstallMetricsFromFile(local_data_path, &uninstall_metrics)) { diff --git a/chrome/installer/util/helper.cc b/chrome/installer/util/helper.cc index 51d095c..cfd6a32 100644 --- a/chrome/installer/util/helper.cc +++ b/chrome/installer/util/helper.cc @@ -17,7 +17,7 @@ #include "chrome/installer/util/work_item_list.h" std::wstring installer::GetChromeInstallPath(bool system_install) { - std::wstring install_path; + FilePath install_path; if (system_install) { PathService::Get(base::DIR_PROGRAM_FILES, &install_path); } else { @@ -26,12 +26,11 @@ std::wstring installer::GetChromeInstallPath(bool system_install) { if (!install_path.empty()) { BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - file_util::AppendToPath(&install_path, dist->GetInstallSubDir()); - file_util::AppendToPath(&install_path, - std::wstring(installer_util::kInstallBinaryDir)); + install_path = install_path.Append(dist->GetInstallSubDir()); + install_path = install_path.Append(installer_util::kInstallBinaryDir); } - return install_path; + return install_path.ToWStringHack(); } bool installer::LaunchChrome(bool system_install) { diff --git a/chrome/installer/util/helper_unittest.cc b/chrome/installer/util/helper_unittest.cc index 3152bc1..9430f25 100644 --- a/chrome/installer/util/helper_unittest.cc +++ b/chrome/installer/util/helper_unittest.cc @@ -22,11 +22,11 @@ namespace { virtual void SetUp() { // Name a subdirectory of the user temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"SetupHelperTest"); + test_dir_.AppendASCII("SetupHelperTest"); // Create a fresh, empty copy of this test directory. file_util::Delete(test_dir_, true); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); ASSERT_TRUE(file_util::PathExists(test_dir_)); } @@ -38,7 +38,7 @@ namespace { } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; + FilePath test_dir_; }; // Simple function to dump some text into a new file. @@ -59,7 +59,7 @@ namespace { // should be deleted. TEST_F(SetupHelperTest, Delete) { // Create a Chrome dir - std::wstring chrome_dir(test_dir_); + std::wstring chrome_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&chrome_dir, L"chrome"); CreateDirectory(chrome_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir)); @@ -118,7 +118,7 @@ TEST_F(SetupHelperTest, Delete) { // Delete older version directories, keeping the one in used intact. TEST_F(SetupHelperTest, DeleteInUsed) { // Create a Chrome dir - std::wstring chrome_dir(test_dir_); + std::wstring chrome_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&chrome_dir, L"chrome"); CreateDirectory(chrome_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(chrome_dir)); diff --git a/chrome/installer/util/logging_installer.cc b/chrome/installer/util/logging_installer.cc index 953535c..25dceb2 100644 --- a/chrome/installer/util/logging_installer.cc +++ b/chrome/installer/util/logging_installer.cc @@ -7,7 +7,7 @@ #include "chrome/installer/util/logging_installer.h" #include "base/command_line.h" -#include "base/file_util.h" +#include "base/file_path.h" #include "base/logging.h" #include "base/path_service.h" #include "chrome/installer/util/util_constants.h" @@ -19,7 +19,6 @@ namespace installer { bool installer_logging_ = false; void InitInstallerLogging(const CommandLine& command_line) { - if (installer_logging_) return; @@ -54,11 +53,11 @@ std::wstring GetLogFilePath(const CommandLine& command_line) { } const std::wstring log_filename(L"chrome_installer.log"); - std::wstring log_path; + FilePath log_path; if (PathService::Get(base::DIR_TEMP, &log_path)) { - file_util::AppendToPath(&log_path, log_filename); - return log_path; + log_path = log_path.Append(log_filename); + return log_path.ToWStringHack(); } else { return log_filename; } diff --git a/chrome/installer/util/move_tree_work_item_unittest.cc b/chrome/installer/util/move_tree_work_item_unittest.cc index 39f823e..abf6160 100644 --- a/chrome/installer/util/move_tree_work_item_unittest.cc +++ b/chrome/installer/util/move_tree_work_item_unittest.cc @@ -23,16 +23,15 @@ namespace { virtual void SetUp() { // Name a subdirectory of the user temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"MoveTreeWorkItemTest"); + test_dir_ = test_dir_.AppendASCII("MoveTreeWorkItemTest"); // Create a fresh, empty copy of this test directory. file_util::Delete(test_dir_, true); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); // Create a tempory directory under the test directory. - temp_dir_.assign(test_dir_); - file_util::AppendToPath(&temp_dir_, L"temp"); - CreateDirectory(temp_dir_.c_str(), NULL); + temp_dir_ = test_dir_.AppendASCII("temp"); + file_util::CreateDirectoryW(temp_dir_); ASSERT_TRUE(file_util::PathExists(test_dir_)); ASSERT_TRUE(file_util::PathExists(temp_dir_)); @@ -45,8 +44,8 @@ namespace { } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; - std::wstring temp_dir_; + FilePath test_dir_; + FilePath temp_dir_; }; // Simple function to dump some text into a new file. @@ -78,7 +77,7 @@ namespace { // exist. TEST_F(MoveTreeWorkItemTest, MoveDirectory) { // Create two level deep source dir - std::wstring from_dir1(test_dir_); + std::wstring from_dir1(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir1, L"From_Dir1"); CreateDirectory(from_dir1.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir1)); @@ -94,7 +93,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectory) { ASSERT_TRUE(file_util::PathExists(from_file)); // Generate destination path - std::wstring to_dir(test_dir_); + std::wstring to_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_dir, L"To_Dir"); ASSERT_FALSE(file_util::PathExists(to_dir)); @@ -105,7 +104,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectory) { // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1, to_dir, temp_dir_)); + from_dir1, to_dir, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -124,7 +123,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectory) { // exists. TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { // Create two level deep source dir - std::wstring from_dir1(test_dir_); + std::wstring from_dir1(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir1, L"From_Dir1"); CreateDirectory(from_dir1.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir1)); @@ -140,7 +139,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { ASSERT_TRUE(file_util::PathExists(from_file)); // Create destination path - std::wstring to_dir(test_dir_); + std::wstring to_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_dir, L"To_Dir"); CreateDirectory(to_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); @@ -157,7 +156,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1, to_dir, temp_dir_)); + from_dir1, to_dir, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -180,7 +179,7 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { // exist. TEST_F(MoveTreeWorkItemTest, MoveAFile) { // Create a file inside source dir - std::wstring from_dir(test_dir_); + std::wstring from_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir, L"From_Dir"); CreateDirectory(from_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); @@ -191,13 +190,13 @@ TEST_F(MoveTreeWorkItemTest, MoveAFile) { ASSERT_TRUE(file_util::PathExists(from_file)); // Generate destination file name - std::wstring to_file(test_dir_); + std::wstring to_file(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_file, L"To_File"); ASSERT_FALSE(file_util::PathExists(to_file)); // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_)); + from_file, to_file, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); @@ -218,7 +217,7 @@ TEST_F(MoveTreeWorkItemTest, MoveAFile) { // exists. TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { // Create a file inside source dir - std::wstring from_dir(test_dir_); + std::wstring from_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir, L"From_Dir"); CreateDirectory(from_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); @@ -229,7 +228,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { ASSERT_TRUE(file_util::PathExists(from_file)); // Create destination path - std::wstring to_dir(test_dir_); + std::wstring to_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_dir, L"To_Dir"); CreateDirectory(to_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); @@ -241,7 +240,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_dir, temp_dir_)); + from_file, to_dir, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); @@ -263,7 +262,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { // exists and is in use. TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { // Create a file inside source dir - std::wstring from_dir(test_dir_); + std::wstring from_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir, L"From_Dir"); CreateDirectory(from_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); @@ -274,7 +273,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { ASSERT_TRUE(file_util::PathExists(from_file)); // Create an executable in destination path by copying ourself to it. - std::wstring to_dir(test_dir_); + std::wstring to_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_dir, L"To_Dir"); CreateDirectory(to_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); @@ -297,7 +296,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_)); + from_file, to_file, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); @@ -322,7 +321,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { // Move one file that is in use to destination. TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { // Create an executable for source by copying ourself to a new source dir. - std::wstring from_dir(test_dir_); + std::wstring from_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&from_dir, L"From_Dir"); CreateDirectory(from_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(from_dir)); @@ -336,7 +335,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { ASSERT_TRUE(file_util::PathExists(from_file)); // Create a destination source dir and generate destination file name. - std::wstring to_dir(test_dir_); + std::wstring to_dir(test_dir_.ToWStringHack()); file_util::AppendToPath(&to_dir, L"To_Dir"); CreateDirectory(to_dir.c_str(), NULL); ASSERT_TRUE(file_util::PathExists(to_dir)); @@ -356,7 +355,7 @@ TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { // test Do() scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file, to_file, temp_dir_)); + from_file, to_file, temp_dir_.ToWStringHack())); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); diff --git a/chrome/installer/util/work_item_list_unittest.cc b/chrome/installer/util/work_item_list_unittest.cc index c96477c..cf8bfd2 100644 --- a/chrome/installer/util/work_item_list_unittest.cc +++ b/chrome/installer/util/work_item_list_unittest.cc @@ -29,10 +29,10 @@ namespace { // Create a temp directory for test. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); - file_util::AppendToPath(&test_dir_, L"WorkItemListTest"); + test_dir_ = test_dir_.AppendASCII("WorkItemListTest"); file_util::Delete(test_dir_, true); ASSERT_FALSE(file_util::PathExists(test_dir_)); - CreateDirectory(test_dir_.c_str(), NULL); + file_util::CreateDirectoryW(test_dir_); ASSERT_TRUE(file_util::PathExists(test_dir_)); } @@ -46,7 +46,7 @@ namespace { ASSERT_TRUE(key.DeleteKey(test_root)); } - std::wstring test_dir_; + FilePath test_dir_; }; }; @@ -55,7 +55,7 @@ TEST_F(WorkItemListTest, ExecutionSuccess) { scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); scoped_ptr<WorkItem> work_item; - std::wstring top_dir_to_create(test_dir_); + std::wstring top_dir_to_create(test_dir_.ToWStringHack()); file_util::AppendToPath(&top_dir_to_create, L"a"); std::wstring dir_to_create(top_dir_to_create); file_util::AppendToPath(&dir_to_create, L"b"); @@ -104,7 +104,7 @@ TEST_F(WorkItemListTest, ExecutionFailAndRollback) { scoped_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList()); scoped_ptr<WorkItem> work_item; - std::wstring top_dir_to_create(test_dir_); + std::wstring top_dir_to_create(test_dir_.ToWStringHack()); file_util::AppendToPath(&top_dir_to_create, L"a"); std::wstring dir_to_create(top_dir_to_create); file_util::AppendToPath(&dir_to_create, L"b"); |