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

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

Issue 15091002: Lazily load API schemas from resource files and convert all APIs to features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos tests Created 7 years, 6 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/common/extensions/api/extension_api.h" 9 #include "chrome/common/extensions/features/base_feature_provider.h"
10 10
11 namespace { 11 namespace {
12 const char kInvalidExtensionNamespace[] = "Invalid extension namespace"; 12 const char kInvalidExtensionNamespace[] = "Invalid extension namespace";
13 } 13 }
14 14
15 namespace extensions { 15 namespace extensions {
16 16
17 ApiDefinitionsNatives::ApiDefinitionsNatives(Dispatcher* dispatcher, 17 ApiDefinitionsNatives::ApiDefinitionsNatives(Dispatcher* dispatcher,
18 ChromeV8Context* context) 18 ChromeV8Context* context)
19 : ChromeV8Extension(dispatcher, context) { 19 : ChromeV8Extension(dispatcher, context) {
20 RouteFunction("GetExtensionAPIDefinitions", 20 RouteFunction("GetExtensionAPIDefinitionsForTest",
21 base::Bind(&ApiDefinitionsNatives::GetExtensionAPIDefinitions, 21 base::Bind(
22 base::Unretained(this))); 22 &ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest,
23 base::Unretained(this)));
23 } 24 }
24 25
25 v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinitions( 26 v8::Handle<v8::Value> ApiDefinitionsNatives::GetExtensionAPIDefinitionsForTest(
26 const v8::Arguments& args) { 27 const v8::Arguments& args) {
27 return dispatcher()->v8_schema_registry()->GetSchemas( 28 std::vector<std::string> apis;
28 ExtensionAPI::GetSharedInstance()->GetAllAPINames()); 29 FeatureProvider* feature_provider = BaseFeatureProvider::GetByName("api");
30 const std::vector<std::string>& feature_names =
31 feature_provider->GetAllFeatureNames();
32 for (std::vector<std::string>::const_iterator i = feature_names.begin();
33 i != feature_names.end(); ++i) {
34 if (!feature_provider->GetParent(feature_provider->GetFeature(*i)) &&
35 context()->GetAvailability(*i).is_available()) {
36 apis.push_back(*i);
37 }
38 }
39 return dispatcher()->v8_schema_registry()->GetSchemas(apis);
29 } 40 }
30 41
31 } // namespace extensions 42 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/api_definitions_natives.h ('k') | chrome/renderer/extensions/chrome_v8_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698