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 <map> | 7 #include <map> |
8 | 8 |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 // static | 245 // static |
246 ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( | 246 ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( |
247 const ExtensionHostMsg_Request_Params& params, | 247 const ExtensionHostMsg_Request_Params& params, |
248 const Extension* extension, | 248 const Extension* extension, |
249 int requesting_process_id, | 249 int requesting_process_id, |
250 const extensions::ProcessMap& process_map, | 250 const extensions::ProcessMap& process_map, |
251 extensions::ExtensionAPI* api, | 251 extensions::ExtensionAPI* api, |
252 void* profile, | 252 void* profile, |
253 IPC::Message::Sender* ipc_sender, | 253 IPC::Sender* ipc_sender, |
254 int routing_id) { | 254 int routing_id) { |
255 if (!extension) { | 255 if (!extension) { |
256 LOG(ERROR) << "Specified extension does not exist."; | 256 LOG(ERROR) << "Specified extension does not exist."; |
257 SendAccessDenied(ipc_sender, routing_id, params.request_id); | 257 SendAccessDenied(ipc_sender, routing_id, params.request_id); |
258 return NULL; | 258 return NULL; |
259 } | 259 } |
260 | 260 |
261 if (api->IsPrivileged(params.name) && | 261 if (api->IsPrivileged(params.name) && |
262 !process_map.Contains(extension->id(), requesting_process_id)) { | 262 !process_map.Contains(extension->id(), requesting_process_id)) { |
263 LOG(ERROR) << "Extension API called from incorrect process " | 263 LOG(ERROR) << "Extension API called from incorrect process " |
(...skipping 17 matching lines...) Expand all Loading... |
281 function->set_request_id(params.request_id); | 281 function->set_request_id(params.request_id); |
282 function->set_has_callback(params.has_callback); | 282 function->set_has_callback(params.has_callback); |
283 function->set_user_gesture(params.user_gesture); | 283 function->set_user_gesture(params.user_gesture); |
284 function->set_extension(extension); | 284 function->set_extension(extension); |
285 function->set_profile_id(profile); | 285 function->set_profile_id(profile); |
286 return function; | 286 return function; |
287 } | 287 } |
288 | 288 |
289 // static | 289 // static |
290 void ExtensionFunctionDispatcher::SendAccessDenied( | 290 void ExtensionFunctionDispatcher::SendAccessDenied( |
291 IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { | 291 IPC::Sender* ipc_sender, int routing_id, int request_id) { |
292 ListValue empty_list; | 292 ListValue empty_list; |
293 ipc_sender->Send(new ExtensionMsg_Response( | 293 ipc_sender->Send(new ExtensionMsg_Response( |
294 routing_id, request_id, false, empty_list, | 294 routing_id, request_id, false, empty_list, |
295 "Access to extension API denied.")); | 295 "Access to extension API denied.")); |
296 } | 296 } |
OLD | NEW |