| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
| 10 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" | 10 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Check that unloading the page has removed all rules. | 39 // Check that unloading the page has removed all rules. |
| 40 std::string extension_id = GetSingleLoadedExtension()->id(); | 40 std::string extension_id = GetSingleLoadedExtension()->id(); |
| 41 UnloadExtension(extension_id); | 41 UnloadExtension(extension_id); |
| 42 | 42 |
| 43 // UnloadExtension posts a task to the owner thread of the extension | 43 // UnloadExtension posts a task to the owner thread of the extension |
| 44 // to process this unloading. The next task to retrive all rules | 44 // to process this unloading. The next task to retrive all rules |
| 45 // is therefore processed after the UnloadExtension task has been executed. | 45 // is therefore processed after the UnloadExtension task has been executed. |
| 46 | 46 |
| 47 RulesRegistryService* rules_registry_service = | 47 RulesRegistryService* rules_registry_service = |
| 48 extensions::ExtensionSystemFactory::GetForProfile(browser()->profile())-> | 48 extensions::ProfileKeyedAPIFactory<RulesRegistryService>::GetForProfile( |
| 49 rules_registry_service(); | 49 browser()->profile()); |
| 50 scoped_refptr<RulesRegistry> rules_registry = | 50 scoped_refptr<RulesRegistry> rules_registry = |
| 51 rules_registry_service->GetRulesRegistry( | 51 rules_registry_service->GetRulesRegistry( |
| 52 extensions::declarative_webrequest_constants::kOnRequest); | 52 extensions::declarative_webrequest_constants::kOnRequest); |
| 53 | 53 |
| 54 std::vector<linked_ptr<RulesRegistry::Rule> > known_rules; | 54 std::vector<linked_ptr<RulesRegistry::Rule> > known_rules; |
| 55 | 55 |
| 56 content::BrowserThread::PostTask( | 56 content::BrowserThread::PostTask( |
| 57 rules_registry->GetOwnerThread(), | 57 rules_registry->GetOwnerThread(), |
| 58 FROM_HERE, | 58 FROM_HERE, |
| 59 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules), | 59 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules), |
| 60 rules_registry, extension_id, &known_rules)); | 60 rules_registry, extension_id, &known_rules)); |
| 61 | 61 |
| 62 content::RunAllPendingInMessageLoop(rules_registry->GetOwnerThread()); | 62 content::RunAllPendingInMessageLoop(rules_registry->GetOwnerThread()); |
| 63 | 63 |
| 64 EXPECT_TRUE(known_rules.empty()); | 64 EXPECT_TRUE(known_rules.empty()); |
| 65 } | 65 } |
| OLD | NEW |