| OLD | NEW |
| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 | 402 |
| 403 const DictionaryValue* PrefService::GetDictionary(const char* path) const { | 403 const DictionaryValue* PrefService::GetDictionary(const char* path) const { |
| 404 DCHECK(CalledOnValidThread()); | 404 DCHECK(CalledOnValidThread()); |
| 405 | 405 |
| 406 const Preference* pref = FindPreference(path); | 406 const Preference* pref = FindPreference(path); |
| 407 if (!pref) { | 407 if (!pref) { |
| 408 NOTREACHED() << "Trying to read an unregistered pref: " << path; | 408 NOTREACHED() << "Trying to read an unregistered pref: " << path; |
| 409 return NULL; | 409 return NULL; |
| 410 } | 410 } |
| 411 const Value* value = pref->GetValue(); | 411 const Value* value = pref->GetValue(); |
| 412 if (value->GetType() == Value::TYPE_NULL) | 412 if (value->GetType() != Value::TYPE_DICTIONARY) { |
| 413 NOTREACHED(); |
| 413 return NULL; | 414 return NULL; |
| 415 } |
| 414 return static_cast<const DictionaryValue*>(value); | 416 return static_cast<const DictionaryValue*>(value); |
| 415 } | 417 } |
| 416 | 418 |
| 417 const ListValue* PrefService::GetList(const char* path) const { | 419 const ListValue* PrefService::GetList(const char* path) const { |
| 418 DCHECK(CalledOnValidThread()); | 420 DCHECK(CalledOnValidThread()); |
| 419 | 421 |
| 420 const Preference* pref = FindPreference(path); | 422 const Preference* pref = FindPreference(path); |
| 421 if (!pref) { | 423 if (!pref) { |
| 422 NOTREACHED() << "Trying to read an unregistered pref: " << path; | 424 NOTREACHED() << "Trying to read an unregistered pref: " << path; |
| 423 return NULL; | 425 return NULL; |
| 424 } | 426 } |
| 425 const Value* value = pref->GetValue(); | 427 const Value* value = pref->GetValue(); |
| 426 if (value->GetType() == Value::TYPE_NULL) | 428 if (value->GetType() != Value::TYPE_LIST) { |
| 429 NOTREACHED(); |
| 427 return NULL; | 430 return NULL; |
| 431 } |
| 428 return static_cast<const ListValue*>(value); | 432 return static_cast<const ListValue*>(value); |
| 429 } | 433 } |
| 430 | 434 |
| 431 void PrefService::AddPrefObserver(const char* path, | 435 void PrefService::AddPrefObserver(const char* path, |
| 432 NotificationObserver* obs) { | 436 NotificationObserver* obs) { |
| 433 pref_notifier_->AddPrefObserver(path, obs); | 437 pref_notifier_->AddPrefObserver(path, obs); |
| 434 } | 438 } |
| 435 | 439 |
| 436 void PrefService::RemovePrefObserver(const char* path, | 440 void PrefService::RemovePrefObserver(const char* path, |
| 437 NotificationObserver* obs) { | 441 NotificationObserver* obs) { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 | 679 |
| 676 bool PrefService::Preference::IsDefaultValue() const { | 680 bool PrefService::Preference::IsDefaultValue() const { |
| 677 return pref_service_->pref_value_store_-> | 681 return pref_service_->pref_value_store_-> |
| 678 PrefValueFromDefaultStore(name_.c_str()); | 682 PrefValueFromDefaultStore(name_.c_str()); |
| 679 } | 683 } |
| 680 | 684 |
| 681 bool PrefService::Preference::IsUserModifiable() const { | 685 bool PrefService::Preference::IsUserModifiable() const { |
| 682 return pref_service_->pref_value_store_-> | 686 return pref_service_->pref_value_store_-> |
| 683 PrefValueUserModifiable(name_.c_str()); | 687 PrefValueUserModifiable(name_.c_str()); |
| 684 } | 688 } |
| OLD | NEW |