OLD | NEW |
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" | |
17 #include "extensions/browser/api/extensions_api_client.h" | 16 #include "extensions/browser/api/extensions_api_client.h" |
18 #include "extensions/browser/extension_system.h" | 17 #include "extensions/browser/extension_system.h" |
19 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 18 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
20 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 19 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
21 #include "extensions/common/api/events.h" | 20 #include "extensions/common/api/events.h" |
22 #include "extensions/common/extension_api.h" | 21 #include "extensions/common/extension_api.h" |
23 #include "extensions/common/permissions/permissions_data.h" | 22 #include "extensions/common/permissions/permissions_data.h" |
24 | 23 |
25 using extensions::core_api::events::Rule; | 24 using extensions::core_api::events::Rule; |
26 | 25 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 if (has_webview != IsWebViewEvent(event_name)) | 146 if (has_webview != IsWebViewEvent(event_name)) |
148 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); | 147 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); |
149 event_name = GetWebRequestEventName(event_name); | 148 event_name = GetWebRequestEventName(event_name); |
150 | 149 |
151 // If we are not operating on a particular <webview>, then the key is (0, 0). | 150 // If we are not operating on a particular <webview>, then the key is (0, 0). |
152 RulesRegistry::WebViewKey key( | 151 RulesRegistry::WebViewKey key( |
153 webview_instance_id ? embedder_process_id : 0, webview_instance_id); | 152 webview_instance_id ? embedder_process_id : 0, webview_instance_id); |
154 | 153 |
155 // The following call will return a NULL pointer for apps_shell, but should | 154 // The following call will return a NULL pointer for apps_shell, but should |
156 // never be called there anyways. | 155 // never be called there anyways. |
157 rules_registry_ = RulesRegistryService::Get(browser_context())-> | 156 rules_registry_ = ExtensionsAPIClient::Get()->GetRulesRegistry( |
158 GetRulesRegistry(key, event_name); | 157 browser_context(), key, event_name); |
159 DCHECK(rules_registry_.get()); | 158 DCHECK(rules_registry_.get()); |
160 // Raw access to this function is not available to extensions, therefore | 159 // Raw access to this function is not available to extensions, therefore |
161 // there should never be a request for a nonexisting rules registry. | 160 // there should never be a request for a nonexisting rules registry. |
162 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); | 161 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); |
163 | 162 |
164 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { | 163 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { |
165 bool success = RunAsyncOnCorrectThread(); | 164 bool success = RunAsyncOnCorrectThread(); |
166 SendResponse(success); | 165 SendResponse(success); |
167 } else { | 166 } else { |
168 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = | 167 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } else { | 215 } else { |
217 rules_registry_->GetAllRules(extension_id(), &rules); | 216 rules_registry_->GetAllRules(extension_id(), &rules); |
218 } | 217 } |
219 | 218 |
220 results_ = GetRules::Results::Create(rules); | 219 results_ = GetRules::Results::Create(rules); |
221 | 220 |
222 return true; | 221 return true; |
223 } | 222 } |
224 | 223 |
225 } // namespace extensions | 224 } // namespace extensions |
OLD | NEW |