Change DtmfSenderHandler to handle events on the signaling thread.
[chromium-blink-merge.git] / extensions / test / test_extensions_client.cc
blobe93666a713a923f56e0fa0d087d6e1bbf86c2a92
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
3 // found in the LICENSE file.
5 #include "extensions/test/test_extensions_client.h"
7 #include "extensions/common/api/generated_schemas.h"
8 #include "extensions/common/common_manifest_handlers.h"
9 #include "extensions/common/extension_urls.h"
10 #include "extensions/common/features/api_feature.h"
11 #include "extensions/common/features/base_feature_provider.h"
12 #include "extensions/common/features/feature_provider.h"
13 #include "extensions/common/features/json_feature_provider_source.h"
14 #include "extensions/common/features/manifest_feature.h"
15 #include "extensions/common/features/permission_feature.h"
16 #include "extensions/common/manifest_handler.h"
17 #include "extensions/common/permissions/extensions_api_permissions.h"
18 #include "extensions/common/permissions/permissions_info.h"
19 #include "extensions/common/url_pattern_set.h"
20 #include "extensions/test/test_permission_message_provider.h"
21 #include "grit/extensions_resources.h"
23 namespace extensions {
25 namespace {
27 template <class FeatureClass>
28 SimpleFeature* CreateFeature() {
29 return new FeatureClass;
32 } // namespace
34 TestExtensionsClient::TestExtensionsClient() {
37 TestExtensionsClient::~TestExtensionsClient() {
40 void TestExtensionsClient::Initialize() {
41 // Registration could already be finalized in unit tests, where the utility
42 // thread runs in-process.
43 if (!ManifestHandler::IsRegistrationFinalized()) {
44 RegisterCommonManifestHandlers();
45 ManifestHandler::FinalizeRegistration();
48 // Allow the core API permissions.
49 static ExtensionsAPIPermissions extensions_api_permissions;
50 PermissionsInfo::GetInstance()->AddProvider(extensions_api_permissions);
53 const PermissionMessageProvider&
54 TestExtensionsClient::GetPermissionMessageProvider() const {
55 static TestPermissionMessageProvider provider;
56 return provider;
59 const std::string TestExtensionsClient::GetProductName() {
60 return "extensions_test";
63 scoped_ptr<FeatureProvider> TestExtensionsClient::CreateFeatureProvider(
64 const std::string& name) const {
65 scoped_ptr<FeatureProvider> provider;
66 scoped_ptr<JSONFeatureProviderSource> source(
67 CreateFeatureProviderSource(name));
68 if (name == "api") {
69 provider.reset(new BaseFeatureProvider(source->dictionary(),
70 CreateFeature<APIFeature>));
71 } else if (name == "manifest") {
72 provider.reset(new BaseFeatureProvider(source->dictionary(),
73 CreateFeature<ManifestFeature>));
74 } else if (name == "permission") {
75 provider.reset(new BaseFeatureProvider(source->dictionary(),
76 CreateFeature<PermissionFeature>));
77 } else {
78 NOTREACHED();
80 return provider.Pass();
83 scoped_ptr<JSONFeatureProviderSource>
84 TestExtensionsClient::CreateFeatureProviderSource(
85 const std::string& name) const {
86 scoped_ptr<JSONFeatureProviderSource> source(
87 new JSONFeatureProviderSource(name));
88 if (name == "api") {
89 source->LoadJSON(IDR_EXTENSION_API_FEATURES);
90 } else if (name == "manifest") {
91 source->LoadJSON(IDR_EXTENSION_MANIFEST_FEATURES);
92 } else if (name == "permission") {
93 source->LoadJSON(IDR_EXTENSION_PERMISSION_FEATURES);
94 } else {
95 NOTREACHED();
96 source.reset();
98 return source.Pass();
101 void TestExtensionsClient::FilterHostPermissions(
102 const URLPatternSet& hosts,
103 URLPatternSet* new_hosts,
104 std::set<PermissionMessage>* messages) const {
107 void TestExtensionsClient::SetScriptingWhitelist(
108 const ExtensionsClient::ScriptingWhitelist& whitelist) {
109 scripting_whitelist_ = whitelist;
112 const ExtensionsClient::ScriptingWhitelist&
113 TestExtensionsClient::GetScriptingWhitelist() const {
114 return scripting_whitelist_;
117 URLPatternSet TestExtensionsClient::GetPermittedChromeSchemeHosts(
118 const Extension* extension,
119 const APIPermissionSet& api_permissions) const {
120 URLPatternSet hosts;
121 return hosts;
124 bool TestExtensionsClient::IsScriptableURL(const GURL& url,
125 std::string* error) const {
126 return true;
129 bool TestExtensionsClient::IsAPISchemaGenerated(
130 const std::string& name) const {
131 return core_api::GeneratedSchemas::IsGenerated(name);
134 base::StringPiece TestExtensionsClient::GetAPISchema(
135 const std::string& name) const {
136 return core_api::GeneratedSchemas::Get(name);
139 void TestExtensionsClient::RegisterAPISchemaResources(ExtensionAPI* api) const {
142 bool TestExtensionsClient::ShouldSuppressFatalErrors() const {
143 return true;
146 std::string TestExtensionsClient::GetWebstoreBaseURL() const {
147 return extension_urls::kChromeWebstoreBaseURL;
150 std::string TestExtensionsClient::GetWebstoreUpdateURL() const {
151 return extension_urls::kChromeWebstoreUpdateURL;
154 bool TestExtensionsClient::IsBlacklistUpdateURL(const GURL& url) const {
155 return true;
158 } // namespace extensions