cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / printing / print_settings_initializer.cc
blob867f4dcace26b506dacf86d51df96810800956f4
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"
7 #include <algorithm>
8 #include <cmath>
9 #include <string>
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/text/text_elider.h"
20 #include "ui/gfx/font.h"
21 #include "url/gurl.h"
23 using base::DictionaryValue;
25 namespace printing {
27 void PrintSettingsInitializer::InitHeaderFooterStrings(
28 const DictionaryValue& job_settings,
29 PrintSettings* print_settings) {
30 if (!job_settings.GetBoolean(kSettingHeaderFooterEnabled,
31 &print_settings->display_header_footer)) {
32 NOTREACHED();
34 if (!print_settings->display_header_footer)
35 return;
37 string16 date = base::TimeFormatShortDateNumeric(base::Time::Now());
38 string16 title;
39 string16 url;
40 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
41 !job_settings.GetString(kSettingHeaderFooterURL, &url)) {
42 NOTREACHED();
45 print_settings->date = date;
46 print_settings->title = title;
47 print_settings->url = ui::ElideUrl(GURL(url), gfx::Font(), 0, std::string());
50 } // namespace printing