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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_service_test_base.h" | 10 #include "chrome/browser/extensions/extension_service_test_base.h" |
11 #include "chrome/browser/extensions/pending_extension_manager.h" | 11 #include "chrome/browser/extensions/pending_extension_manager.h" |
12 #include "chrome/browser/extensions/shared_module_service.h" | 12 #include "chrome/browser/extensions/shared_module_service.h" |
13 #include "chrome/common/extensions/features/feature_channel.h" | 13 #include "chrome/common/extensions/features/feature_channel.h" |
14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
15 #include "extensions/browser/install_flag.h" | 15 #include "extensions/browser/install_flag.h" |
| 16 #include "extensions/browser/uninstall_reason.h" |
16 #include "extensions/common/extension_builder.h" | 17 #include "extensions/common/extension_builder.h" |
17 #include "extensions/common/id_util.h" | 18 #include "extensions/common/id_util.h" |
18 #include "extensions/common/value_builder.h" | 19 #include "extensions/common/value_builder.h" |
19 #include "sync/api/string_ordinal.h" | 20 #include "sync/api/string_ordinal.h" |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Return an extension with |id| which imports a module with the given | 26 // Return an extension with |id| which imports a module with the given |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 138 |
138 std::string extension_id = id_util::GenerateId("extension_id"); | 139 std::string extension_id = id_util::GenerateId("extension_id"); |
139 // Create and install an extension that imports our new module. | 140 // Create and install an extension that imports our new module. |
140 scoped_refptr<Extension> importing_extension = | 141 scoped_refptr<Extension> importing_extension = |
141 CreateExtensionImportingModule(shared_module->id(), extension_id, "1.0"); | 142 CreateExtensionImportingModule(shared_module->id(), extension_id, "1.0"); |
142 EXPECT_TRUE(InstallExtension(importing_extension, false)); | 143 EXPECT_TRUE(InstallExtension(importing_extension, false)); |
143 | 144 |
144 // Uninstall the extension that imports our module. | 145 // Uninstall the extension that imports our module. |
145 base::string16 error; | 146 base::string16 error; |
146 service()->UninstallExtension(importing_extension->id(), | 147 service()->UninstallExtension(importing_extension->id(), |
147 ExtensionService::UNINSTALL_REASON_FOR_TESTING, | 148 extensions::UNINSTALL_REASON_FOR_TESTING, |
148 &error); | 149 &error); |
149 EXPECT_TRUE(error.empty()); | 150 EXPECT_TRUE(error.empty()); |
150 | 151 |
151 // Since the module was only referenced by that single extension, it should | 152 // Since the module was only referenced by that single extension, it should |
152 // have been uninstalled as a side-effect of uninstalling the extension that | 153 // have been uninstalled as a side-effect of uninstalling the extension that |
153 // depended upon it. | 154 // depended upon it. |
154 EXPECT_FALSE(registry()->GetExtensionById(shared_module->id(), | 155 EXPECT_FALSE(registry()->GetExtensionById(shared_module->id(), |
155 ExtensionRegistry::EVERYTHING)); | 156 ExtensionRegistry::EVERYTHING)); |
156 } | 157 } |
157 | 158 |
158 TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUpdate) { | 159 TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUpdate) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 259 |
259 // Try to install an extension with an ID that is not whitelisted. | 260 // Try to install an extension with an ID that is not whitelisted. |
260 scoped_refptr<Extension> nonwhitelisted_extension = | 261 scoped_refptr<Extension> nonwhitelisted_extension = |
261 CreateExtensionImportingModule(shared_module->id(), | 262 CreateExtensionImportingModule(shared_module->id(), |
262 nonwhitelisted_id, | 263 nonwhitelisted_id, |
263 "1.0"); | 264 "1.0"); |
264 EXPECT_FALSE(InstallExtension(nonwhitelisted_extension, false)); | 265 EXPECT_FALSE(InstallExtension(nonwhitelisted_extension, false)); |
265 } | 266 } |
266 | 267 |
267 } // namespace extensions | 268 } // namespace extensions |
OLD | NEW |