1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWebEngine module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #include "ozone/gl_context_qt.h"
41 #include "qtwebenginecoreglobal_p.h"
42 #include "web_contents_view_qt.h"
43 
44 #include "base/values.h"
45 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h"
46 #include "content/browser/accessibility/accessibility_tree_formatter_browser.h"
47 #include "content/browser/renderer_host/render_widget_host_view_base.h"
48 #include "content/browser/web_contents/web_contents_impl.h"
49 #include "content/common/font_list.h"
50 #include "ui/base/dragdrop/os_exchange_data.h"
51 #include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
52 #include "ui/events/devices/device_data_manager.h"
53 #include "ui/events/platform/platform_event_source.h"
54 #include "ui/snapshot/snapshot.h"
55 #include "ppapi/buildflags/buildflags.h"
56 
57 #include <QGuiApplication>
58 #include <QScreen>
59 #include <QWindow>
60 #include <QFontDatabase>
61 #include <QStringList>
62 #include <QLibraryInfo>
63 
64 #if defined(USE_AURA) && !defined(USE_OZONE)
65 #include "ui/base/dragdrop/os_exchange_data.h"
66 #include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
67 #include "ui/gfx/render_text.h"
68 #include "ui/gfx/platform_font.h"
69 #endif
70 
71 #if defined(USE_OPENSSL_CERTS)
72 #include "net/ssl/openssl_client_key_store.h"
73 #endif
74 
GetQtXDisplay()75 void *GetQtXDisplay()
76 {
77     return GLContextHelper::getXDisplay();
78 }
79 
80 namespace content {
81 class WebContentsImpl;
82 class WebContentsView;
83 class WebContentsViewDelegate;
84 class RenderViewHostDelegateView;
85 
CreateWebContentsView(WebContentsImpl * web_contents,WebContentsViewDelegate *,RenderViewHostDelegateView ** render_view_host_delegate_view)86 WebContentsView* CreateWebContentsView(WebContentsImpl *web_contents,
87     WebContentsViewDelegate *,
88     RenderViewHostDelegateView **render_view_host_delegate_view)
89 {
90     QtWebEngineCore::WebContentsViewQt* rv = new QtWebEngineCore::WebContentsViewQt(web_contents);
91     *render_view_host_delegate_view = rv;
92     return rv;
93 }
94 
95 #if defined(Q_OS_MACOS)
getQtPrefix()96 std::string getQtPrefix()
97 {
98     const QString prefix = QLibraryInfo::location(QLibraryInfo::PrefixPath);
99     return prefix.toStdString();
100 }
101 #endif
102 
103 } // namespace content
104 
105 #if defined(USE_AURA) || defined(USE_OZONE)
106 namespace content {
107 
108 // content/common/font_list.h
GetFontList_SlowBlocking()109 std::unique_ptr<base::ListValue> GetFontList_SlowBlocking()
110 {
111     std::unique_ptr<base::ListValue> font_list(new base::ListValue);
112 
113     QFontDatabase database;
114     for (auto family : database.families()){
115         std::unique_ptr<base::ListValue> font_item(new base::ListValue());
116         font_item->AppendString(family.toStdString());
117         font_item->AppendString(family.toStdString());  // localized name.
118         // TODO(yusukes): Support localized family names.
119         font_list->Append(std::move(font_item));
120     }
121     return font_list;
122 }
123 
124 } // namespace content
125 
126 namespace aura {
127 class Window;
128 }
129 
130 namespace wm {
131 class ActivationClient;
132 
GetActivationClient(aura::Window *)133 ActivationClient *GetActivationClient(aura::Window *)
134 {
135     return nullptr;
136 }
137 
138 } // namespace wm
139 #endif // defined(USE_AURA) || defined(USE_OZONE)
140 
141 namespace content {
GetTestPasses()142 std::vector<AccessibilityTreeFormatter::TestPass> AccessibilityTreeFormatter::GetTestPasses()
143 {
144     return {
145         {"blink", &AccessibilityTreeFormatterBlink::CreateBlink, nullptr},
146         {"native", &AccessibilityTreeFormatter::Create, nullptr},
147     };
148 }
149 } // namespace content
150 
151 #if defined(USE_AURA)
152 namespace ui {
153 
GrabWindowSnapshot(gfx::NativeWindow window,const gfx::Rect & snapshot_bounds,gfx::Image * image)154 bool GrabWindowSnapshot(gfx::NativeWindow window,
155                         const gfx::Rect& snapshot_bounds,
156                         gfx::Image* image)
157 {
158     NOTIMPLEMENTED();
159     return false;
160 }
161 
GrabViewSnapshot(gfx::NativeView view,const gfx::Rect & snapshot_bounds,gfx::Image * image)162 bool GrabViewSnapshot(gfx::NativeView view,
163                       const gfx::Rect& snapshot_bounds,
164                       gfx::Image* image)
165 {
166     NOTIMPLEMENTED();
167     return false;
168 }
169 
GrabWindowSnapshotAndScaleAsync(gfx::NativeWindow window,const gfx::Rect & source_rect,const gfx::Size & target_size,GrabWindowSnapshotAsyncCallback callback)170 void GrabWindowSnapshotAndScaleAsync(gfx::NativeWindow window,
171                                      const gfx::Rect& source_rect,
172                                      const gfx::Size& target_size,
173                                      GrabWindowSnapshotAsyncCallback callback)
174 {
175     NOTIMPLEMENTED();
176     std::move(callback).Run(gfx::Image());
177 }
178 
GrabWindowSnapshotAsync(gfx::NativeWindow window,const gfx::Rect & source_rect,GrabWindowSnapshotAsyncCallback callback)179 void GrabWindowSnapshotAsync(gfx::NativeWindow window,
180                              const gfx::Rect& source_rect,
181                              GrabWindowSnapshotAsyncCallback callback)
182 {
183     NOTIMPLEMENTED();
184     std::move(callback).Run(gfx::Image());
185 }
186 
GrabViewSnapshotAsync(gfx::NativeView view,const gfx::Rect & source_rect,GrabWindowSnapshotAsyncCallback callback)187 void GrabViewSnapshotAsync(gfx::NativeView view,
188                            const gfx::Rect& source_rect,
189                            GrabWindowSnapshotAsyncCallback callback)
190 {
191     NOTIMPLEMENTED();
192     std::move(callback).Run(gfx::Image());
193 }
194 
195 } // namespace ui
196 #endif // defined(USE_AURA)
197 
198 std::unique_ptr<ui::OSExchangeData::Provider>
CreateProvider()199 ui::OSExchangeDataProviderFactory::CreateProvider() {
200     return nullptr;
201 }
202