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

Side by Side Diff: chrome/browser/ui/webui/web_ui_util.cc

Issue 11881055: Simplify WebUI data sources. Currently WebUI data sources implement a URLDataSourceDelegate interfa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix issue in about_ui exposed by cros tests Created 7 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/web_ui_util.h" 5 #include "chrome/browser/ui/webui/web_ui_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/debug/trace_event.h"
11 #include "base/i18n/rtl.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/memory/ref_counted_memory.h" 13 #include "base/memory/ref_counted_memory.h"
12 #include "base/values.h"
13 #include "chrome/browser/disposition_utils.h" 14 #include "chrome/browser/disposition_utils.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "net/base/escape.h" 16 #include "net/base/escape.h"
17 #include "grit/platform_locale_settings.h"
16 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/codec/png_codec.h" 19 #include "ui/gfx/codec/png_codec.h"
18 #include "ui/gfx/image/image_skia.h" 20 #include "ui/gfx/image/image_skia.h"
21 #include "ui/base/l10n/l10n_util.h"
19 22
20 #include "base/debug/trace_event.h" 23 #if defined (TOOLKIT_GTK)
24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/font.h"
26 #endif
27
28 #if defined(OS_WIN)
29 #include "base/win/windows_version.h"
30 #endif
21 31
22 namespace { 32 namespace {
23 33
24 struct ScaleFactorMap { 34 struct ScaleFactorMap {
25 const char* name; 35 const char* name;
26 ui::ScaleFactor scale_factor; 36 ui::ScaleFactor scale_factor;
27 }; 37 };
28 38
29 const ScaleFactorMap kScaleFactorMap[] = { 39 const ScaleFactorMap kScaleFactorMap[] = {
30 { "1x", ui::SCALE_FACTOR_100P }, 40 { "1x", ui::SCALE_FACTOR_100P },
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 pos + 1, stripped_path.length() - pos - 1), &factor)) { 124 pos + 1, stripped_path.length() - pos - 1), &factor)) {
115 // Strip scale factor specification from path. 125 // Strip scale factor specification from path.
116 stripped_path.remove_suffix(stripped_path.length() - pos); 126 stripped_path.remove_suffix(stripped_path.length() - pos);
117 stripped_path.CopyToString(path); 127 stripped_path.CopyToString(path);
118 } 128 }
119 if (scale_factor) 129 if (scale_factor)
120 *scale_factor = factor; 130 *scale_factor = factor;
121 } 131 }
122 } 132 }
123 133
134 // static
135 void SetFontAndTextDirection(DictionaryValue* localized_strings) {
136 int web_font_family_id = IDS_WEB_FONT_FAMILY;
137 int web_font_size_id = IDS_WEB_FONT_SIZE;
138 #if defined(OS_WIN)
139 // Vary font settings for Windows XP.
140 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
141 web_font_family_id = IDS_WEB_FONT_FAMILY_XP;
142 web_font_size_id = IDS_WEB_FONT_SIZE_XP;
143 }
144 #endif
145
146 std::string font_family = l10n_util::GetStringUTF8(web_font_family_id);
147
148 #if defined(TOOLKIT_GTK)
149 // Use the system font on Linux/GTK. Keep the hard-coded font families as
150 // backup in case for some crazy reason this one isn't available.
151 font_family = ui::ResourceBundle::GetSharedInstance().GetFont(
152 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family;
153 #endif
154
155 localized_strings->SetString("fontfamily", font_family);
156 localized_strings->SetString("fontsize",
157 l10n_util::GetStringUTF8(web_font_size_id));
158 localized_strings->SetString("textdirection",
159 base::i18n::IsRTL() ? "rtl" : "ltr");
160 }
161
124 } // namespace web_ui_util 162 } // namespace web_ui_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698