| 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/common_manifest_handlers.h" | 10 #include "extensions/common/common_manifest_handlers.h" |
| 11 #include "extensions/common/extension_urls.h" | 11 #include "extensions/common/extension_urls.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" |
| 23 #include "grit/extensions_resources.h" | 25 #include "grit/extensions_resources.h" |
| 24 | 26 |
| 25 namespace extensions { | 27 namespace extensions { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| 28 | 30 |
| 29 template <class FeatureClass> | 31 template <class FeatureClass> |
| 30 SimpleFeature* CreateFeature() { | 32 SimpleFeature* CreateFeature() { |
| 31 return new FeatureClass; | 33 return new FeatureClass; |
| 32 } | 34 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 return provider.Pass(); | 122 return provider.Pass(); |
| 121 } | 123 } |
| 122 | 124 |
| 123 scoped_ptr<JSONFeatureProviderSource> | 125 scoped_ptr<JSONFeatureProviderSource> |
| 124 ShellExtensionsClient::CreateFeatureProviderSource( | 126 ShellExtensionsClient::CreateFeatureProviderSource( |
| 125 const std::string& name) const { | 127 const std::string& name) const { |
| 126 scoped_ptr<JSONFeatureProviderSource> source( | 128 scoped_ptr<JSONFeatureProviderSource> source( |
| 127 new JSONFeatureProviderSource(name)); | 129 new JSONFeatureProviderSource(name)); |
| 128 if (name == "api") { | 130 if (name == "api") { |
| 129 source->LoadJSON(IDR_EXTENSION_API_FEATURES); | 131 source->LoadJSON(IDR_EXTENSION_API_FEATURES); |
| 132 source->LoadJSON(IDR_SHELL_EXTENSION_API_FEATURES); |
| 130 } else if (name == "manifest") { | 133 } else if (name == "manifest") { |
| 131 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); | 134 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES); |
| 132 } else if (name == "permission") { | 135 } else if (name == "permission") { |
| 133 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); | 136 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES); |
| 134 } else { | 137 } else { |
| 135 NOTREACHED(); | 138 NOTREACHED(); |
| 136 source.reset(); | 139 source.reset(); |
| 137 } | 140 } |
| 138 return source.Pass(); | 141 return source.Pass(); |
| 139 } | 142 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 164 } | 167 } |
| 165 | 168 |
| 166 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, | 169 bool ShellExtensionsClient::IsScriptableURL(const GURL& url, |
| 167 std::string* error) const { | 170 std::string* error) const { |
| 168 NOTIMPLEMENTED(); | 171 NOTIMPLEMENTED(); |
| 169 return true; | 172 return true; |
| 170 } | 173 } |
| 171 | 174 |
| 172 bool ShellExtensionsClient::IsAPISchemaGenerated( | 175 bool ShellExtensionsClient::IsAPISchemaGenerated( |
| 173 const std::string& name) const { | 176 const std::string& name) const { |
| 174 return core_api::GeneratedSchemas::IsGenerated(name); | 177 return core_api::GeneratedSchemas::IsGenerated(name) || |
| 178 shell_api::GeneratedSchemas::IsGenerated(name); |
| 175 } | 179 } |
| 176 | 180 |
| 177 base::StringPiece ShellExtensionsClient::GetAPISchema( | 181 base::StringPiece ShellExtensionsClient::GetAPISchema( |
| 178 const std::string& name) const { | 182 const std::string& name) const { |
| 183 // Schema for app_shell-only APIs. |
| 184 if (shell_api::GeneratedSchemas::IsGenerated(name)) |
| 185 return shell_api::GeneratedSchemas::Get(name); |
| 186 |
| 187 // Core extensions APIs. |
| 179 return core_api::GeneratedSchemas::Get(name); | 188 return core_api::GeneratedSchemas::Get(name); |
| 180 } | 189 } |
| 181 | 190 |
| 182 void ShellExtensionsClient::RegisterAPISchemaResources( | 191 void ShellExtensionsClient::RegisterAPISchemaResources( |
| 183 ExtensionAPI* api) const { | 192 ExtensionAPI* api) const { |
| 184 } | 193 } |
| 185 | 194 |
| 186 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { | 195 bool ShellExtensionsClient::ShouldSuppressFatalErrors() const { |
| 187 return true; | 196 return true; |
| 188 } | 197 } |
| 189 | 198 |
| 190 std::string ShellExtensionsClient::GetWebstoreBaseURL() const { | 199 std::string ShellExtensionsClient::GetWebstoreBaseURL() const { |
| 191 return extension_urls::kChromeWebstoreBaseURL; | 200 return extension_urls::kChromeWebstoreBaseURL; |
| 192 } | 201 } |
| 193 | 202 |
| 194 std::string ShellExtensionsClient::GetWebstoreUpdateURL() const { | 203 std::string ShellExtensionsClient::GetWebstoreUpdateURL() const { |
| 195 return extension_urls::kChromeWebstoreUpdateURL; | 204 return extension_urls::kChromeWebstoreUpdateURL; |
| 196 } | 205 } |
| 197 | 206 |
| 198 bool ShellExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { | 207 bool ShellExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const { |
| 199 // TODO(rockot): Maybe we want to do something else here. For now we accept | 208 // TODO(rockot): Maybe we want to do something else here. For now we accept |
| 200 // any URL as a blacklist URL because we don't really care. | 209 // any URL as a blacklist URL because we don't really care. |
| 201 return true; | 210 return true; |
| 202 } | 211 } |
| 203 | 212 |
| 204 } // namespace extensions | 213 } // namespace extensions |
| OLD | NEW |