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

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: Rebasing 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
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | printing/print_job_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 08f506a787b480d3ee511441b2603387e2e32120..101b8b6058198d0230a4cdc7860e2019c70bdf9b 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"
@@ -202,11 +205,24 @@ void PrintPreviewHandler::HandlePrint(const ListValue* args) {
if (!settings.get())
return;
- bool print_to_pdf;
+ bool print_to_pdf = false;
settings->GetBoolean(printing::kSettingPrintToPDF, &print_to_pdf);
if (print_to_pdf) {
- SelectFile();
+ // Pre-populating select file dialog with print job title.
+ FilePath::StringType print_job_title;
+ bool ret = settings->GetString(printing::kPrintJobTitle, &print_job_title);
+ if (!ret || print_job_title.length() == 0)
kmadhusu 2011/04/05 20:57:48 If the "print_job_title" is empty, I think its bet
dpapad 2011/04/09 01:38:06 Done.
+ return;
+
+ file_util::ReplaceIllegalCharactersInPath(&print_job_title, '_');
+ FilePath default_path;
+ PathService::Get(chrome::DIR_USER_DOCUMENTS, &default_path);
+ FilePath default_filename(print_job_title);
+ default_filename =
+ default_filename.ReplaceExtension(FILE_PATH_LITERAL("pdf"));
+
+ SelectFile(default_path.Append(default_filename));
} else {
RenderViewHost* rvh = web_ui_->GetRenderViewHost();
rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->routing_id(), *settings));
@@ -240,7 +256,7 @@ void PrintPreviewHandler::ProcessLandscapeSetting(
}
}
-void PrintPreviewHandler::SelectFile() {
+void PrintPreviewHandler::SelectFile(const FilePath& default_path) {
SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.resize(1);
file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("pdf"));
@@ -251,7 +267,7 @@ void PrintPreviewHandler::SelectFile() {
select_file_dialog_->SelectFile(
SelectFileDialog::SELECT_SAVEAS_FILE,
string16(),
- FilePath(),
+ default_path,
&file_type_info,
0,
FILE_PATH_LITERAL(""),
« no previous file with comments | « chrome/browser/ui/webui/print_preview_handler.h ('k') | printing/print_job_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698