summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api/declarative/declarative_apitest.cc
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 08:21:36 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 08:21:36 +0000
commitb813ed790aa8a212b197c231b883bdf193595aa3 (patch)
tree833830e3a6fd5895485efbada982ba36dcbc625f /chrome/browser/extensions/api/declarative/declarative_apitest.cc
parentb3ee317ffd1621d89a8ce1b330586667d5f9ba41 (diff)
downloadchromium_src-b813ed790aa8a212b197c231b883bdf193595aa3.zip
chromium_src-b813ed790aa8a212b197c231b883bdf193595aa3.tar.gz
chromium_src-b813ed790aa8a212b197c231b883bdf193595aa3.tar.bz2
Hook up WebRequestRulesRegistry into old WebRequest API
BUG=112155 TEST=no Review URL: https://chromiumcodereview.appspot.com/9965019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130867 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/declarative/declarative_apitest.cc')
-rw-r--r--chrome/browser/extensions/api/declarative/declarative_apitest.cc35
1 files changed, 13 insertions, 22 deletions
diff --git a/chrome/browser/extensions/api/declarative/declarative_apitest.cc b/chrome/browser/extensions/api/declarative/declarative_apitest.cc
index d40a401..3e56f45 100644
--- a/chrome/browser/extensions/api/declarative/declarative_apitest.cc
+++ b/chrome/browser/extensions/api/declarative/declarative_apitest.cc
@@ -7,9 +7,10 @@
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
+#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_constants.h"
#include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_registry.h"
#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
@@ -21,35 +22,18 @@ using extensions::RulesRegistry;
using extensions::RulesRegistryService;
using extensions::WebRequestRulesRegistry;
-namespace {
-const char kTestEvent[] = "experimental.webRequest.onRequest";
-} // namespace
-
class DeclarativeApiTest : public ExtensionApiTest {
public:
- DeclarativeApiTest() : rules_registry_(NULL) {}
+ DeclarativeApiTest() {}
virtual ~DeclarativeApiTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
ExtensionApiTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
}
-
- void RegisterTestRuleRegistry() {
- Profile* profile = browser()->profile();
- RulesRegistryService* rules_registry_service =
- profile->GetExtensionService()->GetRulesRegistryService();
- rules_registry_ = new WebRequestRulesRegistry();
- // TODO(battre): The registry should register itself when the
- // RulesRegistryService is instantiated.
- rules_registry_service->RegisterRulesRegistry(kTestEvent, rules_registry_);
- }
-
- scoped_refptr<RulesRegistry> rules_registry_;
};
IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, DeclarativeApi) {
- RegisterTestRuleRegistry();
ASSERT_TRUE(RunExtensionTest("declarative/api")) << message_;
// Check that unloading the page has removed all rules.
@@ -60,15 +44,22 @@ IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, DeclarativeApi) {
// to process this unloading. The next task to retrive all rules
// is therefore processed after the UnloadExtension task has been executed.
+ RulesRegistryService* rules_registry_service =
+ ExtensionSystemFactory::GetForProfile(browser()->profile())->
+ rules_registry_service();
+ scoped_refptr<RulesRegistry> rules_registry =
+ rules_registry_service->GetRulesRegistry(
+ extensions::declarative_webrequest_constants::kOnRequest);
+
std::vector<linked_ptr<RulesRegistry::Rule> > known_rules;
content::BrowserThread::PostTask(
- rules_registry_->GetOwnerThread(),
+ rules_registry->GetOwnerThread(),
FROM_HERE,
base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules),
- rules_registry_, extension_id, &known_rules));
+ rules_registry, extension_id, &known_rules));
- ui_test_utils::RunAllPendingInMessageLoop(rules_registry_->GetOwnerThread());
+ ui_test_utils::RunAllPendingInMessageLoop(rules_registry->GetOwnerThread());
EXPECT_TRUE(known_rules.empty());
}