Connect PPAPI IPC channels for non-SFI mode.
[chromium-blink-merge.git] / extensions / common / extensions_client.h
blobd309fd7e8084cafd2b757f1d117dc7325e026af5
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 EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_
6 #define EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 class GURL;
14 namespace extensions {
16 class APIPermissionSet;
17 class Extension;
18 class FeatureProvider;
19 class ManifestPermissionSet;
20 class PermissionMessage;
21 class PermissionMessageProvider;
22 class PermissionsProvider;
23 class URLPatternSet;
25 // Sets up global state for the extensions system. Should be Set() once in each
26 // process. This should be implemented by the client of the extensions system.
27 class ExtensionsClient {
28 public:
29 typedef std::vector<std::string> ScriptingWhitelist;
31 virtual ~ExtensionsClient() {}
33 // Initializes global state. Not done in the constructor because unit tests
34 // can create additional ExtensionsClients because the utility thread runs
35 // in-process.
36 virtual void Initialize() = 0;
38 // Returns a PermissionsProvider to initialize the permissions system.
39 virtual const PermissionsProvider& GetPermissionsProvider() const = 0;
41 // Returns the global PermissionMessageProvider to use to provide permission
42 // warning strings.
43 virtual const PermissionMessageProvider& GetPermissionMessageProvider()
44 const = 0;
46 // Gets a feature provider for a specific feature type.
47 virtual FeatureProvider* GetFeatureProviderByName(const std::string& name)
48 const = 0;
50 // Takes the list of all hosts and filters out those with special
51 // permission strings. Adds the regular hosts to |new_hosts|,
52 // and adds the special permission messages to |messages|.
53 virtual void FilterHostPermissions(
54 const URLPatternSet& hosts,
55 URLPatternSet* new_hosts,
56 std::set<PermissionMessage>* messages) const = 0;
58 // Replaces the scripting whitelist with |whitelist|. Used in the renderer;
59 // only used for testing in the browser process.
60 virtual void SetScriptingWhitelist(const ScriptingWhitelist& whitelist) = 0;
62 // Return the whitelist of extensions that can run content scripts on
63 // any origin.
64 virtual const ScriptingWhitelist& GetScriptingWhitelist() const = 0;
66 // Get the set of chrome:// hosts that |extension| can run content scripts on.
67 virtual URLPatternSet GetPermittedChromeSchemeHosts(
68 const Extension* extension,
69 const APIPermissionSet& api_permissions) const = 0;
71 // Returns false if content scripts are forbidden from running on |url|.
72 virtual bool IsScriptableURL(const GURL& url, std::string* error) const = 0;
74 // Return the extensions client.
75 static ExtensionsClient* Get();
77 // Initialize the extensions system with this extensions client.
78 static void Set(ExtensionsClient* client);
81 } // namespace extensions
83 #endif // EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_