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 ManagementAPIDelegate
;
33 class MimeHandlerViewGuest
;
34 class MimeHandlerViewGuestDelegate
;
36 class WebViewGuestDelegate
;
37 class WebViewPermissionHelper
;
38 class WebViewPermissionHelperDelegate
;
39 class WebRequestEventRouterDelegate
;
40 class RulesCacheDelegate
;
41 class SettingsObserver
;
42 class SettingsStorageFactory
;
43 class ValueStoreCache
;
44 class VirtualKeyboardDelegate
;
46 // Allows the embedder of the extensions module to customize its support for
47 // API features. The embedder must create a single instance in the browser
48 // process. Provides a default implementation that does nothing.
49 class ExtensionsAPIClient
{
51 // Construction sets the single instance.
52 ExtensionsAPIClient();
54 // Destruction clears the single instance.
55 virtual ~ExtensionsAPIClient();
57 // Returns the single instance of |this|.
58 static ExtensionsAPIClient
* Get();
60 // Storage API support.
62 // Add any additional value store caches (e.g. for chrome.storage.managed)
63 // to |caches|. By default adds nothing.
64 virtual void AddAdditionalValueStoreCaches(
65 content::BrowserContext
* context
,
66 const scoped_refptr
<SettingsStorageFactory
>& factory
,
67 const scoped_refptr
<ObserverListThreadSafe
<SettingsObserver
> >& observers
,
68 std::map
<settings_namespace::Namespace
, ValueStoreCache
*>* caches
);
70 // Creates the AppViewGuestDelegate.
71 virtual AppViewGuestDelegate
* CreateAppViewGuestDelegate() const;
73 // Returns a delegate for ExtensionOptionsGuest. The caller owns the returned
74 // ExtensionOptionsGuestDelegate.
75 virtual ExtensionOptionsGuestDelegate
* CreateExtensionOptionsGuestDelegate(
76 ExtensionOptionsGuest
* guest
) const;
78 // Creates a delegate for MimeHandlerViewGuest.
79 virtual scoped_ptr
<MimeHandlerViewGuestDelegate
>
80 CreateMimeHandlerViewGuestDelegate(MimeHandlerViewGuest
* guest
) const;
82 // Returns a delegate for some of WebViewGuest's behavior. The caller owns the
83 // returned WebViewGuestDelegate.
84 virtual WebViewGuestDelegate
* CreateWebViewGuestDelegate (
85 WebViewGuest
* web_view_guest
) const;
87 // Returns a delegate for some of WebViewPermissionHelper's behavior. The
88 // caller owns the returned WebViewPermissionHelperDelegate.
89 virtual WebViewPermissionHelperDelegate
*
90 CreateWebViewPermissionHelperDelegate (
91 WebViewPermissionHelper
* web_view_permission_helper
) const;
93 // Creates a delegate for WebRequestEventRouter.
94 virtual WebRequestEventRouterDelegate
* CreateWebRequestEventRouterDelegate()
97 // TODO(wjmaclean): Remove this when (if) ContentRulesRegistry code moves
98 // to extensions/browser/api.
99 virtual scoped_refptr
<ContentRulesRegistry
> CreateContentRulesRegistry(
100 content::BrowserContext
* browser_context
,
101 RulesCacheDelegate
* cache_delegate
) const;
103 // Creates a DevicePermissionsPrompt appropriate for the embedder.
104 virtual scoped_ptr
<DevicePermissionsPrompt
> CreateDevicePermissionsPrompt(
105 content::WebContents
* web_contents
) const;
107 // Returns a delegate for some of VirtualKeyboardAPI's behavior.
108 virtual scoped_ptr
<VirtualKeyboardDelegate
> CreateVirtualKeyboardDelegate()
111 // Creates a delegate for handling the management extension api.
112 virtual ManagementAPIDelegate
* CreateManagementAPIDelegate() const;
114 // NOTE: If this interface gains too many methods (perhaps more than 20) it
115 // should be split into one interface per API.
118 } // namespace extensions
120 #endif // EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_