diff options
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.cc | 16 | ||||
-rw-r--r-- | chrome/browser/bookmarks/bookmark_storage.h | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_ui_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 2 | ||||
-rw-r--r-- | chrome/common/json_value_serializer.h | 4 | ||||
-rw-r--r-- | chrome/common/json_value_serializer_unittest.cc | 29 | ||||
-rw-r--r-- | chrome/common/pref_service.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_service_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 5 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 7 |
11 files changed, 40 insertions, 41 deletions
diff --git a/chrome/browser/bookmarks/bookmark_storage.cc b/chrome/browser/bookmarks/bookmark_storage.cc index 64743e5..e529b43 100644 --- a/chrome/browser/bookmarks/bookmark_storage.cc +++ b/chrome/browser/bookmarks/bookmark_storage.cc @@ -116,8 +116,8 @@ void BookmarkStorage::SaveNow() { BookmarkStorageBackend::BookmarkStorageBackend( const FilePath& path, const FilePath& tmp_history_path) - : path_(path.ToWStringHack()), - tmp_history_path_(tmp_history_path.ToWStringHack()) { + : path_(path), + tmp_history_path_(tmp_history_path) { // Make a backup of the current file. FilePath backup_path = path.ReplaceExtension(kBackupExtension); file_util::CopyFile(path, backup_path); @@ -133,11 +133,7 @@ void BookmarkStorageBackend::Write(Value* value) { JSONWriter::Write(value, true, &content); // Write to a temp file, then rename. - // TODO(port): this code was all written to use wstrings; needs cleaning up - // for FilePath. - FilePath tmp_file_filepath = - FilePath::FromWStringHack(path_).ReplaceExtension(kTmpExtension); - std::wstring tmp_file = tmp_file_filepath.ToWStringHack(); + FilePath tmp_file = path_.ReplaceExtension(kTmpExtension); int bytes_written = file_util::WriteFile(tmp_file, content.c_str(), static_cast<int>(content.length())); @@ -150,9 +146,9 @@ void BookmarkStorageBackend::Write(Value* value) { if (!move_result) LOG(WARNING) << " writing bookmarks failed, result=" << move_result; else - LOG(INFO) << "wrote bookmarks, file=" << path_; + LOG(INFO) << "wrote bookmarks, file=" << path_.value(); } else { - LOG(INFO) << "wrote bookmarks, file=" << path_; + LOG(INFO) << "wrote bookmarks, file=" << path_.value(); } // Nuke the history file so that we don't attempt to load from it again. file_util::Delete(tmp_history_path_, false); @@ -165,7 +161,7 @@ void BookmarkStorageBackend::Write(Value* value) { void BookmarkStorageBackend::Read(scoped_refptr<BookmarkStorage> service, MessageLoop* message_loop, bool load_from_history) { - const std::wstring& path = load_from_history ? tmp_history_path_ : path_; + const FilePath& path = load_from_history ? tmp_history_path_ : path_; bool bookmark_file_exists = file_util::PathExists(path); Value* root = NULL; if (bookmark_file_exists) { diff --git a/chrome/browser/bookmarks/bookmark_storage.h b/chrome/browser/bookmarks/bookmark_storage.h index 59b91a8..7048928 100644 --- a/chrome/browser/bookmarks/bookmark_storage.h +++ b/chrome/browser/bookmarks/bookmark_storage.h @@ -5,12 +5,12 @@ #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_STORAGE_H_ +#include "base/file_path.h" #include "base/ref_counted.h" #include "base/task.h" class BookmarkModel; class BookmarkStorageBackend; -class FilePath; class Profile; class MessageLoop; class Value; @@ -91,10 +91,10 @@ class BookmarkStorageBackend : private: // Path we read/write to. - const std::wstring path_; + const FilePath path_; // Path bookmarks are read from if asked to load from history file. - const std::wstring tmp_history_path_; + const FilePath tmp_history_path_; DISALLOW_COPY_AND_ASSIGN(BookmarkStorageBackend); }; diff --git a/chrome/browser/extensions/extension_ui_unittest.cc b/chrome/browser/extensions/extension_ui_unittest.cc index 3915e74..0e24832 100644 --- a/chrome/browser/extensions/extension_ui_unittest.cc +++ b/chrome/browser/extensions/extension_ui_unittest.cc @@ -15,7 +15,7 @@ namespace { std::string *error) { Value* value; - JSONFileValueSerializer serializer(path.ToWStringHack()); + JSONFileValueSerializer serializer(path); value = serializer.Deserialize(error); return static_cast<DictionaryValue*>(value); diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc index 44e6106..5cde5ca 100644 --- a/chrome/browser/extensions/extension_unittest.cc +++ b/chrome/browser/extensions/extension_unittest.cc @@ -33,7 +33,7 @@ TEST(ExtensionTest, InitFromValueInvalid) { .AppendASCII("1") .AppendASCII(Extension::kManifestFilename); - JSONFileValueSerializer serializer(extensions_path.ToWStringHack()); + JSONFileValueSerializer serializer(extensions_path); scoped_ptr<DictionaryValue> valid_value( static_cast<DictionaryValue*>(serializer.Deserialize(&error))); ASSERT_TRUE(valid_value.get()); diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 11eff23..5c836d0 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -302,7 +302,7 @@ Extension* ExtensionsServiceBackend::LoadExtension( return NULL; } - JSONFileValueSerializer serializer(manifest_path.ToWStringHack()); + JSONFileValueSerializer serializer(manifest_path); std::string error; scoped_ptr<Value> root(serializer.Deserialize(&error)); if (!root.get()) { diff --git a/chrome/common/json_value_serializer.h b/chrome/common/json_value_serializer.h index b049e4e..92bd069 100644 --- a/chrome/common/json_value_serializer.h +++ b/chrome/common/json_value_serializer.h @@ -69,10 +69,6 @@ class JSONFileValueSerializer : public ValueSerializer { // serializer will attempt to create the file at the specified location. JSONFileValueSerializer(const FilePath& json_file_path) : json_file_path_(json_file_path) {} - // DEPRECATED - DO NOT USE - // TODO(port): remove references to this - JSONFileValueSerializer(const std::wstring& json_file_path) - : json_file_path_(FilePath::FromWStringHack(json_file_path)) {} ~JSONFileValueSerializer() {} diff --git a/chrome/common/json_value_serializer_unittest.cc b/chrome/common/json_value_serializer_unittest.cc index 1fc9e97..41b1b7c 100644 --- a/chrome/common/json_value_serializer_unittest.cc +++ b/chrome/common/json_value_serializer_unittest.cc @@ -226,7 +226,8 @@ protected: 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"JSONFileValueSerializerTest"); + test_dir_ = + test_dir_.Append(FILE_PATH_LITERAL("JSONFileValueSerializerTest")); // Create a fresh, empty copy of this directory. file_util::Delete(test_dir_, true); @@ -239,14 +240,15 @@ protected: } // the path to temporary directory used to contain the test operations - std::wstring test_dir_; + FilePath test_dir_; }; TEST_F(JSONFileValueSerializerTest, Roundtrip) { - std::wstring original_file_path; + FilePath original_file_path; ASSERT_TRUE( PathService::Get(chrome::DIR_TEST_DATA, &original_file_path)); - file_util::AppendToPath(&original_file_path, L"serializer_test.js"); + original_file_path = + original_file_path.Append(FILE_PATH_LITERAL("serializer_test.js")); ASSERT_TRUE(file_util::PathExists(original_file_path)); @@ -277,8 +279,8 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { ASSERT_EQ(L"hello", string_value); // Now try writing. - std::wstring written_file_path = test_dir_; - file_util::AppendToPath(&written_file_path, L"test_output.js"); + const FilePath written_file_path = + test_dir_.Append(FILE_PATH_LITERAL("test_output.js")); ASSERT_FALSE(file_util::PathExists(written_file_path)); JSONFileValueSerializer serializer(written_file_path); @@ -291,10 +293,11 @@ TEST_F(JSONFileValueSerializerTest, Roundtrip) { } TEST_F(JSONFileValueSerializerTest, RoundtripNested) { - std::wstring original_file_path; + FilePath original_file_path; ASSERT_TRUE( PathService::Get(chrome::DIR_TEST_DATA, &original_file_path)); - file_util::AppendToPath(&original_file_path, L"serializer_nested_test.js"); + original_file_path = + original_file_path.Append(FILE_PATH_LITERAL("serializer_nested_test.js")); ASSERT_TRUE(file_util::PathExists(original_file_path)); @@ -304,8 +307,8 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { ASSERT_TRUE(root.get()); // Now try writing. - std::wstring written_file_path = test_dir_; - file_util::AppendToPath(&written_file_path, L"test_output.js"); + FilePath written_file_path = + test_dir_.Append(FILE_PATH_LITERAL("test_output.js")); ASSERT_FALSE(file_util::PathExists(written_file_path)); JSONFileValueSerializer serializer(written_file_path); @@ -318,10 +321,10 @@ TEST_F(JSONFileValueSerializerTest, RoundtripNested) { } TEST_F(JSONFileValueSerializerTest, NoWhitespace) { - std::wstring source_file_path; + FilePath source_file_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_file_path)); - file_util::AppendToPath(&source_file_path, - L"serializer_test_nowhitespace.js"); + source_file_path = source_file_path.Append( + FILE_PATH_LITERAL("serializer_test_nowhitespace.js")); ASSERT_TRUE(file_util::PathExists(source_file_path)); JSONFileValueSerializer serializer(source_file_path); scoped_ptr<Value> root; diff --git a/chrome/common/pref_service.cc b/chrome/common/pref_service.cc index b47d985..12ed13e 100644 --- a/chrome/common/pref_service.cc +++ b/chrome/common/pref_service.cc @@ -136,7 +136,7 @@ bool PrefService::LoadPersistentPrefs(const FilePath& file_path) { DCHECK(!file_path.empty()); DCHECK(CalledOnValidThread()); - JSONFileValueSerializer serializer(file_path.ToWStringHack()); + JSONFileValueSerializer serializer(file_path); scoped_ptr<Value> root(serializer.Deserialize(NULL)); if (!root.get()) return false; @@ -152,7 +152,7 @@ bool PrefService::LoadPersistentPrefs(const FilePath& file_path) { void PrefService::ReloadPersistentPrefs() { DCHECK(CalledOnValidThread()); - JSONFileValueSerializer serializer(pref_filename_.ToWStringHack()); + JSONFileValueSerializer serializer(pref_filename_); scoped_ptr<Value> root(serializer.Deserialize(NULL)); if (!root.get()) return; diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc index ced810b..61d6506 100644 --- a/chrome/common/pref_service_uitest.cc +++ b/chrome/common/pref_service_uitest.cc @@ -5,6 +5,7 @@ #include <string> #include "base/command_line.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/values.h" #include "chrome/common/chrome_constants.h" @@ -71,7 +72,8 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { ASSERT_TRUE(file_util::PathExists(tmp_pref_file_)); - JSONFileValueSerializer deserializer(tmp_pref_file_); + JSONFileValueSerializer deserializer = + FilePath::FromWStringHack(tmp_pref_file_); scoped_ptr<Value> root(deserializer.Deserialize(NULL)); ASSERT_TRUE(root.get()); diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index 7766484..76ea297 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -11,6 +11,7 @@ #include <windows.h> #include <msi.h> +#include "base/file_path.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/registry.h" @@ -64,7 +65,7 @@ bool GoogleChromeDistribution::BuildUninstallMetricsString( bool GoogleChromeDistribution::ExtractUninstallMetricsFromFile( const std::wstring& file_path, std::wstring* uninstall_metrics_string) { - JSONFileValueSerializer json_serializer(file_path); + JSONFileValueSerializer json_serializer(FilePath::FromWStringHack(file_path)); std::string json_error_string; scoped_ptr<Value> root(json_serializer.Deserialize(NULL)); @@ -166,7 +167,7 @@ std::wstring GoogleChromeDistribution::GetApplicationName() { std::wstring GoogleChromeDistribution::GetAlternateApplicationName() { const std::wstring& alt_product_name = - installer_util::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE); + installer_util::GetLocalizedString(IDS_OEM_MAIN_SHORTCUT_NAME_BASE); return alt_product_name; } diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 2ae2955..6b43ae0 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -9,6 +9,7 @@ #include "base/base_switches.h" #include "base/command_line.h" +#include "base/file_path.h" #include "base/file_util.h" #include "base/platform_thread.h" #include "base/process_util.h" @@ -598,7 +599,7 @@ int UITest::GetBrowserProcessCount() { &filter); } -static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { +static DictionaryValue* LoadDictionaryValueFromPath(const FilePath& path) { if (path.empty()) return NULL; @@ -611,7 +612,7 @@ static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { } DictionaryValue* UITest::GetLocalState() { - std::wstring local_state_path; + FilePath local_state_path; PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); return LoadDictionaryValueFromPath(local_state_path); } @@ -621,7 +622,7 @@ DictionaryValue* UITest::GetDefaultProfilePreferences() { PathService::Get(chrome::DIR_USER_DATA, &path); file_util::AppendToPath(&path, chrome::kNotSignedInProfile); file_util::AppendToPath(&path, chrome::kPreferencesFilename); - return LoadDictionaryValueFromPath(path); + return LoadDictionaryValueFromPath(FilePath::FromWStringHack(path)); } #endif // OS_WIN |