| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 return NULL; | 556 return NULL; |
| 557 } | 557 } |
| 558 | 558 |
| 559 if (!extension) { | 559 if (!extension) { |
| 560 LOG(ERROR) << "Extension does not exist for URL: " | 560 LOG(ERROR) << "Extension does not exist for URL: " |
| 561 << params.source_url.spec(); | 561 << params.source_url.spec(); |
| 562 SendAccessDenied(ipc_sender, routing_id, params.request_id); | 562 SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 563 return NULL; | 563 return NULL; |
| 564 } | 564 } |
| 565 | 565 |
| 566 if (!extension->HasApiPermission(params.name)) { | 566 if (!extension->HasAPIPermission(params.name)) { |
| 567 LOG(ERROR) << "Extension " << extension->id() << " does not have " | 567 LOG(ERROR) << "Extension " << extension->id() << " does not have " |
| 568 << "permission to function: " << params.name; | 568 << "permission to function: " << params.name; |
| 569 SendAccessDenied(ipc_sender, routing_id, params.request_id); | 569 SendAccessDenied(ipc_sender, routing_id, params.request_id); |
| 570 return NULL; | 570 return NULL; |
| 571 } | 571 } |
| 572 | 572 |
| 573 ExtensionFunction* function = | 573 ExtensionFunction* function = |
| 574 FactoryRegistry::GetInstance()->NewFunction(params.name); | 574 FactoryRegistry::GetInstance()->NewFunction(params.name); |
| 575 function->SetArgs(¶ms.arguments); | 575 function->SetArgs(¶ms.arguments); |
| 576 function->set_source_url(params.source_url); | 576 function->set_source_url(params.source_url); |
| 577 function->set_request_id(params.request_id); | 577 function->set_request_id(params.request_id); |
| 578 function->set_has_callback(params.has_callback); | 578 function->set_has_callback(params.has_callback); |
| 579 function->set_user_gesture(params.user_gesture); | 579 function->set_user_gesture(params.user_gesture); |
| 580 function->set_extension(extension); | 580 function->set_extension(extension); |
| 581 function->set_profile_id(profile_id); | 581 function->set_profile_id(profile_id); |
| 582 return function; | 582 return function; |
| 583 } | 583 } |
| 584 | 584 |
| 585 // static | 585 // static |
| 586 void ExtensionFunctionDispatcher::SendAccessDenied( | 586 void ExtensionFunctionDispatcher::SendAccessDenied( |
| 587 IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { | 587 IPC::Message::Sender* ipc_sender, int routing_id, int request_id) { |
| 588 ipc_sender->Send(new ExtensionMsg_Response( | 588 ipc_sender->Send(new ExtensionMsg_Response( |
| 589 routing_id, request_id, false, std::string(), | 589 routing_id, request_id, false, std::string(), |
| 590 "Access to extension API denied.")); | 590 "Access to extension API denied.")); |
| 591 } | 591 } |
| OLD | NEW |