summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/api/declarative/declarative_api.cc2
-rw-r--r--chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc2
-rw-r--r--chrome/browser/extensions/event_router.cc2
-rw-r--r--chrome/browser/extensions/extension_function.cc2
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc4
-rw-r--r--chrome/chrome_common.gypi8
-rw-r--r--chrome/common/extensions/api/extension_api.cc416
-rw-r--r--chrome/common/extensions/api/extension_api.h141
-rw-r--r--chrome/common/extensions/api/extension_api_stub.cc48
-rw-r--r--chrome/common/extensions/api/extension_api_unittest.cc2
-rw-r--r--chrome/renderer/extensions/chrome_v8_context.cc2
-rw-r--r--chrome/renderer/extensions/chrome_v8_extension.cc2
-rw-r--r--chrome/renderer/extensions/dispatcher.cc2
-rw-r--r--chrome/renderer/extensions/render_view_observer_natives.cc2
-rw-r--r--chrome/renderer/extensions/v8_schema_registry.cc2
15 files changed, 12 insertions, 625 deletions
diff --git a/chrome/browser/extensions/api/declarative/declarative_api.cc b/chrome/browser/extensions/api/declarative/declarative_api.cc
index a77a6bd..f0bd305 100644
--- a/chrome/browser/extensions/api/declarative/declarative_api.cc
+++ b/chrome/browser/extensions/api/declarative/declarative_api.cc
@@ -12,8 +12,8 @@
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/events.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "content/public/browser/browser_thread.h"
+#include "extensions/common/extension_api.h"
using extensions::api::events::Rule;
diff --git a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc b/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc
index 6e928ff..6961cb9 100644
--- a/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc
+++ b/chrome/browser/extensions/api/storage/settings_storage_quota_enforcer.cc
@@ -11,7 +11,7 @@
#include "base/metrics/histogram.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/value_store/value_store_util.h"
-#include "chrome/common/extensions/api/extension_api.h"
+#include "extensions/common/extension_api.h"
namespace util = value_store_util;
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index c1203f6..a89ce72 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -28,7 +28,6 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
@@ -37,6 +36,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/lazy_background_task_queue.h"
+#include "extensions/common/extension_api.h"
#include "extensions/common/extension_urls.h"
using base::DictionaryValue;
diff --git a/chrome/browser/extensions/extension_function.cc b/chrome/browser/extensions/extension_function.cc
index f63d4fd..552490d 100644
--- a/chrome/browser/extensions/extension_function.cc
+++ b/chrome/browser/extensions/extension_function.cc
@@ -9,13 +9,13 @@
#include "chrome/browser/extensions/extension_function_dispatcher.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "extensions/common/extension_api.h"
using content::BrowserThread;
using content::RenderViewHost;
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index a61348b..9fc3be3 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -25,17 +25,17 @@
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/chrome_render_message_filter.h"
-#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/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
-#include "content/public/browser/user_metrics.h"
#include "content/public/common/result_codes.h"
+#include "extensions/common/extension_api.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "webkit/common/resource_type.h"
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 4a9ecb1..7ee1591 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -127,9 +127,6 @@
'common/extensions/api/extension_action/page_action_handler.h',
'common/extensions/api/extension_action/script_badge_handler.cc',
'common/extensions/api/extension_action/script_badge_handler.h',
- 'common/extensions/api/extension_api.cc',
- 'common/extensions/api/extension_api.h',
- 'common/extensions/api/extension_api_stub.cc',
'common/extensions/api/file_browser_handlers/file_browser_handler.cc',
'common/extensions/api/file_browser_handlers/file_browser_handler.h',
'common/extensions/api/file_handlers/file_handlers_parser.cc',
@@ -414,9 +411,6 @@
],
'conditions': [
['enable_extensions==1', {
- 'sources!': [
- 'common/extensions/api/extension_api_stub.cc',
- ],
'dependencies': [
'../device/bluetooth/bluetooth.gyp:device_bluetooth',
'../device/usb/usb.gyp:device_usb',
@@ -424,7 +418,6 @@
}, { # enable_extensions == 0
'sources/': [
['exclude', '^common/extensions/api/'],
- ['include', 'common/extensions/api/extension_api_stub.cc'],
['include', 'common/extensions/api/extension_action/action_info.cc'],
['include', 'common/extensions/api/extension_action/action_info.h'],
['include', 'common/extensions/api/i18n/default_locale_handler.cc'],
@@ -457,7 +450,6 @@
['OS != "ios"', {
'dependencies': [
'<(DEPTH)/chrome/app/policy/cloud_policy_codegen.gyp:policy',
- '<(DEPTH)/chrome/common/extensions/api/api.gyp:api',
'<(DEPTH)/components/components.gyp:autofill_core_common',
'<(DEPTH)/components/nacl_common.gyp:nacl_common',
'<(DEPTH)/ipc/ipc.gyp:ipc',
diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc
deleted file mode 100644
index 2490d5d..0000000
--- a/chrome/common/extensions/api/extension_api.cc
+++ /dev/null
@@ -1,416 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/extensions/api/extension_api.h"
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-#include "base/json/json_reader.h"
-#include "base/json/json_writer.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_split.h"
-#include "base/strings/string_util.h"
-#include "base/values.h"
-#include "chrome/common/extensions/api/generated_schemas.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/permissions/permissions_data.h"
-#include "extensions/common/features/feature.h"
-#include "extensions/common/features/feature_provider.h"
-#include "extensions/common/permissions/permission_set.h"
-#include "grit/common_resources.h"
-#include "grit/extensions_api_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "url/gurl.h"
-
-namespace extensions {
-
-using api::GeneratedSchemas;
-
-namespace {
-
-const char* kChildKinds[] = {
- "functions",
- "events"
-};
-
-base::StringPiece ReadFromResource(int resource_id) {
- return ResourceBundle::GetSharedInstance().GetRawDataResource(
- resource_id);
-}
-
-scoped_ptr<base::ListValue> LoadSchemaList(const std::string& name,
- const base::StringPiece& schema) {
- std::string error_message;
- scoped_ptr<base::Value> result(
- base::JSONReader::ReadAndReturnError(
- schema,
- base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN, // options
- NULL, // error code
- &error_message));
-
- // Tracking down http://crbug.com/121424
- char buf[128];
- base::snprintf(buf, arraysize(buf), "%s: (%d) '%s'",
- name.c_str(),
- result.get() ? result->GetType() : -1,
- error_message.c_str());
-
- CHECK(result.get()) << error_message << " for schema " << schema;
- CHECK(result->IsType(base::Value::TYPE_LIST)) << " for schema " << schema;
- return scoped_ptr<base::ListValue>(static_cast<base::ListValue*>(
- result.release()));
-}
-
-const base::DictionaryValue* FindListItem(const base::ListValue* list,
- const std::string& property_name,
- const std::string& property_value) {
- for (size_t i = 0; i < list->GetSize(); ++i) {
- const base::DictionaryValue* item = NULL;
- CHECK(list->GetDictionary(i, &item))
- << property_value << "/" << property_name;
- std::string value;
- if (item->GetString(property_name, &value) && value == property_value)
- return item;
- }
-
- return NULL;
-}
-
-const base::DictionaryValue* GetSchemaChild(
- const base::DictionaryValue* schema_node,
- const std::string& child_name) {
- const base::DictionaryValue* child_node = NULL;
- for (size_t i = 0; i < arraysize(kChildKinds); ++i) {
- const base::ListValue* list_node = NULL;
- if (!schema_node->GetList(kChildKinds[i], &list_node))
- continue;
- child_node = FindListItem(list_node, "name", child_name);
- if (child_node)
- return child_node;
- }
-
- return NULL;
-}
-
-struct Static {
- Static()
- : api(ExtensionAPI::CreateWithDefaultConfiguration()) {
- }
- scoped_ptr<ExtensionAPI> api;
-};
-
-base::LazyInstance<Static> g_lazy_instance = LAZY_INSTANCE_INITIALIZER;
-
-// If it exists and does not already specify a namespace, then the value stored
-// with key |key| in |schema| will be updated to |schema_namespace| + "." +
-// |schema[key]|.
-void MaybePrefixFieldWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema,
- const std::string& key) {
- if (!schema->HasKey(key))
- return;
-
- std::string old_id;
- CHECK(schema->GetString(key, &old_id));
- if (old_id.find(".") == std::string::npos)
- schema->SetString(key, schema_namespace + "." + old_id);
-}
-
-// Modify all "$ref" keys anywhere in |schema| to be prefxied by
-// |schema_namespace| if they do not already specify a namespace.
-void PrefixRefsWithNamespace(const std::string& schema_namespace,
- base::Value* value) {
- base::ListValue* list = NULL;
- base::DictionaryValue* dict = NULL;
- if (value->GetAsList(&list)) {
- for (base::ListValue::iterator i = list->begin(); i != list->end(); ++i) {
- PrefixRefsWithNamespace(schema_namespace, *i);
- }
- } else if (value->GetAsDictionary(&dict)) {
- MaybePrefixFieldWithNamespace(schema_namespace, dict, "$ref");
- for (base::DictionaryValue::Iterator i(*dict); !i.IsAtEnd(); i.Advance()) {
- base::Value* value = NULL;
- CHECK(dict->GetWithoutPathExpansion(i.key(), &value));
- PrefixRefsWithNamespace(schema_namespace, value);
- }
- }
-}
-
-// Modify all objects in the "types" section of the schema to be prefixed by
-// |schema_namespace| if they do not already specify a namespace.
-void PrefixTypesWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema) {
- if (!schema->HasKey("types"))
- return;
-
- // Add the namespace to all of the types defined in this schema
- base::ListValue *types = NULL;
- CHECK(schema->GetList("types", &types));
- for (size_t i = 0; i < types->GetSize(); ++i) {
- base::DictionaryValue *type = NULL;
- CHECK(types->GetDictionary(i, &type));
- MaybePrefixFieldWithNamespace(schema_namespace, type, "id");
- MaybePrefixFieldWithNamespace(schema_namespace, type, "customBindings");
- }
-}
-
-// Modify the schema so that all types are fully qualified.
-void PrefixWithNamespace(const std::string& schema_namespace,
- base::DictionaryValue* schema) {
- PrefixTypesWithNamespace(schema_namespace, schema);
- PrefixRefsWithNamespace(schema_namespace, schema);
-}
-
-} // namespace
-
-// static
-ExtensionAPI* ExtensionAPI::GetSharedInstance() {
- return g_lazy_instance.Get().api.get();
-}
-
-// static
-ExtensionAPI* ExtensionAPI::CreateWithDefaultConfiguration() {
- ExtensionAPI* api = new ExtensionAPI();
- api->InitDefaultConfiguration();
- return api;
-}
-
-// static
-void ExtensionAPI::SplitDependencyName(const std::string& full_name,
- std::string* feature_type,
- std::string* feature_name) {
- size_t colon_index = full_name.find(':');
- if (colon_index == std::string::npos) {
- // TODO(aa): Remove this code when all API descriptions have been updated.
- *feature_type = "api";
- *feature_name = full_name;
- return;
- }
-
- *feature_type = full_name.substr(0, colon_index);
- *feature_name = full_name.substr(colon_index + 1);
-}
-
-void ExtensionAPI::LoadSchema(const std::string& name,
- const base::StringPiece& schema) {
- scoped_ptr<base::ListValue> schema_list(LoadSchemaList(name, schema));
- std::string schema_namespace;
-
- while (!schema_list->empty()) {
- base::DictionaryValue* schema = NULL;
- {
- scoped_ptr<base::Value> value;
- schema_list->Remove(schema_list->GetSize() - 1, &value);
- CHECK(value.release()->GetAsDictionary(&schema));
- }
-
- CHECK(schema->GetString("namespace", &schema_namespace));
- PrefixWithNamespace(schema_namespace, schema);
- schemas_[schema_namespace] = make_linked_ptr(schema);
- if (!GeneratedSchemas::IsGenerated(schema_namespace))
- CHECK_EQ(1u, unloaded_schemas_.erase(schema_namespace));
- }
-}
-
-ExtensionAPI::ExtensionAPI() : default_configuration_initialized_(false) {
-}
-
-ExtensionAPI::~ExtensionAPI() {
-}
-
-void ExtensionAPI::InitDefaultConfiguration() {
- const char* names[] = {"api", "manifest", "permission"};
- for (size_t i = 0; i < arraysize(names); ++i)
- RegisterDependencyProvider(names[i], FeatureProvider::GetByName(names[i]));
-
- // Schemas to be loaded from resources.
- CHECK(unloaded_schemas_.empty());
- RegisterSchemaResource("app", IDR_EXTENSION_API_JSON_APP);
- RegisterSchemaResource("browserAction", IDR_EXTENSION_API_JSON_BROWSERACTION);
- RegisterSchemaResource("browsingData", IDR_EXTENSION_API_JSON_BROWSINGDATA);
- RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS);
- RegisterSchemaResource("declarativeContent",
- IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT);
- RegisterSchemaResource("declarativeWebRequest",
- IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST);
- RegisterSchemaResource("runtime", IDR_EXTENSION_API_JSON_RUNTIME);
- RegisterSchemaResource("fileBrowserHandler",
- IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER);
- RegisterSchemaResource("fileBrowserPrivate",
- IDR_EXTENSION_API_JSON_FILEBROWSERPRIVATE);
- RegisterSchemaResource("inputMethodPrivate",
- IDR_EXTENSION_API_JSON_INPUTMETHODPRIVATE);
- RegisterSchemaResource("pageAction", IDR_EXTENSION_API_JSON_PAGEACTION);
- RegisterSchemaResource("pageActions", IDR_EXTENSION_API_JSON_PAGEACTIONS);
- RegisterSchemaResource("privacy", IDR_EXTENSION_API_JSON_PRIVACY);
- RegisterSchemaResource("processes", IDR_EXTENSION_API_JSON_PROCESSES);
- RegisterSchemaResource("proxy", IDR_EXTENSION_API_JSON_PROXY);
- RegisterSchemaResource("scriptBadge", IDR_EXTENSION_API_JSON_SCRIPTBADGE);
- RegisterSchemaResource("streamsPrivate",
- IDR_EXTENSION_API_JSON_STREAMSPRIVATE);
- RegisterSchemaResource("ttsEngine", IDR_EXTENSION_API_JSON_TTSENGINE);
- RegisterSchemaResource("tts", IDR_EXTENSION_API_JSON_TTS);
- RegisterSchemaResource("types", IDR_EXTENSION_API_JSON_TYPES);
- RegisterSchemaResource("types.private", IDR_EXTENSION_API_JSON_TYPES_PRIVATE);
- RegisterSchemaResource("webRequestInternal",
- IDR_EXTENSION_API_JSON_WEBREQUESTINTERNAL);
- RegisterSchemaResource("webstore", IDR_EXTENSION_API_JSON_WEBSTORE);
- RegisterSchemaResource("webstorePrivate",
- IDR_EXTENSION_API_JSON_WEBSTOREPRIVATE);
- default_configuration_initialized_ = true;
-}
-
-void ExtensionAPI::RegisterSchemaResource(const std::string& name,
- int resource_id) {
- unloaded_schemas_[name] = resource_id;
-}
-
-void ExtensionAPI::RegisterDependencyProvider(const std::string& name,
- FeatureProvider* provider) {
- dependency_providers_[name] = provider;
-}
-
-bool ExtensionAPI::IsAnyFeatureAvailableToContext(const std::string& api_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
- FeatureProviderMap::iterator provider = dependency_providers_.find("api");
- CHECK(provider != dependency_providers_.end());
- const std::vector<std::string>& features =
- provider->second->GetAllFeatureNames();
-
- // Check to see if there are any parts of this API that are allowed in this
- // context.
- for (std::vector<std::string>::const_iterator i = features.begin();
- i != features.end(); ++i) {
- const std::string& feature_name = *i;
- if (feature_name != api_name && feature_name.find(api_name + ".") == 0) {
- if (IsAvailable(feature_name, extension, context, url).is_available())
- return true;
- }
- }
- return IsAvailable(api_name, extension, context, url).is_available();
-}
-
-Feature::Availability ExtensionAPI::IsAvailable(const std::string& full_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
- Feature* feature = GetFeatureDependency(full_name);
- CHECK(feature) << full_name;
-
- Feature::Availability availability =
- feature->IsAvailableToContext(extension, context, url);
- if (!availability.is_available())
- return availability;
-
- for (std::set<std::string>::iterator iter = feature->dependencies().begin();
- iter != feature->dependencies().end(); ++iter) {
- Feature::Availability dependency_availability =
- IsAvailable(*iter, extension, context, url);
- if (!dependency_availability.is_available())
- return dependency_availability;
- }
-
- return Feature::CreateAvailability(Feature::IS_AVAILABLE, std::string());
-}
-
-bool ExtensionAPI::IsPrivileged(const std::string& full_name) {
- Feature* feature = GetFeatureDependency(full_name);
- CHECK(feature);
- DCHECK(!feature->GetContexts()->empty());
- // An API is 'privileged' if it can only be run in a blessed context.
- return feature->GetContexts()->size() ==
- feature->GetContexts()->count(Feature::BLESSED_EXTENSION_CONTEXT);
-}
-
-const base::DictionaryValue* ExtensionAPI::GetSchema(
- const std::string& full_name) {
- std::string child_name;
- std::string api_name = GetAPINameFromFullName(full_name, &child_name);
-
- const base::DictionaryValue* result = NULL;
- SchemaMap::iterator maybe_schema = schemas_.find(api_name);
- if (maybe_schema != schemas_.end()) {
- result = maybe_schema->second.get();
- } else {
- // Might not have loaded yet; or might just not exist.
- UnloadedSchemaMap::iterator maybe_schema_resource =
- unloaded_schemas_.find(api_name);
- if (maybe_schema_resource != unloaded_schemas_.end()) {
- LoadSchema(maybe_schema_resource->first,
- ReadFromResource(maybe_schema_resource->second));
- } else if (default_configuration_initialized_ &&
- GeneratedSchemas::IsGenerated(api_name)) {
- LoadSchema(api_name, GeneratedSchemas::Get(api_name));
- } else {
- return NULL;
- }
-
- maybe_schema = schemas_.find(api_name);
- CHECK(schemas_.end() != maybe_schema);
- result = maybe_schema->second.get();
- }
-
- if (!child_name.empty())
- result = GetSchemaChild(result, child_name);
-
- return result;
-}
-
-Feature* ExtensionAPI::GetFeatureDependency(const std::string& full_name) {
- std::string feature_type;
- std::string feature_name;
- SplitDependencyName(full_name, &feature_type, &feature_name);
-
- FeatureProviderMap::iterator provider =
- dependency_providers_.find(feature_type);
- if (provider == dependency_providers_.end())
- return NULL;
-
- Feature* feature = provider->second->GetFeature(feature_name);
- // Try getting the feature for the parent API, if this was a child.
- if (!feature) {
- std::string child_name;
- feature = provider->second->GetFeature(
- GetAPINameFromFullName(feature_name, &child_name));
- }
- return feature;
-}
-
-std::string ExtensionAPI::GetAPINameFromFullName(const std::string& full_name,
- std::string* child_name) {
- std::string api_name_candidate = full_name;
- while (true) {
- if (schemas_.find(api_name_candidate) != schemas_.end() ||
- GeneratedSchemas::IsGenerated(api_name_candidate) ||
- unloaded_schemas_.find(api_name_candidate) != unloaded_schemas_.end()) {
- std::string result = api_name_candidate;
-
- if (child_name) {
- if (result.length() < full_name.length())
- *child_name = full_name.substr(result.length() + 1);
- else
- *child_name = "";
- }
-
- return result;
- }
-
- size_t last_dot_index = api_name_candidate.rfind('.');
- if (last_dot_index == std::string::npos)
- break;
-
- api_name_candidate = api_name_candidate.substr(0, last_dot_index);
- }
-
- *child_name = "";
- return std::string();
-}
-
-} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_api.h b/chrome/common/extensions/api/extension_api.h
deleted file mode 100644
index ad8ae00..0000000
--- a/chrome/common/extensions/api/extension_api.h
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
-#define CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/gtest_prod_util.h"
-#include "base/memory/linked_ptr.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/singleton.h"
-#include "base/strings/string_piece.h"
-#include "base/values.h"
-#include "extensions/common/features/feature.h"
-#include "extensions/common/features/feature_provider.h"
-#include "extensions/common/url_pattern_set.h"
-
-namespace base {
-class DictionaryValue;
-class Value;
-}
-
-class GURL;
-
-namespace extensions {
-
-class Extension;
-class Feature;
-
-// C++ Wrapper for the JSON API definitions in chrome/common/extensions/api/.
-//
-// WARNING: This class is accessed on multiple threads in the browser process
-// (see ExtensionFunctionDispatcher). No state should be modified after
-// construction.
-class ExtensionAPI {
- public:
- // Returns a single shared instance of this class. This is the typical use
- // case in Chrome.
- //
- // TODO(aa): Make this const to enforce thread-safe usage.
- static ExtensionAPI* GetSharedInstance();
-
- // Creates a new instance configured the way ExtensionAPI typically is in
- // Chrome. Use the default constructor to get a clean instance.
- static ExtensionAPI* CreateWithDefaultConfiguration();
-
- // Splits a name like "permission:bookmark" into ("permission", "bookmark").
- // The first part refers to a type of feature, for example "manifest",
- // "permission", or "api". The second part is the full name of the feature.
- static void SplitDependencyName(const std::string& full_name,
- std::string* feature_type,
- std::string* feature_name);
-
- // Creates a completely clean instance. Configure using RegisterSchema() and
- // RegisterDependencyProvider before use.
- ExtensionAPI();
- virtual ~ExtensionAPI();
-
- void RegisterSchemaResource(const std::string& api_name, int resource_id);
-
- void RegisterDependencyProvider(const std::string& name,
- FeatureProvider* provider);
-
- // Returns true if the specified API is available. |api_full_name| can be
- // either a namespace name (like "bookmarks") or a member name (like
- // "bookmarks.create"). Returns true if the feature and all of its
- // dependencies are available to the specified context.
- Feature::Availability IsAvailable(const std::string& api_full_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url);
-
- // Determines whether an API, or any parts of that API, are available in
- // |context|.
- bool IsAnyFeatureAvailableToContext(const std::string& api_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url);
-
- // Returns true if |name| is a privileged API path. Privileged paths can only
- // be called from extension code which is running in its own designated
- // extension process. They cannot be called from extension code running in
- // content scripts, or other low-privileged contexts.
- bool IsPrivileged(const std::string& name);
-
- // Gets the schema for the extension API with namespace |full_name|.
- // Ownership remains with this object.
- const base::DictionaryValue* GetSchema(const std::string& full_name);
-
- // Splits a full name from the extension API into its API and child name
- // parts. Some examples:
- //
- // "bookmarks.create" -> ("bookmarks", "create")
- // "experimental.input.ui.cursorUp" -> ("experimental.input.ui", "cursorUp")
- // "storage.sync.set" -> ("storage", "sync.get")
- // "<unknown-api>.monkey" -> ("", "")
- //
- // The |child_name| parameter can be be NULL if you don't need that part.
- std::string GetAPINameFromFullName(const std::string& full_name,
- std::string* child_name);
-
- private:
- FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, DefaultConfigurationFeatures);
- FRIEND_TEST_ALL_PREFIXES(ExtensionAPITest, TypesHaveNamespace);
- friend struct DefaultSingletonTraits<ExtensionAPI>;
-
- void InitDefaultConfiguration();
-
- bool default_configuration_initialized_;
-
- // Gets a feature from any dependency provider registered with ExtensionAPI.
- // Returns NULL if the feature could not be found.
- Feature* GetFeatureDependency(const std::string& dependency_name);
-
- // Loads a schema.
- void LoadSchema(const std::string& name, const base::StringPiece& schema);
-
- // Map from each API that hasn't been loaded yet to the schema which defines
- // it. Note that there may be multiple APIs per schema.
- typedef std::map<std::string, int> UnloadedSchemaMap;
- UnloadedSchemaMap unloaded_schemas_;
-
- // Schemas for each namespace.
- typedef std::map<std::string, linked_ptr<const base::DictionaryValue> >
- SchemaMap;
- SchemaMap schemas_;
-
- // FeatureProviders used for resolving dependencies.
- typedef std::map<std::string, FeatureProvider*> FeatureProviderMap;
- FeatureProviderMap dependency_providers_;
-
- DISALLOW_COPY_AND_ASSIGN(ExtensionAPI);
-};
-
-} // namespace extensions
-
-#endif // CHROME_COMMON_EXTENSIONS_API_EXTENSION_API_H_
diff --git a/chrome/common/extensions/api/extension_api_stub.cc b/chrome/common/extensions/api/extension_api_stub.cc
deleted file mode 100644
index add1f97..0000000
--- a/chrome/common/extensions/api/extension_api_stub.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Stub methods to be used when extensions are disabled
-// i.e. ENABLE_EXTENSIONS is not defined
-
-#include "chrome/common/extensions/api/extension_api.h"
-
-#include "extensions/common/features/feature.h"
-
-namespace extensions {
-
-// static
-ExtensionAPI* ExtensionAPI::GetSharedInstance() {
- return NULL;
-}
-
-// static
-ExtensionAPI* ExtensionAPI::CreateWithDefaultConfiguration() {
- return NULL;
-}
-
-Feature::Availability ExtensionAPI::IsAvailable(
- const std::string& api_full_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
- return Feature::CreateAvailability(Feature::NOT_PRESENT, "");
-}
-
-bool ExtensionAPI::IsAnyFeatureAvailableToContext(const std::string& api_name,
- const Extension* extension,
- Feature::Context context,
- const GURL& url) {
- return false;
-}
-
-bool ExtensionAPI::IsPrivileged(const std::string& full_name) {
- return false;
-}
-
-const base::DictionaryValue* ExtensionAPI::GetSchema(
- const std::string& full_name) {
- return NULL;
-}
-
-} // namespace extensions
diff --git a/chrome/common/extensions/api/extension_api_unittest.cc b/chrome/common/extensions/api/extension_api_unittest.cc
index 0e340ba..a481d9d 100644
--- a/chrome/common/extensions/api/extension_api_unittest.cc
+++ b/chrome/common/extensions/api/extension_api_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/extensions/api/extension_api.h"
+#include "extensions/common/extension_api.h"
#include <string>
#include <vector>
diff --git a/chrome/renderer/extensions/chrome_v8_context.cc b/chrome/renderer/extensions/chrome_v8_context.cc
index 1e0ca6f..64b0658 100644
--- a/chrome/renderer/extensions/chrome_v8_context.cc
+++ b/chrome/renderer/extensions/chrome_v8_context.cc
@@ -8,7 +8,6 @@
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_split.h"
#include "base/values.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/features/base_feature_provider.h"
@@ -17,6 +16,7 @@
#include "chrome/renderer/extensions/user_script_slave.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/v8_value_converter.h"
+#include "extensions/common/extension_api.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
#include "third_party/WebKit/public/web/WebView.h"
diff --git a/chrome/renderer/extensions/chrome_v8_extension.cc b/chrome/renderer/extensions/chrome_v8_extension.cc
index 27c0b70..c1060e4 100644
--- a/chrome/renderer/extensions/chrome_v8_extension.cc
+++ b/chrome/renderer/extensions/chrome_v8_extension.cc
@@ -8,12 +8,12 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
#include "chrome/renderer/extensions/chrome_v8_context.h"
#include "chrome/renderer/extensions/dispatcher.h"
#include "content/public/renderer/render_view.h"
+#include "extensions/common/extension_api.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebView.h"
diff --git a/chrome/renderer/extensions/dispatcher.cc b/chrome/renderer/extensions/dispatcher.cc
index 21e55cd..55a0bb1 100644
--- a/chrome/renderer/extensions/dispatcher.cc
+++ b/chrome/renderer/extensions/dispatcher.cc
@@ -17,7 +17,6 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/crash_keys.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/common/extensions/api/messaging/message.h"
#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
@@ -76,6 +75,7 @@
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/v8_value_converter.h"
#include "extensions/common/constants.h"
+#include "extensions/common/extension_api.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/features/feature_provider.h"
diff --git a/chrome/renderer/extensions/render_view_observer_natives.cc b/chrome/renderer/extensions/render_view_observer_natives.cc
index adb0e9c..bf5f02e 100644
--- a/chrome/renderer/extensions/render_view_observer_natives.cc
+++ b/chrome/renderer/extensions/render_view_observer_natives.cc
@@ -4,10 +4,10 @@
#include "chrome/renderer/extensions/render_view_observer_natives.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/renderer/extensions/dispatcher.h"
#include "content/public/renderer/render_view.h"
#include "content/public/renderer/render_view_observer.h"
+#include "extensions/common/extension_api.h"
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
diff --git a/chrome/renderer/extensions/v8_schema_registry.cc b/chrome/renderer/extensions/v8_schema_registry.cc
index f5c2c71..e358b98 100644
--- a/chrome/renderer/extensions/v8_schema_registry.cc
+++ b/chrome/renderer/extensions/v8_schema_registry.cc
@@ -9,10 +9,10 @@
#include "base/logging.h"
#include "base/values.h"
-#include "chrome/common/extensions/api/extension_api.h"
#include "chrome/renderer/extensions/chrome_v8_context.h"
#include "chrome/renderer/extensions/object_backed_native_handler.h"
#include "content/public/renderer/v8_value_converter.h"
+#include "extensions/common/extension_api.h"
using content::V8ValueConverter;