Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 441008: Many changes to DictionaryValues:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_prefs.cc
===================================================================
--- chrome/browser/extensions/extension_prefs.cc (revision 32858)
+++ chrome/browser/extensions/extension_prefs.cc (working copy)
@@ -50,10 +50,12 @@
void InstalledExtensions::VisitInstalledExtensions(
InstalledExtensions::Callback *callback) {
scoped_ptr<InstalledExtensions::Callback> cleanup(callback);
- DictionaryValue::key_iterator extension_id = extension_data_->begin_keys();
- for (; extension_id != extension_data_->end_keys(); ++extension_id) {
+ for (DictionaryValue::key_iterator extension_id(
+ extension_data_->begin_keys());
+ extension_id != extension_data_->end_keys(); ++extension_id) {
DictionaryValue* ext;
- if (!extension_data_->GetDictionary(*extension_id, &ext)) {
+ if (!extension_data_->GetDictionaryWithoutPathExpansion(*extension_id,
+ &ext)) {
LOG(WARNING) << "Invalid pref for extension " << *extension_id;
NOTREACHED();
continue;
@@ -125,13 +127,13 @@
void ExtensionPrefs::MakePathsRelative() {
bool dirty = false;
const DictionaryValue* dict = prefs_->GetMutableDictionary(kExtensionsPref);
- if (!dict || dict->GetSize() == 0)
+ if (!dict || dict->empty())
return;
for (DictionaryValue::key_iterator i = dict->begin_keys();
i != dict->end_keys(); ++i) {
DictionaryValue* extension_dict;
- if (!dict->GetDictionary(*i, &extension_dict))
+ if (!dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict))
continue;
FilePath::StringType path_string;
if (!extension_dict->GetString(kPrefPath, &path_string))
@@ -147,13 +149,13 @@
}
void ExtensionPrefs::MakePathsAbsolute(DictionaryValue* dict) {
- if (!dict || dict->GetSize() == 0)
+ if (!dict || dict->empty())
return;
for (DictionaryValue::key_iterator i = dict->begin_keys();
i != dict->end_keys(); ++i) {
DictionaryValue* extension_dict;
- if (!dict->GetDictionary(*i, &extension_dict)) {
+ if (!dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict)) {
NOTREACHED();
continue;
}
@@ -211,21 +213,21 @@
std::set<std::string> used_id_set;
const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref);
DCHECK(extensions);
- DictionaryValue::key_iterator extension_id = extensions->begin_keys();
- for (; extension_id != extensions->end_keys(); ++extension_id) {
+ for (DictionaryValue::key_iterator extension_id = extensions->begin_keys();
+ extension_id != extensions->end_keys(); ++extension_id) {
DictionaryValue* ext;
- std::string id = WideToASCII(*extension_id);
- if (!extensions->GetDictionary(*extension_id, &ext)) {
+ if (!extensions->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) {
NOTREACHED() << "Invalid pref for extension " << *extension_id;
continue;
}
+ std::string id = WideToASCII(*extension_id);
if (blacklist_set.find(id) == blacklist_set.end()) {
if (!IsBlacklistBitSet(ext)) {
// This extension is not in blacklist. And it was not blacklisted
// before.
continue;
} else {
- if (ext->GetSize() == 1) {
+ if (ext->size() == 1) {
// We should remove the entry if the only flag here is blacklist.
remove_pref_ids.push_back(id);
} else {
@@ -261,7 +263,7 @@
void ExtensionPrefs::GetKilledExtensionIds(std::set<std::string>* killed_ids) {
const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
- if (!dict || dict->GetSize() == 0)
+ if (!dict || dict->empty())
return;
for (DictionaryValue::key_iterator i = dict->begin_keys();
@@ -273,7 +275,7 @@
continue;
}
- DictionaryValue* extension = NULL;
+ DictionaryValue* extension;
if (!dict->GetDictionary(key_name, &extension)) {
NOTREACHED();
continue;
@@ -391,7 +393,7 @@
FilePath ExtensionPrefs::GetExtensionPath(const std::string& extension_id) {
const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
- if (!dict || dict->GetSize() == 0)
+ if (!dict || dict->empty())
return FilePath();
std::wstring path;
@@ -401,16 +403,11 @@
return install_directory_.Append(FilePath::FromWStringHack(path));
}
-bool ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id,
+void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id,
const std::wstring& key,
Value* data_value) {
DictionaryValue* extension = GetOrCreateExtensionPref(extension_id);
- if (!extension->Set(key, data_value)) {
- NOTREACHED() << "Cannot modify key: '" << key.c_str()
- << "' for extension: '" << extension_id.c_str() << "'";
- return false;
- }
- return true;
+ extension->Set(key, data_value);
}
void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) {

Powered by Google App Engine
This is Rietveld 408576698