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

Side by Side Diff: extensions/browser/api/declarative/declarative_api.cc

Issue 596003002: Allow declarative webrequest and webrequest in extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clean up RuleRegistry in ExtensionsApiClient. Created 6 years, 2 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 #include "extensions/browser/api/declarative/declarative_api.h" 5 #include "extensions/browser/api/declarative/declarative_api.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/task_runner_util.h" 10 #include "base/task_runner_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/public/browser/browser_thread.h" 12 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
16 #include "extensions/browser/api/declarative/rules_registry_service.h"
16 #include "extensions/browser/api/extensions_api_client.h" 17 #include "extensions/browser/api/extensions_api_client.h"
17 #include "extensions/browser/extension_system.h" 18 #include "extensions/browser/extension_system.h"
18 #include "extensions/browser/guest_view/web_view/web_view_constants.h" 19 #include "extensions/browser/guest_view/web_view/web_view_constants.h"
19 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 20 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
20 #include "extensions/common/api/events.h" 21 #include "extensions/common/api/events.h"
21 #include "extensions/common/extension_api.h" 22 #include "extensions/common/extension_api.h"
22 #include "extensions/common/permissions/permissions_data.h" 23 #include "extensions/common/permissions/permissions_data.h"
23 24
24 using extensions::core_api::events::Rule; 25 using extensions::core_api::events::Rule;
25 26
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 if (has_webview != IsWebViewEvent(event_name)) 147 if (has_webview != IsWebViewEvent(event_name))
147 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); 148 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError);
148 event_name = GetWebRequestEventName(event_name); 149 event_name = GetWebRequestEventName(event_name);
149 150
150 // If we are not operating on a particular <webview>, then the key is (0, 0). 151 // If we are not operating on a particular <webview>, then the key is (0, 0).
151 RulesRegistry::WebViewKey key( 152 RulesRegistry::WebViewKey key(
152 webview_instance_id ? embedder_process_id : 0, webview_instance_id); 153 webview_instance_id ? embedder_process_id : 0, webview_instance_id);
153 154
154 // The following call will return a NULL pointer for apps_shell, but should 155 // The following call will return a NULL pointer for apps_shell, but should
155 // never be called there anyways. 156 // never be called there anyways.
156 rules_registry_ = ExtensionsAPIClient::Get()->GetRulesRegistry( 157 rules_registry_ = RulesRegistryService::Get(browser_context())->
157 browser_context(), key, event_name); 158 GetRulesRegistry(key, event_name);
158 DCHECK(rules_registry_.get()); 159 DCHECK(rules_registry_.get());
159 // Raw access to this function is not available to extensions, therefore 160 // Raw access to this function is not available to extensions, therefore
160 // there should never be a request for a nonexisting rules registry. 161 // there should never be a request for a nonexisting rules registry.
161 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); 162 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get());
162 163
163 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { 164 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) {
164 bool success = RunAsyncOnCorrectThread(); 165 bool success = RunAsyncOnCorrectThread();
165 SendResponse(success); 166 SendResponse(success);
166 } else { 167 } else {
167 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = 168 scoped_refptr<base::MessageLoopProxy> message_loop_proxy =
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } else { 216 } else {
216 rules_registry_->GetAllRules(extension_id(), &rules); 217 rules_registry_->GetAllRules(extension_id(), &rules);
217 } 218 }
218 219
219 results_ = GetRules::Results::Create(rules); 220 results_ = GetRules::Results::Create(rules);
220 221
221 return true; 222 return true;
222 } 223 }
223 224
224 } // namespace extensions 225 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698