blob: ab655ed9b3eb4b57c58cee887957e9dd713a4be6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/chrome_extensions_api_client.h"
#include "base/files/file_path.h"
#include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h"
#include "chrome/browser/extensions/api/declarative_content/chrome_content_rules_registry.h"
#include "chrome/browser/extensions/api/management/chrome_management_api_delegate.h"
#include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
#include "chrome/browser/extensions/api/web_request/chrome_extension_web_request_event_router_delegate.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/favicon/favicon_utils.h"
#include "chrome/browser/guest_view/app_view/chrome_app_view_guest_delegate.h"
#include "chrome/browser/guest_view/chrome_guest_view_manager_delegate.h"
#include "chrome/browser/guest_view/extension_options/chrome_extension_options_guest_delegate.h"
#include "chrome/browser/guest_view/mime_handler_view/chrome_mime_handler_view_guest_delegate.h"
#include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h"
#include "chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.h"
#include "chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.h"
#include "components/pdf/browser/pdf_web_contents_helper.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/virtual_keyboard_private/virtual_keyboard_delegate.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
#if defined(ENABLE_CONFIGURATION_POLICY)
#include "chrome/browser/extensions/api/storage/managed_value_store_cache.h"
#endif
#if defined(OS_CHROMEOS)
#include "chrome/browser/extensions/api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.h"
#endif
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager.h"
#else
#include "chrome/browser/printing/print_view_manager_basic.h"
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
namespace extensions {
ChromeExtensionsAPIClient::ChromeExtensionsAPIClient() {}
ChromeExtensionsAPIClient::~ChromeExtensionsAPIClient() {}
void ChromeExtensionsAPIClient::AddAdditionalValueStoreCaches(
content::BrowserContext* context,
const scoped_refptr<SettingsStorageFactory>& factory,
const scoped_refptr<base::ObserverListThreadSafe<SettingsObserver>>&
observers,
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches) {
// Add support for chrome.storage.sync.
(*caches)[settings_namespace::SYNC] =
new SyncValueStoreCache(factory, observers, context->GetPath());
#if defined(ENABLE_CONFIGURATION_POLICY)
// Add support for chrome.storage.managed.
(*caches)[settings_namespace::MANAGED] =
new ManagedValueStoreCache(context, factory, observers);
#endif
}
void ChromeExtensionsAPIClient::AttachWebContentsHelpers(
content::WebContents* web_contents) const {
favicon::CreateContentFaviconDriverForWebContents(web_contents);
#if defined(ENABLE_PRINTING)
#if defined(ENABLE_PRINT_PREVIEW)
printing::PrintViewManager::CreateForWebContents(web_contents);
printing::PrintPreviewMessageHandler::CreateForWebContents(web_contents);
#else
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
#endif // defined(ENABLE_PRINT_PREVIEW)
#endif // defined(ENABLE_PRINTING)
pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
web_contents,
scoped_ptr<pdf::PDFWebContentsHelperClient>(
new ChromePDFWebContentsHelperClient()));
extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
web_contents);
}
AppViewGuestDelegate* ChromeExtensionsAPIClient::CreateAppViewGuestDelegate()
const {
return new ChromeAppViewGuestDelegate();
}
ExtensionOptionsGuestDelegate*
ChromeExtensionsAPIClient::CreateExtensionOptionsGuestDelegate(
ExtensionOptionsGuest* guest) const {
return new ChromeExtensionOptionsGuestDelegate(guest);
}
scoped_ptr<guest_view::GuestViewManagerDelegate>
ChromeExtensionsAPIClient::CreateGuestViewManagerDelegate(
content::BrowserContext* context) const {
return make_scoped_ptr(new ChromeGuestViewManagerDelegate(context));
}
scoped_ptr<MimeHandlerViewGuestDelegate>
ChromeExtensionsAPIClient::CreateMimeHandlerViewGuestDelegate(
MimeHandlerViewGuest* guest) const {
return make_scoped_ptr(new ChromeMimeHandlerViewGuestDelegate());
}
WebViewGuestDelegate* ChromeExtensionsAPIClient::CreateWebViewGuestDelegate(
WebViewGuest* web_view_guest) const {
return new ChromeWebViewGuestDelegate(web_view_guest);
}
WebViewPermissionHelperDelegate* ChromeExtensionsAPIClient::
CreateWebViewPermissionHelperDelegate(
WebViewPermissionHelper* web_view_permission_helper) const {
return new ChromeWebViewPermissionHelperDelegate(web_view_permission_helper);
}
WebRequestEventRouterDelegate*
ChromeExtensionsAPIClient::CreateWebRequestEventRouterDelegate() const {
return new ChromeExtensionWebRequestEventRouterDelegate();
}
scoped_refptr<ContentRulesRegistry>
ChromeExtensionsAPIClient::CreateContentRulesRegistry(
content::BrowserContext* browser_context,
RulesCacheDelegate* cache_delegate) const {
return scoped_refptr<ContentRulesRegistry>(
new ChromeContentRulesRegistry(browser_context, cache_delegate));
}
scoped_ptr<DevicePermissionsPrompt>
ChromeExtensionsAPIClient::CreateDevicePermissionsPrompt(
content::WebContents* web_contents) const {
return make_scoped_ptr(new ChromeDevicePermissionsPrompt(web_contents));
}
scoped_ptr<VirtualKeyboardDelegate>
ChromeExtensionsAPIClient::CreateVirtualKeyboardDelegate() const {
#if defined(OS_CHROMEOS)
return make_scoped_ptr(new ChromeVirtualKeyboardDelegate());
#else
return nullptr;
#endif
}
ManagementAPIDelegate* ChromeExtensionsAPIClient::CreateManagementAPIDelegate()
const {
return new ChromeManagementAPIDelegate;
}
} // namespace extensions
|