summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-03 09:38:39 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-03 09:38:39 +0000
commitfd6159afa2356ec37405265aca2e4375df3b8d3a (patch)
treec5d2f731fd04ad22767ffd711aeb1530698e1b3c /chrome/common
parentdc3fa284459e3c7938d2ec26c62fef513531e911 (diff)
downloadchromium_src-fd6159afa2356ec37405265aca2e4375df3b8d3a.zip
chromium_src-fd6159afa2356ec37405265aca2e4375df3b8d3a.tar.gz
chromium_src-fd6159afa2356ec37405265aca2e4375df3b8d3a.tar.bz2
Gracefully handle the case of empty preference file names in PrefValueStore.
BUG=53917 TEST=Instead of crashing, chrome should display a message if it cannot determine the local state file. Review URL: http://codereview.chromium.org/3322005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58471 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/json_pref_store.cc5
-rw-r--r--chrome/common/pref_store.h4
2 files changed, 6 insertions, 3 deletions
diff --git a/chrome/common/json_pref_store.cc b/chrome/common/json_pref_store.cc
index 9acfcb2d..d68307f 100644
--- a/chrome/common/json_pref_store.cc
+++ b/chrome/common/json_pref_store.cc
@@ -31,6 +31,10 @@ JsonPrefStore::~JsonPrefStore() {
}
PrefStore::PrefReadError JsonPrefStore::ReadPrefs() {
+ if (path_.empty()) {
+ read_only_ = true;
+ return PREF_READ_ERROR_FILE_NOT_SPECIFIED;
+ }
JSONFileValueSerializer serializer(path_);
int error_code = 0;
@@ -127,4 +131,3 @@ bool JsonPrefStore::SerializeData(std::string* output) {
scoped_ptr<DictionaryValue> copy(prefs_->DeepCopyWithoutEmptyChildren());
return serializer.Serialize(*(copy.get()));
}
-
diff --git a/chrome/common/pref_store.h b/chrome/common/pref_store.h
index d5acd89..727c020 100644
--- a/chrome/common/pref_store.h
+++ b/chrome/common/pref_store.h
@@ -27,7 +27,8 @@ class PrefStore {
PREF_READ_ERROR_FILE_LOCKED,
PREF_READ_ERROR_NO_FILE,
PREF_READ_ERROR_JSON_REPEAT,
- PREF_READ_ERROR_OTHER
+ PREF_READ_ERROR_OTHER,
+ PREF_READ_ERROR_FILE_NOT_SPECIFIED
};
virtual ~PrefStore() { }
@@ -47,4 +48,3 @@ class PrefStore {
};
#endif // CHROME_COMMON_PREF_STORE_H_
-