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

Side by Side Diff: chrome/renderer/extensions/api_definitions_natives.cc

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove obsolete special cases from ExtensionPermissionSet 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/renderer/extensions/api_definitions_natives.h" 5 #include "chrome/renderer/extensions/api_definitions_natives.h"
6 6
7 #include "chrome/common/extensions/api/extension_api.h" 7 #include "chrome/common/extensions/api/extension_api.h"
8 #include "chrome/renderer/extensions/user_script_slave.h" 8 #include "chrome/renderer/extensions/user_script_slave.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 ApiDefinitionsNatives::ApiDefinitionsNatives( 12 ApiDefinitionsNatives::ApiDefinitionsNatives(
13 ExtensionDispatcher* extension_dispatcher) 13 ExtensionDispatcher* extension_dispatcher)
14 : ChromeV8Extension(extension_dispatcher) { 14 : ChromeV8Extension(extension_dispatcher) {
15 RouteFunction("GetExtensionAPIDefinition", 15 RouteFunction("GetExtensionAPIDefinition",
16 base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinition, 16 base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinition,
17 base::Unretained(this))); 17 base::Unretained(this)));
18 RouteFunction("IsMemberAllowed",
19 base::Bind(&ApiDefinitionsNatives::IsMemberAllowed,
20 base::Unretained(this)));
18 } 21 }
19 22
20 v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinition( 23 v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinition(
21 const v8::Arguments& args) { 24 const v8::Arguments& args) {
22 ChromeV8Context* v8_context = 25 ChromeV8Context* v8_context =
23 extension_dispatcher()->v8_context_set().GetCurrent(); 26 extension_dispatcher()->v8_context_set().GetCurrent();
24 CHECK(v8_context); 27 CHECK(v8_context);
25 28
26 // TODO(kalman): This is being calculated twice, first in 29 // TODO(kalman): This is being calculated twice, first in
27 // ExtensionDispatcher then again here. It might as well be a property of 30 // ExtensionDispatcher then again here. It might as well be a property of
(...skipping 11 matching lines...) Expand all
39 } else { 42 } else {
40 apis = ExtensionAPI::GetSharedInstance()->GetAPIsForContext( 43 apis = ExtensionAPI::GetSharedInstance()->GetAPIsForContext(
41 v8_context->context_type(), 44 v8_context->context_type(),
42 extension_dispatcher()->extensions()->GetByID(extension_id), 45 extension_dispatcher()->extensions()->GetByID(extension_id),
43 UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame())); 46 UserScriptSlave::GetDataSourceURLForFrame(v8_context->web_frame()));
44 } 47 }
45 48
46 return extension_dispatcher()->v8_schema_registry()->GetSchemas(*apis); 49 return extension_dispatcher()->v8_schema_registry()->GetSchemas(*apis);
47 } 50 }
48 51
52 v8::Handle<v8::Value> ApiDefinitionsNatives::IsMemberAllowed(
53 const v8::Arguments& arguments) {
54 if (arguments.Length() < 1 || !arguments[0]->IsString()) {
55 LOG(ERROR) << "Invalid arguments";
56 return v8::Boolean::New(false);
57 }
58
59 ChromeV8Context* v8_context =
60 extension_dispatcher()->v8_context_set().GetCurrent();
61 CHECK(v8_context);
62
63 const Extension* extension = extension_dispatcher()->extensions()->GetByID(
64 v8_context->extension_id());
65
66 return v8::Boolean::New(
67 ExtensionAPI::GetSharedInstance()->IsAvailable(
68 *v8::String::AsciiValue(arguments[0]->ToString()),
69 extension,
70 v8_context->context_type()));
71
72 }
73
49 } // namespace extensions 74 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698