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