OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_management_test_util.h" | 5 #include "chrome/browser/extensions/extension_management_test_util.h" |
6 | 6 |
7 #include "components/crx_file/id_util.h" | 7 #include "components/crx_file/id_util.h" |
8 | 8 |
9 namespace extensions { | 9 namespace extensions { |
10 | 10 |
11 namespace schema = schema_constants; | 11 namespace schema = schema_constants; |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 std::string make_path(std::string a, std::string b) { | 15 std::string make_path(std::string a, std::string b) { |
16 return a + "." + b; | 16 return a + "." + b; |
17 } | 17 } |
18 | 18 |
19 const char kInstallSourcesPath[] = "*.install_sources"; | 19 const char kInstallSourcesPath[] = "*.install_sources"; |
20 const char kAllowedTypesPath[] = "*.allowed_types"; | 20 const char kAllowedTypesPath[] = "*.allowed_types"; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 ExtensionManagementPrefUpdaterBase::ExtensionManagementPrefUpdaterBase() { | 24 ExtensionManagementPrefUpdaterBase::ExtensionManagementPrefUpdaterBase() { |
25 } | 25 } |
26 | 26 |
27 ExtensionManagementPrefUpdaterBase::~ExtensionManagementPrefUpdaterBase() { | 27 ExtensionManagementPrefUpdaterBase::~ExtensionManagementPrefUpdaterBase() { |
28 } | 28 } |
29 | 29 |
| 30 void ExtensionManagementPrefUpdaterBase::UnsetPerExtensionSettings( |
| 31 const ExtensionId& id) { |
| 32 DCHECK(crx_file::id_util::IdIsValid(id)); |
| 33 pref_->RemoveWithoutPathExpansion(id, NULL); |
| 34 } |
| 35 |
| 36 void ExtensionManagementPrefUpdaterBase::ClearPerExtensionSettings( |
| 37 const ExtensionId& id) { |
| 38 DCHECK(crx_file::id_util::IdIsValid(id)); |
| 39 pref_->SetWithoutPathExpansion(id, new base::DictionaryValue()); |
| 40 } |
| 41 |
30 void ExtensionManagementPrefUpdaterBase::SetBlacklistedByDefault(bool value) { | 42 void ExtensionManagementPrefUpdaterBase::SetBlacklistedByDefault(bool value) { |
31 pref_->SetString(make_path(schema::kWildcard, schema::kInstallationMode), | 43 pref_->SetString(make_path(schema::kWildcard, schema::kInstallationMode), |
32 value ? schema::kBlocked : schema::kAllowed); | 44 value ? schema::kBlocked : schema::kAllowed); |
33 } | 45 } |
34 | 46 |
35 void ExtensionManagementPrefUpdaterBase:: | 47 void ExtensionManagementPrefUpdaterBase:: |
36 ClearInstallationModesForIndividualExtensions() { | 48 ClearInstallationModesForIndividualExtensions() { |
37 for (base::DictionaryValue::Iterator it(*pref_.get()); !it.IsAtEnd(); | 49 for (base::DictionaryValue::Iterator it(*pref_.get()); !it.IsAtEnd(); |
38 it.Advance()) { | 50 it.Advance()) { |
39 DCHECK(it.value().IsType(base::Value::TYPE_DICTIONARY)); | 51 DCHECK(it.value().IsType(base::Value::TYPE_DICTIONARY)); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 143 |
132 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( | 144 void ExtensionManagementPrefUpdaterBase::RemoveStringFromList( |
133 const std::string& path, | 145 const std::string& path, |
134 const std::string& str) { | 146 const std::string& str) { |
135 base::ListValue* list_value = NULL; | 147 base::ListValue* list_value = NULL; |
136 if (pref_->GetList(path, &list_value)) | 148 if (pref_->GetList(path, &list_value)) |
137 CHECK(list_value->Remove(base::StringValue(str), NULL)); | 149 CHECK(list_value->Remove(base::StringValue(str), NULL)); |
138 } | 150 } |
139 | 151 |
140 } // namespace extensions | 152 } // namespace extensions |
OLD | NEW |