diff options
Diffstat (limited to 'chromium/extensions/browser/extension_prefs.cc')
-rw-r--r-- | chromium/extensions/browser/extension_prefs.cc | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/chromium/extensions/browser/extension_prefs.cc b/chromium/extensions/browser/extension_prefs.cc index eac7d0aa27b..3c212c8bde9 100644 --- a/chromium/extensions/browser/extension_prefs.cc +++ b/chromium/extensions/browser/extension_prefs.cc @@ -786,10 +786,6 @@ int ExtensionPrefs::GetDisableReasons(const std::string& extension_id) const { int value = -1; if (ReadPrefAsInteger(extension_id, kPrefDisableReasons, &value) && value >= 0) { - // TODO(crbug.com/860198): After we've gotten rid of the migration code for - // DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC, we should maybe filter it out here - // just to be sure: - // value = value & ~disable_reason::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC; return value; } return disable_reason::DISABLE_NONE; @@ -1966,6 +1962,10 @@ ExtensionPrefs::ExtensionPrefs( MigrateToNewWithholdingPref(); MigrateToNewExternalUninstallPref(); + + MigrateYoutubeOffBookmarkApps(); + + MigrateDeprecatedDisableReasons(); } AppSorting* ExtensionPrefs::app_sorting() const { @@ -2246,6 +2246,47 @@ void ExtensionPrefs::FinishExtensionInfoPrefs( observer.OnExtensionRegistered(extension_id, install_time, is_enabled); } +void ExtensionPrefs::MigrateDeprecatedDisableReasons() { + std::unique_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); + + for (const auto& info : *extensions_info) { + const ExtensionId& extension_id = info->extension_id; + int disable_reasons = GetDisableReasons(extension_id); + if ((disable_reasons & + disable_reason::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC) == 0) + continue; + disable_reasons &= ~disable_reason::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC; + if (disable_reasons == 0) { + // We don't know exactly why the extension was disabled, but we don't + // want to just suddenly re-enable it. Default to disabling it by the + // user (which was most likely for coming in from sync, and is + // reversible). + disable_reasons = disable_reason::DISABLE_USER_ACTION; + } + ReplaceDisableReasons(extension_id, disable_reasons); + } +} + +void ExtensionPrefs::MigrateYoutubeOffBookmarkApps() { + const base::DictionaryValue* extensions_dictionary = + prefs_->GetDictionary(pref_names::kExtensions); + DCHECK(extensions_dictionary->is_dict()); + + const base::DictionaryValue* youtube_dictionary = nullptr; + if (!extensions_dictionary->GetDictionary(extension_misc::kYoutubeAppId, + &youtube_dictionary)) { + return; + } + int creation_flags = 0; + if (!youtube_dictionary->GetInteger(kPrefCreationFlags, &creation_flags) || + (creation_flags & Extension::FROM_BOOKMARK) == 0) { + return; + } + ScopedExtensionPrefUpdate update(prefs_, extension_misc::kYoutubeAppId); + creation_flags &= ~Extension::FROM_BOOKMARK; + update->SetInteger(kPrefCreationFlags, creation_flags); +} + void ExtensionPrefs::MigrateObsoleteExtensionPrefs() { const base::Value* extensions_dictionary = prefs_->GetDictionary(pref_names::kExtensions); |