diff options
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/new_profile_dialog.cc | 14 | ||||
-rw-r--r-- | chrome/browser/views/tab_contents/tab_contents_view_win.cc | 10 |
2 files changed, 14 insertions, 10 deletions
diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc index f0cfded..54ac154 100644 --- a/chrome/browser/views/new_profile_dialog.cc +++ b/chrome/browser/views/new_profile_dialog.cc @@ -65,12 +65,14 @@ bool NewProfileDialog::IsDialogButtonEnabled( MessageBoxFlags::DialogButton button) const { if (button == MessageBoxFlags::DIALOGBUTTON_OK) { std::wstring profile_name = message_box_view_->GetInputText(); - // TODO(munjal): Refactor the function ReplaceIllegalCharacters in - // file_util to something that just checks if there are illegal chars - // since that's what we really need. Also, replaceIllegalChars seems to - // be expensive since it builds a list of illegal characters for each call. - // So at the least fix that. - file_util::ReplaceIllegalCharacters(&profile_name, L'_'); + +#if defined(OS_POSIX) + std::string profile_name_narrow = WideToUTF8(profile_name); + file_util::ReplaceIllegalCharactersInPath(&profile_name_narrow, '_'); + profile_name = UTF8ToWide(profile_name_narrow); +#else + file_util::ReplaceIllegalCharactersInPath(&profile_name, '_'); +#endif return !profile_name.empty() && profile_name == message_box_view_->GetInputText(); } diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 227425f..e1aa377 100644 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -138,10 +138,12 @@ void TabContentsViewWin::StartDragging(const WebDropData& drop_data, file_name = file_name.BaseName().RemoveExtension(); if (file_name.value().empty()) { // Retrieve the name from the URL. - std::wstring fn = net::GetSuggestedFilename(drop_data.url, "", "", L""); - if ((fn.size() + drop_data.file_extension.size() + 1) > MAX_PATH) - fn = fn.substr(0, MAX_PATH - drop_data.file_extension.size() - 2); - file_name = FilePath::FromWStringHack(fn); + file_name = net::GetSuggestedFilename(drop_data.url, "", "", ""); + if (file_name.value().size() + drop_data.file_extension.size() + 1 > + MAX_PATH) { + file_name = FilePath(file_name.value().substr( + 0, MAX_PATH - drop_data.file_extension.size() - 2)); + } } file_name = file_name.ReplaceExtension(drop_data.file_extension); data.SetFileContents(file_name.value(), drop_data.file_contents); |