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

Side by Side Diff: chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.cc

Issue 764643002: Remove WebViewKey in rules registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "chrome/browser/extensions/api/declarative_content/chrome_content_rules _registry.h" 5 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules _registry.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/declarative_content/content_action.h" 8 #include "chrome/browser/extensions/api/declarative_content/content_action.h"
9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h" 9 #include "chrome/browser/extensions/api/declarative_content/content_condition.h"
10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h" 10 #include "chrome/browser/extensions/api/declarative_content/content_constants.h"
11 #include "chrome/browser/extensions/extension_tab_util.h" 11 #include "chrome/browser/extensions/extension_tab_util.h"
12 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
13 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
14 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
15 #include "content/public/browser/render_process_host.h" 15 #include "content/public/browser/render_process_host.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "extensions/browser/api/declarative/rules_registry_service.h"
17 #include "extensions/browser/extension_registry.h" 18 #include "extensions/browser/extension_registry.h"
18 #include "extensions/browser/extension_system.h" 19 #include "extensions/browser/extension_system.h"
19 #include "extensions/common/extension_messages.h" 20 #include "extensions/common/extension_messages.h"
20 21
21 using url_matcher::URLMatcherConditionSet; 22 using url_matcher::URLMatcherConditionSet;
22 23
23 namespace extensions { 24 namespace extensions {
24 25
25 ChromeContentRulesRegistry::ChromeContentRulesRegistry( 26 ChromeContentRulesRegistry::ChromeContentRulesRegistry(
26 content::BrowserContext* browser_context, 27 content::BrowserContext* browser_context,
27 RulesCacheDelegate* cache_delegate) 28 RulesCacheDelegate* cache_delegate)
28 : ContentRulesRegistry(browser_context, 29 : ContentRulesRegistry(browser_context,
29 declarative_content_constants::kOnPageChanged, 30 declarative_content_constants::kOnPageChanged,
30 content::BrowserThread::UI, 31 content::BrowserThread::UI,
31 cache_delegate, 32 cache_delegate,
32 WebViewKey(0, 0)) { 33 RulesRegistryService::kDefultRulesRegistryID) {
33 extension_info_map_ = ExtensionSystem::Get(browser_context)->info_map(); 34 extension_info_map_ = ExtensionSystem::Get(browser_context)->info_map();
34 35
35 registrar_.Add(this, 36 registrar_.Add(this,
36 content::NOTIFICATION_RENDERER_PROCESS_CREATED, 37 content::NOTIFICATION_RENDERER_PROCESS_CREATED,
37 content::NotificationService::AllBrowserContextsAndSources()); 38 content::NotificationService::AllBrowserContextsAndSources());
38 registrar_.Add(this, 39 registrar_.Add(this,
39 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 40 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
40 content::NotificationService::AllBrowserContextsAndSources()); 41 content::NotificationService::AllBrowserContextsAndSources());
41 } 42 }
42 43
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 RulesMap new_content_rules; 160 RulesMap new_content_rules;
160 161
161 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule = 162 for (std::vector<linked_ptr<RulesRegistry::Rule> >::const_iterator rule =
162 rules.begin(); 163 rules.begin();
163 rule != rules.end(); 164 rule != rules.end();
164 ++rule) { 165 ++rule) {
165 ContentRule::GlobalRuleId rule_id(extension_id, *(*rule)->id); 166 ContentRule::GlobalRuleId rule_id(extension_id, *(*rule)->id);
166 DCHECK(content_rules_.find(rule_id) == content_rules_.end()); 167 DCHECK(content_rules_.find(rule_id) == content_rules_.end());
167 168
168 scoped_ptr<ContentRule> content_rule( 169 scoped_ptr<ContentRule> content_rule(
169 ContentRule::Create(url_matcher_.condition_factory(), 170 ContentRule::Create(url_matcher_.condition_factory(), browser_context(),
170 browser_context(), 171 extension, extension_installation_time, *rule,
171 extension, 172 ContentRule::ConsistencyChecker(), &error));
172 extension_installation_time,
173 *rule,
174 ContentRule::ConsistencyChecker(),
175 &error));
176 if (!error.empty()) { 173 if (!error.empty()) {
177 // Clean up temporary condition sets created during rule creation. 174 // Clean up temporary condition sets created during rule creation.
178 url_matcher_.ClearUnusedConditionSets(); 175 url_matcher_.ClearUnusedConditionSets();
179 return error; 176 return error;
180 } 177 }
181 DCHECK(content_rule); 178 DCHECK(content_rule);
182 179
183 new_content_rules[rule_id] = make_linked_ptr(content_rule.release()); 180 new_content_rules[rule_id] = make_linked_ptr(content_rule.release());
184 } 181 }
185 182
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 333
337 base::Time ChromeContentRulesRegistry::GetExtensionInstallationTime( 334 base::Time ChromeContentRulesRegistry::GetExtensionInstallationTime(
338 const std::string& extension_id) const { 335 const std::string& extension_id) const {
339 if (!extension_info_map_.get()) // May be NULL during testing. 336 if (!extension_info_map_.get()) // May be NULL during testing.
340 return base::Time(); 337 return base::Time();
341 338
342 return extension_info_map_->GetInstallTime(extension_id); 339 return extension_info_map_->GetInstallTime(extension_id);
343 } 340 }
344 341
345 } // namespace extensions 342 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698