| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |