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

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

Issue 764643002: Remove WebViewKey in rules registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 6 years 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/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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 return base::UTF16ToUTF8(title); 107 return base::UTF16ToUTF8(title);
108 } 108 }
109 109
110 // Reports the number of rules registered for the |extension_id| with the 110 // Reports the number of rules registered for the |extension_id| with the
111 // non-webview rules registry. 111 // non-webview rules registry.
112 size_t NumberOfRegisteredRules(const std::string& extension_id) { 112 size_t NumberOfRegisteredRules(const std::string& extension_id) {
113 RulesRegistryService* rules_registry_service = 113 RulesRegistryService* rules_registry_service =
114 extensions::RulesRegistryService::Get(browser()->profile()); 114 extensions::RulesRegistryService::Get(browser()->profile());
115 scoped_refptr<RulesRegistry> rules_registry = 115 scoped_refptr<RulesRegistry> rules_registry =
116 rules_registry_service->GetRulesRegistry( 116 rules_registry_service->GetRulesRegistry(
117 RulesRegistry::WebViewKey(0, 0), 117 RulesRegistryService::kDefaultRulesRegistryID,
118 extensions::declarative_webrequest_constants::kOnRequest); 118 extensions::declarative_webrequest_constants::kOnRequest);
119 std::vector<linked_ptr<RulesRegistry::Rule> > rules; 119 std::vector<linked_ptr<RulesRegistry::Rule> > rules;
120 BrowserThread::PostTask( 120 BrowserThread::PostTask(
121 BrowserThread::IO, 121 BrowserThread::IO,
122 FROM_HERE, 122 FROM_HERE,
123 base::Bind( 123 base::Bind(
124 &RulesRegistry::GetAllRules, rules_registry, extension_id, &rules)); 124 &RulesRegistry::GetAllRules, rules_registry, extension_id, &rules));
125 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( 125 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper(
126 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get())); 126 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get()));
127 EXPECT_TRUE(io_helper->Run()); 127 EXPECT_TRUE(io_helper->Run());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile()); 247 ExtensionPrefs* extension_prefs = ExtensionPrefs::Get(browser()->profile());
248 EXPECT_TRUE(extension_prefs->HasPrefForExtension(extension_id)); 248 EXPECT_TRUE(extension_prefs->HasPrefForExtension(extension_id));
249 249
250 // 2. Uninstall the extension. Rules are gone and preferences should be empty. 250 // 2. Uninstall the extension. Rules are gone and preferences should be empty.
251 UninstallExtension(extension_id); 251 UninstallExtension(extension_id);
252 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl)); 252 ui_test_utils::NavigateToURL(browser(), GURL(kArbitraryUrl));
253 EXPECT_NE(kTestTitle, GetTitle()); 253 EXPECT_NE(kTestTitle, GetTitle());
254 EXPECT_EQ(0u, NumberOfRegisteredRules(extension_id)); 254 EXPECT_EQ(0u, NumberOfRegisteredRules(extension_id));
255 EXPECT_FALSE(extension_prefs->HasPrefForExtension(extension_id)); 255 EXPECT_FALSE(extension_prefs->HasPrefForExtension(extension_id));
256 } 256 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698