OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extension_prefs.h" | 5 #include "chrome/browser/extensions/extension_prefs.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 if (!IsBlacklistBitSet(ext)) { | 692 if (!IsBlacklistBitSet(ext)) { |
693 // This extension is not in blacklist. And it was not blacklisted | 693 // This extension is not in blacklist. And it was not blacklisted |
694 // before. | 694 // before. |
695 continue; | 695 continue; |
696 } else { | 696 } else { |
697 if (ext->size() == 1) { | 697 if (ext->size() == 1) { |
698 // We should remove the entry if the only flag here is blacklist. | 698 // We should remove the entry if the only flag here is blacklist. |
699 remove_pref_ids.push_back(id); | 699 remove_pref_ids.push_back(id); |
700 } else { | 700 } else { |
701 // Remove the blacklist bit. | 701 // Remove the blacklist bit. |
702 ext->Remove(kPrefBlacklist, NULL); | 702 UpdateExtensionPref(id, kPrefBlacklist, NULL); |
703 } | 703 } |
704 } | 704 } |
705 } else { | 705 } else { |
706 if (!IsBlacklistBitSet(ext)) { | 706 if (!IsBlacklistBitSet(ext)) { |
707 // Only set the blacklist if it was not set. | 707 // Only set the blacklist if it was not set. |
708 ext->SetBoolean(kPrefBlacklist, true); | 708 UpdateExtensionPref(id, kPrefBlacklist, |
| 709 Value::CreateBooleanValue(true)); |
709 } | 710 } |
710 // Keep the record if this extension is already processed. | 711 // Keep the record if this extension is already processed. |
711 used_id_set.insert(id); | 712 used_id_set.insert(id); |
712 } | 713 } |
713 } | 714 } |
714 } | 715 } |
715 | 716 |
716 // Iterate the leftovers to set blacklist in pref | 717 // Iterate the leftovers to set blacklist in pref |
717 std::set<std::string>::const_iterator set_itr = blacklist_set.begin(); | 718 std::set<std::string>::const_iterator set_itr = blacklist_set.begin(); |
718 for (; set_itr != blacklist_set.end(); ++set_itr) { | 719 for (; set_itr != blacklist_set.end(); ++set_itr) { |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 CHECK(out); | 1537 CHECK(out); |
1537 | 1538 |
1538 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); | 1539 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); |
1539 | 1540 |
1540 for (size_t i = 0; i < extensions_info->size(); ++i) { | 1541 for (size_t i = 0; i < extensions_info->size(); ++i) { |
1541 ExtensionInfo* info = extensions_info->at(i).get(); | 1542 ExtensionInfo* info = extensions_info->at(i).get(); |
1542 out->push_back(info->extension_id); | 1543 out->push_back(info->extension_id); |
1543 } | 1544 } |
1544 } | 1545 } |
1545 | 1546 |
| 1547 // static |
| 1548 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetExtensionsFrom( |
| 1549 const base::DictionaryValue* extension_prefs) { |
| 1550 ExtensionIdSet result; |
| 1551 for (base::DictionaryValue::key_iterator it = extension_prefs->begin_keys(); |
| 1552 it != extension_prefs->end_keys(); ++it) { |
| 1553 DictionaryValue* ext; |
| 1554 if (!extension_prefs->GetDictionaryWithoutPathExpansion(*it, &ext)) { |
| 1555 NOTREACHED() << "Invalid pref for extension " << *it; |
| 1556 continue; |
| 1557 } |
| 1558 if (!IsBlacklistBitSet(ext)) |
| 1559 result.push_back(*it); |
| 1560 } |
| 1561 return result; |
| 1562 } |
| 1563 |
1546 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdSet& extension_ids) { | 1564 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdSet& extension_ids) { |
1547 // Fix old entries that did not get an installation time entry when they | 1565 // Fix old entries that did not get an installation time entry when they |
1548 // were installed or don't have a preferences field. | 1566 // were installed or don't have a preferences field. |
1549 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); | 1567 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); |
1550 ext_id != extension_ids.end(); ++ext_id) { | 1568 ext_id != extension_ids.end(); ++ext_id) { |
1551 if (GetInstallTime(*ext_id) == base::Time()) { | 1569 if (GetInstallTime(*ext_id) == base::Time()) { |
1552 LOG(INFO) << "Could not parse installation time of extension " | 1570 LOG(INFO) << "Could not parse installation time of extension " |
1553 << *ext_id << ". It was probably installed before setting " | 1571 << *ext_id << ". It was probably installed before setting " |
1554 << kPrefInstallTime << " was introduced. Updating " | 1572 << kPrefInstallTime << " was introduced. Updating " |
1555 << kPrefInstallTime << " to the current time."; | 1573 << kPrefInstallTime << " to the current time."; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1759 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1777 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
1760 PrefService::UNSYNCABLE_PREF); | 1778 PrefService::UNSYNCABLE_PREF); |
1761 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1779 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
1762 PrefService::UNSYNCABLE_PREF); | 1780 PrefService::UNSYNCABLE_PREF); |
1763 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1781 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
1764 PrefService::UNSYNCABLE_PREF); | 1782 PrefService::UNSYNCABLE_PREF); |
1765 prefs->RegisterStringPref(kWebStoreLogin, | 1783 prefs->RegisterStringPref(kWebStoreLogin, |
1766 std::string() /* default_value */, | 1784 std::string() /* default_value */, |
1767 PrefService::UNSYNCABLE_PREF); | 1785 PrefService::UNSYNCABLE_PREF); |
1768 } | 1786 } |
OLD | NEW |