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_BROWSER_API_EXTENSIONS_API_CLIENT_H_
6 #define EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "extensions/browser/api/declarative_content/content_rules_registry.h"
13 #include "extensions/browser/api/storage/settings_namespace.h"
19 class ObserverListThreadSafe
;
27 namespace extensions
{
29 class AppViewGuestDelegate
;
30 class ContentRulesRegistry
;
31 class DevicePermissionsPrompt
;
32 class ExtensionOptionsGuest
;
33 class ExtensionOptionsGuestDelegate
;
34 class ManagementAPIDelegate
;
35 class MimeHandlerViewGuest
;
36 class MimeHandlerViewGuestDelegate
;
38 class WebViewGuestDelegate
;
39 class WebViewPermissionHelper
;
40 class WebViewPermissionHelperDelegate
;
41 class WebRequestEventRouterDelegate
;
42 class RulesCacheDelegate
;
43 class SettingsObserver
;
44 class SettingsStorageFactory
;
45 class ValueStoreCache
;
46 class VirtualKeyboardDelegate
;
48 // Allows the embedder of the extensions module to customize its support for
49 // API features. The embedder must create a single instance in the browser
50 // process. Provides a default implementation that does nothing.
51 class ExtensionsAPIClient
{
53 // Construction sets the single instance.
54 ExtensionsAPIClient();
56 // Destruction clears the single instance.
57 virtual ~ExtensionsAPIClient();
59 // Returns the single instance of |this|.
60 static ExtensionsAPIClient
* Get();
62 // Storage API support.
64 // Add any additional value store caches (e.g. for chrome.storage.managed)
65 // to |caches|. By default adds nothing.
66 virtual void AddAdditionalValueStoreCaches(
67 content::BrowserContext
* context
,
68 const scoped_refptr
<SettingsStorageFactory
>& factory
,
69 const scoped_refptr
<base::ObserverListThreadSafe
<SettingsObserver
>>&
71 std::map
<settings_namespace::Namespace
, ValueStoreCache
*>* caches
);
73 // Attaches any extra web contents helpers (like ExtensionWebContentsObserver)
75 virtual void AttachWebContentsHelpers(content::WebContents
* web_contents
)
78 // Creates the AppViewGuestDelegate.
79 virtual AppViewGuestDelegate
* CreateAppViewGuestDelegate() const;
81 // Returns a delegate for ExtensionOptionsGuest. The caller owns the returned
82 // ExtensionOptionsGuestDelegate.
83 virtual ExtensionOptionsGuestDelegate
* CreateExtensionOptionsGuestDelegate(
84 ExtensionOptionsGuest
* guest
) const;
86 // Creates a delegate for MimeHandlerViewGuest.
87 virtual scoped_ptr
<MimeHandlerViewGuestDelegate
>
88 CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest
* guest
) const;
90 // Returns a delegate for some of WebViewGuest's behavior. The caller owns the
91 // returned WebViewGuestDelegate.
92 virtual WebViewGuestDelegate
* CreateWebViewGuestDelegate (
93 WebViewGuest
* web_view_guest
) const;
95 // Returns a delegate for some of WebViewPermissionHelper's behavior. The
96 // caller owns the returned WebViewPermissionHelperDelegate.
97 virtual WebViewPermissionHelperDelegate
*
98 CreateWebViewPermissionHelperDelegate (
99 WebViewPermissionHelper
* web_view_permission_helper
) const;
101 // Creates a delegate for WebRequestEventRouter.
102 virtual WebRequestEventRouterDelegate
* CreateWebRequestEventRouterDelegate()
105 // TODO(wjmaclean): Remove this when (if) ContentRulesRegistry code moves
106 // to extensions/browser/api.
107 virtual scoped_refptr
<ContentRulesRegistry
> CreateContentRulesRegistry(
108 content::BrowserContext
* browser_context
,
109 RulesCacheDelegate
* cache_delegate
) const;
111 // Creates a DevicePermissionsPrompt appropriate for the embedder.
112 virtual scoped_ptr
<DevicePermissionsPrompt
> CreateDevicePermissionsPrompt(
113 content::WebContents
* web_contents
) const;
115 // Returns a delegate for some of VirtualKeyboardAPI's behavior.
116 virtual scoped_ptr
<VirtualKeyboardDelegate
> CreateVirtualKeyboardDelegate()
119 // Creates a delegate for handling the management extension api.
120 virtual ManagementAPIDelegate
* CreateManagementAPIDelegate() const;
122 // NOTE: If this interface gains too many methods (perhaps more than 20) it
123 // should be split into one interface per API.
126 } // namespace extensions
128 #endif // EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_