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 #ifndef EXTENSIONS_TEST_TEST_EXTENSIONS_CLIENT_H_
6 #define EXTENSIONS_TEST_TEST_EXTENSIONS_CLIENT_H_
8 #include "base/macros.h"
9 #include "extensions/common/extensions_client.h"
11 namespace extensions
{
13 class TestExtensionsClient
: public ExtensionsClient
{
15 // An interface that lets tests change the set of image paths before they are
16 // returned by TestExtensionClient::GetBrowserImagePaths.
17 class BrowserImagePathsFilter
{
19 virtual void Filter(const Extension
* extension
,
20 std::set
<base::FilePath
>* paths
) = 0;
23 TestExtensionsClient();
24 ~TestExtensionsClient() override
;
26 void AddBrowserImagePathsFilter(BrowserImagePathsFilter
* filter
);
27 void RemoveBrowserImagePathsFilter(BrowserImagePathsFilter
* filter
);
30 void Initialize() override
;
31 const PermissionMessageProvider
& GetPermissionMessageProvider()
33 const std::string
GetProductName() override
;
34 scoped_ptr
<FeatureProvider
> CreateFeatureProvider(
35 const std::string
& name
) const override
;
36 scoped_ptr
<JSONFeatureProviderSource
> CreateFeatureProviderSource(
37 const std::string
& name
) const override
;
38 void FilterHostPermissions(
39 const URLPatternSet
& hosts
,
40 URLPatternSet
* new_hosts
,
41 std::set
<PermissionMessage
>* messages
) const override
;
42 void FilterHostPermissions(const URLPatternSet
& hosts
,
43 URLPatternSet
* new_hosts
,
44 PermissionIDSet
* permissions
) const override
;
45 void SetScriptingWhitelist(const ScriptingWhitelist
& whitelist
) override
;
46 const ScriptingWhitelist
& GetScriptingWhitelist() const override
;
47 URLPatternSet
GetPermittedChromeSchemeHosts(
48 const Extension
* extension
,
49 const APIPermissionSet
& api_permissions
) const override
;
50 bool IsScriptableURL(const GURL
& url
, std::string
* error
) const override
;
51 bool IsAPISchemaGenerated(const std::string
& name
) const override
;
52 base::StringPiece
GetAPISchema(const std::string
& name
) const override
;
53 void RegisterAPISchemaResources(ExtensionAPI
* api
) const override
;
54 bool ShouldSuppressFatalErrors() const override
;
55 std::string
GetWebstoreBaseURL() const override
;
56 std::string
GetWebstoreUpdateURL() const override
;
57 bool IsBlacklistUpdateURL(const GURL
& url
) const override
;
58 std::set
<base::FilePath
> GetBrowserImagePaths(
59 const Extension
* extension
) override
;
61 // A whitelist of extensions that can script anywhere. Do not add to this
62 // list (except in tests) without consulting the Extensions team first.
63 // Note: Component extensions have this right implicitly and do not need to be
64 // added to this list.
65 ScriptingWhitelist scripting_whitelist_
;
67 std::set
<BrowserImagePathsFilter
*> browser_image_filters_
;
69 DISALLOW_COPY_AND_ASSIGN(TestExtensionsClient
);
72 } // namespace extensions
74 #endif // EXTENSIONS_TEST_TEST_EXTENSIONS_CLIENT_H_