Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / extensions / api / chrome_extensions_api_client.cc
blobab655ed9b3eb4b57c58cee887957e9dd713a4be6
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 #include "chrome/browser/extensions/api/chrome_extensions_api_client.h"
7 #include "base/files/file_path.h"
8 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
9 #include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
10 #include "chrome/browser/extensions/api/management/chrome_management_api_delegate.h"
11 #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
12 #include "chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.h"
13 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
14 #include "chrome/browser/favicon/favicon_utils.h"
15 #include "chrome/browser/guest_view/app_view/chrome_app_view_guest_delegate.h"
16 #include "chrome/browser/guest_view/chrome_guest_view_manager_delegate.h"
17 #include "chrome/browser/guest_view/extension_options/chrome_extension_options_guest_delegate.h"
18 #include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h"
19 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h"
20 #include "chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.h"
21 #include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
22 #include "components/pdf/browser/pdf_web_contents_helper.h"
23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/browser_thread.h"
25 #include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h"
26 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
27 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
29 #if defined(ENABLE_CONFIGURATION_POLICY)
30 #include "chrome/browser/extensions/api/storage/managed_value_store_cache.h"
31 #endif
33 #if defined(OS_CHROMEOS)
34 #include "chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.h"
35 #endif
37 #if defined(ENABLE_PRINTING)
38 #if defined(ENABLE_PRINT_PREVIEW)
39 #include "chrome/browser/printing/print_preview_message_handler.h"
40 #include "chrome/browser/printing/print_view_manager.h"
41 #else
42 #include "chrome/browser/printing/print_view_manager_basic.h"
43 #endif // defined(ENABLE_PRINT_PREVIEW)
44 #endif // defined(ENABLE_PRINTING)
46 namespace extensions {
48 ChromeExtensionsAPIClient::ChromeExtensionsAPIClient() {}
50 ChromeExtensionsAPIClient::~ChromeExtensionsAPIClient() {}
52 void ChromeExtensionsAPIClient::AddAdditionalValueStoreCaches(
53 content::BrowserContext* context,
54 const scoped_refptr<SettingsStorageFactory>& factory,
55 const scoped_refptr<base::ObserverListThreadSafe<SettingsObserver>>&
56 observers,
57 std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) {
58 // Add support for chrome.storage.sync.
59 (*caches)[settings_namespace::SYNC] =
60 new SyncValueStoreCache(factory, observers, context->GetPath());
62 #if defined(ENABLE_CONFIGURATION_POLICY)
63 // Add support for chrome.storage.managed.
64 (*caches)[settings_namespace::MANAGED] =
65 new ManagedValueStoreCache(context, factory, observers);
66 #endif
69 void ChromeExtensionsAPIClient::AttachWebContentsHelpers(
70 content::WebContents* web_contents) const {
71 favicon::CreateContentFaviconDriverForWebContents(web_contents);
72 #if defined(ENABLE_PRINTING)
73 #if defined(ENABLE_PRINT_PREVIEW)
74 printing::PrintViewManager::CreateForWebContents(web_contents);
75 printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
76 #else
77 printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
78 #endif // defined(ENABLE_PRINT_PREVIEW)
79 #endif // defined(ENABLE_PRINTING)
80 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
81 web_contents,
82 scoped_ptr<pdf::PDFWebContentsHelperClient>(
83 new ChromePDFWebContentsHelperClient()));
85 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
86 web_contents);
89 AppViewGuestDelegate* ChromeExtensionsAPIClient::CreateAppViewGuestDelegate()
90 const {
91 return new ChromeAppViewGuestDelegate();
94 ExtensionOptionsGuestDelegate*
95 ChromeExtensionsAPIClient::CreateExtensionOptionsGuestDelegate(
96 ExtensionOptionsGuest* guest) const {
97 return new ChromeExtensionOptionsGuestDelegate(guest);
100 scoped_ptr<guest_view::GuestViewManagerDelegate>
101 ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate(
102 content::BrowserContext* context) const {
103 return make_scoped_ptr(new ChromeGuestViewManagerDelegate(context));
106 scoped_ptr<MimeHandlerViewGuestDelegate>
107 ChromeExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
108 MimeHandlerViewGuest* guest) const {
109 return make_scoped_ptr(new ChromeMimeHandlerViewGuestDelegate());
112 WebViewGuestDelegate* ChromeExtensionsAPIClient::CreateWebViewGuestDelegate(
113 WebViewGuest* web_view_guest) const {
114 return new ChromeWebViewGuestDelegate(web_view_guest);
117 WebViewPermissionHelperDelegate* ChromeExtensionsAPIClient::
118 CreateWebViewPermissionHelperDelegate(
119 WebViewPermissionHelper* web_view_permission_helper) const {
120 return new ChromeWebViewPermissionHelperDelegate(web_view_permission_helper);
123 WebRequestEventRouterDelegate*
124 ChromeExtensionsAPIClient::CreateWebRequestEventRouterDelegate() const {
125 return new ChromeExtensionWebRequestEventRouterDelegate();
128 scoped_refptr<ContentRulesRegistry>
129 ChromeExtensionsAPIClient::CreateContentRulesRegistry(
130 content::BrowserContext* browser_context,
131 RulesCacheDelegate* cache_delegate) const {
132 return scoped_refptr<ContentRulesRegistry>(
133 new ChromeContentRulesRegistry(browser_context, cache_delegate));
136 scoped_ptr<DevicePermissionsPrompt>
137 ChromeExtensionsAPIClient::CreateDevicePermissionsPrompt(
138 content::WebContents* web_contents) const {
139 return make_scoped_ptr(new ChromeDevicePermissionsPrompt(web_contents));
142 scoped_ptr<VirtualKeyboardDelegate>
143 ChromeExtensionsAPIClient::CreateVirtualKeyboardDelegate() const {
144 #if defined(OS_CHROMEOS)
145 return make_scoped_ptr(new ChromeVirtualKeyboardDelegate());
146 #else
147 return nullptr;
148 #endif
151 ManagementAPIDelegate* ChromeExtensionsAPIClient::CreateManagementAPIDelegate()
152 const {
153 return new ChromeManagementAPIDelegate;
156 } // namespace extensions