diff options
27 files changed, 119 insertions, 91 deletions
diff --git a/base/file_path.cc b/base/file_path.cc index 9bc46f0..5f1375a 100644 --- a/base/file_path.cc +++ b/base/file_path.cc @@ -513,10 +513,14 @@ bool FilePath::ReferencesParent() const { } #if defined(OS_POSIX) - // See file_path.h for a discussion of the encoding of paths on POSIX -// platforms. These *Hack() functions are not quite correct, but they're -// only temporary while we fix the remainder of the code. +// platforms. These encoding conversion functions are not quite correct. + +string16 FilePath::LossyDisplayName() const { + return WideToUTF16(base::SysNativeMBToWide(path_)); +} + +// The *Hack functions are temporary while we fix the remainder of the code. // Remember to remove the #includes at the top when you remove these. // static @@ -527,6 +531,10 @@ std::wstring FilePath::ToWStringHack() const { return base::SysNativeMBToWide(path_); } #elif defined(OS_WIN) +string16 FilePath::LossyDisplayName() const { + return path_; +} + // static FilePath FilePath::FromWStringHack(const std::wstring& wstring) { return FilePath(wstring); diff --git a/base/file_path.h b/base/file_path.h index 01cd4a5..84bb350 100644 --- a/base/file_path.h +++ b/base/file_path.h @@ -277,6 +277,12 @@ class FilePath { // directory (i.e. has a path component that is ".." bool ReferencesParent() const; + // Return a Unicode human-readable version of this path. + // Warning: you can *not*, in general, go from a display name back to a real + // path. Only use this when displaying paths to users, not just when you + // want to stuff a string16 into some other API. + string16 LossyDisplayName() const; + // Older Chromium code assumes that paths are always wstrings. // These functions convert wstrings to/from FilePaths, and are // useful to smooth porting that old code to the FilePath API. @@ -290,6 +296,9 @@ class FilePath { // OS-native string format. // - Am I using well-known file names, like "config.ini"? Then use the // ASCII functions (we require paths to always be supersets of ASCII). + // - Am I displaying a string to the user in some UI? Then use the + // LossyDisplayName() function, but keep in mind that you can't + // ever use the result of that again as a path. static FilePath FromWStringHack(const std::wstring& wstring); std::wstring ToWStringHack() const; diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc index 6ea94e4..ea29df5 100644 --- a/base/file_util_unittest.cc +++ b/base/file_util_unittest.cc @@ -163,7 +163,7 @@ class FindResultCollector { void CreateTextFile(const FilePath& filename, const std::wstring& contents) { std::ofstream file; - file.open(WideToUTF8(filename.ToWStringHack()).c_str()); + file.open(filename.value().c_str()); ASSERT_TRUE(file.is_open()); file << contents; file.close(); @@ -173,7 +173,7 @@ void CreateTextFile(const FilePath& filename, std::wstring ReadTextFile(const FilePath& filename) { wchar_t contents[64]; std::wifstream file; - file.open(WideToUTF8(filename.ToWStringHack()).c_str()); + file.open(filename.value().c_str()); EXPECT_TRUE(file.is_open()); file.getline(contents, 64); file.close(); diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index 7939766..f55c1b5 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -194,8 +194,10 @@ void WifiConfigView::ItemChanged(views::Combobox* combo_box, void WifiConfigView::FileSelected(const FilePath& path, int index, void* params) { certificate_path_ = path.value(); - if (certificate_browse_button_) - certificate_browse_button_->SetLabel(path.BaseName().ToWStringHack()); + if (certificate_browse_button_) { + certificate_browse_button_->SetLabel( + UTF16ToWide(path.BaseName().LossyDisplayName())); + } UpdateCanLogin(); // TODO(njw) Check if the passphrase decrypts the key. } diff --git a/chrome/browser/diagnostics/recon_diagnostics.cc b/chrome/browser/diagnostics/recon_diagnostics.cc index ac0548b..d8f9526 100644 --- a/chrome/browser/diagnostics/recon_diagnostics.cc +++ b/chrome/browser/diagnostics/recon_diagnostics.cc @@ -145,8 +145,7 @@ class InstallTypeTest : public DiagnosticTest { RecordFailure(ASCIIToUTF16("Path provider failure")); return false; } - user_level_ = InstallUtil::IsPerUserInstall( - chrome_exe.ToWStringHack().c_str()); + user_level_ = InstallUtil::IsPerUserInstall(chrome_exe.value().c_str()); const char* type = user_level_ ? "User Level" : "System Level"; string16 install_type(ASCIIToUTF16(type)); #else diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc index 123b292..524d695 100644 --- a/chrome/browser/download/download_browsertest.cc +++ b/chrome/browser/download/download_browsertest.cc @@ -370,11 +370,11 @@ class DownloadTest : public InProcessBrowserTest { } // TODO(ahendrickson) -- |expected_title_in_progress| and - // |expected_title_in_finished| need to be checked. + // |expected_title_finished| need to be checked. bool RunSizeTest(Browser* browser, const GURL& url, - const std::wstring& expected_title_in_progress, - const std::wstring& expected_title_finished) { + const string16& expected_title_in_progress, + const string16& expected_title_finished) { if (!InitialSetup(false)) return false; @@ -613,10 +613,11 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_UnknownSize) { FilePath filename; net::FileURLToFilePath(url, &filename); filename = filename.BaseName(); - ASSERT_TRUE(RunSizeTest(browser(), - url, - L"32.0 KB - " + filename.ToWStringHack(), - L"100% - " + filename.ToWStringHack())); + ASSERT_TRUE(RunSizeTest( + browser(), + url, + ASCIIToUTF16("32.0 KB - ") + filename.LossyDisplayName(), + ASCIIToUTF16("100% - ") + filename.LossyDisplayName())); } // Test is believed mostly good (non-flaky) in itself, but it @@ -629,10 +630,11 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DISABLED_KnownSize) { FilePath filename; net::FileURLToFilePath(url, &filename); filename = filename.BaseName(); - ASSERT_TRUE(RunSizeTest(browser(), - url, - L"71% - " + filename.ToWStringHack(), - L"100% - " + filename.ToWStringHack())); + ASSERT_TRUE(RunSizeTest( + browser(), + url, + ASCIIToUTF16("71% - ") + filename.LossyDisplayName(), + ASCIIToUTF16("100% - ") + filename.LossyDisplayName())); } // Test that when downloading an item in Incognito mode, we don't crash when diff --git a/chrome/browser/download/download_item.cc b/chrome/browser/download/download_item.cc index 620828b..beb9cf7 100644 --- a/chrome/browser/download/download_item.cc +++ b/chrome/browser/download/download_item.cc @@ -486,8 +486,12 @@ bool DownloadItem::MatchesQuery(const string16& query) const { if (url_formatted.find(query) != string16::npos) return true; - string16 path(l10n_util::ToLower(WideToUTF16(full_path().ToWStringHack()))); - if (path.find(query) != std::wstring::npos) + string16 path(l10n_util::ToLower(full_path().LossyDisplayName())); + // This shouldn't just do a substring match; it is wrong for Unicode + // due to normalization and we have a fancier search-query system + // used elsewhere. + // http://code.google.com/p/chromium/issues/detail?id=71982 + if (path.find(query) != string16::npos) return true; return false; diff --git a/chrome/browser/download/download_uitest.cc b/chrome/browser/download/download_uitest.cc index 743642c..0f6971a 100644 --- a/chrome/browser/download/download_uitest.cc +++ b/chrome/browser/download/download_uitest.cc @@ -79,8 +79,8 @@ class DownloadTest : public UITest { protected: void RunSizeTest(const GURL& url, - const std::wstring& expected_title_in_progress, - const std::wstring& expected_title_finished) { + const string16& expected_title_in_progress, + const string16& expected_title_finished) { FilePath filename; net::FileURLToFilePath(url, &filename); filename = filename.BaseName(); @@ -242,8 +242,9 @@ TEST_F(DownloadTest, FLAKY_UnknownSize) { FilePath filename; net::FileURLToFilePath(url, &filename); filename = filename.BaseName(); - RunSizeTest(url, L"32.0 KB - " + filename.ToWStringHack(), - L"100% - " + filename.ToWStringHack()); + RunSizeTest(url, + ASCIIToUTF16("32.0 KB - ") + filename.LossyDisplayName(), + ASCIIToUTF16("100% - ") + filename.LossyDisplayName()); } // All download tests are flaky on all platforms, http://crbug.com/35275, @@ -254,8 +255,9 @@ TEST_F(DownloadTest, FLAKY_KnownSize) { FilePath filename; net::FileURLToFilePath(url, &filename); filename = filename.BaseName(); - RunSizeTest(url, L"71% - " + filename.ToWStringHack(), - L"100% - " + filename.ToWStringHack()); + RunSizeTest(url, + ASCIIToUTF16("71% - ") + filename.LossyDisplayName(), + ASCIIToUTF16("100% - ") + filename.LossyDisplayName()); } // Test that when downloading an item in Incognito mode, we don't crash when diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index ef2b2a4..6cfba30 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -1893,8 +1893,7 @@ void ExtensionService::ReportExtensionLoadError( Source<Profile>(profile_), Details<const std::string>(&error)); - // TODO(port): note that this isn't guaranteed to work properly on Linux. - std::string path_str = WideToUTF8(extension_path.ToWStringHack()); + std::string path_str = UTF16ToUTF8(extension_path.LossyDisplayName()); std::string message = base::StringPrintf( "Could not load extension from '%s'. %s", path_str.c_str(), error.c_str()); diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index e8514b8..31efea8 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -126,7 +126,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, if (WriteEULAtoTempFile(&inner_html)) { int retcode = 0; if (!LaunchSetupWithParam(installer::switches::kShowEula, - inner_html.ToWStringHack(), &retcode) || + inner_html.value(), &retcode) || (retcode == installer::EULA_REJECTED)) { LOG(WARNING) << "EULA rejected. Fast exit."; ::ExitProcess(1); diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 529f21e..183218c 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -258,26 +258,26 @@ void PluginObserver::OnMissingPluginStatus(int status) { void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { DCHECK(!plugin_path.value().empty()); - std::wstring plugin_name = plugin_path.ToWStringHack(); + string16 plugin_name = plugin_path.LossyDisplayName(); webkit::npapi::WebPluginInfo plugin_info; if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( plugin_path, &plugin_info) && !plugin_info.name.empty()) { - plugin_name = UTF16ToWide(plugin_info.name); + plugin_name = plugin_info.name; #if defined(OS_MACOSX) // Many plugins on the Mac have .plugin in the actual name, which looks // terrible, so look for that and strip it off if present. - const std::wstring plugin_extension(L".plugin"); - if (EndsWith(plugin_name, plugin_extension, true)) - plugin_name.erase(plugin_name.length() - plugin_extension.length()); + const string kPluginExtension = ".plugin"; + if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) + plugin_name.erase(plugin_name.length() - kPluginExtension.length()); #endif // OS_MACOSX } SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INFOBAR_PLUGIN_CRASHED); tab_contents_->AddInfoBar(new SimpleAlertInfoBarDelegate( tab_contents_, crash_icon, - l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, - WideToUTF16Hack(plugin_name)), true)); + l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), + true)); } void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc index a13aec8..148f65e 100644 --- a/chrome/browser/plugin_service.cc +++ b/chrome/browser/plugin_service.cc @@ -496,7 +496,7 @@ void PluginService::RegisterPepperPlugins() { webkit::npapi::WebPluginInfo info; info.path = plugins[i].path; info.name = plugins[i].name.empty() ? - WideToUTF16(plugins[i].path.BaseName().ToWStringHack()) : + plugins[i].path.BaseName().LossyDisplayName() : ASCIIToUTF16(plugins[i].name); info.desc = ASCIIToUTF16(plugins[i].description); info.enabled = webkit::npapi::WebPluginInfo::USER_ENABLED_POLICY_UNMANAGED; @@ -509,7 +509,7 @@ void PluginService::RegisterPepperPlugins() { ASCIIToUTF16(plugins[i].type_descriptions), &info.mime_types)) { LOG(ERROR) << "Error parsing mime types for " - << plugins[i].path.ToWStringHack(); + << plugins[i].path.LossyDisplayName(); return; } diff --git a/chrome/browser/printing/printing_layout_uitest.cc b/chrome/browser/printing/printing_layout_uitest.cc index 4f8ede1..a3917c5 100644 --- a/chrome/browser/printing/printing_layout_uitest.cc +++ b/chrome/browser/printing/printing_layout_uitest.cc @@ -59,7 +59,7 @@ class PrintingLayoutTest : public PrintingTest<UITest> { return 100.; } - std::wstring verification_file(test_data_directory_.ToWStringHack()); + std::wstring verification_file(test_data_directory_.value()); file_util::AppendToPath(&verification_file, L"printing"); file_util::AppendToPath(&verification_file, verification_name); FilePath emf(verification_file + L".emf"); @@ -143,22 +143,22 @@ class PrintingLayoutTest : public PrintingTest<UITest> { prn_file.clear(); found_emf = false; found_prn = false; - std::wstring file; - while (!(file = enumerator.Next().ToWStringHack()).empty()) { - std::wstring ext = FilePath(file).Extension(); + FilePath file; + while (!(file = enumerator.Next()).empty()) { + std::wstring ext = file.Extension(); if (base::strcasecmp(WideToUTF8(ext).c_str(), ".emf") == 0) { EXPECT_FALSE(found_emf) << "Found a leftover .EMF file: \"" << - emf_file << "\" and \"" << file << "\" when looking for \"" << - verification_name << "\""; + emf_file << "\" and \"" << file.value() << + "\" when looking for \"" << verification_name << "\""; found_emf = true; - emf_file = file; + emf_file = file.value(); continue; } if (base::strcasecmp(WideToUTF8(ext).c_str(), ".prn") == 0) { EXPECT_FALSE(found_prn) << "Found a leftover .PRN file: \"" << - prn_file << "\" and \"" << file << "\" when looking for \"" << - verification_name << "\""; - prn_file = file; + prn_file << "\" and \"" << file.value() << + "\" when looking for \"" << verification_name << "\""; + prn_file = file.value(); found_prn = true; file_util::Delete(file, false); continue; diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc index 1be5a87..17910dc 100644 --- a/chrome/browser/process_singleton_win.cc +++ b/chrome/browser/process_singleton_win.cc @@ -42,10 +42,9 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) { // Look for a Chrome instance that uses the same profile directory. ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) : window_(NULL), locked_(false), foreground_window_(NULL) { - std::wstring user_data_dir_str(user_data_dir.ToWStringHack()); remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, - user_data_dir_str.c_str()); + user_data_dir.value().c_str()); if (!remote_window_) { // Make sure we will be the one and only process creating the window. // We use a named Mutex since we are protecting against multi-process @@ -68,7 +67,7 @@ ProcessSingleton::ProcessSingleton(const FilePath& user_data_dir) // was given to us. remote_window_ = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, - user_data_dir_str.c_str()); + user_data_dir.value().c_str()); if (!remote_window_) Create(); BOOL success = ReleaseMutex(only_me); diff --git a/chrome/browser/ui/views/options/advanced_contents_view.cc b/chrome/browser/ui/views/options/advanced_contents_view.cc index 0595dc3..eb4f4bf 100644 --- a/chrome/browser/ui/views/options/advanced_contents_view.cc +++ b/chrome/browser/ui/views/options/advanced_contents_view.cc @@ -136,7 +136,7 @@ void FileDisplayArea::SetFile(const FilePath& file_path) { base::i18n::WrapPathWithLTRFormatting(file_path, &localized_file_path); text_field_->SetText(UTF16ToWide(localized_file_path)); } else { - text_field_->SetText(file_path.ToWStringHack()); + text_field_->SetText(file_path.LossyDisplayName()); } } diff --git a/chrome/browser/ui/views/shell_dialogs_win.cc b/chrome/browser/ui/views/shell_dialogs_win.cc index b643c34..0d3953c 100644 --- a/chrome/browser/ui/views/shell_dialogs_win.cc +++ b/chrome/browser/ui/views/shell_dialogs_win.cc @@ -698,13 +698,12 @@ void SelectFileDialogImpl::ExecuteSelectFile( params.run_state.owner, &path); } else if (params.type == SELECT_SAVEAS_FILE) { - std::wstring path_as_wstring = path.ToWStringHack(); + std::wstring path_as_wstring = path.value(); success = SaveFileAsWithFilter(params.run_state.owner, - params.default_path.ToWStringHack(), filter, + params.default_path.value(), filter, params.default_extension, false, &filter_index, &path_as_wstring); - if (success) { - path = FilePath::FromWStringHack(path_as_wstring); - } + if (success) + path = FilePath(path_as_wstring); DisableOwner(params.run_state.owner); } else if (params.type == SELECT_OPEN_FILE) { success = RunOpenFileDialog(params.title, filter, diff --git a/chrome/browser/ui/views/user_data_dir_dialog.cc b/chrome/browser/ui/views/user_data_dir_dialog.cc index 28f8763..0794d63 100644 --- a/chrome/browser/ui/views/user_data_dir_dialog.cc +++ b/chrome/browser/ui/views/user_data_dir_dialog.cc @@ -28,7 +28,7 @@ UserDataDirDialog::UserDataDirDialog(const FilePath& user_data_dir) is_blocking_(true) { std::wstring message_text = UTF16ToWide(l10n_util::GetStringFUTF16( IDS_CANT_WRITE_USER_DIRECTORY_SUMMARY, - WideToUTF16Hack(user_data_dir.ToWStringHack()))); + user_data_dir.LossyDisplayName())); const int kDialogWidth = 400; message_box_view_ = new MessageBoxView( ui::MessageBoxFlags::kIsConfirmMessageBox, diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index c9777e0..fb96f92 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -1244,8 +1244,7 @@ void Extension::DecodeIconFromPath(const FilePath& icon_path, std::string file_contents; if (!file_util::ReadFileToString(icon_path, &file_contents)) { - LOG(ERROR) << "Could not read icon file: " - << WideToUTF8(icon_path.ToWStringHack()); + LOG(ERROR) << "Could not read icon file: " << icon_path.LossyDisplayName(); return; } @@ -1257,7 +1256,7 @@ void Extension::DecodeIconFromPath(const FilePath& icon_path, *decoded = decoder.Decode(data, file_contents.length()); if (decoded->empty()) { LOG(ERROR) << "Could not decode icon file: " - << WideToUTF8(icon_path.ToWStringHack()); + << icon_path.LossyDisplayName(); return; } diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc index 44668e8..7aef3728 100644 --- a/chrome/common/extensions/extension_file_util.cc +++ b/chrome/common/extensions/extension_file_util.cc @@ -161,7 +161,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { if (!file_util::PathExists(image_path)) { *error = l10n_util::GetStringFUTF8(IDS_EXTENSION_INVALID_IMAGE_PATH, - WideToUTF16(image_path.ToWStringHack())); + image_path.LossyDisplayName()); return false; } } @@ -203,7 +203,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_PLUGIN_PATH_FAILED, - WideToUTF16(plugin.path.ToWStringHack())); + plugin.path.LossyDisplayName()); return false; } } @@ -250,7 +250,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_BACKGROUND_PAGE_FAILED, - WideToUTF16(page_path.ToWStringHack())); + page_path.LossyDisplayName()); return false; } } @@ -265,7 +265,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_OPTIONS_PAGE_FAILED, - WideToUTF16(options_path.ToWStringHack())); + options_path.LossyDisplayName()); return false; } } @@ -280,7 +280,7 @@ bool ValidateExtension(Extension* extension, std::string* error) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_LOAD_SIDEBAR_PAGE_FAILED, - WideToUTF16(page_path.ToWStringHack())); + page_path.LossyDisplayName()); return false; } } @@ -312,15 +312,21 @@ void GarbageCollectExtensions( FilePath extension_path; for (extension_path = enumerator.Next(); !extension_path.value().empty(); extension_path = enumerator.Next()) { - std::string extension_id = WideToASCII( - extension_path.BaseName().ToWStringHack()); + std::string extension_id; + + FilePath basename = extension_path.BaseName(); + if (IsStringASCII(basename.value())) { + extension_id = UTF16ToASCII(basename.LossyDisplayName()); + if (!Extension::IdIsValid(extension_id)) + extension_id.clear(); + } // Delete directories that aren't valid IDs. - if (!Extension::IdIsValid(extension_id)) { + if (extension_id.empty()) { LOG(WARNING) << "Invalid extension ID encountered in extensions " - "directory: " << extension_id; + "directory: " << basename.value(); VLOG(1) << "Deleting invalid extension directory " - << WideToASCII(extension_path.ToWStringHack()) << "."; + << extension_path.value() << "."; file_util::Delete(extension_path, true); // Recursive. continue; } @@ -333,7 +339,7 @@ void GarbageCollectExtensions( // complete, for example, when a plugin is in use at uninstall time. if (iter == extension_paths.end()) { VLOG(1) << "Deleting unreferenced install for directory " - << WideToASCII(extension_path.ToWStringHack()) << "."; + << extension_path.LossyDisplayName() << "."; file_util::Delete(extension_path, true); // Recursive. continue; } @@ -348,7 +354,7 @@ void GarbageCollectExtensions( version_dir = versions_enumerator.Next()) { if (version_dir.BaseName() != iter->second.BaseName()) { VLOG(1) << "Deleting old version for directory " - << WideToASCII(version_dir.ToWStringHack()) << "."; + << version_dir.LossyDisplayName() << "."; file_util::Delete(version_dir, true); // Recursive. } } @@ -428,7 +434,7 @@ static bool ValidateLocaleInfo(const Extension& extension, std::string* error) { if (!file_util::PathExists(messages_path)) { *error = base::StringPrintf( "%s %s", errors::kLocalesMessagesFileMissing, - WideToUTF8(messages_path.ToWStringHack()).c_str()); + UTF16ToUTF8(messages_path.LossyDisplayName()).c_str()); return false; } @@ -454,14 +460,14 @@ static bool IsScriptValid(const FilePath& path, !file_util::ReadFileToString(path, &content)) { *error = l10n_util::GetStringFUTF8( message_id, - WideToUTF16(relative_path.ToWStringHack())); + relative_path.LossyDisplayName()); return false; } if (!IsStringUTF8(content)) { *error = l10n_util::GetStringFUTF8( IDS_EXTENSION_BAD_FILE_ENCODING, - WideToUTF16(relative_path.ToWStringHack())); + relative_path.LossyDisplayName()); return false; } diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index 632d873..16049e8 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -611,14 +611,14 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, if (!exposed_dir.empty()) { result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, sandbox::TargetPolicy::FILES_ALLOW_ANY, - exposed_dir.ToWStringHack().c_str()); + exposed_dir.value().c_str()); if (result != sandbox::SBOX_ALL_OK) return 0; FilePath exposed_files = exposed_dir.AppendASCII("*"); result = policy->AddRule(sandbox::TargetPolicy::SUBSYS_FILES, sandbox::TargetPolicy::FILES_ALLOW_ANY, - exposed_files.ToWStringHack().c_str()); + exposed_files.value().c_str()); if (result != sandbox::SBOX_ALL_OK) return 0; } diff --git a/chrome/common/zip.cc b/chrome/common/zip.cc index 3e24b53..d5ff5d0 100644 --- a/chrome/common/zip.cc +++ b/chrome/common/zip.cc @@ -206,7 +206,7 @@ static bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; if (stream.Open(src_dir, flags) != 0) { LOG(ERROR) << "Could not open stream for path " - << WideToASCII(src_dir.ToWStringHack()); + << src_dir.value(); return false; } @@ -217,7 +217,7 @@ static bool AddFileToZip(zipFile zip_file, const FilePath& src_dir) { if (num_bytes > 0) { if (ZIP_OK != zipWriteInFileInZip(zip_file, buf, num_bytes)) { LOG(ERROR) << "Could not write data to zip for path " - << WideToASCII(src_dir.ToWStringHack()); + << src_dir.value(); return false; } } @@ -296,7 +296,7 @@ bool Zip(const FilePath& src_dir, const FilePath& dest_file, file_util::FileEnumerator::DIRECTORIES)); for (FilePath path = file_enumerator.Next(); !path.value().empty(); path = file_enumerator.Next()) { - if (!include_hidden_files && path.BaseName().ToWStringHack()[0] == L'.') + if (!include_hidden_files && path.BaseName().value()[0] == '.') continue; if (!AddEntryToZip(zip_file, path, src_dir)) { diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index 1f52295..402ef68 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -484,7 +484,7 @@ std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { PathService::Get(base::DIR_PROGRAM_FILES, &path); else PathService::Get(base::DIR_LOCAL_APP_DATA, &path); - return path.ToWStringHack(); + return path.value(); } FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { diff --git a/chrome/test/ui/ui_test_suite.cc b/chrome/test/ui/ui_test_suite.cc index bde938c..0f804f6 100644 --- a/chrome/test/ui/ui_test_suite.cc +++ b/chrome/test/ui/ui_test_suite.cc @@ -119,7 +119,7 @@ void UITestSuite::LoadCrashService() { } FilePath crash_service = exe_dir.Append(L"crash_service.exe"); - if (!base::LaunchApp(crash_service.ToWStringHack(), false, false, + if (!base::LaunchApp(crash_service.value(), false, false, &crash_service_)) { printf("Couldn't start crash_service.exe, so this ui_test run won't tell " \ "you if any test crashes!\n"); diff --git a/chrome/tools/crash_service/main.cc b/chrome/tools/crash_service/main.cc index b9cabec6..ae802ab 100644 --- a/chrome/tools/crash_service/main.cc +++ b/chrome/tools/crash_service/main.cc @@ -55,7 +55,7 @@ int __stdcall wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd_line, VLOG(1) << "session start. cmdline is [" << cmd_line << "]"; - CrashService crash_service(operating_dir.ToWStringHack()); + CrashService crash_service(operating_dir.value()); if (!crash_service.Initialize(::GetCommandLineW())) return 1; diff --git a/printing/printed_document.cc b/printing/printed_document.cc index 0360b5b..56a340f 100644 --- a/printing/printed_document.cc +++ b/printing/printed_document.cc @@ -251,9 +251,9 @@ void PrintedDocument::DebugDump(const PrintedPage& page) { filename += ASCIIToUTF16("_.emf"); #if defined(OS_WIN) page.native_metafile()->SaveTo( - g_debug_dump_info.Get().debug_dump_path.Append(filename).ToWStringHack()); + g_debug_dump_info.Get().debug_dump_path.Append(filename).value()); #else // OS_WIN - NOTIMPLEMENTED(); + NOTIMPLEMENTED(); // TODO: convert SaveTo to accept a FilePath #endif // OS_WIN } diff --git a/views/drag_utils.cc b/views/drag_utils.cc index 23622ae..43fc3d4 100644 --- a/views/drag_utils.cc +++ b/views/drag_utils.cc @@ -74,7 +74,7 @@ void CreateDragImageForFile(const FilePath& file_name, // Paint the icon. canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0); - std::wstring name = file_name.BaseName().ToWStringHack(); + std::wstring name = UTF16ToWide(file_name.BaseName().LossyDisplayName()); #if defined(OS_WIN) // Paint the file name. We inset it one pixel to allow room for the halo. canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE, diff --git a/webkit/plugins/npapi/plugin_list_win.cc b/webkit/plugins/npapi/plugin_list_win.cc index eaa64a7..22eb670 100644 --- a/webkit/plugins/npapi/plugin_list_win.cc +++ b/webkit/plugins/npapi/plugin_list_win.cc @@ -343,9 +343,9 @@ bool PluginList::ShouldLoadPlugin(const WebPluginInfo& info, (*plugin_groups)[i]->web_plugins_info(); for (size_t j = 0; j < plugins.size(); ++j) { std::wstring plugin1 = - StringToLowerASCII(plugins[j].path.BaseName().ToWStringHack()); + StringToLowerASCII(plugins[j].path.BaseName().value()); std::wstring plugin2 = - StringToLowerASCII(info.path.BaseName().ToWStringHack()); + StringToLowerASCII(info.path.BaseName().value()); if ((plugin1 == plugin2 && HaveSharedMimeType(plugins[j], info)) || (plugin1 == kJavaDeploy1 && plugin2 == kJavaDeploy2) || (plugin1 == kJavaDeploy2 && plugin2 == kJavaDeploy1)) { |