| 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 "components/prefs/pref_service.h" | 5 #include "components/prefs/pref_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 base::Value::Type PrefService::Preference::GetType() const { | 531 base::Value::Type PrefService::Preference::GetType() const { |
| 532 return type_; | 532 return type_; |
| 533 } | 533 } |
| 534 | 534 |
| 535 const base::Value* PrefService::Preference::GetValue() const { | 535 const base::Value* PrefService::Preference::GetValue() const { |
| 536 const base::Value* result= pref_service_->GetPreferenceValue(name_); | 536 const base::Value* result= pref_service_->GetPreferenceValue(name_); |
| 537 DCHECK(result) << "Must register pref before getting its value"; | 537 DCHECK(result) << "Must register pref before getting its value"; |
| 538 return result; | 538 return result; |
| 539 } | 539 } |
| 540 | 540 |
| 541 const base::Value* PrefService::Preference::GetManagedValue() const { |
| 542 DCHECK(pref_service_->FindPreference(name_)) |
| 543 << "Must register pref before getting its value"; |
| 544 |
| 545 const base::Value* found_value = nullptr; |
| 546 if (pref_value_store()->GetManagedValue(name_, type_, &found_value)) { |
| 547 DCHECK(found_value->IsType(type_)); |
| 548 return found_value; |
| 549 } |
| 550 |
| 551 // The pref has no managed value. |
| 552 return nullptr; |
| 553 } |
| 554 |
| 541 const base::Value* PrefService::Preference::GetRecommendedValue() const { | 555 const base::Value* PrefService::Preference::GetRecommendedValue() const { |
| 542 DCHECK(pref_service_->FindPreference(name_)) | 556 DCHECK(pref_service_->FindPreference(name_)) |
| 543 << "Must register pref before getting its value"; | 557 << "Must register pref before getting its value"; |
| 544 | 558 |
| 545 const base::Value* found_value = NULL; | 559 const base::Value* found_value = nullptr; |
| 546 if (pref_value_store()->GetRecommendedValue(name_, type_, &found_value)) { | 560 if (pref_value_store()->GetRecommendedValue(name_, type_, &found_value)) { |
| 547 DCHECK(found_value->IsType(type_)); | 561 DCHECK(found_value->IsType(type_)); |
| 548 return found_value; | 562 return found_value; |
| 549 } | 563 } |
| 550 | 564 |
| 551 // The pref has no recommended value. | 565 // The pref has no recommended value. |
| 552 return NULL; | 566 return nullptr; |
| 553 } | 567 } |
| 554 | 568 |
| 555 bool PrefService::Preference::IsManaged() const { | 569 bool PrefService::Preference::IsManaged() const { |
| 556 return pref_value_store()->PrefValueInManagedStore(name_); | 570 return pref_value_store()->PrefValueInManagedStore(name_); |
| 557 } | 571 } |
| 558 | 572 |
| 559 bool PrefService::Preference::IsManagedByCustodian() const { | 573 bool PrefService::Preference::IsManagedByCustodian() const { |
| 560 return pref_value_store()->PrefValueInSupervisedStore(name_.c_str()); | 574 return pref_value_store()->PrefValueInSupervisedStore(name_.c_str()); |
| 561 } | 575 } |
| 562 | 576 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 DCHECK(found_value->IsType(default_type)); | 625 DCHECK(found_value->IsType(default_type)); |
| 612 return found_value; | 626 return found_value; |
| 613 } else { | 627 } else { |
| 614 // Every registered preference has at least a default value. | 628 // Every registered preference has at least a default value. |
| 615 NOTREACHED() << "no valid value found for registered pref " << path; | 629 NOTREACHED() << "no valid value found for registered pref " << path; |
| 616 } | 630 } |
| 617 } | 631 } |
| 618 | 632 |
| 619 return NULL; | 633 return NULL; |
| 620 } | 634 } |
| OLD | NEW |