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 guest_view
{
28 class GuestViewManagerDelegate
;
29 } // namespace guest_view
31 namespace extensions
{
33 class AppViewGuestDelegate
;
34 class ContentRulesRegistry
;
35 class DevicePermissionsPrompt
;
36 class ExtensionOptionsGuest
;
37 class ExtensionOptionsGuestDelegate
;
38 class ManagementAPIDelegate
;
39 class MimeHandlerViewGuest
;
40 class MimeHandlerViewGuestDelegate
;
42 class WebViewGuestDelegate
;
43 class WebViewPermissionHelper
;
44 class WebViewPermissionHelperDelegate
;
45 class WebRequestEventRouterDelegate
;
46 class RulesCacheDelegate
;
47 class SettingsObserver
;
48 class SettingsStorageFactory
;
49 class ValueStoreCache
;
50 class VirtualKeyboardDelegate
;
52 // Allows the embedder of the extensions module to customize its support for
53 // API features. The embedder must create a single instance in the browser
54 // process. Provides a default implementation that does nothing.
55 class ExtensionsAPIClient
{
57 // Construction sets the single instance.
58 ExtensionsAPIClient();
60 // Destruction clears the single instance.
61 virtual ~ExtensionsAPIClient();
63 // Returns the single instance of |this|.
64 static ExtensionsAPIClient
* Get();
66 // Storage API support.
68 // Add any additional value store caches (e.g. for chrome.storage.managed)
69 // to |caches|. By default adds nothing.
70 virtual void AddAdditionalValueStoreCaches(
71 content::BrowserContext
* context
,
72 const scoped_refptr
<SettingsStorageFactory
>& factory
,
73 const scoped_refptr
<base::ObserverListThreadSafe
<SettingsObserver
>>&
75 std::map
<settings_namespace::Namespace
, ValueStoreCache
*>* caches
);
77 // Attaches any extra web contents helpers (like ExtensionWebContentsObserver)
79 virtual void AttachWebContentsHelpers(content::WebContents
* web_contents
)
82 // Creates the AppViewGuestDelegate.
83 virtual AppViewGuestDelegate
* CreateAppViewGuestDelegate() const;
85 // Returns a delegate for ExtensionOptionsGuest. The caller owns the returned
86 // ExtensionOptionsGuestDelegate.
87 virtual ExtensionOptionsGuestDelegate
* CreateExtensionOptionsGuestDelegate(
88 ExtensionOptionsGuest
* guest
) const;
90 // Returns a delegate for GuestViewManagerDelegate.
91 virtual scoped_ptr
<guest_view::GuestViewManagerDelegate
>
92 CreateGuestViewManagerDelegate(content::BrowserContext
* context
) const;
94 // Creates a delegate for MimeHandlerViewGuest.
95 virtual scoped_ptr
<MimeHandlerViewGuestDelegate
>
96 CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest
* guest
) const;
98 // Returns a delegate for some of WebViewGuest's behavior. The caller owns the
99 // returned WebViewGuestDelegate.
100 virtual WebViewGuestDelegate
* CreateWebViewGuestDelegate (
101 WebViewGuest
* web_view_guest
) const;
103 // Returns a delegate for some of WebViewPermissionHelper's behavior. The
104 // caller owns the returned WebViewPermissionHelperDelegate.
105 virtual WebViewPermissionHelperDelegate
*
106 CreateWebViewPermissionHelperDelegate (
107 WebViewPermissionHelper
* web_view_permission_helper
) const;
109 // Creates a delegate for WebRequestEventRouter.
110 virtual WebRequestEventRouterDelegate
* CreateWebRequestEventRouterDelegate()
113 // TODO(wjmaclean): Remove this when (if) ContentRulesRegistry code moves
114 // to extensions/browser/api.
115 virtual scoped_refptr
<ContentRulesRegistry
> CreateContentRulesRegistry(
116 content::BrowserContext
* browser_context
,
117 RulesCacheDelegate
* cache_delegate
) const;
119 // Creates a DevicePermissionsPrompt appropriate for the embedder.
120 virtual scoped_ptr
<DevicePermissionsPrompt
> CreateDevicePermissionsPrompt(
121 content::WebContents
* web_contents
) const;
123 // Returns a delegate for some of VirtualKeyboardAPI's behavior.
124 virtual scoped_ptr
<VirtualKeyboardDelegate
> CreateVirtualKeyboardDelegate()
127 // Creates a delegate for handling the management extension api.
128 virtual ManagementAPIDelegate
* CreateManagementAPIDelegate() const;
130 // NOTE: If this interface gains too many methods (perhaps more than 20) it
131 // should be split into one interface per API.
134 } // namespace extensions
136 #endif // EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_