Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: chrome/browser/extensions/extension_function_dispatcher.cc

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_function_dispatcher.cc
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 588d08851e36298e00f647f0c649e11eb4722ea3..f51b9a3df61fb33bc6641a01af35f7b94f0577a8 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -27,6 +27,7 @@
#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/extension_set.h"
+#include "chrome/common/extensions/feature.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
@@ -37,6 +38,7 @@
#include "webkit/glue/resource_type.h"
using extensions::ExtensionAPI;
+using extensions::Feature;
using content::RenderViewHost;
using WebKit::WebSecurityOrigin;
@@ -272,6 +274,27 @@ ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction(
return NULL;
}
+ // If the API has been ported to the feature system, use that.
+ if (api->GetFeature(params.name)) {
+ if (!api->IsAvailable(
+ params.name,
+ extension,
+ static_cast<Feature::Context>(params.source_context_type))) {
+ LOG(ERROR) << "Access to extension API '" << params.name << "' denied.";
+ SendAccessDenied(ipc_sender, routing_id, params.request_id);
+ return NULL;
+ }
+ } else {
+ // Otherwise, fall back to the older system.
+ if (!extension->HasAPIPermission(params.name)) {
+ LOG(ERROR) << "Extension " << extension->id() << " does not have "
+ << "permission to function: " << params.name;
+ SendAccessDenied(ipc_sender, routing_id, params.request_id);
+ return NULL;
+ }
+ }
+
+ // If the API requires a privileged process, ensure it is in one.
if (api->IsPrivileged(params.name) &&
!process_map.Contains(extension->id(), requesting_process_id)) {
LOG(ERROR) << "Extension API called from incorrect process "
@@ -281,13 +304,6 @@ ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction(
return NULL;
}
- if (!extension->HasAPIPermission(params.name)) {
- LOG(ERROR) << "Extension " << extension->id() << " does not have "
- << "permission to function: " << params.name;
- SendAccessDenied(ipc_sender, routing_id, params.request_id);
- return NULL;
- }
-
ExtensionFunction* function =
ExtensionFunctionRegistry::GetInstance()->NewFunction(params.name);
function->SetArgs(&params.arguments);
« no previous file with comments | « chrome/browser/extensions/extension_event_router.cc ('k') | chrome/browser/renderer_host/chrome_render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698