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

Side by Side Diff: chrome/browser/extensions/extension_prefs.cc

Issue 9620010: Added Protector backup for Preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments, removed blacklist from extension ID list, added unittest. Created 8 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 CHECK(out); 1536 CHECK(out);
1537 1537
1538 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo()); 1538 scoped_ptr<ExtensionsInfo> extensions_info(GetInstalledExtensionsInfo());
1539 1539
1540 for (size_t i = 0; i < extensions_info->size(); ++i) { 1540 for (size_t i = 0; i < extensions_info->size(); ++i) {
1541 ExtensionInfo* info = extensions_info->at(i).get(); 1541 ExtensionInfo* info = extensions_info->at(i).get();
1542 out->push_back(info->extension_id); 1542 out->push_back(info->extension_id);
1543 } 1543 }
1544 } 1544 }
1545 1545
1546 // static
1547 void ExtensionPrefs::GetExtensionsFrom(
1548 const base::DictionaryValue* extension_prefs,
1549 ExtensionIdSet* out) {
1550 CHECK(out);
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 out->push_back(*it);
1560 }
1561 }
1562
1546 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdSet& extension_ids) { 1563 void ExtensionPrefs::FixMissingPrefs(const ExtensionIdSet& extension_ids) {
1547 // Fix old entries that did not get an installation time entry when they 1564 // Fix old entries that did not get an installation time entry when they
1548 // were installed or don't have a preferences field. 1565 // were installed or don't have a preferences field.
1549 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); 1566 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin();
1550 ext_id != extension_ids.end(); ++ext_id) { 1567 ext_id != extension_ids.end(); ++ext_id) {
1551 if (GetInstallTime(*ext_id) == base::Time()) { 1568 if (GetInstallTime(*ext_id) == base::Time()) {
1552 LOG(INFO) << "Could not parse installation time of extension " 1569 LOG(INFO) << "Could not parse installation time of extension "
1553 << *ext_id << ". It was probably installed before setting " 1570 << *ext_id << ". It was probably installed before setting "
1554 << kPrefInstallTime << " was introduced. Updating " 1571 << kPrefInstallTime << " was introduced. Updating "
1555 << kPrefInstallTime << " to the current time."; 1572 << kPrefInstallTime << " to the current time.";
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, 1776 prefs->RegisterListPref(prefs::kExtensionInstallAllowList,
1760 PrefService::UNSYNCABLE_PREF); 1777 PrefService::UNSYNCABLE_PREF);
1761 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, 1778 prefs->RegisterListPref(prefs::kExtensionInstallDenyList,
1762 PrefService::UNSYNCABLE_PREF); 1779 PrefService::UNSYNCABLE_PREF);
1763 prefs->RegisterListPref(prefs::kExtensionInstallForceList, 1780 prefs->RegisterListPref(prefs::kExtensionInstallForceList,
1764 PrefService::UNSYNCABLE_PREF); 1781 PrefService::UNSYNCABLE_PREF);
1765 prefs->RegisterStringPref(kWebStoreLogin, 1782 prefs->RegisterStringPref(kWebStoreLogin,
1766 std::string() /* default_value */, 1783 std::string() /* default_value */,
1767 PrefService::UNSYNCABLE_PREF); 1784 PrefService::UNSYNCABLE_PREF);
1768 } 1785 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698