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

Side by Side Diff: printing/print_settings_initializer.cc

Issue 8392017: Change string16 to std::string in the gfx::Font() interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add 'UTF-8' everywhere in the comments Created 9 years, 1 month 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
« no previous file with comments | « chrome/common/badge_util.cc ('k') | ui/gfx/font.h » ('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 #include <string>
10 10
(...skipping 24 matching lines...) Expand all
35 35
36 string16 date = base::TimeFormatShortDateNumeric(base::Time::Now()); 36 string16 date = base::TimeFormatShortDateNumeric(base::Time::Now());
37 string16 title; 37 string16 title;
38 std::string url; 38 std::string url;
39 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) || 39 if (!job_settings.GetString(kSettingHeaderFooterTitle, &title) ||
40 !job_settings.GetString(kSettingHeaderFooterURL, &url)) { 40 !job_settings.GetString(kSettingHeaderFooterURL, &url)) {
41 NOTREACHED(); 41 NOTREACHED();
42 } 42 }
43 43
44 gfx::Font font( 44 gfx::Font font(
45 UTF8ToUTF16(kSettingHeaderFooterFontName), 45 kSettingHeaderFooterFontName,
46 ceil(ConvertPointsToPixelDouble(kSettingHeaderFooterFontSize))); 46 ceil(ConvertPointsToPixelDouble(kSettingHeaderFooterFontSize)));
47 double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble( 47 double segment_width = GetHeaderFooterSegmentWidth(ConvertUnitDouble(
48 print_settings->page_setup_device_units().physical_size().width(), 48 print_settings->page_setup_device_units().physical_size().width(),
49 print_settings->device_units_per_inch(), kPixelsPerInch)); 49 print_settings->device_units_per_inch(), kPixelsPerInch));
50 date = ui::ElideText(date, font, segment_width, false); 50 date = ui::ElideText(date, font, segment_width, false);
51 print_settings->date = date; 51 print_settings->date = date;
52 52
53 // 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
54 // enough, increase the available space for the title. 54 // enough, increase the available space for the title.
55 // Assumes there is no header text to RIGHT of title. 55 // Assumes there is no header text to RIGHT of title.
56 double date_width = font.GetStringWidth(date); 56 double date_width = font.GetStringWidth(date);
57 double max_title_width = std::min(2 * segment_width, 57 double max_title_width = std::min(2 * segment_width,
58 2 * (segment_width - date_width) + 58 2 * (segment_width - date_width) +
59 segment_width); 59 segment_width);
60 print_settings->title = ui::ElideText(title, font, max_title_width, false); 60 print_settings->title = ui::ElideText(title, font, max_title_width, false);
61 61
62 double max_url_width = 2 * segment_width; 62 double max_url_width = 2 * segment_width;
63 GURL gurl(url); 63 GURL gurl(url);
64 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());
65 } 65 }
66 66
67 } // namespace printing 67 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/common/badge_util.cc ('k') | ui/gfx/font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698