diff options
author | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 12:42:25 +0000 |
---|---|---|
committer | battre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-02 12:42:25 +0000 |
commit | 11b040b925457851de18130929f5c90d6e5a7d1b (patch) | |
tree | 6fbe7376740bb80ce20369c302c8ed2161e29d34 /chrome/browser/prefs | |
parent | 094087175d038b24eb82b50e1fb4b07b0fd83bbd (diff) | |
download | chromium_src-11b040b925457851de18130929f5c90d6e5a7d1b.zip chromium_src-11b040b925457851de18130929f5c90d6e5a7d1b.tar.gz chromium_src-11b040b925457851de18130929f5c90d6e5a7d1b.tar.bz2 |
Pacify Coverity when reading kExtensionsPref dictionary
CID 14614
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6392022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73450 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-rw-r--r-- | chrome/browser/prefs/pref_service.cc | 8 | ||||
-rw-r--r-- | chrome/browser/prefs/pref_service.h | 11 |
2 files changed, 13 insertions, 6 deletions
diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc index 34b6ca4..45b4042 100644 --- a/chrome/browser/prefs/pref_service.cc +++ b/chrome/browser/prefs/pref_service.cc @@ -409,8 +409,10 @@ const DictionaryValue* PrefService::GetDictionary(const char* path) const { return NULL; } const Value* value = pref->GetValue(); - if (value->GetType() == Value::TYPE_NULL) + if (value->GetType() != Value::TYPE_DICTIONARY) { + NOTREACHED(); return NULL; + } return static_cast<const DictionaryValue*>(value); } @@ -423,8 +425,10 @@ const ListValue* PrefService::GetList(const char* path) const { return NULL; } const Value* value = pref->GetValue(); - if (value->GetType() == Value::TYPE_NULL) + if (value->GetType() != Value::TYPE_LIST) { + NOTREACHED(); return NULL; + } return static_cast<const ListValue*>(value); } diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h index 5891a1d..a7b64d2 100644 --- a/chrome/browser/prefs/pref_service.h +++ b/chrome/browser/prefs/pref_service.h @@ -167,8 +167,9 @@ class PrefService : public base::NonThreadSafe { std::string GetString(const char* path) const; FilePath GetFilePath(const char* path) const; - // Returns the branch if it exists. If it's not a branch or the branch does - // not exist, returns NULL. + // Returns the branch if it exists, or the registered default value otherwise. + // Note that |path| must point to a registered preference. In that case, these + // functions will never return NULL. const DictionaryValue* GetDictionary(const char* path) const; const ListValue* GetList(const char* path) const; @@ -274,8 +275,10 @@ class PrefService : public base::NonThreadSafe { virtual void AddPrefObserver(const char* path, NotificationObserver* obs); virtual void RemovePrefObserver(const char* path, NotificationObserver* obs); - // Add a preference to the PreferenceMap. If the pref already exists, return - // false. This method takes ownership of |default_value|. + // Registers a new preference at |path|. The |default_value| must not be + // NULL as it determines the preference value's type. + // RegisterPreference must not be called twice for the same path. + // This method takes ownership of |default_value|. void RegisterPreference(const char* path, Value* default_value); // Sets the value for this pref path in the user pref store and informs the |