Index: extensions/browser/extension_prefs.cc |
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc |
index e0cd6734f593893fe61e0e89ff0efdb9c89aac1c..f85d0711ca683a0fd2a5001f9708a99cd30cda41 100644 |
--- a/extensions/browser/extension_prefs.cc |
+++ b/extensions/browser/extension_prefs.cc |
@@ -211,7 +211,7 @@ class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { |
// DictionaryPrefUpdate overrides: |
virtual base::DictionaryValue* Get() OVERRIDE { |
base::DictionaryValue* dict = DictionaryPrefUpdate::Get(); |
- base::DictionaryValue* extension = NULL; |
+ base::DictionaryValue* extension = nullptr; |
if (!dict->GetDictionary(extension_id_, &extension)) { |
// Extension pref does not exist, create it. |
extension = new base::DictionaryValue(); |
@@ -249,7 +249,7 @@ void LoadExtensionControlledPrefs(ExtensionPrefs* prefs, |
const base::DictionaryValue* source_dict = |
prefs->pref_service()->GetDictionary(pref_names::kExtensions); |
- const base::DictionaryValue* preferences = NULL; |
+ const base::DictionaryValue* preferences = nullptr; |
if (!source_dict->GetDictionary(key, &preferences)) |
return; |
@@ -297,23 +297,22 @@ ExtensionPrefs::ScopedUpdate<T, type_enum_value>::~ScopedUpdate() { |
template <typename T, base::Value::Type type_enum_value> |
T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Get() { |
base::DictionaryValue* dict = update_.Get(); |
- base::DictionaryValue* extension = NULL; |
- base::Value* key_value = NULL; |
+ base::DictionaryValue* extension = nullptr; |
+ base::Value* key_value = nullptr; |
if (!dict->GetDictionary(extension_id_, &extension) || |
!extension->Get(key_, &key_value)) { |
- return NULL; |
+ return nullptr; |
} |
- return key_value->GetType() == type_enum_value ? |
- static_cast<T*>(key_value) : |
- NULL; |
+ return key_value->GetType() == type_enum_value ? static_cast<T*>(key_value) |
+ : nullptr; |
} |
template <typename T, base::Value::Type type_enum_value> |
T* ExtensionPrefs::ScopedUpdate<T, type_enum_value>::Create() { |
base::DictionaryValue* dict = update_.Get(); |
- base::DictionaryValue* extension = NULL; |
- base::Value* key_value = NULL; |
- T* value_as_t = NULL; |
+ base::DictionaryValue* extension = nullptr; |
+ base::Value* key_value = nullptr; |
+ T* value_as_t = nullptr; |
if (!dict->GetDictionary(extension_id_, &extension)) { |
extension = new base::DictionaryValue; |
dict->SetWithoutPathExpansion(extension_id_, extension); |
@@ -403,7 +402,7 @@ void ExtensionPrefs::MakePathsRelative() { |
// Collect all extensions ids with absolute paths in |absolute_keys|. |
std::set<std::string> absolute_keys; |
for (base::DictionaryValue::Iterator i(*dict); !i.IsAtEnd(); i.Advance()) { |
- const base::DictionaryValue* extension_dict = NULL; |
+ const base::DictionaryValue* extension_dict = nullptr; |
if (!i.value().GetAsDictionary(&extension_dict)) |
continue; |
int location_value; |
@@ -428,7 +427,7 @@ void ExtensionPrefs::MakePathsRelative() { |
base::DictionaryValue* update_dict = update.Get(); |
for (std::set<std::string>::iterator i = absolute_keys.begin(); |
i != absolute_keys.end(); ++i) { |
- base::DictionaryValue* extension_dict = NULL; |
+ base::DictionaryValue* extension_dict = nullptr; |
if (!update_dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict)) { |
NOTREACHED() << "Control should never reach here for extension " << *i; |
continue; |
@@ -445,10 +444,10 @@ const base::DictionaryValue* ExtensionPrefs::GetExtensionPref( |
const std::string& extension_id) const { |
const base::DictionaryValue* extensions = |
prefs_->GetDictionary(pref_names::kExtensions); |
- const base::DictionaryValue* extension_dict = NULL; |
+ const base::DictionaryValue* extension_dict = nullptr; |
if (!extensions || |
!extensions->GetDictionary(extension_id, &extension_dict)) { |
- return NULL; |
+ return nullptr; |
} |
return extension_dict; |
} |
@@ -464,7 +463,7 @@ void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id, |
if (data_value) |
update->Set(key, data_value); |
else |
- update->Remove(key, NULL); |
+ update->Remove(key, nullptr); |
} |
void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) { |
@@ -474,7 +473,7 @@ void ExtensionPrefs::DeleteExtensionPrefs(const std::string& extension_id) { |
OnExtensionPrefsDeleted(extension_id)); |
DictionaryPrefUpdate update(prefs_, pref_names::kExtensions); |
base::DictionaryValue* dict = update.Get(); |
- dict->Remove(extension_id, NULL); |
+ dict->Remove(extension_id, nullptr); |
} |
bool ExtensionPrefs::ReadPrefAsBoolean(const std::string& extension_id, |
@@ -511,7 +510,7 @@ bool ExtensionPrefs::ReadPrefAsList(const std::string& extension_id, |
const std::string& pref_key, |
const base::ListValue** out_value) const { |
const base::DictionaryValue* ext = GetExtensionPref(extension_id); |
- const base::ListValue* out = NULL; |
+ const base::ListValue* out = nullptr; |
if (!ext || !ext->GetList(pref_key, &out)) |
return false; |
if (out_value) |
@@ -525,7 +524,7 @@ bool ExtensionPrefs::ReadPrefAsDictionary( |
const std::string& pref_key, |
const base::DictionaryValue** out_value) const { |
const base::DictionaryValue* ext = GetExtensionPref(extension_id); |
- const base::DictionaryValue* out = NULL; |
+ const base::DictionaryValue* out = nullptr; |
if (!ext || !ext->GetDictionary(pref_key, &out)) |
return false; |
if (out_value) |
@@ -536,19 +535,19 @@ bool ExtensionPrefs::ReadPrefAsDictionary( |
bool ExtensionPrefs::HasPrefForExtension( |
const std::string& extension_id) const { |
- return GetExtensionPref(extension_id) != NULL; |
+ return GetExtensionPref(extension_id) != nullptr; |
} |
bool ExtensionPrefs::ReadPrefAsURLPatternSet(const std::string& extension_id, |
const std::string& pref_key, |
URLPatternSet* result, |
int valid_schemes) { |
- const base::ListValue* value = NULL; |
+ const base::ListValue* value = nullptr; |
if (!ReadPrefAsList(extension_id, pref_key, &value)) |
return false; |
bool allow_file_access = AllowFileAccess(extension_id); |
- return result->Populate(*value, valid_schemes, allow_file_access, NULL); |
+ return result->Populate(*value, valid_schemes, allow_file_access, nullptr); |
} |
void ExtensionPrefs::SetExtensionPrefURLPatternSet( |
@@ -569,29 +568,31 @@ PermissionSet* ExtensionPrefs::ReadPrefAsPermissionSet( |
const std::string& extension_id, |
const std::string& pref_key) { |
if (!GetExtensionPref(extension_id)) |
- return NULL; |
+ return nullptr; |
// Retrieve the API permissions. Please refer SetExtensionPrefPermissionSet() |
// for api_values format. |
APIPermissionSet apis; |
- const base::ListValue* api_values = NULL; |
+ const base::ListValue* api_values = nullptr; |
std::string api_pref = JoinPrefs(pref_key, kPrefAPIs); |
if (ReadPrefAsList(extension_id, api_pref, &api_values)) { |
APIPermissionSet::ParseFromJSON(api_values, |
APIPermissionSet::kAllowInternalPermissions, |
- &apis, NULL, NULL); |
+ &apis, |
+ nullptr, |
+ nullptr); |
} |
// Retrieve the Manifest Keys permissions. Please refer to |
// |SetExtensionPrefPermissionSet| for manifest_permissions_values format. |
ManifestPermissionSet manifest_permissions; |
- const base::ListValue* manifest_permissions_values = NULL; |
+ const base::ListValue* manifest_permissions_values = nullptr; |
std::string manifest_permission_pref = |
JoinPrefs(pref_key, kPrefManifestPermissions); |
if (ReadPrefAsList(extension_id, manifest_permission_pref, |
&manifest_permissions_values)) { |
ManifestPermissionSet::ParseFromJSON( |
- manifest_permissions_values, &manifest_permissions, NULL, NULL); |
+ manifest_permissions_values, &manifest_permissions, nullptr, nullptr); |
} |
// Retrieve the explicit host permissions. |
@@ -686,7 +687,7 @@ void ExtensionPrefs::AcknowledgeExternalExtension( |
DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
UpdateExtensionPref(extension_id, kPrefExternalAcknowledged, |
new base::FundamentalValue(true)); |
- UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
+ UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, nullptr); |
} |
bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged( |
@@ -699,7 +700,7 @@ void ExtensionPrefs::AcknowledgeBlacklistedExtension( |
DCHECK(crx_file::id_util::IdIsValid(extension_id)); |
UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, |
new base::FundamentalValue(true)); |
- UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL); |
+ UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, nullptr); |
} |
bool ExtensionPrefs::IsExternalInstallFirstRun( |
@@ -724,7 +725,7 @@ void ExtensionPrefs::SetWipeoutAcknowledged( |
bool value) { |
UpdateExtensionPref(extension_id, |
kPrefWipeoutAcknowledged, |
- value ? new base::FundamentalValue(value) : NULL); |
+ value ? new base::FundamentalValue(value) : nullptr); |
} |
bool ExtensionPrefs::HasSettingsApiBubbleBeenAcknowledged( |
@@ -738,7 +739,7 @@ void ExtensionPrefs::SetSettingsApiBubbleBeenAcknowledged( |
bool value) { |
UpdateExtensionPref(extension_id, |
kPrefSettingsBubbleAcknowledged, |
- value ? new base::FundamentalValue(value) : NULL); |
+ value ? new base::FundamentalValue(value) : nullptr); |
} |
bool ExtensionPrefs::HasNtpOverriddenBubbleBeenAcknowledged( |
@@ -751,7 +752,7 @@ void ExtensionPrefs::SetNtpOverriddenBubbleBeenAcknowledged( |
bool value) { |
UpdateExtensionPref(extension_id, |
kPrefNtpBubbleAcknowledged, |
- value ? new base::FundamentalValue(value) : NULL); |
+ value ? new base::FundamentalValue(value) : nullptr); |
} |
bool ExtensionPrefs::HasProxyOverriddenBubbleBeenAcknowledged( |
@@ -764,7 +765,7 @@ void ExtensionPrefs::SetProxyOverriddenBubbleBeenAcknowledged( |
bool value) { |
UpdateExtensionPref(extension_id, |
kPrefProxyBubbleAcknowledged, |
- value ? new base::FundamentalValue(value) : NULL); |
+ value ? new base::FundamentalValue(value) : nullptr); |
} |
bool ExtensionPrefs::SetAlertSystemFirstRun() { |
@@ -839,7 +840,7 @@ void ExtensionPrefs::ModifyDisableReason(const std::string& extension_id, |
return; |
if (new_value == Extension::DISABLE_NONE) { |
- UpdateExtensionPref(extension_id, kPrefDisableReasons, NULL); |
+ UpdateExtensionPref(extension_id, kPrefDisableReasons, nullptr); |
} else { |
UpdateExtensionPref(extension_id, |
kPrefDisableReasons, |
@@ -882,14 +883,14 @@ void ExtensionPrefs::SetExtensionBlacklisted(const std::string& extension_id, |
// Always make sure the "acknowledged" bit is cleared since the blacklist bit |
// is changing. |
- UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, NULL); |
+ UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged, nullptr); |
if (is_blacklisted) { |
UpdateExtensionPref(extension_id, |
kPrefBlacklist, |
new base::FundamentalValue(true)); |
} else { |
- UpdateExtensionPref(extension_id, kPrefBlacklist, NULL); |
+ UpdateExtensionPref(extension_id, kPrefBlacklist, nullptr); |
const base::DictionaryValue* dict = GetExtensionPref(extension_id); |
if (dict && dict->empty()) |
DeleteExtensionPrefs(extension_id); |
@@ -1013,8 +1014,8 @@ void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) { |
// Add the plugin permission if the full access bit was set. |
if (full_access) { |
- const base::ListValue* apis = NULL; |
- base::ListValue* new_apis = NULL; |
+ const base::ListValue* apis = nullptr; |
+ base::ListValue* new_apis = nullptr; |
std::string granted_apis = JoinPrefs(kPrefGrantedPermissions, kPrefAPIs); |
if (ext->GetList(kPrefOldGrantedAPIs, &apis)) |
@@ -1033,7 +1034,7 @@ void ExtensionPrefs::MigratePermissions(const ExtensionIdList& extension_ids) { |
// does not matter how we treat the old effective hosts as long as the |
// new effective hosts will be the same, so we move them to explicit |
// host permissions. |
- const base::ListValue* hosts = NULL; |
+ const base::ListValue* hosts = nullptr; |
std::string explicit_hosts = |
JoinPrefs(kPrefGrantedPermissions, kPrefExplicitHosts); |
if (ext->GetList(kPrefOldGrantedHosts, &hosts)) { |
@@ -1068,7 +1069,7 @@ void ExtensionPrefs::MigrateDisableReasons( |
UpdateExtensionPref(*ext_id, kPrefDisableReasons, |
new base::FundamentalValue(new_value)); |
// Remove the old disable reason. |
- UpdateExtensionPref(*ext_id, kDeprecatedPrefDisableReason, NULL); |
+ UpdateExtensionPref(*ext_id, kDeprecatedPrefDisableReason, nullptr); |
} |
} |
} |
@@ -1314,7 +1315,7 @@ void ExtensionPrefs::UpdateManifest(const Extension* extension) { |
GetExtensionPref(extension->id()); |
if (!extension_dict) |
return; |
- const base::DictionaryValue* old_manifest = NULL; |
+ const base::DictionaryValue* old_manifest = nullptr; |
bool update_required = |
!extension_dict->GetDictionary(kPrefManifest, &old_manifest) || |
!extension->manifest()->value()->Equals(old_manifest); |
@@ -1350,7 +1351,7 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( |
return scoped_ptr<ExtensionInfo>(); |
} |
- const base::DictionaryValue* manifest = NULL; |
+ const base::DictionaryValue* manifest = nullptr; |
if (!Manifest::IsUnpackedLocation(location) && |
!extension->GetDictionary(kPrefManifest, &manifest)) { |
LOG(WARNING) << "Missing manifest for extension " << extension_id; |
@@ -1371,7 +1372,7 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( |
scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledExtensionInfo( |
const std::string& extension_id) const { |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
const base::DictionaryValue* extensions = |
prefs_->GetDictionary(pref_names::kExtensions); |
if (!extensions || |
@@ -1416,7 +1417,7 @@ ExtensionPrefs::GetUninstalledExtensionsInfo() const { |
prefs_->GetDictionary(pref_names::kExtensions); |
for (base::DictionaryValue::Iterator extension_id(*extensions); |
!extension_id.IsAtEnd(); extension_id.Advance()) { |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
if (!crx_file::id_util::IdIsValid(extension_id.key()) || |
!IsExternalExtensionUninstalled(extension_id.key()) || |
!extension_id.value().GetAsDictionary(&ext)) |
@@ -1467,7 +1468,7 @@ bool ExtensionPrefs::RemoveDelayedInstallInfo( |
if (!GetExtensionPref(extension_id)) |
return false; |
ScopedExtensionPrefUpdate update(prefs_, extension_id); |
- bool result = update->Remove(kDelayedInstallInfo, NULL); |
+ bool result = update->Remove(kDelayedInstallInfo, nullptr); |
return result; |
} |
@@ -1476,7 +1477,7 @@ bool ExtensionPrefs::FinishDelayedInstallInfo( |
CHECK(crx_file::id_util::IdIsValid(extension_id)); |
ScopedExtensionPrefUpdate update(prefs_, extension_id); |
base::DictionaryValue* extension_dict = update.Get(); |
- base::DictionaryValue* pending_install_dict = NULL; |
+ base::DictionaryValue* pending_install_dict = nullptr; |
if (!extension_dict->GetDictionary(kDelayedInstallInfo, |
&pending_install_dict)) { |
return false; |
@@ -1491,9 +1492,9 @@ bool ExtensionPrefs::FinishDelayedInstallInfo( |
&serialized_ordinal)) { |
suggested_page_ordinal = syncer::StringOrdinal(serialized_ordinal); |
needs_sort_ordinal = true; |
- pending_install_dict->Remove(kPrefSuggestedPageOrdinal, NULL); |
+ pending_install_dict->Remove(kPrefSuggestedPageOrdinal, nullptr); |
} |
- pending_install_dict->Remove(kDelayedInstallReason, NULL); |
+ pending_install_dict->Remove(kDelayedInstallReason, nullptr); |
const base::Time install_time = time_provider_->GetCurrentTime(); |
pending_install_dict->Set( |
@@ -1504,7 +1505,7 @@ bool ExtensionPrefs::FinishDelayedInstallInfo( |
// Some extension pref values are written conditionally. If they are not |
// present in the delayed install data, they should be removed when the |
// delayed install is committed. |
- extension_dict->Remove(kPrefEphemeralApp, NULL); |
+ extension_dict->Remove(kPrefEphemeralApp, nullptr); |
// Commit the delayed install data. |
for (base::DictionaryValue::Iterator it(*pending_install_dict); !it.IsAtEnd(); |
@@ -1523,7 +1524,7 @@ scoped_ptr<ExtensionInfo> ExtensionPrefs::GetDelayedInstallInfo( |
if (!extension_prefs) |
return scoped_ptr<ExtensionInfo>(); |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
if (!extension_prefs->GetDictionary(kDelayedInstallInfo, &ext)) |
return scoped_ptr<ExtensionInfo>(); |
@@ -1537,7 +1538,7 @@ ExtensionPrefs::DelayReason ExtensionPrefs::GetDelayedInstallReason( |
if (!extension_prefs) |
return DELAY_REASON_NONE; |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
if (!extension_prefs->GetDictionary(kDelayedInstallInfo, &ext)) |
return DELAY_REASON_NONE; |
@@ -1579,7 +1580,7 @@ bool ExtensionPrefs::IsEphemeralApp(const std::string& extension_id) const { |
void ExtensionPrefs::OnEphemeralAppPromoted(const std::string& extension_id) { |
DCHECK(IsEphemeralApp(extension_id)); |
- UpdateExtensionPref(extension_id, kPrefEphemeralApp, NULL); |
+ UpdateExtensionPref(extension_id, kPrefEphemeralApp, nullptr); |
// Ephemerality was previously stored in the creation flags, so ensure the bit |
// is cleared. |
@@ -1641,7 +1642,7 @@ int ExtensionPrefs::GetCreationFlags(const std::string& extension_id) const { |
int ExtensionPrefs::GetDelayedInstallCreationFlags( |
const std::string& extension_id) const { |
int creation_flags = Extension::NO_FLAGS; |
- const base::DictionaryValue* delayed_info = NULL; |
+ const base::DictionaryValue* delayed_info = nullptr; |
if (ReadPrefAsDictionary(extension_id, kDelayedInstallInfo, &delayed_info)) { |
delayed_info->GetInteger(kPrefCreationFlags, &creation_flags); |
} |
@@ -1728,7 +1729,7 @@ ExtensionIdList ExtensionPrefs::GetExtensionsFrom( |
const PrefService* pref_service) { |
ExtensionIdList result; |
- const base::DictionaryValue* extension_prefs = NULL; |
+ const base::DictionaryValue* extension_prefs = nullptr; |
const base::Value* extension_prefs_value = |
pref_service->GetUserPrefValue(pref_names::kExtensions); |
if (!extension_prefs_value || |
@@ -1738,7 +1739,7 @@ ExtensionIdList ExtensionPrefs::GetExtensionsFrom( |
for (base::DictionaryValue::Iterator it(*extension_prefs); !it.IsAtEnd(); |
it.Advance()) { |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
if (!it.value().GetAsDictionary(&ext)) { |
NOTREACHED() << "Invalid pref for extension " << it.key(); |
continue; |
@@ -1817,11 +1818,11 @@ const base::DictionaryValue* ExtensionPrefs::GetGeometryCache( |
const std::string& extension_id) const { |
const base::DictionaryValue* extension_prefs = GetExtensionPref(extension_id); |
if (!extension_prefs) |
- return NULL; |
+ return nullptr; |
- const base::DictionaryValue* ext = NULL; |
+ const base::DictionaryValue* ext = nullptr; |
if (!extension_prefs->GetDictionary(kPrefGeometryCache, &ext)) |
- return NULL; |
+ return nullptr; |
return ext; |
} |
@@ -2045,7 +2046,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs( |
if (install_flags & kInstallFlagIsEphemeral) |
extension_dict->Set(kPrefEphemeralApp, new base::FundamentalValue(true)); |
else |
- extension_dict->Remove(kPrefEphemeralApp, NULL); |
+ extension_dict->Remove(kPrefEphemeralApp, nullptr); |
base::FilePath::StringType path = MakePathRelative(install_directory_, |
extension->path()); |
@@ -2065,7 +2066,7 @@ void ExtensionPrefs::PopulateExtensionInfoPrefs( |
if (install_flags & kInstallFlagDoNotSync) |
extension_dict->Set(kPrefDoNotSync, new base::FundamentalValue(true)); |
else |
- extension_dict->Remove(kPrefDoNotSync, NULL); |
+ extension_dict->Remove(kPrefDoNotSync, nullptr); |
} |
void ExtensionPrefs::InitExtensionControlledPrefs( |
@@ -2137,10 +2138,10 @@ void ExtensionPrefs::FinishExtensionInfoPrefs( |
// If this point has been reached, any pending installs should be considered |
// out of date. |
- extension_dict->Remove(kDelayedInstallInfo, NULL); |
+ extension_dict->Remove(kDelayedInstallInfo, nullptr); |
// Clear state that may be registered from a previous install. |
- extension_dict->Remove(EventRouter::kRegisteredEvents, NULL); |
+ extension_dict->Remove(EventRouter::kRegisteredEvents, nullptr); |
// FYI, all code below here races on sudden shutdown because |extension_dict|, |
// |app_sorting_|, |extension_pref_value_map_|, and (potentially) observers |