| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extension_function_dispatcher.h" | 5 #include "extensions/browser/extension_function_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/json/json_string_value_serializer.h" | 8 #include "base/json/json_string_value_serializer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/metrics/sparse_histogram.h" | 12 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/process/process.h" | 13 #include "base/process/process.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/render_process_host.h" | 18 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 21 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "content/public/common/result_codes.h" | 23 #include "content/public/common/result_codes.h" |
| 24 #include "extensions/browser/api_activity_monitor.h" | 24 #include "extensions/browser/api_activity_monitor.h" |
| 25 #include "extensions/browser/extension_function_registry.h" | 25 #include "extensions/browser/extension_function_registry.h" |
| 26 #include "extensions/browser/extension_message_filter.h" | |
| 27 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
| 28 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
| 29 #include "extensions/browser/extensions_browser_client.h" | 28 #include "extensions/browser/extensions_browser_client.h" |
| 29 #include "extensions/browser/io_thread_extension_message_filter.h" |
| 30 #include "extensions/browser/process_manager.h" | 30 #include "extensions/browser/process_manager.h" |
| 31 #include "extensions/browser/process_map.h" | 31 #include "extensions/browser/process_map.h" |
| 32 #include "extensions/browser/quota_service.h" | 32 #include "extensions/browser/quota_service.h" |
| 33 #include "extensions/common/extension_api.h" | 33 #include "extensions/common/extension_api.h" |
| 34 #include "extensions/common/extension_messages.h" | 34 #include "extensions/common/extension_messages.h" |
| 35 #include "extensions/common/extension_set.h" | 35 #include "extensions/common/extension_set.h" |
| 36 #include "ipc/ipc_message.h" | 36 #include "ipc/ipc_message.h" |
| 37 #include "ipc/ipc_message_macros.h" | 37 #include "ipc/ipc_message_macros.h" |
| 38 | 38 |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 ipc_sender->Send(new ExtensionMsg_Response( | 116 ipc_sender->Send(new ExtensionMsg_Response( |
| 117 routing_id, request_id, type == ExtensionFunction::SUCCEEDED, results, | 117 routing_id, request_id, type == ExtensionFunction::SUCCEEDED, results, |
| 118 error)); | 118 error)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 void IOThreadResponseCallback( | 121 void IOThreadResponseCallback( |
| 122 const base::WeakPtr<ExtensionMessageFilter>& ipc_sender, | 122 const base::WeakPtr<IOThreadExtensionMessageFilter>& ipc_sender, |
| 123 int routing_id, | 123 int routing_id, |
| 124 int request_id, | 124 int request_id, |
| 125 ExtensionFunction::ResponseType type, | 125 ExtensionFunction::ResponseType type, |
| 126 const base::ListValue& results, | 126 const base::ListValue& results, |
| 127 const std::string& error) { | 127 const std::string& error) { |
| 128 if (!ipc_sender.get()) | 128 if (!ipc_sender.get()) |
| 129 return; | 129 return; |
| 130 | 130 |
| 131 CommonResponseCallback(ipc_sender.get(), | 131 CommonResponseCallback(ipc_sender.get(), |
| 132 routing_id, | 132 routing_id, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 const std::string& name, ExtensionFunctionFactory factory) { | 217 const std::string& name, ExtensionFunctionFactory factory) { |
| 218 return ExtensionFunctionRegistry::GetInstance()->OverrideFunction(name, | 218 return ExtensionFunctionRegistry::GetInstance()->OverrideFunction(name, |
| 219 factory); | 219 factory); |
| 220 } | 220 } |
| 221 | 221 |
| 222 // static | 222 // static |
| 223 void ExtensionFunctionDispatcher::DispatchOnIOThread( | 223 void ExtensionFunctionDispatcher::DispatchOnIOThread( |
| 224 InfoMap* extension_info_map, | 224 InfoMap* extension_info_map, |
| 225 void* profile_id, | 225 void* profile_id, |
| 226 int render_process_id, | 226 int render_process_id, |
| 227 base::WeakPtr<ExtensionMessageFilter> ipc_sender, | 227 base::WeakPtr<IOThreadExtensionMessageFilter> ipc_sender, |
| 228 int routing_id, | 228 int routing_id, |
| 229 const ExtensionHostMsg_Request_Params& params) { | 229 const ExtensionHostMsg_Request_Params& params) { |
| 230 const Extension* extension = | 230 const Extension* extension = |
| 231 extension_info_map->extensions().GetByID(params.extension_id); | 231 extension_info_map->extensions().GetByID(params.extension_id); |
| 232 | 232 |
| 233 ExtensionFunction::ResponseCallback callback( | 233 ExtensionFunction::ResponseCallback callback( |
| 234 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id, | 234 base::Bind(&IOThreadResponseCallback, ipc_sender, routing_id, |
| 235 params.request_id)); | 235 params.request_id)); |
| 236 | 236 |
| 237 scoped_refptr<ExtensionFunction> function( | 237 scoped_refptr<ExtensionFunction> function( |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 | 471 |
| 472 // static | 472 // static |
| 473 void ExtensionFunctionDispatcher::SendAccessDenied( | 473 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 474 const ExtensionFunction::ResponseCallback& callback) { | 474 const ExtensionFunction::ResponseCallback& callback) { |
| 475 base::ListValue empty_list; | 475 base::ListValue empty_list; |
| 476 callback.Run(ExtensionFunction::FAILED, empty_list, | 476 callback.Run(ExtensionFunction::FAILED, empty_list, |
| 477 "Access to extension API denied."); | 477 "Access to extension API denied."); |
| 478 } | 478 } |
| 479 | 479 |
| 480 } // namespace extensions | 480 } // namespace extensions |
| OLD | NEW |