Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: ui/shell_dialogs/select_file_dialog.cc

Issue 2804793002: Print Preview: Fix failure to save with long page title (Closed)
Patch Set: Remove path check Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698