diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 21:31:31 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-27 21:31:31 +0000 |
commit | ea5b31f00f8a5fb3ff65abf436c6aade3ee15c8e (patch) | |
tree | 9124e65460d2b746eca711b2bbc15d04c814bef4 /chrome/installer | |
parent | a7dfda007eabea65c51c9e7ca3bcac472bdd2043 (diff) | |
download | chromium_src-ea5b31f00f8a5fb3ff65abf436c6aade3ee15c8e.zip chromium_src-ea5b31f00f8a5fb3ff65abf436c6aade3ee15c8e.tar.gz chromium_src-ea5b31f00f8a5fb3ff65abf436c6aade3ee15c8e.tar.bz2 |
wstring: use a few more FilePaths to remove Hack functions
BUG=69467
Review URL: http://codereview.chromium.org/6332018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/util/create_reg_key_work_item.cc | 2 | ||||
-rw-r--r-- | chrome/installer/util/create_reg_key_work_item_unittest.cc | 10 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 11 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item.h | 6 | ||||
-rw-r--r-- | chrome/installer/util/move_tree_work_item_unittest.cc | 55 | ||||
-rw-r--r-- | chrome/installer/util/work_item.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/work_item.h | 6 | ||||
-rw-r--r-- | chrome/installer/util/work_item_list.cc | 5 |
9 files changed, 52 insertions, 55 deletions
diff --git a/chrome/installer/util/create_reg_key_work_item.cc b/chrome/installer/util/create_reg_key_work_item.cc index e634c9c..9addb33e 100644 --- a/chrome/installer/util/create_reg_key_work_item.cc +++ b/chrome/installer/util/create_reg_key_work_item.cc @@ -24,7 +24,7 @@ void UpOneDirectoryOrEmpty(std::wstring* dir) { if (directory == path || directory.value() == FilePath::kCurrentDirectory) dir->clear(); else - *dir = directory.ToWStringHack(); + *dir = directory.value(); } } // namespace diff --git a/chrome/installer/util/create_reg_key_work_item_unittest.cc b/chrome/installer/util/create_reg_key_work_item_unittest.cc index 47aa13e..9934d47 100644 --- a/chrome/installer/util/create_reg_key_work_item_unittest.cc +++ b/chrome/installer/util/create_reg_key_work_item_unittest.cc @@ -55,7 +55,7 @@ TEST_F(CreateRegKeyWorkItemTest, CreateKey) { scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create.ToWStringHack())); + key_to_create.value())); EXPECT_TRUE(work_item->Do()); @@ -81,7 +81,7 @@ TEST_F(CreateRegKeyWorkItemTest, CreateExistingKey) { scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create.ToWStringHack())); + key_to_create.value())); EXPECT_TRUE(work_item->Do()); @@ -109,7 +109,7 @@ TEST_F(CreateRegKeyWorkItemTest, CreateSharedKey) { scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create_3.ToWStringHack())); + key_to_create_3.value())); EXPECT_TRUE(work_item->Do()); @@ -148,7 +148,7 @@ TEST_F(CreateRegKeyWorkItemTest, RollbackWithMissingKey) { scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create_3.ToWStringHack())); + key_to_create_3.value())); EXPECT_TRUE(work_item->Do()); @@ -178,7 +178,7 @@ TEST_F(CreateRegKeyWorkItemTest, RollbackWithSetValue) { scoped_ptr<CreateRegKeyWorkItem> work_item( WorkItem::CreateCreateRegKeyWorkItem(HKEY_CURRENT_USER, - key_to_create.ToWStringHack())); + key_to_create.value())); EXPECT_TRUE(work_item->Do()); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 300ee1d..eff776b 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -170,7 +170,7 @@ bool RelaunchSetup(const std::string& flag, int value, // This function changes the permisions so that any authenticated user // can launch |exe| later on. This function should only be called if the // code is running at the system level. -bool FixDACLsForExecute(const wchar_t* exe) { +bool FixDACLsForExecute(const FilePath& exe) { // The general strategy to is to add an ACE to the exe DACL the quick // and dirty way: a) read the DACL b) convert it to sddl string c) add the // new ACE to the string d) convert sddl string back to DACL and finally @@ -178,8 +178,10 @@ bool FixDACLsForExecute(const wchar_t* exe) { char buff[1024]; DWORD len = sizeof(buff); PSECURITY_DESCRIPTOR sd = reinterpret_cast<PSECURITY_DESCRIPTOR>(buff); - if (!::GetFileSecurityW(exe, DACL_SECURITY_INFORMATION, sd, len, &len)) + if (!::GetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION, + sd, len, &len)) { return false; + } wchar_t* sddl = 0; if (!::ConvertSecurityDescriptorToStringSecurityDescriptorW(sd, SDDL_REVISION_1, DACL_SECURITY_INFORMATION, &sddl, NULL)) @@ -205,7 +207,8 @@ bool FixDACLsForExecute(const wchar_t* exe) { if (!::ConvertStringSecurityDescriptorToSecurityDescriptorW(new_sddl.c_str(), SDDL_REVISION_1, &sd, NULL)) return false; - bool rv = ::SetFileSecurityW(exe, DACL_SECURITY_INFORMATION, sd) == TRUE; + bool rv = ::SetFileSecurityW(exe.value().c_str(), DACL_SECURITY_INFORMATION, + sd) == TRUE; ::LocalFree(sd); return rv; } @@ -232,7 +235,7 @@ bool RelaunchSetupAsConsoleUser(const std::string& flag) { if (base::win::GetVersion() > base::win::VERSION_XP) { // Make sure that in Vista and Above we have the proper DACLs so // the interactive user can launch it. - if (!FixDACLsForExecute(setup_exe.ToWStringHack().c_str())) + if (!FixDACLsForExecute(setup_exe)) NOTREACHED(); } diff --git a/chrome/installer/util/move_tree_work_item.cc b/chrome/installer/util/move_tree_work_item.cc index 95b3650..027de2f 100644 --- a/chrome/installer/util/move_tree_work_item.cc +++ b/chrome/installer/util/move_tree_work_item.cc @@ -16,9 +16,9 @@ MoveTreeWorkItem::~MoveTreeWorkItem() { } } -MoveTreeWorkItem::MoveTreeWorkItem(const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir) +MoveTreeWorkItem::MoveTreeWorkItem(const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir) : source_path_(source_path), dest_path_(dest_path), temp_dir_(temp_dir), diff --git a/chrome/installer/util/move_tree_work_item.h b/chrome/installer/util/move_tree_work_item.h index 69aa845..f1941cd8 100644 --- a/chrome/installer/util/move_tree_work_item.h +++ b/chrome/installer/util/move_tree_work_item.h @@ -36,9 +36,9 @@ class MoveTreeWorkItem : public WorkItem { // specified by dest_path. To facilitate rollback, the caller needs to supply // a temporary directory (temp_dir) to save the original files if they exist // under dest_path. - MoveTreeWorkItem(const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir); + MoveTreeWorkItem(const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir); // Source path to move files from. FilePath source_path_; diff --git a/chrome/installer/util/move_tree_work_item_unittest.cc b/chrome/installer/util/move_tree_work_item_unittest.cc index 46dd415..393b444 100644 --- a/chrome/installer/util/move_tree_work_item_unittest.cc +++ b/chrome/installer/util/move_tree_work_item_unittest.cc @@ -58,10 +58,10 @@ namespace { } // Simple function to read text from a file. - std::wstring ReadTextFile(const std::wstring& filename) { + std::wstring ReadTextFile(const FilePath& path) { WCHAR contents[64]; std::wifstream file; - file.open(filename.c_str()); + file.open(path.value().c_str()); EXPECT_TRUE(file.is_open()); file.getline(contents, 64); file.close(); @@ -102,9 +102,8 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectory) { ASSERT_FALSE(file_util::PathExists(to_file)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1.ToWStringHack(), to_dir.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_dir1, to_dir, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -155,9 +154,8 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { ASSERT_FALSE(file_util::PathExists(new_to_file)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_dir1.ToWStringHack(), to_dir.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_dir1, to_dir, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_FALSE(file_util::PathExists(from_dir1)); @@ -172,9 +170,8 @@ TEST_F(MoveTreeWorkItemTest, MoveDirectoryDestExists) { EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_FALSE(file_util::PathExists(new_to_file)); EXPECT_TRUE(file_util::PathExists(orig_to_file)); - EXPECT_EQ(0, ReadTextFile(orig_to_file.ToWStringHack()).compare( - text_content_2)); - EXPECT_EQ(0, ReadTextFile(from_file.ToWStringHack()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(orig_to_file).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); } // Move one file from source to destination when destination does not @@ -197,15 +194,14 @@ TEST_F(MoveTreeWorkItemTest, MoveAFile) { ASSERT_FALSE(file_util::PathExists(to_file)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file.ToWStringHack(), to_file.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_file, to_file, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); // test rollback() work_item->Rollback(); @@ -213,7 +209,7 @@ TEST_F(MoveTreeWorkItemTest, MoveAFile) { EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_TRUE(file_util::PathExists(from_file)); EXPECT_FALSE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); } // Move one file from source to destination when destination already @@ -242,24 +238,23 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestExists) { ASSERT_TRUE(file_util::PathExists(to_file)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file.ToWStringHack(), to_dir.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_file, to_dir, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_FALSE(file_util::PathExists(to_file)); - EXPECT_EQ(0, ReadTextFile(to_dir.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_dir).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(from_dir)); - EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_2)); + EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_2)); } // Move one file from source to destination when destination already @@ -300,21 +295,20 @@ TEST_F(MoveTreeWorkItemTest, MoveFileDestInUse) { NULL, NULL, &si, &pi)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file.ToWStringHack(), to_file.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_file, to_file, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_FALSE(file_util::PathExists(from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); // test rollback() work_item->Rollback(); EXPECT_TRUE(file_util::PathExists(from_dir)); - EXPECT_EQ(0, ReadTextFile(from_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(from_file).compare(text_content_1)); EXPECT_TRUE(file_util::PathExists(to_dir)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, to_file)); @@ -361,9 +355,8 @@ TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { NULL, NULL, &si, &pi)); // test Do() - scoped_ptr<MoveTreeWorkItem> work_item(WorkItem::CreateMoveTreeWorkItem( - from_file.ToWStringHack(), to_file.ToWStringHack(), - temp_dir_.ToWStringHack())); + scoped_ptr<MoveTreeWorkItem> work_item( + WorkItem::CreateMoveTreeWorkItem(from_file, to_file, temp_dir_)); EXPECT_TRUE(work_item->Do()); EXPECT_TRUE(file_util::PathExists(from_dir)); @@ -389,5 +382,5 @@ TEST_F(MoveTreeWorkItemTest, MoveFileInUse) { EXPECT_TRUE(file_util::PathExists(from_dir)); EXPECT_TRUE(file_util::ContentsEqual(exe_full_path, from_file)); EXPECT_TRUE(file_util::PathExists(to_dir)); - EXPECT_EQ(0, ReadTextFile(to_file.value()).compare(text_content_1)); + EXPECT_EQ(0, ReadTextFile(to_file).compare(text_content_1)); } diff --git a/chrome/installer/util/work_item.cc b/chrome/installer/util/work_item.cc index c62a383..2d40d36 100644 --- a/chrome/installer/util/work_item.cc +++ b/chrome/installer/util/work_item.cc @@ -59,9 +59,9 @@ DeleteTreeWorkItem* WorkItem::CreateDeleteTreeWorkItem( } MoveTreeWorkItem* WorkItem::CreateMoveTreeWorkItem( - const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir) { + const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir) { return new MoveTreeWorkItem(source_path, dest_path, temp_dir); } diff --git a/chrome/installer/util/work_item.h b/chrome/installer/util/work_item.h index be7331b..9b98cc6 100644 --- a/chrome/installer/util/work_item.h +++ b/chrome/installer/util/work_item.h @@ -93,9 +93,9 @@ class WorkItem { // Create a MoveTreeWorkItem that recursively moves a file system hierarchy // from source path to destination path. static MoveTreeWorkItem* CreateMoveTreeWorkItem( - const std::wstring& source_path, - const std::wstring& dest_path, - const std::wstring& temp_dir); + const FilePath& source_path, + const FilePath& dest_path, + const FilePath& temp_dir); // Create a SetRegValueWorkItem that sets a registry value with REG_SZ type // at the key with specified path. diff --git a/chrome/installer/util/work_item_list.cc b/chrome/installer/util/work_item_list.cc index 05c0b58..464f4c9 100644 --- a/chrome/installer/util/work_item_list.cc +++ b/chrome/installer/util/work_item_list.cc @@ -133,8 +133,9 @@ WorkItem* WorkItemList::AddDeleteTreeWorkItem(const FilePath& root_path) { WorkItem* WorkItemList::AddMoveTreeWorkItem(const std::wstring& source_path, const std::wstring& dest_path, const std::wstring& temp_dir) { - WorkItem* item = WorkItem::CreateMoveTreeWorkItem(source_path, dest_path, - temp_dir); + WorkItem* item = WorkItem::CreateMoveTreeWorkItem(FilePath(source_path), + FilePath(dest_path), + FilePath(temp_dir)); AddWorkItem(item); return item; } |