summaryrefslogtreecommitdiffstats
path: root/src/core/chromium_overrides.cpp
blob: 0b79f2dd47298f76d591f408e961eb98b896e3d1 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "type_conversion.h"
#include "ozone/gl_context_qt.h"
#include "qtwebenginecoreglobal_p.h"
#include "web_contents_view_qt.h"
#include "web_engine_library_info.h"

#include "base/values.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/font_list.h"
#include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"
#include "gpu/vulkan/buildflags.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"

#include <QGuiApplication>
#include <QFontDatabase>
#include <QLibraryInfo>

#if !QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
#include "chrome/browser/extensions/api/webrtc_logging_private/webrtc_logging_private_api.h"
#endif

#if BUILDFLAG(ENABLE_VULKAN)
#include "compositor/vulkan_implementation_qt.h"

#include "gpu/vulkan/init/vulkan_factory.h"

#if defined(USE_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/surface_factory_ozone.h"
#endif // defined(USE_OZONE)
#endif // defined(ENABLE_VULKAN)

void *GetQtXDisplay()
{
    return GLContextHelper::getXDisplay();
}

namespace content {
class WebContentsView;
class WebContentsViewDelegate;
class RenderViewHostDelegateView;

std::unique_ptr<WebContentsView> CreateWebContentsView(WebContentsImpl *web_contents,
    std::unique_ptr<WebContentsViewDelegate> delegate,
    RenderViewHostDelegateView **render_view_host_delegate_view)
{
    QtWebEngineCore::WebContentsViewQt* rv = new QtWebEngineCore::WebContentsViewQt(web_contents);
    *render_view_host_delegate_view = rv;
    return std::unique_ptr<WebContentsView>(rv);
}

#if defined(Q_OS_DARWIN)
#if defined(QT_MAC_FRAMEWORK_BUILD)
base::FilePath getSandboxPath()
{
    return WebEngineLibraryInfo::getPath(QT_FRAMEWORK_BUNDLE);
}
#else
base::FilePath getSandboxPath()
{
    const QString prefix = QLibraryInfo::location(QLibraryInfo::PrefixPath);
    return QtWebEngineCore::toFilePath(prefix);
}
#endif
#endif
} // namespace content

#if defined(USE_AURA) || defined(USE_OZONE)
namespace content {

// content/common/font_list.h
std::unique_ptr<base::ListValue> GetFontList_SlowBlocking()
{
    std::unique_ptr<base::ListValue> font_list(new base::ListValue);

    for (auto family : QFontDatabase::families()){
        base::Value::List font_item;
        font_item.Append(family.toStdString());
        font_item.Append(family.toStdString());  // localized name.
        // TODO(yusukes): Support localized family names.
        font_list->Append(std::move(font_item));
    }
    return font_list;
}

} // namespace content

namespace aura {
class Window;
}

namespace wm {
class ActivationClient;

ActivationClient *GetActivationClient(aura::Window *)
{
    return nullptr;
}

} // namespace wm
#endif // defined(USE_AURA) || defined(USE_OZONE)

#if BUILDFLAG(ENABLE_VULKAN)
namespace gpu {
std::unique_ptr<VulkanImplementation> CreateVulkanImplementation(bool use_swiftshader,
                                                                 bool allow_protected_memory)
{
#if QT_CONFIG(webengine_vulkan)
#if BUILDFLAG(IS_APPLE)
    // TODO: Investigate if we can support MoltenVK.
    NOTIMPLEMENTED();
    return nullptr;
#else
#if defined(USE_OZONE)
    return ui::OzonePlatform::GetInstance()->GetSurfaceFactoryOzone()->CreateVulkanImplementation(
            use_swiftshader, allow_protected_memory);
#endif

#if !BUILDFLAG(IS_WIN)
    // TODO(samans): Support Swiftshader on more platforms.
    // https://crbug.com/963988
    DCHECK(!use_swiftshader) << "Vulkan Swiftshader is not supported on this platform.";
#endif // !BUILDFLAG(IS_WIN)

    // Protected memory is supported only on Fuchsia, which uses Ozone, i.e.
    // VulkanImplementation is initialized above.
    DCHECK(!allow_protected_memory) << "Protected memory is not supported on this platform.";

    return std::make_unique<VulkanImplementationQt>();
#endif // BUILDFLAG(IS_APPLE)
#else
    NOTREACHED();
    return nullptr;
#endif // QT_CONFIG(webengine_vulkan)
}
} // namespace gpu
#endif // BUILDFLAG(ENABLE_VULKAN)

std::unique_ptr<ui::OSExchangeDataProvider> ui::OSExchangeDataProviderFactory::CreateProvider()
{
    return nullptr;
}

#if !BUILDFLAG(ENABLE_EXTENSIONS)
namespace extensions {
  const char kExtensionScheme[] = "chrome-extension";
}
#endif

#if !QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)
namespace extensions {
ExtensionFunction::ResponseAction WebrtcLoggingPrivateSetMetaDataFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStartFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateSetUploadOnRenderCloseFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStopFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStoreFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateUploadStoredFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateUploadFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateDiscardFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStartRtpDumpFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStopRtpDumpFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStartAudioDebugRecordingsFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStopAudioDebugRecordingsFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateStartEventLoggingFunction::Run()
{
    return RespondNow(NoArguments());
}

ExtensionFunction::ResponseAction WebrtcLoggingPrivateGetLogsDirectoryFunction::Run()
{
    return RespondNow(NoArguments());
}
} // namespace extensions
#endif // !QT_CONFIG(webengine_webrtc) && QT_CONFIG(webengine_extensions)