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"
18 class ObserverListThreadSafe
;
25 namespace extensions
{
27 class AppViewGuestDelegate
;
28 class ContentRulesRegistry
;
29 class DevicePermissionsPrompt
;
30 class ExtensionOptionsGuest
;
31 class ExtensionOptionsGuestDelegate
;
32 class ExtensionViewGuest
;
33 class ExtensionViewGuestDelegate
;
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
<ObserverListThreadSafe
<SettingsObserver
> >& observers
,
70 std::map
<settings_namespace::Namespace
, ValueStoreCache
*>* caches
);
72 // Creates the AppViewGuestDelegate.
73 virtual AppViewGuestDelegate
* CreateAppViewGuestDelegate() const;
75 // Returns a delegate for ExtensionOptionsGuest. The caller owns the returned
76 // ExtensionOptionsGuestDelegate.
77 virtual ExtensionOptionsGuestDelegate
* CreateExtensionOptionsGuestDelegate(
78 ExtensionOptionsGuest
* guest
) const;
80 // Returns a delegate for ExtensionViewGuest. The caller owns the returned
81 // ExtensionViewGuestDelegate.
82 virtual ExtensionViewGuestDelegate
* CreateExtensionViewGuestDelegate(
83 ExtensionViewGuest
* guest
) const;
85 // Creates a delegate for MimeHandlerViewGuest.
86 virtual scoped_ptr
<MimeHandlerViewGuestDelegate
>
87 CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest
* guest
) const;
89 // Returns a delegate for some of WebViewGuest's behavior. The caller owns the
90 // returned WebViewGuestDelegate.
91 virtual WebViewGuestDelegate
* CreateWebViewGuestDelegate (
92 WebViewGuest
* web_view_guest
) const;
94 // Returns a delegate for some of WebViewPermissionHelper's behavior. The
95 // caller owns the returned WebViewPermissionHelperDelegate.
96 virtual WebViewPermissionHelperDelegate
*
97 CreateWebViewPermissionHelperDelegate (
98 WebViewPermissionHelper
* web_view_permission_helper
) const;
100 // Creates a delegate for WebRequestEventRouter.
101 virtual WebRequestEventRouterDelegate
* CreateWebRequestEventRouterDelegate()
104 // TODO(wjmaclean): Remove this when (if) ContentRulesRegistry code moves
105 // to extensions/browser/api.
106 virtual scoped_refptr
<ContentRulesRegistry
> CreateContentRulesRegistry(
107 content::BrowserContext
* browser_context
,
108 RulesCacheDelegate
* cache_delegate
) const;
110 // Creates a DevicePermissionsPrompt appropriate for the embedder.
111 virtual scoped_ptr
<DevicePermissionsPrompt
> CreateDevicePermissionsPrompt(
112 content::WebContents
* web_contents
) const;
114 // Returns a delegate for some of VirtualKeyboardAPI's behavior.
115 virtual scoped_ptr
<VirtualKeyboardDelegate
> CreateVirtualKeyboardDelegate()
118 // Creates a delegate for handling the management extension api.
119 virtual ManagementAPIDelegate
* CreateManagementAPIDelegate() const;
121 // NOTE: If this interface gains too many methods (perhaps more than 20) it
122 // should be split into one interface per API.
125 } // namespace extensions
127 #endif // EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_