Commit ec5143b6 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Reland r223124: Don't clear existing extension-defined preferences and content...

Reland r223124: Don't clear existing extension-defined preferences and content settings when reloading or updating an extension.

TBR=falken@chromium.org,sky@chromium.org
BUG=284385

Original review: https://chromiumcodereview.appspot.com/23694020

Review URL: https://chromiumcodereview.appspot.com/23581015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223587 0039d316-1c4b-4281-b951-d872f2087c98
parent fc20fdd3
...@@ -123,15 +123,16 @@ void ContentSettingsStore::RegisterExtension( ...@@ -123,15 +123,16 @@ void ContentSettingsStore::RegisterExtension(
bool is_enabled) { bool is_enabled) {
base::AutoLock lock(lock_); base::AutoLock lock(lock_);
ExtensionEntryMap::iterator i = FindEntry(ext_id); ExtensionEntryMap::iterator i = FindEntry(ext_id);
ExtensionEntry* entry;
if (i != entries_.end()) { if (i != entries_.end()) {
delete i->second; entry = i->second;
entries_.erase(i); } else {
entry = new ExtensionEntry;
entries_.insert(std::make_pair(install_time, entry));
} }
ExtensionEntry* entry = new ExtensionEntry;
entry->id = ext_id; entry->id = ext_id;
entry->enabled = is_enabled; entry->enabled = is_enabled;
entries_.insert(std::make_pair(install_time, entry));
} }
void ContentSettingsStore::UnregisterExtension( void ContentSettingsStore::UnregisterExtension(
......
...@@ -116,10 +116,13 @@ bool ExtensionPrefValueMap::DoesExtensionControlPref( ...@@ -116,10 +116,13 @@ bool ExtensionPrefValueMap::DoesExtensionControlPref(
void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id, void ExtensionPrefValueMap::RegisterExtension(const std::string& ext_id,
const base::Time& install_time, const base::Time& install_time,
bool is_enabled) { bool is_enabled) {
if (entries_.find(ext_id) != entries_.end()) if (entries_.find(ext_id) == entries_.end()) {
UnregisterExtension(ext_id); entries_[ext_id] = new ExtensionEntry;
entries_[ext_id] = new ExtensionEntry;
entries_[ext_id]->install_time = install_time; // Only update the install time if the extension is newly installed.
entries_[ext_id]->install_time = install_time;
}
entries_[ext_id]->enabled = is_enabled; entries_[ext_id]->enabled = is_enabled;
} }
......
...@@ -1835,13 +1835,26 @@ void ExtensionPrefs::FinishExtensionInfoPrefs( ...@@ -1835,13 +1835,26 @@ void ExtensionPrefs::FinishExtensionInfoPrefs(
const syncer::StringOrdinal& suggested_page_ordinal, const syncer::StringOrdinal& suggested_page_ordinal,
DictionaryValue* extension_dict) { DictionaryValue* extension_dict) {
// Reinitializes various preferences with empty dictionaries. // Reinitializes various preferences with empty dictionaries.
extension_dict->Set(pref_names::kPrefPreferences, new DictionaryValue); if (!extension_dict->HasKey(pref_names::kPrefPreferences))
extension_dict->Set(pref_names::kPrefIncognitoPreferences, extension_dict->Set(pref_names::kPrefPreferences, new DictionaryValue);
new DictionaryValue);
extension_dict->Set(pref_names::kPrefRegularOnlyPreferences, if (!extension_dict->HasKey(pref_names::kPrefIncognitoPreferences)) {
new DictionaryValue); extension_dict->Set(pref_names::kPrefIncognitoPreferences,
extension_dict->Set(pref_names::kPrefContentSettings, new ListValue); new DictionaryValue);
extension_dict->Set(pref_names::kPrefIncognitoContentSettings, new ListValue); }
if (!extension_dict->HasKey(pref_names::kPrefRegularOnlyPreferences)) {
extension_dict->Set(pref_names::kPrefRegularOnlyPreferences,
new DictionaryValue);
}
if (!extension_dict->HasKey(pref_names::kPrefContentSettings))
extension_dict->Set(pref_names::kPrefContentSettings, new ListValue);
if (!extension_dict->HasKey(pref_names::kPrefIncognitoContentSettings)) {
extension_dict->Set(pref_names::kPrefIncognitoContentSettings,
new ListValue);
}
// If this point has been reached, any pending installs should be considered // If this point has been reached, any pending installs should be considered
// out of date. // out of date.
......
...@@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest, ...@@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(ManagedModeBlockModeTest,
QueryHistory(history_service, "", options, &results); QueryHistory(history_service, "", options, &results);
// Check that the entries have the correct blocked_visit value. // Check that the entries have the correct blocked_visit value.
EXPECT_EQ(2u, results.size()); ASSERT_EQ(2u, results.size());
EXPECT_EQ(blocked_url.spec(), results[0].url().spec()); EXPECT_EQ(blocked_url.spec(), results[0].url().spec());
EXPECT_TRUE(results[0].blocked_visit()); EXPECT_TRUE(results[0].blocked_visit());
EXPECT_EQ(allowed_url.spec(), results[1].url().spec()); EXPECT_EQ(allowed_url.spec(), results[1].url().spec());
......
...@@ -3,8 +3,5 @@ ...@@ -3,8 +3,5 @@
"version" : "0.1", "version" : "0.1",
"manifest_version": 2, "manifest_version": 2,
"description" : "Content Settings API Test Extension", "description" : "Content Settings API Test Extension",
"permissions": [ "contentSettings" ], "permissions": [ "contentSettings" ]
"background": {
"page": "test.html"
}
} }
...@@ -3,8 +3,5 @@ ...@@ -3,8 +3,5 @@
"version" : "0.1", "version" : "0.1",
"manifest_version": 2, "manifest_version": 2,
"description" : "Preferences API Test Extension", "description" : "Preferences API Test Extension",
"permissions": [ "privacy" ], "permissions": [ "privacy" ]
"background": {
"page": "test.html"
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment