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 "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Reports the number of rules registered for the |extension_id| with the | 106 // Reports the number of rules registered for the |extension_id| with the |
107 // non-webview rules registry. | 107 // non-webview rules registry. |
108 size_t NumberOfRegisteredRules(const std::string& extension_id) { | 108 size_t NumberOfRegisteredRules(const std::string& extension_id) { |
109 RulesRegistryService* rules_registry_service = | 109 RulesRegistryService* rules_registry_service = |
110 extensions::RulesRegistryService::Get(browser()->profile()); | 110 extensions::RulesRegistryService::Get(browser()->profile()); |
111 scoped_refptr<RulesRegistry> rules_registry = | 111 scoped_refptr<RulesRegistry> rules_registry = |
112 rules_registry_service->GetRulesRegistry( | 112 rules_registry_service->GetRulesRegistry( |
113 RulesRegistryService::kDefaultRulesRegistryID, | 113 RulesRegistryService::kDefaultRulesRegistryID, |
114 extensions::declarative_webrequest_constants::kOnRequest); | 114 extensions::declarative_webrequest_constants::kOnRequest); |
115 | 115 |
116 std::vector<linked_ptr<core_api::events::Rule>> rules; | 116 std::vector<linked_ptr<api::events::Rule>> rules; |
117 BrowserThread::PostTask( | 117 BrowserThread::PostTask( |
118 BrowserThread::IO, | 118 BrowserThread::IO, |
119 FROM_HERE, | 119 FROM_HERE, |
120 base::Bind( | 120 base::Bind( |
121 &RulesRegistry::GetAllRules, rules_registry, extension_id, &rules)); | 121 &RulesRegistry::GetAllRules, rules_registry, extension_id, &rules)); |
122 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( | 122 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( |
123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); | 123 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); |
124 EXPECT_TRUE(io_helper->Run()); | 124 EXPECT_TRUE(io_helper->Run()); |
125 return rules.size(); | 125 return rules.size(); |
126 } | 126 } |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 // 2. Uninstall the extension. Rules are gone and preferences should be empty. | 247 // 2. Uninstall the extension. Rules are gone and preferences should be empty. |
248 UninstallExtension(extension_id); | 248 UninstallExtension(extension_id); |
249 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl)); | 249 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl)); |
250 EXPECT_NE(kTestTitle, GetTitle()); | 250 EXPECT_NE(kTestTitle, GetTitle()); |
251 EXPECT_EQ(0u, NumberOfRegisteredRules(extension_id)); | 251 EXPECT_EQ(0u, NumberOfRegisteredRules(extension_id)); |
252 EXPECT_FALSE(extension_prefs->HasPrefForExtension(extension_id)); | 252 EXPECT_FALSE(extension_prefs->HasPrefForExtension(extension_id)); |
253 } | 253 } |
254 | 254 |
255 } // namespace extensions | 255 } // namespace extensions |
OLD | NEW |