| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/shell/common/shell_extensions_client.h" | 5 #include "extensions/shell/common/shell_extensions_client.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "extensions/common/api/generated_schemas.h" | 9 #include "extensions/common/api/generated_schemas.h" |
| 10 #include "extensions/common/api/sockets/sockets_manifest_handler.h" | 10 #include "extensions/common/api/sockets/sockets_manifest_handler.h" |
| 11 #include "extensions/common/common_manifest_handlers.h" | 11 #include "extensions/common/common_manifest_handlers.h" |
| 12 #include "extensions/common/features/api_feature.h" | 12 #include "extensions/common/features/api_feature.h" |
| 13 #include "extensions/common/features/base_feature_provider.h" | 13 #include "extensions/common/features/base_feature_provider.h" |
| 14 #include "extensions/common/features/json_feature_provider_source.h" | 14 #include "extensions/common/features/json_feature_provider_source.h" |
| 15 #include "extensions/common/features/manifest_feature.h" | 15 #include "extensions/common/features/manifest_feature.h" |
| 16 #include "extensions/common/features/permission_feature.h" | 16 #include "extensions/common/features/permission_feature.h" |
| 17 #include "extensions/common/features/simple_feature.h" | 17 #include "extensions/common/features/simple_feature.h" |
| 18 #include "extensions/common/manifest_handler.h" | 18 #include "extensions/common/manifest_handler.h" |
| 19 #include "extensions/common/permissions/permission_message_provider.h" | 19 #include "extensions/common/permissions/permission_message_provider.h" |
| 20 #include "extensions/common/permissions/permissions_info.h" | 20 #include "extensions/common/permissions/permissions_info.h" |
| 21 #include "extensions/common/permissions/permissions_provider.h" | 21 #include "extensions/common/permissions/permissions_provider.h" |
| 22 #include "extensions/common/url_pattern_set.h" | 22 #include "extensions/common/url_pattern_set.h" |
| 23 #include "extensions/shell/common/api/generated_schemas.h" | |
| 24 #include "grit/app_shell_resources.h" | |
| 25 #include "grit/extensions_resources.h" | 23 #include "grit/extensions_resources.h" |
| 26 | 24 |
| 27 namespace extensions { | 25 namespace extensions { |
| 28 | 26 |
| 29 namespace { | 27 namespace { |
| 30 | 28 |
| 31 template <class FeatureClass> | 29 template <class FeatureClass> |
| 32 SimpleFeature* CreateFeature() { | 30 SimpleFeature* CreateFeature() { |
| 33 return new FeatureClass; | 31 return new FeatureClass; |
| 34 } | 32 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 return provider.Pass(); | 126 return provider.Pass(); |
| 129 } | 127 } |
| 130 | 128 |
| 131 scoped_ptr<JSONFeatureProviderSource> | 129 scoped_ptr<JSONFeatureProviderSource> |
| 132 ShellExtensionsClient::CreateFeatureProviderSource( | 130 ShellExtensionsClient::CreateFeatureProviderSource( |
| 133 const std::string& name) const { | 131 const std::string& name) const { |
| 134 scoped_ptr<JSONFeatureProviderSource> source( | 132 scoped_ptr<JSONFeatureProviderSource> source( |
| 135 new JSONFeatureProviderSource(name)); | 133 new JSONFeatureProviderSource(name)); |
| 136 if (name == "api") { | 134 if (name == "api") { |
| 137 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | 135 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
| 138 source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES); | |
| 139 } else if (name == "manifest") { | 136 } else if (name == "manifest") { |
| 140 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | 137 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); |
| 141 } else if (name == "permission") { | 138 } else if (name == "permission") { |
| 142 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | 139 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); |
| 143 } else { | 140 } else { |
| 144 NOTREACHED(); | 141 NOTREACHED(); |
| 145 source.reset(); | 142 source.reset(); |
| 146 } | 143 } |
| 147 return source.Pass(); | 144 return source.Pass(); |
| 148 } | 145 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 } | 170 } |
| 174 | 171 |
| 175 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, | 172 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, |
| 176 std::string* error) const { | 173 std::string* error) const { |
| 177 NOTIMPLEMENTED(); | 174 NOTIMPLEMENTED(); |
| 178 return true; | 175 return true; |
| 179 } | 176 } |
| 180 | 177 |
| 181 bool ShellExtensionsClient::IsAPISchemaGenerated( | 178 bool ShellExtensionsClient::IsAPISchemaGenerated( |
| 182 const std::string& name) const { | 179 const std::string& name) const { |
| 183 // TODO(rockot): Remove dependency on src/chrome once we have some core APIs | 180 return core_api::GeneratedSchemas::IsGenerated(name); |
| 184 // moved out. See http://crbug.com/349042. | |
| 185 // Special-case our simplified app.runtime implementation because we don't | |
| 186 // have the Chrome app APIs available. | |
| 187 return core_api::GeneratedSchemas::IsGenerated(name) || | |
| 188 shell_api::GeneratedSchemas::IsGenerated(name); | |
| 189 } | 181 } |
| 190 | 182 |
| 191 base::StringPiece ShellExtensionsClient::GetAPISchema( | 183 base::StringPiece ShellExtensionsClient::GetAPISchema( |
| 192 const std::string& name) const { | 184 const std::string& name) const { |
| 193 // Schema for chrome.shell APIs. | |
| 194 if (shell_api::GeneratedSchemas::IsGenerated(name)) | |
| 195 return shell_api::GeneratedSchemas::Get(name); | |
| 196 | |
| 197 return core_api::GeneratedSchemas::Get(name); | 185 return core_api::GeneratedSchemas::Get(name); |
| 198 } | 186 } |
| 199 | 187 |
| 200 void ShellExtensionsClient::RegisterAPISchemaResources( | 188 void ShellExtensionsClient::RegisterAPISchemaResources( |
| 201 ExtensionAPI* api) const { | 189 ExtensionAPI* api) const { |
| 202 } | 190 } |
| 203 | 191 |
| 204 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { | 192 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { |
| 205 return true; | 193 return true; |
| 206 } | 194 } |
| 207 | 195 |
| 208 } // namespace extensions | 196 } // namespace extensions |
| OLD | NEW |