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

Unified Diff: chrome/browser/ui/webui/print_preview_handler.cc

Issue 6759044: Prepopulating "Print To PDF" select file dialog with a suggested filename and path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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
Index: chrome/browser/ui/webui/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc
index 7e31d633582906575f67a3803ff46940d74a71d6..32b8c9a850fbca5d0f9f11dc66a4db6499ca6b90 100644
--- a/chrome/browser/ui/webui/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview_handler.cc
@@ -6,13 +6,16 @@
#include <string>
+#include "base/i18n/file_util_icu.h"
#include "base/json/json_reader.h"
+#include "base/path_service.h"
#include "base/threading/thread.h"
#include "base/values.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/printing/print_preview_tab_controller.h"
#include "chrome/browser/ui/webui/print_preview_ui_html_source.h"
#include "chrome/browser/ui/webui/print_preview_ui.h"
+#include "chrome/common/chrome_paths.h"
#include "chrome/common/print_messages.h"
#include "content/browser/browser_thread.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -199,7 +202,15 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
if (print_to_pdf) {
- SelectFile();
+ // Pre-populating select file dialog with print job title.
+ std::string print_job_title;
+ settings->GetString(printing::kPrintJobTitle, &print_job_title);
Lei Zhang 2011/04/01 01:05:35 Check the return value and handle both the failure
dpapad 2011/04/01 02:32:15 Done.
+ file_util::ReplaceIllegalCharactersInPath(&print_job_title, '_');
Lei Zhang 2011/04/01 01:05:35 This won't work on Windows. You need to write this
dpapad 2011/04/01 02:32:15 Done, without the ifdefs (thanks to overloading ;>
+ FilePath default_path;
+ PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path);
+ FilePath default_filename(print_job_title + ".pdf");
+
+ SelectFile(default_path.Append(default_filename));
} else {
RenderViewHost* rvh = web_ui_->GetRenderViewHost();
rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings));
@@ -230,7 +241,7 @@ void PrintPreviewHandler::ProcessLandscapeSetting(
}
}
-void PrintPreviewHandler::SelectFile() {
+void PrintPreviewHandler::SelectFile(const FilePath& default_filename) {
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.resize(1);
file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf"));
@@ -241,7 +252,7 @@ void PrintPreviewHandler::SelectFile() {
select_file_dialog_->SelectFile(
SelectFileDialog::SELECT_SAVEAS_FILE,
string16(),
- FilePath(),
+ default_filename,
&file_type_info,
0,
FILE_PATH_LITERAL(""),

Powered by Google App Engine
This is Rietveld 408576698