diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 22:22:07 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 22:22:07 +0000 |
commit | 967d18bad65a0dc0cf8d0207cbd2cf82651752b8 (patch) | |
tree | 2d06825366c1d876dd432b60db417565dc3d4e7e | |
parent | 849991d6cebb241a26db85ba50b4e0c2a6b6a80c (diff) | |
download | chromium_src-967d18bad65a0dc0cf8d0207cbd2cf82651752b8.zip chromium_src-967d18bad65a0dc0cf8d0207cbd2cf82651752b8.tar.gz chromium_src-967d18bad65a0dc0cf8d0207cbd2cf82651752b8.tar.bz2 |
wstring: remove some simple instances of ToWStringHack
BUG=69467
Review URL: http://codereview.chromium.org/6588131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76630 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/download/download_util.cc | 11 | ||||
-rw-r--r-- | chrome/browser/extensions/pack_extension_job.cc | 4 | ||||
-rw-r--r-- | chrome/browser/safe_browsing/filter_false_positive_perftest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/download_item_view.cc | 8 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.cc | 7 | ||||
-rw-r--r-- | chrome/common/extensions/extension_unpacker.cc | 19 | ||||
-rw-r--r-- | chrome/common/zip_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/test/plugin/pdf_browsertest.cc | 3 | ||||
-rw-r--r-- | skia/ext/vector_canvas_unittest.cc | 4 | ||||
-rw-r--r-- | webkit/database/database_tracker.cc | 6 |
10 files changed, 40 insertions, 26 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 69dcce6..4f0b475 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -525,8 +525,8 @@ void DragDownload(const DownloadItem* download, // Add URL so that we can load supported files when dragged to TabContents. if (net::IsSupportedMimeType(mime_type)) { - data.SetURL(GURL(WideToUTF8(full_path.ToWStringHack())), - download->GetFileNameToReportUser().LossyDisplayName()); + data.SetURL(net::FilePathToFileURL(full_path), + download->GetFileNameToReportUser().LossyDisplayName()); } #if defined(OS_WIN) @@ -566,11 +566,10 @@ DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) { file_value->SetString("date_string", base::TimeFormatShortDate(download->start_time())); file_value->SetInteger("id", id); - file_value->SetString("file_path", - WideToUTF16Hack(download->GetTargetFilePath().ToWStringHack())); + file_value->Set("file_path", + Value::CreateFilePathValue(download->GetTargetFilePath())); // Keep file names as LTR. - string16 file_name = WideToUTF16Hack( - download->GetFileNameToReportUser().ToWStringHack()); + string16 file_name = download->GetFileNameToReportUser().LossyDisplayName(); file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name); file_value->SetString("file_name", file_name); file_value->SetString("url", download->url().spec()); diff --git a/chrome/browser/extensions/pack_extension_job.cc b/chrome/browser/extensions/pack_extension_job.cc index 41f87d2..591756b 100644 --- a/chrome/browser/extensions/pack_extension_job.cc +++ b/chrome/browser/extensions/pack_extension_job.cc @@ -83,8 +83,8 @@ void PackExtensionJob::ReportFailureOnClientThread(const std::string& error) { // static string16 PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file, const FilePath& key_file) { - string16 crx_file_string = WideToUTF16(crx_file.ToWStringHack()); - string16 key_file_string = WideToUTF16(key_file.ToWStringHack()); + string16 crx_file_string = crx_file.LossyDisplayName(); + string16 key_file_string = key_file.LossyDisplayName(); if (key_file_string.empty()) { return l10n_util::GetStringFUTF16( IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE, diff --git a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc index 34c4512..4afa953 100644 --- a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc +++ b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc @@ -239,7 +239,7 @@ void CalculateBloomFilterFalsePositives( // Read in data file line at a time. FilePath url_file = data_dir.Append(FILE_PATH_LITERAL("urls")); - std::ifstream url_stream(WideToASCII(url_file.ToWStringHack()).c_str()); + std::ifstream url_stream(url_file.value().c_str()); // Keep track of stats int hits = 0; diff --git a/chrome/browser/ui/views/download_item_view.cc b/chrome/browser/ui/views/download_item_view.cc index 8cdc4f4..b6098de 100644 --- a/chrome/browser/ui/views/download_item_view.cc +++ b/chrome/browser/ui/views/download_item_view.cc @@ -211,7 +211,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download, dangerous_mode_body_image_set_ = dangerous_mode_body_image_set; LoadIcon(); - tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack(); + tooltip_text_ = + UTF16ToWide(download_->GetFileNameToReportUser().LossyDisplayName()); font_ = ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::BaseFont); box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() + @@ -748,7 +749,8 @@ void DownloadItemView::ClearDangerousMode() { // We need to load the icon now that the download_ has the real path. LoadIcon(); - tooltip_text_ = download_->GetFileNameToReportUser().ToWStringHack(); + tooltip_text_ = + UTF16ToWide(download_->GetFileNameToReportUser().LossyDisplayName()); // Force the shelf to layout again as our size has changed. parent_->Layout(); @@ -1079,7 +1081,7 @@ void DownloadItemView::UpdateAccessibleName() { new_name = WideToUTF16Hack(dangerous_download_label_->GetText()); } else { new_name = WideToUTF16Hack(status_text_) + char16(' ') + - WideToUTF16Hack(download_->GetFileNameToReportUser().ToWStringHack()); + download_->GetFileNameToReportUser().LossyDisplayName(); } // If the name has changed, call SetAccessibleName and notify diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index dad4d06..0874046 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -199,8 +199,11 @@ bool GetValidLocales(const FilePath& locale_path, file_util::FileEnumerator::DIRECTORIES); FilePath locale_folder; while (!(locale_folder = locales.Next()).empty()) { - std::string locale_name = - WideToASCII(locale_folder.BaseName().ToWStringHack()); + std::string locale_name = locale_folder.BaseName().MaybeAsASCII(); + if (locale_name.empty()) { + NOTREACHED(); + continue; // Not ASCII. + } if (!AddLocale(chrome_locales, locale_folder, locale_name, diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index e001911..25919cf 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -286,13 +286,14 @@ bool ExtensionUnpacker::ReadMessageCatalog(const FilePath& message_path) { scoped_ptr<DictionaryValue> root( static_cast<DictionaryValue*>(serializer.Deserialize(NULL, &error))); if (!root.get()) { - std::string messages_file = WideToASCII(message_path.ToWStringHack()); + string16 messages_file = message_path.LossyDisplayName(); if (error.empty()) { // If file is missing, Deserialize will fail with empty error. SetError(base::StringPrintf("%s %s", errors::kLocalesMessagesFileMissing, - messages_file.c_str())); + UTF16ToUTF8(messages_file).c_str())); } else { - SetError(base::StringPrintf("%s: %s", messages_file.c_str(), + SetError(base::StringPrintf("%s: %s", + UTF16ToUTF8(messages_file).c_str(), error.c_str())); } return false; @@ -300,11 +301,17 @@ bool ExtensionUnpacker::ReadMessageCatalog(const FilePath& message_path) { FilePath relative_path; // message_path was created from temp_install_dir. This should never fail. - if (!temp_install_dir_.AppendRelativePath(message_path, &relative_path)) + if (!temp_install_dir_.AppendRelativePath(message_path, &relative_path)) { NOTREACHED(); + return false; + } - parsed_catalogs_->Set(WideToUTF8(relative_path.DirName().ToWStringHack()), - root.release()); + std::string dir_name = relative_path.DirName().MaybeAsASCII(); + if (dir_name.empty()) { + NOTREACHED(); + return false; + } + parsed_catalogs_->Set(dir_name, root.release()); return true; } diff --git a/chrome/common/zip_unittest.cc b/chrome/common/zip_unittest.cc index afb50c0..d7c73c5 100644 --- a/chrome/common/zip_unittest.cc +++ b/chrome/common/zip_unittest.cc @@ -71,7 +71,7 @@ class ZipTest : public PlatformTest { size_t expected_count = 0; for (std::set<FilePath>::iterator iter = zip_contents_.begin(); iter != zip_contents_.end(); ++iter) { - if (expect_hidden_files || iter->BaseName().ToWStringHack()[0] != L'.') + if (expect_hidden_files || iter->BaseName().value()[0] != '.') ++expected_count; } diff --git a/chrome/test/plugin/pdf_browsertest.cc b/chrome/test/plugin/pdf_browsertest.cc index a42f528..e56625f 100644 --- a/chrome/test/plugin/pdf_browsertest.cc +++ b/chrome/test/plugin/pdf_browsertest.cc @@ -271,7 +271,8 @@ IN_PROC_BROWSER_TEST_F(PDFBrowserTest, FLAKY_SLOW_Loading) { for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); file_path = file_enumerator.Next()) { - std::string filename = WideToASCII(file_path.BaseName().ToWStringHack()); + std::string filename = file_path.BaseName().MaybeAsASCII(); + ASSERT_FALSE(filename.empty()); #if defined(OS_MACOSX) || defined(OS_LINUX) if (filename == "sample.pdf") diff --git a/skia/ext/vector_canvas_unittest.cc b/skia/ext/vector_canvas_unittest.cc index 4752aeb..0266c81 100644 --- a/skia/ext/vector_canvas_unittest.cc +++ b/skia/ext/vector_canvas_unittest.cc @@ -234,10 +234,10 @@ class ImageTest : public testing::Test { AppendASCII(test_info.name()); // Hack for a quick lowercase. We assume all the tests names are ASCII. - std::string tmp(WideToASCII(test_dir_.ToWStringHack())); + FilePath::StringType tmp(test_dir_.value()); for (size_t i = 0; i < tmp.size(); ++i) tmp[i] = base::ToLowerASCII(tmp[i]); - test_dir_ = FilePath::FromWStringHack(ASCIIToWide(tmp)); + test_dir_ = FilePath(tmp); if (action_ == GENERATE) { // Make sure the directory exist. diff --git a/webkit/database/database_tracker.cc b/webkit/database/database_tracker.cc index 20f5971..5911ad2 100644 --- a/webkit/database/database_tracker.cc +++ b/webkit/database/database_tracker.cc @@ -715,9 +715,11 @@ void DatabaseTracker::ClearLocalState(const FilePath& profile_path) { for (FilePath file_path = file_enumerator.Next(); !file_path.empty(); file_path = file_enumerator.Next()) { if (file_path.BaseName() != FilePath(kTrackerDatabaseFileName)) { - if (!StartsWith(file_path.BaseName().ToWStringHack(), - ASCIIToWide(kExtensionOriginIdentifierPrefix), true)) + std::string basename = file_path.BaseName().MaybeAsASCII(); + if (!basename.empty() && + !StartsWithASCII(basename, kExtensionOriginIdentifierPrefix, true)) { file_util::Delete(file_path, true); + } } } } |