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/string_number_conversions.h"
13 #include "base/time.h"
14 #include "base/utf_string_conversions.h"
15 #include "base/values.h"
16 #include "googleurl/src/gurl.h"
17 #include "printing/print_job_constants.h"
18 #include "printing/print_settings.h"
19 #include "printing/units.h"
20 #include "ui/base/text/text_elider.h"
22 using base::DictionaryValue
;
26 void PrintSettingsInitializer::InitHeaderFooterStrings(
27 const DictionaryValue
& job_settings
,
28 PrintSettings
* print_settings
) {
29 if (!job_settings
.GetBoolean(kSettingHeaderFooterEnabled
,
30 &print_settings
->display_header_footer
)) {
33 if (!print_settings
->display_header_footer
)
36 string16 date
= base::TimeFormatShortDateNumeric(base::Time::Now());
39 if (!job_settings
.GetString(kSettingHeaderFooterTitle
, &title
) ||
40 !job_settings
.GetString(kSettingHeaderFooterURL
, &url
)) {
44 print_settings
->date
= date
;
45 print_settings
->title
= title
;
46 print_settings
->url
= ui::ElideUrl(GURL(url
), gfx::Font(), 0, std::string());
49 } // namespace printing