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

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

Issue 1549233002: Convert Pass()→std::move() in //chrome/browser/extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 12 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
OLDNEW
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/shared_module_service.h" 5 #include "chrome/browser/extensions/shared_module_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 25 matching lines...) Expand all
36 DictionaryBuilder builder; 36 DictionaryBuilder builder;
37 builder.Set("name", "Has Dependent Modules") 37 builder.Set("name", "Has Dependent Modules")
38 .Set("version", version) 38 .Set("version", version)
39 .Set("manifest_version", 2); 39 .Set("manifest_version", 2);
40 if (!import_id.empty()) { 40 if (!import_id.empty()) {
41 builder.Set("import", std::move(ListBuilder().Append(std::move( 41 builder.Set("import", std::move(ListBuilder().Append(std::move(
42 DictionaryBuilder().Set("id", import_id))))); 42 DictionaryBuilder().Set("id", import_id)))));
43 } 43 }
44 scoped_ptr<base::DictionaryValue> manifest = builder.Build(); 44 scoped_ptr<base::DictionaryValue> manifest = builder.Build();
45 45
46 return ExtensionBuilder().SetManifest(manifest.Pass()) 46 return ExtensionBuilder()
47 .AddFlags(Extension::FROM_WEBSTORE) 47 .SetManifest(std::move(manifest))
48 .SetID(id) 48 .AddFlags(Extension::FROM_WEBSTORE)
49 .Build(); 49 .SetID(id)
50 .Build();
50 } 51 }
51 52
52 } // namespace 53 } // namespace
53 54
54 class SharedModuleServiceUnitTest : public ExtensionServiceTestBase { 55 class SharedModuleServiceUnitTest : public ExtensionServiceTestBase {
55 public: 56 public:
56 SharedModuleServiceUnitTest() : 57 SharedModuleServiceUnitTest() :
57 // The "export" key is open for dev-channel only, but unit tests 58 // The "export" key is open for dev-channel only, but unit tests
58 // run as stable channel on the official Windows build. 59 // run as stable channel on the official Windows build.
59 current_channel_(version_info::Channel::UNKNOWN) {} 60 current_channel_(version_info::Channel::UNKNOWN) {}
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 DictionaryBuilder() 129 DictionaryBuilder()
129 .Set("name", "Shared Module") 130 .Set("name", "Shared Module")
130 .Set("version", "1.0") 131 .Set("version", "1.0")
131 .Set("manifest_version", 2) 132 .Set("manifest_version", 2)
132 .Set("export", 133 .Set("export",
133 std::move(DictionaryBuilder().Set( 134 std::move(DictionaryBuilder().Set(
134 "resources", std::move(ListBuilder().Append("foo.js"))))) 135 "resources", std::move(ListBuilder().Append("foo.js")))))
135 .Build(); 136 .Build();
136 scoped_refptr<Extension> shared_module = 137 scoped_refptr<Extension> shared_module =
137 ExtensionBuilder() 138 ExtensionBuilder()
138 .SetManifest(manifest.Pass()) 139 .SetManifest(std::move(manifest))
139 .AddFlags(Extension::FROM_WEBSTORE) 140 .AddFlags(Extension::FROM_WEBSTORE)
140 .SetID(crx_file::id_util::GenerateId("shared_module")) 141 .SetID(crx_file::id_util::GenerateId("shared_module"))
141 .Build(); 142 .Build();
142 143
143 EXPECT_TRUE(InstallExtension(shared_module.get(), false)); 144 EXPECT_TRUE(InstallExtension(shared_module.get(), false));
144 145
145 std::string extension_id = crx_file::id_util::GenerateId("extension_id"); 146 std::string extension_id = crx_file::id_util::GenerateId("extension_id");
146 // Create and install an extension that imports our new module. 147 // Create and install an extension that imports our new module.
147 scoped_refptr<Extension> importing_extension = 148 scoped_refptr<Extension> importing_extension =
148 CreateExtensionImportingModule(shared_module->id(), extension_id, "1.0"); 149 CreateExtensionImportingModule(shared_module->id(), extension_id, "1.0");
(...skipping 20 matching lines...) Expand all
169 DictionaryBuilder() 170 DictionaryBuilder()
170 .Set("name", "Shared Module 1") 171 .Set("name", "Shared Module 1")
171 .Set("version", "1.0") 172 .Set("version", "1.0")
172 .Set("manifest_version", 2) 173 .Set("manifest_version", 2)
173 .Set("export", 174 .Set("export",
174 std::move(DictionaryBuilder().Set( 175 std::move(DictionaryBuilder().Set(
175 "resources", std::move(ListBuilder().Append("foo.js"))))) 176 "resources", std::move(ListBuilder().Append("foo.js")))))
176 .Build(); 177 .Build();
177 scoped_refptr<Extension> shared_module_1 = 178 scoped_refptr<Extension> shared_module_1 =
178 ExtensionBuilder() 179 ExtensionBuilder()
179 .SetManifest(manifest_1.Pass()) 180 .SetManifest(std::move(manifest_1))
180 .AddFlags(Extension::FROM_WEBSTORE) 181 .AddFlags(Extension::FROM_WEBSTORE)
181 .SetID(crx_file::id_util::GenerateId("shared_module_1")) 182 .SetID(crx_file::id_util::GenerateId("shared_module_1"))
182 .Build(); 183 .Build();
183 EXPECT_TRUE(InstallExtension(shared_module_1.get(), false)); 184 EXPECT_TRUE(InstallExtension(shared_module_1.get(), false));
184 185
185 scoped_ptr<base::DictionaryValue> manifest_2 = 186 scoped_ptr<base::DictionaryValue> manifest_2 =
186 DictionaryBuilder() 187 DictionaryBuilder()
187 .Set("name", "Shared Module 2") 188 .Set("name", "Shared Module 2")
188 .Set("version", "1.0") 189 .Set("version", "1.0")
189 .Set("manifest_version", 2) 190 .Set("manifest_version", 2)
190 .Set("export", 191 .Set("export",
191 std::move(DictionaryBuilder().Set( 192 std::move(DictionaryBuilder().Set(
192 "resources", std::move(ListBuilder().Append("foo.js"))))) 193 "resources", std::move(ListBuilder().Append("foo.js")))))
193 .Build(); 194 .Build();
194 scoped_refptr<Extension> shared_module_2 = 195 scoped_refptr<Extension> shared_module_2 =
195 ExtensionBuilder() 196 ExtensionBuilder()
196 .SetManifest(manifest_2.Pass()) 197 .SetManifest(std::move(manifest_2))
197 .AddFlags(Extension::FROM_WEBSTORE) 198 .AddFlags(Extension::FROM_WEBSTORE)
198 .SetID(crx_file::id_util::GenerateId("shared_module_2")) 199 .SetID(crx_file::id_util::GenerateId("shared_module_2"))
199 .Build(); 200 .Build();
200 EXPECT_TRUE(InstallExtension(shared_module_2.get(), false)); 201 EXPECT_TRUE(InstallExtension(shared_module_2.get(), false));
201 202
202 std::string extension_id = crx_file::id_util::GenerateId("extension_id"); 203 std::string extension_id = crx_file::id_util::GenerateId("extension_id");
203 204
204 // Create and install an extension v1.0 that imports our new module 1. 205 // Create and install an extension v1.0 that imports our new module 1.
205 scoped_refptr<Extension> importing_extension_1 = 206 scoped_refptr<Extension> importing_extension_1 =
206 CreateExtensionImportingModule(shared_module_1->id(), 207 CreateExtensionImportingModule(shared_module_1->id(),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 .Set("manifest_version", 2) 251 .Set("manifest_version", 2)
251 .Set("export", 252 .Set("export",
252 std::move( 253 std::move(
253 DictionaryBuilder() 254 DictionaryBuilder()
254 .Set("whitelist", 255 .Set("whitelist",
255 std::move(ListBuilder().Append(whitelisted_id))) 256 std::move(ListBuilder().Append(whitelisted_id)))
256 .Set("resources", std::move(ListBuilder().Append("*"))))) 257 .Set("resources", std::move(ListBuilder().Append("*")))))
257 .Build(); 258 .Build();
258 scoped_refptr<Extension> shared_module = 259 scoped_refptr<Extension> shared_module =
259 ExtensionBuilder() 260 ExtensionBuilder()
260 .SetManifest(manifest.Pass()) 261 .SetManifest(std::move(manifest))
261 .AddFlags(Extension::FROM_WEBSTORE) 262 .AddFlags(Extension::FROM_WEBSTORE)
262 .SetID(crx_file::id_util::GenerateId("shared_module")) 263 .SetID(crx_file::id_util::GenerateId("shared_module"))
263 .Build(); 264 .Build();
264 265
265 EXPECT_TRUE(InstallExtension(shared_module.get(), false)); 266 EXPECT_TRUE(InstallExtension(shared_module.get(), false));
266 267
267 // Create and install an extension with the whitelisted ID. 268 // Create and install an extension with the whitelisted ID.
268 scoped_refptr<Extension> whitelisted_extension = 269 scoped_refptr<Extension> whitelisted_extension =
269 CreateExtensionImportingModule(shared_module->id(), 270 CreateExtensionImportingModule(shared_module->id(),
270 whitelisted_id, 271 whitelisted_id,
271 "1.0"); 272 "1.0");
272 EXPECT_TRUE(InstallExtension(whitelisted_extension.get(), false)); 273 EXPECT_TRUE(InstallExtension(whitelisted_extension.get(), false));
273 274
274 // Try to install an extension with an ID that is not whitelisted. 275 // Try to install an extension with an ID that is not whitelisted.
275 scoped_refptr<Extension> nonwhitelisted_extension = 276 scoped_refptr<Extension> nonwhitelisted_extension =
276 CreateExtensionImportingModule(shared_module->id(), 277 CreateExtensionImportingModule(shared_module->id(),
277 nonwhitelisted_id, 278 nonwhitelisted_id,
278 "1.0"); 279 "1.0");
279 // This should succeed because only CRX installer (and by extension the 280 // This should succeed because only CRX installer (and by extension the
280 // WebStore Installer) checks the shared module whitelist. InstallExtension 281 // WebStore Installer) checks the shared module whitelist. InstallExtension
281 // bypasses the whitelist check because the SharedModuleService does not 282 // bypasses the whitelist check because the SharedModuleService does not
282 // care about whitelists. 283 // care about whitelists.
283 EXPECT_TRUE(InstallExtension(nonwhitelisted_extension.get(), false)); 284 EXPECT_TRUE(InstallExtension(nonwhitelisted_extension.get(), false));
284 } 285 }
285 286
286 } // namespace extensions 287 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/shared_module_service.cc ('k') | chrome/browser/extensions/test_extension_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698