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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_handler.cc

Issue 2058233002: Rewrite simple uses of base::ListValue::Append() taking a raw pointer var. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: less comments more ownership Created 4 years, 6 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
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/options/font_settings_handler.h" 5 #include "chrome/browser/ui/webui/options/font_settings_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
13 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 19 #include "base/values.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 217 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
217 encodings = CharacterEncoding::GetCurrentDisplayEncodings( 218 encodings = CharacterEncoding::GetCurrentDisplayEncodings(
218 g_browser_process->GetApplicationLocale(), 219 g_browser_process->GetApplicationLocale(),
219 pref_service->GetString(prefs::kStaticEncodings), 220 pref_service->GetString(prefs::kStaticEncodings),
220 pref_service->GetString(prefs::kRecentlySelectedEncoding)); 221 pref_service->GetString(prefs::kRecentlySelectedEncoding));
221 DCHECK(encodings); 222 DCHECK(encodings);
222 DCHECK(!encodings->empty()); 223 DCHECK(!encodings->empty());
223 224
224 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it; 225 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it;
225 for (it = encodings->begin(); it != encodings->end(); ++it) { 226 for (it = encodings->begin(); it != encodings->end(); ++it) {
226 base::ListValue* option = new base::ListValue(); 227 std::unique_ptr<base::ListValue> option(new base::ListValue());
227 if (it->encoding_id) { 228 if (it->encoding_id) {
228 int cmd_id = it->encoding_id; 229 int cmd_id = it->encoding_id;
229 std::string encoding = 230 std::string encoding =
230 CharacterEncoding::GetCanonicalEncodingNameByCommandId(cmd_id); 231 CharacterEncoding::GetCanonicalEncodingNameByCommandId(cmd_id);
231 base::string16 name = it->encoding_display_name; 232 base::string16 name = it->encoding_display_name;
232 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(name); 233 bool has_rtl_chars = base::i18n::StringContainsStrongRTLChars(name);
233 option->AppendString(encoding); 234 option->AppendString(encoding);
234 option->AppendString(name); 235 option->AppendString(name);
235 option->AppendString(has_rtl_chars ? "rtl" : "ltr"); 236 option->AppendString(has_rtl_chars ? "rtl" : "ltr");
236 } else { 237 } else {
237 // Add empty name/value to indicate a separator item. 238 // Add empty name/value to indicate a separator item.
238 option->AppendString(std::string()); 239 option->AppendString(std::string());
239 option->AppendString(std::string()); 240 option->AppendString(std::string());
240 } 241 }
241 encoding_list.Append(option); 242 encoding_list.Append(std::move(option));
242 } 243 }
243 244
244 base::ListValue selected_values; 245 base::ListValue selected_values;
245 selected_values.AppendString( 246 selected_values.AppendString(
246 MaybeGetLocalizedFontName(standard_font_.GetValue())); 247 MaybeGetLocalizedFontName(standard_font_.GetValue()));
247 selected_values.AppendString( 248 selected_values.AppendString(
248 MaybeGetLocalizedFontName(serif_font_.GetValue())); 249 MaybeGetLocalizedFontName(serif_font_.GetValue()));
249 selected_values.AppendString( 250 selected_values.AppendString(
250 MaybeGetLocalizedFontName(sans_serif_font_.GetValue())); 251 MaybeGetLocalizedFontName(sans_serif_font_.GetValue()));
251 selected_values.AppendString( 252 selected_values.AppendString(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); 316 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()));
316 } 317 }
317 318
318 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() { 319 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() {
319 SetUpStandardFontSample(); 320 SetUpStandardFontSample();
320 SetUpSerifFontSample(); 321 SetUpSerifFontSample();
321 SetUpSansSerifFontSample(); 322 SetUpSansSerifFontSample();
322 } 323 }
323 324
324 } // namespace options 325 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698