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

Side by Side Diff: base/prefs/pref_service.cc

Issue 12315116: Add ability to change default pref values, and use in BrowserInstantController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Add a bit of documentation. Created 7 years, 9 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
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 "base/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 return NULL; 266 return NULL;
267 267
268 if (!value->IsType(pref->GetType())) { 268 if (!value->IsType(pref->GetType())) {
269 NOTREACHED() << "Pref value type doesn't match registered type."; 269 NOTREACHED() << "Pref value type doesn't match registered type.";
270 return NULL; 270 return NULL;
271 } 271 }
272 272
273 return value; 273 return value;
274 } 274 }
275 275
276 void PrefService::SetDefaultPrefValue(const char* path,
277 base::Value* value) {
278 DCHECK(CalledOnValidThread());
279 pref_registry_->SetDefaultPrefValue(path, value);
280 }
281
276 const base::Value* PrefService::GetDefaultPrefValue(const char* path) const { 282 const base::Value* PrefService::GetDefaultPrefValue(const char* path) const {
277 DCHECK(CalledOnValidThread()); 283 DCHECK(CalledOnValidThread());
278 // Lookup the preference in the default store. 284 // Lookup the preference in the default store.
279 const base::Value* value = NULL; 285 const base::Value* value = NULL;
280 if (!pref_registry_->defaults()->GetValue(path, &value)) { 286 if (!pref_registry_->defaults()->GetValue(path, &value)) {
281 NOTREACHED() << "Default value missing for pref: " << path; 287 NOTREACHED() << "Default value missing for pref: " << path;
282 return NULL; 288 return NULL;
283 } 289 }
284 return value; 290 return value;
285 } 291 }
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 DCHECK(found_value->IsType(default_type)); 581 DCHECK(found_value->IsType(default_type));
576 return found_value; 582 return found_value;
577 } else { 583 } else {
578 // Every registered preference has at least a default value. 584 // Every registered preference has at least a default value.
579 NOTREACHED() << "no valid value found for registered pref " << path; 585 NOTREACHED() << "no valid value found for registered pref " << path;
580 } 586 }
581 } 587 }
582 588
583 return NULL; 589 return NULL;
584 } 590 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698