| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/font_handler.h" | 5 #include "chrome/browser/ui/webui/settings/font_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 DCHECK(has_font); | 130 DCHECK(has_font); |
| 131 | 131 |
| 132 base::string16 value; | 132 base::string16 value; |
| 133 bool has_value = font->GetString(1, &value); | 133 bool has_value = font->GetString(1, &value); |
| 134 DCHECK(has_value); | 134 DCHECK(has_value); |
| 135 | 135 |
| 136 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(value); | 136 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(value); |
| 137 font->AppendString(has_rtl_chars ? "rtl" : "ltr"); | 137 font->AppendString(has_rtl_chars ? "rtl" : "ltr"); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // Character encoding list. | |
| 141 const std::vector<CharacterEncoding::EncodingInfo>* encodings; | |
| 142 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | |
| 143 encodings = CharacterEncoding::GetCurrentDisplayEncodings( | |
| 144 g_browser_process->GetApplicationLocale(), | |
| 145 pref_service->GetString(prefs::kStaticEncodings), | |
| 146 pref_service->GetString(prefs::kRecentlySelectedEncoding)); | |
| 147 DCHECK(!encodings->empty()); | |
| 148 | |
| 149 std::unique_ptr<base::ListValue> encoding_list(new base::ListValue()); | |
| 150 for (const auto& it : *encodings) { | |
| 151 std::unique_ptr<base::ListValue> option(new base::ListValue()); | |
| 152 if (it.encoding_id) { | |
| 153 option->AppendString( | |
| 154 CharacterEncoding::GetCanonicalEncodingNameByCommandId( | |
| 155 it.encoding_id)); | |
| 156 option->AppendString(it.encoding_display_name); | |
| 157 option->AppendString( | |
| 158 base::i18n::StringContainsStrongRTLChars(it.encoding_display_name) | |
| 159 ? "rtl" | |
| 160 : "ltr"); | |
| 161 } else { | |
| 162 // Add empty value to indicate a separator item. | |
| 163 option->AppendString(std::string()); | |
| 164 } | |
| 165 encoding_list->Append(std::move(option)); | |
| 166 } | |
| 167 | |
| 168 base::DictionaryValue response; | 140 base::DictionaryValue response; |
| 169 response.Set("fontList", std::move(list)); | 141 response.Set("fontList", std::move(list)); |
| 170 response.Set("encodingList", std::move(encoding_list)); | |
| 171 | 142 |
| 172 GURL extension_url(extension_urls::GetWebstoreItemDetailURLPrefix()); | 143 GURL extension_url(extension_urls::GetWebstoreItemDetailURLPrefix()); |
| 173 response.SetString( | 144 response.SetString( |
| 174 "extensionUrl", | 145 "extensionUrl", |
| 175 extension_url.Resolve(kAdvancedFontSettingsExtensionId).spec()); | 146 extension_url.Resolve(kAdvancedFontSettingsExtensionId).spec()); |
| 176 | 147 |
| 177 ResolveJavascriptCallback(base::StringValue(callback_id), response); | 148 ResolveJavascriptCallback(base::StringValue(callback_id), response); |
| 178 } | 149 } |
| 179 | 150 |
| 180 } // namespace settings | 151 } // namespace settings |
| OLD | NEW |