1 // Copyright 2013 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 CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_
6 #define CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h"
11 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
12 #include "chrome/common/extensions/permissions/chrome_permission_message_provider.h"
13 #include "extensions/common/extensions_client.h"
14 #include "extensions/common/permissions/extensions_api_permissions.h"
16 namespace extensions
{
18 // The implementation of ExtensionsClient for Chrome, which encapsulates the
19 // global knowledge of features, permissions, and manifest fields.
20 class ChromeExtensionsClient
: public ExtensionsClient
{
22 ChromeExtensionsClient();
23 ~ChromeExtensionsClient() override
;
25 void Initialize() override
;
27 const PermissionMessageProvider
& GetPermissionMessageProvider()
29 const std::string
GetProductName() override
;
30 scoped_ptr
<FeatureProvider
> CreateFeatureProvider(
31 const std::string
& name
) const override
;
32 scoped_ptr
<JSONFeatureProviderSource
> CreateFeatureProviderSource(
33 const std::string
& name
) const override
;
34 void FilterHostPermissions(
35 const URLPatternSet
& hosts
,
36 URLPatternSet
* new_hosts
,
37 std::set
<PermissionMessage
>* messages
) const override
;
38 void FilterHostPermissions(const URLPatternSet
& hosts
,
39 URLPatternSet
* new_hosts
,
40 PermissionIDSet
* permissions
) const override
;
41 void SetScriptingWhitelist(const ScriptingWhitelist
& whitelist
) override
;
42 const ScriptingWhitelist
& GetScriptingWhitelist() const override
;
43 URLPatternSet
GetPermittedChromeSchemeHosts(
44 const Extension
* extension
,
45 const APIPermissionSet
& api_permissions
) const override
;
46 bool IsScriptableURL(const GURL
& url
, std::string
* error
) const override
;
47 bool IsAPISchemaGenerated(const std::string
& name
) const override
;
48 base::StringPiece
GetAPISchema(const std::string
& name
) const override
;
49 void RegisterAPISchemaResources(ExtensionAPI
* api
) const override
;
50 bool ShouldSuppressFatalErrors() const override
;
51 std::string
GetWebstoreBaseURL() const override
;
52 std::string
GetWebstoreUpdateURL() const override
;
53 bool IsBlacklistUpdateURL(const GURL
& url
) const override
;
54 std::set
<base::FilePath
> GetBrowserImagePaths(
55 const Extension
* extension
) override
;
57 // Get the LazyInstance for ChromeExtensionsClient.
58 static ChromeExtensionsClient
* GetInstance();
61 const ChromeAPIPermissions chrome_api_permissions_
;
62 const ExtensionsAPIPermissions extensions_api_permissions_
;
63 const ChromePermissionMessageProvider permission_message_provider_
;
65 // A whitelist of extensions that can script anywhere. Do not add to this
66 // list (except in tests) without consulting the Extensions team first.
67 // Note: Component extensions have this right implicitly and do not need to be
68 // added to this list.
69 ScriptingWhitelist scripting_whitelist_
;
71 friend struct base::DefaultLazyInstanceTraits
<ChromeExtensionsClient
>;
73 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsClient
);
76 } // namespace extensions
78 #endif // CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_