| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ui/base/webui/web_ui_util.h" | 5 #include "ui/base/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" | 10 #include "base/debug/trace_event.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 pos + 1, stripped_path.length() - pos - 1), &factor)) { | 118 pos + 1, stripped_path.length() - pos - 1), &factor)) { |
| 119 // Strip scale factor specification from path. | 119 // Strip scale factor specification from path. |
| 120 stripped_path.remove_suffix(stripped_path.length() - pos); | 120 stripped_path.remove_suffix(stripped_path.length() - pos); |
| 121 stripped_path.CopyToString(path); | 121 stripped_path.CopyToString(path); |
| 122 } | 122 } |
| 123 if (scale_factor) | 123 if (scale_factor) |
| 124 *scale_factor = factor; | 124 *scale_factor = factor; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 // static | 128 std::string GetFontFamily() { |
| 129 void SetFontAndTextDirection(base::DictionaryValue* localized_strings) { | 129 std::string font_family = l10n_util::GetStringUTF8( |
| 130 int web_font_family_id = IDS_WEB_FONT_FAMILY; | |
| 131 int web_font_size_id = IDS_WEB_FONT_SIZE; | |
| 132 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
| 133 // Vary font settings for Windows XP. | 131 base::win::GetVersion() < base::win::VERSION_VISTA ? |
| 134 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 132 IDS_WEB_FONT_FAMILY_XP : |
| 135 web_font_family_id = IDS_WEB_FONT_FAMILY_XP; | |
| 136 web_font_size_id = IDS_WEB_FONT_SIZE_XP; | |
| 137 } | |
| 138 #endif | 133 #endif |
| 139 | 134 IDS_WEB_FONT_FAMILY); |
| 140 std::string font_family = l10n_util::GetStringUTF8(web_font_family_id); | |
| 141 | 135 |
| 142 // TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced | 136 // TODO(dnicoara) Remove Ozone check when PlatformFont support is introduced |
| 143 // into Ozone: crbug.com/320050 | 137 // into Ozone: crbug.com/320050 |
| 144 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE) | 138 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && !defined(USE_OZONE) |
| 145 font_family = ui::ResourceBundle::GetSharedInstance().GetFont( | 139 font_family = ui::ResourceBundle::GetSharedInstance().GetFont( |
| 146 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family; | 140 ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family; |
| 147 #endif | 141 #endif |
| 148 | 142 |
| 149 localized_strings->SetString("fontfamily", font_family); | 143 return font_family; |
| 150 localized_strings->SetString("fontsize", | 144 } |
| 151 l10n_util::GetStringUTF8(web_font_size_id)); | 145 |
| 152 localized_strings->SetString("textdirection", | 146 std::string GetFontSize() { |
| 153 base::i18n::IsRTL() ? "rtl" : "ltr"); | 147 return l10n_util::GetStringUTF8( |
| 148 #if defined(OS_WIN) |
| 149 base::win::GetVersion() < base::win::VERSION_VISTA ? |
| 150 IDS_WEB_FONT_SIZE_XP : |
| 151 #endif |
| 152 IDS_WEB_FONT_SIZE); |
| 153 } |
| 154 |
| 155 std::string GetTextDirection() { |
| 156 return base::i18n::IsRTL() ? "rtl" : "ltr"; |
| 157 } |
| 158 |
| 159 void SetFontAndTextDirection(base::DictionaryValue* localized_strings) { |
| 160 localized_strings->SetString("fontfamily", GetFontFamily()); |
| 161 localized_strings->SetString("fontsize", GetFontSize()); |
| 162 localized_strings->SetString("textdirection", GetTextDirection()); |
| 154 } | 163 } |
| 155 | 164 |
| 156 } // namespace webui | 165 } // namespace webui |
| OLD | NEW |