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 "extensions/browser/api/storage/settings_namespace.h"
16 class ObserverListThreadSafe
;
26 namespace extensions
{
28 class AppViewGuestDelegate
;
30 class WebViewGuestDelegate
;
31 class WebViewPermissionHelper
;
32 class WebViewPermissionHelperDelegate
;
33 class SettingsObserver
;
34 class SettingsStorageFactory
;
35 class ValueStoreCache
;
37 // Allows the embedder of the extensions module to customize its support for
38 // API features. The embedder must create a single instance in the browser
39 // process. Provides a default implementation that does nothing.
40 class ExtensionsAPIClient
{
42 // Construction sets the single instance.
43 ExtensionsAPIClient();
45 // Destruction clears the single instance.
46 virtual ~ExtensionsAPIClient();
48 // Returns the single instance of |this|.
49 static ExtensionsAPIClient
* Get();
51 // Storage API support.
53 // Add any additional value store caches (e.g. for chrome.storage.managed)
54 // to |caches|. By default adds nothing.
55 virtual void AddAdditionalValueStoreCaches(
56 content::BrowserContext
* context
,
57 const scoped_refptr
<SettingsStorageFactory
>& factory
,
58 const scoped_refptr
<ObserverListThreadSafe
<SettingsObserver
> >& observers
,
59 std::map
<settings_namespace::Namespace
, ValueStoreCache
*>* caches
);
61 // Attaches a frame |url| inside the <appview> specified by
62 // |guest_instance_id|. Returns true if the operation completes succcessfully.
63 virtual bool AppViewInternalAttachFrame(
64 content::BrowserContext
* browser_context
,
66 int guest_instance_id
,
67 const std::string
& guest_extension_id
);
69 // Denies the embedding requested by the <appview> specified by
70 // |guest_instance_id|. Returns true if the operation completes successfully.
71 virtual bool AppViewInternalDenyRequest(
72 content::BrowserContext
* browser_context
,
73 int guest_instance_id
,
74 const std::string
& guest_extension_id
);
76 // Creates the AppViewGuestDelegate.
77 virtual AppViewGuestDelegate
* CreateAppViewGuestDelegate() const;
79 // Returns the HidService instance for this embedder.
80 virtual device::HidService
* GetHidService();
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 virtual void RegisterGuestViewTypes() {}
95 // NOTE: If this interface gains too many methods (perhaps more than 20) it
96 // should be split into one interface per API.
99 } // namespace extensions
101 #endif // EXTENSIONS_BROWSER_API_EXTENSIONS_API_CLIENT_H_