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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_service.h

Issue 344433003: Prepare declarativeContent API for new script injection feature. Added Javascript types and functio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up declarative_content.json and store RequestContentScript data in action object Created 6 years, 5 months 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "chrome/browser/extensions/api/declarative/rules_registry.h" 16 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
17 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "extensions/browser/browser_context_keyed_api_factory.h" 21 #include "extensions/browser/browser_context_keyed_api_factory.h"
21 #include "extensions/browser/extension_registry_observer.h" 22 #include "extensions/browser/extension_registry_observer.h"
22 23
23 class Profile; 24 class Profile;
24 25
25 namespace content { 26 namespace content {
26 class BrowserContext; 27 class BrowserContext;
27 class NotificationSource; 28 class NotificationSource;
28 } 29 }
29 30
30 namespace extensions { 31 namespace extensions {
31 class ContentRulesRegistry;
32 class ExtensionRegistry; 32 class ExtensionRegistry;
33 class RulesRegistry; 33 class RulesRegistry;
34 class RulesRegistryStorageDelegate; 34 class RulesRegistryStorageDelegate;
35 } 35 }
36 36
37 namespace extensions { 37 namespace extensions {
38 38
39 // This class owns all RulesRegistries implementations of an ExtensionService. 39 // This class owns all RulesRegistries implementations of an ExtensionService.
40 // This class lives on the UI thread. 40 // This class lives on the UI thread.
41 class RulesRegistryService : public BrowserContextKeyedAPI, 41 class RulesRegistryService : public BrowserContextKeyedAPI,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry. 77 // Registers a RulesRegistry and wraps it in an InitializingRulesRegistry.
78 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry); 78 void RegisterRulesRegistry(scoped_refptr<RulesRegistry> rule_registry);
79 79
80 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no 80 // Returns the RulesRegistry for |event_name| and |webview_key| or NULL if no
81 // such registry has been registered. Default rules registries (such as the 81 // such registry has been registered. Default rules registries (such as the
82 // WebRequest rules registry) will be created on first access. 82 // WebRequest rules registry) will be created on first access.
83 scoped_refptr<RulesRegistry> GetRulesRegistry( 83 scoped_refptr<RulesRegistry> GetRulesRegistry(
84 const WebViewKey& webview_key, 84 const WebViewKey& webview_key,
85 const std::string& event_name); 85 const std::string& event_name);
86 86
87 // Accessors for each type of rules registry. 87 // Accessors for content rules registries.
88 ContentRulesRegistry* content_rules_registry() const { 88 std::map<std::string, ContentRulesRegistry*>& content_rules_registry_map() {
89 CHECK(content_rules_registry_); 89 return content_rules_registry_map_;
90 return content_rules_registry_;
91 } 90 }
91 ContentRulesRegistry* GetContentRulesRegistry(
92 const std::string& event_name);
92 93
93 // Removes all rules registries of a given webview embedder process ID. 94 // Removes all rules registries of a given webview embedder process ID.
94 void RemoveWebViewRulesRegistries(int process_id); 95 void RemoveWebViewRulesRegistries(int process_id);
95 96
96 // For testing. 97 // For testing.
97 void SimulateExtensionUninstalled(const std::string& extension_id); 98 void SimulateExtensionUninstalled(const std::string& extension_id);
98 99
99 private: 100 private:
100 friend class BrowserContextKeyedAPIFactory<RulesRegistryService>; 101 friend class BrowserContextKeyedAPIFactory<RulesRegistryService>;
101 102
(...skipping 30 matching lines...) Expand all
132 return "RulesRegistryService"; 133 return "RulesRegistryService";
133 } 134 }
134 static const bool kServiceHasOwnInstanceInIncognito = true; 135 static const bool kServiceHasOwnInstanceInIncognito = true;
135 static const bool kServiceIsNULLWhileTesting = true; 136 static const bool kServiceIsNULLWhileTesting = true;
136 137
137 RulesRegistryMap rule_registries_; 138 RulesRegistryMap rule_registries_;
138 139
139 // We own the parts of the registries which need to run on the UI thread. 140 // We own the parts of the registries which need to run on the UI thread.
140 ScopedVector<RulesCacheDelegate> cache_delegates_; 141 ScopedVector<RulesCacheDelegate> cache_delegates_;
141 142
142 // Weak pointer into rule_registries_ to make it easier to handle content rule 143 // Collection of content rule registries to make it easier to handle content
Jeffrey Yasskin 2014/07/15 17:12:59 You've removed the information about what structur
Mark Dittmer 2014/07/15 18:32:42 Fixed comment to refer to weak pointers. When/if w
143 // conditions. 144 // rule conditions.
144 ContentRulesRegistry* content_rules_registry_; 145 std::map<std::string, ContentRulesRegistry*> content_rules_registry_map_;
145 146
146 content::NotificationRegistrar registrar_; 147 content::NotificationRegistrar registrar_;
147 148
148 // Listen to extension load, unloaded notification. 149 // Listen to extension load, unloaded notification.
149 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 150 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
150 extension_registry_observer_; 151 extension_registry_observer_;
151 152
152 Profile* profile_; 153 Profile* profile_;
153 154
154 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService); 155 DISALLOW_COPY_AND_ASSIGN(RulesRegistryService);
155 }; 156 };
156 157
157 } // namespace extensions 158 } // namespace extensions
158 159
159 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__ 160 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_SERVICE_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698