| 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 "chrome/browser/extensions/api/declarative/declarative_api.h" | 5 #include "chrome/browser/extensions/api/declarative/declarative_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/task_runner_util.h" | 9 #include "base/task_runner_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 11 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/common/extensions/api/events.h" | 12 #include "chrome/common/extensions/api/events.h" |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/render_process_host.h" | 14 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/render_view_host.h" | 15 #include "content/public/browser/render_view_host.h" |
| 17 #include "extensions/browser/extension_system.h" | 16 #include "extensions/browser/extension_system.h" |
| 18 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 17 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
| 19 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 18 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 20 #include "extensions/common/extension_api.h" | 19 #include "extensions/common/extension_api.h" |
| 21 #include "extensions/common/permissions/permissions_data.h" | 20 #include "extensions/common/permissions/permissions_data.h" |
| 22 | 21 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 bool has_webview = webview_instance_id != 0; | 86 bool has_webview = webview_instance_id != 0; |
| 88 if (has_webview != IsWebViewEvent(event_name)) | 87 if (has_webview != IsWebViewEvent(event_name)) |
| 89 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); | 88 EXTENSION_FUNCTION_ERROR(kWebViewExpectedError); |
| 90 event_name = GetWebRequestEventName(event_name); | 89 event_name = GetWebRequestEventName(event_name); |
| 91 | 90 |
| 92 // If we are not operating on a particular <webview>, then the key is (0, 0). | 91 // If we are not operating on a particular <webview>, then the key is (0, 0). |
| 93 RulesRegistryService::WebViewKey key( | 92 RulesRegistryService::WebViewKey key( |
| 94 webview_instance_id ? embedder_process_id : 0, webview_instance_id); | 93 webview_instance_id ? embedder_process_id : 0, webview_instance_id); |
| 95 | 94 |
| 96 RulesRegistryService* rules_registry_service = | 95 RulesRegistryService* rules_registry_service = |
| 97 RulesRegistryService::Get(GetProfile()); | 96 RulesRegistryService::Get(browser_context()); |
| 98 rules_registry_ = rules_registry_service->GetRulesRegistry(key, event_name); | 97 rules_registry_ = rules_registry_service->GetRulesRegistry(key, event_name); |
| 99 // Raw access to this function is not available to extensions, therefore | 98 // Raw access to this function is not available to extensions, therefore |
| 100 // there should never be a request for a nonexisting rules registry. | 99 // there should never be a request for a nonexisting rules registry. |
| 101 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); | 100 EXTENSION_FUNCTION_VALIDATE(rules_registry_.get()); |
| 102 | 101 |
| 103 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { | 102 if (content::BrowserThread::CurrentlyOn(rules_registry_->owner_thread())) { |
| 104 bool success = RunAsyncOnCorrectThread(); | 103 bool success = RunAsyncOnCorrectThread(); |
| 105 SendResponse(success); | 104 SendResponse(success); |
| 106 } else { | 105 } else { |
| 107 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = | 106 scoped_refptr<base::MessageLoopProxy> message_loop_proxy = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } else { | 153 } else { |
| 155 rules_registry_->GetAllRules(extension_id(), &rules); | 154 rules_registry_->GetAllRules(extension_id(), &rules); |
| 156 } | 155 } |
| 157 | 156 |
| 158 results_ = GetRules::Results::Create(rules); | 157 results_ = GetRules::Results::Create(rules); |
| 159 | 158 |
| 160 return true; | 159 return true; |
| 161 } | 160 } |
| 162 | 161 |
| 163 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |