OLD | NEW |
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 "extensions/browser/api/declarative/rules_registry.h" | 5 #include "extensions/browser/api/declarative/rules_registry.h" |
6 | 6 |
7 // Here we test the TestRulesRegistry which is the simplest possible | 7 // Here we test the TestRulesRegistry which is the simplest possible |
8 // implementation of RulesRegistryWithCache as a proxy for | 8 // implementation of RulesRegistryWithCache as a proxy for |
9 // RulesRegistryWithCache. | 9 // RulesRegistryWithCache. |
10 | 10 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 // on registry (in particular, browser) restart. | 335 // on registry (in particular, browser) restart. |
336 | 336 |
337 // TODO(vabr): Once some API using declarative rules enters the stable | 337 // TODO(vabr): Once some API using declarative rules enters the stable |
338 // channel, make sure to use that API here, and remove |channel|. | 338 // channel, make sure to use that API here, and remove |channel|. |
339 ScopedCurrentChannel channel(version_info::Channel::UNKNOWN); | 339 ScopedCurrentChannel channel(version_info::Channel::UNKNOWN); |
340 | 340 |
341 ExtensionService* extension_service = env_.GetExtensionService(); | 341 ExtensionService* extension_service = env_.GetExtensionService(); |
342 | 342 |
343 // 1. Add an extension, before rules registry gets created. | 343 // 1. Add an extension, before rules registry gets created. |
344 std::string error; | 344 std::string error; |
345 scoped_refptr<Extension> extension( | 345 scoped_refptr<Extension> extension(LoadManifestUnchecked( |
346 LoadManifestUnchecked("permissions", | 346 "permissions", "web_request_all_host_permissions.json", |
347 "web_request_all_host_permissions.json", | 347 Manifest::UNPACKED, Extension::NO_FLAGS, extension1_->id(), &error)); |
348 Manifest::INVALID_LOCATION, | |
349 Extension::NO_FLAGS, | |
350 extension1_->id(), | |
351 &error)); | |
352 ASSERT_TRUE(error.empty()); | 348 ASSERT_TRUE(error.empty()); |
353 extension_service->AddExtension(extension.get()); | 349 extension_service->AddExtension(extension.get()); |
354 EXPECT_TRUE(extensions::ExtensionRegistry::Get(env_.profile()) | 350 EXPECT_TRUE(extensions::ExtensionRegistry::Get(env_.profile()) |
355 ->enabled_extensions() | 351 ->enabled_extensions() |
356 .Contains(extension->id())); | 352 .Contains(extension->id())); |
357 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( | 353 EXPECT_TRUE(extension->permissions_data()->HasAPIPermission( |
358 APIPermission::kDeclarativeWebRequest)); | 354 APIPermission::kDeclarativeWebRequest)); |
359 env_.GetExtensionSystem()->SetReady(); | 355 env_.GetExtensionSystem()->SetReady(); |
360 | 356 |
361 // 2. First run, adding a rule for the extension. | 357 // 2. First run, adding a rule for the extension. |
(...skipping 29 matching lines...) Expand all Loading... |
391 | 387 |
392 int write_count = 0; | 388 int write_count = 0; |
393 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); | 389 EXPECT_EQ("", AddRule(extension1_->id(), kRuleId)); |
394 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); | 390 EXPECT_EQ("", AddRule(extension2_->id(), kRule2Id)); |
395 env_.GetExtensionSystem()->SetReady(); | 391 env_.GetExtensionSystem()->SetReady(); |
396 base::RunLoop().RunUntilIdle(); | 392 base::RunLoop().RunUntilIdle(); |
397 EXPECT_EQ(write_count + 2, system->value_store()->write_count()); | 393 EXPECT_EQ(write_count + 2, system->value_store()->write_count()); |
398 } | 394 } |
399 | 395 |
400 } // namespace extensions | 396 } // namespace extensions |
OLD | NEW |