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

Side by Side Diff: chrome/browser/extensions/api/declarative/declarative_apitest.cc

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits Created 7 years, 1 month 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 (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 "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" 10 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 UnloadExtension(extension_id); 50 UnloadExtension(extension_id);
51 51
52 // UnloadExtension posts a task to the owner thread of the extension 52 // UnloadExtension posts a task to the owner thread of the extension
53 // to process this unloading. The next task to retrive all rules 53 // to process this unloading. The next task to retrive all rules
54 // is therefore processed after the UnloadExtension task has been executed. 54 // is therefore processed after the UnloadExtension task has been executed.
55 55
56 RulesRegistryService* rules_registry_service = 56 RulesRegistryService* rules_registry_service =
57 extensions::RulesRegistryService::Get(browser()->profile()); 57 extensions::RulesRegistryService::Get(browser()->profile());
58 scoped_refptr<RulesRegistry> rules_registry = 58 scoped_refptr<RulesRegistry> rules_registry =
59 rules_registry_service->GetRulesRegistry( 59 rules_registry_service->GetRulesRegistry(
60 RulesRegistry::WebViewKey(0, 0),
60 extensions::declarative_webrequest_constants::kOnRequest); 61 extensions::declarative_webrequest_constants::kOnRequest);
61 62
62 std::vector<linked_ptr<RulesRegistry::Rule> > known_rules; 63 std::vector<linked_ptr<RulesRegistry::Rule> > known_rules;
63 64
64 content::BrowserThread::PostTask( 65 content::BrowserThread::PostTask(
65 rules_registry->owner_thread(), 66 rules_registry->owner_thread(),
66 FROM_HERE, 67 FROM_HERE,
67 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules), 68 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules),
68 rules_registry, extension_id, &known_rules)); 69 rules_registry, extension_id, &known_rules));
69 70
70 content::RunAllPendingInMessageLoop(rules_registry->owner_thread()); 71 content::RunAllPendingInMessageLoop(rules_registry->owner_thread());
71 72
72 EXPECT_TRUE(known_rules.empty()); 73 EXPECT_TRUE(known_rules.empty());
73 } 74 }
74 75
75 // PersistRules test first installs an extension, which registers some rules. 76 // PersistRules test first installs an extension, which registers some rules.
76 // Then after browser restart, it checks that the rules are still in effect. 77 // Then after browser restart, it checks that the rules are still in effect.
77 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, PRE_PersistRules) { 78 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, PRE_PersistRules) {
78 ASSERT_TRUE(RunExtensionTest("declarative/redirect_to_data")) << message_; 79 ASSERT_TRUE(RunExtensionTest("declarative/redirect_to_data")) << message_;
79 } 80 }
80 81
81 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, PersistRules) { 82 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, PersistRules) {
82 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl)); 83 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl));
83 EXPECT_EQ(kTestTitle, GetTitle()); 84 EXPECT_EQ(kTestTitle, GetTitle());
84 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698