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

Side by Side Diff: printing/print_settings_initializer.cc

Issue 8334007: Cleanup: Remove unneeded namespaces. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 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') | printing/printed_document_mac.cc » ('j') | 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 10
10 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #include "printing/print_job_constants.h" 17 #include "printing/print_job_constants.h"
17 #include "printing/print_settings.h" 18 #include "printing/print_settings.h"
18 #include "printing/units.h" 19 #include "printing/units.h"
19 #include "ui/base/text/text_elider.h" 20 #include "ui/base/text/text_elider.h"
20 21
21 using base::DictionaryValue; 22 using base::DictionaryValue;
22 using base::Time;
23 using printing::ConvertPointsToPixelDouble;
24 using printing::ConvertUnitDouble;
25 using printing::GetHeaderFooterSegmentWidth;
26 23
27 namespace printing { 24 namespace printing {
28 25
29 void PrintSettingsInitializer::InitHeaderFooterStrings( 26 void PrintSettingsInitializer::InitHeaderFooterStrings(
30 const DictionaryValue& job_settings, 27 const DictionaryValue& job_settings,
31 PrintSettings* print_settings) { 28 PrintSettings* print_settings) {
32 if (!job_settings.GetBoolean(printing::kSettingHeaderFooterEnabled, 29 if (!job_settings.GetBoolean(kSettingHeaderFooterEnabled,
33 &print_settings->display_header_footer)) { 30 &print_settings->display_header_footer)) {
34 NOTREACHED(); 31 NOTREACHED();
35 } 32 }
36 if (!print_settings->display_header_footer) 33 if (!print_settings->display_header_footer)
37 return; 34 return;
38 35
39 string16 date = base::TimeFormatShortDateNumeric(Time::Now()); 36 string16 date = base::TimeFormatShortDateNumeric(base::Time::Now());
40 string16 title; 37 string16 title;
41 std::string url; 38 std::string url;
42 if (!job_settings.GetString(printing::kSettingHeaderFooterTitle, &title) || 39 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
43 !job_settings.GetString(printing::kSettingHeaderFooterURL, &url)) { 40 !job_settings.GetString(kSettingHeaderFooterURL, &url)) {
44 NOTREACHED(); 41 NOTREACHED();
45 } 42 }
46 43
47 gfx::Font font(UTF8ToUTF16(printing::kSettingHeaderFooterFontName), 44 gfx::Font font(
48 ceil(ConvertPointsToPixelDouble( 45 UTF8ToUTF16(kSettingHeaderFooterFontName),
49 printing::kSettingHeaderFooterFontSize))); 46 ceil(ConvertPointsToPixelDouble(kSettingHeaderFooterFontSize)));
50 double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble( 47 double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble(
51 print_settings->page_setup_device_units().physical_size().width(), 48 print_settings->page_setup_device_units().physical_size().width(),
52 print_settings->device_units_per_inch(), 49 print_settings->device_units_per_inch(), kPixelsPerInch));
53 printing::kPixelsPerInch));
54 date = ui::ElideText(date, font, segment_width, false); 50 date = ui::ElideText(date, font, segment_width, false);
55 print_settings->date = date; 51 print_settings->date = date;
56 52
57 // Calculate the available title width. If the date string is not long 53 // Calculate the available title width. If the date string is not long
58 // enough, increase the available space for the title. 54 // enough, increase the available space for the title.
59 // Assumes there is no header text to RIGHT of title. 55 // Assumes there is no header text to RIGHT of title.
60 double date_width = font.GetStringWidth(date); 56 double date_width = font.GetStringWidth(date);
61 double max_title_width = std::min(2 * segment_width, 57 double max_title_width = std::min(2 * segment_width,
62 2 * (segment_width - date_width) + 58 2 * (segment_width - date_width) +
63 segment_width); 59 segment_width);
64 print_settings->title = ui::ElideText(title, font, max_title_width, false); 60 print_settings->title = ui::ElideText(title, font, max_title_width, false);
65 61
66 double max_url_width = 2 * segment_width; 62 double max_url_width = 2 * segment_width;
67 GURL gurl(url); 63 GURL gurl(url);
68 print_settings->url = ui::ElideUrl(gurl, font, max_url_width, std::string()); 64 print_settings->url = ui::ElideUrl(gurl, font, max_url_width, std::string());
69 } 65 }
70 66
71 } // namespace printing 67 } // namespace printing
72
OLDNEW
« no previous file with comments | « printing/print_settings.cc ('k') | printing/printed_document_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698