Ignore non-active fullscreen windows for shelf state.
[chromium-blink-merge.git] / extensions / common / extensions_client.h
blobfb6aba87ac8e65d667bd8bff2e24d8cf6b0db466
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 // Initializes global state. Not done in the constructor because unit tests
32 // can create additional ExtensionsClients because the utility thread runs
33 // in-process.
34 virtual void Initialize() = 0;
36 // Returns a PermissionsProvider to initialize the permissions system.
37 virtual const PermissionsProvider& GetPermissionsProvider() const = 0;
39 // Returns the global PermissionMessageProvider to use to provide permission
40 // warning strings.
41 virtual const PermissionMessageProvider& GetPermissionMessageProvider()
42 const = 0;
44 // Gets a feature provider for a specific feature type.
45 virtual FeatureProvider* GetFeatureProviderByName(const std::string& name)
46 const = 0;
48 // Takes the list of all hosts and filters out those with special
49 // permission strings. Adds the regular hosts to |new_hosts|,
50 // and adds the special permission messages to |messages|.
51 virtual void FilterHostPermissions(
52 const URLPatternSet& hosts,
53 URLPatternSet* new_hosts,
54 std::set<PermissionMessage>* messages) const = 0;
56 // Replaces the scripting whitelist with |whitelist|. Used in the renderer;
57 // only used for testing in the browser process.
58 virtual void SetScriptingWhitelist(const ScriptingWhitelist& whitelist) = 0;
60 // Return the whitelist of extensions that can run content scripts on
61 // any origin.
62 virtual const ScriptingWhitelist& GetScriptingWhitelist() const = 0;
64 // Get the set of chrome:// hosts that |extension| can run content scripts on.
65 virtual URLPatternSet GetPermittedChromeSchemeHosts(
66 const Extension* extension,
67 const APIPermissionSet& api_permissions) const = 0;
69 // Returns false if content scripts are forbidden from running on |url|.
70 virtual bool IsScriptableURL(const GURL& url, std::string* error) const = 0;
72 // Return the extensions client.
73 static ExtensionsClient* Get();
75 // Initialize the extensions system with this extensions client.
76 static void Set(ExtensionsClient* client);
79 } // namespace extensions
81 #endif // EXTENSIONS_COMMON_EXTENSIONS_CLIENT_H_