| 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/extension_function_dispatcher.h" | 5 #include "chrome/browser/extensions/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/process/process.h" | 12 #include "base/process/process.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/extension_function_registry.h" | |
| 16 #include "chrome/browser/external_protocol/external_protocol_handler.h" | 15 #include "chrome/browser/external_protocol/external_protocol_handler.h" |
| 17 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" | 16 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 18 #include "chrome/common/extensions/extension_messages.h" | 17 #include "chrome/common/extensions/extension_messages.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 19 #include "content/public/browser/render_frame_host.h" |
| 21 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 22 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/user_metrics.h" | 22 #include "content/public/browser/user_metrics.h" |
| 24 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
| 26 #include "content/public/common/result_codes.h" | 25 #include "content/public/common/result_codes.h" |
| 27 #include "extensions/browser/api_activity_monitor.h" | 26 #include "extensions/browser/api_activity_monitor.h" |
| 27 #include "extensions/browser/extension_function_registry.h" |
| 28 #include "extensions/browser/extension_registry.h" | 28 #include "extensions/browser/extension_registry.h" |
| 29 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
| 30 #include "extensions/browser/extensions_browser_client.h" | 30 #include "extensions/browser/extensions_browser_client.h" |
| 31 #include "extensions/browser/process_manager.h" | 31 #include "extensions/browser/process_manager.h" |
| 32 #include "extensions/browser/process_map.h" | 32 #include "extensions/browser/process_map.h" |
| 33 #include "extensions/browser/quota_service.h" | 33 #include "extensions/browser/quota_service.h" |
| 34 #include "extensions/common/extension_api.h" | 34 #include "extensions/common/extension_api.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" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 std::vector<std::string>* names) { | 222 std::vector<std::string>* names) { |
| 223 ExtensionFunctionRegistry::GetInstance()->GetAllNames(names); | 223 ExtensionFunctionRegistry::GetInstance()->GetAllNames(names); |
| 224 } | 224 } |
| 225 | 225 |
| 226 bool ExtensionFunctionDispatcher::OverrideFunction( | 226 bool ExtensionFunctionDispatcher::OverrideFunction( |
| 227 const std::string& name, ExtensionFunctionFactory factory) { | 227 const std::string& name, ExtensionFunctionFactory factory) { |
| 228 return ExtensionFunctionRegistry::GetInstance()->OverrideFunction(name, | 228 return ExtensionFunctionRegistry::GetInstance()->OverrideFunction(name, |
| 229 factory); | 229 factory); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void ExtensionFunctionDispatcher::ResetFunctions() { | |
| 233 ExtensionFunctionRegistry::GetInstance()->ResetFunctions(); | |
| 234 } | |
| 235 | |
| 236 // static | 232 // static |
| 237 void ExtensionFunctionDispatcher::DispatchOnIOThread( | 233 void ExtensionFunctionDispatcher::DispatchOnIOThread( |
| 238 extensions::InfoMap* extension_info_map, | 234 extensions::InfoMap* extension_info_map, |
| 239 void* browser_context, | 235 void* browser_context, |
| 240 int render_process_id, | 236 int render_process_id, |
| 241 base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, | 237 base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, |
| 242 int routing_id, | 238 int routing_id, |
| 243 const ExtensionHostMsg_Request_Params& params) { | 239 const ExtensionHostMsg_Request_Params& params) { |
| 244 const Extension* extension = | 240 const Extension* extension = |
| 245 extension_info_map->extensions().GetByID(params.extension_id); | 241 extension_info_map->extensions().GetByID(params.extension_id); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 return function; | 512 return function; |
| 517 } | 513 } |
| 518 | 514 |
| 519 // static | 515 // static |
| 520 void ExtensionFunctionDispatcher::SendAccessDenied( | 516 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 521 const ExtensionFunction::ResponseCallback& callback) { | 517 const ExtensionFunction::ResponseCallback& callback) { |
| 522 base::ListValue empty_list; | 518 base::ListValue empty_list; |
| 523 callback.Run(ExtensionFunction::FAILED, empty_list, | 519 callback.Run(ExtensionFunction::FAILED, empty_list, |
| 524 "Access to extension API denied."); | 520 "Access to extension API denied."); |
| 525 } | 521 } |
| OLD | NEW |