Chromium Code Reviews| Index: ui/shell_dialogs/select_file_dialog.cc |
| diff --git a/ui/shell_dialogs/select_file_dialog.cc b/ui/shell_dialogs/select_file_dialog.cc |
| index 1aa7a0e26164079e0563943180353d03cdb6c861..8ef4ec26352d639b4c199c9a6dc5a861095a60c2 100644 |
| --- a/ui/shell_dialogs/select_file_dialog.cc |
| +++ b/ui/shell_dialogs/select_file_dialog.cc |
| @@ -5,6 +5,7 @@ |
| #include "ui/shell_dialogs/select_file_dialog.h" |
| #include <stddef.h> |
| +#include <algorithm> |
| #include "base/bind.h" |
| #include "base/location.h" |
| @@ -98,8 +99,19 @@ void SelectFileDialog::SelectFile( |
| return; |
| } |
| + // Shorten filename if necessary. |
| + base::FilePath filename = default_path.BaseName(); |
| + base::FilePath path = default_path; |
| + size_t max_name_length = 255; |
|
Lei Zhang
2017/04/12 19:10:25
const size_t kMaxNameLength ?
rbpotter
2017/04/13 00:25:02
Done.
|
| + if (filename.value().length() > max_name_length) { |
| + base::FilePath::StringType extension = filename.Extension(); |
|
Lei Zhang
2017/04/12 19:10:25
What if the extension is 256 letters long?
rbpotter
2017/04/13 00:25:02
Have addressed this in new patch.
|
| + path = default_path.DirName().Append( |
| + filename.value().substr(0, max_name_length - extension.length())); |
| + path = path.AddExtension(extension); |
| + } |
| + |
| // Call the platform specific implementation of the file selection dialog. |
| - SelectFileImpl(type, title, default_path, file_types, file_type_index, |
| + SelectFileImpl(type, title, path, file_types, file_type_index, |
| default_extension, owning_window, params); |
| } |