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

Side by Side Diff: components/translate/core/browser/translate_prefs.cc

Issue 2030833003: Remove ListValue::Append(new {Fundamental,String}Value(...)) pattern in //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/translate/core/browser/translate_prefs.h" 5 #include "components/translate/core/browser/translate_prefs.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 void TranslatePrefs::BlacklistValue(const char* pref_id, 534 void TranslatePrefs::BlacklistValue(const char* pref_id,
535 const std::string& value) { 535 const std::string& value) {
536 { 536 {
537 ListPrefUpdate update(prefs_, pref_id); 537 ListPrefUpdate update(prefs_, pref_id);
538 base::ListValue* blacklist = update.Get(); 538 base::ListValue* blacklist = update.Get();
539 if (!blacklist) { 539 if (!blacklist) {
540 NOTREACHED() << "Unregistered translate blacklist pref"; 540 NOTREACHED() << "Unregistered translate blacklist pref";
541 return; 541 return;
542 } 542 }
543 blacklist->Append(new base::StringValue(value)); 543 blacklist->AppendString(value);
544 } 544 }
545 } 545 }
546 546
547 void TranslatePrefs::RemoveValueFromBlacklist(const char* pref_id, 547 void TranslatePrefs::RemoveValueFromBlacklist(const char* pref_id,
548 const std::string& value) { 548 const std::string& value) {
549 ListPrefUpdate update(prefs_, pref_id); 549 ListPrefUpdate update(prefs_, pref_id);
550 base::ListValue* blacklist = update.Get(); 550 base::ListValue* blacklist = update.Get();
551 if (!blacklist) { 551 if (!blacklist) {
552 NOTREACHED() << "Unregistered translate blacklist pref"; 552 NOTREACHED() << "Unregistered translate blacklist pref";
553 return; 553 return;
554 } 554 }
555 base::StringValue string_value(value); 555 base::StringValue string_value(value);
556 blacklist->Remove(string_value, NULL); 556 blacklist->Remove(string_value, NULL);
557 } 557 }
558 558
559 bool TranslatePrefs::IsListEmpty(const char* pref_id) const { 559 bool TranslatePrefs::IsListEmpty(const char* pref_id) const {
560 const base::ListValue* blacklist = prefs_->GetList(pref_id); 560 const base::ListValue* blacklist = prefs_->GetList(pref_id);
561 return (blacklist == NULL || blacklist->empty()); 561 return (blacklist == NULL || blacklist->empty());
562 } 562 }
563 563
564 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { 564 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const {
565 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id); 565 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id);
566 return (dict == NULL || dict->empty()); 566 return (dict == NULL || dict->empty());
567 } 567 }
568 568
569 } // namespace translate 569 } // namespace translate
OLDNEW
« no previous file with comments | « components/syncable_prefs/pref_service_syncable_unittest.cc ('k') | components/url_matcher/url_matcher_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698