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
3 // found in the LICENSE file.
5 #include "printing/print_settings_initializer.h"
11 #include "base/i18n/time_formatting.h"
12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h"
15 #include "base/values.h"
16 #include "printing/print_job_constants.h"
17 #include "printing/print_settings.h"
18 #include "printing/units.h"
19 #include "ui/base/resource/resource_bundle.h"
20 #include "ui/gfx/font_list.h"
21 #include "ui/gfx/text_elider.h"
24 using base::DictionaryValue
;
28 void PrintSettingsInitializer::InitHeaderFooterStrings(
29 const DictionaryValue
& job_settings
,
30 PrintSettings
* print_settings
) {
31 if (!job_settings
.GetBoolean(kSettingHeaderFooterEnabled
,
32 &print_settings
->display_header_footer
)) {
35 if (!print_settings
->display_header_footer
)
38 string16 date
= base::TimeFormatShortDateNumeric(base::Time::Now());
41 if (!job_settings
.GetString(kSettingHeaderFooterTitle
, &title
) ||
42 !job_settings
.GetString(kSettingHeaderFooterURL
, &url
)) {
46 print_settings
->date
= date
;
47 print_settings
->title
= title
;
48 const gfx::FontList
& default_fonts
=
49 ui::ResourceBundle::GetSharedInstance().GetFontList(
50 ui::ResourceBundle::BaseFont
);
51 print_settings
->url
= gfx::ElideUrl(GURL(url
), default_fonts
, 0,
55 } // namespace printing