diff options
author | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 16:07:55 +0000 |
---|---|---|
committer | erikkay@chromium.org <erikkay@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 16:07:55 +0000 |
commit | 33edeab42b851a5617a77caa1d65a3782a01ee7b (patch) | |
tree | d1baa44ff796c9f0c4881e9819e7e5b359489b1d /chrome/installer | |
parent | f348b92e95dd67fef3a9a6109bc0465fb4078d6b (diff) | |
download | chromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.zip chromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.tar.gz chromium_src-33edeab42b851a5617a77caa1d65a3782a01ee7b.tar.bz2 |
Renames the function CreateTemporaryFilename to CreateTemporaryFile and track down all callers, also removes the
deprecated function that uses std::wstring.
BUG=3078 (http://crbug.com/3078)
TEST=run base_unittests, installer_util_unittests, net_unittests, setup_unittests, and unit_tests.
Review URL: http://codereview.chromium.org/164537
Patch from Thiago Farina.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23631 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/setup/setup_util_unittest.cc | 7 | ||||
-rw-r--r-- | chrome/installer/setup/uninstall.cc | 23 | ||||
-rw-r--r-- | chrome/installer/util/master_preferences_unittest.cc | 21 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item.cc | 10 |
4 files changed, 34 insertions, 27 deletions
diff --git a/chrome/installer/setup/setup_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc index 6223f37..39003bc 100644 --- a/chrome/installer/setup/setup_util_unittest.cc +++ b/chrome/installer/setup/setup_util_unittest.cc @@ -66,8 +66,8 @@ TEST_F(SetupUtilTest, ApplyDiffPatchTest) { // Test that we are parsing master preferences correctly. TEST_F(SetupUtilTest, GetInstallPreferencesTest) { // Create a temporary prefs file. - std::wstring prefs_file; - ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file)); + FilePath prefs_file; + ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file)); const char text[] = "{ \n" " \"distribution\": { \n" @@ -81,7 +81,8 @@ TEST_F(SetupUtilTest, GetInstallPreferencesTest) { EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text))); // Make sure command line values override the values in master preferences. - std::wstring cmd_str(L"setup.exe --installerdata=\"" + prefs_file + L"\""); + std::wstring cmd_str( + L"setup.exe --installerdata=\"" + prefs_file.value() + L"\""); cmd_str.append(L" --create-all-shortcuts"); cmd_str.append(L" --do-not-launch-chrome"); cmd_str.append(L" --alt-desktop-shortcut"); diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc index 460c4a2..206cf72 100644 --- a/chrome/installer/setup/uninstall.cc +++ b/chrome/installer/setup/uninstall.cc @@ -158,22 +158,25 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall, install_path, installed_version.GetString())); file_util::AppendToPath(&setup_exe, file_util::GetFilenameFromPath(exe_path)); - std::wstring temp_file; - if (!file_util::CreateTemporaryFileName(&temp_file)) + FilePath temp_file; + if (!file_util::CreateTemporaryFile(&temp_file)) { LOG(ERROR) << "Failed to create temporary file for setup.exe."; - else - file_util::Move(setup_exe, temp_file); + } else { + FilePath setup_exe_path = FilePath::FromWStringHack(setup_exe); + file_util::Move(setup_exe_path, temp_file); + } // Move the browser's persisted local state FilePath user_local_state; if (chrome::GetDefaultUserDataDirectory(&user_local_state)) { - std::wstring user_local_file( - user_local_state.Append(chrome::kLocalStateFilename).value()); + FilePath user_local_file( + user_local_state.Append(chrome::kLocalStateFilename)); - if (!file_util::CreateTemporaryFileName(local_state_path)) + FilePath path = FilePath::FromWStringHack(*local_state_path); + if (!file_util::CreateTemporaryFile(&path)) LOG(ERROR) << "Failed to create temporary file for Local State."; - else - file_util::CopyFile(user_local_file, *local_state_path); + else + file_util::CopyFile(user_local_file, path); } LOG(INFO) << "Deleting install path " << install_path; @@ -317,7 +320,7 @@ bool installer_setup::DeleteChromeRegistrationKeys(HKEY root, file_util::AppendToPath(&app_path_key, installer_util::kChromeExe); DeleteRegistryKey(key, app_path_key); - //Cleanup OpenWithList + // Cleanup OpenWithList for (int i = 0; ShellUtil::kFileAssociations[i] != NULL; i++) { std::wstring open_with_key(ShellUtil::kRegClasses); file_util::AppendToPath(&open_with_key, ShellUtil::kFileAssociations[i]); diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc index 8132374..24eacae 100644 --- a/chrome/installer/util/master_preferences_unittest.cc +++ b/chrome/installer/util/master_preferences_unittest.cc @@ -24,8 +24,8 @@ class MasterPreferencesTest : public testing::Test { } // namespace TEST(MasterPreferencesTest, ParseDistroParams) { - std::wstring prefs_file; - ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file)); + FilePath prefs_file; + ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file)); const char text[] = "{ \n" " \"distribution\": { \n" @@ -54,8 +54,7 @@ TEST(MasterPreferencesTest, ParseDistroParams) { EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text))); scoped_ptr<DictionaryValue> prefs( - installer_util::ParseDistributionPreferences( - FilePath::FromWStringHack(prefs_file))); + installer_util::ParseDistributionPreferences(prefs_file)); EXPECT_TRUE(prefs.get() != NULL); EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(), installer_util::master_preferences::kDistroSkipFirstRunPref)); @@ -104,8 +103,8 @@ TEST(MasterPreferencesTest, ParseDistroParams) { } TEST(MasterPreferencesTest, ParseMissingDistroParams) { - std::wstring prefs_file; - ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file)); + FilePath prefs_file; + ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file)); const char text[] = "{ \n" " \"distribution\": { \n" @@ -120,8 +119,7 @@ TEST(MasterPreferencesTest, ParseMissingDistroParams) { EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text))); scoped_ptr<DictionaryValue> prefs( - installer_util::ParseDistributionPreferences( - FilePath::FromWStringHack(prefs_file))); + installer_util::ParseDistributionPreferences(prefs_file)); EXPECT_TRUE(prefs.get() != NULL); EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(), installer_util::master_preferences::kDistroSkipFirstRunPref)); @@ -159,8 +157,8 @@ TEST(MasterPreferencesTest, ParseMissingDistroParams) { } TEST(MasterPreferencesTest, FirstRunTabs) { - std::wstring prefs_file; - ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file)); + FilePath prefs_file; + ASSERT_TRUE(file_util::CreateTemporaryFile(&prefs_file)); const char text[] = "{ \n" " \"distribution\": { \n" @@ -175,8 +173,7 @@ TEST(MasterPreferencesTest, FirstRunTabs) { EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text))); scoped_ptr<DictionaryValue> prefs( - installer_util::ParseDistributionPreferences( - FilePath::FromWStringHack(prefs_file))); + installer_util::ParseDistributionPreferences(prefs_file)); EXPECT_TRUE(prefs.get() != NULL); typedef std::vector<std::wstring> TabsVector; diff --git a/chrome/installer/util/move_tree_work_item.cc b/chrome/installer/util/move_tree_work_item.cc index da35ec1..b90665e 100644 --- a/chrome/installer/util/move_tree_work_item.cc +++ b/chrome/installer/util/move_tree_work_item.cc @@ -30,20 +30,26 @@ bool MoveTreeWorkItem::Do() { return false; } + FilePath backup_path; + // If dest_path_ exists, move destination to a backup path. if (file_util::PathExists(dest_path_)) { // Generate a backup path that can keep the original files under dest_path_. - if (!file_util::CreateTemporaryFileNameInDir(temp_dir_, &backup_path_)) { + if (!file_util::CreateTemporaryFileInDir(FilePath(temp_dir_), + &backup_path)) { LOG(ERROR) << "Failed to get backup path in folder " << temp_dir_; return false; } + backup_path_ = backup_path.value(); + if (file_util::Move(dest_path_, backup_path_)) { moved_to_backup_ = true; LOG(INFO) << "Moved destination " << dest_path_ << " to backup path " << backup_path_; } else { - LOG(ERROR) << "failed moving " << dest_path_ << " to " << backup_path_; + LOG(ERROR) << "failed moving " << dest_path_ + << " to " << backup_path_; return false; } } |