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

Side by Side Diff: chrome/browser/prefs/pref_service.cc

Issue 8879016: Add more per-tab preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CHECK -> DCHECK Created 8 years, 12 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
« no previous file with comments | « chrome/browser/prefs/pref_service.h ('k') | chrome/browser/prefs/pref_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/prefs/pref_service.h" 5 #include "chrome/browser/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
738 "invalid preference type: " << orig_type; 738 "invalid preference type: " << orig_type;
739 739
740 // Hand off ownership. 740 // Hand off ownership.
741 default_store_->SetDefaultValue(path, scoped_value.release()); 741 default_store_->SetDefaultValue(path, scoped_value.release());
742 742
743 // Register with sync if necessary. 743 // Register with sync if necessary.
744 if (sync_status == SYNCABLE_PREF && pref_sync_associator_.get()) 744 if (sync_status == SYNCABLE_PREF && pref_sync_associator_.get())
745 pref_sync_associator_->RegisterPref(path); 745 pref_sync_associator_->RegisterPref(path);
746 } 746 }
747 747
748 void PrefService::UnregisterPreference(const char* path) {
749 DCHECK(CalledOnValidThread());
750
751 Preference p(this, path, Value::TYPE_NULL);
752 PreferenceSet::const_iterator it = prefs_.find(&p);
753 if (it == prefs_.end()) {
754 NOTREACHED() << "Trying to unregister an unregistered pref: " << path;
755 return;
756 }
757
758 prefs_.erase(it);
759 default_store_->RemoveDefaultValue(path);
760 if (pref_sync_associator_.get() &&
761 pref_sync_associator_->IsPrefRegistered(path)) {
762 pref_sync_associator_->UnregisterPref(path);
763 }
764 }
765
748 void PrefService::ClearPref(const char* path) { 766 void PrefService::ClearPref(const char* path) {
749 DCHECK(CalledOnValidThread()); 767 DCHECK(CalledOnValidThread());
750 768
751 const Preference* pref = FindPreference(path); 769 const Preference* pref = FindPreference(path);
752 if (!pref) { 770 if (!pref) {
753 NOTREACHED() << "Trying to clear an unregistered pref: " << path; 771 NOTREACHED() << "Trying to clear an unregistered pref: " << path;
754 return; 772 return;
755 } 773 }
756 user_pref_store_->RemoveValue(path); 774 user_pref_store_->RemoveValue(path);
757 } 775 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str()); 939 return pref_value_store()->PrefValueFromDefaultStore(name_.c_str());
922 } 940 }
923 941
924 bool PrefService::Preference::IsUserModifiable() const { 942 bool PrefService::Preference::IsUserModifiable() const {
925 return pref_value_store()->PrefValueUserModifiable(name_.c_str()); 943 return pref_value_store()->PrefValueUserModifiable(name_.c_str());
926 } 944 }
927 945
928 bool PrefService::Preference::IsExtensionModifiable() const { 946 bool PrefService::Preference::IsExtensionModifiable() const {
929 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str()); 947 return pref_value_store()->PrefValueExtensionModifiable(name_.c_str());
930 } 948 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service.h ('k') | chrome/browser/prefs/pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698