Skip to content

Commit

Permalink
Use JS Date().toLocaleDateString() to format date in header. Fixed is…
Browse files Browse the repository at this point in the history
…sues with local date formats.

Remove date from printing settings.

BUG=103111

Review URL: https://codereview.chromium.org/30443003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230283 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
vitalybuka@chromium.org committed Oct 23, 2013
1 parent 452fb14 commit ede33b4
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion chrome/browser/printing/printing_message_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ void RenderParamsFromPrintSettings(const printing::PrintSettings& settings,
params->supports_alpha_blend = settings.supports_alpha_blend();
params->should_print_backgrounds = settings.should_print_backgrounds;
params->display_header_footer = settings.display_header_footer;
params->date = settings.date;
params->title = settings.title;
params->url = settings.url;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@
options['bottomMargin']);
footer.style.height = pixels(options['bottomMargin']);

document.querySelector('#date span').innerText = options['date'];
document.querySelector('#date span').innerText =
new Date(options['date']).toLocaleDateString();
document.querySelector('#title span').innerText = options['title'];

document.querySelector('#url span').innerText = options['url'];
document.querySelector('#page_number span').innerText = options['pageNumber'];

Expand Down
2 changes: 0 additions & 2 deletions chrome/common/print_messages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ PrintMsg_Print_Params::PrintMsg_Print_Params()
print_scaling_option(WebKit::WebPrintScalingOptionSourceSize),
print_to_pdf(false),
display_header_footer(false),
date(),
title(),
url(),
should_print_backgrounds(false) {
Expand All @@ -54,7 +53,6 @@ void PrintMsg_Print_Params::Reset() {
print_scaling_option = WebKit::WebPrintScalingOptionSourceSize;
print_to_pdf = false;
display_header_footer = false;
date = string16();
title = string16();
url = string16();
should_print_backgrounds = false;
Expand Down
4 changes: 0 additions & 4 deletions chrome/common/print_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ struct PrintMsg_Print_Params {
WebKit::WebPrintScalingOption print_scaling_option;
bool print_to_pdf;
bool display_header_footer;
string16 date;
string16 title;
string16 url;
bool should_print_backgrounds;
Expand Down Expand Up @@ -137,9 +136,6 @@ IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
// Specifies if the header and footer should be rendered.
IPC_STRUCT_TRAITS_MEMBER(display_header_footer)

// Date string to be printed as header if requested by the user.
IPC_STRUCT_TRAITS_MEMBER(date)

// Title string to be printed as header if requested by the user.
IPC_STRUCT_TRAITS_MEMBER(title)

Expand Down
4 changes: 0 additions & 4 deletions chrome/renderer/mock_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ MockPrinter::MockPrinter()
preview_request_id_(0),
print_scaling_option_(WebKit::WebPrintScalingOptionSourceSize),
display_header_footer_(false),
date_(ASCIIToUTF16("date")),
title_(ASCIIToUTF16("title")),
url_(ASCIIToUTF16("url")),
use_invalid_settings_(false) {
Expand Down Expand Up @@ -119,7 +118,6 @@ void MockPrinter::SetDefaultPrintSettings(const PrintMsg_Print_Params& params) {
margin_left_ = params.margin_left;
margin_top_ = params.margin_top;
display_header_footer_ = params.display_header_footer;
date_ = params.date;
title_ = params.title;
url_ = params.url;
}
Expand Down Expand Up @@ -162,7 +160,6 @@ void MockPrinter::ScriptedPrint(int cookie,
settings->params.print_to_pdf = print_to_pdf_;
settings->params.preview_request_id = preview_request_id_;
settings->params.display_header_footer = display_header_footer_;
settings->params.date = date_;
settings->params.title = title_;
settings->params.url = url_;
printer_status_ = PRINTER_PRINTING;
Expand Down Expand Up @@ -312,7 +309,6 @@ void MockPrinter::SetPrintParams(PrintMsg_Print_Params* params) {
params->print_to_pdf = print_to_pdf_;
params->preview_request_id = preview_request_id_;
params->display_header_footer = display_header_footer_;
params->date = date_;
params->title = title_;
params->url = url_;
}
1 change: 0 additions & 1 deletion chrome/renderer/mock_printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class MockPrinter {

// Used for displaying headers and footers.
bool display_header_footer_;
string16 date_;
string16 title_;
string16 url_;

Expand Down
4 changes: 2 additions & 2 deletions chrome/renderer/printing/print_web_view_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1483,8 +1483,8 @@ bool PrintWebViewHelper::UpdatePrintSettings(
// Header/Footer: Set |header_footer_info_|.
if (settings.params.display_header_footer) {
header_footer_info_.reset(new base::DictionaryValue());
header_footer_info_->SetString(kSettingHeaderFooterDate,
settings.params.date);
header_footer_info_->SetDouble(kSettingHeaderFooterDate,
base::Time::Now().ToJsTime());
header_footer_info_->SetString(kSettingHeaderFooterURL,
settings.params.url);
header_footer_info_->SetString(kSettingHeaderFooterTitle,
Expand Down
1 change: 0 additions & 1 deletion printing/print_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ void PrintSettings::Clear() {
max_shrink = 2.;
desired_dpi = 72;
selection_only = false;
date = base::string16();
title = base::string16();
url = base::string16();
display_header_footer = false;
Expand Down
1 change: 0 additions & 1 deletion printing/print_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class PRINTING_EXPORT PrintSettings {
void SetOrientation(bool landscape);

// Strings to be printed as headers and footers if requested by the user.
base::string16 date;
base::string16 title;
base::string16 url;

Expand Down
3 changes: 0 additions & 3 deletions printing/print_settings_initializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <cmath>
#include <string>

#include "base/i18n/time_formatting.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
Expand All @@ -33,15 +32,13 @@ void PrintSettingsInitializer::InitHeaderFooterStrings(
if (!print_settings->display_header_footer)
return;

base::string16 date = base::TimeFormatShortDateNumeric(base::Time::Now());
base::string16 title;
base::string16 url;
if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
!job_settings.GetString(kSettingHeaderFooterURL, &url)) {
NOTREACHED();
}

print_settings->date = date;
print_settings->title = title;
const gfx::FontList& default_fonts =
ui::ResourceBundle::GetSharedInstance().GetFontList(
Expand Down

0 comments on commit ede33b4

Please sign in to comment.