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

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

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reupload 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__ 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H__
7 7
8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" 8 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
9 9
10 #include <map> 10 #include <map>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // registering rules on initialization will be logged with UMA. 43 // registering rules on initialization will be logged with UMA.
44 class RuleStorageOnUI : public content::NotificationObserver { 44 class RuleStorageOnUI : public content::NotificationObserver {
45 public: 45 public:
46 // |event_name| identifies the JavaScript event for which rules are 46 // |event_name| identifies the JavaScript event for which rules are
47 // registered. For example, for WebRequestRulesRegistry the name is 47 // registered. For example, for WebRequestRulesRegistry the name is
48 // "declarativeWebRequest.onRequest". 48 // "declarativeWebRequest.onRequest".
49 RuleStorageOnUI(Profile* profile, 49 RuleStorageOnUI(Profile* profile,
50 const std::string& event_name, 50 const std::string& event_name,
51 content::BrowserThread::ID rules_registry_thread, 51 content::BrowserThread::ID rules_registry_thread,
52 base::WeakPtr<RulesRegistryWithCache> registry, 52 base::WeakPtr<RulesRegistryWithCache> registry,
53 bool log_storage_init_delay); 53 bool log_storage_init_delay,
54 const WebViewKey& webview_key);
54 55
55 virtual ~RuleStorageOnUI(); 56 virtual ~RuleStorageOnUI();
56 57
57 // Returns a key for the state store. The associated preference is a boolean 58 // Returns a key for the state store. The associated preference is a boolean
58 // indicating whether there are some declarative rules stored in the rule 59 // indicating whether there are some declarative rules stored in the rule
59 // store. 60 // store.
60 static std::string GetRulesStoredKey(const std::string& event_name, 61 static std::string GetRulesStoredKey(const std::string& event_name,
61 bool incognito); 62 bool incognito,
63 const WebViewKey& webview_key);
62 64
63 // Initialize the storage functionality. 65 // Initialize the storage functionality.
64 void Init(); 66 void Init();
65 67
66 void WriteToStorage(const std::string& extension_id, 68 void WriteToStorage(const std::string& extension_id,
67 scoped_ptr<base::Value> value); 69 scoped_ptr<base::Value> value);
68 70
69 base::WeakPtr<RuleStorageOnUI> GetWeakPtr() { 71 base::WeakPtr<RuleStorageOnUI> GetWeakPtr() {
70 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
71 return weak_ptr_factory_.GetWeakPtr(); 73 return weak_ptr_factory_.GetWeakPtr();
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // the UI thread) is created, a pointer to it is passed to |*ui_part|. 143 // the UI thread) is created, a pointer to it is passed to |*ui_part|.
142 // If |log_storage_init_delay| is set, the delay caused by loading and 144 // If |log_storage_init_delay| is set, the delay caused by loading and
143 // registering rules on initialization will be logged with UMA. 145 // registering rules on initialization will be logged with UMA.
144 // In tests, |profile| and |ui_part| can be NULL (at the same time). In that 146 // In tests, |profile| and |ui_part| can be NULL (at the same time). In that
145 // case the storage functionality disabled (no RuleStorageOnUI object 147 // case the storage functionality disabled (no RuleStorageOnUI object
146 // created) and the |log_storage_init_delay| flag is ignored. 148 // created) and the |log_storage_init_delay| flag is ignored.
147 RulesRegistryWithCache(Profile* profile, 149 RulesRegistryWithCache(Profile* profile,
148 const std::string& event_name, 150 const std::string& event_name,
149 content::BrowserThread::ID owner_thread, 151 content::BrowserThread::ID owner_thread,
150 bool log_storage_init_delay, 152 bool log_storage_init_delay,
151 scoped_ptr<RuleStorageOnUI>* ui_part); 153 scoped_ptr<RuleStorageOnUI>* ui_part,
154 const WebViewKey& webview_key);
152 155
153 const OneShotEvent& ready() const { 156 const OneShotEvent& ready() const {
154 return ready_; 157 return ready_;
155 } 158 }
156 159
157 // RulesRegistry implementation: 160 // RulesRegistry implementation:
158 virtual std::string AddRules( 161 virtual std::string AddRules(
159 const std::string& extension_id, 162 const std::string& extension_id,
160 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE; 163 const std::vector<linked_ptr<RulesRegistry::Rule> >& rules) OVERRIDE;
161 virtual std::string RemoveRules( 164 virtual std::string RemoveRules(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const base::WeakPtr<RuleStorageOnUI> storage_on_ui_; 240 const base::WeakPtr<RuleStorageOnUI> storage_on_ui_;
238 241
239 ProcessChangedRulesState process_changed_rules_requested_; 242 ProcessChangedRulesState process_changed_rules_requested_;
240 243
241 DISALLOW_COPY_AND_ASSIGN(RulesRegistryWithCache); 244 DISALLOW_COPY_AND_ASSIGN(RulesRegistryWithCache);
242 }; 245 };
243 246
244 } // namespace extensions 247 } // namespace extensions
245 248
246 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H __ 249 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_RULES_REGISTRY_WITH_CACHE_H __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698