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

Side by Side Diff: printing/print_settings_initializer.cc

Issue 30443003: Use JS Date().toLocaleDateString() to format date in header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « printing/print_settings.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/print_settings_initializer.h" 5 #include "printing/print_settings_initializer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <string> 9 #include <string>
10 10
11 #include "base/i18n/time_formatting.h"
12 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 13 #include "base/time/time.h"
15 #include "base/values.h" 14 #include "base/values.h"
16 #include "printing/print_job_constants.h" 15 #include "printing/print_job_constants.h"
17 #include "printing/print_settings.h" 16 #include "printing/print_settings.h"
18 #include "printing/units.h" 17 #include "printing/units.h"
19 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/font_list.h" 19 #include "ui/gfx/font_list.h"
21 #include "ui/gfx/text_elider.h" 20 #include "ui/gfx/text_elider.h"
22 #include "url/gurl.h" 21 #include "url/gurl.h"
23 22
24 namespace printing { 23 namespace printing {
25 24
26 void PrintSettingsInitializer::InitHeaderFooterStrings( 25 void PrintSettingsInitializer::InitHeaderFooterStrings(
27 const base::DictionaryValue& job_settings, 26 const base::DictionaryValue& job_settings,
28 PrintSettings* print_settings) { 27 PrintSettings* print_settings) {
29 if (!job_settings.GetBoolean(kSettingHeaderFooterEnabled, 28 if (!job_settings.GetBoolean(kSettingHeaderFooterEnabled,
30 &print_settings->display_header_footer)) { 29 &print_settings->display_header_footer)) {
31 NOTREACHED(); 30 NOTREACHED();
32 } 31 }
33 if (!print_settings->display_header_footer) 32 if (!print_settings->display_header_footer)
34 return; 33 return;
35 34
36 base::string16 date = base::TimeFormatShortDateNumeric(base::Time::Now());
37 base::string16 title; 35 base::string16 title;
38 base::string16 url; 36 base::string16 url;
39 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) || 37 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
40 !job_settings.GetString(kSettingHeaderFooterURL, &url)) { 38 !job_settings.GetString(kSettingHeaderFooterURL, &url)) {
41 NOTREACHED(); 39 NOTREACHED();
42 } 40 }
43 41
44 print_settings->date = date;
45 print_settings->title = title; 42 print_settings->title = title;
46 const gfx::FontList& default_fonts = 43 const gfx::FontList& default_fonts =
47 ui::ResourceBundle::GetSharedInstance().GetFontList( 44 ui::ResourceBundle::GetSharedInstance().GetFontList(
48 ui::ResourceBundle::BaseFont); 45 ui::ResourceBundle::BaseFont);
49 print_settings->url = gfx::ElideUrl(GURL(url), default_fonts, 0, 46 print_settings->url = gfx::ElideUrl(GURL(url), default_fonts, 0,
50 std::string()); 47 std::string());
51 } 48 }
52 49
53 } // namespace printing 50 } // namespace printing
OLDNEW
« no previous file with comments | « printing/print_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698