summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.qmake.conf2
-rw-r--r--examples/examples.pro2
-rw-r--r--examples/webengine/quicknanobrowser/ApplicationRoot.qml2
-rw-r--r--examples/webengine/quicknanobrowser/BrowserDialog.qml2
-rw-r--r--examples/webengine/quicknanobrowser/BrowserWindow.qml59
-rw-r--r--examples/webengine/quicknanobrowser/DownloadView.qml2
-rw-r--r--examples/webenginewidgets/browser/browser.rc1
-rw-r--r--examples/webenginewidgets/browser/networkaccessmanager.cpp160
-rw-r--r--examples/webenginewidgets/browser/networkaccessmanager.h75
-rw-r--r--examples/webenginewidgets/demobrowser/Info_mac.plist (renamed from examples/webenginewidgets/browser/Info_mac.plist)0
-rw-r--r--examples/webenginewidgets/demobrowser/addbookmarkdialog.ui (renamed from examples/webenginewidgets/browser/addbookmarkdialog.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/autosaver.cpp (renamed from examples/webenginewidgets/browser/autosaver.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/autosaver.h (renamed from examples/webenginewidgets/browser/autosaver.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/bookmarks.cpp (renamed from examples/webenginewidgets/browser/bookmarks.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/bookmarks.h (renamed from examples/webenginewidgets/browser/bookmarks.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/bookmarks.ui (renamed from examples/webenginewidgets/browser/bookmarks.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/browserapplication.cpp (renamed from examples/webenginewidgets/browser/browserapplication.cpp)40
-rw-r--r--examples/webenginewidgets/demobrowser/browserapplication.h (renamed from examples/webenginewidgets/browser/browserapplication.h)2
-rw-r--r--examples/webenginewidgets/demobrowser/browsermainwindow.cpp (renamed from examples/webenginewidgets/browser/browsermainwindow.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/browsermainwindow.h (renamed from examples/webenginewidgets/browser/browsermainwindow.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/chasewidget.cpp (renamed from examples/webenginewidgets/browser/chasewidget.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/chasewidget.h (renamed from examples/webenginewidgets/browser/chasewidget.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/cookiejar.cpp (renamed from examples/webenginewidgets/browser/cookiejar.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/cookiejar.h (renamed from examples/webenginewidgets/browser/cookiejar.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/cookies.ui (renamed from examples/webenginewidgets/browser/cookies.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/cookiesexceptions.ui (renamed from examples/webenginewidgets/browser/cookiesexceptions.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/data/addtab.png (renamed from examples/webenginewidgets/browser/data/addtab.png)bin469 -> 469 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/data/closetab.png (renamed from examples/webenginewidgets/browser/data/closetab.png)bin516 -> 516 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/data/data.qrc (renamed from examples/webenginewidgets/browser/data/data.qrc)2
-rw-r--r--examples/webenginewidgets/demobrowser/data/defaultbookmarks.xbel (renamed from examples/webenginewidgets/browser/data/defaultbookmarks.xbel)0
-rw-r--r--examples/webenginewidgets/demobrowser/data/defaulticon.png (renamed from examples/webenginewidgets/browser/data/defaulticon.png)bin1473 -> 1473 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/data/demobrowser.svg (renamed from examples/webenginewidgets/browser/data/browser.svg)3
-rw-r--r--examples/webenginewidgets/demobrowser/data/history.png (renamed from examples/webenginewidgets/browser/data/history.png)bin1527 -> 1527 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/data/loading.gif (renamed from examples/webenginewidgets/browser/data/loading.gif)bin847 -> 847 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/demobrowser.icns (renamed from examples/webenginewidgets/browser/browser.icns)bin50218 -> 50218 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/demobrowser.ico (renamed from examples/webenginewidgets/browser/browser.ico)bin15374 -> 15374 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/demobrowser.pro (renamed from examples/webenginewidgets/browser/browser.pro)15
-rw-r--r--examples/webenginewidgets/demobrowser/demobrowser.rc1
-rw-r--r--examples/webenginewidgets/demobrowser/doc/images/browser-demo.png (renamed from examples/webenginewidgets/browser/doc/images/browser-demo.png)bin156342 -> 156342 bytes
-rw-r--r--examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc (renamed from examples/webenginewidgets/browser/doc/src/browser.qdoc)6
-rw-r--r--examples/webenginewidgets/demobrowser/downloaditem.ui (renamed from examples/webenginewidgets/browser/downloaditem.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/downloadmanager.cpp (renamed from examples/webenginewidgets/browser/downloadmanager.cpp)1
-rw-r--r--examples/webenginewidgets/demobrowser/downloadmanager.h (renamed from examples/webenginewidgets/browser/downloadmanager.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/downloads.ui (renamed from examples/webenginewidgets/browser/downloads.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/edittableview.cpp (renamed from examples/webenginewidgets/browser/edittableview.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/edittableview.h (renamed from examples/webenginewidgets/browser/edittableview.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/edittreeview.cpp (renamed from examples/webenginewidgets/browser/edittreeview.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/edittreeview.h (renamed from examples/webenginewidgets/browser/edittreeview.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/featurepermissionbar.cpp (renamed from examples/webenginewidgets/browser/featurepermissionbar.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/featurepermissionbar.h (renamed from examples/webenginewidgets/browser/featurepermissionbar.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/history.cpp (renamed from examples/webenginewidgets/browser/history.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/history.h (renamed from examples/webenginewidgets/browser/history.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/history.ui (renamed from examples/webenginewidgets/browser/history.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/htmls/htmls.qrc (renamed from examples/webenginewidgets/browser/htmls/htmls.qrc)0
-rw-r--r--examples/webenginewidgets/demobrowser/htmls/notfound.html (renamed from examples/webenginewidgets/browser/htmls/notfound.html)0
-rw-r--r--examples/webenginewidgets/demobrowser/main.cpp (renamed from examples/webenginewidgets/browser/main.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/modelmenu.cpp (renamed from examples/webenginewidgets/browser/modelmenu.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/modelmenu.h (renamed from examples/webenginewidgets/browser/modelmenu.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/passworddialog.ui (renamed from examples/webenginewidgets/browser/passworddialog.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/proxy.ui (renamed from examples/webenginewidgets/browser/proxy.ui)0
-rw-r--r--examples/webenginewidgets/demobrowser/searchlineedit.cpp (renamed from examples/webenginewidgets/browser/searchlineedit.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/searchlineedit.h (renamed from examples/webenginewidgets/browser/searchlineedit.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/settings.cpp (renamed from examples/webenginewidgets/browser/settings.cpp)33
-rw-r--r--examples/webenginewidgets/demobrowser/settings.h (renamed from examples/webenginewidgets/browser/settings.h)3
-rw-r--r--examples/webenginewidgets/demobrowser/settings.ui (renamed from examples/webenginewidgets/browser/settings.ui)27
-rw-r--r--examples/webenginewidgets/demobrowser/squeezelabel.cpp (renamed from examples/webenginewidgets/browser/squeezelabel.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/squeezelabel.h (renamed from examples/webenginewidgets/browser/squeezelabel.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.cpp (renamed from examples/webenginewidgets/browser/tabwidget.cpp)30
-rw-r--r--examples/webenginewidgets/demobrowser/tabwidget.h (renamed from examples/webenginewidgets/browser/tabwidget.h)4
-rw-r--r--examples/webenginewidgets/demobrowser/toolbarsearch.cpp (renamed from examples/webenginewidgets/browser/toolbarsearch.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/toolbarsearch.h (renamed from examples/webenginewidgets/browser/toolbarsearch.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/urllineedit.cpp (renamed from examples/webenginewidgets/browser/urllineedit.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/urllineedit.h (renamed from examples/webenginewidgets/browser/urllineedit.h)0
-rw-r--r--examples/webenginewidgets/demobrowser/webview.cpp (renamed from examples/webenginewidgets/browser/webview.cpp)60
-rw-r--r--examples/webenginewidgets/demobrowser/webview.h (renamed from examples/webenginewidgets/browser/webview.h)2
-rw-r--r--examples/webenginewidgets/demobrowser/xbel.cpp (renamed from examples/webenginewidgets/browser/xbel.cpp)0
-rw-r--r--examples/webenginewidgets/demobrowser/xbel.h (renamed from examples/webenginewidgets/browser/xbel.h)0
m---------src/3rdparty0
-rw-r--r--src/core/api/core_api.pro49
-rw-r--r--src/core/api/qtwebenginecoreglobal.h50
-rw-r--r--src/core/api/qtwebenginecoreglobal_p.h (renamed from src/core/qtwebenginecoreglobal.h)31
-rw-r--r--src/core/api/qwebenginecallback.h92
-rw-r--r--src/core/api/qwebenginecallback_p.h226
-rw-r--r--src/core/api/qwebenginecookiestoreclient.cpp372
-rw-r--r--src/core/api/qwebenginecookiestoreclient.h94
-rw-r--r--src/core/api/qwebenginecookiestoreclient_p.h103
-rw-r--r--src/core/api/qwebengineurlrequestinfo.cpp265
-rw-r--r--src/core/api/qwebengineurlrequestinfo.h107
-rw-r--r--src/core/api/qwebengineurlrequestinfo_p.h76
-rw-r--r--src/core/api/qwebengineurlrequestinterceptor.h68
-rw-r--r--src/core/api/qwebengineurlrequestjob.cpp (renamed from src/webenginewidgets/api/qwebengineurlrequestjob.cpp)33
-rw-r--r--src/core/api/qwebengineurlrequestjob.h (renamed from src/webenginewidgets/api/qwebengineurlrequestjob_p.h)19
-rw-r--r--src/core/api/qwebengineurlschemehandler.cpp (renamed from src/webenginewidgets/api/qwebengineurlschemehandler.cpp)32
-rw-r--r--src/core/api/qwebengineurlschemehandler.h (renamed from src/webenginewidgets/api/qwebengineurlschemehandler_p.h)33
-rw-r--r--src/core/api/qwebengineurlschemehandler_p.h (renamed from src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h)9
-rw-r--r--src/core/authentication_dialog_controller.cpp96
-rw-r--r--src/core/authentication_dialog_controller.h71
-rw-r--r--src/core/authentication_dialog_controller_p.h56
-rw-r--r--src/core/browser_accessibility_qt.cpp80
-rw-r--r--src/core/browser_accessibility_qt.h12
-rw-r--r--src/core/browser_context_adapter.cpp56
-rw-r--r--src/core/browser_context_adapter.h27
-rw-r--r--src/core/browser_context_qt.cpp17
-rw-r--r--src/core/browser_context_qt.h7
-rw-r--r--src/core/chrome_qt.gyp2
-rw-r--r--src/core/chromium_gpu_helper.cpp8
-rw-r--r--src/core/chromium_gpu_helper.h9
-rw-r--r--src/core/chromium_overrides.cpp53
-rw-r--r--src/core/clipboard_qt.cpp4
-rw-r--r--src/core/clipboard_qt.h2
-rw-r--r--src/core/common/qt_messages.h3
-rw-r--r--src/core/config/desktop_linux.pri22
-rw-r--r--src/core/config/embedded_linux.pri21
-rw-r--r--src/core/config/mac_osx.pri3
-rw-r--r--src/core/config/windows.pri14
-rw-r--r--src/core/content_browser_client_qt.cpp63
-rw-r--r--src/core/content_browser_client_qt.h27
-rw-r--r--src/core/content_client_qt.cpp108
-rw-r--r--src/core/content_client_qt.h4
-rw-r--r--src/core/content_main_delegate_qt.cpp2
-rw-r--r--src/core/cookie_monster_delegate_qt.cpp176
-rw-r--r--src/core/cookie_monster_delegate_qt.h89
-rw-r--r--src/core/core.pro13
-rw-r--r--src/core/core_common.pri2
-rw-r--r--src/core/core_gyp_generator.pro41
-rw-r--r--src/core/core_module.pro49
-rw-r--r--src/core/custom_url_scheme_handler.cpp4
-rw-r--r--src/core/custom_url_scheme_handler.h2
-rw-r--r--src/core/delegated_frame_node.cpp50
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.cpp123
-rw-r--r--src/core/dev_tools_http_handler_delegate_qt.h38
-rw-r--r--src/core/doc/snippets/qtwebenginecore_build_snippet.qdoc8
-rw-r--r--src/core/doc/src/qtwebenginecore-index.qdoc104
-rw-r--r--src/core/doc/src/qtwebenginecore-module.qdoc44
-rw-r--r--src/core/file_picker_controller.cpp129
-rw-r--r--src/core/file_picker_controller.h81
-rw-r--r--src/core/gl_surface_qt.cpp17
-rw-r--r--src/core/gl_surface_qt.h4
-rw-r--r--src/core/gyp_run.pro2
-rw-r--r--src/core/javascript_dialog_manager_qt.h3
-rw-r--r--src/core/media_capture_devices_dispatcher.cpp11
-rw-r--r--src/core/network_delegate_qt.cpp155
-rw-r--r--src/core/network_delegate_qt.h35
-rw-r--r--src/core/ozone_platform_eglfs.cpp18
-rw-r--r--src/core/ozone_platform_eglfs.h5
-rw-r--r--src/core/permission_manager_qt.cpp211
-rw-r--r--src/core/permission_manager_qt.h119
-rw-r--r--src/core/proxy_config_service_qt.cpp173
-rw-r--r--src/core/proxy_config_service_qt.h87
-rw-r--r--src/core/qtwebengine.gypi6
-rw-r--r--src/core/qtwebengine_extras.gypi2
-rw-r--r--src/core/render_widget_host_view_qt.cpp65
-rw-r--r--src/core/render_widget_host_view_qt.h7
-rw-r--r--src/core/render_widget_host_view_qt_delegate.h1
-rw-r--r--src/core/renderer/content_renderer_client_qt.cpp8
-rw-r--r--src/core/renderer/content_renderer_client_qt.h2
-rw-r--r--src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp134
-rw-r--r--src/core/renderer/pepper/pepper_flash_browser_host_qt.h91
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp349
-rw-r--r--src/core/renderer/pepper/pepper_flash_renderer_host_qt.h105
-rw-r--r--src/core/renderer/pepper/pepper_host_factory_qt.cpp82
-rw-r--r--src/core/renderer/pepper/pepper_host_factory_qt.h70
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp79
-rw-r--r--src/core/renderer/pepper/pepper_renderer_host_factory_qt.h73
-rw-r--r--src/core/renderer/qt_render_frame_observer.cpp65
-rw-r--r--src/core/renderer/qt_render_frame_observer.h66
-rw-r--r--src/core/renderer/qt_render_view_observer.cpp6
-rw-r--r--src/core/renderer/qt_render_view_observer.h1
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.cpp53
-rw-r--r--src/core/resource_dispatcher_host_delegate_qt.h17
-rw-r--r--src/core/resources/resources.gyp4
-rw-r--r--src/core/type_conversion.h26
-rw-r--r--src/core/url_request_context_getter_qt.cpp85
-rw-r--r--src/core/url_request_context_getter_qt.h8
-rw-r--r--src/core/url_request_custom_job_delegate.cpp5
-rw-r--r--src/core/url_request_custom_job_delegate.h1
-rw-r--r--src/core/user_script_controller_host.cpp19
-rw-r--r--src/core/web_contents_adapter.cpp109
-rw-r--r--src/core/web_contents_adapter.h19
-rw-r--r--src/core/web_contents_adapter_client.h62
-rw-r--r--src/core/web_contents_delegate_qt.cpp62
-rw-r--r--src/core/web_contents_delegate_qt.h20
-rw-r--r--src/core/web_contents_view_qt.cpp41
-rw-r--r--src/core/web_contents_view_qt.h5
-rw-r--r--src/core/web_engine_context.cpp42
-rw-r--r--src/core/web_engine_context.h5
-rw-r--r--src/core/web_engine_library_info.cpp4
-rw-r--r--src/core/web_engine_settings.cpp4
-rw-r--r--src/core/web_engine_settings.h2
-rw-r--r--src/core/yuv_video_node.cpp175
-rw-r--r--src/core/yuv_video_node.h24
-rw-r--r--src/process/process.pro18
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest.cpp7
-rw-r--r--src/webengine/api/qquickwebenginenewviewrequest_p.h2
-rw-r--r--src/webengine/api/qquickwebengineprofile.cpp32
-rw-r--r--src/webengine/api/qquickwebengineprofile_p.h8
-rw-r--r--src/webengine/api/qquickwebenginesettings.cpp41
-rw-r--r--src/webengine/api/qquickwebenginesettings_p.h8
-rw-r--r--src/webengine/api/qquickwebenginetestsupport_p.h3
-rw-r--r--src/webengine/api/qquickwebengineview.cpp326
-rw-r--r--src/webengine/api/qquickwebengineview_p.h55
-rw-r--r--src/webengine/api/qquickwebengineview_p_p.h8
-rw-r--r--src/webengine/doc/images/qtwebengine-architecture.pngbin0 -> 11325 bytes
-rw-r--r--src/webengine/doc/qtwebengine.qdocconf40
-rw-r--r--src/webengine/doc/src/qtwebengine-examples.qdoc (renamed from src/webengine/doc/src/qtwebengine.qdoc)19
-rw-r--r--src/webengine/doc/src/qtwebengine-index.qdoc89
-rw-r--r--src/webengine/doc/src/qtwebengine-overview.qdoc171
-rw-r--r--src/webengine/doc/src/qtwebengine-qmlmodule.qdoc39
-rw-r--r--src/webengine/doc/src/webengineview.qdoc (renamed from src/webengine/doc/src/qquickwebengineview_lgpl.qdoc)48
-rw-r--r--src/webengine/plugin/experimental/experimental.pro2
-rw-r--r--src/webengine/plugin/experimental/plugin.cpp6
-rw-r--r--src/webengine/plugin/plugin.cpp24
-rw-r--r--src/webengine/plugin/plugin.pro4
-rw-r--r--src/webengine/plugin/testsupport/plugin.cpp2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.cpp23
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quick.h2
-rw-r--r--src/webengine/render_widget_host_view_qt_delegate_quickwindow.h1
-rw-r--r--src/webengine/ui_delegates_manager.cpp93
-rw-r--r--src/webengine/ui_delegates_manager.h27
-rw-r--r--src/webengine/webengine.pro6
-rw-r--r--src/webenginewidgets/api/qwebenginecertificateerror.h6
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h4
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp459
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h60
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h59
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp192
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.h27
-rw-r--r--src/webenginewidgets/api/qwebengineprofile_p.h7
-rw-r--r--src/webenginewidgets/api/qwebenginescript.cpp91
-rw-r--r--src/webenginewidgets/api/qwebenginescript.h7
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.cpp59
-rw-r--r--src/webenginewidgets/api/qwebenginescriptcollection.h10
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.cpp4
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.h4
-rw-r--r--src/webenginewidgets/api/qwebengineview.h1
-rw-r--r--src/webenginewidgets/doc/qtwebenginewidgets.qdocconf6
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc38
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc (renamed from src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc)84
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc43
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc20
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc2
-rw-r--r--src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc14
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp16
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h2
-rw-r--r--src/webenginewidgets/webenginewidgets.pro11
-rw-r--r--sync.profile2
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/core/core.pro7
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro1
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/resources/content.html5
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/resources/index.html38
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp212
-rw-r--r--tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.qrc6
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro1
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html5
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/resources/index.html16
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp155
-rw-r--r--tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc6
-rw-r--r--tests/auto/core/tests.pri17
-rw-r--r--tests/auto/quick/inspectorserver/tst_inspectorserver.cpp2
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml2
-rw-r--r--tests/auto/quick/qmltests/data/directoryupload.html16
-rw-r--r--tests/auto/quick/qmltests/data/forms.html40
-rw-r--r--tests/auto/quick/qmltests/data/multifileupload.html17
-rw-r--r--tests/auto/quick/qmltests/data/singlefileupload.html17
-rw-r--r--tests/auto/quick/qmltests/data/titleupdate.js55
-rw-r--r--tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml82
-rw-r--r--tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_favIconLoad.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml129
-rw-r--r--tests/auto/quick/qmltests/data/tst_findText.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_formValidation.qml124
-rw-r--r--tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_linkHovered.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadFail.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadHtml.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadProgress.qml23
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadProgressSignal.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_loadUrl.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationHistory.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_navigationRequested.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_properties.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_runJavaScript.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_titleChanged.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_userScripts.qml2
-rw-r--r--tests/auto/quick/qmltests/data/tst_webchannel.qml2
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml60
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/qmldir1
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml49
-rw-r--r--tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir1
-rw-r--r--tests/auto/quick/qmltests/qmltests.pro10
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp34
-rw-r--r--tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp2
-rw-r--r--tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro1
-rw-r--r--tests/auto/widgets/qwebengineframe/qwebengineframe.pro1
-rw-r--r--tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro1
-rw-r--r--tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro1
-rw-r--r--tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro1
-rw-r--r--tests/auto/widgets/qwebenginepage/qwebenginepage.pro1
-rw-r--r--tests/auto/widgets/qwebenginepage/resources/fullscreen.html10
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp174
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc3
-rw-r--r--tests/auto/widgets/qwebenginescript/qwebenginescript.pro1
-rw-r--r--tests/auto/widgets/qwebengineview/qwebengineview.pro1
-rw-r--r--tests/auto/widgets/tests.pri2
-rw-r--r--tests/auto/widgets/util.h5
-rw-r--r--tests/auto/widgets/widgets.pro1
-rw-r--r--tests/quicktestbrowser/ApplicationRoot.qml2
-rw-r--r--tests/quicktestbrowser/BrowserWindow.qml18
-rw-r--r--tests/quicktestbrowser/main.cpp40
-rwxr-xr-xtools/buildscripts/gyp_qtwebengine7
-rw-r--r--tools/qmake/config.tests/khr/khr.cpp4
-rw-r--r--tools/qmake/config.tests/snappy/snappy.cpp44
-rw-r--r--tools/qmake/config.tests/snappy/snappy.pro3
-rw-r--r--tools/qmake/config.tests/srtp/srtp.cpp43
-rw-r--r--tools/qmake/config.tests/srtp/srtp.pro3
-rw-r--r--tools/qmake/mkspecs/features/configure.prf64
-rw-r--r--tools/qmake/mkspecs/features/default_post.prf3
-rw-r--r--tools/qmake/mkspecs/features/default_pre.prf4
-rw-r--r--tools/qmake/mkspecs/features/functions.prf2
-rwxr-xr-xtools/scripts/take_snapshot.py57
-rw-r--r--tools/scripts/version_resolver.py7
326 files changed, 8937 insertions, 1831 deletions
diff --git a/.gitignore b/.gitignore
index b66341f8f..67a9d4d04 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@ src/3rdparty_upstream/ninja
src/3rdparty_upstream/chromium
src/core/Debug
src/core/Release
+src/core/api/Release
+src/core/api/Debug
src/core/core_generated.gyp
src/core/gypfiles
src/core/qmake_extras.gypi
diff --git a/.qmake.conf b/.qmake.conf
index 513fe9a0e..fe1cde075 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -2,4 +2,4 @@ QMAKEPATH += $$PWD/tools/qmake
load(qt_build_config)
CONFIG += qt_example_installs
-MODULE_VERSION = 5.5.1
+MODULE_VERSION = 5.6.0
diff --git a/examples/examples.pro b/examples/examples.pro
index 3d6872d55..8345fded6 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -6,6 +6,6 @@ qtHaveModule(webengine) {
qtHaveModule(webenginewidgets) {
SUBDIRS += \
- webenginewidgets/browser \
+ webenginewidgets/demobrowser \
webenginewidgets/fancybrowser
}
diff --git a/examples/webengine/quicknanobrowser/ApplicationRoot.qml b/examples/webengine/quicknanobrowser/ApplicationRoot.qml
index b409696be..91d1551a7 100644
--- a/examples/webengine/quicknanobrowser/ApplicationRoot.qml
+++ b/examples/webengine/quicknanobrowser/ApplicationRoot.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.1
-import QtWebEngine 1.1
+import QtWebEngine 1.2
QtObject {
id: root
diff --git a/examples/webengine/quicknanobrowser/BrowserDialog.qml b/examples/webengine/quicknanobrowser/BrowserDialog.qml
index 6202d02f7..0577bf642 100644
--- a/examples/webengine/quicknanobrowser/BrowserDialog.qml
+++ b/examples/webengine/quicknanobrowser/BrowserDialog.qml
@@ -40,7 +40,7 @@
import QtQuick 2.1
import QtQuick.Window 2.2
-import QtWebEngine 1.1
+import QtWebEngine 1.2
Window {
property alias currentWebView: webView
diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml
index c4c0270a4..bdee68d17 100644
--- a/examples/webengine/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml
@@ -38,8 +38,8 @@
**
****************************************************************************/
-import QtQuick 2.1
-import QtWebEngine 1.1
+import QtQuick 2.2
+import QtWebEngine 1.2
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
import QtQuick.Layouts 1.0
@@ -82,6 +82,7 @@ ApplicationWindow {
property alias autoLoadImages: loadImages.checked;
property alias javaScriptEnabled: javaScriptEnabled.checked;
property alias errorPageEnabled: errorPageEnabled.checked;
+ property alias pluginsEnabled: pluginsEnabled.checked;
}
Action {
@@ -99,14 +100,14 @@ ApplicationWindow {
}
}
Action {
- shortcut: "Ctrl+R"
+ shortcut: StandardKey.Refresh
onTriggered: {
if (currentWebView)
currentWebView.reload()
}
}
Action {
- shortcut: "Ctrl+T"
+ shortcut: StandardKey.AddTab
onTriggered: {
tabs.createEmptyTab(currentWebView.profile)
tabs.currentIndex = tabs.count - 1
@@ -115,7 +116,7 @@ ApplicationWindow {
}
}
Action {
- shortcut: "Ctrl+W"
+ shortcut: StandardKey.Close
onTriggered: {
if (tabs.count == 1)
browserWindow.close()
@@ -135,14 +136,51 @@ ApplicationWindow {
onTriggered: currentWebView.zoomFactor = 1.0;
}
Action {
- shortcut: "Ctrl+-"
+ shortcut: StandardKey.ZoomOut
onTriggered: currentWebView.zoomFactor -= 0.1;
}
Action {
- shortcut: "Ctrl+="
+ shortcut: StandardKey.ZoomIn
onTriggered: currentWebView.zoomFactor += 0.1;
}
+ Action {
+ shortcut: StandardKey.Copy
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Copy)
+ }
+ Action {
+ shortcut: StandardKey.Cut
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Cut)
+ }
+ Action {
+ shortcut: StandardKey.Paste
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Paste)
+ }
+ Action {
+ shortcut: "Shift+"+StandardKey.Paste
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.PasteAndMatchStyle)
+ }
+ Action {
+ shortcut: StandardKey.SelectAll
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.SelectAll)
+ }
+ Action {
+ shortcut: StandardKey.Undo
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Undo)
+ }
+ Action {
+ shortcut: StandardKey.Redo
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Redo)
+ }
+ Action {
+ shortcut: StandardKey.Back
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Back)
+ }
+ Action {
+ shortcut: StandardKey.Forward
+ onTriggered: currentWebView.triggerWebAction(WebEngineView.Forward)
+ }
+
toolBar: ToolBar {
id: navigationBar
RowLayout {
@@ -230,6 +268,12 @@ ApplicationWindow {
checked: WebEngine.settings.errorPageEnabled
}
MenuItem {
+ id: pluginsEnabled
+ text: "Plugins On"
+ checkable: true
+ checked: true
+ }
+ MenuItem {
id: offTheRecordEnabled
text: "Off The Record"
checkable: true
@@ -312,6 +356,7 @@ ApplicationWindow {
settings.autoLoadImages: appSettings.autoLoadImages
settings.javascriptEnabled: appSettings.javaScriptEnabled
settings.errorPageEnabled: appSettings.errorPageEnabled
+ settings.pluginsEnabled: appSettings.pluginsEnabled
onCertificateError: {
error.defer()
diff --git a/examples/webengine/quicknanobrowser/DownloadView.qml b/examples/webengine/quicknanobrowser/DownloadView.qml
index 9a5cdd28f..c17a8bd60 100644
--- a/examples/webengine/quicknanobrowser/DownloadView.qml
+++ b/examples/webengine/quicknanobrowser/DownloadView.qml
@@ -41,7 +41,7 @@
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Styles 1.0
-import QtWebEngine 1.0
+import QtWebEngine 1.2
import QtQuick.Layouts 1.0
Rectangle {
diff --git a/examples/webenginewidgets/browser/browser.rc b/examples/webenginewidgets/browser/browser.rc
deleted file mode 100644
index 39e17e973..000000000
--- a/examples/webenginewidgets/browser/browser.rc
+++ /dev/null
@@ -1 +0,0 @@
-IDI_ICON1 ICON DISCARDABLE "browser.ico"
diff --git a/examples/webenginewidgets/browser/networkaccessmanager.cpp b/examples/webenginewidgets/browser/networkaccessmanager.cpp
deleted file mode 100644
index d2b4f827f..000000000
--- a/examples/webenginewidgets/browser/networkaccessmanager.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "networkaccessmanager.h"
-
-#include "browserapplication.h"
-#include "browsermainwindow.h"
-
-#include <QtCore/QSettings>
-
-#include <QtGui/QDesktopServices>
-#include <QtWidgets/QDialog>
-#include <QtWidgets/QMessageBox>
-#include <QtWidgets/QStyle>
-#include <QtGui/QTextDocument>
-
-#include <QtNetwork/QAuthenticator>
-#include <QtNetwork/QNetworkDiskCache>
-#include <QtNetwork/QNetworkProxy>
-#include <QtNetwork/QNetworkRequest>
-#include <QtNetwork/QNetworkReply>
-#include <QtNetwork/QSslError>
-
-NetworkAccessManager::NetworkAccessManager(QObject *parent)
- : QNetworkAccessManager(parent),
- requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0),
- requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0)
-{
- connect(this, SIGNAL(finished(QNetworkReply*)),
- SLOT(requestFinished(QNetworkReply*)));
-#ifndef QT_NO_OPENSSL
- connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)),
- SLOT(sslErrors(QNetworkReply*,QList<QSslError>)));
-#endif
- loadSettings();
-
- QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
- QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- diskCache->setCacheDirectory(location);
- setCache(diskCache);
-}
-
-QNetworkReply* NetworkAccessManager::createRequest(Operation op, const QNetworkRequest & req, QIODevice * outgoingData)
-{
- QNetworkRequest request = req; // copy so we can modify
- // this is a temporary hack until we properly use the pipelining flags from QtWebkit
- // pipeline everything! :)
- request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
- return QNetworkAccessManager::createRequest(op, request, outgoingData);
-}
-
-void NetworkAccessManager::requestFinished(QNetworkReply *reply)
-{
- requestFinishedCount++;
-
- if (reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool() == true)
- requestFinishedFromCacheCount++;
-
- if (reply->attribute(QNetworkRequest::HttpPipeliningWasUsedAttribute).toBool() == true)
- requestFinishedPipelinedCount++;
-
- if (reply->attribute(QNetworkRequest::ConnectionEncryptedAttribute).toBool() == true)
- requestFinishedSecureCount++;
-
- if (reply->attribute(QNetworkRequest::DownloadBufferAttribute).isValid() == true)
- requestFinishedDownloadBufferCount++;
-
- if (requestFinishedCount % 10)
- return;
-
-#ifdef QT_DEBUG
- double pctCached = (double(requestFinishedFromCacheCount) * 100.0/ double(requestFinishedCount));
- double pctPipelined = (double(requestFinishedPipelinedCount) * 100.0/ double(requestFinishedCount));
- double pctSecure = (double(requestFinishedSecureCount) * 100.0/ double(requestFinishedCount));
- double pctDownloadBuffer = (double(requestFinishedDownloadBufferCount) * 100.0/ double(requestFinishedCount));
-
- qDebug("STATS [%lli requests total] [%3.2f%% from cache] [%3.2f%% pipelined] [%3.2f%% SSL/TLS] [%3.2f%% Zerocopy]", requestFinishedCount, pctCached, pctPipelined, pctSecure, pctDownloadBuffer);
-#endif
-}
-
-void NetworkAccessManager::loadSettings()
-{
- QSettings settings;
- settings.beginGroup(QLatin1String("proxy"));
- QNetworkProxy proxy;
- if (settings.value(QLatin1String("enabled"), false).toBool()) {
- if (settings.value(QLatin1String("type"), 0).toInt() == 0)
- proxy = QNetworkProxy::Socks5Proxy;
- else
- proxy = QNetworkProxy::HttpProxy;
- proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
- proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
- proxy.setUser(settings.value(QLatin1String("userName")).toString());
- proxy.setPassword(settings.value(QLatin1String("password")).toString());
- }
- setProxy(proxy);
-}
-
-#ifndef QT_NO_OPENSSL
-void NetworkAccessManager::sslErrors(QNetworkReply *reply, const QList<QSslError> &error)
-{
- // check if SSL certificate has been trusted already
- QString replyHost = reply->url().host() + QString(":%1").arg(reply->url().port());
- if (! sslTrustedHostList.contains(replyHost)) {
- BrowserMainWindow *mainWindow = BrowserApplication::instance()->mainWindow();
-
- QStringList errorStrings;
- for (int i = 0; i < error.count(); ++i)
- errorStrings += error.at(i).errorString();
- QString errors = errorStrings.join(QLatin1String("\n"));
- int ret = QMessageBox::warning(mainWindow, QCoreApplication::applicationName(),
- tr("SSL Errors:\n\n%1\n\n%2\n\n"
- "Do you want to ignore these errors for this host?").arg(reply->url().toString()).arg(errors),
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::No);
- if (ret == QMessageBox::Yes) {
- reply->ignoreSslErrors();
- sslTrustedHostList.append(replyHost);
- }
- }
-}
-#endif
diff --git a/examples/webenginewidgets/browser/networkaccessmanager.h b/examples/webenginewidgets/browser/networkaccessmanager.h
deleted file mode 100644
index f3ee2d338..000000000
--- a/examples/webenginewidgets/browser/networkaccessmanager.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the demonstration applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef NETWORKACCESSMANAGER_H
-#define NETWORKACCESSMANAGER_H
-
-#include <QtNetwork/QNetworkAccessManager>
-#include <QtNetwork/QNetworkRequest>
-
-class NetworkAccessManager : public QNetworkAccessManager
-{
- Q_OBJECT
-
-public:
- NetworkAccessManager(QObject *parent = 0);
-
- virtual QNetworkReply* createRequest ( Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 );
-
-private:
- QList<QString> sslTrustedHostList;
- qint64 requestFinishedCount;
- qint64 requestFinishedFromCacheCount;
- qint64 requestFinishedPipelinedCount;
- qint64 requestFinishedSecureCount;
- qint64 requestFinishedDownloadBufferCount;
-
-public slots:
- void loadSettings();
- void requestFinished(QNetworkReply *reply);
-
-private slots:
-#ifndef QT_NO_OPENSSL
- void sslErrors(QNetworkReply *reply, const QList<QSslError> &error);
-#endif
-};
-
-#endif // NETWORKACCESSMANAGER_H
diff --git a/examples/webenginewidgets/browser/Info_mac.plist b/examples/webenginewidgets/demobrowser/Info_mac.plist
index ccd4b3f28..ccd4b3f28 100644
--- a/examples/webenginewidgets/browser/Info_mac.plist
+++ b/examples/webenginewidgets/demobrowser/Info_mac.plist
diff --git a/examples/webenginewidgets/browser/addbookmarkdialog.ui b/examples/webenginewidgets/demobrowser/addbookmarkdialog.ui
index 3460d7bb8..3460d7bb8 100644
--- a/examples/webenginewidgets/browser/addbookmarkdialog.ui
+++ b/examples/webenginewidgets/demobrowser/addbookmarkdialog.ui
diff --git a/examples/webenginewidgets/browser/autosaver.cpp b/examples/webenginewidgets/demobrowser/autosaver.cpp
index dc72090dd..dc72090dd 100644
--- a/examples/webenginewidgets/browser/autosaver.cpp
+++ b/examples/webenginewidgets/demobrowser/autosaver.cpp
diff --git a/examples/webenginewidgets/browser/autosaver.h b/examples/webenginewidgets/demobrowser/autosaver.h
index b0c73846f..b0c73846f 100644
--- a/examples/webenginewidgets/browser/autosaver.h
+++ b/examples/webenginewidgets/demobrowser/autosaver.h
diff --git a/examples/webenginewidgets/browser/bookmarks.cpp b/examples/webenginewidgets/demobrowser/bookmarks.cpp
index 15078caa3..15078caa3 100644
--- a/examples/webenginewidgets/browser/bookmarks.cpp
+++ b/examples/webenginewidgets/demobrowser/bookmarks.cpp
diff --git a/examples/webenginewidgets/browser/bookmarks.h b/examples/webenginewidgets/demobrowser/bookmarks.h
index 244f003c6..244f003c6 100644
--- a/examples/webenginewidgets/browser/bookmarks.h
+++ b/examples/webenginewidgets/demobrowser/bookmarks.h
diff --git a/examples/webenginewidgets/browser/bookmarks.ui b/examples/webenginewidgets/demobrowser/bookmarks.ui
index c893e941d..c893e941d 100644
--- a/examples/webenginewidgets/browser/bookmarks.ui
+++ b/examples/webenginewidgets/demobrowser/bookmarks.ui
diff --git a/examples/webenginewidgets/browser/browserapplication.cpp b/examples/webenginewidgets/demobrowser/browserapplication.cpp
index ca28b2d0b..84ce35d9d 100644
--- a/examples/webenginewidgets/browser/browserapplication.cpp
+++ b/examples/webenginewidgets/demobrowser/browserapplication.cpp
@@ -46,7 +46,6 @@
#include "cookiejar.h"
#include "downloadmanager.h"
#include "history.h"
-#include "networkaccessmanager.h"
#include "tabwidget.h"
#include "webview.h"
@@ -191,25 +190,24 @@ BrowserApplication::~BrowserApplication()
delete s_bookmarksManager;
}
-#if defined(Q_OS_OSX)
void BrowserApplication::lastWindowClosed()
{
+#if defined(Q_OS_OSX)
clean();
BrowserMainWindow *mw = new BrowserMainWindow;
mw->slotHome();
m_mainWindows.prepend(mw);
-}
#endif
+}
BrowserApplication *BrowserApplication::instance()
{
return (static_cast<BrowserApplication *>(QCoreApplication::instance()));
}
-#if defined(Q_OS_OSX)
-#include <QtWidgets/QMessageBox>
void BrowserApplication::quitBrowser()
{
+#if defined(Q_OS_OSX)
clean();
int tabCount = 0;
for (int i = 0; i < m_mainWindows.count(); ++i) {
@@ -227,8 +225,8 @@ void BrowserApplication::quitBrowser()
}
exit(0);
-}
#endif
+}
/*!
Any actions that can be delayed until the window is visible
@@ -243,7 +241,7 @@ void BrowserApplication::postLaunch()
QWebEngineSettings::setOfflineStoragePath(directory);
#endif
- setWindowIcon(QIcon(QLatin1String(":browser.svg")));
+ setWindowIcon(QIcon(QLatin1String(":demobrowser.svg")));
loadSettings();
@@ -283,14 +281,15 @@ void BrowserApplication::loadSettings()
defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
defaultSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.value(QLatin1String("enableScrollAnimator"), true).toBool());
-#if defined(QTWEBENGINE_PLUGINS)
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());
-#endif
+
+ defaultSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
QString css = settings.value(QLatin1String("userStyleSheet")).toString();
setUserStyleSheet(defaultProfile, css, mainWindow());
defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString());
+ defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString());
settings.endGroup();
settings.beginGroup(QLatin1String("cookies"));
@@ -300,6 +299,21 @@ void BrowserApplication::loadSettings()
defaultProfile->setPersistentStoragePath(pdataPath);
settings.endGroup();
+
+ settings.beginGroup(QLatin1String("proxy"));
+ QNetworkProxy proxy;
+ if (settings.value(QLatin1String("enabled"), false).toBool()) {
+ if (settings.value(QLatin1String("type"), 0).toInt() == 0)
+ proxy = QNetworkProxy::Socks5Proxy;
+ else
+ proxy = QNetworkProxy::HttpProxy;
+ proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
+ proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
+ proxy.setUser(settings.value(QLatin1String("userName")).toString());
+ proxy.setPassword(settings.value(QLatin1String("password")).toString());
+ }
+ QNetworkProxy::setApplicationProxy(proxy);
+ settings.endGroup();
}
QList<BrowserMainWindow*> BrowserApplication::mainWindows()
@@ -475,18 +489,10 @@ DownloadManager *BrowserApplication::downloadManager()
QNetworkAccessManager *BrowserApplication::networkAccessManager()
{
-#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
- if (!s_networkAccessManager) {
- s_networkAccessManager = new NetworkAccessManager();
- s_networkAccessManager->setCookieJar(new CookieJar);
- }
- return s_networkAccessManager;
-#else
if (!s_networkAccessManager) {
s_networkAccessManager = new QNetworkAccessManager();
}
return s_networkAccessManager;
-#endif
}
HistoryManager *BrowserApplication::historyManager()
diff --git a/examples/webenginewidgets/browser/browserapplication.h b/examples/webenginewidgets/demobrowser/browserapplication.h
index 26557b8f9..dd3045bc9 100644
--- a/examples/webenginewidgets/browser/browserapplication.h
+++ b/examples/webenginewidgets/demobrowser/browserapplication.h
@@ -93,10 +93,8 @@ public:
public slots:
BrowserMainWindow *newMainWindow();
void restoreLastSession();
-#if defined(Q_OS_OSX)
void lastWindowClosed();
void quitBrowser();
-#endif
void setPrivateBrowsing(bool);
signals:
diff --git a/examples/webenginewidgets/browser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
index 9595ca7ba..9595ca7ba 100644
--- a/examples/webenginewidgets/browser/browsermainwindow.cpp
+++ b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
diff --git a/examples/webenginewidgets/browser/browsermainwindow.h b/examples/webenginewidgets/demobrowser/browsermainwindow.h
index a2bbc443f..a2bbc443f 100644
--- a/examples/webenginewidgets/browser/browsermainwindow.h
+++ b/examples/webenginewidgets/demobrowser/browsermainwindow.h
diff --git a/examples/webenginewidgets/browser/chasewidget.cpp b/examples/webenginewidgets/demobrowser/chasewidget.cpp
index fb0e9ce76..fb0e9ce76 100644
--- a/examples/webenginewidgets/browser/chasewidget.cpp
+++ b/examples/webenginewidgets/demobrowser/chasewidget.cpp
diff --git a/examples/webenginewidgets/browser/chasewidget.h b/examples/webenginewidgets/demobrowser/chasewidget.h
index a90389034..a90389034 100644
--- a/examples/webenginewidgets/browser/chasewidget.h
+++ b/examples/webenginewidgets/demobrowser/chasewidget.h
diff --git a/examples/webenginewidgets/browser/cookiejar.cpp b/examples/webenginewidgets/demobrowser/cookiejar.cpp
index d9a7465ca..d9a7465ca 100644
--- a/examples/webenginewidgets/browser/cookiejar.cpp
+++ b/examples/webenginewidgets/demobrowser/cookiejar.cpp
diff --git a/examples/webenginewidgets/browser/cookiejar.h b/examples/webenginewidgets/demobrowser/cookiejar.h
index 374156e89..374156e89 100644
--- a/examples/webenginewidgets/browser/cookiejar.h
+++ b/examples/webenginewidgets/demobrowser/cookiejar.h
diff --git a/examples/webenginewidgets/browser/cookies.ui b/examples/webenginewidgets/demobrowser/cookies.ui
index c4bccc548..c4bccc548 100644
--- a/examples/webenginewidgets/browser/cookies.ui
+++ b/examples/webenginewidgets/demobrowser/cookies.ui
diff --git a/examples/webenginewidgets/browser/cookiesexceptions.ui b/examples/webenginewidgets/demobrowser/cookiesexceptions.ui
index 3d9ef6241..3d9ef6241 100644
--- a/examples/webenginewidgets/browser/cookiesexceptions.ui
+++ b/examples/webenginewidgets/demobrowser/cookiesexceptions.ui
diff --git a/examples/webenginewidgets/browser/data/addtab.png b/examples/webenginewidgets/demobrowser/data/addtab.png
index 20928fb40..20928fb40 100644
--- a/examples/webenginewidgets/browser/data/addtab.png
+++ b/examples/webenginewidgets/demobrowser/data/addtab.png
Binary files differ
diff --git a/examples/webenginewidgets/browser/data/closetab.png b/examples/webenginewidgets/demobrowser/data/closetab.png
index ab9d669ee..ab9d669ee 100644
--- a/examples/webenginewidgets/browser/data/closetab.png
+++ b/examples/webenginewidgets/demobrowser/data/closetab.png
Binary files differ
diff --git a/examples/webenginewidgets/browser/data/data.qrc b/examples/webenginewidgets/demobrowser/data/data.qrc
index c7d0294c1..5cb8a97c0 100644
--- a/examples/webenginewidgets/browser/data/data.qrc
+++ b/examples/webenginewidgets/demobrowser/data/data.qrc
@@ -3,7 +3,7 @@
<file>addtab.png</file>
<file>closetab.png</file>
<file>history.png</file>
- <file>browser.svg</file>
+ <file>demobrowser.svg</file>
<file>defaultbookmarks.xbel</file>
<file>loading.gif</file>
<file>defaulticon.png</file>
diff --git a/examples/webenginewidgets/browser/data/defaultbookmarks.xbel b/examples/webenginewidgets/demobrowser/data/defaultbookmarks.xbel
index fef7f5514..fef7f5514 100644
--- a/examples/webenginewidgets/browser/data/defaultbookmarks.xbel
+++ b/examples/webenginewidgets/demobrowser/data/defaultbookmarks.xbel
diff --git a/examples/webenginewidgets/browser/data/defaulticon.png b/examples/webenginewidgets/demobrowser/data/defaulticon.png
index 01a0920c9..01a0920c9 100644
--- a/examples/webenginewidgets/browser/data/defaulticon.png
+++ b/examples/webenginewidgets/demobrowser/data/defaulticon.png
Binary files differ
diff --git a/examples/webenginewidgets/browser/data/browser.svg b/examples/webenginewidgets/demobrowser/data/demobrowser.svg
index 2127a0a6e..f61a54c67 100644
--- a/examples/webenginewidgets/browser/data/browser.svg
+++ b/examples/webenginewidgets/demobrowser/data/demobrowser.svg
@@ -14,11 +14,10 @@
id="svg2160"
sodipodi:version="0.32"
inkscape:version="0.46"
- inkscape:export-filename="c:\icons\qtbrowser48.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
sodipodi:docbase="C:\icons"
- sodipodi:docname="browser.svg"
+ sodipodi:docname="demobrowser.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs2162"><linearGradient
diff --git a/examples/webenginewidgets/browser/data/history.png b/examples/webenginewidgets/demobrowser/data/history.png
index 552a1cbd8..552a1cbd8 100644
--- a/examples/webenginewidgets/browser/data/history.png
+++ b/examples/webenginewidgets/demobrowser/data/history.png
Binary files differ
diff --git a/examples/webenginewidgets/browser/data/loading.gif b/examples/webenginewidgets/demobrowser/data/loading.gif
index c1545eb0e..c1545eb0e 100644
--- a/examples/webenginewidgets/browser/data/loading.gif
+++ b/examples/webenginewidgets/demobrowser/data/loading.gif
Binary files differ
diff --git a/examples/webenginewidgets/browser/browser.icns b/examples/webenginewidgets/demobrowser/demobrowser.icns
index f591ae48a..f591ae48a 100644
--- a/examples/webenginewidgets/browser/browser.icns
+++ b/examples/webenginewidgets/demobrowser/demobrowser.icns
Binary files differ
diff --git a/examples/webenginewidgets/browser/browser.ico b/examples/webenginewidgets/demobrowser/demobrowser.ico
index 7f9be934d..7f9be934d 100644
--- a/examples/webenginewidgets/browser/browser.ico
+++ b/examples/webenginewidgets/demobrowser/demobrowser.ico
Binary files differ
diff --git a/examples/webenginewidgets/browser/browser.pro b/examples/webenginewidgets/demobrowser/demobrowser.pro
index f54186856..310aea59c 100644
--- a/examples/webenginewidgets/browser/browser.pro
+++ b/examples/webenginewidgets/demobrowser/demobrowser.pro
@@ -1,5 +1,5 @@
TEMPLATE = app
-TARGET = browser
+TARGET = demobrowser
QT += webenginewidgets network widgets printsupport
qtHaveModule(uitools):!embedded: QT += uitools
@@ -62,28 +62,23 @@ SOURCES += \
RESOURCES += data/data.qrc htmls/htmls.qrc
-contains(DEFINES, QWEBENGINEPAGE_SETNETWORKACCESSMANAGER) {
- HEADERS += cookiejar.h networkaccessmanager.h
- SOURCES += cookiejar.cpp networkaccessmanager.cpp
-}
-
build_all:!build_pass {
CONFIG -= build_all
CONFIG += release
}
win32 {
- RC_FILE = browser.rc
+ RC_FILE = demobrowser.rc
}
mac {
- ICON = browser.icns
+ ICON = demobrowser.icns
QMAKE_INFO_PLIST = Info_mac.plist
TARGET = Browser
}
-EXAMPLE_FILES = Info_mac.plist browser.icns browser.ico browser.rc
+EXAMPLE_FILES = Info_mac.plist demobrowser.icns demobrowser.ico demobrowser.rc
# install
-target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/browser
+target.path = $$[QT_INSTALL_EXAMPLES]/webenginewidgets/demobrowser
INSTALLS += target
diff --git a/examples/webenginewidgets/demobrowser/demobrowser.rc b/examples/webenginewidgets/demobrowser/demobrowser.rc
new file mode 100644
index 000000000..70cd8bb1c
--- /dev/null
+++ b/examples/webenginewidgets/demobrowser/demobrowser.rc
@@ -0,0 +1 @@
+IDI_ICON1 ICON DISCARDABLE "demobrowser.ico"
diff --git a/examples/webenginewidgets/browser/doc/images/browser-demo.png b/examples/webenginewidgets/demobrowser/doc/images/browser-demo.png
index 09d065095..09d065095 100644
--- a/examples/webenginewidgets/browser/doc/images/browser-demo.png
+++ b/examples/webenginewidgets/demobrowser/doc/images/browser-demo.png
Binary files differ
diff --git a/examples/webenginewidgets/browser/doc/src/browser.qdoc b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc
index 99581d8a9..5e70bd48d 100644
--- a/examples/webenginewidgets/browser/doc/src/browser.qdoc
+++ b/examples/webenginewidgets/demobrowser/doc/src/demobrowser.qdoc
@@ -26,12 +26,12 @@
****************************************************************************/
/*!
- \example browser
- \title WebEngine Tab Browser Example
+ \example demobrowser
+ \title WebEngine Demo Browser Example
\ingroup webengine-widgetexamples
\brief The QtWebKit browser example ported to use QtWebEngine
- The Tab Browser example shows the \l{Qt WebEngine Widgets} module in action,
+ The Demo Browser example shows the \l{Qt WebEngine Widgets} module in action,
providing a little Web browser application with support for tabs.
\image browser-demo.png
diff --git a/examples/webenginewidgets/browser/downloaditem.ui b/examples/webenginewidgets/demobrowser/downloaditem.ui
index b7f7deb72..b7f7deb72 100644
--- a/examples/webenginewidgets/browser/downloaditem.ui
+++ b/examples/webenginewidgets/demobrowser/downloaditem.ui
diff --git a/examples/webenginewidgets/browser/downloadmanager.cpp b/examples/webenginewidgets/demobrowser/downloadmanager.cpp
index 90b0cec9d..eab28942e 100644
--- a/examples/webenginewidgets/browser/downloadmanager.cpp
+++ b/examples/webenginewidgets/demobrowser/downloadmanager.cpp
@@ -43,7 +43,6 @@
#include "autosaver.h"
#include "browserapplication.h"
-#include "networkaccessmanager.h"
#include <math.h>
diff --git a/examples/webenginewidgets/browser/downloadmanager.h b/examples/webenginewidgets/demobrowser/downloadmanager.h
index 877682d77..877682d77 100644
--- a/examples/webenginewidgets/browser/downloadmanager.h
+++ b/examples/webenginewidgets/demobrowser/downloadmanager.h
diff --git a/examples/webenginewidgets/browser/downloads.ui b/examples/webenginewidgets/demobrowser/downloads.ui
index a2e256935..a2e256935 100644
--- a/examples/webenginewidgets/browser/downloads.ui
+++ b/examples/webenginewidgets/demobrowser/downloads.ui
diff --git a/examples/webenginewidgets/browser/edittableview.cpp b/examples/webenginewidgets/demobrowser/edittableview.cpp
index 866ee6f1f..866ee6f1f 100644
--- a/examples/webenginewidgets/browser/edittableview.cpp
+++ b/examples/webenginewidgets/demobrowser/edittableview.cpp
diff --git a/examples/webenginewidgets/browser/edittableview.h b/examples/webenginewidgets/demobrowser/edittableview.h
index 315427eac..315427eac 100644
--- a/examples/webenginewidgets/browser/edittableview.h
+++ b/examples/webenginewidgets/demobrowser/edittableview.h
diff --git a/examples/webenginewidgets/browser/edittreeview.cpp b/examples/webenginewidgets/demobrowser/edittreeview.cpp
index d515ea058..d515ea058 100644
--- a/examples/webenginewidgets/browser/edittreeview.cpp
+++ b/examples/webenginewidgets/demobrowser/edittreeview.cpp
diff --git a/examples/webenginewidgets/browser/edittreeview.h b/examples/webenginewidgets/demobrowser/edittreeview.h
index 1cf87d54f..1cf87d54f 100644
--- a/examples/webenginewidgets/browser/edittreeview.h
+++ b/examples/webenginewidgets/demobrowser/edittreeview.h
diff --git a/examples/webenginewidgets/browser/featurepermissionbar.cpp b/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp
index b7275dfc2..b7275dfc2 100644
--- a/examples/webenginewidgets/browser/featurepermissionbar.cpp
+++ b/examples/webenginewidgets/demobrowser/featurepermissionbar.cpp
diff --git a/examples/webenginewidgets/browser/featurepermissionbar.h b/examples/webenginewidgets/demobrowser/featurepermissionbar.h
index 1bfe1b483..1bfe1b483 100644
--- a/examples/webenginewidgets/browser/featurepermissionbar.h
+++ b/examples/webenginewidgets/demobrowser/featurepermissionbar.h
diff --git a/examples/webenginewidgets/browser/history.cpp b/examples/webenginewidgets/demobrowser/history.cpp
index ce104e982..ce104e982 100644
--- a/examples/webenginewidgets/browser/history.cpp
+++ b/examples/webenginewidgets/demobrowser/history.cpp
diff --git a/examples/webenginewidgets/browser/history.h b/examples/webenginewidgets/demobrowser/history.h
index bcb9c9b28..bcb9c9b28 100644
--- a/examples/webenginewidgets/browser/history.h
+++ b/examples/webenginewidgets/demobrowser/history.h
diff --git a/examples/webenginewidgets/browser/history.ui b/examples/webenginewidgets/demobrowser/history.ui
index 0944940e7..0944940e7 100644
--- a/examples/webenginewidgets/browser/history.ui
+++ b/examples/webenginewidgets/demobrowser/history.ui
diff --git a/examples/webenginewidgets/browser/htmls/htmls.qrc b/examples/webenginewidgets/demobrowser/htmls/htmls.qrc
index 03b256ccb..03b256ccb 100644
--- a/examples/webenginewidgets/browser/htmls/htmls.qrc
+++ b/examples/webenginewidgets/demobrowser/htmls/htmls.qrc
diff --git a/examples/webenginewidgets/browser/htmls/notfound.html b/examples/webenginewidgets/demobrowser/htmls/notfound.html
index e89845aa6..e89845aa6 100644
--- a/examples/webenginewidgets/browser/htmls/notfound.html
+++ b/examples/webenginewidgets/demobrowser/htmls/notfound.html
diff --git a/examples/webenginewidgets/browser/main.cpp b/examples/webenginewidgets/demobrowser/main.cpp
index 86859f741..86859f741 100644
--- a/examples/webenginewidgets/browser/main.cpp
+++ b/examples/webenginewidgets/demobrowser/main.cpp
diff --git a/examples/webenginewidgets/browser/modelmenu.cpp b/examples/webenginewidgets/demobrowser/modelmenu.cpp
index ec0eaffab..ec0eaffab 100644
--- a/examples/webenginewidgets/browser/modelmenu.cpp
+++ b/examples/webenginewidgets/demobrowser/modelmenu.cpp
diff --git a/examples/webenginewidgets/browser/modelmenu.h b/examples/webenginewidgets/demobrowser/modelmenu.h
index c0a7d56b8..c0a7d56b8 100644
--- a/examples/webenginewidgets/browser/modelmenu.h
+++ b/examples/webenginewidgets/demobrowser/modelmenu.h
diff --git a/examples/webenginewidgets/browser/passworddialog.ui b/examples/webenginewidgets/demobrowser/passworddialog.ui
index 7c1665867..7c1665867 100644
--- a/examples/webenginewidgets/browser/passworddialog.ui
+++ b/examples/webenginewidgets/demobrowser/passworddialog.ui
diff --git a/examples/webenginewidgets/browser/proxy.ui b/examples/webenginewidgets/demobrowser/proxy.ui
index 62a8be627..62a8be627 100644
--- a/examples/webenginewidgets/browser/proxy.ui
+++ b/examples/webenginewidgets/demobrowser/proxy.ui
diff --git a/examples/webenginewidgets/browser/searchlineedit.cpp b/examples/webenginewidgets/demobrowser/searchlineedit.cpp
index 5152ac1c0..5152ac1c0 100644
--- a/examples/webenginewidgets/browser/searchlineedit.cpp
+++ b/examples/webenginewidgets/demobrowser/searchlineedit.cpp
diff --git a/examples/webenginewidgets/browser/searchlineedit.h b/examples/webenginewidgets/demobrowser/searchlineedit.h
index b8b8337fd..b8b8337fd 100644
--- a/examples/webenginewidgets/browser/searchlineedit.h
+++ b/examples/webenginewidgets/demobrowser/searchlineedit.h
diff --git a/examples/webenginewidgets/browser/settings.cpp b/examples/webenginewidgets/demobrowser/settings.cpp
index 7ed5f707b..35e5e26c9 100644
--- a/examples/webenginewidgets/browser/settings.cpp
+++ b/examples/webenginewidgets/demobrowser/settings.cpp
@@ -47,9 +47,9 @@
#include "cookiejar.h"
#endif
#include "history.h"
-#include "networkaccessmanager.h"
#include "webview.h"
+#include <QtCore/QLocale>
#include <QtCore/QSettings>
#include <QtWidgets/QtWidgets>
#include <QtWebEngineWidgets/QtWebEngineWidgets>
@@ -66,6 +66,21 @@ SettingsDialog::SettingsDialog(QWidget *parent)
loadFromSettings();
}
+static QString defaultAcceptLanguage()
+{
+ const QStringList langs = QLocale().uiLanguages();
+ if (langs.isEmpty())
+ return QString();
+ QString str = langs.first();
+ const float qstep = 1.0f / float(langs.count());
+ float q = 1.0f - qstep;
+ for (int i = 1; i < langs.count(); ++i) {
+ str += QStringLiteral(", ") + langs.at(i) + QStringLiteral(";q=") + QString::number(q, 'f', 2);
+ q -= qstep;
+ }
+ return str;
+}
+
void SettingsDialog::loadDefaults()
{
QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
@@ -82,15 +97,14 @@ void SettingsDialog::loadDefaults()
downloadsLocation->setText(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
enableJavascript->setChecked(defaultSettings->testAttribute(QWebEngineSettings::JavascriptEnabled));
-#if defined(QTWEBENGINE_PLUGINS)
enablePlugins->setChecked(defaultSettings->testAttribute(QWebEngineSettings::PluginsEnabled));
-#endif
enableScrollAnimator->setChecked(defaultSettings->testAttribute(QWebEngineSettings::ScrollAnimatorEnabled));
persistentDataPath->setText(QWebEngineProfile::defaultProfile()->persistentStoragePath());
sessionCookiesCombo->setCurrentIndex(QWebEngineProfile::defaultProfile()->persistentCookiesPolicy());
httpUserAgent->setText(QWebEngineProfile::defaultProfile()->httpUserAgent());
+ httpAcceptLanguage->setText(defaultAcceptLanguage());
}
void SettingsDialog::loadFromSettings()
@@ -140,6 +154,7 @@ void SettingsDialog::loadFromSettings()
userStyleSheet->setPlainText(settings.value(QLatin1String("userStyleSheet")).toString());
enableScrollAnimator->setChecked(settings.value(QLatin1String("enableScrollAnimator"), enableScrollAnimator->isChecked()).toBool());
httpUserAgent->setText(settings.value(QLatin1String("httpUserAgent"), httpUserAgent->text()).toString());
+ httpAcceptLanguage->setText(settings.value(QLatin1String("httpAcceptLanguage"), httpAcceptLanguage->text()).toString());
settings.endGroup();
// Privacy
@@ -198,6 +213,7 @@ void SettingsDialog::saveToSettings()
settings.setValue(QLatin1String("enableScrollAnimator"), enableScrollAnimator->isChecked());
settings.setValue(QLatin1String("userStyleSheet"), userStyleSheet->toPlainText());
settings.setValue(QLatin1String("httpUserAgent"), httpUserAgent->text());
+ settings.setValue(QLatin1String("httpAcceptLanguage"), httpAcceptLanguage->text());
settings.endGroup();
//Privacy
@@ -223,7 +239,6 @@ void SettingsDialog::saveToSettings()
BrowserApplication::instance()->loadSettings();
#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
- BrowserApplication::networkAccessManager()->loadSettings();
BrowserApplication::cookieJar()->loadSettings();
#endif
BrowserApplication::historyManager()->loadSettings();
@@ -271,6 +286,16 @@ void SettingsDialog::chooseFixedFont()
}
}
+void SettingsDialog::on_httpUserAgent_editingFinished()
+{
+ QWebEngineProfile::defaultProfile()->setHttpUserAgent(httpUserAgent->text());
+}
+
+void SettingsDialog::on_httpAcceptLanguage_editingFinished()
+{
+ QWebEngineProfile::defaultProfile()->setHttpAcceptLanguage(httpAcceptLanguage->text());
+}
+
void SettingsDialog::setHomeToCurrentPage()
{
BrowserMainWindow *mw = static_cast<BrowserMainWindow*>(parent());
diff --git a/examples/webenginewidgets/browser/settings.h b/examples/webenginewidgets/demobrowser/settings.h
index 6def66928..3a50dd29f 100644
--- a/examples/webenginewidgets/browser/settings.h
+++ b/examples/webenginewidgets/demobrowser/settings.h
@@ -65,6 +65,9 @@ private slots:
void chooseFont();
void chooseFixedFont();
+ void on_httpUserAgent_editingFinished();
+ void on_httpAcceptLanguage_editingFinished();
+
private:
QFont standardFont;
QFont fixedFont;
diff --git a/examples/webenginewidgets/browser/settings.ui b/examples/webenginewidgets/demobrowser/settings.ui
index 11bdee4d3..38a7af344 100644
--- a/examples/webenginewidgets/browser/settings.ui
+++ b/examples/webenginewidgets/demobrowser/settings.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>657</width>
- <height>322</height>
+ <height>336</height>
</rect>
</property>
<property name="windowTitle">
@@ -499,19 +499,29 @@
<string>Advanced</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="2" column="1">
- <widget class="QTextEdit" name="userStyleSheet"/>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>HTTP User-Agent:</string>
+ </property>
+ </widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="httpUserAgent"/>
</item>
- <item row="0" column="0">
- <widget class="QLabel" name="label_15">
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_16">
<property name="text">
- <string>HTTP User-Agent:</string>
+ <string>HTTP Accept-&amp;Language:</string>
+ </property>
+ <property name="buddy">
+ <cstring>httpAcceptLanguage</cstring>
</property>
</widget>
</item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="httpAcceptLanguage"/>
+ </item>
<item row="2" column="0">
<widget class="QLabel" name="label_14">
<property name="text">
@@ -519,7 +529,10 @@
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="2" column="1">
+ <widget class="QTextEdit" name="userStyleSheet"/>
+ </item>
+ <item row="3" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/examples/webenginewidgets/browser/squeezelabel.cpp b/examples/webenginewidgets/demobrowser/squeezelabel.cpp
index 78198c3f0..78198c3f0 100644
--- a/examples/webenginewidgets/browser/squeezelabel.cpp
+++ b/examples/webenginewidgets/demobrowser/squeezelabel.cpp
diff --git a/examples/webenginewidgets/browser/squeezelabel.h b/examples/webenginewidgets/demobrowser/squeezelabel.h
index 628b7350a..628b7350a 100644
--- a/examples/webenginewidgets/browser/squeezelabel.h
+++ b/examples/webenginewidgets/demobrowser/squeezelabel.h
diff --git a/examples/webenginewidgets/browser/tabwidget.cpp b/examples/webenginewidgets/demobrowser/tabwidget.cpp
index c093b804a..4532683b5 100644
--- a/examples/webenginewidgets/browser/tabwidget.cpp
+++ b/examples/webenginewidgets/demobrowser/tabwidget.cpp
@@ -85,6 +85,11 @@ TabBar::TabBar(QWidget *parent)
setMovable(true);
}
+TabWidget::~TabWidget()
+{
+ delete m_fullScreenView;
+}
+
void TabBar::selectTabAction()
{
if (QShortcut *shortCut = qobject_cast<QShortcut*>(sender())) {
@@ -213,6 +218,7 @@ TabWidget::TabWidget(QWidget *parent)
, m_lineEdits(0)
, m_tabBar(new TabBar(this))
, m_profile(QWebEngineProfile::defaultProfile())
+ , m_fullScreenView(0)
{
setElideMode(Qt::ElideRight);
@@ -315,6 +321,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
disconnect(oldWebView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
+ disconnect(oldWebView->page(), SIGNAL(fullScreenRequested(bool)),
+ this, SLOT(fullScreenRequested(bool)));
}
#if defined(QWEBENGINEVIEW_STATUSBARMESSAGE)
@@ -327,6 +335,8 @@ void TabWidget::currentChanged(int index)
this, SIGNAL(loadProgress(int)));
connect(webView->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
+ connect(webView->page(), SIGNAL(fullScreenRequested(bool)),
+ this, SLOT(fullScreenRequested(bool)));
for (int i = 0; i < m_actions.count(); ++i) {
WebActionMapper *mapper = m_actions[i];
@@ -342,6 +352,26 @@ void TabWidget::currentChanged(int index)
webView->setFocus();
}
+void TabWidget::fullScreenRequested(bool fullscreen)
+{
+ if (fullscreen) {
+ if (!m_fullScreenView)
+ m_fullScreenView = new QWebEngineView();
+ WebPage *webPage = qobject_cast<WebPage*>(sender());
+ webPage->setView(m_fullScreenView);
+ m_fullScreenView->showFullScreen();
+ m_fullScreenView->raise();
+ } else {
+ if (!m_fullScreenView)
+ return;
+ WebPage *webPage = qobject_cast<WebPage*>(sender());
+ WebView *oldWebView = this->webView(m_lineEdits->currentIndex());
+ webPage->setView(oldWebView);
+ raise();
+ m_fullScreenView->hide();
+ }
+}
+
QAction *TabWidget::newTabAction() const
{
return m_newTabAction;
diff --git a/examples/webenginewidgets/browser/tabwidget.h b/examples/webenginewidgets/demobrowser/tabwidget.h
index 5d7f1e2c5..f6c4edba2 100644
--- a/examples/webenginewidgets/browser/tabwidget.h
+++ b/examples/webenginewidgets/demobrowser/tabwidget.h
@@ -49,6 +49,7 @@
QT_BEGIN_NAMESPACE
class QWebEngineDownloadItem;
class QWebEngineProfile;
+class QWebEngineView;
QT_END_NAMESPACE
/*
@@ -164,6 +165,7 @@ signals:
public:
TabWidget(QWidget *parent = 0);
+ ~TabWidget();
void clear();
void addWebAction(QAction *action, QWebEnginePage::WebAction webAction);
@@ -213,6 +215,7 @@ private slots:
void lineEditReturnPressed();
void windowCloseRequested();
void moveTab(int fromIndex, int toIndex);
+ void fullScreenRequested(bool);
private:
QAction *m_recentlyClosedTabsAction;
@@ -230,6 +233,7 @@ private:
QStackedWidget *m_lineEdits;
TabBar *m_tabBar;
QWebEngineProfile *m_profile;
+ QWebEngineView *m_fullScreenView;
};
#endif // TABWIDGET_H
diff --git a/examples/webenginewidgets/browser/toolbarsearch.cpp b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp
index 42cdaec18..42cdaec18 100644
--- a/examples/webenginewidgets/browser/toolbarsearch.cpp
+++ b/examples/webenginewidgets/demobrowser/toolbarsearch.cpp
diff --git a/examples/webenginewidgets/browser/toolbarsearch.h b/examples/webenginewidgets/demobrowser/toolbarsearch.h
index cbe00366c..cbe00366c 100644
--- a/examples/webenginewidgets/browser/toolbarsearch.h
+++ b/examples/webenginewidgets/demobrowser/toolbarsearch.h
diff --git a/examples/webenginewidgets/browser/urllineedit.cpp b/examples/webenginewidgets/demobrowser/urllineedit.cpp
index 685277d9c..685277d9c 100644
--- a/examples/webenginewidgets/browser/urllineedit.cpp
+++ b/examples/webenginewidgets/demobrowser/urllineedit.cpp
diff --git a/examples/webenginewidgets/browser/urllineedit.h b/examples/webenginewidgets/demobrowser/urllineedit.h
index 775aa7d18..775aa7d18 100644
--- a/examples/webenginewidgets/browser/urllineedit.h
+++ b/examples/webenginewidgets/demobrowser/urllineedit.h
diff --git a/examples/webenginewidgets/browser/webview.cpp b/examples/webenginewidgets/demobrowser/webview.cpp
index 99986642e..d56ab8025 100644
--- a/examples/webenginewidgets/browser/webview.cpp
+++ b/examples/webenginewidgets/demobrowser/webview.cpp
@@ -44,7 +44,6 @@
#include "cookiejar.h"
#include "downloadmanager.h"
#include "featurepermissionbar.h"
-#include "networkaccessmanager.h"
#include "ui_passworddialog.h"
#include "ui_proxy.h"
#include "tabwidget.h"
@@ -72,7 +71,6 @@ WebPage::WebPage(QWebEngineProfile *profile, QObject *parent)
: QWebEnginePage(profile, parent)
, m_keyboardModifiers(Qt::NoModifier)
, m_pressedButtons(Qt::NoButton)
- , m_openInNewTab(false)
{
#if defined(QWEBENGINEPAGE_SETNETWORKACCESSMANAGER)
setNetworkAccessManager(BrowserApplication::networkAccessManager());
@@ -175,8 +173,7 @@ private:
QWebEnginePage *WebPage::createWindow(QWebEnginePage::WebWindowType type)
{
- if (m_openInNewTab || type == QWebEnginePage::WebBrowserTab) {
- m_openInNewTab = false;
+ if (type == QWebEnginePage::WebBrowserTab) {
return mainWindow()->tabWidget()->newTab()->page();
} else if (type == QWebEnginePage::WebBrowserWindow) {
BrowserApplication::instance()->newMainWindow();
@@ -276,6 +273,9 @@ void WebPage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *aut
if (dialog.exec() == QDialog::Accepted) {
auth->setUser(passwordDialog.userNameLineEdit->text());
auth->setPassword(passwordDialog.passwordLineEdit->text());
+ } else {
+ // Set authenticator null if dialog is cancelled
+ *auth = QAuthenticator();
}
}
@@ -301,6 +301,26 @@ void WebPage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator
if (dialog.exec() == QDialog::Accepted) {
auth->setUser(proxyDialog.userNameLineEdit->text());
auth->setPassword(proxyDialog.passwordLineEdit->text());
+ } else {
+ // Set authenticator null if dialog is cancelled
+ *auth = QAuthenticator();
+ }
+}
+
+void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int /*lineNumber*/, const QString& sourceID)
+{
+ QUrl url;
+ url.setUrl(sourceID);
+ switch (level) {
+ case InfoMessageLevel:
+ // Ignore these, they can still be found in the inspector.
+ break;
+ case WarningMessageLevel:
+ qInfo() << "JavaScript WARNING:" << url.host() << message;
+ break;
+ case ErrorMessageLevel:
+ qInfo() << "JavaScript ERROR:" << url.host() << message;
+ break;
}
}
@@ -338,24 +358,17 @@ void WebView::setPage(WebPage *_page)
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
-#if defined(QWEBENGINEPAGE_HITTESTCONTENT)
- QWebEngineHitTestResult r = page()->hitTestContent(event->pos());
- if (!r.linkUrl().isEmpty()) {
- QMenu menu(this);
- menu.addAction(pageAction(QWebEnginePage::OpenLinkInNewWindow));
- menu.addAction(tr("Open in New Tab"), this, SLOT(openLinkInNewTab()));
- menu.addSeparator();
- menu.addAction(pageAction(QWebEnginePage::DownloadLinkToDisk));
- // Add link to bookmarks...
- menu.addSeparator();
- menu.addAction(pageAction(QWebEnginePage::CopyLinkToClipboard));
- if (page()->settings()->testAttribute(QWebEngineSettings::DeveloperExtrasEnabled))
- menu.addAction(pageAction(QWebEnginePage::InspectElement));
- menu.exec(mapToGlobal(event->pos()));
- return;
+ QMenu *menu = page()->createStandardContextMenu();
+ const QList<QAction*> actions = menu->actions();
+ QList<QAction*>::const_iterator it = qFind(actions.cbegin(), actions.cend(), page()->action(QWebEnginePage::OpenLinkInThisWindow));
+ if (it != actions.cend()) {
+ (*it)->setText(tr("Open Link in This Window"));
+ ++it;
+ menu->insertAction(*it, page()->action(QWebEnginePage::OpenLinkInNewWindow));
+ menu->insertAction(*it, page()->action(QWebEnginePage::OpenLinkInNewTab));
}
-#endif
- QWebEngineView::contextMenuEvent(event);
+
+ menu->popup(event->globalPos());
}
void WebView::wheelEvent(QWheelEvent *event)
@@ -374,10 +387,7 @@ void WebView::wheelEvent(QWheelEvent *event)
void WebView::openLinkInNewTab()
{
-#if defined(QWEBENGINEPAGE_WEBACTION_OPENLINKINNEWWINDOW)
- m_page->m_openInNewTab = true;
- pageAction(QWebEnginePage::OpenLinkInNewWindow)->trigger();
-#endif
+ pageAction(QWebEnginePage::OpenLinkInNewTab)->trigger();
}
void WebView::onFeaturePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature)
diff --git a/examples/webenginewidgets/browser/webview.h b/examples/webenginewidgets/demobrowser/webview.h
index a147d780a..cb78fdd8a 100644
--- a/examples/webenginewidgets/browser/webview.h
+++ b/examples/webenginewidgets/demobrowser/webview.h
@@ -71,6 +71,7 @@ protected:
QObject *createPlugin(const QString &classId, const QUrl &url, const QStringList &paramNames, const QStringList &paramValues);
#endif
virtual bool certificateError(const QWebEngineCertificateError &error) Q_DECL_OVERRIDE;
+ virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
private slots:
#if defined(QWEBENGINEPAGE_UNSUPPORTEDCONTENT)
@@ -85,7 +86,6 @@ private:
// set the webview mousepressedevent
Qt::KeyboardModifiers m_keyboardModifiers;
Qt::MouseButtons m_pressedButtons;
- bool m_openInNewTab;
QUrl m_loadingUrl;
};
diff --git a/examples/webenginewidgets/browser/xbel.cpp b/examples/webenginewidgets/demobrowser/xbel.cpp
index 6b4f53d2e..6b4f53d2e 100644
--- a/examples/webenginewidgets/browser/xbel.cpp
+++ b/examples/webenginewidgets/demobrowser/xbel.cpp
diff --git a/examples/webenginewidgets/browser/xbel.h b/examples/webenginewidgets/demobrowser/xbel.h
index d95549dd8..d95549dd8 100644
--- a/examples/webenginewidgets/browser/xbel.h
+++ b/examples/webenginewidgets/demobrowser/xbel.h
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 305284960db83fe9b9ae47674db9914d82180c2
+Subproject 8a2ae40fde77efb717668abedc5f0c9e28cd86b
diff --git a/src/core/api/core_api.pro b/src/core/api/core_api.pro
new file mode 100644
index 000000000..1f82c7e21
--- /dev/null
+++ b/src/core/api/core_api.pro
@@ -0,0 +1,49 @@
+TARGET = qtwebenginecoreapi
+DESTDIR = $$OUT_PWD/$$getConfigDir()
+
+TEMPLATE = lib
+
+CONFIG += staticlib c++11
+QT += network
+
+# Don't create .prl file for this intermediate library because
+# their contents get used when linking against them, breaking
+# "-Wl,-whole-archive -lqtwebenginecoreapi --Wl,-no-whole-archive"
+CONFIG -= create_prl
+
+# Copy this logic from qt_module.prf so that the intermediate library can be
+# created to the same rules as the final module linking in core_module.pro.
+!host_build:if(win32|mac):!macx-xcode {
+ contains(QT_CONFIG, debug_and_release):CONFIG += debug_and_release
+ contains(QT_CONFIG, build_all):CONFIG += build_all
+}
+
+DEFINES += \
+ BUILDING_CHROMIUM \
+ NOMINMAX
+
+CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core \
+ $$CHROMIUM_SRC_DIR
+
+linux-g++*: QMAKE_CXXFLAGS += -Wno-unused-parameter
+
+HEADERS = \
+ qwebenginecallback.h \
+ qwebenginecallback_p.h \
+ qtwebenginecoreglobal.h \
+ qtwebenginecoreglobal_p.h \
+ qwebenginecookiestoreclient.h \
+ qwebenginecookiestoreclient_p.h \
+ qwebengineurlrequestinterceptor.h \
+ qwebengineurlrequestinfo.h \
+ qwebengineurlrequestinfo_p.h \
+ qwebengineurlrequestjob.h \
+ qwebengineurlschemehandler.h \
+ qwebengineurlschemehandler_p.h
+
+SOURCES = \
+ qwebenginecookiestoreclient.cpp \
+ qwebengineurlrequestinfo.cpp \
+ qwebengineurlrequestjob.cpp \
+ qwebengineurlschemehandler.cpp
diff --git a/src/core/api/qtwebenginecoreglobal.h b/src/core/api/qtwebenginecoreglobal.h
new file mode 100644
index 000000000..16daaab7d
--- /dev/null
+++ b/src/core/api/qtwebenginecoreglobal.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTWEBENGINECOREGLOBAL_H
+#define QTWEBENGINECOREGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(BUILDING_CHROMIUM)
+# define QWEBENGINE_EXPORT Q_DECL_EXPORT
+#else
+# define QWEBENGINE_EXPORT Q_DECL_IMPORT
+#endif
+
+#define ASSERT_ENUMS_MATCH(A, B) Q_STATIC_ASSERT_X(static_cast<int>(A) == static_cast<int>(B), "The enum values must match");
+
+#endif // QTWEBENGINECOREGLOBAL_H
diff --git a/src/core/qtwebenginecoreglobal.h b/src/core/api/qtwebenginecoreglobal_p.h
index d09497ce8..e93ca9c2c 100644
--- a/src/core/qtwebenginecoreglobal.h
+++ b/src/core/api/qtwebenginecoreglobal_p.h
@@ -34,10 +34,21 @@
**
****************************************************************************/
-#ifndef QTWEBENGINECOREGLOBAL_H
-#define QTWEBENGINECOREGLOBAL_H
+#ifndef QTWEBENGINECOREGLOBAL_P_H
+#define QTWEBENGINECOREGLOBAL_P_H
-#include <QtCore/qglobal.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qtwebenginecoreglobal.h"
#ifdef QT_WEBENGINE_LOGGING
#define QT_NOT_YET_IMPLEMENTED fprintf(stderr, "function %s not implemented! - %s:%d\n", __func__, __FILE__, __LINE__);
@@ -47,16 +58,6 @@
#define QT_NOT_USED Q_UNREACHABLE(); // This will assert in debug.
#endif
-#ifndef QT_STATIC
-# if defined(BUILDING_CHROMIUM)
-# define QWEBENGINE_EXPORT Q_DECL_EXPORT
-# else
-# define QWEBENGINE_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define QWEBENGINE_EXPORT
-#endif
-
-#define ASSERT_ENUMS_MATCH(A, B) Q_STATIC_ASSERT_X(static_cast<int>(A) == static_cast<int>(B), "The enum values must match");
+#define QWEBENGINE_PRIVATE_EXPORT QWEBENGINE_EXPORT
-#endif // QTWEBENGINECOREGLOBAL_H
+#endif // QTWEBENGINECOREGLOBAL_P_H
diff --git a/src/core/api/qwebenginecallback.h b/src/core/api/qwebenginecallback.h
new file mode 100644
index 000000000..ddee20d06
--- /dev/null
+++ b/src/core/api/qwebenginecallback.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECALLBACK_H
+#define QWEBENGINECALLBACK_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
+#include <QtCore/qshareddata.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qvariant.h>
+
+namespace QtWebEngineCore {
+class CallbackDirectory;
+}
+
+QT_BEGIN_NAMESPACE
+
+namespace QtWebEnginePrivate {
+
+template <typename T>
+class QWebEngineCallbackPrivateBase : public QSharedData {
+public:
+ QWebEngineCallbackPrivateBase() {}
+ virtual ~QWebEngineCallbackPrivateBase() {}
+ virtual void operator()(T) = 0;
+};
+
+template <typename T, typename F>
+class QWebEngineCallbackPrivate : public QWebEngineCallbackPrivateBase<T> {
+public:
+ QWebEngineCallbackPrivate(F callable)
+ : m_callable(callable)
+ {}
+ virtual void operator()(T value) Q_DECL_OVERRIDE { m_callable(value); }
+private:
+ F m_callable;
+};
+
+} // namespace QtWebEnginePrivate
+
+template <typename T>
+class QWebEngineCallback {
+public:
+ template <typename F>
+ QWebEngineCallback(F f)
+ : d(new QtWebEnginePrivate::QWebEngineCallbackPrivate<T, F>(f))
+ { }
+ QWebEngineCallback() { }
+ operator bool() const { return d; }
+private:
+ friend class QtWebEngineCore::CallbackDirectory;
+ QExplicitlySharedDataPointer<QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> > d;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINECALLBACK_H
diff --git a/src/core/api/qwebenginecallback_p.h b/src/core/api/qwebenginecallback_p.h
new file mode 100644
index 000000000..44d9ceb14
--- /dev/null
+++ b/src/core/api/qwebenginecallback_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECALLBACK_P_H
+#define QWEBENGINECALLBACK_P_H
+
+#include "qtwebenginecoreglobal_p.h"
+#include "qwebenginecallback.h"
+
+#include <QByteArray>
+#include <QHash>
+#include <QSharedData>
+#include <QString>
+#include <QVariant>
+#include <type_traits>
+
+#define FOR_EACH_TYPE(F) \
+ F(bool) \
+ F(int) \
+ F(const QString &) \
+ F(const QByteArray &) \
+ F(const QVariant &)
+
+namespace QtWebEngineCore {
+
+class CallbackDirectory {
+ template<typename T>
+ void invokeInternal(quint64 callbackId, T result);
+ template<typename T>
+ void invokeEmptyInternal(QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> *callback);
+
+public:
+ ~CallbackDirectory()
+ {
+ // "Cancel" pending callbacks by calling them with an invalid value.
+ // This guarantees that each callback is called exactly once.
+ for (CallbackSharedDataPointerBase * const sharedPtrBase: m_callbackMap) {
+ Q_ASSERT(sharedPtrBase);
+ sharedPtrBase->invokeEmpty();
+ delete sharedPtrBase;
+ }
+ }
+
+ enum ReservedCallbackIds {
+ NoCallbackId = 0,
+ DeleteCookieCallbackId,
+ DeleteSessionCookiesCallbackId,
+ DeleteAllCookiesCallbackId,
+ GetAllCookiesCallbackId,
+
+ // Place reserved id's before this.
+ ReservedCallbackIdsEnd
+ };
+
+ template<typename T>
+ void registerCallback(quint64 callbackId, const QWebEngineCallback<T> &callback);
+
+ template<typename T>
+ void invokeEmpty(const QWebEngineCallback<T> &callback);
+
+#define DEFINE_INVOKE_FOR_TYPE(Type) \
+ void invoke(quint64 callbackId, Type result) { \
+ invokeInternal<Type>(callbackId, std::forward<Type>(result)); \
+ }
+ FOR_EACH_TYPE(DEFINE_INVOKE_FOR_TYPE)
+#undef DEFINE_INVOKE_FOR_TYPE
+
+private:
+ struct CallbackSharedDataPointerBase {
+ virtual ~CallbackSharedDataPointerBase() { }
+ virtual void invokeEmpty() = 0;
+ virtual void doRef() = 0;
+ virtual void doDeref() = 0;
+ virtual operator bool () const = 0;
+ };
+
+ template <typename T>
+ struct CallbackSharedDataPointer : public CallbackSharedDataPointerBase {
+ CallbackDirectory* parent;
+ QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> *callback;
+
+ ~CallbackSharedDataPointer() { doDeref(); }
+ CallbackSharedDataPointer() : parent(0), callback(0) { }
+ CallbackSharedDataPointer(const CallbackSharedDataPointer<T> &other)
+ : parent(other.parent), callback(other.callback) { doRef(); }
+ CallbackSharedDataPointer(CallbackDirectory *p, QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> *c)
+ : parent(p), callback(c) { Q_ASSERT(callback); doRef(); }
+
+ void invokeEmpty() override;
+ operator bool () const override { return callback; }
+
+ private:
+ void doRef() override;
+ void doDeref() override;
+ };
+
+ QHash<quint64, CallbackSharedDataPointerBase*> m_callbackMap;
+};
+
+template<typename T>
+inline
+void CallbackDirectory::registerCallback(quint64 callbackId, const QWebEngineCallback<T> &callback)
+{
+ if (!callback.d)
+ return;
+ m_callbackMap.insert(callbackId, new CallbackSharedDataPointer<T>(this, callback.d.data()));
+}
+
+template<typename T>
+inline
+void CallbackDirectory::invokeInternal(quint64 callbackId, T result)
+{
+ CallbackSharedDataPointerBase * const sharedPtrBase = m_callbackMap.take(callbackId);
+ if (!sharedPtrBase)
+ return;
+
+ auto ptr = static_cast<CallbackSharedDataPointer<T> *>(sharedPtrBase);
+ Q_ASSERT(ptr);
+ (*ptr->callback)(std::forward<T>(result));
+ delete ptr;
+}
+
+template<typename T>
+inline
+void CallbackDirectory::invokeEmptyInternal(QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> *callback)
+{
+ Q_ASSERT(callback);
+ using NoRefT = typename std::remove_reference<T>::type;
+ using NoConstNoRefT = typename std::remove_const<NoRefT>::type;
+ NoConstNoRefT t;
+ (*callback)(t);
+}
+
+template<>
+inline
+void CallbackDirectory::invokeEmptyInternal(QtWebEnginePrivate::QWebEngineCallbackPrivateBase<bool> *callback)
+{
+ Q_ASSERT(callback);
+ (*callback)(false);
+}
+
+template<>
+inline
+void CallbackDirectory::invokeEmptyInternal(QtWebEnginePrivate::QWebEngineCallbackPrivateBase<int> *callback)
+{
+ Q_ASSERT(callback);
+ (*callback)(0);
+}
+
+template<typename T>
+inline
+void CallbackDirectory::invokeEmpty(const QWebEngineCallback<T> &callback)
+{
+ if (!callback.d)
+ return;
+
+ invokeEmptyInternal(callback.d.data());
+}
+
+template <typename T>
+inline
+void CallbackDirectory::CallbackSharedDataPointer<T>::doRef()
+{
+ if (!callback)
+ return;
+
+ callback->ref.ref();
+}
+
+template <typename T>
+inline
+void CallbackDirectory::CallbackSharedDataPointer<T>::doDeref()
+{
+ if (!callback)
+ return;
+ if (!callback->ref.deref())
+ delete callback;
+}
+
+template <typename T>
+inline
+void CallbackDirectory::CallbackSharedDataPointer<T>::invokeEmpty()
+{
+ if (!callback)
+ return;
+
+ Q_ASSERT(parent);
+ parent->invokeEmptyInternal(callback);
+}
+
+} // namespace QtWebEngineCore
+
+#endif // QWEBENGINECALLBACK_P_H
diff --git a/src/core/api/qwebenginecookiestoreclient.cpp b/src/core/api/qwebenginecookiestoreclient.cpp
new file mode 100644
index 000000000..61d38099d
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebenginecookiestoreclient.h"
+#include "qwebenginecookiestoreclient_p.h"
+
+#include <QByteArray>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QtWebEngineCore;
+
+QWebEngineCookieStoreClientPrivate::QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient* q)
+ : m_nextCallbackId(CallbackDirectory::ReservedCallbackIdsEnd)
+ , m_deleteSessionCookiesPending(false)
+ , m_deleteAllCookiesPending(false)
+ , m_getAllCookiesPending(false)
+ , delegate(0)
+ , q_ptr(q)
+{
+}
+
+QWebEngineCookieStoreClientPrivate::~QWebEngineCookieStoreClientPrivate()
+{
+
+}
+
+void QWebEngineCookieStoreClientPrivate::processPendingUserCookies()
+{
+ Q_ASSERT(delegate);
+ Q_ASSERT(delegate->hasCookieMonster());
+
+ if (m_getAllCookiesPending) {
+ m_getAllCookiesPending = false;
+ delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId);
+ }
+
+ if (m_deleteAllCookiesPending) {
+ m_deleteAllCookiesPending = false;
+ delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId);
+ }
+
+ if (m_deleteSessionCookiesPending) {
+ m_deleteSessionCookiesPending = false;
+ delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId);
+ }
+
+ if (m_pendingUserCookies.isEmpty())
+ return;
+
+ Q_FOREACH (const auto &cookieData, m_pendingUserCookies) {
+ if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId)
+ delegate->deleteCookie(cookieData.cookie, cookieData.origin);
+ else
+ delegate->setCookie(cookieData.callbackId, cookieData.cookie, cookieData.origin);
+ }
+
+ m_pendingUserCookies.clear();
+}
+
+void QWebEngineCookieStoreClientPrivate::setCookie(const QWebEngineCallback<bool> &callback, const QNetworkCookie &cookie, const QUrl &origin)
+{
+ const quint64 currentCallbackId = callback ? m_nextCallbackId++ : static_cast<quint64>(CallbackDirectory::NoCallbackId);
+
+ if (currentCallbackId != CallbackDirectory::NoCallbackId)
+ callbackDirectory.registerCallback(currentCallbackId, callback);
+
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_pendingUserCookies.append(CookieData{ currentCallbackId, cookie, origin });
+ return;
+ }
+
+ delegate->setCookie(currentCallbackId, cookie, origin);
+}
+
+void QWebEngineCookieStoreClientPrivate::deleteCookie(const QNetworkCookie &cookie, const QUrl &url)
+{
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_pendingUserCookies.append(CookieData{ CallbackDirectory::DeleteCookieCallbackId, cookie, url });
+ return;
+ }
+
+ delegate->deleteCookie(cookie, url);
+}
+
+void QWebEngineCookieStoreClientPrivate::deleteSessionCookies()
+{
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_deleteSessionCookiesPending = true;
+ return;
+ }
+
+ delegate->deleteSessionCookies(CallbackDirectory::DeleteSessionCookiesCallbackId);
+}
+
+void QWebEngineCookieStoreClientPrivate::deleteAllCookies()
+{
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_deleteAllCookiesPending = true;
+ m_deleteSessionCookiesPending = false;
+ return;
+ }
+
+ delegate->deleteAllCookies(CallbackDirectory::DeleteAllCookiesCallbackId);
+}
+
+void QWebEngineCookieStoreClientPrivate::getAllCookies()
+{
+ if (!delegate || !delegate->hasCookieMonster()) {
+ m_getAllCookiesPending = true;
+ return;
+ }
+
+ delegate->getAllCookies(CallbackDirectory::GetAllCookiesCallbackId);
+}
+
+void QWebEngineCookieStoreClientPrivate::onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList)
+{
+ callbackDirectory.invoke(callbackId, cookieList);
+}
+void QWebEngineCookieStoreClientPrivate::onSetCallbackResult(qint64 callbackId, bool success)
+{
+ callbackDirectory.invoke(callbackId, success);
+}
+
+void QWebEngineCookieStoreClientPrivate::onDeleteCallbackResult(qint64 callbackId, int numCookies)
+{
+ callbackDirectory.invoke(callbackId, numCookies);
+}
+
+void QWebEngineCookieStoreClientPrivate::onCookieChanged(const QNetworkCookie &cookie, bool removed)
+{
+ Q_Q(QWebEngineCookieStoreClient);
+ if (removed)
+ Q_EMIT q->cookieRemoved(cookie);
+ else
+ Q_EMIT q->cookieAdded(cookie);
+}
+
+bool QWebEngineCookieStoreClientPrivate::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url)
+{
+ Q_Q(QWebEngineCookieStoreClient);
+ return q->acceptCookie(firstPartyUrl, cookieLine, url);
+}
+
+/*!
+ \class QWebEngineCookieStoreClient
+ \inmodule QtWebEngineCore
+ \since 5.6
+ \brief The QWebEngineCookieStoreClient class provides access to Chromium's cookies.
+
+ By subclassing the QWebEngineCookieStoreClient and installing it on the profile, the user can
+ access HTTP cookies of Chromium.
+ It can be used to synchronize cookies of Chromium and the QNetworkAccessManager, as well as
+ to set, delete, and intercept cookies during navigation.
+ Because cookie operations are asynchronous, the user can choose to provide a callback function
+ to get notified about the success of the operation.
+ The signal handlers for removal and addition should not be used to execute heavy tasks,
+ because they might block the IO thread in case of a blocking connection.
+*/
+
+/*!
+ \fn void QWebEngineCookieStoreClient::cookieAdded(const QNetworkCookie &cookie)
+
+ This signal is emitted whenever a new \a cookie is added to the cookie store.
+*/
+
+/*!
+ \fn void QWebEngineCookieStoreClient::cookieRemoved(const QNetworkCookie &cookie)
+
+ This signal is emitted whenever a \a cookie is deleted from the cookie store.
+*/
+
+/*!
+ Creates a new QWebEngineCookieStoreClient object with \a parent.
+*/
+
+QWebEngineCookieStoreClient::QWebEngineCookieStoreClient(QObject *parent)
+ : QObject(parent)
+ , d_ptr(new QWebEngineCookieStoreClientPrivate(this))
+{
+
+}
+
+/*!
+ Destroys this QWebEngineCookieStoreClient object.
+*/
+
+QWebEngineCookieStoreClient::~QWebEngineCookieStoreClient()
+{
+
+}
+
+/*!
+ \fn void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl())
+
+ Adds \a cookie to the cookie store. When the operation finishes, \a resultCallback will be executed
+ on the caller thread.
+ It is possible to provide an optional \a origin URL argument to limit the scope of the cookie.
+ The provided URL should also include the scheme.
+
+ \sa setCookie()
+*/
+
+void QWebEngineCookieStoreClient::setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ d->setCookie(resultCallback, cookie, origin);
+}
+
+/*!
+ Adds \a cookie to the cookie store. This function is provided for convenience and is
+ equivalent to calling setCookieWithCallback() with an empty callback.
+ It is possible to provide an optional \a origin URL argument to limit the scope of the cookie.
+ The provided URL should also include the scheme.
+
+ \sa setCookieWithCallback()
+*/
+
+void QWebEngineCookieStoreClient::setCookie(const QNetworkCookie &cookie, const QUrl &origin)
+{
+ setCookieWithCallback(cookie, QWebEngineCallback<bool>(), origin);
+}
+
+/*!
+ Deletes \a cookie from the cookie store.
+ It is possible to provide an optional \a origin URL argument to limit the scope of the
+ cookie to be deleted.
+ The provided URL should also include the scheme.
+*/
+
+void QWebEngineCookieStoreClient::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ d->deleteCookie(cookie, origin);
+}
+
+/*!
+ \fn void QWebEngineCookieStoreClient::getAllCookies(FunctorOrLambda resultCallback)
+
+ Requests all the cookies in the cookie store. When the asynchronous operation finishes,
+ \a resultCallback will be called with a QByteArray as the argument containing the cookies.
+ This QByteArray can be parsed using QNetworkCookie::parseCookies().
+
+ \sa deleteCookie()
+*/
+
+void QWebEngineCookieStoreClient::getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ if (d->m_getAllCookiesPending) {
+ d->callbackDirectory.invokeEmpty(resultCallback);
+ return;
+ }
+ d->callbackDirectory.registerCallback(CallbackDirectory::GetAllCookiesCallbackId, resultCallback);
+ d->getAllCookies();
+}
+
+/*!
+ \fn void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback)
+
+ Deletes all the session cookies in the cookie store. Session cookies do not have an
+ expiration date assigned to them.
+ When the asynchronous operation finishes, \a resultCallback will be called with the
+ number of cookies deleted as the argument.
+*/
+
+void QWebEngineCookieStoreClient::deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ if (d->m_deleteAllCookiesPending || d->m_deleteSessionCookiesPending) {
+ d->callbackDirectory.invokeEmpty(resultCallback);
+ return;
+ }
+ d->callbackDirectory.registerCallback(CallbackDirectory::DeleteSessionCookiesCallbackId, resultCallback);
+ d->deleteSessionCookies();
+}
+
+/*!
+ \fn void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(FunctorOrLambda resultCallback)
+
+ Deletes all the cookies in the cookie store. When the asynchronous operation finishes,
+ \a resultCallback will be called with the number of cookies deleted as the argument.
+
+ \sa deleteSessionCookiesWithCallback(), getAllCookies()
+*/
+
+void QWebEngineCookieStoreClient::deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback)
+{
+ Q_D(QWebEngineCookieStoreClient);
+ if (d->m_deleteAllCookiesPending) {
+ d->callbackDirectory.invokeEmpty(resultCallback);
+ return;
+ }
+ d->callbackDirectory.registerCallback(CallbackDirectory::DeleteAllCookiesCallbackId, resultCallback);
+ d->deleteAllCookies();
+}
+
+/*!
+ Deletes all the session cookies in the cookie store.
+
+ \sa deleteSessionCookiesWithCallback()
+*/
+
+void QWebEngineCookieStoreClient::deleteSessionCookies()
+{
+ deleteSessionCookiesWithCallback(QWebEngineCallback<int>());
+}
+
+/*!
+ Deletes all the cookies in the cookie store.
+
+ \sa deleteAllCookiesWithCallback(), getAllCookies()
+*/
+
+void QWebEngineCookieStoreClient::deleteAllCookies()
+{
+ deleteAllCookiesWithCallback(QWebEngineCallback<int>());
+}
+
+/*!
+ This virtual function is called before a new cookie is added to the cookie store.
+ By overriding this function and returning \c false the user can decide to deny
+ from \a firstPartyUrl the cookie \a cookieLine with the source \a cookieSource.
+ The request's \a firstPartyUrl can be used to identify a third-party cookie.
+ This function should not be used to execute heavy tasks since it is running on the
+ IO thread and therefore blocks the Chromium networking.
+*/
+
+bool QWebEngineCookieStoreClient::acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource)
+{
+ Q_UNUSED(firstPartyUrl);
+ Q_UNUSED(cookieLine);
+ Q_UNUSED(cookieSource);
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebenginecookiestoreclient.h b/src/core/api/qwebenginecookiestoreclient.h
new file mode 100644
index 000000000..3a6f54ea7
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECOOKIESTORECLIENT_H
+#define QWEBENGINECOOKIESTORECLIENT_H
+
+#include "qtwebenginecoreglobal.h"
+#include "qwebenginecallback.h"
+
+#include <QtCore/qobject.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qurl.h>
+#include <QtNetwork/qnetworkcookie.h>
+
+namespace QtWebEngineCore {
+class CookieMonsterDelegateQt;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineCookieStoreClientPrivate;
+class QWEBENGINE_EXPORT QWebEngineCookieStoreClient : public QObject {
+ Q_OBJECT
+public:
+ explicit QWebEngineCookieStoreClient(QObject *parent = 0);
+ virtual ~QWebEngineCookieStoreClient();
+
+#ifdef Q_QDOC
+ void setCookieWithCallback(const QNetworkCookie &cookie, FunctorOrLambda resultCallback, const QUrl &origin = QUrl());
+ void deleteSessionCookiesWithCallback(FunctorOrLambda resultCallback);
+ void deleteAllCookiesWithCallback(FunctorOrLambda resultCallback);
+ void getAllCookies(FunctorOrLambda resultCallback);
+#else
+ void setCookieWithCallback(const QNetworkCookie &cookie, const QWebEngineCallback<bool> &resultCallback, const QUrl &origin = QUrl());
+ void deleteSessionCookiesWithCallback(const QWebEngineCallback<int> &resultCallback);
+ void deleteAllCookiesWithCallback(const QWebEngineCallback<int> &resultCallback);
+ void getAllCookies(const QWebEngineCallback<const QByteArray&> &resultCallback);
+#endif
+ void setCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
+ void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin = QUrl());
+ void deleteSessionCookies();
+ void deleteAllCookies();
+
+ virtual bool acceptCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &cookieSource);
+
+Q_SIGNALS:
+ void cookieAdded(const QNetworkCookie &cookie);
+ void cookieRemoved(const QNetworkCookie &cookie);
+
+private:
+ friend class QtWebEngineCore::CookieMonsterDelegateQt;
+ Q_DISABLE_COPY(QWebEngineCookieStoreClient)
+ Q_DECLARE_PRIVATE(QWebEngineCookieStoreClient)
+ QScopedPointer<QWebEngineCookieStoreClientPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QWebEngineCookieStoreClient*)
+
+#endif // QWEBENGINECOOKIESTORECLIENT_H
diff --git a/src/core/api/qwebenginecookiestoreclient_p.h b/src/core/api/qwebenginecookiestoreclient_p.h
new file mode 100644
index 000000000..dbb49c81f
--- /dev/null
+++ b/src/core/api/qwebenginecookiestoreclient_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINECOOKIESTORECLIENT_P_H
+#define QWEBENGINECOOKIESTORECLIENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include "cookie_monster_delegate_qt.h"
+#include "qwebenginecallback_p.h"
+#include "qwebenginecookiestoreclient.h"
+
+#include <QList>
+#include <QMap>
+#include <QNetworkCookie>
+#include <QUrl>
+
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINE_PRIVATE_EXPORT QWebEngineCookieStoreClientPrivate {
+ struct CookieData {
+ quint64 callbackId;
+ QNetworkCookie cookie;
+ QUrl origin;
+ };
+
+public:
+ Q_DECLARE_PUBLIC(QWebEngineCookieStoreClient)
+ QtWebEngineCore::CallbackDirectory callbackDirectory;
+ QList<CookieData> m_pendingUserCookies;
+ quint64 m_nextCallbackId;
+ bool m_deleteSessionCookiesPending;
+ bool m_deleteAllCookiesPending;
+ bool m_getAllCookiesPending;
+
+ QtWebEngineCore::CookieMonsterDelegateQt *delegate;
+ QWebEngineCookieStoreClient *q_ptr;
+
+ QWebEngineCookieStoreClientPrivate(QWebEngineCookieStoreClient *q);
+ ~QWebEngineCookieStoreClientPrivate();
+
+ void processPendingUserCookies();
+ void setCookie(const QWebEngineCallback<bool> &callback, const QNetworkCookie &cookie, const QUrl &origin);
+ void deleteCookie(const QNetworkCookie &cookie, const QUrl &url);
+ void deleteSessionCookies();
+ void deleteAllCookies();
+ void getAllCookies();
+
+ bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url);
+
+ void onGetAllCallbackResult(qint64 callbackId, const QByteArray &cookieList);
+ void onSetCallbackResult(qint64 callbackId, bool success);
+ void onDeleteCallbackResult(qint64 callbackId, int numCookies);
+ void onCookieChanged(const QNetworkCookie &cookie, bool removed);
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINECOOKIESTORECLIENT_P_H
diff --git a/src/core/api/qwebengineurlrequestinfo.cpp b/src/core/api/qwebengineurlrequestinfo.cpp
new file mode 100644
index 000000000..b769081f8
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestinfo.cpp
@@ -0,0 +1,265 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwebengineurlrequestinfo.h"
+#include "qwebengineurlrequestinfo_p.h"
+
+#include "content/public/common/resource_type.h"
+
+#include "web_contents_adapter_client.h"
+
+QT_BEGIN_NAMESPACE
+
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMainFrame, content::RESOURCE_TYPE_MAIN_FRAME)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubFrame, content::RESOURCE_TYPE_SUB_FRAME)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeStylesheet, content::RESOURCE_TYPE_STYLESHEET)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeScript, content::RESOURCE_TYPE_SCRIPT)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeImage, content::RESOURCE_TYPE_IMAGE)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFontResource, content::RESOURCE_TYPE_FONT_RESOURCE)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSubResource, content::RESOURCE_TYPE_SUB_RESOURCE)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeObject, content::RESOURCE_TYPE_OBJECT)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeMedia, content::RESOURCE_TYPE_MEDIA)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeWorker, content::RESOURCE_TYPE_WORKER)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeSharedWorker, content::RESOURCE_TYPE_SHARED_WORKER)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePrefetch, content::RESOURCE_TYPE_PREFETCH)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeFavicon, content::RESOURCE_TYPE_FAVICON)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeXhr, content::RESOURCE_TYPE_XHR)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypePing, content::RESOURCE_TYPE_PING)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeServiceWorker, content::RESOURCE_TYPE_SERVICE_WORKER)
+ASSERT_ENUMS_MATCH(QWebEngineUrlRequestInfo::ResourceTypeUnknown, content::RESOURCE_TYPE_LAST_TYPE)
+
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::LinkNavigation, QWebEngineUrlRequestInfo::NavigationTypeLink)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::TypedNavigation, QWebEngineUrlRequestInfo::NavigationTypeTyped)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::FormSubmittedNavigation, QWebEngineUrlRequestInfo::NavigationTypeFormSubmitted)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::BackForwardNavigation, QWebEngineUrlRequestInfo::NavigationTypeBackForward)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::ReloadNavigation, QWebEngineUrlRequestInfo::NavigationTypeReload)
+ASSERT_ENUMS_MATCH(QtWebEngineCore::WebContentsAdapterClient::OtherNavigation, QWebEngineUrlRequestInfo::NavigationTypeOther)
+
+/*!
+ \class QWebEngineUrlRequestInfo
+ \inmodule QtWebEngineCore
+ \since 5.6
+ \brief The QWebEngineUrlRequestInfo class provides information about URL requests.
+
+ The QWebEngineUrlRequestInfo is useful for setting extra header fields for requests
+ or for redirecting certain requests without payload data to another URL.
+ This class cannot be instantiated or copied by the user, instead it will
+ be created by Qt WebEngine and sent through the virtual function
+ QWebEngineUrlRequestInterceptor::interceptRequest() if an interceptor has been set.
+*/
+
+/*!
+ \class QWebEngineUrlRequestInterceptor
+ \inmodule QtWebEngineCore
+ \since 5.6
+ \brief The QWebEngineUrlRequestInterceptor class provides an abstract base class for URL interception.
+
+ Implementing the \l{QWebEngineUrlRequestInterceptor} interface and installing the
+ interceptor on the profile enables intercepting, blocking, and modifying URL requests
+ before they reach the networking stack of Chromium.
+
+ \sa QWebEngineUrlRequestInterceptor::interceptRequest, QWebEngineUrlRequestInfo
+*/
+
+/*!
+ \fn QWebEngineUrlRequestInterceptor::QWebEngineUrlRequestInterceptor(QObject * p = 0)
+
+ Creates a new QWebEngineUrlRequestInterceptor object with \a p as parent.
+*/
+
+/*!
+ \fn QWebEngineUrlRequestInterceptor::~QWebEngineUrlRequestInterceptor()
+
+ Destroys this QWebEngineUrlRequestInterceptor object.
+*/
+
+/*!
+ \fn bool QWebEngineUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
+
+ Reimplementing this virtual function and setting the interceptor on a profile makes
+ it possible to intercept URL requests. This function is executed on the IO thread,
+ and therefore running long tasks here will block networking.
+ If this function is only used for inspection, it should return \c false, in which
+ case any modification to \a info will be ignored.
+
+ \sa QWebEngineProfile::setRequestInterceptor
+*/
+
+
+QWebEngineUrlRequestInfoPrivate::QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource, QWebEngineUrlRequestInfo::NavigationType navigation, const QUrl &u, const QByteArray &m)
+ : resourceType(resource)
+ , navigationType(navigation)
+ , shouldBlockRequest(false)
+ , url(u)
+ , method(m)
+{
+}
+
+/*!
+ \internal
+*/
+
+QWebEngineUrlRequestInfo::~QWebEngineUrlRequestInfo()
+{
+
+}
+
+/*!
+ \internal
+*/
+
+QWebEngineUrlRequestInfo::QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPrivate *p)
+ : d_ptr(p)
+{
+ d_ptr->q_ptr = this;
+}
+
+/*!
+ \enum QWebEngineUrlRequestInfo::ResourceType
+
+ This enum type holds the type of the requested resource:
+
+ \value ResourceTypeMainFrame Top level page.
+ \value ResourceTypeSubFrame Frame or iframe.
+ \value ResourceTypeStylesheet A CSS stylesheet.
+ \value ResourceTypeScript An external script.
+ \value ResourceTypeImage An image (JPG, GIF, PNG, and so on).
+ \value ResourceTypeFontResource A font.
+ \value ResourceTypeSubResource An "other" subresource.
+ \value ResourceTypeObject An object (or embed) tag for a plugin or a resource that a plugin requested.
+ \value ResourceTypeMedia A media resource.
+ \value ResourceTypeWorker The main resource of a dedicated worker.
+ \value ResourceTypeSharedWorker The main resource of a shared worker.
+ \value ResourceTypePrefetch An explicitly requested prefetch.
+ \value ResourceTypeFavicon A favicon.
+ \value ResourceTypeXhr An XMLHttpRequest.
+ \value ResourceTypePing A ping request for <a ping>.
+ \value ResourceTypeServiceWorker The main resource of a service worker.
+ \value ResourceTypeUnknown Unknown request type.
+*/
+
+/*!
+ Returns the resource type of the request.
+
+ \sa QWebEngineUrlRequestInfo::ResourceType
+*/
+
+QWebEngineUrlRequestInfo::ResourceType QWebEngineUrlRequestInfo::resourceType() const
+{
+ Q_D(const QWebEngineUrlRequestInfo);
+ return d->resourceType;
+}
+
+/*!
+ \enum QWebEngineUrlRequestInfo::NavigationType
+
+ This enum type describes the navigation type of the request:
+
+ \value NavigationTypeLink Navigation initiated by clicking a link.
+ \value NavigationTypeTyped Navigation explicitly initiated by typing a URL.
+ \value NavigationTypeFormSubmitted Navigation submits a form.
+ \value NavigationTypeBackForward Navigation initiated by a history action.
+ \value NavigationTypeReload Navigation initiated by refreshing the page.
+ \value NavigationTypeOther None of the above.
+*/
+
+/*!
+ Returns the navigation type of the request.
+
+ \sa QWebEngineUrlRequestInfo::NavigationType
+*/
+
+QWebEngineUrlRequestInfo::NavigationType QWebEngineUrlRequestInfo::navigationType() const
+{
+ Q_D(const QWebEngineUrlRequestInfo);
+ return d->navigationType;
+}
+
+/*!
+ Returns the requested URL.
+*/
+
+QUrl QWebEngineUrlRequestInfo::requestUrl() const
+{
+ Q_D(const QWebEngineUrlRequestInfo);
+ return d->url;
+}
+
+
+/*!
+ Returns the HTTP method of the request (for example, GET or POST).
+*/
+
+QByteArray QWebEngineUrlRequestInfo::requestMethod() const
+{
+ Q_D(const QWebEngineUrlRequestInfo);
+ return d->method;
+}
+
+/*!
+ Redirects this request to \a url.
+ It is only possible to redirect requests that do not have payload data, such as GET requests.
+*/
+
+void QWebEngineUrlRequestInfo::redirect(const QUrl &url)
+{
+ Q_D(QWebEngineUrlRequestInfo);
+ d->url = url;
+}
+
+/*!
+ Blocks this request if \a shouldBlock is true, so that it will not proceed.
+
+ This function can be used to prevent navigating away from a given domain, for example.
+*/
+
+void QWebEngineUrlRequestInfo::block(bool shouldBlock)
+{
+ Q_D(QWebEngineUrlRequestInfo);
+ d->shouldBlockRequest = shouldBlock;
+}
+
+/*!
+ Sets an extra request header for this request with \a name and \a value.
+*/
+
+void QWebEngineUrlRequestInfo::setExtraHeader(const QByteArray &name, const QByteArray &value)
+{
+ Q_D(QWebEngineUrlRequestInfo);
+ d->extraHeaders.insert(name, value);
+}
+
+QT_END_NAMESPACE
diff --git a/src/core/api/qwebengineurlrequestinfo.h b/src/core/api/qwebengineurlrequestinfo.h
new file mode 100644
index 000000000..7c016d20d
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestinfo.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEURLREQUESTINFO_H
+#define QWEBENGINEURLREQUESTINFO_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qurl.h>
+
+namespace QtWebEngineCore {
+class NetworkDelegateQt;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineUrlRequestInfoPrivate;
+
+class QWEBENGINE_EXPORT QWebEngineUrlRequestInfo {
+public:
+ enum ResourceType {
+ ResourceTypeMainFrame = 0, // top level page
+ ResourceTypeSubFrame, // frame or iframe
+ ResourceTypeStylesheet, // a CSS stylesheet
+ ResourceTypeScript, // an external script
+ ResourceTypeImage, // an image (jpg/gif/png/etc)
+ ResourceTypeFontResource, // a font
+ ResourceTypeSubResource, // an "other" subresource.
+ ResourceTypeObject, // an object (or embed) tag for a plugin,
+ // or a resource that a plugin requested.
+ ResourceTypeMedia, // a media resource.
+ ResourceTypeWorker, // the main resource of a dedicated worker.
+ ResourceTypeSharedWorker, // the main resource of a shared worker.
+ ResourceTypePrefetch, // an explicitly requested prefetch
+ ResourceTypeFavicon, // a favicon
+ ResourceTypeXhr, // a XMLHttpRequest
+ ResourceTypePing, // a ping request for <a ping>
+ ResourceTypeServiceWorker, // the main resource of a service worker.
+ ResourceTypeUnknown
+ };
+
+ enum NavigationType {
+ NavigationTypeLink,
+ NavigationTypeTyped,
+ NavigationTypeFormSubmitted,
+ NavigationTypeBackForward,
+ NavigationTypeReload,
+ NavigationTypeOther
+ };
+
+ ResourceType resourceType() const;
+ NavigationType navigationType() const;
+
+ QUrl requestUrl() const;
+ QByteArray requestMethod() const;
+
+ void block(bool shouldBlock);
+ void redirect(const QUrl &url);
+ void setExtraHeader(const QByteArray &name, const QByteArray &value);
+
+private:
+ friend class QtWebEngineCore::NetworkDelegateQt;
+ Q_DISABLE_COPY(QWebEngineUrlRequestInfo)
+ Q_DECLARE_PRIVATE(QWebEngineUrlRequestInfo)
+
+ QWebEngineUrlRequestInfo(QWebEngineUrlRequestInfoPrivate *p);
+ ~QWebEngineUrlRequestInfo();
+ QScopedPointer<QWebEngineUrlRequestInfoPrivate> d_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEURLREQUESTINFO_H
diff --git a/src/core/api/qwebengineurlrequestinfo_p.h b/src/core/api/qwebengineurlrequestinfo_p.h
new file mode 100644
index 000000000..b6a304a03
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestinfo_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENGINEURLREQUESTINFO_P_H
+#define QWEBENGINEURLREQUESTINFO_P_H
+
+#include "qtwebenginecoreglobal_p.h"
+
+#include "qwebengineurlrequestinfo.h"
+
+#include <QByteArray>
+#include <QHash>
+#include <QUrl>
+
+namespace net {
+class URLRequest;
+}
+
+QT_BEGIN_NAMESPACE
+
+class QWebEngineUrlRequestInfoPrivate
+{
+ Q_DECLARE_PUBLIC(QWebEngineUrlRequestInfo)
+public:
+ QWebEngineUrlRequestInfoPrivate(QWebEngineUrlRequestInfo::ResourceType resource
+ , QWebEngineUrlRequestInfo::NavigationType navigation
+ , const QUrl &u
+ , const QByteArray &m);
+
+ QWebEngineUrlRequestInfo::ResourceType resourceType;
+ QWebEngineUrlRequestInfo::NavigationType navigationType;
+ bool shouldBlockRequest;
+
+ QUrl url;
+ const QByteArray method;
+ QHash<QByteArray, QByteArray> extraHeaders;
+
+ QWebEngineUrlRequestInfo *q_ptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENGINEURLREQUESTINFO_P_H
diff --git a/src/core/api/qwebengineurlrequestinterceptor.h b/src/core/api/qwebengineurlrequestinterceptor.h
new file mode 100644
index 000000000..72f3452d0
--- /dev/null
+++ b/src/core/api/qwebengineurlrequestinterceptor.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWEBENINGEURLREQUESTINTERCEPTOR_H
+#define QWEBENINGEURLREQUESTINTERCEPTOR_H
+
+#include "qtwebenginecoreglobal.h"
+#include "qwebengineurlrequestinfo.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QWEBENGINE_EXPORT QWebEngineUrlRequestInterceptor : public QObject
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(QWebEngineUrlRequestInterceptor)
+public:
+ explicit QWebEngineUrlRequestInterceptor(QObject *p = 0)
+ : QObject (p)
+ {
+ }
+ virtual ~QWebEngineUrlRequestInterceptor()
+ {
+ }
+
+ virtual bool interceptRequest(QWebEngineUrlRequestInfo &info) = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWEBENINGEURLREQUESTINTERCEPTOR_H
diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp b/src/core/api/qwebengineurlrequestjob.cpp
index 2bff57236..d9f3833b9 100644
--- a/src/webenginewidgets/api/qwebengineurlrequestjob.cpp
+++ b/src/core/api/qwebengineurlrequestjob.cpp
@@ -34,9 +34,7 @@
**
****************************************************************************/
-#include "qwebengineurlrequestjob_p.h"
-
-#include "qwebengineprofile.h"
+#include "qwebengineurlrequestjob.h"
#include "url_request_custom_job_delegate.h"
@@ -47,19 +45,18 @@ QT_BEGIN_NAMESPACE
/*!
\class QWebEngineUrlRequestJob
\brief The QWebEngineUrlRequestJob class represents a custom URL request.
- \since 5.5
- \internal
+ \since 5.6
A QWebEngineUrlRequestJob is given to QWebEngineUrlSchemeHandler::requestStarted() and must
- be handled by the derived implementations of class.
+ be handled by the derived implementations of the class.
- A job can be handled by calling either setReply(), redirect() or setError().
+ A job can be handled by calling either reply(), redirect() or fail().
The class is owned by QtWebEngine and does not need to be deleted. Note QtWebEngine may delete
the job when it is no longer needed, so the signal QObject::destroyed() must be monitored if
a pointer to the object is stored.
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
*/
/*!
@@ -79,17 +76,25 @@ QWebEngineUrlRequestJob::~QWebEngineUrlRequestJob()
}
/*!
- Returns the url requested.
- */
+ Returns the requested URL.
+*/
QUrl QWebEngineUrlRequestJob::requestUrl() const
{
return d_ptr->url();
}
/*!
- Sets the reply for the request to \a device with the mime-type \a contentType.
+ Returns the HTTP method of the request (for example, GET or POST).
+*/
+QByteArray QWebEngineUrlRequestJob::requestMethod() const
+{
+ return d_ptr->method();
+}
+
+/*!
+ Replies the request with \a device with the mime-type \a contentType.
*/
-void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice *device)
+void QWebEngineUrlRequestJob::reply(const QByteArray &contentType, QIODevice *device)
{
d_ptr->setReply(contentType, device);
}
@@ -97,7 +102,7 @@ void QWebEngineUrlRequestJob::setReply(const QByteArray &contentType, QIODevice
/*!
Fails the request with error \a error.
*/
-void QWebEngineUrlRequestJob::setError(Error r)
+void QWebEngineUrlRequestJob::fail(Error r)
{
d_ptr->fail((URLRequestCustomJobDelegate::Error)r);
}
@@ -105,7 +110,7 @@ void QWebEngineUrlRequestJob::setError(Error r)
/*!
Tell the request is redirected to \a url.
*/
-void QWebEngineUrlRequestJob::setRedirect(const QUrl &url)
+void QWebEngineUrlRequestJob::redirect(const QUrl &url)
{
d_ptr->redirect(url);
}
diff --git a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h b/src/core/api/qwebengineurlrequestjob.h
index 32e2498fa..098d46c93 100644
--- a/src/webenginewidgets/api/qwebengineurlrequestjob_p.h
+++ b/src/core/api/qwebengineurlrequestjob.h
@@ -48,11 +48,11 @@
// We mean it.
//
-#include "qtwebenginewidgetsglobal.h"
+#include "qtwebenginecoreglobal.h"
-#include <QtCore/QByteArray>
-#include <QtCore/QObject>
-#include <QtCore/QUrl>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qurl.h>
namespace QtWebEngineCore {
class URLRequestCustomJobDelegate;
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QIODevice;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineUrlRequestJob : public QObject {
+class QWEBENGINE_EXPORT QWebEngineUrlRequestJob : public QObject {
Q_OBJECT
public:
~QWebEngineUrlRequestJob();
@@ -75,11 +75,14 @@ public:
RequestDenied,
RequestFailed
};
+ Q_ENUM(Error)
QUrl requestUrl() const;
- void setReply(const QByteArray &contentType, QIODevice *device);
- void setError(Error error);
- void setRedirect(const QUrl &url);
+ QByteArray requestMethod() const;
+
+ void reply(const QByteArray &contentType, QIODevice *device);
+ void fail(Error error);
+ void redirect(const QUrl &url);
private:
QWebEngineUrlRequestJob(QtWebEngineCore::URLRequestCustomJobDelegate *);
diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp b/src/core/api/qwebengineurlschemehandler.cpp
index a0e751c24..330648893 100644
--- a/src/webenginewidgets/api/qwebengineurlschemehandler.cpp
+++ b/src/core/api/qwebengineurlschemehandler.cpp
@@ -34,36 +34,28 @@
**
****************************************************************************/
+#include "qwebengineurlschemehandler.h"
#include "qwebengineurlschemehandler_p.h"
-#include "qwebengineurlschemehandler_p_p.h"
-#include "qwebengineprofile.h"
-#include "qwebengineprofile_p.h"
-#include "qwebengineurlrequestjob_p.h"
+#include "qwebengineurlrequestjob.h"
QT_BEGIN_NAMESPACE
/*!
\class QWebEngineUrlSchemeHandler
- \brief The QWebEngineUrlSchemeHandler Base class for handling custom URL schemes.
- \since 5.5
- \internal
+ \brief The QWebEngineUrlSchemeHandler base class for handling custom URL schemes.
+ \since 5.6
To implement a custom URL scheme for QtWebEngine you must write a class derived from this class,
and reimplement requestStarted().
- To install a custom URL scheme handler into a QtWebProfile, you only need to call the constructor
- with the correct profile. Each instance of a QWebEngineUrlSchemeHandler can only handle requests
- from a single profile.
-
- \inmodule QtWebEngineWidgets
+ \inmodule QtWebEngineCore
*/
-QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q, QWebEngineProfile *profile)
+QWebEngineUrlSchemeHandlerPrivate::QWebEngineUrlSchemeHandlerPrivate(const QByteArray &scheme, QWebEngineUrlSchemeHandler *q)
: CustomUrlSchemeHandler(scheme)
, q_ptr(q)
- , m_profile(profile)
{
}
@@ -81,20 +73,18 @@ bool QWebEngineUrlSchemeHandlerPrivate::handleJob(QtWebEngineCore::URLRequestCus
/*!
Constructs a new URL scheme handler.
- The handler is created for \a scheme and for the \a profile.
+ The handler is created for \a scheme with the parent \a parent.
*/
-QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QWebEngineProfile *profile, QObject *parent)
+QWebEngineUrlSchemeHandler::QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent)
: QObject(parent)
- , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this, profile))
+ , d_ptr(new QWebEngineUrlSchemeHandlerPrivate(scheme, this))
{
- profile->d_func()->installUrlSchemeHandler(this);
}
QWebEngineUrlSchemeHandler::~QWebEngineUrlSchemeHandler()
{
- if (d_ptr->m_profile)
- d_ptr->m_profile->d_func()->removeUrlSchemeHandler(this);
+ delete d_ptr;
}
/*!
@@ -108,7 +98,7 @@ QByteArray QWebEngineUrlSchemeHandler::scheme() const
/*!
\fn void QWebEngineUrlSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
- This method is called whenever a request for the registered scheme is started.
+ This method is called whenever a request \a request for the registered scheme is started.
This method must be reimplemented by all custom URL scheme handlers.
The request is asynchronous and does not need to be handled right away.
diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler_p.h b/src/core/api/qwebengineurlschemehandler.h
index 7de87dff2..b6f6a69f0 100644
--- a/src/webenginewidgets/api/qwebengineurlschemehandler_p.h
+++ b/src/core/api/qwebengineurlschemehandler.h
@@ -37,45 +37,32 @@
#ifndef QWEBENGINEURLSCHEMEHANDLER_H
#define QWEBENGINEURLSCHEMEHANDLER_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#include "qtwebenginecoreglobal.h"
-#include "qtwebenginewidgetsglobal.h"
-
-#include <QtCore/QByteArray>
-#include <QtCore/QIODevice>
-#include <QtCore/QObject>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QUrl>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
-class QWebEngineProfile;
class QWebEngineUrlRequestJob;
class QWebEngineUrlSchemeHandlerPrivate;
-class QWEBENGINEWIDGETS_EXPORT QWebEngineUrlSchemeHandler : public QObject {
+class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandler : public QObject {
Q_OBJECT
public:
- QWebEngineUrlSchemeHandler(const QByteArray &scheme, QWebEngineProfile *profile, QObject *parent = 0);
- virtual ~QWebEngineUrlSchemeHandler();
+ QWebEngineUrlSchemeHandler(const QByteArray &scheme, QObject *parent = 0);
+ ~QWebEngineUrlSchemeHandler();
QByteArray scheme() const;
virtual void requestStarted(QWebEngineUrlRequestJob*) = 0;
private:
+ Q_DISABLE_COPY(QWebEngineUrlSchemeHandler)
Q_DECLARE_PRIVATE(QWebEngineUrlSchemeHandler)
- friend class QWebEngineProfilePrivate;
- QScopedPointer<QWebEngineUrlSchemeHandlerPrivate> d_ptr;
+ friend class QWebEngineProfile;
+ friend class QQuickWebEngineProfile;
+ QWebEngineUrlSchemeHandlerPrivate *d_ptr;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h b/src/core/api/qwebengineurlschemehandler_p.h
index d349d7d8c..dc4b272b3 100644
--- a/src/webenginewidgets/api/qwebengineurlschemehandler_p_p.h
+++ b/src/core/api/qwebengineurlschemehandler_p.h
@@ -48,30 +48,27 @@
// We mean it.
//
-#include "qwebengineurlschemehandler_p.h"
+#include "qwebengineurlschemehandler.h"
#include "custom_url_scheme_handler.h"
-#include <QPointer>
-
QT_BEGIN_NAMESPACE
class QWebEngineProfile;
class QWebEngineUrlRequestJob;
class QWebEngineUrlSchemeHandler;
-class QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler {
+class QWEBENGINE_EXPORT QWebEngineUrlSchemeHandlerPrivate : public QtWebEngineCore::CustomUrlSchemeHandler {
public:
Q_DECLARE_PUBLIC(QWebEngineUrlSchemeHandler)
- QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *, QWebEngineProfile *);
+ QWebEngineUrlSchemeHandlerPrivate(const QByteArray &, QWebEngineUrlSchemeHandler *);
virtual ~QWebEngineUrlSchemeHandlerPrivate();
virtual bool handleJob(QtWebEngineCore::URLRequestCustomJobDelegate*) Q_DECL_OVERRIDE;
private:
QWebEngineUrlSchemeHandler *q_ptr;
- QPointer<QWebEngineProfile> m_profile;
};
QT_END_NAMESPACE
diff --git a/src/core/authentication_dialog_controller.cpp b/src/core/authentication_dialog_controller.cpp
new file mode 100644
index 000000000..db534a24e
--- /dev/null
+++ b/src/core/authentication_dialog_controller.cpp
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "authentication_dialog_controller.h"
+#include "authentication_dialog_controller_p.h"
+
+#include "content/public/browser/browser_thread.h"
+
+namespace QtWebEngineCore {
+
+AuthenticationDialogControllerPrivate::AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate)
+ : loginDelegate(loginDelegate)
+{
+}
+
+void AuthenticationDialogControllerPrivate::dialogFinished(bool accepted, const QString &user, const QString &password)
+{
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO, FROM_HERE,
+ base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, loginDelegate, accepted, user, password));
+}
+
+AuthenticationDialogController::AuthenticationDialogController(AuthenticationDialogControllerPrivate *dd)
+{
+ Q_ASSERT(dd);
+ d.reset(dd);
+}
+
+AuthenticationDialogController::~AuthenticationDialogController()
+{
+}
+
+QUrl AuthenticationDialogController::url() const
+{
+ return d->loginDelegate->url();
+}
+
+QString AuthenticationDialogController::realm() const
+{
+ return d->loginDelegate->realm();
+}
+
+QString AuthenticationDialogController::host() const
+{
+ return d->loginDelegate->host();
+}
+
+bool AuthenticationDialogController::isProxy() const
+{
+ return d->loginDelegate->isProxy();
+}
+
+void AuthenticationDialogController::accept(const QString &user, const QString &password)
+{
+ d->dialogFinished(true, user, password);
+}
+
+void AuthenticationDialogController::reject()
+{
+ d->dialogFinished(false);
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/authentication_dialog_controller.h b/src/core/authentication_dialog_controller.h
new file mode 100644
index 000000000..ae741f537
--- /dev/null
+++ b/src/core/authentication_dialog_controller.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUTHENTICATION_DIALOG_CONTROLLER_H
+#define AUTHENTICATION_DIALOG_CONTROLLER_H
+
+#include "qtwebenginecoreglobal.h"
+
+#include <QObject>
+
+namespace QtWebEngineCore {
+
+class AuthenticationDialogControllerPrivate;
+
+class QWEBENGINE_EXPORT AuthenticationDialogController : public QObject {
+ Q_OBJECT
+public:
+ ~AuthenticationDialogController();
+
+ QUrl url() const;
+ QString realm() const;
+ QString host() const;
+ bool isProxy() const;
+
+public Q_SLOTS:
+ void accept(const QString &user, const QString &password);
+ void reject();
+
+private:
+ AuthenticationDialogController(AuthenticationDialogControllerPrivate *);
+
+ QScopedPointer<AuthenticationDialogControllerPrivate> d;
+ friend class ResourceDispatcherHostLoginDelegateQt;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // AUTHENTICATION_DIALOG_CONTROLLER_H
diff --git a/src/core/authentication_dialog_controller_p.h b/src/core/authentication_dialog_controller_p.h
new file mode 100644
index 000000000..5b1d21ae0
--- /dev/null
+++ b/src/core/authentication_dialog_controller_p.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef AUTHENTICATION_DIALOG_CONTROLLER_P_H
+#define AUTHENTICATION_DIALOG_CONTROLLER_P_H
+
+#include "base/memory/ref_counted.h"
+#include "resource_dispatcher_host_delegate_qt.h"
+
+namespace QtWebEngineCore {
+
+class AuthenticationDialogControllerPrivate {
+
+public:
+ AuthenticationDialogControllerPrivate(ResourceDispatcherHostLoginDelegateQt *loginDelegate);
+ void dialogFinished(bool accepted, const QString &user = QString(), const QString &password = QString());
+
+ scoped_refptr<ResourceDispatcherHostLoginDelegateQt> loginDelegate;
+};
+
+} // namespace QtWebEngineCore
+
+#endif // AUTHENTICATION_DIALOG_CONTROLLER_H
diff --git a/src/core/browser_accessibility_qt.cpp b/src/core/browser_accessibility_qt.cpp
index 7cd5ac21f..ebf99e950 100644
--- a/src/core/browser_accessibility_qt.cpp
+++ b/src/core/browser_accessibility_qt.cpp
@@ -46,7 +46,7 @@
#include "ui/accessibility/ax_node_data.h"
#include "browser_accessibility_manager_qt.h"
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include "type_conversion.h"
using namespace blink;
@@ -86,19 +86,19 @@ void BrowserAccessibilityQt::OnDataChanged()
// always returns the primary name in "name" and the secondary name,
// if any, in "description".
- int title_elem_id = GetIntAttribute(
- ui::AX_ATTR_TITLE_UI_ELEMENT);
- std::string help = GetStringAttribute(ui::AX_ATTR_HELP);
- std::string description = GetStringAttribute(
- ui::AX_ATTR_DESCRIPTION);
+ int title_elem_id = GetIntAttribute(ui::AX_ATTR_TITLE_UI_ELEMENT);
+ base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME);
+ base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
+ base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP);
+ base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE);
// WebKit annoyingly puts the title in the description if there's no other
// description, which just confuses the rest of the logic. Put it back.
// Now "help" is always the value of the "title" attribute, if present.
- std::string title_attr;
+ base::string16 title_attr;
if (GetHtmlAttribute("title", &title_attr) &&
- description == title_attr &&
- help.empty()) {
+ description == title_attr &&
+ help.empty()) {
help = description;
description.clear();
}
@@ -107,32 +107,34 @@ void BrowserAccessibilityQt::OnDataChanged()
// it's nonempty, and the help should become the description if
// there's no description - or the name if there's no name or description.
if (!description.empty()) {
- set_name(description);
+ name = description;
description.clear();
}
if (!help.empty() && description.empty()) {
description = help;
help.clear();
}
- if (!description.empty() && name().empty() && !title_elem_id) {
- set_name(description);
+ if (!description.empty() && name.empty() && !title_elem_id) {
+ name = description;
description.clear();
}
// If it's a text field, also consider the placeholder.
- std::string placeholder;
+ base::string16 placeholder;
if (GetRole() == ui::AX_ROLE_TEXT_FIELD &&
- HasState(ui::AX_STATE_FOCUSABLE) &&
- GetHtmlAttribute("placeholder", &placeholder)) {
- if (name().empty() && !title_elem_id) {
- set_name(placeholder);
+ HasState(ui::AX_STATE_FOCUSABLE) &&
+ GetHtmlAttribute("placeholder", &placeholder)) {
+ if (name.empty() && !title_elem_id) {
+ name = placeholder;
} else if (description.empty()) {
description = placeholder;
}
}
- SetStringAttribute(ui::AX_ATTR_DESCRIPTION, description);
- SetStringAttribute(ui::AX_ATTR_HELP, help);
+ m_name = toQt(name);
+ m_description = toQt(description);
+ m_help = toQt(help);
+ m_value = toQt(value);
}
bool BrowserAccessibilityQt::isValid() const
@@ -227,13 +229,13 @@ QString BrowserAccessibilityQt::text(QAccessible::Text t) const
{
switch (t) {
case QAccessible::Name:
- return toQt(name());
+ return name();
case QAccessible::Description:
- return toQt(GetStringAttribute(ui::AX_ATTR_DESCRIPTION));
+ return description();
case QAccessible::Help:
- return toQt(GetStringAttribute(ui::AX_ATTR_HELP));
+ return help();
case QAccessible::Value:
- return toQt(GetStringAttribute(ui::AX_ATTR_VALUE));
+ return value();
case QAccessible::Accelerator:
return toQt(GetStringAttribute(ui::AX_ATTR_SHORTCUT));
default:
@@ -277,10 +279,10 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Document; // returning Application here makes Qt return the top level app object
case ui::AX_ROLE_ARTICLE:
return QAccessible::Section;
- case ui::AX_ROLE_BROWSER:
- return QAccessible::Document; // FIXME
case ui::AX_ROLE_BANNER:
return QAccessible::Section;
+ case ui::AX_ROLE_BLOCKQUOTE:
+ return QAccessible::Section;
case ui::AX_ROLE_BUSY_INDICATOR:
return QAccessible::Animation; // FIXME
case ui::AX_ROLE_BUTTON:
@@ -325,10 +327,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Section;
case ui::AX_ROLE_DOCUMENT:
return QAccessible::Document;
- case ui::AX_ROLE_DRAWER:
- return QAccessible::Client; // FIXME
- case ui::AX_ROLE_EDITABLE_TEXT:
- return QAccessible::EditableText;
case ui::AX_ROLE_EMBEDDED_OBJECT:
return QAccessible::Grouping; // FIXME
case ui::AX_ROLE_FOOTER:
@@ -339,14 +337,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Table;
case ui::AX_ROLE_GROUP:
return QAccessible::Grouping;
- case ui::AX_ROLE_GROW_AREA:
- return QAccessible::Grip;
case ui::AX_ROLE_HEADING:
return QAccessible::Heading;
- case ui::AX_ROLE_HELP_TAG:
- return QAccessible::HelpBalloon; // FIXME
- case ui::AX_ROLE_HORIZONTAL_RULE:
- return QAccessible::Separator;
case ui::AX_ROLE_IFRAME:
return QAccessible::Grouping;
case ui::AX_ROLE_IGNORED:
@@ -357,8 +349,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Graphic;
case ui::AX_ROLE_IMAGE_MAP_LINK:
return QAccessible::Link;
- case ui::AX_ROLE_INCREMENTOR:
- return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_INLINE_TEXT_BOX:
return QAccessible::EditableText;
case ui::AX_ROLE_LABEL_TEXT:
@@ -387,8 +377,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_MATH:
return QAccessible::Equation;
- case ui::AX_ROLE_MATTE:
- return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_MENU:
return QAccessible::PopupMenu;
case ui::AX_ROLE_MENU_BAR:
@@ -413,6 +401,8 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Paragraph;
case ui::AX_ROLE_POP_UP_BUTTON:
return QAccessible::ComboBox;
+ case ui::AX_ROLE_PRE:
+ return QAccessible::Section;
case ui::AX_ROLE_PRESENTATIONAL:
return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_PROGRESS_INDICATOR:
@@ -429,8 +419,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::RowHeader;
case ui::AX_ROLE_RULER:
return QAccessible::NoRole; // FIXME
- case ui::AX_ROLE_RULER_MARKER:
- return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_SCROLL_AREA:
return QAccessible::Client; // FIXME
case ui::AX_ROLE_SCROLL_BAR:
@@ -439,8 +427,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_SEARCH:
return QAccessible::Section;
- case ui::AX_ROLE_SHEET:
- return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_SLIDER:
return QAccessible::Slider;
case ui::AX_ROLE_SLIDER_THUMB:
@@ -451,16 +437,12 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_SPLITTER:
return QAccessible::Splitter;
- case ui::AX_ROLE_SPLIT_GROUP:
- return QAccessible::Splitter;
case ui::AX_ROLE_STATIC_TEXT:
return QAccessible::StaticText;
case ui::AX_ROLE_STATUS:
return QAccessible::StatusBar;
case ui::AX_ROLE_SVG_ROOT:
return QAccessible::Graphic;
- case ui::AX_ROLE_SYSTEM_WIDE:
- return QAccessible::NoRole; // FIXME
case ui::AX_ROLE_TABLE:
return QAccessible::Table;
case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
@@ -473,8 +455,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::PageTabList;
case ui::AX_ROLE_TAB_PANEL:
return QAccessible::PageTab;
- case ui::AX_ROLE_TEXT_AREA:
- return QAccessible::EditableText;
case ui::AX_ROLE_TEXT_FIELD:
return QAccessible::EditableText;
case ui::AX_ROLE_TIMER:
@@ -493,8 +473,6 @@ QAccessible::Role BrowserAccessibilityQt::role() const
return QAccessible::Tree;
case ui::AX_ROLE_TREE_ITEM:
return QAccessible::TreeItem;
- case ui::AX_ROLE_VALUE_INDICATOR:
- return QAccessible::Client; // FIXME
case ui::AX_ROLE_WINDOW:
return QAccessible::Window;
}
diff --git a/src/core/browser_accessibility_qt.h b/src/core/browser_accessibility_qt.h
index 7d58f515e..b7b4c39bc 100644
--- a/src/core/browser_accessibility_qt.h
+++ b/src/core/browser_accessibility_qt.h
@@ -142,6 +142,18 @@ public:
virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
virtual void modelChange(QAccessibleTableModelChangeEvent *event) Q_DECL_OVERRIDE;
+
+ QString name() const { return m_name; }
+ QString description() const { return m_description; }
+ QString help() const { return m_help; }
+ QString value() const { return m_value; }
+
+private:
+ // IAccessible name, description, help, value.
+ QString m_name;
+ QString m_description;
+ QString m_help;
+ QString m_value;
};
}
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index fa51575e3..48d05ae1d 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -40,6 +40,7 @@
#include "browser_context_qt.h"
#include "content_client_qt.h"
#include "download_manager_delegate_qt.h"
+#include "permission_manager_qt.h"
#include "web_engine_context.h"
#include "web_engine_visited_links_manager.h"
#include "url_request_context_getter_qt.h"
@@ -53,6 +54,8 @@
#include <QStringBuilder>
#include <QStandardPaths>
+#include <numeric>
+
namespace {
inline QString buildLocationFromStandardPath(const QString &standardPath, const QString &name) {
QString location = standardPath;
@@ -132,6 +135,28 @@ DownloadManagerDelegateQt *BrowserContextAdapter::downloadManagerDelegate()
return m_downloadManagerDelegate.data();
}
+QWebEngineCookieStoreClient *BrowserContextAdapter::cookieStoreClient()
+{
+ return m_cookieStoreClient.data();
+}
+
+void BrowserContextAdapter::setCookieStoreClient(QWebEngineCookieStoreClient *client)
+{
+ m_cookieStoreClient = client;
+ if (m_browserContext->url_request_getter_.get())
+ m_browserContext->url_request_getter_->updateStorageSettings();
+}
+
+QWebEngineUrlRequestInterceptor *BrowserContextAdapter::requestInterceptor()
+{
+ return m_requestInterceptor.data();
+}
+
+void BrowserContextAdapter::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
+{
+ m_requestInterceptor = interceptor;
+}
+
void BrowserContextAdapter::addClient(BrowserContextAdapterClient *adapterClient)
{
m_clients.append(adapterClient);
@@ -333,6 +358,12 @@ void BrowserContextAdapter::updateCustomUrlSchemeHandlers()
m_browserContext->url_request_getter_->updateStorageSettings();
}
+void BrowserContextAdapter::removeCustomUrlSchemeHandler(CustomUrlSchemeHandler *handler)
+{
+ m_customUrlSchemeHandlers.removeOne(handler);
+ Q_ASSERT(!m_customUrlSchemeHandlers.contains(handler));
+}
+
UserScriptControllerHost *BrowserContextAdapter::userScriptController()
{
if (!m_userScriptController)
@@ -340,4 +371,29 @@ UserScriptControllerHost *BrowserContextAdapter::userScriptController()
return m_userScriptController.data();
}
+void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, PermissionType type, bool reply)
+{
+ static_cast<PermissionManagerQt*>(browserContext()->GetPermissionManager())->permissionRequestReply(origin, type, reply);
+}
+
+QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const
+{
+ const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(','));
+ return std::accumulate(list.constBegin(), list.constEnd(), QString(),
+ [](const QString &r, const QString &e) {
+ return (r.isEmpty() ? r : r + QString(QLatin1Char(',')))
+ + e.split(QLatin1Char(';')).first();
+ });
+}
+
+QString BrowserContextAdapter::httpAcceptLanguage() const
+{
+ return m_httpAcceptLanguage;
+}
+
+void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
+{
+ m_httpAcceptLanguage = httpAcceptLanguage;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index 42787bc23..0bca1bf8b 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -40,11 +40,15 @@
#include "qtwebenginecoreglobal.h"
#include <QList>
+#include <QPointer>
#include <QScopedPointer>
#include <QSharedData>
#include <QString>
#include <QVector>
+#include "api/qwebenginecookiestoreclient.h"
+#include "api/qwebengineurlrequestinterceptor.h"
+
QT_FORWARD_DECLARE_CLASS(QObject)
namespace QtWebEngineCore {
@@ -69,6 +73,12 @@ public:
WebEngineVisitedLinksManager *visitedLinksManager();
DownloadManagerDelegateQt *downloadManagerDelegate();
+ QWebEngineCookieStoreClient *cookieStoreClient();
+ void setCookieStoreClient(QWebEngineCookieStoreClient *client);
+
+ QWebEngineUrlRequestInterceptor* requestInterceptor();
+ void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
+
QList<BrowserContextAdapterClient*> clients() { return m_clients; }
void addClient(BrowserContextAdapterClient *adapterClient);
void removeClient(BrowserContextAdapterClient *adapterClient);
@@ -113,6 +123,13 @@ public:
TrackVisitedLinksOnDisk,
};
+ enum PermissionType {
+ UnsupportedPermission = 0,
+ GeolocationPermission = 1,
+// Reserved:
+// NotificationPermission = 2,
+ };
+
HttpCacheType httpCacheType() const;
void setHttpCacheType(BrowserContextAdapter::HttpCacheType);
@@ -130,8 +147,15 @@ public:
QVector<CustomUrlSchemeHandler*> &customUrlSchemeHandlers();
void updateCustomUrlSchemeHandlers();
+ void removeCustomUrlSchemeHandler(CustomUrlSchemeHandler*);
UserScriptControllerHost *userScriptController();
+ void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
+
+ QString httpAcceptLanguageWithoutQualities() const;
+ QString httpAcceptLanguage() const;
+ void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
+
private:
QString m_name;
bool m_offTheRecord;
@@ -139,11 +163,14 @@ private:
QScopedPointer<WebEngineVisitedLinksManager> m_visitedLinksManager;
QScopedPointer<DownloadManagerDelegateQt> m_downloadManagerDelegate;
QScopedPointer<UserScriptControllerHost> m_userScriptController;
+ QPointer<QWebEngineCookieStoreClient> m_cookieStoreClient;
+ QPointer<QWebEngineUrlRequestInterceptor> m_requestInterceptor;
QString m_dataPath;
QString m_cachePath;
QString m_httpUserAgent;
HttpCacheType m_httpCacheType;
+ QString m_httpAcceptLanguage;
PersistentCookiesPolicy m_persistentCookiesPolicy;
VisitedLinksPolicy m_visitedLinksPolicy;
QVector<CustomUrlSchemeHandler*> m_customUrlSchemeHandlers;
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp
index 7f285b1e5..28486cced 100644
--- a/src/core/browser_context_qt.cpp
+++ b/src/core/browser_context_qt.cpp
@@ -38,9 +38,10 @@
#include "browser_context_adapter.h"
#include "download_manager_delegate_qt.h"
-#include "type_conversion.h"
-#include "qtwebenginecoreglobal.h"
+#include "permission_manager_qt.h"
+#include "qtwebenginecoreglobal_p.h"
#include "resource_context_qt.h"
+#include "type_conversion.h"
#include "url_request_context_getter_qt.h"
#include "base/time/time.h"
@@ -134,6 +135,18 @@ content::SSLHostStateDelegate* BrowserContextQt::GetSSLHostStateDelegate()
return 0;
}
+scoped_ptr<content::ZoomLevelDelegate> BrowserContextQt::CreateZoomLevelDelegate(const base::FilePath&)
+{
+ return nullptr;
+}
+
+content::PermissionManager *BrowserContextQt::GetPermissionManager()
+{
+ if (!permissionManager)
+ permissionManager.reset(new PermissionManagerQt(m_adapter));
+ return permissionManager.get();
+}
+
net::URLRequestContextGetter *BrowserContextQt::CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers)
{
url_request_getter_ = new URLRequestContextGetterQt(m_adapter, protocol_handlers);
diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h
index af36b55ab..eccd684a3 100644
--- a/src/core/browser_context_qt.h
+++ b/src/core/browser_context_qt.h
@@ -47,6 +47,7 @@
namespace QtWebEngineCore {
class BrowserContextAdapter;
+class PermissionManagerQt;
class URLRequestContextGetterQt;
class BrowserContextQt : public content::BrowserContext
@@ -72,13 +73,17 @@ public:
virtual content::PushMessagingService* GetPushMessagingService() Q_DECL_OVERRIDE;
virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() Q_DECL_OVERRIDE;
net::URLRequestContextGetter *CreateRequestContext(content::ProtocolHandlerMap *protocol_handlers);
+ virtual scoped_ptr<content::ZoomLevelDelegate> CreateZoomLevelDelegate(const base::FilePath& partition_path) Q_DECL_OVERRIDE;
+ virtual content::PermissionManager *GetPermissionManager() Q_DECL_OVERRIDE;
+
+ BrowserContextAdapter *adapter() { return m_adapter; }
- BrowserContextAdapter* adapter() { return m_adapter; }
private:
friend class ContentBrowserClientQt;
friend class WebContentsAdapter;
scoped_ptr<content::ResourceContext> resourceContext;
scoped_refptr<URLRequestContextGetterQt> url_request_getter_;
+ scoped_ptr<PermissionManagerQt> permissionManager;
BrowserContextAdapter *m_adapter;
friend class BrowserContextAdapter;
diff --git a/src/core/chrome_qt.gyp b/src/core/chrome_qt.gyp
index 703ce7525..0f30b7a04 100644
--- a/src/core/chrome_qt.gyp
+++ b/src/core/chrome_qt.gyp
@@ -19,6 +19,8 @@
'<(chromium_src_dir)/chrome/browser/media/desktop_streams_registry.cc',
'<(chromium_src_dir)/chrome/browser/media/desktop_streams_registry.h',
'<(chromium_src_dir)/chrome/browser/media/desktop_media_list.h',
+ '<(chromium_src_dir)/chrome/common/chrome_switches.cc',
+ '<(chromium_src_dir)/chrome/common/chrome_switches.h',
'<(chromium_src_dir)/chrome/common/localized_error.cc',
'<(chromium_src_dir)/chrome/common/localized_error.h',
],
diff --git a/src/core/chromium_gpu_helper.cpp b/src/core/chromium_gpu_helper.cpp
index ef574eccd..9dfc498ad 100644
--- a/src/core/chromium_gpu_helper.cpp
+++ b/src/core/chromium_gpu_helper.cpp
@@ -43,18 +43,18 @@
// Including gpu/command_buffer headers before content/gpu headers makes sure that
// guards are defined to prevent duplicate definition errors with forward declared
// GL typedefs cascading through content header includes.
+#include "gpu/command_buffer/service/sync_point_manager.h"
#include "gpu/command_buffer/service/mailbox_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
#include "content/common/gpu/gpu_channel_manager.h"
-#include "content/common/gpu/sync_point_manager.h"
#include "content/gpu/gpu_child_thread.h"
#ifdef Q_OS_QNX
#include "content/common/gpu/stream_texture_qnx.h"
#endif
-static void addSyncPointCallbackDelegate(content::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback)
+static void addSyncPointCallbackDelegate(gpu::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback)
{
syncPointManager->AddSyncPointCallback(sync_point, callback);
}
@@ -78,13 +78,13 @@ base::MessageLoop *gpu_message_loop()
return content::GpuChildThread::instance()->message_loop();
}
-content::SyncPointManager *sync_point_manager()
+gpu::SyncPointManager *sync_point_manager()
{
content::GpuChannelManager *gpuChannelManager = content::GpuChildThread::instance()->ChannelManager();
return gpuChannelManager->sync_point_manager();
}
-void AddSyncPointCallbackOnGpuThread(base::MessageLoop *gpuMessageLoop, content::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback)
+void AddSyncPointCallbackOnGpuThread(base::MessageLoop *gpuMessageLoop, gpu::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback)
{
// We need to set our callback from the GPU thread, where the SyncPointManager lives.
gpuMessageLoop->PostTask(FROM_HERE, base::Bind(&addSyncPointCallbackDelegate, make_scoped_refptr(syncPointManager), sync_point, callback));
diff --git a/src/core/chromium_gpu_helper.h b/src/core/chromium_gpu_helper.h
index 936ad1d24..6242dd068 100644
--- a/src/core/chromium_gpu_helper.h
+++ b/src/core/chromium_gpu_helper.h
@@ -47,12 +47,9 @@ namespace base {
class MessageLoop;
}
-namespace content {
-class SyncPointManager;
-}
-
namespace gpu {
struct Mailbox;
+class SyncPointManager;
namespace gles2 {
class MailboxManager;
class Texture;
@@ -66,10 +63,10 @@ class Texture;
QMap<uint32, gfx::TransferableFence> transferFences();
base::MessageLoop *gpu_message_loop();
-content::SyncPointManager *sync_point_manager();
+gpu::SyncPointManager *sync_point_manager();
gpu::gles2::MailboxManager *mailbox_manager();
-void AddSyncPointCallbackOnGpuThread(base::MessageLoop *gpuMessageLoop, content::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback);
+void AddSyncPointCallbackOnGpuThread(base::MessageLoop *gpuMessageLoop, gpu::SyncPointManager *syncPointManager, uint32 sync_point, const base::Closure& callback);
gpu::gles2::Texture* ConsumeTexture(gpu::gles2::MailboxManager *mailboxManager, unsigned target, const gpu::Mailbox& mailbox);
unsigned int service_id(gpu::gles2::Texture *tex);
diff --git a/src/core/chromium_overrides.cpp b/src/core/chromium_overrides.cpp
index 5af8a6ad8..b9ce722dd 100644
--- a/src/core/chromium_overrides.cpp
+++ b/src/core/chromium_overrides.cpp
@@ -37,8 +37,9 @@
#include "chromium_overrides.h"
#include "gl_context_qt.h"
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include "web_contents_view_qt.h"
+
#include "base/values.h"
#include "content/browser/renderer_host/pepper/pepper_truetype_font_list.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
@@ -47,6 +48,8 @@
#include <QGuiApplication>
#include <QScreen>
#include <QWindow>
+#include <QFontDatabase>
+#include <QStringList>
#if defined(USE_X11)
#include "ui/gfx/x/x11_types.h"
@@ -115,8 +118,17 @@ namespace content {
// content/common/font_list.h
scoped_ptr<base::ListValue> GetFontList_SlowBlocking()
{
- QT_NOT_USED
- return scoped_ptr<base::ListValue>(new base::ListValue);
+ scoped_ptr<base::ListValue> font_list(new base::ListValue);
+
+ QFontDatabase database;
+ for (auto family : database.families()){
+ base::ListValue* font_item = new base::ListValue();
+ font_item->Append(new base::StringValue(family.toStdString()));
+ font_item->Append(new base::StringValue(family.toStdString())); // should be localized name.
+ // TODO: Support localized family names.
+ font_list->Append(font_item);
+ }
+ return font_list.Pass();
}
#if defined(ENABLE_PLUGINS)
@@ -142,39 +154,6 @@ OSExchangeData::Provider* OSExchangeData::CreateProvider()
return 0;
}
-}
-
-namespace gfx {
-
-// Stubs for these unused functions that are stripped in case
-// of a release aura build but a debug build needs the symbols.
-
-RenderText* RenderText::CreateNativeInstance()
-{
- QT_NOT_USED;
- return 0;
-}
-
-#if defined(OS_LINUX)
-PlatformFont* PlatformFont::CreateDefault()
-{
- QT_NOT_USED;
- return 0;
-}
-
-PlatformFont* PlatformFont::CreateFromNativeFont(NativeFont)
-{
- QT_NOT_USED;
- return 0;
-}
-
-PlatformFont* PlatformFont::CreateFromNameAndSize(const std::string&, int)
-{
- QT_NOT_USED;
- return 0;
-}
-#endif
-
-} // namespace gfx
+} // namespace ui
#endif // defined(USE_AURA) && !defined(USE_OZONE)
diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp
index 797f5c7f4..206392840 100644
--- a/src/core/clipboard_qt.cpp
+++ b/src/core/clipboard_qt.cpp
@@ -331,7 +331,7 @@ SkBitmap ClipboardQt::ReadImage(ui::ClipboardType type) const
const QMimeData *mimeData = QGuiApplication::clipboard()->mimeData(type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
QImage image = qvariant_cast<QImage>(mimeData->imageData());
- Q_ASSERT(image.format() == QImage::Format_ARGB32);
+ image = image.convertToFormat(QImage::Format_ARGB32);
SkBitmap bitmap;
bitmap.setInfo(SkImageInfo::MakeN32(image.width(), image.height(), kOpaque_SkAlphaType));
bitmap.setPixels(const_cast<uchar*>(image.constBits()));
@@ -361,7 +361,7 @@ void ClipboardQt::ReadData(const FormatType& format, std::string* result) const
*result = std::string(byteArray.constData(), byteArray.length());
}
-uint64 ClipboardQt::GetSequenceNumber(ui::ClipboardType type)
+uint64 ClipboardQt::GetSequenceNumber(ui::ClipboardType type) const
{
return clipboardChangeObserver()->getSequenceNumber(type == ui::CLIPBOARD_TYPE_COPY_PASTE ? QClipboard::Clipboard : QClipboard::Selection);
}
diff --git a/src/core/clipboard_qt.h b/src/core/clipboard_qt.h
index 4c7e6ab59..ee1fc7440 100644
--- a/src/core/clipboard_qt.h
+++ b/src/core/clipboard_qt.h
@@ -62,7 +62,7 @@ private:
class ClipboardQt : public ui::Clipboard {
public:
- virtual uint64 GetSequenceNumber(ui::ClipboardType type) Q_DECL_OVERRIDE;
+ virtual uint64 GetSequenceNumber(ui::ClipboardType type) const Q_DECL_OVERRIDE;
virtual bool IsFormatAvailable(const FormatType& format, ui::ClipboardType type) const Q_DECL_OVERRIDE;
virtual void Clear(ui::ClipboardType type) Q_DECL_OVERRIDE;
virtual void ReadAvailableTypes(ui::ClipboardType type, std::vector<base::string16>* types, bool* contains_filenames) const Q_DECL_OVERRIDE;
diff --git a/src/core/common/qt_messages.h b/src/core/common/qt_messages.h
index c692ee5ca..25a995b27 100644
--- a/src/core/common/qt_messages.h
+++ b/src/core/common/qt_messages.h
@@ -31,6 +31,9 @@ IPC_MESSAGE_ROUTED1(QtRenderViewObserver_FetchDocumentMarkup,
IPC_MESSAGE_ROUTED1(QtRenderViewObserver_FetchDocumentInnerText,
uint64 /* requestId */)
+IPC_MESSAGE_ROUTED1(QtRenderViewObserver_SetBackgroundColor,
+ uint32 /* color */)
+
IPC_MESSAGE_ROUTED1(WebChannelIPCTransport_Message, std::vector<char> /*binaryJSON*/)
// User scripts messages
diff --git a/src/core/config/desktop_linux.pri b/src/core/config/desktop_linux.pri
index 041b094a1..5c61a8b7b 100644
--- a/src/core/config/desktop_linux.pri
+++ b/src/core/config/desktop_linux.pri
@@ -13,9 +13,27 @@ GYP_CONFIG += \
use_gnome_keyring=0 \
use_kerberos=0 \
use_pango=0 \
- host_clang=0 \
- clang=0 \
+ enable_plugins=1 \
+linux-clang: GYP_CONFIG += clang=1 host_clang=1 clang_use_chrome_plugins=0 make_clang_dir=/usr
+else: GYP_CONFIG += clang=0 host_clang=0
+
+contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1
+contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1
contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
+contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
+config_system_libevent: GYP_CONFIG += use_system_libevent=1
+config_system_libwebp: GYP_CONFIG += use_system_libwebp=1
+config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1
+config_system_libxslt: GYP_CONFIG += use_system_libxml=1
+config_system_flac: GYP_CONFIG += use_system_flac=1
+config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1
+config_system_opus: GYP_CONFIG += use_system_opus=1
+config_system_snappy: GYP_CONFIG += use_system_snappy=1
+config_system_speex: GYP_CONFIG += use_system_speex=1
+config_system_vpx: GYP_CONFIG += use_system_libvpx=1
+
+contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1
+contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1
!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0
diff --git a/src/core/config/embedded_linux.pri b/src/core/config/embedded_linux.pri
index cc8c40f8e..c87938b45 100644
--- a/src/core/config/embedded_linux.pri
+++ b/src/core/config/embedded_linux.pri
@@ -1,7 +1,6 @@
GYP_ARGS += "-D qt_os=\"embedded_linux\" -I config/embedded_linux.gypi"
GYP_CONFIG += \
- build_ffmpegsumo=1 \
clang=0 \
desktop_linux=0 \
disable_nacl=1 \
@@ -24,6 +23,7 @@ GYP_CONFIG += \
gtest_target_type=none \
host_clang=0 \
notifications=0 \
+ ozone_auto_platforms=0 \
ozone_platform_dri=0 \
ozone_platform_test=0 \
p2p_apis=0 \
@@ -40,15 +40,32 @@ GYP_CONFIG += \
use_gnome_keyring=0 \
use_kerberos=0 \
use_libpci=0 \
+ use_nss_certs=0 \
use_openssl=1 \
+ use_openssl_certs=1 \
use_ozone=1 \
use_pango=0 \
use_system_fontconfig=1 \
- use_system_icu=1 \
icu_use_data_file_flag=0 \
use_x11=0 \
v8_use_snapshot=false \
want_separate_host_toolset=1 \
+contains(QT_CONFIG, system-zlib): config_system_minizip: GYP_CONFIG += use_system_zlib=1
+contains(QT_CONFIG, system-png): GYP_CONFIG += use_system_libpng=1
contains(QT_CONFIG, system-jpeg): GYP_CONFIG += use_system_libjpeg=1
+contains(QT_CONFIG, system-harfbuzz): GYP_CONFIG += use_system_harfbuzz=1
!contains(QT_CONFIG, pulseaudio): GYP_CONFIG += use_pulseaudio=0
+config_system_libevent: GYP_CONFIG += use_system_libevent=1
+config_system_libwebp: GYP_CONFIG += use_system_libwebp=1
+config_system_libsrtp: GYP_CONFIG += use_system_libsrtp=1
+config_system_libxslt: GYP_CONFIG += use_system_libxml=1
+config_system_flac: GYP_CONFIG += use_system_flac=1
+config_system_jsoncpp: GYP_CONFIG += use_system_jsoncpp=1
+config_system_opus: GYP_CONFIG += use_system_opus=1
+config_system_snappy: GYP_CONFIG += use_system_snappy=1
+config_system_speex: GYP_CONFIG += use_system_speex=1
+config_system_vpx: GYP_CONFIG += use_system_libvpx=1
+
+contains(WEBENGINE_CONFIG, use_system_icu): GYP_CONFIG += use_system_icu=1
+contains(WEBENGINE_CONFIG, use_system_ffmpeg): GYP_CONFIG += use_system_ffmpeg=1
diff --git a/src/core/config/mac_osx.pri b/src/core/config/mac_osx.pri
index 3f42b6fd7..93c77623c 100644
--- a/src/core/config/mac_osx.pri
+++ b/src/core/config/mac_osx.pri
@@ -14,7 +14,8 @@ GYP_CONFIG += \
mac_sdk_min=\"10.7\" \
mac_deployment_target=\"$${QMAKE_MACOSX_DEPLOYMENT_TARGET}\" \
make_clang_dir=\"$${QMAKE_CLANG_DIR}\" \
- clang_use_chrome_plugins=0
+ clang_use_chrome_plugins=0 \
+ enable_plugins=1
QMAKE_MAC_SDK_PATH = "$$eval(QMAKE_MAC_SDK.$${QMAKE_MAC_SDK}.path)"
exists($$QMAKE_MAC_SDK_PATH): GYP_CONFIG += mac_sdk_path=\"$${QMAKE_MAC_SDK_PATH}\"
diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri
index f7644c83b..602afbc67 100644
--- a/src/core/config/windows.pri
+++ b/src/core/config/windows.pri
@@ -28,3 +28,17 @@ contains(QT_CONFIG, angle) {
GYP_ARGS += "-D qt_gl=\"opengl\""
}
+msvc {
+ equals(MSVC_VER, 12.0) {
+ MSVS_VERSION = 2013
+ } else:equals(MSVC_VER, 14.0) {
+ MSVS_VERSION = 2015
+ } else {
+ fatal("Visual Studio compiler version \"$$MSVC_VER\" is not supported by Qt WebEngine")
+ }
+
+ GYP_ARGS += "-G msvs_version=$$MSVS_VERSION"
+
+} else {
+ fatal("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler")
+}
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index fdfbaf0f5..91cd0b0c4 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -56,6 +56,7 @@
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_share_group.h"
+#include "ui/gl/gpu_timing.h"
#include "access_token_store_qt.h"
#include "browser_context_adapter.h"
@@ -74,6 +75,12 @@
#include "web_engine_context.h"
#include "web_engine_library_info.h"
+#if defined(ENABLE_PLUGINS)
+#include "content/public/browser/browser_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "renderer/pepper/pepper_host_factory_qt.h"
+#endif
+
#include <QGuiApplication>
#include <QLocale>
#include <QOpenGLContext>
@@ -277,7 +284,11 @@ public:
virtual bool MakeCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
virtual void ReleaseCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
virtual bool IsCurrent(gfx::GLSurface *) Q_DECL_OVERRIDE { Q_UNREACHABLE(); return false; }
- virtual void SetSwapInterval(int) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ virtual void OnSetSwapInterval(int) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
+ virtual scoped_refptr<gfx::GPUTimingClient> CreateGPUTimingClient() Q_DECL_OVERRIDE
+ {
+ return nullptr;
+ }
private:
void *m_handle;
@@ -360,9 +371,8 @@ content::MediaObserver *ContentBrowserClientQt::GetMediaObserver()
return MediaCaptureDevicesDispatcher::GetInstance();
}
-void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, const GURL &url, content::WebPreferences *web_prefs)
+void ContentBrowserClientQt::OverrideWebkitPrefs(content::RenderViewHost *rvh, content::WebPreferences *web_prefs)
{
- Q_UNUSED(url);
if (content::WebContents *webContents = rvh->GetDelegate()->GetAsWebContents())
static_cast<WebContentsDelegateQt*>(webContents->GetDelegate())->overrideWebPreferences(webContents, web_prefs);
}
@@ -402,41 +412,6 @@ void ContentBrowserClientQt::AllowCertificateError(int render_process_id, int re
contentsDelegate->allowCertificateError(errorController);
}
-void ContentBrowserClientQt::RequestPermission(content::PermissionType permission,
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame,
- bool user_gesture,
- const base::Callback<void(bool)>& result_callback)
-{
- Q_UNUSED(bridge_id);
- Q_UNUSED(user_gesture);
- WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
- Q_ASSERT(contentsDelegate);
- if (permission == content::PERMISSION_GEOLOCATION)
- contentsDelegate->requestGeolocationPermission(requesting_frame, result_callback);
- else
- result_callback.Run(false);
-}
-
-
-void ContentBrowserClientQt::CancelPermissionRequest(content::PermissionType permission,
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame)
-{
- Q_UNUSED(bridge_id);
- WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(web_contents->GetDelegate());
- Q_ASSERT(contentsDelegate);
- if (permission == content::PERMISSION_GEOLOCATION)
- contentsDelegate->cancelGeolocationPermissionRequest(requesting_frame);
-}
-
-blink::WebNotificationPermission ContentBrowserClientQt::CheckDesktopNotificationPermission(const GURL&, content::ResourceContext *, int )
-{
- return blink::WebNotificationPermission::WebNotificationPermissionDenied;
-}
-
content::LocationProvider *ContentBrowserClientQt::OverrideSystemLocationProvider()
{
#ifdef QT_USE_POSITIONING
@@ -451,6 +426,11 @@ std::string ContentBrowserClientQt::GetApplicationLocale()
return WebEngineLibraryInfo::getApplicationLocale();
}
+std::string ContentBrowserClientQt::GetAcceptLangs(content::BrowserContext *context)
+{
+ return static_cast<BrowserContextQt*>(context)->adapter()->httpAcceptLanguage().toStdString();
+}
+
void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id)
{
Q_UNUSED(child_process_id);
@@ -460,6 +440,13 @@ void ContentBrowserClientQt::AppendExtraCommandLineSwitches(base::CommandLine* c
command_line->AppendSwitchASCII(switches::kLang, GetApplicationLocale());
}
+#if defined(ENABLE_PLUGINS)
+ void ContentBrowserClientQt::DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) {
+ browser_host->GetPpapiHost()->AddHostFactoryFilter(
+ scoped_ptr<ppapi::host::HostFactory>(new QtWebEngineCore::PepperHostFactoryQt(browser_host)));
+ }
+#endif
+
content::DevToolsManagerDelegate* ContentBrowserClientQt::GetDevToolsManagerDelegate()
{
return new DevToolsManagerDelegateQt;
diff --git a/src/core/content_browser_client_qt.h b/src/core/content_browser_client_qt.h
index 0af5ae9d3..eea7d2a22 100644
--- a/src/core/content_browser_client_qt.h
+++ b/src/core/content_browser_client_qt.h
@@ -40,7 +40,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "content/public/browser/content_browser_client.h"
-#include "third_party/WebKit/public/platform/WebNotificationPermission.h"
+#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationPermission.h"
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
@@ -51,6 +51,11 @@ class URLRequestContextGetter;
namespace content {
class BrowserContext;
class BrowserMainParts;
+
+#if defined(ENABLE_PLUGINS)
+class BrowserPpapiHost;
+#endif
+
class DevToolsManagerDelegate;
class RenderProcessHost;
class RenderViewHostDelegateView;
@@ -83,7 +88,7 @@ public:
virtual content::MediaObserver* GetMediaObserver() Q_DECL_OVERRIDE;
virtual content::AccessTokenStore* CreateAccessTokenStore() Q_DECL_OVERRIDE;
virtual content::QuotaPermissionContext *CreateQuotaPermissionContext() Q_DECL_OVERRIDE;
- virtual void OverrideWebkitPrefs(content::RenderViewHost *, const GURL &, content::WebPreferences *) Q_DECL_OVERRIDE;
+ virtual void OverrideWebkitPrefs(content::RenderViewHost *, content::WebPreferences *) Q_DECL_OVERRIDE;
virtual void AllowCertificateError(
int render_process_id,
int render_frame_id,
@@ -96,26 +101,18 @@ public:
bool expired_previous_decision,
const base::Callback<void(bool)>& callback,
content::CertificateRequestResultType* result) Q_DECL_OVERRIDE;
- virtual void RequestPermission(
- content::PermissionType permission,
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame,
- bool user_gesture,
- const base::Callback<void(bool)>& result_callback) Q_DECL_OVERRIDE;
- virtual void CancelPermissionRequest(content::PermissionType permission,
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame) Q_DECL_OVERRIDE;
content::LocationProvider* OverrideSystemLocationProvider() Q_DECL_OVERRIDE;
content::DevToolsManagerDelegate *GetDevToolsManagerDelegate() Q_DECL_OVERRIDE;
virtual net::URLRequestContextGetter *CreateRequestContext(content::BrowserContext *browser_context, content::ProtocolHandlerMap *protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptorss) Q_DECL_OVERRIDE;
- virtual blink::WebNotificationPermission CheckDesktopNotificationPermission(const GURL& source_origin, content::ResourceContext* context, int render_process_id) Q_DECL_OVERRIDE;
-
virtual std::string GetApplicationLocale() Q_DECL_OVERRIDE;
+ std::string GetAcceptLangs(content::BrowserContext* context) Q_DECL_OVERRIDE;
virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) Q_DECL_OVERRIDE;
+#if defined(ENABLE_PLUGINS)
+ virtual void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) Q_DECL_OVERRIDE;
+#endif
+
private:
BrowserMainPartsQt* m_browserMainParts;
scoped_ptr<ResourceDispatcherHostDelegateQt> m_resourceDispatcherHostDelegate;
diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp
index 20a8df75e..01e1fe383 100644
--- a/src/core/content_client_qt.cpp
+++ b/src/core/content_client_qt.cpp
@@ -36,11 +36,119 @@
#include "content_client_qt.h"
+#include "base/command_line.h"
#include "base/strings/string_piece.h"
+#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
+#include "content/public/common/content_constants.h"
#include "content/public/common/user_agent.h"
#include "ui/base/layout.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "type_conversion.h"
+
+#include <QCoreApplication>
+#include <QFile>
+#include <QStringBuilder>
+
+#if defined(ENABLE_PLUGINS)
+#include "content/public/common/pepper_plugin_info.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+static const int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV |
+ ppapi::PERMISSION_PRIVATE |
+ ppapi::PERMISSION_BYPASS_USER_GESTURE |
+ ppapi::PERMISSION_FLASH;
+
+namespace switches {
+const char kPpapiFlashPath[] = "ppapi-flash-path";
+const char kPpapiFlashVersion[] = "ppapi-flash-version";
+}
+
+// Adopted from chrome_content_client.cc
+content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, const std::string& version)
+{
+ content::PepperPluginInfo plugin;
+
+ plugin.is_out_of_process = true;
+ plugin.name = content::kFlashPluginName;
+ plugin.path = path;
+ plugin.permissions = kPepperFlashPermissions;
+
+ std::vector<std::string> flash_version_numbers;
+ base::SplitString(version, '.', &flash_version_numbers);
+ if (flash_version_numbers.size() < 1)
+ flash_version_numbers.push_back("11");
+ else if (flash_version_numbers[0].empty())
+ flash_version_numbers[0] = "11";
+ if (flash_version_numbers.size() < 2)
+ flash_version_numbers.push_back("2");
+ if (flash_version_numbers.size() < 3)
+ flash_version_numbers.push_back("999");
+ if (flash_version_numbers.size() < 4)
+ flash_version_numbers.push_back("999");
+
+ // E.g., "Shockwave Flash 10.2 r154":
+ plugin.description = plugin.name + " " + flash_version_numbers[0] + "." + flash_version_numbers[1] + " r" + flash_version_numbers[2];
+ plugin.version = JoinString(flash_version_numbers, '.');
+ content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
+ content::kFlashPluginSwfExtension,
+ content::kFlashPluginSwfDescription);
+ plugin.mime_types.push_back(swf_mime_type);
+ content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
+ content::kFlashPluginSplExtension,
+ content::kFlashPluginSplDescription);
+ plugin.mime_types.push_back(spl_mime_type);
+
+ return plugin;
+}
+
+void AddPepperFlashFromSystem(std::vector<content::PepperPluginInfo>* plugins)
+{
+ QStringList pluginPaths;
+#if defined(Q_OS_WIN) && defined(Q_PROCESSOR_X86_32)
+ QDir pluginDir("C:/Windows/SysWOW64/Macromed/Flash");
+ pluginDir.setFilter(QDir::Files);
+ QStringList nameFilters("pepflashplayer*.dll");
+ pluginPaths << pluginDir.entryList(nameFilters);
+#endif
+#if defined(Q_OS_OSX)
+ pluginPaths << "/Library/Internet Plug-Ins/PepperFlashPlayer/PepperFlashPlayer.plugin"; // Mac OS X
+#endif
+#if defined(Q_OS_LINUX)
+ pluginPaths << "/usr/lib/pepperflashplugin-nonfree/libpepflashplayer.so" // Ubuntu
+ << "/usr/lib/PepperFlash/libpepflashplayer.so" // Arch
+ << "/usr/lib64/chromium/PepperFlash/libpepflashplayer.so"; // OpenSuSE
+#endif
+ for (auto it = pluginPaths.constBegin(); it != pluginPaths.constEnd(); ++it) {
+ if (!QFile(*it).exists())
+ continue;
+ plugins->push_back(CreatePepperFlashInfo(QtWebEngineCore::toFilePath(*it), std::string()));
+ return;
+ }
+}
+
+void AddPepperFlashFromCommandLine(std::vector<content::PepperPluginInfo>* plugins)
+{
+ const base::CommandLine::StringType flash_path = base::CommandLine::ForCurrentProcess()->GetSwitchValueNative(switches::kPpapiFlashPath);
+ if (flash_path.empty() || !QFile(QtWebEngineCore::toQt(flash_path)).exists())
+ return;
+
+ // Read pepper flash plugin version from command-line. (e.g. 16.0.0.235)
+ std::string flash_version = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kPpapiFlashVersion);
+ plugins->push_back(CreatePepperFlashInfo(base::FilePath(flash_path), flash_version));
+}
+
+namespace QtWebEngineCore {
+
+void ContentClientQt::AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins)
+{
+ AddPepperFlashFromSystem(plugins);
+ AddPepperFlashFromCommandLine(plugins);
+}
+
+}
+#endif
#include <QCoreApplication>
#include <QStringBuilder>
diff --git a/src/core/content_client_qt.h b/src/core/content_client_qt.h
index f68282dcf..309e049dc 100644
--- a/src/core/content_client_qt.h
+++ b/src/core/content_client_qt.h
@@ -48,6 +48,10 @@ class ContentClientQt : public content::ContentClient {
public:
static std::string getUserAgent();
+#if defined(ENABLE_PLUGINS)
+ virtual void AddPepperPlugins(std::vector<content::PepperPluginInfo>* plugins) Q_DECL_OVERRIDE;
+#endif
+
virtual base::StringPiece GetDataResource(int, ui::ScaleFactor) const Q_DECL_OVERRIDE;
virtual std::string GetUserAgent() const Q_DECL_OVERRIDE { return getUserAgent(); }
virtual base::string16 GetLocalizedString(int message_id) const Q_DECL_OVERRIDE;
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp
index 4003823b1..0688fb015 100644
--- a/src/core/content_main_delegate_qt.cpp
+++ b/src/core/content_main_delegate_qt.cpp
@@ -72,7 +72,7 @@ void ContentMainDelegateQt::PreSandboxStartup()
// Suppress info, warning and error messages per default.
int logLevel = logging::LOG_FATAL;
- CommandLine* parsedCommandLine = CommandLine::ForCurrentProcess();
+ base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess();
if (parsedCommandLine->HasSwitch(switches::kLoggingLevel)) {
std::string logLevelValue = parsedCommandLine->GetSwitchValueASCII(switches::kLoggingLevel);
int level = 0;
diff --git a/src/core/cookie_monster_delegate_qt.cpp b/src/core/cookie_monster_delegate_qt.cpp
new file mode 100644
index 000000000..7838617ba
--- /dev/null
+++ b/src/core/cookie_monster_delegate_qt.cpp
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "cookie_monster_delegate_qt.h"
+
+#include "base/bind.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/cookies/cookie_util.h"
+
+#include "api/qwebenginecookiestoreclient.h"
+#include "api/qwebenginecookiestoreclient_p.h"
+#include "type_conversion.h"
+
+#include <QStringBuilder>
+
+namespace QtWebEngineCore {
+
+static GURL sourceUrlForCookie(const QNetworkCookie &cookie) {
+ QString urlFragment = QString("%1%2").arg(cookie.domain()).arg(cookie.path());
+ return net::cookie_util::CookieOriginToURL(urlFragment.toStdString(), /* is_https */ cookie.isSecure());
+}
+
+static void onSetCookieCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, bool success) {
+ client->onSetCallbackResult(callbackId, success);
+}
+
+static void onDeleteCookiesCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, int numCookies) {
+ client->onDeleteCallbackResult(callbackId, numCookies);
+}
+
+static void onGetAllCookiesCallback(QWebEngineCookieStoreClientPrivate *client, qint64 callbackId, const net::CookieList& cookies) {
+ QByteArray rawCookies;
+ for (auto&& cookie: cookies)
+ rawCookies += toQt(cookie).toRawForm() % QByteArrayLiteral("\n");
+
+ client->onGetAllCallbackResult(callbackId, rawCookies);
+}
+
+CookieMonsterDelegateQt::CookieMonsterDelegateQt()
+ : m_client(0)
+ , m_cookieMonster(0)
+{
+
+}
+
+CookieMonsterDelegateQt::~CookieMonsterDelegateQt()
+{
+
+}
+
+bool CookieMonsterDelegateQt::hasCookieMonster()
+{
+ return m_cookieMonster.get();
+}
+
+void CookieMonsterDelegateQt::getAllCookies(quint64 callbackId)
+{
+ net::CookieMonster::GetCookieListCallback callback = base::Bind(&onGetAllCookiesCallback, m_client->d_func(), callbackId);
+ m_cookieMonster->GetAllCookiesAsync(callback);
+}
+
+void CookieMonsterDelegateQt::setCookie(quint64 callbackId, const QNetworkCookie &cookie, const QUrl &origin)
+{
+ Q_ASSERT(hasCookieMonster());
+ Q_ASSERT(m_client);
+
+ net::CookieStore::SetCookiesCallback callback;
+ if (callbackId != CallbackDirectory::NoCallbackId)
+ callback = base::Bind(&onSetCookieCallback, m_client->d_func(), callbackId);
+
+ net::CookieOptions options;
+ options.set_include_httponly();
+
+ GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
+
+ m_cookieMonster->SetCookieWithOptionsAsync(gurl, cookie.toRawForm().toStdString(), options, callback);
+}
+
+void CookieMonsterDelegateQt::deleteCookie(const QNetworkCookie &cookie, const QUrl &origin)
+{
+ Q_ASSERT(hasCookieMonster());
+ Q_ASSERT(m_client);
+
+ GURL gurl = origin.isEmpty() ? sourceUrlForCookie(cookie) : toGurl(origin);
+
+ m_cookieMonster->DeleteCookieAsync(gurl, cookie.name().toStdString(), base::Closure());
+}
+
+void CookieMonsterDelegateQt::deleteSessionCookies(quint64 callbackId)
+{
+ Q_ASSERT(hasCookieMonster());
+ Q_ASSERT(m_client);
+
+ net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
+ m_cookieMonster->DeleteSessionCookiesAsync(callback);
+}
+
+void CookieMonsterDelegateQt::deleteAllCookies(quint64 callbackId)
+{
+ Q_ASSERT(hasCookieMonster());
+ Q_ASSERT(m_client);
+
+ net::CookieMonster::DeleteCallback callback = base::Bind(&onDeleteCookiesCallback, m_client->d_func(), callbackId);
+ m_cookieMonster->DeleteAllAsync(callback);
+}
+
+void CookieMonsterDelegateQt::setCookieMonster(net::CookieMonster* monster)
+{
+ m_cookieMonster = monster;
+
+ if (m_client)
+ m_client->d_func()->processPendingUserCookies();
+}
+
+void CookieMonsterDelegateQt::setClient(QWebEngineCookieStoreClient *client)
+{
+ m_client = client;
+
+ if (!m_client)
+ return;
+
+ m_client->d_ptr->delegate = this;
+
+ if (hasCookieMonster())
+ m_client->d_func()->processPendingUserCookies();
+}
+
+bool CookieMonsterDelegateQt::canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url)
+{
+ if (!m_client)
+ return true;
+
+ return m_client->d_ptr->canSetCookie(firstPartyUrl, cookieLine, url);
+}
+
+void CookieMonsterDelegateQt::OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause)
+{
+ if (!m_client)
+ return;
+ m_client->d_ptr->onCookieChanged(toQt(cookie), removed);
+}
+
+}
diff --git a/src/core/cookie_monster_delegate_qt.h b/src/core/cookie_monster_delegate_qt.h
new file mode 100644
index 000000000..7592d57fa
--- /dev/null
+++ b/src/core/cookie_monster_delegate_qt.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef COOKIE_MONSTER_DELEGATE_QT_H
+#define COOKIE_MONSTER_DELEGATE_QT_H
+
+#include "qtwebenginecoreglobal.h"
+
+QT_WARNING_PUSH
+// For some reason adding -Wno-unused-parameter to QMAKE_CXXFLAGS has no
+// effect with clang, so use a pragma for these dirty chromium headers
+QT_WARNING_DISABLE_CLANG("-Wunused-parameter")
+#include "base/memory/ref_counted.h"
+#include "net/cookies/cookie_monster.h"
+QT_WARNING_POP
+
+#include <QList>
+#include <QNetworkCookie>
+#include <QPointer>
+
+QT_FORWARD_DECLARE_CLASS(QWebEngineCookieStoreClient)
+
+namespace QtWebEngineCore {
+
+// Extends net::CookieMonster::kDefaultCookieableSchemes with qrc, without enabling
+// cookies for the file:// scheme, which is disabled by default in Chromium.
+// Since qrc:// is similar to file:// and there are some unknowns about how
+// to correctly handle file:// cookies, qrc:// should only be used for testing.
+static const char* const kCookieableSchemes[] =
+ { "http", "https", "qrc", "ws", "wss" };
+
+class QWEBENGINE_EXPORT CookieMonsterDelegateQt: public net::CookieMonsterDelegate {
+ QPointer<QWebEngineCookieStoreClient> m_client;
+ scoped_refptr<net::CookieMonster> m_cookieMonster;
+public:
+ CookieMonsterDelegateQt();
+ ~CookieMonsterDelegateQt();
+
+ bool hasCookieMonster();
+
+ void setCookie(quint64 callbackId, const QNetworkCookie &cookie, const QUrl &origin);
+ void deleteCookie(const QNetworkCookie &cookie, const QUrl &origin);
+ void getAllCookies(quint64 callbackId);
+ void deleteSessionCookies(quint64 callbackId);
+ void deleteAllCookies(quint64 callbackId);
+
+ void setCookieMonster(net::CookieMonster* monster);
+ void setClient(QWebEngineCookieStoreClient *client);
+
+ bool canSetCookie(const QUrl &firstPartyUrl, const QByteArray &cookieLine, const QUrl &url);
+ void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed, ChangeCause cause) override;
+};
+
+}
+
+#endif // COOKIE_MONSTER_DELEGATE_QT_H
diff --git a/src/core/core.pro b/src/core/core.pro
index cf00f39cb..7ddad4ed6 100644
--- a/src/core/core.pro
+++ b/src/core/core.pro
@@ -8,13 +8,14 @@ core_gyp_generator.file = core_gyp_generator.pro
gyp_run.file = gyp_run.pro
gyp_run.depends = core_gyp_generator
+core_api.file = api/core_api.pro
+core_api.depends = gyp_run
+
# This will take the compile output of ninja, and link+deploy the final binary.
core_module.file = core_module.pro
-core_module.depends = gyp_run
+core_module.depends = core_api
-SUBDIRS += core_gyp_generator \
- gyp_run \
- core_module
+SUBDIRS += core_gyp_generator
!win32 {
# gyp_configure_host.pro and gyp_configure_target.pro are phony pro files that
@@ -28,3 +29,7 @@ SUBDIRS += core_gyp_generator \
gyp_run.depends += gyp_configure_host gyp_configure_target
SUBDIRS += gyp_configure_host gyp_configure_target
}
+
+SUBDIRS += gyp_run \
+ core_api \
+ core_module
diff --git a/src/core/core_common.pri b/src/core/core_common.pri
index cefde4302..1ea4e1862 100644
--- a/src/core/core_common.pri
+++ b/src/core/core_common.pri
@@ -6,7 +6,7 @@ QT += qml quick webchannel
QT_PRIVATE += quick-private gui-private core-private
# Make QtCreator happy.
-CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$${getChromiumSrcDir()}
+CHROMIUM_SRC_DIR = $$QTWEBENGINE_ROOT/$$getChromiumSrcDir()
INCLUDEPATH += $$CHROMIUM_SRC_DIR
qtHaveModule(positioning):QT += positioning
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index c745fd19e..17d73ccfd 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -18,17 +18,18 @@ DEFINES += QT_NO_KEYWORDS \
# Assume that we want mobile touch and low-end hardware behaviors
# whenever we are cross compiling.
-cross_compile: DEFINES += QTWEBENGINE_MOBILE_SWITCHES
+cross_compile: DEFINES += QTWEBENGINE_EMBEDDED_SWITCHES
contains(QT_CONFIG, egl): CONFIG += egl
else: DEFINES += QT_NO_EGL
RESOURCES += devtools.qrc
-INCLUDEPATH += $$PWD
+INCLUDEPATH += $$PWD $$PWD/api
SOURCES = \
access_token_store_qt.cpp \
+ authentication_dialog_controller.cpp \
browser_accessibility_manager_qt.cpp \
browser_accessibility_qt.cpp \
browser_context_adapter.cpp \
@@ -42,12 +43,14 @@ SOURCES = \
content_client_qt.cpp \
content_browser_client_qt.cpp \
content_main_delegate_qt.cpp \
+ cookie_monster_delegate_qt.cpp \
custom_protocol_handler.cpp \
custom_url_scheme_handler.cpp \
delegated_frame_node.cpp \
desktop_screen_qt.cpp \
dev_tools_http_handler_delegate_qt.cpp \
download_manager_delegate_qt.cpp \
+ file_picker_controller.cpp \
gl_context_qt.cpp \
gl_surface_qt.cpp \
javascript_dialog_controller.cpp \
@@ -56,11 +59,18 @@ SOURCES = \
native_web_keyboard_event_qt.cpp \
network_delegate_qt.cpp \
ozone_platform_eglfs.cpp \
+ permission_manager_qt.cpp \
process_main.cpp \
+ proxy_config_service_qt.cpp \
qrc_protocol_handler_qt.cpp \
qt_render_view_observer_host.cpp \
render_widget_host_view_qt.cpp \
renderer/content_renderer_client_qt.cpp \
+ renderer/pepper/pepper_flash_browser_host_qt.cpp \
+ renderer/pepper/pepper_flash_renderer_host_qt.cpp \
+ renderer/pepper/pepper_host_factory_qt.cpp \
+ renderer/pepper/pepper_renderer_host_factory_qt.cpp \
+ renderer/qt_render_frame_observer.cpp \
renderer/qt_render_view_observer.cpp \
renderer/user_script_controller.cpp \
renderer/web_channel_ipc_transport.cpp \
@@ -89,6 +99,8 @@ SOURCES = \
HEADERS = \
access_token_store_qt.h \
+ authentication_dialog_controller_p.h \
+ authentication_dialog_controller.h \
browser_accessibility_manager_qt.h \
browser_accessibility_qt.h \
browser_context_adapter.h \
@@ -103,6 +115,7 @@ HEADERS = \
content_client_qt.h \
content_browser_client_qt.h \
content_main_delegate_qt.h \
+ cookie_monster_delegate_qt.h \
custom_protocol_handler.h \
custom_url_scheme_handler.h \
delegated_frame_node.h \
@@ -110,6 +123,7 @@ HEADERS = \
dev_tools_http_handler_delegate_qt.h \
download_manager_delegate_qt.h \
chromium_gpu_helper.h \
+ file_picker_controller.h \
gl_context_qt.h \
gl_surface_qt.h \
javascript_dialog_controller_p.h \
@@ -118,13 +132,19 @@ HEADERS = \
media_capture_devices_dispatcher.h \
network_delegate_qt.h \
ozone_platform_eglfs.h \
+ permission_manager_qt.h \
process_main.h \
+ proxy_config_service_qt.h \
qrc_protocol_handler_qt.h \
qt_render_view_observer_host.h \
- qtwebenginecoreglobal.h \
render_widget_host_view_qt.h \
render_widget_host_view_qt_delegate.h \
renderer/content_renderer_client_qt.h \
+ renderer/pepper/pepper_flash_browser_host_qt.h \
+ renderer/pepper/pepper_flash_renderer_host_qt.h \
+ renderer/pepper/pepper_host_factory_qt.h \
+ renderer/pepper/pepper_renderer_host_factory_qt.h \
+ renderer/qt_render_frame_observer.h \
renderer/qt_render_view_observer.h \
renderer/user_script_controller.h \
renderer/web_channel_ipc_transport.h \
@@ -158,3 +178,18 @@ qtHaveModule(positioning) {
HEADERS += location_provider_qt.h
DEFINES += QT_USE_POSITIONING=1
}
+
+win32:msvc {
+ EXPORTS_CPP = $$OUT_PWD/api/public_exports.cpp
+ !build_pass {
+ API_HEADERS = $$files($$PWD/api/*.h)
+ CONTENT = "// Dummy C++ file to make sure API symbols are exported."
+ for(f, API_HEADERS) {
+ CONTENT += "$${LITERAL_HASH}include <$$basename(f)>"
+ }
+ write_file($$EXPORTS_CPP, CONTENT)
+ unset(API_HEADERS)
+ unset(CONTENT)
+ }
+ SOURCES += $$EXPORTS_CPP
+}
diff --git a/src/core/core_module.pro b/src/core/core_module.pro
index e6a36332f..c23fc235b 100644
--- a/src/core/core_module.pro
+++ b/src/core/core_module.pro
@@ -9,10 +9,26 @@ QMAKE_INFO_PLIST = Info_mac.plist
error("Could not find the linking information that gyp should have generated.")
}
-# We distribute the module binary but headers are only available in-tree.
-CONFIG += no_module_headers
load(qt_module)
+api_library_name = qtwebenginecoreapi
+api_library_path = $$OUT_PWD/api/$$getConfigDir()
+LIBS_PRIVATE += -L$$api_library_path
+CONFIG *= no_smart_library_merge
+osx {
+ LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a
+} else:win32-msvc* {
+ LIBS_PRIVATE += /OPT:REF -l$$api_library_name
+} else {
+ LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive
+}
+
+win32-msvc* {
+ POST_TARGETDEPS += $${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib
+} else {
+ POST_TARGETDEPS += $${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a
+}
+
# Using -Wl,-Bsymbolic-functions seems to confuse the dynamic linker
# and doesn't let Chromium get access to libc symbols through dlsym.
CONFIG -= bsymbolic_functions
@@ -31,17 +47,8 @@ resources.files = $$REPACK_DIR/qtwebengine_resources.pak \
$$REPACK_DIR/qtwebengine_resources_100p.pak \
$$REPACK_DIR/qtwebengine_resources_200p.pak
-PLUGIN_EXTENSION = .so
-PLUGIN_PREFIX = lib
-osx: PLUGIN_PREFIX =
-win32 {
- PLUGIN_EXTENSION = .dll
- PLUGIN_PREFIX =
-}
icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat
-plugins.files = $$OUT_PWD/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_EXTENSION}
-
!debug_and_release|!build_all|CONFIG(release, debug|release) {
contains(QT_CONFIG, qt_framework) {
locales.version = Versions
@@ -50,12 +57,10 @@ plugins.files = $$OUT_PWD/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_
resources.path = Resources
icu.version = Versions
icu.path = Resources
- plugins.version = Versions
- plugins.path = Libraries
# No files, this prepares the bundle Helpers symlink, process.pro will create the directories
qtwebengineprocessplaceholder.version = Versions
qtwebengineprocessplaceholder.path = Helpers
- QMAKE_BUNDLE_DATA += icu locales resources plugins qtwebengineprocessplaceholder
+ QMAKE_BUNDLE_DATA += icu locales resources qtwebengineprocessplaceholder
} else {
locales.CONFIG += no_check_exist
locales.path = $$[QT_INSTALL_TRANSLATIONS]/qtwebengine_locales
@@ -63,9 +68,7 @@ plugins.files = $$OUT_PWD/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_
resources.path = $$[QT_INSTALL_DATA]
icu.CONFIG += no_check_exist
icu.path = $$[QT_INSTALL_DATA]
- plugins.CONFIG += no_check_exist
- plugins.path = $$[QT_INSTALL_PLUGINS]/qtwebengine
- INSTALLS += icu locales resources plugins
+ INSTALLS += icu locales resources
}
!contains(QT_CONFIG, qt_framework): contains(QT_CONFIG, private_tests) {
@@ -75,15 +78,7 @@ plugins.files = $$OUT_PWD/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_
unix: icu_rule.commands = if [ -e $$ICU_FILE ] ; then $$QMAKE_COPY $$ICU_FILE $$ICU_TARGET ; fi
win32: icu_rule.commands = if exist $$ICU_FILE ( $$QMAKE_COPY $$ICU_FILE $$ICU_TARGET )
- PLUGIN_DIR = $$shell_path($$[QT_INSTALL_PLUGINS/get]/qtwebengine)
- PLUGIN_TARGET = $$shell_path($$PLUGIN_DIR/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_EXTENSION})
- PLUGIN_FILE = $$shell_path($$OUT_PWD/$$getConfigDir()/$${PLUGIN_PREFIX}ffmpegsumo$${PLUGIN_EXTENSION})
- plugins_rule.target = $$PLUGIN_TARGET
- unix: plugins_rule.commands = $$QMAKE_MKDIR $$PLUGIN_DIR && if [ -e $$PLUGIN_FILE ] ; then $$QMAKE_COPY $$PLUGIN_FILE $$PLUGIN_TARGET ; fi
- win32: plugins_rule.commands = (if not exist $$PLUGIN_DIR ( $$QMAKE_MKDIR $$PLUGIN_DIR )) && \
- if exist $$PLUGIN_FILE ( $$QMAKE_COPY $$PLUGIN_FILE $$PLUGIN_TARGET )
-
- QMAKE_EXTRA_TARGETS += icu_rule plugins_rule
- PRE_TARGETDEPS += $$ICU_TARGET $$PLUGIN_TARGET
+ QMAKE_EXTRA_TARGETS += icu_rule
+ PRE_TARGETDEPS += $$ICU_TARGET
}
}
diff --git a/src/core/custom_url_scheme_handler.cpp b/src/core/custom_url_scheme_handler.cpp
index b9fcf9c36..29791b555 100644
--- a/src/core/custom_url_scheme_handler.cpp
+++ b/src/core/custom_url_scheme_handler.cpp
@@ -44,10 +44,6 @@ CustomUrlSchemeHandler::CustomUrlSchemeHandler(const QByteArray &scheme)
{
}
-CustomUrlSchemeHandler::~CustomUrlSchemeHandler()
-{
-}
-
QByteArray CustomUrlSchemeHandler::scheme() const
{
return m_scheme;
diff --git a/src/core/custom_url_scheme_handler.h b/src/core/custom_url_scheme_handler.h
index 745f0eb4c..d866628de 100644
--- a/src/core/custom_url_scheme_handler.h
+++ b/src/core/custom_url_scheme_handler.h
@@ -53,7 +53,7 @@ class URLRequestCustomJobDelegate;
class QWEBENGINE_EXPORT CustomUrlSchemeHandler {
public:
explicit CustomUrlSchemeHandler(const QByteArray &);
- ~CustomUrlSchemeHandler();
+ virtual ~CustomUrlSchemeHandler() { }
QByteArray scheme() const;
void setScheme(const QByteArray &);
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 6f79d4952..aebdfd027 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -76,6 +76,10 @@
#include <EGL/eglext.h>
#endif
+#ifndef GL_TIMEOUT_IGNORED
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
+#endif
+
namespace QtWebEngineCore {
class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
@@ -161,9 +165,9 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const cc::SharedQuadState
layerChain->appendChildNode(clipNode);
layerChain = clipNode;
}
- if (!layerState->content_to_target_transform.IsIdentity()) {
+ if (!layerState->quad_to_target_transform.IsIdentity()) {
QSGTransformNode *transformNode = new QSGTransformNode;
- transformNode->setMatrix(toQt(layerState->content_to_target_transform.matrix()));
+ transformNode->setMatrix(toQt(layerState->quad_to_target_transform.matrix()));
layerChain->appendChildNode(transformNode);
layerChain = transformNode;
}
@@ -205,7 +209,6 @@ static void waitChromiumSync(gfx::TransferableFence *sync)
#endif
break;
case gfx::TransferableFence::ArbSync:
-#ifdef GL_ARB_sync
typedef void (QOPENGLF_APIENTRYP WaitSyncPtr)(GLsync sync, GLbitfield flags, GLuint64 timeout);
static WaitSyncPtr glWaitSync_ = 0;
if (!glWaitSync_) {
@@ -214,7 +217,6 @@ static void waitChromiumSync(gfx::TransferableFence *sync)
Q_ASSERT(glWaitSync_);
}
glWaitSync_(sync->arb.sync, 0, GL_TIMEOUT_IGNORED);
-#endif
break;
}
}
@@ -250,7 +252,6 @@ static void deleteChromiumSync(gfx::TransferableFence *sync)
#endif
break;
case gfx::TransferableFence::ArbSync:
-#ifdef GL_ARB_sync
typedef void (QOPENGLF_APIENTRYP DeleteSyncPtr)(GLsync sync);
static DeleteSyncPtr glDeleteSync_ = 0;
if (!glDeleteSync_) {
@@ -260,7 +261,6 @@ static void deleteChromiumSync(gfx::TransferableFence *sync)
}
glDeleteSync_(sync->arb.sync);
sync->reset();
-#endif
break;
}
// If Chromium was able to create a sync, we should have been able to handle its type here too.
@@ -409,7 +409,7 @@ void DelegatedFrameNode::preprocess()
{
QMutexLocker lock(&m_mutex);
base::MessageLoop *gpuMessageLoop = gpu_message_loop();
- content::SyncPointManager *syncPointManager = sync_point_manager();
+ gpu::SyncPointManager *syncPointManager = sync_point_manager();
Q_FOREACH (MailboxTexture *mailboxTexture, mailboxesToFetch) {
m_numPendingSyncPoints++;
@@ -444,6 +444,20 @@ void DelegatedFrameNode::preprocess()
}
}
+static YUVVideoMaterial::ColorSpace toQt(cc::YUVVideoDrawQuad::ColorSpace color_space)
+{
+ switch (color_space) {
+ case cc::YUVVideoDrawQuad::REC_601:
+ return YUVVideoMaterial::REC_601;
+ case cc::YUVVideoDrawQuad::REC_709:
+ return YUVVideoMaterial::REC_709;
+ case cc::YUVVideoDrawQuad::JPEG:
+ return YUVVideoMaterial::JPEG;
+ }
+ Q_UNREACHABLE();
+ return YUVVideoMaterial::REC_601;
+}
+
void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData, cc::ReturnedResourceArray *resourcesToRelease, RenderWidgetHostViewQtDelegate *apiDelegate)
{
m_chromiumCompositorData = chromiumCompositorData;
@@ -557,10 +571,10 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
break;
} case cc::DrawQuad::TEXTURE_CONTENT: {
const cc::TextureDrawQuad *tquad = cc::TextureDrawQuad::MaterialCast(quad);
- ResourceHolder *resource = findAndHoldResource(tquad->resource_id, resourceCandidates);
+ ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates);
QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode;
- textureNode->setTextureCoordinatesTransform(tquad->flipped ? QSGSimpleTextureNode::MirrorVertically : QSGSimpleTextureNode::NoTransform);
+ textureNode->setTextureCoordinatesTransform(tquad->y_flipped ? QSGSimpleTextureNode::MirrorVertically : QSGSimpleTextureNode::NoTransform);
textureNode->setRect(toQt(quad->rect));
textureNode->setFiltering(resource->transferableResource().filter == GL_LINEAR ? QSGTexture::Linear : QSGTexture::Nearest);
textureNode->setTexture(initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate));
@@ -605,7 +619,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
break;
} case cc::DrawQuad::TILED_CONTENT: {
const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad);
- ResourceHolder *resource = findAndHoldResource(tquad->resource_id, resourceCandidates);
+ ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates);
QSGSimpleTextureNode *textureNode = new QSGSimpleTextureNode;
textureNode->setRect(toQt(quad->rect));
@@ -616,26 +630,28 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
break;
} case cc::DrawQuad::YUV_VIDEO_CONTENT: {
const cc::YUVVideoDrawQuad *vquad = cc::YUVVideoDrawQuad::MaterialCast(quad);
- ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id, resourceCandidates);
- ResourceHolder *uResource = findAndHoldResource(vquad->u_plane_resource_id, resourceCandidates);
- ResourceHolder *vResource = findAndHoldResource(vquad->v_plane_resource_id, resourceCandidates);
+ ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id(), resourceCandidates);
+ ResourceHolder *uResource = findAndHoldResource(vquad->u_plane_resource_id(), resourceCandidates);
+ ResourceHolder *vResource = findAndHoldResource(vquad->v_plane_resource_id(), resourceCandidates);
ResourceHolder *aResource = 0;
// This currently requires --enable-vp8-alpha-playback and needs a video with alpha data to be triggered.
- if (vquad->a_plane_resource_id)
- aResource = findAndHoldResource(vquad->a_plane_resource_id, resourceCandidates);
+ if (vquad->a_plane_resource_id())
+ aResource = findAndHoldResource(vquad->a_plane_resource_id(), resourceCandidates);
YUVVideoNode *videoNode = new YUVVideoNode(
initAndHoldTexture(yResource, quad->ShouldDrawWithBlending()),
initAndHoldTexture(uResource, quad->ShouldDrawWithBlending()),
initAndHoldTexture(vResource, quad->ShouldDrawWithBlending()),
- aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0, toQt(vquad->tex_coord_rect));
+ aResource ? initAndHoldTexture(aResource, quad->ShouldDrawWithBlending()) : 0,
+ toQt(vquad->ya_tex_coord_rect), toQt(vquad->uv_tex_coord_rect),
+ toQt(vquad->ya_tex_size), toQt(vquad->uv_tex_size), toQt(vquad->color_space));
videoNode->setRect(toQt(quad->rect));
currentLayerChain->appendChildNode(videoNode);
break;
#ifdef GL_OES_EGL_image_external
} case cc::DrawQuad::STREAM_VIDEO_CONTENT: {
const cc::StreamVideoDrawQuad *squad = cc::StreamVideoDrawQuad::MaterialCast(quad);
- ResourceHolder *resource = findAndHoldResource(squad->resource_id, resourceCandidates);
+ ResourceHolder *resource = findAndHoldResource(squad->resource_id(), resourceCandidates);
MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending()));
texture->setTarget(GL_TEXTURE_EXTERNAL_OES); // since this is not default TEXTURE_2D type
diff --git a/src/core/dev_tools_http_handler_delegate_qt.cpp b/src/core/dev_tools_http_handler_delegate_qt.cpp
index 964d6ad38..793ed0981 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.cpp
+++ b/src/core/dev_tools_http_handler_delegate_qt.cpp
@@ -49,9 +49,11 @@
#include "base/files/file_path.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/devtools_discovery/devtools_discovery_manager.h"
+#include "components/devtools_discovery/devtools_target_descriptor.h"
+#include "components/devtools_http_handler/devtools_http_handler.h"
#include "content/public/browser/devtools_agent_host.h"
-#include "content/public/browser/devtools_http_handler.h"
-#include "content/public/browser/devtools_target.h"
+#include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -59,14 +61,17 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/content_switches.h"
#include "net/base/ip_endpoint.h"
-#include "net/socket/stream_listen_socket.h"
+#include "net/base/net_errors.h"
#include "net/socket/tcp_server_socket.h"
using namespace content;
+using namespace devtools_discovery;
+using namespace devtools_http_handler;
namespace {
const char kTargetTypePage[] = "page";
+const char kTargetTypeSharedWorker[] = "worker";
const char kTargetTypeServiceWorker[] = "service_worker";
const char kTargetTypeOther[] = "other";
@@ -74,15 +79,29 @@ class TCPServerSocketFactory
: public DevToolsHttpHandler::ServerSocketFactory {
public:
TCPServerSocketFactory(const std::string& address, int port, int backlog)
- : DevToolsHttpHandler::ServerSocketFactory(address, port, backlog) {}
+ : m_address(address), m_port(port), m_backlog(backlog)
+ {}
private:
- scoped_ptr<net::ServerSocket> Create() const override {
- return scoped_ptr<net::ServerSocket>(new net::TCPServerSocket(NULL, net::NetLog::Source()));
- }
- DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
+ scoped_ptr<net::ServerSocket> CreateForHttpServer() override {
+ scoped_ptr<net::ServerSocket> socket(new net::TCPServerSocket(nullptr, net::NetLog::Source()));
+ if (socket->ListenWithAddressAndPort(m_address, m_port, m_backlog) != net::OK)
+ return scoped_ptr<net::ServerSocket>();
+
+ return socket;
+ }
+
+ const std::string m_address;
+ int m_port;
+ int m_backlog;
+ DISALLOW_COPY_AND_ASSIGN(TCPServerSocketFactory);
};
-class Target : public content::DevToolsTarget {
+class DevToolsDiscoveryProviderQt : public DevToolsDiscoveryManager::Provider {
+public:
+ DevToolsTargetDescriptor::List GetDescriptors() override;
+};
+
+class Target : public DevToolsTargetDescriptor {
public:
explicit Target(scoped_refptr<DevToolsAgentHost> agent_host);
@@ -92,6 +111,8 @@ public:
switch (agent_host_->GetType()) {
case DevToolsAgentHost::TYPE_WEB_CONTENTS:
return kTargetTypePage;
+ case DevToolsAgentHost::TYPE_SHARED_WORKER:
+ return kTargetTypeSharedWorker;
case DevToolsAgentHost::TYPE_SERVICE_WORKER:
return kTargetTypeServiceWorker;
default:
@@ -141,17 +162,40 @@ bool Target::Close() const {
return agent_host_->Close();
}
+DevToolsTargetDescriptor::List DevToolsDiscoveryProviderQt::GetDescriptors()
+{
+ DevToolsTargetDescriptor::List targets;
+ for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) {
+ targets.push_back(new Target(agent_host));
+ }
+ return targets;
+}
+
} // namespace
namespace QtWebEngineCore {
+scoped_ptr<DevToolsHttpHandler> createDevToolsHttpHandler()
+{
+ DevToolsHttpHandlerDelegateQt *delegate = new DevToolsHttpHandlerDelegateQt();
+ if (!delegate->isValid()) {
+ delete delegate;
+ return nullptr;
+ }
+ scoped_ptr<DevToolsHttpHandler::ServerSocketFactory> factory(new TCPServerSocketFactory(delegate->bindAddress().toStdString(), delegate->port(), 1));
+ // Ownership of the delegate is taken over the devtools http handler.
+ scoped_ptr<DevToolsHttpHandler> handler(new DevToolsHttpHandler(factory.Pass(), std::string(), delegate, base::FilePath(), base::FilePath(), std::string(), std::string()));
+ DevToolsDiscoveryManager::GetInstance()->AddProvider(scoped_ptr<DevToolsDiscoveryManager::Provider>(new DevToolsDiscoveryProviderQt()));
+ return handler;
+}
+
DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt()
- : m_devtoolsHttpHandler(0)
- , m_bindAddress(QLatin1String("127.0.0.1"))
+ : m_bindAddress(QLatin1String("127.0.0.1"))
, m_port(0)
+ , m_valid(false)
{
const QString inspectorEnv = QString::fromUtf8(qgetenv("QTWEBENGINE_REMOTE_DEBUGGING"));
- const CommandLine &commandLine = *CommandLine::ForCurrentProcess();
+ const base::CommandLine &commandLine = *base::CommandLine::ForCurrentProcess();
QString portStr;
if (commandLine.HasSwitch(switches::kRemoteDebuggingPort)) {
@@ -166,26 +210,16 @@ DevToolsHttpHandlerDelegateQt::DevToolsHttpHandlerDelegateQt()
} else
return;
- bool ok = false;
- m_port = portStr.toInt(&ok);
- if (ok && m_port > 0 && m_port < 65535) {
- scoped_ptr<content::DevToolsHttpHandler::ServerSocketFactory> factory(new TCPServerSocketFactory(m_bindAddress.toStdString(), m_port, 1));
- m_devtoolsHttpHandler = DevToolsHttpHandler::Start(factory.Pass(), std::string(), this, base::FilePath());
- } else
+ m_port = portStr.toInt(&m_valid);
+ m_valid = m_valid && m_port > 0 && m_port < 65535;
+ if (!m_valid)
qWarning("Invalid port given for the inspector server \"%s\". Examples of valid input: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's network interface).", qPrintable(portStr));
}
-DevToolsHttpHandlerDelegateQt::~DevToolsHttpHandlerDelegateQt()
-{
- // Stop() takes care of deleting the DevToolsHttpHandler.
- if (m_devtoolsHttpHandler)
- m_devtoolsHttpHandler->Stop();
-}
-
-void DevToolsHttpHandlerDelegateQt::Initialized(const net::IPEndPoint& ip_address)
+void DevToolsHttpHandlerDelegateQt::Initialized(const net::IPEndPoint *ip_address)
{
- if (ip_address.address().size()) {
- QString addressAndPort = QString::fromStdString(ip_address.ToString());
+ if (ip_address && ip_address->address().size()) {
+ QString addressAndPort = QString::fromStdString(ip_address->ToString());
qWarning("Remote debugging server started successfully. Try pointing a Chromium-based browser to http://%s", qPrintable(addressAndPort));
} else
qWarning("Couldn't start the inspector server on bind address \"%s\" and port \"%d\". In case of invalid input, try something like: \"12345\" or \"192.168.2.14:12345\" (with the address of one of this host's interface).", qPrintable(m_bindAddress), m_port);
@@ -203,42 +237,19 @@ std::string DevToolsHttpHandlerDelegateQt::GetDiscoveryPageHTML()
return html;
}
-bool DevToolsHttpHandlerDelegateQt::BundlesFrontendResources()
-{
- return true;
-}
-
-base::FilePath DevToolsHttpHandlerDelegateQt::GetDebugFrontendDir()
-{
- return base::FilePath();
-}
-
-scoped_ptr<net::StreamListenSocket> DevToolsHttpHandlerDelegateQt::CreateSocketForTethering(net::StreamListenSocket::Delegate* delegate, std::string* name)
-{
- return scoped_ptr<net::StreamListenSocket>();
-}
-
-base::DictionaryValue* DevToolsManagerDelegateQt::HandleCommand(DevToolsAgentHost *, base::DictionaryValue *) {
- return 0;
-}
-
-std::string DevToolsManagerDelegateQt::GetPageThumbnailData(const GURL& url)
+std::string DevToolsHttpHandlerDelegateQt::GetPageThumbnailData(const GURL& url)
{
return std::string();
}
-scoped_ptr<DevToolsTarget> DevToolsManagerDelegateQt::CreateNewTarget(const GURL &)
+std::string DevToolsHttpHandlerDelegateQt::GetFrontendResource(const std::string &path)
{
- return scoped_ptr<DevToolsTarget>();
+ return content::DevToolsFrontendHost::GetFrontendResource(path).as_string();
}
-void DevToolsManagerDelegateQt::EnumerateTargets(TargetCallback callback)
+base::DictionaryValue* DevToolsManagerDelegateQt::HandleCommand(DevToolsAgentHost *, base::DictionaryValue *)
{
- TargetList targets;
- for (const auto& agent_host : DevToolsAgentHost::GetOrCreateAll()) {
- targets.push_back(new Target(agent_host));
- }
- callback.Run(targets);
+ return 0;
}
} //namespace QtWebEngineCore
diff --git a/src/core/dev_tools_http_handler_delegate_qt.h b/src/core/dev_tools_http_handler_delegate_qt.h
index 902e99507..0fe9ad0ce 100644
--- a/src/core/dev_tools_http_handler_delegate_qt.h
+++ b/src/core/dev_tools_http_handler_delegate_qt.h
@@ -37,43 +37,42 @@
#ifndef DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H
#define DEV_TOOLS_HTTP_HANDLER_DELEGATE_QT_H
-#include "content/public/browser/devtools_http_handler_delegate.h"
+#include "components/devtools_http_handler/devtools_http_handler_delegate.h"
#include "content/public/browser/devtools_manager_delegate.h"
#include <QString>
#include <QtCore/qcompilerdetection.h> // needed for Q_DECL_OVERRIDE
-namespace net {
-class StreamListenSocket;
-}
-
namespace content {
class BrowserContext;
+}
+
+namespace devtools_http_handler {
class DevToolsHttpHandler;
-class RenderViewHost;
}
namespace QtWebEngineCore {
-class DevToolsHttpHandlerDelegateQt : public content::DevToolsHttpHandlerDelegate {
-public:
+scoped_ptr<devtools_http_handler::DevToolsHttpHandler> createDevToolsHttpHandler();
+class DevToolsHttpHandlerDelegateQt : public devtools_http_handler::DevToolsHttpHandlerDelegate {
+public:
DevToolsHttpHandlerDelegateQt();
- virtual ~DevToolsHttpHandlerDelegateQt();
- // content::DevToolsHttpHandlerDelegate Overrides
- virtual void Initialized(const net::IPEndPoint &ip_address) Q_DECL_OVERRIDE;
- virtual std::string GetDiscoveryPageHTML() Q_DECL_OVERRIDE;
- virtual bool BundlesFrontendResources() Q_DECL_OVERRIDE;
- virtual base::FilePath GetDebugFrontendDir() Q_DECL_OVERRIDE;
- // Requests the list of all inspectable targets.
- // The caller gets the ownership of the returned targets.
- virtual scoped_ptr<net::StreamListenSocket> CreateSocketForTethering(net::StreamListenSocket::Delegate *delegate, std::string *name) Q_DECL_OVERRIDE;
+ bool isValid() const { return m_valid; }
+ QString bindAddress() const { return m_bindAddress; }
+ int port() const { return m_port; }
+
+ // devtools_http_handler::DevToolsHttpHandlerDelegate Overrides
+ void Initialized(const net::IPEndPoint *ip_address) Q_DECL_OVERRIDE;
+ std::string GetDiscoveryPageHTML() Q_DECL_OVERRIDE;
+ std::string GetFrontendResource(const std::string&) Q_DECL_OVERRIDE;
+ std::string GetPageThumbnailData(const GURL &url) Q_DECL_OVERRIDE;
private:
- content::DevToolsHttpHandler *m_devtoolsHttpHandler;
QString m_bindAddress;
int m_port;
+ bool m_valid;
};
class DevToolsManagerDelegateQt : public content::DevToolsManagerDelegate {
@@ -81,9 +80,6 @@ public:
void Inspect(content::BrowserContext *browser_context, content::DevToolsAgentHost *agent_host) Q_DECL_OVERRIDE { }
void DevToolsAgentStateChanged(content::DevToolsAgentHost *agent_host, bool attached) Q_DECL_OVERRIDE { }
base::DictionaryValue *HandleCommand(content::DevToolsAgentHost *agent_host, base::DictionaryValue *command) Q_DECL_OVERRIDE;
- scoped_ptr<content::DevToolsTarget> CreateNewTarget(const GURL &url) Q_DECL_OVERRIDE;
- void EnumerateTargets(TargetCallback callback) Q_DECL_OVERRIDE;
- std::string GetPageThumbnailData(const GURL &url) Q_DECL_OVERRIDE;
};
} // namespace QtWebEngineCore
diff --git a/src/core/doc/snippets/qtwebenginecore_build_snippet.qdoc b/src/core/doc/snippets/qtwebenginecore_build_snippet.qdoc
new file mode 100644
index 000000000..4806359c9
--- /dev/null
+++ b/src/core/doc/snippets/qtwebenginecore_build_snippet.qdoc
@@ -0,0 +1,8 @@
+//! [0]
+QT += webenginecore
+//! [0]
+
+
+//! [1]
+#include <QtWebEngineCore>
+//! [1]
diff --git a/src/core/doc/src/qtwebenginecore-index.qdoc b/src/core/doc/src/qtwebenginecore-index.qdoc
new file mode 100644
index 000000000..49231c8f2
--- /dev/null
+++ b/src/core/doc/src/qtwebenginecore-index.qdoc
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtwebenginecore-index.html
+ \title Qt WebEngine Core
+ \ingroup modules
+
+ \brief Provides common API shared by Qt WebEngine and Qt WebEngine Widgets.
+
+ Qt WebEngine Core provides API shared by \l {Qt WebEngine} and \l {Qt WebEngine Widgets}.
+
+ \section1 Getting Started
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet qtwebenginecore_build_snippet.qdoc 1
+
+ To link against the module, add this line to your qmake project file:
+
+ \snippet qtwebenginecore_build_snippet.qdoc 0
+
+ \section1 Articles and Guides
+
+ \list
+ \li \l{Qt WebEngine Overview}
+ \endlist
+
+ \section1 API Reference
+
+ \list
+ \li \l{Qt WebEngine Core C++ Classes}
+ \endlist
+
+ \section1 License Information
+
+ This is a snapshot of the integration of Chromium into Qt.
+
+ Qt Commercial Edition licensees that wish to distribute applications that
+ use the Qt WebEngine module need to be aware of their obligations under the
+ GNU Library General Public License (LGPLv2).
+
+ Developers using the Open Source Edition can choose to redistribute
+ the module under the GNU LGPLv3 or GPLv2 and up.
+
+ \legalese
+
+ Chromium is licensed under the following license:
+
+ Copyright (c) 2013 The Chromium Authors. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ \endlegalese
+*/
diff --git a/src/core/doc/src/qtwebenginecore-module.qdoc b/src/core/doc/src/qtwebenginecore-module.qdoc
new file mode 100644
index 000000000..750a0244e
--- /dev/null
+++ b/src/core/doc/src/qtwebenginecore-module.qdoc
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+/*!
+ \module QtWebEngineCore
+ \title Qt WebEngine Core C++ Classes
+ \brief Provides public API shared by both QtWebEngine and QtWebEngineWidgets
+ \since 5.6
+ \ingroup qtwebengine-modules
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet qtwebenginecore_build_snippet.qdoc 1
+
+ If you use qmake to build your projects, Qt WebEngine Core is usually
+ indirectly included through the \l[QtWebEngine]{Qt WebEngine} or
+ \l[QtWebEngineWidgets]{Qt WebEngine Widgets} modules.
+*/
diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp
new file mode 100644
index 000000000..18896c6b4
--- /dev/null
+++ b/src/core/file_picker_controller.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "file_picker_controller.h"
+#include "type_conversion.h"
+#include "content/browser/renderer_host/render_view_host_impl.h"
+#include "content/browser/web_contents/web_contents_impl.h"
+
+#include <QFileInfo>
+#include <QDir>
+#include <QVariant>
+#include <QStringList>
+
+namespace QtWebEngineCore {
+
+FilePickerController::FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject *parent)
+ : QObject(parent)
+ , m_defaultFileName(defaultFileName)
+ , m_acceptedMimeTypes(acceptedMimeTypes)
+ , m_contents(contents)
+ , m_mode(mode)
+{
+}
+
+void FilePickerController::accepted(const QStringList &files)
+{
+ FilePickerController::filesSelectedInChooser(files, m_contents);
+}
+
+void FilePickerController::accepted(const QVariant &files)
+{
+ QStringList stringList;
+
+ if (files.canConvert(QVariant::StringList)) {
+ stringList = files.toStringList();
+ } else if (files.canConvert<QList<QUrl> >()) {
+ Q_FOREACH (const QUrl &url, files.value<QList<QUrl> >())
+ stringList.append(url.toLocalFile());
+ } else {
+ qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName());
+ }
+
+ FilePickerController::filesSelectedInChooser(stringList, m_contents);
+}
+
+void FilePickerController::rejected()
+{
+ FilePickerController::filesSelectedInChooser(QStringList(), m_contents);
+}
+
+static QStringList listRecursively(const QDir &dir)
+{
+ QStringList ret;
+ QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden));
+ Q_FOREACH (const QFileInfo &fileInfo, infoList) {
+ if (fileInfo.isDir()) {
+ ret.append(fileInfo.absolutePath() + QStringLiteral("/.")); // Match chromium's behavior. See chrome/browser/file_select_helper.cc
+ ret.append(listRecursively(QDir(fileInfo.absoluteFilePath())));
+ } else
+ ret.append(fileInfo.absoluteFilePath());
+ }
+ return ret;
+}
+
+ASSERT_ENUMS_MATCH(FilePickerController::Open, content::FileChooserParams::Open)
+ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, content::FileChooserParams::OpenMultiple)
+ASSERT_ENUMS_MATCH(FilePickerController::UploadFolder, content::FileChooserParams::UploadFolder)
+ASSERT_ENUMS_MATCH(FilePickerController::Save, content::FileChooserParams::Save)
+
+void FilePickerController::filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents)
+{
+ content::RenderViewHost *rvh = contents->GetRenderViewHost();
+ Q_ASSERT(rvh);
+ QStringList files(filesList);
+ if (this->m_mode == UploadFolder && !filesList.isEmpty()
+ && QFileInfo(filesList.first()).isDir()) // Enumerate the directory
+ files = listRecursively(QDir(filesList.first()));
+ rvh->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(this->m_mode));
+}
+
+QStringList FilePickerController::acceptedMimeTypes()
+{
+ return m_acceptedMimeTypes;
+}
+
+FilePickerController::FileChooserMode FilePickerController::mode()
+{
+ return m_mode;
+}
+
+QString FilePickerController::defaultFileName()
+{
+ return m_defaultFileName;
+}
+
+} // namespace
diff --git a/src/core/file_picker_controller.h b/src/core/file_picker_controller.h
new file mode 100644
index 000000000..347dd11ef
--- /dev/null
+++ b/src/core/file_picker_controller.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FILE_PICKER_CONTROLLER_H
+#define FILE_PICKER_CONTROLLER_H
+
+#include "qtwebenginecoreglobal.h"
+#include <QObject>
+#include <QStringList>
+
+namespace content {
+ class WebContents;
+}
+
+namespace QtWebEngineCore {
+
+class QWEBENGINE_EXPORT FilePickerController : public QObject {
+ Q_OBJECT
+public:
+ enum FileChooserMode {
+ Open,
+ OpenMultiple,
+ UploadFolder,
+ Save
+ };
+
+ FilePickerController(FileChooserMode mode, content::WebContents *contents, const QString &defaultFileName, const QStringList &acceptedMimeTypes, QObject * = 0);
+ QStringList acceptedMimeTypes();
+ QString defaultFileName();
+ FileChooserMode mode();
+ void filesSelectedInChooser(const QStringList &filesList, content::WebContents *contents);
+
+public Q_SLOTS:
+ void accepted(const QStringList &files);
+ void accepted(const QVariant &files);
+ void rejected();
+
+private:
+ QString m_defaultFileName;
+ QStringList m_acceptedMimeTypes;
+ content::WebContents *m_contents;
+ FileChooserMode m_mode;
+
+};
+
+} // namespace
+
+#endif // FILE_PICKER_CONTROLLER_H
diff --git a/src/core/gl_surface_qt.cpp b/src/core/gl_surface_qt.cpp
index 584bdc227..86bb4fda9 100644
--- a/src/core/gl_surface_qt.cpp
+++ b/src/core/gl_surface_qt.cpp
@@ -44,7 +44,7 @@
#include <QGuiApplication>
#include "gl_context_qt.h"
-#include "qtwebenginecoreglobal.h"
+#include "qtwebenginecoreglobal_p.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
@@ -439,11 +439,11 @@ bool GLSurfaceQt::IsOffscreen()
return true;
}
-bool GLSurfaceQt::SwapBuffers()
+gfx::SwapResult GLSurfaceQt::SwapBuffers()
{
LOG(ERROR) << "Attempted to call SwapBuffers on a pbuffer.";
Q_UNREACHABLE();
- return false;
+ return gfx::SwapResult::SWAP_FAILED;
}
gfx::Size GLSurfaceQt::GetSize()
@@ -533,6 +533,17 @@ GLSurface::CreateViewGLSurface(gfx::AcceleratedWidget window)
return NULL;
}
+std::string DriverEGL::GetPlatformExtensions()
+{
+ EGLDisplay display = GLContextHelper::getEGLDisplay();
+ if (display == EGL_NO_DISPLAY)
+ return "";
+
+ DCHECK(g_driver_egl.fn.eglQueryStringFn);
+ const char* str = g_driver_egl.fn.eglQueryStringFn(display, EGL_EXTENSIONS);
+ return str ? std::string(str) : "";
+}
+
} // namespace gfx
namespace content {
diff --git a/src/core/gl_surface_qt.h b/src/core/gl_surface_qt.h
index 21c46e699..7646063b2 100644
--- a/src/core/gl_surface_qt.h
+++ b/src/core/gl_surface_qt.h
@@ -39,7 +39,7 @@
#ifndef GL_SURFACE_QT_H_
#define GL_SURFACE_QT_H_
-#include "ui/gfx/size.h"
+#include "ui/gfx/geometry/size.h"
#include "ui/gl/gl_surface.h"
#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
@@ -56,7 +56,7 @@ public:
virtual void* GetDisplay() Q_DECL_OVERRIDE;
virtual void* GetConfig() Q_DECL_OVERRIDE;
virtual bool IsOffscreen() Q_DECL_OVERRIDE;
- virtual bool SwapBuffers() Q_DECL_OVERRIDE;
+ virtual gfx::SwapResult SwapBuffers() Q_DECL_OVERRIDE;
virtual gfx::Size GetSize() Q_DECL_OVERRIDE;
protected:
diff --git a/src/core/gyp_run.pro b/src/core/gyp_run.pro
index 3f631302c..bb19a679d 100644
--- a/src/core/gyp_run.pro
+++ b/src/core/gyp_run.pro
@@ -85,7 +85,7 @@ cross_compile {
contains(QT_ARCH, "x86_64"): GYP_ARGS += "-D target_arch=x64"
contains(QT_ARCH, "i386"): GYP_ARGS += "-D target_arch=ia32"
-contains(WEBENGINE_CONFIG, proprietary_codecs): GYP_ARGS += "-Dproprietary_codecs=1 -Dffmpeg_branding=Chrome -Duse_system_ffmpeg=0"
+contains(WEBENGINE_CONFIG, use_proprietary_codecs): GYP_ARGS += "-Dproprietary_codecs=1 -Dffmpeg_branding=Chrome -Duse_system_ffmpeg=0"
!contains(QT_CONFIG, qt_framework): contains(QT_CONFIG, private_tests) {
GYP_ARGS += "-D qt_install_data=\"$$[QT_INSTALL_DATA/get]\""
diff --git a/src/core/javascript_dialog_manager_qt.h b/src/core/javascript_dialog_manager_qt.h
index 4682ce5b8..8bf7ac6b9 100644
--- a/src/core/javascript_dialog_manager_qt.h
+++ b/src/core/javascript_dialog_manager_qt.h
@@ -66,8 +66,7 @@ public:
const content::JavaScriptDialogManager::DialogClosedCallback &callback) Q_DECL_OVERRIDE { Q_UNUSED(messageText); Q_UNUSED(isReload); Q_UNUSED(callback); }
virtual bool HandleJavaScriptDialog(content::WebContents *, bool accept, const base::string16 *promptOverride) Q_DECL_OVERRIDE;
virtual void CancelActiveAndPendingDialogs(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
- virtual void WebContentsDestroyed(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
-
+ virtual void ResetDialogState(content::WebContents *contents) Q_DECL_OVERRIDE { takeDialogForContents(contents); }
void runDialogForContents(content::WebContents *, WebContentsAdapterClient::JavascriptDialogType, const QString &messageText, const QString &defaultPrompt
, const QUrl &,const content::JavaScriptDialogManager::DialogClosedCallback &callback, const QString &title = QString());
diff --git a/src/core/media_capture_devices_dispatcher.cpp b/src/core/media_capture_devices_dispatcher.cpp
index 6866afc41..b31d22a76 100644
--- a/src/core/media_capture_devices_dispatcher.cpp
+++ b/src/core/media_capture_devices_dispatcher.cpp
@@ -91,9 +91,8 @@ scoped_ptr<content::MediaStreamUI> getDevicesForDesktopCapture(content::MediaStr
devices.push_back(content::MediaStreamDevice(
content::MEDIA_DESKTOP_VIDEO_CAPTURE, mediaId.ToString(), "Screen"));
if (captureAudio) {
- // Use the special loopback device ID for system audio capture.
devices.push_back(content::MediaStreamDevice(
- content::MEDIA_LOOPBACK_AUDIO_CAPTURE,
+ content::MEDIA_DESKTOP_AUDIO_CAPTURE,
media::AudioManagerBase::kLoopbackInputDeviceId, "System Audio"));
}
@@ -225,7 +224,7 @@ void MediaCaptureDevicesDispatcher::processMediaAccessRequest(WebContentsAdapter
if (request.video_type == content::MEDIA_TAB_VIDEO_CAPTURE || request.audio_type == content::MEDIA_TAB_AUDIO_CAPTURE)
return;
- if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE)
+ if (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE || request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE)
// It's still unclear what to make of screen capture. We can rely on existing javascript dialog infrastructure
// to experiment with this without exposing it through our API yet.
processDesktopCaptureAccessRequest(webContents, request, callback);
@@ -279,7 +278,7 @@ void MediaCaptureDevicesDispatcher::processDesktopCaptureAccessRequest(content::
// Audio is only supported for screen capture streams.
bool capture_audio = (mediaId.type == content::DesktopMediaID::TYPE_SCREEN &&
- request.audio_type == content::MEDIA_LOOPBACK_AUDIO_CAPTURE);
+ request.audio_type == content::MEDIA_DESKTOP_AUDIO_CAPTURE);
ui = getDevicesForDesktopCapture(
devices, mediaId, capture_audio, true,
@@ -305,8 +304,8 @@ void MediaCaptureDevicesDispatcher::processScreenCaptureAccessRequest(content::W
base::Unretained(this), base::Unretained(webContents));
QUrl securityOrigin(toQt(request.security_origin));
- QString message = QObject::tr("Do you want %1 to share your screen?").arg(securityOrigin.toString());
- QString title = QObject::tr("%1 Screen Sharing request").arg(securityOrigin.toString());
+ QString message = QCoreApplication::translate("MediaCaptureDevicesDispatcher", "Do you want %1 to share your screen?").arg(securityOrigin.toString());
+ QString title = QCoreApplication::translate("MediaCaptureDevicesDispatcher", "%1 Screen Sharing request").arg(securityOrigin.toString());
JavaScriptDialogManagerQt::GetInstance()->runDialogForContents(webContents, WebContentsAdapterClient::InternalAuthorizationDialog, message
, QString(), securityOrigin, dialogCallback, title);
} else
diff --git a/src/core/network_delegate_qt.cpp b/src/core/network_delegate_qt.cpp
index 4e726fec8..38fd3c710 100644
--- a/src/core/network_delegate_qt.cpp
+++ b/src/core/network_delegate_qt.cpp
@@ -36,31 +36,37 @@
#include "network_delegate_qt.h"
+#include "browser_context_adapter.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_request_details.h"
#include "content/public/browser/resource_request_info.h"
+#include "cookie_monster_delegate_qt.h"
#include "ui/base/page_transition_types.h"
+#include "url_request_context_getter_qt.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_request.h"
+#include "qwebengineurlrequestinfo.h"
+#include "qwebengineurlrequestinfo_p.h"
+#include "qwebengineurlrequestinterceptor.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
#include "web_contents_view_qt.h"
namespace QtWebEngineCore {
-int pageTransitionToNavigationType(ui::PageTransition transition)
+static int pageTransitionToNavigationType(ui::PageTransition transition)
{
int32 qualifier = ui::PageTransitionGetQualifier(transition);
if (qualifier & ui::PAGE_TRANSITION_FORWARD_BACK)
return WebContentsAdapterClient::BackForwardNavigation;
- ui::PageTransition stippedTransition = ui::PageTransitionStripQualifier(transition);
+ ui::PageTransition strippedTransition = ui::PageTransitionStripQualifier(transition);
- switch (stippedTransition) {
+ switch (strippedTransition) {
case ui::PAGE_TRANSITION_LINK:
- return WebContentsAdapterClient::LinkClickedNavigation;
+ return WebContentsAdapterClient::LinkNavigation;
case ui::PAGE_TRANSITION_TYPED:
return WebContentsAdapterClient::TypedNavigation;
case ui::PAGE_TRANSITION_FORM_SUBMIT:
@@ -72,29 +78,68 @@ int pageTransitionToNavigationType(ui::PageTransition transition)
}
}
-int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::CompletionCallback &callback, GURL *)
+NetworkDelegateQt::NetworkDelegateQt(URLRequestContextGetterQt *requestContext)
+ : m_requestContextGetter(requestContext)
+{
+}
+
+int NetworkDelegateQt::OnBeforeURLRequest(net::URLRequest *request, const net::CompletionCallback &callback, GURL *newUrl)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- const content::ResourceRequestInfo *info = content::ResourceRequestInfo::ForRequest(request);
- if (!info)
+ Q_ASSERT(m_requestContextGetter);
+ Q_ASSERT(m_requestContextGetter->m_browserContext);
+
+ const content::ResourceRequestInfo *resourceInfo = content::ResourceRequestInfo::ForRequest(request);
+
+ content::ResourceType resourceType = content::RESOURCE_TYPE_LAST_TYPE;
+ int navigationType = QWebEngineUrlRequestInfo::NavigationTypeOther;
+
+ if (resourceInfo) {
+ resourceType = resourceInfo->GetResourceType();
+ navigationType = pageTransitionToNavigationType(resourceInfo->GetPageTransition());
+ }
+
+ const QUrl qUrl = toQt(request->url());
+
+ QWebEngineUrlRequestInterceptor* interceptor = m_requestContextGetter->m_browserContext->requestInterceptor();
+ if (interceptor) {
+ QWebEngineUrlRequestInfoPrivate *infoPrivate = new QWebEngineUrlRequestInfoPrivate(static_cast<QWebEngineUrlRequestInfo::ResourceType>(resourceType)
+ , static_cast<QWebEngineUrlRequestInfo::NavigationType>(navigationType)
+ , qUrl
+ , QByteArray::fromStdString(request->method()));
+ QWebEngineUrlRequestInfo requestInfo(infoPrivate);
+ if (interceptor->interceptRequest(requestInfo)) {
+ int result = infoPrivate->shouldBlockRequest ? net::ERR_ABORTED : net::OK;
+
+ if (qUrl != infoPrivate->url)
+ *newUrl = toGurl(infoPrivate->url);
+
+ if (!infoPrivate->extraHeaders.isEmpty()) {
+ auto end = infoPrivate->extraHeaders.constEnd();
+ for (auto header = infoPrivate->extraHeaders.constBegin(); header != end; ++header)
+ request->SetExtraRequestHeaderByName(header.key().toStdString(), header.value().toStdString(), /* overwrite */ true);
+ }
+
+ return result;
+ }
+ }
+
+ if (!resourceInfo)
return net::OK;
- content::ResourceType resourceType = info->GetResourceType();
int renderProcessId;
int renderFrameId;
// Only intercept MAIN_FRAME and SUB_FRAME with an associated render frame.
- if (!content::IsResourceTypeFrame(resourceType) || !info->GetRenderFrameForRequest(request, &renderProcessId, &renderFrameId))
+ if (!content::IsResourceTypeFrame(resourceType) || !resourceInfo->GetRenderFrameForRequest(request, &renderProcessId, &renderFrameId))
return net::OK;
// Track active requests since |callback| and |new_url| are valid
// only until OnURLRequestDestroyed is called for this request.
m_activeRequests.insert(request);
- int navigationType = pageTransitionToNavigationType(info->GetPageTransition());
-
RequestParams params = {
- toQt(request->url()),
- info->IsMainFrame(),
+ qUrl,
+ resourceInfo->IsMainFrame(),
navigationType,
renderProcessId,
renderFrameId
@@ -172,4 +217,88 @@ void NetworkDelegateQt::NotifyNavigationRequestedOnUIThread(net::URLRequest *req
);
}
+bool NetworkDelegateQt::OnCanSetCookie(const net::URLRequest& request,
+ const std::string& cookie_line,
+ net::CookieOptions*)
+{
+ Q_ASSERT(m_requestContextGetter);
+ return m_requestContextGetter->m_cookieDelegate->canSetCookie(toQt(request.first_party_for_cookies()), QByteArray::fromStdString(cookie_line), toQt(request.url()));
+}
+
+void NetworkDelegateQt::OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*)
+{
+}
+
+void NetworkDelegateQt::OnProxyFallback(const net::ProxyServer&, int)
+{
+}
+
+int NetworkDelegateQt::OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*)
+{
+ return net::OK;
+}
+
+void NetworkDelegateQt::OnBeforeSendProxyHeaders(net::URLRequest*, const net::ProxyInfo&, net::HttpRequestHeaders*)
+{
+}
+
+void NetworkDelegateQt::OnSendHeaders(net::URLRequest*, const net::HttpRequestHeaders&)
+{
+}
+
+int NetworkDelegateQt::OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*)
+{
+ return net::OK;
+}
+
+void NetworkDelegateQt::OnBeforeRedirect(net::URLRequest*, const GURL&)
+{
+}
+
+void NetworkDelegateQt::OnResponseStarted(net::URLRequest*)
+{
+}
+
+void NetworkDelegateQt::OnRawBytesRead(const net::URLRequest&, int)
+{
+}
+
+void NetworkDelegateQt::OnCompleted(net::URLRequest*, bool)
+{
+}
+
+void NetworkDelegateQt::OnPACScriptError(int, const base::string16&)
+{
+}
+
+net::NetworkDelegate::AuthRequiredResponse NetworkDelegateQt::OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*)
+{
+ return AUTH_REQUIRED_RESPONSE_NO_ACTION;
+}
+
+bool NetworkDelegateQt::OnCanGetCookies(const net::URLRequest&, const net::CookieList&)
+{
+ return true;
+}
+
+bool NetworkDelegateQt::OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const
+{
+ return true;
+}
+
+bool NetworkDelegateQt::OnCanEnablePrivacyMode(const GURL&, const GURL&) const
+{
+ return false;
+}
+
+bool NetworkDelegateQt::OnFirstPartyOnlyCookieExperimentEnabled() const
+{
+ return false;
+}
+
+bool NetworkDelegateQt::OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const
+{
+ return false;
+}
+
} // namespace QtWebEngineCore
diff --git a/src/core/network_delegate_qt.h b/src/core/network_delegate_qt.h
index 4f4097fd3..41b5b98b6 100644
--- a/src/core/network_delegate_qt.h
+++ b/src/core/network_delegate_qt.h
@@ -42,19 +42,16 @@
#include <QUrl>
#include <QSet>
-#include <QtCore/qcompilerdetection.h> // Needed for Q_DECL_OVERRIDE
namespace QtWebEngineCore {
+class URLRequestContextGetterQt;
+
class NetworkDelegateQt : public net::NetworkDelegate {
+ QSet<net::URLRequest *> m_activeRequests;
+ URLRequestContextGetterQt *m_requestContextGetter;
public:
- NetworkDelegateQt() {}
- virtual ~NetworkDelegateQt() {}
-
- // net::NetworkDelegate implementation
- virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* new_url) Q_DECL_OVERRIDE;
- virtual void OnURLRequestDestroyed(net::URLRequest* request) Q_DECL_OVERRIDE;
- virtual bool OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const Q_DECL_OVERRIDE { return true; }
+ NetworkDelegateQt(URLRequestContextGetterQt *requestContext);
struct RequestParams {
QUrl url;
@@ -72,7 +69,27 @@ public:
int navigationRequestAction,
const net::CompletionCallback &callback);
- QSet<net::URLRequest *> m_activeRequests;
+ // net::NetworkDelegate implementation
+ virtual int OnBeforeURLRequest(net::URLRequest* request, const net::CompletionCallback& callback, GURL* newUrl) override;
+ virtual void OnURLRequestDestroyed(net::URLRequest* request) override;
+ virtual bool OnCanSetCookie(const net::URLRequest&, const std::string&, net::CookieOptions*) override;
+ virtual void OnResolveProxy(const GURL&, int, const net::ProxyService&, net::ProxyInfo*) override;
+ virtual void OnProxyFallback(const net::ProxyServer&, int) override;
+ virtual int OnBeforeSendHeaders(net::URLRequest*, const net::CompletionCallback&, net::HttpRequestHeaders*) override;
+ virtual void OnBeforeSendProxyHeaders(net::URLRequest*, const net::ProxyInfo&, net::HttpRequestHeaders*) override;
+ virtual void OnSendHeaders(net::URLRequest*, const net::HttpRequestHeaders&) override;
+ virtual int OnHeadersReceived(net::URLRequest*, const net::CompletionCallback&, const net::HttpResponseHeaders*, scoped_refptr<net::HttpResponseHeaders>*, GURL*) override;
+ virtual void OnBeforeRedirect(net::URLRequest*, const GURL&) override;
+ virtual void OnResponseStarted(net::URLRequest*) override;
+ virtual void OnRawBytesRead(const net::URLRequest&, int) override;
+ virtual void OnCompleted(net::URLRequest*, bool) override;
+ virtual void OnPACScriptError(int, const base::string16&) override;
+ virtual net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(net::URLRequest*, const net::AuthChallengeInfo&, const AuthCallback&, net::AuthCredentials*) override;
+ virtual bool OnCanGetCookies(const net::URLRequest&, const net::CookieList&) override;
+ virtual bool OnCanAccessFile(const net::URLRequest& request, const base::FilePath& path) const override;
+ virtual bool OnCanEnablePrivacyMode(const GURL&, const GURL&) const override;
+ virtual bool OnFirstPartyOnlyCookieExperimentEnabled() const override;
+ virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(const net::URLRequest&, const GURL&, const GURL&) const override;
};
} // namespace QtWebEngineCore
diff --git a/src/core/ozone_platform_eglfs.cpp b/src/core/ozone_platform_eglfs.cpp
index 43a3e4a11..834e41fdf 100644
--- a/src/core/ozone_platform_eglfs.cpp
+++ b/src/core/ozone_platform_eglfs.cpp
@@ -45,6 +45,7 @@
#include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/ozone/common/native_display_delegate_ozone.h"
+#include "ui/ozone/common/stub_overlay_manager.h"
#include "ui/ozone/public/ozone_platform.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
#include "ui/ozone/public/gpu_platform_support.h"
@@ -95,6 +96,7 @@ public:
void Restore() override { }
void SetCursor(PlatformCursor) override { }
void MoveCursorTo(const gfx::Point&) override { }
+ void ConfineCursorToBounds(const gfx::Rect&) override { }
// PlatformEventDispatcher:
bool CanDispatchEvent(const PlatformEvent& event) override;
@@ -160,6 +162,18 @@ scoped_ptr<PlatformWindow> OzonePlatformEglfs::CreatePlatformWindow(
bounds));
}
+ui::InputController* OzonePlatformEglfs::GetInputController() {
+ return input_controller_.get();
+}
+
+scoped_ptr<ui::SystemInputInjector> OzonePlatformEglfs::CreateSystemInputInjector() {
+ return nullptr; // no input injection support.
+}
+
+ui::OverlayManagerOzone* OzonePlatformEglfs::GetOverlayManager() {
+ return overlay_manager_.get();
+}
+
scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDelegate()
{
return scoped_ptr<NativeDisplayDelegate>(new NativeDisplayDelegateOzone());
@@ -168,10 +182,12 @@ scoped_ptr<ui::NativeDisplayDelegate> OzonePlatformEglfs::CreateNativeDisplayDel
OzonePlatform* CreateOzonePlatformEglfs() { return new OzonePlatformEglfs; }
void OzonePlatformEglfs::InitializeUI() {
+ overlay_manager_.reset(new StubOverlayManager());
device_manager_ = CreateDeviceManager();
cursor_factory_ozone_.reset(new CursorFactoryOzone());
- event_factory_ozone_.reset(new EventFactoryEvdev(NULL, device_manager_.get()));
+ event_factory_ozone_.reset(new EventFactoryEvdev(NULL, device_manager_.get(), NULL));
gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost());
+ input_controller_ = CreateStubInputController();
}
void OzonePlatformEglfs::InitializeGPU() {
diff --git a/src/core/ozone_platform_eglfs.h b/src/core/ozone_platform_eglfs.h
index 6954595dd..69ff2508f 100644
--- a/src/core/ozone_platform_eglfs.h
+++ b/src/core/ozone_platform_eglfs.h
@@ -62,6 +62,9 @@ class OzonePlatformEglfs : public OzonePlatform {
PlatformWindowDelegate* delegate,
const gfx::Rect& bounds) override;
virtual scoped_ptr<ui::NativeDisplayDelegate> CreateNativeDisplayDelegate() override;
+ virtual ui::InputController* GetInputController() override;
+ virtual scoped_ptr<ui::SystemInputInjector> CreateSystemInputInjector() override;
+ virtual ui::OverlayManagerOzone* GetOverlayManager() override;
private:
virtual void InitializeUI() override;
@@ -74,6 +77,8 @@ class OzonePlatformEglfs : public OzonePlatform {
scoped_ptr<GpuPlatformSupport> gpu_platform_support_;
scoped_ptr<GpuPlatformSupportHost> gpu_platform_support_host_;
+ scoped_ptr<InputController> input_controller_;
+ scoped_ptr<OverlayManagerOzone> overlay_manager_;
DISALLOW_COPY_AND_ASSIGN(OzonePlatformEglfs);
};
diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp
new file mode 100644
index 000000000..d89b530ee
--- /dev/null
+++ b/src/core/permission_manager_qt.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "permission_manager_qt.h"
+
+#include "content/browser/renderer_host/render_view_host_delegate.h"
+#include "content/public/browser/permission_type.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+
+#include "type_conversion.h"
+#include "web_contents_delegate_qt.h"
+
+namespace QtWebEngineCore {
+
+BrowserContextAdapter::PermissionType toQt(content::PermissionType type)
+{
+ switch (type) {
+ case content::PermissionType::GEOLOCATION:
+ return BrowserContextAdapter::GeolocationPermission;
+ case content::PermissionType::NOTIFICATIONS:
+ case content::PermissionType::MIDI_SYSEX:
+ case content::PermissionType::PUSH_MESSAGING:
+ case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
+ case content::PermissionType::NUM:
+ break;
+ }
+ return BrowserContextAdapter::UnsupportedPermission;
+}
+
+PermissionManagerQt::PermissionManagerQt(BrowserContextAdapter *contextAdapter)
+ : m_contextAdapter(contextAdapter)
+ , m_subscriberCount(0)
+{
+}
+
+PermissionManagerQt::~PermissionManagerQt()
+{
+}
+
+void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserContextAdapter::PermissionType type, bool reply)
+{
+ QPair<QUrl, BrowserContextAdapter::PermissionType> key(origin, type);
+ m_permissions[key] = reply;
+ content::PermissionStatus status = reply ? content::PERMISSION_STATUS_GRANTED : content::PERMISSION_STATUS_DENIED;
+ auto it = m_requests.begin();
+ const auto end = m_requests.end();
+ while (it != end) {
+ if (it->origin == origin && it->type == type) {
+ it->callback.Run(status);
+ it = m_requests.erase(it);
+ } else
+ ++it;
+ }
+ Q_FOREACH (const Subscriber &subscriber, m_subscribers) {
+ if (subscriber.origin == origin && subscriber.type == type)
+ subscriber.callback.Run(status);
+ }
+}
+
+void PermissionManagerQt::RequestPermission(content::PermissionType permission,
+ content::RenderFrameHost *frameHost,
+ int request_id,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ const base::Callback<void(content::PermissionStatus)>& callback)
+{
+ Q_UNUSED(user_gesture);
+ BrowserContextAdapter::PermissionType permissionType = toQt(permission);
+ if (permissionType == BrowserContextAdapter::UnsupportedPermission) {
+ callback.Run(content::PERMISSION_STATUS_DENIED);
+ return;
+ }
+
+ content::WebContents *webContents = frameHost->GetRenderViewHost()->GetDelegate()->GetAsWebContents();
+ WebContentsDelegateQt* contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
+ Q_ASSERT(contentsDelegate);
+ Request request = {
+ request_id,
+ permissionType,
+ toQt(requesting_origin),
+ callback
+ };
+ m_requests.append(request);
+ if (permissionType == BrowserContextAdapter::GeolocationPermission)
+ contentsDelegate->requestGeolocationPermission(request.origin);
+}
+
+void PermissionManagerQt::CancelPermissionRequest(content::PermissionType permission,
+ content::RenderFrameHost *frameHost,
+ int request_id,
+ const GURL& requesting_origin)
+{
+ Q_UNUSED(frameHost);
+ const BrowserContextAdapter::PermissionType permissionType = toQt(permission);
+ if (permissionType == BrowserContextAdapter::UnsupportedPermission)
+ return;
+
+ // Should we add API to cancel permissions in the UI level?
+ const QUrl origin = toQt(requesting_origin);
+ auto it = m_requests.begin();
+ const auto end = m_requests.end();
+ while (it != end) {
+ if (it->id == request_id && it->type == permissionType && it->origin == origin) {
+ m_requests.erase(it);
+ return;
+ }
+ }
+ qWarning() << "PermissionManagerQt::CancelPermissionRequest called on unknown request" << request_id << origin << permissionType;
+}
+
+content::PermissionStatus PermissionManagerQt::GetPermissionStatus(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& /*embedding_origin*/)
+{
+ const BrowserContextAdapter::PermissionType permissionType = toQt(permission);
+ if (permissionType == BrowserContextAdapter::UnsupportedPermission)
+ return content::PERMISSION_STATUS_DENIED;
+
+ QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType);
+ if (!m_permissions.contains(key))
+ return content::PERMISSION_STATUS_ASK;
+ if (m_permissions[key])
+ return content::PERMISSION_STATUS_GRANTED;
+ return content::PERMISSION_STATUS_DENIED;
+}
+
+void PermissionManagerQt::ResetPermission(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& /*embedding_origin*/)
+{
+ const BrowserContextAdapter::PermissionType permissionType = toQt(permission);
+ if (permissionType == BrowserContextAdapter::UnsupportedPermission)
+ return;
+
+ QPair<QUrl, BrowserContextAdapter::PermissionType> key(toQt(requesting_origin), permissionType);
+ m_permissions.remove(key);
+}
+
+void PermissionManagerQt::RegisterPermissionUsage(
+ content::PermissionType /*permission*/,
+ const GURL& /*requesting_origin*/,
+ const GURL& /*embedding_origin*/)
+{
+ // We do not currently track which permissions are used.
+}
+
+int PermissionManagerQt::SubscribePermissionStatusChange(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& /*embedding_origin*/,
+ const base::Callback<void(content::PermissionStatus)>& callback)
+{
+ Subscriber subscriber = {
+ m_subscriberCount++,
+ toQt(permission),
+ toQt(requesting_origin),
+ callback
+ };
+ m_subscribers.append(subscriber);
+ return subscriber.id;
+}
+
+void PermissionManagerQt::UnsubscribePermissionStatusChange(int subscription_id)
+{
+ for (int i = 0; i < m_subscribers.count(); i++) {
+ if (m_subscribers[i].id == subscription_id) {
+ m_subscribers.removeAt(i);
+ return;
+ }
+ }
+ qWarning() << "PermissionManagerQt::UnsubscribePermissionStatusChange called on unknown subscription id" << subscription_id;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/permission_manager_qt.h b/src/core/permission_manager_qt.h
new file mode 100644
index 000000000..d4ee72bae
--- /dev/null
+++ b/src/core/permission_manager_qt.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PERMISSION_MANAGER_QT_H
+#define PERMISSION_MANAGER_QT_H
+
+#include "base/callback.h"
+#include "content/public/browser/permission_manager.h"
+#include "browser_context_adapter.h"
+
+#include <QHash>
+#include <QList>
+
+namespace QtWebEngineCore {
+
+class PermissionManagerQt : public content::PermissionManager {
+
+public:
+ PermissionManagerQt(BrowserContextAdapter *);
+ ~PermissionManagerQt();
+ typedef BrowserContextAdapter::PermissionType PermissionType;
+
+ void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
+
+ // content::PermissionManager implementation:
+ void RequestPermission(
+ content::PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ int request_id,
+ const GURL& requesting_origin,
+ bool user_gesture,
+ const base::Callback<void(content::PermissionStatus)>& callback) override;
+
+ void CancelPermissionRequest(
+ content::PermissionType permission,
+ content::RenderFrameHost* render_frame_host,
+ int request_id,
+ const GURL& requesting_origin) override;
+
+ content::PermissionStatus GetPermissionStatus(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) override;
+
+ void ResetPermission(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) override;
+
+ void RegisterPermissionUsage(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin) override;
+
+ int SubscribePermissionStatusChange(
+ content::PermissionType permission,
+ const GURL& requesting_origin,
+ const GURL& embedding_origin,
+ const base::Callback<void(content::PermissionStatus)>& callback) override;
+
+ void UnsubscribePermissionStatusChange(int subscription_id) override;
+
+private:
+ BrowserContextAdapter *m_contextAdapter;
+ QHash<QPair<QUrl, PermissionType>, bool> m_permissions;
+ struct Request {
+ int id;
+ PermissionType type;
+ QUrl origin;
+ base::Callback<void(content::PermissionStatus)> callback;
+ };
+ QList<Request> m_requests;
+ struct Subscriber {
+ int id;
+ PermissionType type;
+ QUrl origin;
+ base::Callback<void(content::PermissionStatus)> callback;
+ };
+ int m_subscriberCount;
+ QList<Subscriber> m_subscribers;
+
+};
+
+} // namespace QtWebEngineCore
+
+#endif // PERMISSION_MANAGER_QT_H
diff --git a/src/core/proxy_config_service_qt.cpp b/src/core/proxy_config_service_qt.cpp
new file mode 100644
index 000000000..fc0959eef
--- /dev/null
+++ b/src/core/proxy_config_service_qt.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+// Copyright (c) 2011 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 "proxy_config_service_qt.h"
+
+#include "base/bind.h"
+#include "content/public/browser/browser_thread.h"
+
+using content::BrowserThread;
+
+net::ProxyServer ProxyConfigServiceQt::fromQNetworkProxy(const QNetworkProxy &qtProxy)
+{
+ net::ProxyServer::Scheme proxyScheme = net::ProxyServer::SCHEME_INVALID;
+ switch (qtProxy.type()) {
+ case QNetworkProxy::Socks5Proxy:
+ proxyScheme = net::ProxyServer::SCHEME_SOCKS5;
+ break;
+ case QNetworkProxy::HttpProxy:
+ case QNetworkProxy::HttpCachingProxy:
+ case QNetworkProxy::FtpCachingProxy:
+ proxyScheme = net::ProxyServer::SCHEME_HTTP;
+ break;
+ case QNetworkProxy::NoProxy:
+ default:
+ proxyScheme = net::ProxyServer::SCHEME_DIRECT;
+ break;
+ }
+ return net::ProxyServer(proxyScheme, net::HostPortPair(qtProxy.hostName().toStdString(), qtProxy.port()));
+}
+
+//================ Based on ChromeProxyConfigService =======================
+
+ProxyConfigServiceQt::ProxyConfigServiceQt(net::ProxyConfigService *baseService)
+ : m_baseService(baseService),
+ m_registeredObserver(false)
+{
+}
+
+ProxyConfigServiceQt::~ProxyConfigServiceQt()
+{
+ if (m_registeredObserver && m_baseService.get())
+ m_baseService->RemoveObserver(this);
+}
+
+void ProxyConfigServiceQt::AddObserver(net::ProxyConfigService::Observer *observer)
+{
+ RegisterObserver();
+ m_observers.AddObserver(observer);
+}
+
+void ProxyConfigServiceQt::RemoveObserver(net::ProxyConfigService::Observer *observer)
+{
+ m_observers.RemoveObserver(observer);
+}
+
+net::ProxyConfigService::ConfigAvailability ProxyConfigServiceQt::GetLatestProxyConfig(net::ProxyConfig *config)
+{
+ RegisterObserver();
+
+ // Ask the base service if available.
+ net::ProxyConfig systemConfig;
+ ConfigAvailability systemAvailability = net::ProxyConfigService::CONFIG_UNSET;
+ if (m_baseService.get())
+ systemAvailability = m_baseService->GetLatestProxyConfig(&systemConfig);
+
+ const QNetworkProxy &qtProxy = QNetworkProxy::applicationProxy();
+ if (qtProxy == m_qtApplicationProxy && !m_qtProxyConfig.proxy_rules().empty()) {
+ *config = m_qtProxyConfig;
+ return CONFIG_VALID;
+ }
+ m_qtApplicationProxy = qtProxy;
+ m_qtProxyConfig = net::ProxyConfig();
+ if (qtProxy.type() == QNetworkProxy::NoProxy) {
+ *config = systemConfig;
+ return systemAvailability;
+ }
+
+ net::ProxyConfig::ProxyRules qtRules;
+ net::ProxyServer server = fromQNetworkProxy(qtProxy);
+ switch (qtProxy.type()) {
+ case QNetworkProxy::HttpProxy:
+ case QNetworkProxy::Socks5Proxy:
+ qtRules.type = net::ProxyConfig::ProxyRules::TYPE_SINGLE_PROXY;
+ qtRules.single_proxies.SetSingleProxyServer(server);
+ break;
+ case QNetworkProxy::HttpCachingProxy:
+ qtRules.type = net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
+ qtRules.proxies_for_http.SetSingleProxyServer(server);
+ break;
+ case QNetworkProxy::FtpCachingProxy:
+ qtRules.type = net::ProxyConfig::ProxyRules::TYPE_PROXY_PER_SCHEME;
+ qtRules.proxies_for_ftp.SetSingleProxyServer(server);
+ break;
+ default:
+ qtRules.type = net::ProxyConfig::ProxyRules::TYPE_NO_RULES;
+ }
+
+ m_qtProxyConfig.proxy_rules() = qtRules;
+ *config = m_qtProxyConfig;
+ return CONFIG_VALID;
+}
+
+void ProxyConfigServiceQt::OnLazyPoll()
+{
+ if (m_qtApplicationProxy != QNetworkProxy::applicationProxy()) {
+ net::ProxyConfig unusedConfig;
+ OnProxyConfigChanged(unusedConfig, CONFIG_VALID);
+ }
+ if (m_baseService.get())
+ m_baseService->OnLazyPoll();
+}
+
+
+void ProxyConfigServiceQt::OnProxyConfigChanged(const net::ProxyConfig &config, ConfigAvailability availability)
+{
+ Q_UNUSED(config);
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+
+ if (m_qtApplicationProxy != QNetworkProxy::applicationProxy()
+ || m_qtApplicationProxy.type() == QNetworkProxy::NoProxy) {
+ net::ProxyConfig actual_config;
+ availability = GetLatestProxyConfig(&actual_config);
+ if (availability == CONFIG_PENDING)
+ return;
+ FOR_EACH_OBSERVER(net::ProxyConfigService::Observer, m_observers,
+ OnProxyConfigChanged(actual_config, availability));
+ }
+}
+
+void ProxyConfigServiceQt::RegisterObserver()
+{
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ if (!m_registeredObserver && m_baseService.get()) {
+ m_baseService->AddObserver(this);
+ m_registeredObserver = true;
+ }
+}
diff --git a/src/core/proxy_config_service_qt.h b/src/core/proxy_config_service_qt.h
new file mode 100644
index 000000000..ee4263314
--- /dev/null
+++ b/src/core/proxy_config_service_qt.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROXY_CONFIG_SERVICE_QT_H
+#define PROXY_CONFIG_SERVICE_QT_H
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
+
+#include "net/proxy/proxy_config.h"
+#include "net/proxy/proxy_config_service.h"
+
+#include <QNetworkProxy>
+
+class ProxyConfigServiceQt
+ : public net::ProxyConfigService,
+ public net::ProxyConfigService::Observer {
+public:
+
+ static net::ProxyServer fromQNetworkProxy(const QNetworkProxy &);
+
+ explicit ProxyConfigServiceQt(net::ProxyConfigService *baseService);
+ ~ProxyConfigServiceQt() override;
+
+ // ProxyConfigService implementation:
+ void AddObserver(net::ProxyConfigService::Observer *observer) override;
+ void RemoveObserver(net::ProxyConfigService::Observer *observer) override;
+ ConfigAvailability GetLatestProxyConfig(net::ProxyConfig *config) override;
+ void OnLazyPoll() override;
+
+private:
+ // ProxyConfigService::Observer implementation:
+ void OnProxyConfigChanged(const net::ProxyConfig& config,
+ ConfigAvailability availability) override;
+
+ // Makes sure that the observer registration with the base service is set up.
+ void RegisterObserver();
+
+ scoped_ptr<net::ProxyConfigService> m_baseService;
+ base::ObserverList<net::ProxyConfigService::Observer, true> m_observers;
+
+ // Keep the last QNetworkProxy::applicationProxy state around.
+ QNetworkProxy m_qtApplicationProxy;
+ net::ProxyConfig m_qtProxyConfig;
+
+ // Indicates whether the base service registration is done.
+ bool m_registeredObserver;
+
+ DISALLOW_COPY_AND_ASSIGN(ProxyConfigServiceQt);
+};
+
+#endif // PROXY_CONFIG_SERVICE_QT_H
diff --git a/src/core/qtwebengine.gypi b/src/core/qtwebengine.gypi
index cca2bd73f..7a6b26ab7 100644
--- a/src/core/qtwebengine.gypi
+++ b/src/core/qtwebengine.gypi
@@ -8,6 +8,8 @@
'dependencies': [
'<(chromium_src_dir)/base/base.gyp:base',
'<(chromium_src_dir)/base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '<(chromium_src_dir)/components/components.gyp:devtools_discovery',
+ '<(chromium_src_dir)/components/components.gyp:devtools_http_handler',
'<(chromium_src_dir)/components/components.gyp:error_page_renderer',
'<(chromium_src_dir)/components/components.gyp:visitedlink_browser',
'<(chromium_src_dir)/components/components.gyp:visitedlink_renderer',
@@ -16,6 +18,7 @@
'<(chromium_src_dir)/content/content.gyp:content_browser',
'<(chromium_src_dir)/content/content.gyp:content_common',
'<(chromium_src_dir)/content/content.gyp:content_gpu',
+ '<(chromium_src_dir)/content/content.gyp:content_ppapi_plugin',
'<(chromium_src_dir)/content/content.gyp:content_renderer',
'<(chromium_src_dir)/content/content.gyp:content_utility',
'<(chromium_src_dir)/content/app/resources/content_resources.gyp:content_resources',
@@ -81,6 +84,9 @@
],
},
},
+ 'dependencies': [
+ '<(chromium_src_dir)/ui/events/ozone/events_ozone.gyp:events_ozone_evdev'
+ ]
}],
['qt_os=="win32" and qt_gl=="opengl"', {
'include_dirs': [
diff --git a/src/core/qtwebengine_extras.gypi b/src/core/qtwebengine_extras.gypi
index e28d6436e..a5de08b55 100644
--- a/src/core/qtwebengine_extras.gypi
+++ b/src/core/qtwebengine_extras.gypi
@@ -57,6 +57,8 @@
['exclude', 'win/accessibility_ids_win\\.h$'],
['exclude', 'win/accessibility_misc_utils\\.(cc|h)$'],
['exclude', 'win/atl_module\\.h$'],
+ ['exclude', 'platform/ax_platform_node_win\\.(cc|h)$'],
+ ['exclude', 'audio_classifier\\.(cc|h)$'],
],
'defines': [
'TOOLKIT_QT',
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 572bc340c..7ca528954 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -36,10 +36,12 @@
#include "render_widget_host_view_qt.h"
+#include "common/qt_messages.h"
#include "browser_accessibility_manager_qt.h"
#include "browser_accessibility_qt.h"
#include "chromium_overrides.h"
#include "delegated_frame_node.h"
+#include "qtwebenginecoreglobal_p.h"
#include "render_widget_host_view_qt_delegate.h"
#include "type_conversion.h"
#include "web_contents_adapter.h"
@@ -60,10 +62,11 @@
#include "third_party/WebKit/public/platform/WebCursorInfo.h"
#include "third_party/WebKit/public/web/WebCompositionUnderline.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
+#include "ui/events/blink/blink_event_util.h"
#include "ui/events/event.h"
#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
#include "ui/events/gesture_detection/motion_event.h"
-#include "ui/gfx/size_conversions.h"
+#include "ui/gfx/geometry/size_conversions.h"
#include <QEvent>
#include <QFocusEvent>
@@ -142,7 +145,7 @@ static inline int firstAvailableId(const QMap<int, int> &map)
}
static inline ui::GestureProvider::Config QtGestureProviderConfig() {
- ui::GestureProvider::Config config = ui::DefaultGestureProviderConfig();
+ ui::GestureProvider::Config config = ui::GetGestureProviderConfig(ui::GestureProviderConfigType::CURRENT_PLATFORM);
// Causes an assert in CreateWebGestureEventFromGestureEventData and we don't need them in Qt.
config.gesture_begin_end_types_enabled = false;
config.gesture_detector_config.swipe_enabled = false;
@@ -180,12 +183,14 @@ static inline int flagsFromModifiers(Qt::KeyboardModifiers modifiers)
return modifierFlags;
}
+static uint32 s_eventId = 0;
class MotionEventQt : public ui::MotionEvent {
public:
MotionEventQt(const QList<QTouchEvent::TouchPoint> &touchPoints, const base::TimeTicks &eventTime, Action action, const Qt::KeyboardModifiers modifiers, int index = -1)
: touchPoints(touchPoints)
, eventTime(eventTime)
, action(action)
+ , eventId(++s_eventId)
, flags(flagsFromModifiers(modifiers))
, index(index)
{
@@ -193,7 +198,7 @@ public:
Q_ASSERT((action != ACTION_DOWN && action != ACTION_UP) || index == 0);
}
- virtual int GetId() const Q_DECL_OVERRIDE { return 0; }
+ virtual uint32 GetUniqueEventId() const Q_DECL_OVERRIDE { return eventId; }
virtual Action GetAction() const Q_DECL_OVERRIDE { return action; }
virtual int GetActionIndex() const Q_DECL_OVERRIDE { return index; }
virtual size_t GetPointerCount() const Q_DECL_OVERRIDE { return touchPoints.size(); }
@@ -232,6 +237,7 @@ private:
QList<QTouchEvent::TouchPoint> touchPoints;
base::TimeTicks eventTime;
Action action;
+ const uint32 eventId;
int flags;
int index;
};
@@ -408,6 +414,14 @@ gfx::Rect RenderWidgetHostViewQt::GetViewBounds() const
return gfx::BoundingRect(p1, p2);
}
+void RenderWidgetHostViewQt::SetBackgroundColor(SkColor color) {
+ RenderWidgetHostViewBase::SetBackgroundColor(color);
+ // Set the background of the compositor if necessary
+ m_delegate->setClearColor(toQt(color));
+ // Set the background of the blink::FrameView
+ m_host->Send(new QtRenderViewObserver_SetBackgroundColor(m_host->GetRoutingID(), color));
+}
+
// Return value indicates whether the mouse is locked successfully or not.
bool RenderWidgetHostViewQt::LockMouse()
{
@@ -426,27 +440,11 @@ void RenderWidgetHostViewQt::UnlockMouse()
m_host->LostMouseLock();
}
-void RenderWidgetHostViewQt::WasShown()
-{
- m_host->WasShown(ui::LatencyInfo());
-}
-
-void RenderWidgetHostViewQt::WasHidden()
-{
- m_host->WasHidden();
-}
-
void RenderWidgetHostViewQt::MovePluginWindows(const std::vector<content::WebPluginGeometry>&)
{
// QT_NOT_YET_IMPLEMENTED
}
-void RenderWidgetHostViewQt::Blur()
-{
- m_host->SetInputMethodActive(false);
- m_host->Blur();
-}
-
void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
{
content::WebCursor::CursorInfo cursorInfo;
@@ -600,13 +598,13 @@ void RenderWidgetHostViewQt::SelectionBoundsChanged(const ViewHostMsg_SelectionB
m_cursorRect = QRect(caretRect.x(), caretRect.y(), caretRect.width(), caretRect.height());
}
-void RenderWidgetHostViewQt::CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& dst_size, content::CopyFromCompositingSurfaceCallback& callback, const SkColorType color_type)
+void RenderWidgetHostViewQt::CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& dst_size, content::ReadbackRequestCallback& callback, const SkColorType color_type)
{
NOTIMPLEMENTED();
Q_UNUSED(src_subrect);
Q_UNUSED(dst_size);
Q_UNUSED(color_type);
- callback.Run(false, SkBitmap());
+ callback.Run(SkBitmap(), content::READBACK_FAILED);
}
void RenderWidgetHostViewQt::CopyFromCompositingSurfaceToVideoFrame(const gfx::Rect& src_subrect, const scoped_refptr<media::VideoFrame>& target, const base::Callback<void(bool)>& callback)
@@ -688,7 +686,7 @@ void RenderWidgetHostViewQt::SelectionChanged(const base::string16 &text, size_t
void RenderWidgetHostViewQt::OnGestureEvent(const ui::GestureEventData& gesture)
{
- m_host->ForwardGestureEvent(content::CreateWebGestureEventFromGestureEventData(gesture));
+ m_host->ForwardGestureEvent(ui::CreateWebGestureEventFromGestureEventData(gesture));
}
QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode)
@@ -717,12 +715,12 @@ void RenderWidgetHostViewQt::notifyResize()
void RenderWidgetHostViewQt::notifyShown()
{
- WasShown();
+ m_host->WasShown(ui::LatencyInfo());
}
void RenderWidgetHostViewQt::notifyHidden()
{
- WasHidden();
+ m_host->WasHidden();
}
void RenderWidgetHostViewQt::windowBoundsChanged()
@@ -808,7 +806,7 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) co
void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) {
Q_UNUSED(touch);
const bool eventConsumed = ack_result == content::INPUT_EVENT_ACK_STATE_CONSUMED;
- m_gestureProvider.OnTouchEventAck(eventConsumed);
+ m_gestureProvider.OnTouchEventAck(touch.event.uniqueTouchEventId, eventConsumed);
}
void RenderWidgetHostViewQt::sendDelegatedFrameAck()
@@ -822,16 +820,10 @@ void RenderWidgetHostViewQt::sendDelegatedFrameAck()
void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEvent)
{
- if (!m_gestureProvider.OnTouchEvent(motionEvent))
+ if (!m_gestureProvider.OnTouchEvent(motionEvent).succeeded)
return;
- // Short-circuit touch forwarding if no touch handlers exist.
- if (!m_host->ShouldForwardTouchEvent()) {
- const bool eventConsumed = false;
- m_gestureProvider.OnTouchEventAck(eventConsumed);
- return;
- }
- blink::WebTouchEvent touchEvent = content::CreateWebTouchEventFromMotionEvent(motionEvent);
+ blink::WebTouchEvent touchEvent = ui::CreateWebTouchEventFromMotionEvent(motionEvent, false);
m_host->ForwardTouchEventWithLatencyInfo(touchEvent, CreateLatencyInfo(touchEvent));
}
@@ -931,14 +923,9 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev)
if (preeditString.isEmpty())
break;
- QTextCharFormat textCharFormat = attribute.value.value<QTextFormat>().toCharFormat();
- QColor qcolor = textCharFormat.underlineColor();
- QColor qBackgroundColor = textCharFormat.background().color();
- blink::WebColor color = SkColorSetARGB(qcolor.alpha(), qcolor.red(), qcolor.green(), qcolor.blue());
- blink::WebColor backgroundColor = SkColorSetARGB(qBackgroundColor.alpha(), qBackgroundColor.red(), qBackgroundColor.green(), qBackgroundColor.blue());
int start = qMin(attribute.start, (attribute.start + attribute.length));
int end = qMax(attribute.start, (attribute.start + attribute.length));
- underlines.push_back(blink::WebCompositionUnderline(start, end, color, false, backgroundColor));
+ underlines.push_back(blink::WebCompositionUnderline(start, end, /*color*/ SK_ColorBLACK, /*thick*/ false, /*backgroundColor*/ SK_ColorTRANSPARENT));
break;
}
case QInputMethodEvent::Cursor:
diff --git a/src/core/render_widget_host_view_qt.h b/src/core/render_widget_host_view_qt.h
index 248c52f6e..274138dcf 100644
--- a/src/core/render_widget_host_view_qt.h
+++ b/src/core/render_widget_host_view_qt.h
@@ -47,6 +47,7 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/view_messages.h"
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
+#include "qtwebenginecoreglobal_p.h"
#include <QMap>
#include <QPoint>
#include <QRect>
@@ -125,12 +126,10 @@ public:
virtual void Hide() Q_DECL_OVERRIDE;
virtual bool IsShowing() Q_DECL_OVERRIDE;
virtual gfx::Rect GetViewBounds() const Q_DECL_OVERRIDE;
+ virtual void SetBackgroundColor(SkColor color) Q_DECL_OVERRIDE;
virtual bool LockMouse() Q_DECL_OVERRIDE;
virtual void UnlockMouse() Q_DECL_OVERRIDE;
- virtual void WasShown() Q_DECL_OVERRIDE;
- virtual void WasHidden() Q_DECL_OVERRIDE;
virtual void MovePluginWindows(const std::vector<content::WebPluginGeometry>&) Q_DECL_OVERRIDE;
- virtual void Blur() Q_DECL_OVERRIDE;
virtual void UpdateCursor(const content::WebCursor&) Q_DECL_OVERRIDE;
virtual void SetIsLoading(bool) Q_DECL_OVERRIDE;
virtual void TextInputTypeChanged(ui::TextInputType type, ui::TextInputMode mode, bool can_compose_inline, int flags) Q_DECL_OVERRIDE;
@@ -140,7 +139,7 @@ public:
virtual void Destroy() Q_DECL_OVERRIDE;
virtual void SetTooltipText(const base::string16 &tooltip_text) Q_DECL_OVERRIDE;
virtual void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params&) Q_DECL_OVERRIDE;
- virtual void CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& dst_size, content::CopyFromCompositingSurfaceCallback& callback, const SkColorType color_type) Q_DECL_OVERRIDE;
+ virtual void CopyFromCompositingSurface(const gfx::Rect& src_subrect, const gfx::Size& dst_size, content::ReadbackRequestCallback& callback, const SkColorType color_type) Q_DECL_OVERRIDE;
virtual void CopyFromCompositingSurfaceToVideoFrame(const gfx::Rect& src_subrect, const scoped_refptr<media::VideoFrame>& target, const base::Callback<void(bool)>& callback) Q_DECL_OVERRIDE;
virtual bool CanCopyToVideoFrame() const Q_DECL_OVERRIDE;
virtual bool HasAcceleratedSurface(const gfx::Size&) Q_DECL_OVERRIDE;
diff --git a/src/core/render_widget_host_view_qt_delegate.h b/src/core/render_widget_host_view_qt_delegate.h
index da595b91f..f4aa9b27d 100644
--- a/src/core/render_widget_host_view_qt_delegate.h
+++ b/src/core/render_widget_host_view_qt_delegate.h
@@ -96,6 +96,7 @@ public:
virtual void move(const QPoint &) = 0;
virtual void inputMethodStateChanged(bool editorVisible) = 0;
virtual void setTooltip(const QString &) = 0;
+ virtual void setClearColor(const QColor &color) = 0;
};
} // namespace QtWebEngineCore
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp
index e1333144a..8f239fc73 100644
--- a/src/core/renderer/content_renderer_client_qt.cpp
+++ b/src/core/renderer/content_renderer_client_qt.cpp
@@ -51,6 +51,7 @@
#include "content/public/common/web_preferences.h"
#include "renderer/web_channel_ipc_transport.h"
+#include "renderer/qt_render_frame_observer.h"
#include "renderer/qt_render_view_observer.h"
#include "renderer/user_script_controller.h"
@@ -85,6 +86,11 @@ void ContentRendererClientQt::RenderViewCreated(content::RenderView* render_view
UserScriptController::instance()->renderViewCreated(render_view);
}
+void ContentRendererClientQt::RenderFrameCreated(content::RenderFrame* render_frame)
+{
+ new QtWebEngineCore::QtRenderFrameObserver(render_frame);
+}
+
bool ContentRendererClientQt::HasErrorPage(int httpStatusCode, std::string *errorDomain)
{
// Use an internal error page, if we have one for the status code.
@@ -105,7 +111,7 @@ bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *fram
void ContentRendererClientQt::GetNavigationErrorStrings(content::RenderView* renderView, blink::WebFrame *frame, const blink::WebURLRequest &failedRequest, const blink::WebURLError &error, std::string *errorHtml, base::string16 *errorDescription)
{
Q_UNUSED(frame)
- const bool isPost = EqualsASCII(failedRequest.httpMethod(), "POST");
+ const bool isPost = base::EqualsASCII(failedRequest.httpMethod(), "POST");
if (errorHtml) {
// Use a local error page.
diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h
index dcb4e7fcb..fab88441f 100644
--- a/src/core/renderer/content_renderer_client_qt.h
+++ b/src/core/renderer/content_renderer_client_qt.h
@@ -53,7 +53,7 @@ public:
~ContentRendererClientQt();
virtual void RenderThreadStarted() Q_DECL_OVERRIDE;
virtual void RenderViewCreated(content::RenderView *render_view) Q_DECL_OVERRIDE;
-
+ virtual void RenderFrameCreated(content::RenderFrame* render_frame) Q_DECL_OVERRIDE;
virtual bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &) Q_DECL_OVERRIDE;
virtual bool HasErrorPage(int httpStatusCode, std::string *errorDomain) Q_DECL_OVERRIDE;
virtual void GetNavigationErrorStrings(content::RenderView* renderView, blink::WebFrame* frame, const blink::WebURLRequest& failedRequest
diff --git a/src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp
new file mode 100644
index 000000000..625e89ae4
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_flash_browser_host_qt.cpp
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Copyright (c) 2012 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 "pepper_flash_browser_host_qt.h"
+
+#include "base/time/time.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_ppapi_host.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_process_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_flash.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/shared_impl/time_conversion.h"
+#include "qtwebenginecoreglobal_p.h"
+#include "url/gurl.h"
+
+#if defined(OS_WIN)
+#include <windows.h>
+#elif defined(OS_MACOSX)
+#include <CoreServices/CoreServices.h>
+#endif
+
+using content::BrowserPpapiHost;
+using content::BrowserThread;
+using content::RenderProcessHost;
+
+namespace QtWebEngineCore {
+
+
+PepperFlashBrowserHostQt::PepperFlashBrowserHostQt(BrowserPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ host_(host),
+ weak_factory_(this)
+{
+ int unused;
+ host->GetRenderFrameIDsForInstance(instance, &render_process_id_, &unused);
+}
+
+PepperFlashBrowserHostQt::~PepperFlashBrowserHostQt() {}
+
+int32_t PepperFlashBrowserHostQt::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context)
+{
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFlashBrowserHostQt, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_UpdateActivity,
+ OnUpdateActivity)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetLocalTimeZoneOffset,
+ OnGetLocalTimeZoneOffset)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_GetLocalDataRestrictions,
+ OnGetLocalDataRestrictions)
+ PPAPI_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashBrowserHostQt::OnUpdateActivity(ppapi::host::HostMessageContext* host_context)
+{
+#if defined(OS_WIN)
+ // Reading then writing back the same value to the screensaver timeout system
+ // setting resets the countdown which prevents the screensaver from turning
+ // on "for a while". As long as the plugin pings us with this message faster
+ // than the screensaver timeout, it won't go on.
+ int value = 0;
+ if (SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0, &value, 0))
+ SystemParametersInfo(SPI_SETSCREENSAVETIMEOUT, value, NULL, 0);
+#elif defined(OS_MACOSX)
+ UpdateSystemActivity(OverallAct);
+#endif
+ return PP_OK;
+}
+
+int32_t PepperFlashBrowserHostQt::OnGetLocalTimeZoneOffset(
+ ppapi::host::HostMessageContext* host_context,
+ const base::Time& t)
+{
+ // The reason for this processing being in the browser process is that on
+ // Linux, the localtime calls require filesystem access prohibited by the
+ // sandbox.
+ host_context->reply_msg = PpapiPluginMsg_Flash_GetLocalTimeZoneOffsetReply(
+ ppapi::PPGetLocalTimeZoneOffset(t));
+ return PP_OK;
+}
+
+int32_t PepperFlashBrowserHostQt::OnGetLocalDataRestrictions(
+ ppapi::host::HostMessageContext* context)
+{
+ QT_NOT_YET_IMPLEMENTED
+ return PP_OK;
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_flash_browser_host_qt.h b/src/core/renderer/pepper/pepper_flash_browser_host_qt.h
new file mode 100644
index 000000000..c5165a1b0
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_flash_browser_host_qt.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEPPER_FLASH_BROWSER_HOST_QT_H
+#define PEPPER_FLASH_BROWSER_HOST_QT_H
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+namespace base {
+class Time;
+}
+
+namespace content {
+class BrowserPpapiHost;
+class ResourceContext;
+}
+
+class GURL;
+
+namespace QtWebEngineCore {
+
+class PepperFlashBrowserHostQt : public ppapi::host::ResourceHost {
+public:
+ PepperFlashBrowserHostQt(content::BrowserPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+ ~PepperFlashBrowserHostQt() override;
+
+ // ppapi::host::ResourceHost override.
+ int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) override;
+
+private:
+ int32_t OnUpdateActivity(ppapi::host::HostMessageContext* host_context);
+ int32_t OnGetLocalTimeZoneOffset(
+ ppapi::host::HostMessageContext* host_context,
+ const base::Time& t);
+ int32_t OnGetLocalDataRestrictions(ppapi::host::HostMessageContext* context);
+
+ void GetLocalDataRestrictions(ppapi::host::ReplyMessageContext reply_context,
+ const GURL& document_url,
+ const GURL& plugin_url);
+
+ content::BrowserPpapiHost* host_;
+ int render_process_id_;
+ base::WeakPtrFactory<PepperFlashBrowserHostQt> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashBrowserHostQt);
+};
+
+} // namespace QtWebEngineCore
+
+#endif // PEPPER_FLASH_BROWSER_HOST_QT_H
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
new file mode 100644
index 000000000..8e68d1682
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.cpp
@@ -0,0 +1,349 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// Copyright (c) 2012 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 "pepper_flash_renderer_host_qt.h"
+
+#include <map>
+#include <vector>
+
+#include "base/lazy_instance.h"
+#include "base/metrics/histogram.h"
+#include "base/strings/string_util.h"
+#include "content/public/renderer/pepper_plugin_instance.h"
+#include "content/public/renderer/render_thread.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ipc/ipc_message_macros.h"
+#include "net/http/http_util.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/proxy/host_dispatcher.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/proxy/serialized_structs.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_image_data_api.h"
+#include "skia/ext/platform_canvas.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "third_party/skia/include/core/SkMatrix.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "third_party/skia/include/core/SkPoint.h"
+#include "third_party/skia/include/core/SkTemplates.h"
+#include "third_party/skia/include/core/SkTypeface.h"
+#include "ui/gfx/geometry/rect.h"
+#include "url/gurl.h"
+
+using ppapi::thunk::EnterResourceNoLock;
+using ppapi::thunk::PPB_ImageData_API;
+
+namespace {
+
+// Some non-simple HTTP request headers that Flash may set.
+// (Please see http://www.w3.org/TR/cors/#simple-header for the definition of
+// simple headers.)
+//
+// The list and the enum defined below are used to collect data about request
+// headers used in PPB_Flash.Navigate() calls, in order to understand the impact
+// of rejecting PPB_Flash.Navigate() requests with non-simple headers.
+//
+// TODO(yzshen): We should be able to remove the histogram recording code once
+// we get the answer.
+const char* const kRejectedHttpRequestHeaders[] = {
+ "authorization", //
+ "cache-control", //
+ "content-encoding", //
+ "content-md5", //
+ "content-type", // If the media type is not one of those covered by the
+ // simple header definition.
+ "expires", //
+ "from", //
+ "if-match", //
+ "if-none-match", //
+ "if-range", //
+ "if-unmodified-since", //
+ "pragma", //
+ "referer" //
+};
+
+// Please note that new entries should be added right above
+// FLASH_NAVIGATE_USAGE_ENUM_COUNT, and existing entries shouldn't be re-ordered
+// or removed, since this ordering is used in a histogram.
+enum FlashNavigateUsage {
+ // This section must be in the same order as kRejectedHttpRequestHeaders.
+ REJECT_AUTHORIZATION = 0,
+ REJECT_CACHE_CONTROL,
+ REJECT_CONTENT_ENCODING,
+ REJECT_CONTENT_MD5,
+ REJECT_CONTENT_TYPE,
+ REJECT_EXPIRES,
+ REJECT_FROM,
+ REJECT_IF_MATCH,
+ REJECT_IF_NONE_MATCH,
+ REJECT_IF_RANGE,
+ REJECT_IF_UNMODIFIED_SINCE,
+ REJECT_PRAGMA,
+ REJECT_REFERER,
+
+ // The navigate request is rejected because of headers not listed above
+ // (e.g., custom headers).
+ REJECT_OTHER_HEADERS,
+
+ // Total number of rejected navigate requests.
+ TOTAL_REJECTED_NAVIGATE_REQUESTS,
+
+ // Total number of navigate requests.
+ TOTAL_NAVIGATE_REQUESTS,
+ FLASH_NAVIGATE_USAGE_ENUM_COUNT
+};
+
+static base::LazyInstance<std::map<std::string, FlashNavigateUsage> >
+g_rejected_headers = LAZY_INSTANCE_INITIALIZER;
+
+bool IsSimpleHeader(const std::string& lower_case_header_name,
+ const std::string& header_value)
+{
+ if (lower_case_header_name == "accept" ||
+ lower_case_header_name == "accept-language" ||
+ lower_case_header_name == "content-language")
+ return true;
+
+ if (lower_case_header_name == "content-type") {
+ std::string lower_case_mime_type;
+ std::string lower_case_charset;
+ bool had_charset = false;
+ net::HttpUtil::ParseContentType(header_value,
+ &lower_case_mime_type,
+ &lower_case_charset,
+ &had_charset,
+ NULL);
+ return lower_case_mime_type == "application/x-www-form-urlencoded" ||
+ lower_case_mime_type == "multipart/form-data" ||
+ lower_case_mime_type == "text/plain";
+ }
+
+ return false;
+}
+
+void RecordFlashNavigateUsage(FlashNavigateUsage usage)
+{
+ DCHECK_NE(FLASH_NAVIGATE_USAGE_ENUM_COUNT, usage);
+ UMA_HISTOGRAM_ENUMERATION(
+ "Plugin.FlashNavigateUsage",
+ usage,
+ FLASH_NAVIGATE_USAGE_ENUM_COUNT);
+}
+
+} // namespace
+
+namespace QtWebEngineCore {
+
+PepperFlashRendererHostQt::PepperFlashRendererHostQt(
+ content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ host_(host),
+ weak_factory_(this)
+{
+}
+
+PepperFlashRendererHostQt::~PepperFlashRendererHostQt() {
+ // This object may be destroyed in the middle of a sync message. If that is
+ // the case, make sure we respond to all the pending navigate calls.
+ std::vector<ppapi::host::ReplyMessageContext>::reverse_iterator it;
+ for (it = navigate_replies_.rbegin(); it != navigate_replies_.rend(); ++it)
+ SendReply(*it, IPC::Message());
+}
+
+int32_t PepperFlashRendererHostQt::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context)
+{
+ PPAPI_BEGIN_MESSAGE_MAP(PepperFlashRendererHostQt, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_GetProxyForURL,
+ OnGetProxyForURL)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_SetInstanceAlwaysOnTop,
+ OnSetInstanceAlwaysOnTop)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_DrawGlyphs,
+ OnDrawGlyphs)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_Navigate, OnNavigate)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_Flash_IsRectTopmost,
+ OnIsRectTopmost)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_Flash_InvokePrinting,
+ OnInvokePrinting)
+ PPAPI_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashRendererHostQt::OnGetProxyForURL(
+ ppapi::host::HostMessageContext* host_context,
+ const std::string& url)
+{
+ GURL gurl(url);
+ if (!gurl.is_valid())
+ return PP_ERROR_FAILED;
+ std::string proxy;
+ bool result = content::RenderThread::Get()->ResolveProxy(gurl, &proxy);
+ if (!result)
+ return PP_ERROR_FAILED;
+ host_context->reply_msg = PpapiPluginMsg_Flash_GetProxyForURLReply(proxy);
+ return PP_OK;
+}
+
+int32_t PepperFlashRendererHostQt::OnSetInstanceAlwaysOnTop(
+ ppapi::host::HostMessageContext* host_context,
+ bool on_top)
+{
+ content::PepperPluginInstance* plugin_instance =
+ host_->GetPluginInstance(pp_instance());
+ if (plugin_instance)
+ plugin_instance->SetAlwaysOnTop(on_top);
+ return PP_OK;
+}
+
+int32_t PepperFlashRendererHostQt::OnDrawGlyphs(
+ ppapi::host::HostMessageContext* host_context,
+ ppapi::proxy::PPBFlash_DrawGlyphs_Params params)
+{
+ if (params.glyph_indices.size() != params.glyph_advances.size() ||
+ params.glyph_indices.empty())
+ return PP_ERROR_FAILED;
+
+ return PP_OK;
+}
+
+// CAUTION: This code is subtle because Navigate is a sync call which may
+// cause re-entrancy or cause the instance to be destroyed. If the instance
+// is destroyed we need to ensure that we respond to all outstanding sync
+// messages so that the plugin process does not remain blocked.
+int32_t PepperFlashRendererHostQt::OnNavigate(
+ ppapi::host::HostMessageContext* host_context,
+ const ppapi::URLRequestInfoData& data,
+ const std::string& target,
+ bool from_user_action)
+{
+ // If our PepperPluginInstance is already destroyed, just return a failure.
+ content::PepperPluginInstance* plugin_instance =
+ host_->GetPluginInstance(pp_instance());
+ if (!plugin_instance)
+ return PP_ERROR_FAILED;
+
+ std::map<std::string, FlashNavigateUsage>& rejected_headers =
+ g_rejected_headers.Get();
+ if (rejected_headers.empty()) {
+ for (size_t i = 0; i < arraysize(kRejectedHttpRequestHeaders); ++i)
+ rejected_headers[kRejectedHttpRequestHeaders[i]] =
+ static_cast<FlashNavigateUsage>(i);
+ }
+
+ net::HttpUtil::HeadersIterator header_iter(
+ data.headers.begin(), data.headers.end(), "\n\r");
+ bool rejected = false;
+ while (header_iter.GetNext()) {
+ std::string lower_case_header_name =
+ base::StringToLowerASCII(header_iter.name());
+ if (!IsSimpleHeader(lower_case_header_name, header_iter.values())) {
+ rejected = true;
+
+ std::map<std::string, FlashNavigateUsage>::const_iterator iter =
+ rejected_headers.find(lower_case_header_name);
+ FlashNavigateUsage usage =
+ iter != rejected_headers.end() ? iter->second : REJECT_OTHER_HEADERS;
+ RecordFlashNavigateUsage(usage);
+ }
+ }
+
+ RecordFlashNavigateUsage(TOTAL_NAVIGATE_REQUESTS);
+ if (rejected) {
+ RecordFlashNavigateUsage(TOTAL_REJECTED_NAVIGATE_REQUESTS);
+ return PP_ERROR_NOACCESS;
+ }
+
+ // Navigate may call into Javascript (e.g. with a "javascript:" URL),
+ // or do things like navigate away from the page, either one of which will
+ // need to re-enter into the plugin. It is safe, because it is essentially
+ // equivalent to NPN_GetURL, where Flash would expect re-entrancy.
+ ppapi::proxy::HostDispatcher* host_dispatcher =
+ ppapi::proxy::HostDispatcher::GetForInstance(pp_instance());
+ host_dispatcher->set_allow_plugin_reentrancy();
+
+ // Grab a weak pointer to ourselves on the stack so we can check if we are
+ // still alive.
+ base::WeakPtr<PepperFlashRendererHostQt> weak_ptr = weak_factory_.GetWeakPtr();
+ // Keep track of reply contexts in case we are destroyed during a Navigate
+ // call. Even if we are destroyed, we still need to send these replies to
+ // unblock the plugin process.
+ navigate_replies_.push_back(host_context->MakeReplyMessageContext());
+ plugin_instance->Navigate(data, target.c_str(), from_user_action);
+ // This object might have been destroyed by this point. If it is destroyed
+ // the reply will be sent in the destructor. Otherwise send the reply here.
+ if (weak_ptr.get()) {
+ SendReply(navigate_replies_.back(), IPC::Message());
+ navigate_replies_.pop_back();
+ }
+
+ // Return PP_OK_COMPLETIONPENDING so that no reply is automatically sent.
+ return PP_OK_COMPLETIONPENDING;
+}
+
+int32_t PepperFlashRendererHostQt::OnIsRectTopmost(
+ ppapi::host::HostMessageContext* host_context,
+ const PP_Rect& rect)
+{
+ content::PepperPluginInstance* plugin_instance =
+ host_->GetPluginInstance(pp_instance());
+ if (plugin_instance &&
+ plugin_instance->IsRectTopmost(
+ gfx::Rect(
+ rect.point.x,
+ rect.point.y,
+ rect.size.width,
+ rect.size.height)))
+ return PP_OK;
+ return PP_ERROR_FAILED;
+}
+
+int32_t PepperFlashRendererHostQt::OnInvokePrinting(
+ ppapi::host::HostMessageContext* host_context)
+{
+ return PP_ERROR_FAILED;
+}
+
+} //QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
new file mode 100644
index 000000000..4a731fad4
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_flash_renderer_host_qt.h
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEPPER_FLASH_RENDERER_HOST_QT_H
+#define PEPPER_FLASH_RENDERER_HOST_QT_H
+
+#include <string>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/memory/weak_ptr.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/resource_host.h"
+
+struct PP_Rect;
+
+namespace ppapi {
+struct URLRequestInfoData;
+}
+
+namespace ppapi {
+namespace proxy {
+struct PPBFlash_DrawGlyphs_Params;
+}
+}
+
+namespace content {
+class RendererPpapiHost;
+}
+
+namespace QtWebEngineCore {
+
+class PepperFlashRendererHostQt : public ppapi::host::ResourceHost {
+public:
+ PepperFlashRendererHostQt(content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+ ~PepperFlashRendererHostQt() override;
+
+ // ppapi::host::ResourceHost override.
+ int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) override;
+
+private:
+ int32_t OnGetProxyForURL(ppapi::host::HostMessageContext* host_context,
+ const std::string& url);
+ int32_t OnSetInstanceAlwaysOnTop(
+ ppapi::host::HostMessageContext* host_context,
+ bool on_top);
+ int32_t OnDrawGlyphs(ppapi::host::HostMessageContext* host_context,
+ ppapi::proxy::PPBFlash_DrawGlyphs_Params params);
+ int32_t OnNavigate(ppapi::host::HostMessageContext* host_context,
+ const ppapi::URLRequestInfoData& data,
+ const std::string& target,
+ bool from_user_action);
+ int32_t OnIsRectTopmost(ppapi::host::HostMessageContext* host_context,
+ const PP_Rect& rect);
+ int32_t OnInvokePrinting(ppapi::host::HostMessageContext* host_context);
+
+ // A stack of ReplyMessageContexts to track Navigate() calls which have not
+ // yet been replied to.
+ std::vector<ppapi::host::ReplyMessageContext> navigate_replies_;
+
+ content::RendererPpapiHost* host_;
+ base::WeakPtrFactory<PepperFlashRendererHostQt> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperFlashRendererHostQt);
+};
+
+} //QtWebEngineCore
+#endif // PEPPER_FLASH_RENDERER_HOST_QT_H
diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_host_factory_qt.cpp
new file mode 100644
index 000000000..61eeac9a0
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_host_factory_qt.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pepper_host_factory_qt.h"
+
+#include "build/build_config.h"
+#include "content/public/browser/browser_ppapi_host.h"
+#include "ppapi/host/message_filter_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+#include "pepper_flash_browser_host_qt.h"
+
+using ppapi::host::MessageFilterHost;
+using ppapi::host::ResourceHost;
+using ppapi::host::ResourceMessageFilter;
+
+namespace QtWebEngineCore {
+
+PepperHostFactoryQt::PepperHostFactoryQt(content::BrowserPpapiHost* host)
+ : host_(host)
+{
+}
+
+PepperHostFactoryQt::~PepperHostFactoryQt() {}
+
+scoped_ptr<ppapi::host::ResourceHost> PepperHostFactoryQt::CreateResourceHost(ppapi::host::PpapiHost* host,
+ PP_Resource resource,
+ PP_Instance instance,
+ const IPC::Message& message)
+{
+ DCHECK(host == host_->GetPpapiHost());
+
+
+ if (!host_->IsValidInstance(instance))
+ return scoped_ptr<ppapi::host::ResourceHost>();
+
+ if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)
+ && message.type() == PpapiHostMsg_Flash_Create::ID)
+ return scoped_ptr<ppapi::host::ResourceHost>(
+ new PepperFlashBrowserHostQt(host_,
+ instance,
+ resource));
+
+ return scoped_ptr<ppapi::host::ResourceHost>();
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_host_factory_qt.h b/src/core/renderer/pepper/pepper_host_factory_qt.h
new file mode 100644
index 000000000..22bf87b1b
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_host_factory_qt.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEPPER_HOST_FACTORY_QT_H
+#define PEPPER_HOST_FACTORY_QT_H
+
+#include "base/compiler_specific.h"
+#include "ppapi/host/host_factory.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/host/ppapi_host.h"
+
+namespace content {
+class BrowserPpapiHost;
+} // namespace content
+
+namespace QtWebEngineCore {
+
+class PepperHostFactoryQt final : public ppapi::host::HostFactory {
+public:
+ // Non-owning pointer to the filter must outlive this class.
+ explicit PepperHostFactoryQt(content::BrowserPpapiHost* host);
+ ~PepperHostFactoryQt() override;
+
+ virtual scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+ ppapi::host::PpapiHost* host,
+ PP_Resource resource,
+ PP_Instance instance,
+ const IPC::Message& message) override;
+private:
+ // Non-owning pointer.
+ content::BrowserPpapiHost* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperHostFactoryQt);
+};
+} // namespace QtWebEngineCore
+
+#endif // PEPPER_HOST_FACTORY_QT_H
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
new file mode 100644
index 000000000..51416d698
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pepper_renderer_host_factory_qt.h"
+#include "pepper_flash_renderer_host_qt.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/host/resource_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/ppapi_message_utils.h"
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+
+namespace QtWebEngineCore {
+
+PepperRendererHostFactoryQt::PepperRendererHostFactoryQt(content::RendererPpapiHost* host)
+ : host_(host)
+{
+}
+
+PepperRendererHostFactoryQt::~PepperRendererHostFactoryQt()
+{
+}
+
+scoped_ptr<ppapi::host::ResourceHost> PepperRendererHostFactoryQt::CreateResourceHost(
+ ppapi::host::PpapiHost* host,
+ PP_Resource resource,
+ PP_Instance instance,
+ const IPC::Message& message)
+{
+ DCHECK_EQ(host_->GetPpapiHost(), host);
+
+ if (!host_->IsValidInstance(instance))
+ return scoped_ptr<ppapi::host::ResourceHost>();
+
+ if (host_->GetPpapiHost()->permissions().HasPermission(ppapi::PERMISSION_FLASH)
+ && message.type() == PpapiHostMsg_Flash_Create::ID)
+ return scoped_ptr<ppapi::host::ResourceHost>(
+ new PepperFlashRendererHostQt(host_,
+ instance,
+ resource));
+
+ return scoped_ptr<ppapi::host::ResourceHost>();
+}
+
+} // QtWebEngineCore
diff --git a/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
new file mode 100644
index 000000000..8631c1e03
--- /dev/null
+++ b/src/core/renderer/pepper/pepper_renderer_host_factory_qt.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PEPPER_RENDERER_HOST_FACTORY_QT_H
+#define PEPPER_RENDERER_HOST_FACTORY_QT_H
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "ppapi/host/host_factory.h"
+#include "content/public/renderer/render_frame_observer.h"
+
+
+namespace content {
+class RenderFrame;
+}
+
+namespace QtWebEngineCore {
+
+class PepperRendererHostFactoryQt : public ppapi::host::HostFactory {
+public:
+ explicit PepperRendererHostFactoryQt(content::RendererPpapiHost* host);
+ ~PepperRendererHostFactoryQt();
+
+ // HostFactory.
+ scoped_ptr<ppapi::host::ResourceHost> CreateResourceHost(
+ ppapi::host::PpapiHost* host,
+ PP_Resource resource,
+ PP_Instance instance,
+ const IPC::Message& message) override;
+
+private:
+ // Not owned by this object.
+ content::RendererPpapiHost* host_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperRendererHostFactoryQt);
+};
+
+} // namespace QtWebEngineCore
+
+#endif // PEPPER_RENDERER_HOST_FACTORY_QT_H
diff --git a/src/core/renderer/qt_render_frame_observer.cpp b/src/core/renderer/qt_render_frame_observer.cpp
new file mode 100644
index 000000000..5f06d1e4e
--- /dev/null
+++ b/src/core/renderer/qt_render_frame_observer.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qt_render_frame_observer.h"
+
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "ppapi/host/ppapi_host.h"
+
+#include "renderer/pepper/pepper_renderer_host_factory_qt.h"
+#include "renderer/pepper/pepper_flash_renderer_host_qt.h"
+
+namespace QtWebEngineCore {
+
+QtRenderFrameObserver::QtRenderFrameObserver(content::RenderFrame* render_frame)
+ : RenderFrameObserver(render_frame)
+{
+}
+
+QtRenderFrameObserver::~QtRenderFrameObserver()
+{
+}
+
+#if defined(ENABLE_PLUGINS)
+void QtRenderFrameObserver::DidCreatePepperPlugin(content::RendererPpapiHost* host)
+{
+ host->GetPpapiHost()->AddHostFactoryFilter(
+ scoped_ptr<ppapi::host::HostFactory>(
+ new PepperRendererHostFactoryQt(host)));
+}
+#endif
+
+} // namespace QtWebEngineCore
diff --git a/src/core/renderer/qt_render_frame_observer.h b/src/core/renderer/qt_render_frame_observer.h
new file mode 100644
index 000000000..42f2b7464
--- /dev/null
+++ b/src/core/renderer/qt_render_frame_observer.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_RENDER_FRAME_OBSERVER_H
+#define QT_RENDER_FRAME_OBSERVER_H
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "content/public/renderer/render_frame_observer.h"
+
+
+namespace content {
+class RenderFrame;
+}
+
+namespace QtWebEngineCore {
+
+class QtRenderFrameObserver : public content::RenderFrameObserver {
+public:
+ explicit QtRenderFrameObserver(content::RenderFrame* render_frame);
+ ~QtRenderFrameObserver();
+
+#if defined(ENABLE_PLUGINS)
+ void DidCreatePepperPlugin(content::RendererPpapiHost* host) override;
+#endif
+
+private:
+ DISALLOW_COPY_AND_ASSIGN(QtRenderFrameObserver);
+};
+
+} // namespace QtWebEngineCore
+
+#endif // QT_RENDER_FRAME_OBSERVER_H
diff --git a/src/core/renderer/qt_render_view_observer.cpp b/src/core/renderer/qt_render_view_observer.cpp
index 83534dadd..ba91e54ae 100644
--- a/src/core/renderer/qt_render_view_observer.cpp
+++ b/src/core/renderer/qt_render_view_observer.cpp
@@ -65,6 +65,11 @@ void QtRenderViewObserver::onFetchDocumentInnerText(quint64 requestId)
render_view()->GetWebView()->mainFrame()->contentAsText(std::numeric_limits<std::size_t>::max())));
}
+void QtRenderViewObserver::onSetBackgroundColor(quint32 color)
+{
+ render_view()->GetWebView()->setBaseBackgroundColor(color);
+}
+
void QtRenderViewObserver::OnFirstVisuallyNonEmptyLayout()
{
Send(new QtRenderViewObserverHost_DidFirstVisuallyNonEmptyLayout(routing_id()));
@@ -76,6 +81,7 @@ bool QtRenderViewObserver::OnMessageReceived(const IPC::Message& message)
IPC_BEGIN_MESSAGE_MAP(QtRenderViewObserver, message)
IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentMarkup, onFetchDocumentMarkup)
IPC_MESSAGE_HANDLER(QtRenderViewObserver_FetchDocumentInnerText, onFetchDocumentInnerText)
+ IPC_MESSAGE_HANDLER(QtRenderViewObserver_SetBackgroundColor, onSetBackgroundColor)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
diff --git a/src/core/renderer/qt_render_view_observer.h b/src/core/renderer/qt_render_view_observer.h
index cb77cd0c9..3f7829a92 100644
--- a/src/core/renderer/qt_render_view_observer.h
+++ b/src/core/renderer/qt_render_view_observer.h
@@ -47,6 +47,7 @@ public:
private:
void onFetchDocumentMarkup(quint64 requestId);
void onFetchDocumentInnerText(quint64 requestId);
+ void onSetBackgroundColor(quint32 color);
void OnFirstVisuallyNonEmptyLayout() Q_DECL_OVERRIDE;
diff --git a/src/core/resource_dispatcher_host_delegate_qt.cpp b/src/core/resource_dispatcher_host_delegate_qt.cpp
index faed58954..b63ecd5c7 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.cpp
+++ b/src/core/resource_dispatcher_host_delegate_qt.cpp
@@ -46,22 +46,20 @@
#include "content/public/browser/resource_request_info.h"
#include "net/url_request/url_request.h"
+#include "authentication_dialog_controller.h"
+#include "authentication_dialog_controller_p.h"
#include "type_conversion.h"
#include "web_contents_view_qt.h"
namespace QtWebEngineCore {
ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request)
- : m_request(request)
+ : m_authInfo(authInfo)
+ , m_request(request)
{
Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
content::ResourceRequestInfo::GetRenderFrameForRequest(request, &m_renderProcessId, &m_renderFrameId);
- m_url = toQt(request->url());
- m_realm = QString::fromStdString(authInfo->realm);
- m_isProxy = authInfo->is_proxy;
- m_host = QString::fromStdString(authInfo->challenger.ToString());
-
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog, this));
@@ -69,13 +67,34 @@ ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net
ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt()
{
+ Q_ASSERT(m_dialogController.isNull());
// We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled.
Q_ASSERT(!m_request);
}
void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled()
{
- m_request = 0;
+ destroy();
+}
+
+QUrl ResourceDispatcherHostLoginDelegateQt::url() const
+{
+ return toQt(m_request->url());
+}
+
+QString ResourceDispatcherHostLoginDelegateQt::realm() const
+{
+ return QString::fromStdString(m_authInfo->realm);
+}
+
+QString ResourceDispatcherHostLoginDelegateQt::host() const
+{
+ return QString::fromStdString(m_authInfo->challenger.ToString());
+}
+
+bool ResourceDispatcherHostLoginDelegateQt::isProxy() const
+{
+ return m_authInfo->is_proxy;
}
void ResourceDispatcherHostLoginDelegateQt::triggerDialog()
@@ -85,17 +104,9 @@ void ResourceDispatcherHostLoginDelegateQt::triggerDialog()
content::WebContentsImpl *webContents = static_cast<content::WebContentsImpl *>(content::WebContents::FromRenderViewHost(renderViewHost));
WebContentsAdapterClient *client = WebContentsViewQt::from(webContents->GetView())->client();
- // The widgets API will ask for credentials synchronouly, keep it simple for now.
- // We'll have to figure out a mechanism to keep a ref to the ResourceDispatcherHostLoginDelegateQt
- // to avoid crashing in the OnRequestCancelled case if we want to allow the credentials to
- // come back asynchronously in the QtQuick API.
- QString user, password;
- client->authenticationRequired(m_url , m_realm , m_isProxy , m_host, &user, &password);
-
- bool success = !user.isEmpty() || !password.isEmpty();
- content::BrowserThread::PostTask(
- content::BrowserThread::IO, FROM_HERE,
- base::Bind(&ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester, this, success, user, password));
+ AuthenticationDialogControllerPrivate *dialogControllerData = new AuthenticationDialogControllerPrivate(this);
+ m_dialogController.reset(new AuthenticationDialogController(dialogControllerData));
+ client->authenticationRequired(m_dialogController);
}
void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password)
@@ -110,6 +121,12 @@ void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, co
m_request->CancelAuth();
content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request);
+ destroy();
+}
+
+void ResourceDispatcherHostLoginDelegateQt::destroy()
+{
+ m_dialogController.reset();
m_request = 0;
}
diff --git a/src/core/resource_dispatcher_host_delegate_qt.h b/src/core/resource_dispatcher_host_delegate_qt.h
index 2cba210d3..d62292995 100644
--- a/src/core/resource_dispatcher_host_delegate_qt.h
+++ b/src/core/resource_dispatcher_host_delegate_qt.h
@@ -44,6 +44,8 @@
namespace QtWebEngineCore {
+class AuthenticationDialogController;
+
class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate {
public:
ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request);
@@ -52,9 +54,16 @@ public:
// ResourceDispatcherHostLoginDelegate implementation
virtual void OnRequestCancelled();
+ QUrl url() const;
+ QString realm() const;
+ QString host() const;
+ bool isProxy() const;
+
+ void sendAuthToRequester(bool success, const QString &user, const QString &password);
+
private:
void triggerDialog();
- void sendAuthToRequester(bool success, const QString &user, const QString &password);
+ void destroy();
QUrl m_url;
QString m_realm;
@@ -64,9 +73,15 @@ private:
int m_renderProcessId;
int m_renderFrameId;
+ net::AuthChallengeInfo *m_authInfo;
+
// The request that wants login data.
// Must only be accessed on the IO thread.
net::URLRequest *m_request;
+
+ // This member is used to keep authentication dialog controller alive until
+ // authorization is sent or cancelled.
+ QSharedPointer<AuthenticationDialogController> m_dialogController;
};
class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostDelegate {
diff --git a/src/core/resources/resources.gyp b/src/core/resources/resources.gyp
index 4d653df12..6293cdf3b 100644
--- a/src/core/resources/resources.gyp
+++ b/src/core/resources/resources.gyp
@@ -15,7 +15,7 @@
},
'dependencies': [
'<(chromium_src_dir)/content/app/strings/content_strings.gyp:content_strings',
- '<(chromium_src_dir)/webkit/blink_resources.gyp:blink_resources',
+ '<(chromium_src_dir)/blink/public/blink_resources.gyp:blink_resources',
'<(chromium_src_dir)/content/browser/devtools/devtools_resources.gyp:devtools_resources',
'../chrome_qt.gyp:chrome_resources',
],
@@ -29,7 +29,7 @@
'variables': {
'pak_inputs': [
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
- '<(SHARED_INTERMEDIATE_DIR)/webkit/devtools_resources.pak',
+ '<(SHARED_INTERMEDIATE_DIR)/blink/devtools_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/blink/public/resources/blink_resources.pak',
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak',
diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h
index 66fcd4dd0..9e5461888 100644
--- a/src/core/type_conversion.h
+++ b/src/core/type_conversion.h
@@ -41,15 +41,17 @@
#include <QDateTime>
#include <QDir>
#include <QMatrix4x4>
+#include <QNetworkCookie>
#include <QRect>
#include <QString>
#include <QUrl>
#include "base/files/file_path.h"
#include "base/time/time.h"
#include "content/public/common/file_chooser_file_info.h"
+#include "net/cookies/canonical_cookie.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/rect.h"
+#include "ui/gfx/geometry/rect.h"
#include "url/gurl.h"
namespace QtWebEngineCore {
@@ -92,6 +94,11 @@ inline QPoint toQt(const gfx::Point &point)
return QPoint(point.x(), point.y());
}
+inline gfx::Point toGfx(const QPoint& point)
+{
+ return gfx::Point(point.x(), point.y());
+}
+
inline QRect toQt(const gfx::Rect &rect)
{
return QRect(rect.x(), rect.y(), rect.width(), rect.height());
@@ -122,6 +129,11 @@ inline QColor toQt(const SkColor &c)
return QColor(SkColorGetR(c), SkColorGetG(c), SkColorGetB(c), SkColorGetA(c));
}
+inline SkColor toSk(const QColor &c)
+{
+ return c.rgba();
+}
+
inline QMatrix4x4 toQt(const SkMatrix44 &m)
{
QMatrix4x4 qtMatrix(
@@ -142,6 +154,18 @@ inline base::Time toTime(const QDateTime &dateTime) {
return base::Time::FromInternalValue(dateTime.toMSecsSinceEpoch());
}
+inline QNetworkCookie toQt(const net::CanonicalCookie & cookie)
+{
+ QNetworkCookie qCookie = QNetworkCookie(QByteArray::fromStdString(cookie.Name()), QByteArray::fromStdString(cookie.Value()));
+ qCookie.setDomain(toQt(cookie.Domain()));
+ if (!cookie.ExpiryDate().is_null())
+ qCookie.setExpirationDate(toQt(cookie.ExpiryDate()));
+ qCookie.setHttpOnly(cookie.IsHttpOnly());
+ qCookie.setPath(toQt(cookie.Path()));
+ qCookie.setSecure(cookie.IsSecure());
+ return qCookie;
+}
+
inline base::FilePath::StringType toFilePathString(const QString &str)
{
#if defined(OS_WIN)
diff --git a/src/core/url_request_context_getter_qt.cpp b/src/core/url_request_context_getter_qt.cpp
index 10923e4cb..c9ebf7f3b 100644
--- a/src/core/url_request_context_getter_qt.cpp
+++ b/src/core/url_request_context_getter_qt.cpp
@@ -41,7 +41,6 @@
#include "base/threading/worker_pool.h"
#include "base/threading/sequenced_worker_pool.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/cookie_crypto_delegate.h"
#include "content/public/browser/cookie_store_factory.h"
#include "content/public/common/content_switches.h"
#include "net/base/cache_type.h"
@@ -70,9 +69,13 @@
#include "browser_context_adapter.h"
#include "custom_protocol_handler.h"
#include "custom_url_scheme_handler.h"
+#include "cookie_monster_delegate_qt.h"
#include "content_client_qt.h"
#include "network_delegate_qt.h"
+#include "proxy_config_service_qt.h"
#include "qrc_protocol_handler_qt.h"
+#include "qwebenginecookiestoreclient.h"
+#include "qwebenginecookiestoreclient_p.h"
#include "type_conversion.h"
namespace QtWebEngineCore {
@@ -84,6 +87,7 @@ using content::BrowserThread;
URLRequestContextGetterQt::URLRequestContextGetterQt(BrowserContextAdapter *browserContext, content::ProtocolHandlerMap *protocolHandlers)
: m_ignoreCertificateErrors(false)
, m_browserContext(browserContext)
+ , m_cookieDelegate(new CookieMonsterDelegateQt())
{
std::swap(m_protocolHandlers, *protocolHandlers);
@@ -100,7 +104,7 @@ net::URLRequestContext *URLRequestContextGetterQt::GetURLRequestContext()
if (!m_urlRequestContext) {
m_urlRequestContext.reset(new net::URLRequestContext());
- m_networkDelegate.reset(new NetworkDelegateQt);
+ m_networkDelegate.reset(new NetworkDelegateQt(this));
m_urlRequestContext->set_network_delegate(m_networkDelegate.get());
generateStorage();
@@ -117,10 +121,10 @@ void URLRequestContextGetterQt::updateStorageSettings()
// We must create the proxy config service on the UI loop on Linux because it
// must synchronously run on the glib message loop. This will be passed to
// the URLRequestContextStorage on the IO thread in GetURLRequestContext().
- m_proxyConfigService = net::ProxyService::CreateSystemProxyConfigService(
+ m_proxyConfigService = new ProxyConfigServiceQt(net::ProxyService::CreateSystemProxyConfigService(
content::BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
content::BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)
- );
+ ));
if (m_storage)
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateStorage, this));
}
@@ -150,34 +154,27 @@ void URLRequestContextGetterQt::generateStorage()
generateCookieStore();
generateUserAgent();
- m_storage->set_channel_id_service(new net::ChannelIDService(
+ m_storage->set_channel_id_service(scoped_ptr<net::ChannelIDService>(new net::ChannelIDService(
new net::DefaultChannelIDStore(NULL),
- base::WorkerPool::GetTaskRunner(true)));
+ base::WorkerPool::GetTaskRunner(true))));
m_storage->set_cert_verifier(net::CertVerifier::CreateDefault());
scoped_ptr<net::HostResolver> host_resolver(net::HostResolver::CreateDefaultResolver(NULL));
// The System Proxy Resolver has issues on Windows with unconfigured network cards,
- // which is why we want to use the v8 one. However, V8ProxyResolver doesn't work reliably with
- // --single-process (See also the warnings in net/proxy/proxy_resolver_v8.h).
- base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kSingleProcess)) {
- m_storage->set_proxy_service(
- net::ProxyService::CreateUsingSystemProxyResolver(proxyConfigService, 0, NULL));
- } else {
- if (!m_dhcpProxyScriptFetcherFactory)
- m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory);
-
- net::ProxyResolverV8::EnsureIsolateCreated();
- m_storage->set_proxy_service(net::CreateProxyServiceUsingV8ProxyResolver(
- proxyConfigService,
- new net::ProxyScriptFetcherImpl(m_urlRequestContext.get()),
- m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()),
- host_resolver.get(),
- NULL /* NetLog */,
- m_networkDelegate.get()));
- }
+ // which is why we want to use the v8 one
+ if (!m_dhcpProxyScriptFetcherFactory)
+ m_dhcpProxyScriptFetcherFactory.reset(new net::DhcpProxyScriptFetcherFactory);
+
+ m_storage->set_proxy_service(net::CreateProxyServiceUsingV8ProxyResolver(
+ proxyConfigService,
+ new net::ProxyScriptFetcherImpl(m_urlRequestContext.get()),
+ m_dhcpProxyScriptFetcherFactory->Create(m_urlRequestContext.get()),
+ host_resolver.get(),
+ NULL /* NetLog */,
+ m_networkDelegate.get()));
+
m_storage->set_ssl_config_service(new net::SSLConfigServiceDefaults);
m_storage->set_transport_security_state(new net::TransportSecurityState());
@@ -206,6 +203,8 @@ void URLRequestContextGetterQt::generateCookieStore()
// Unset it first to get a chance to destroy and flush the old cookie store before before opening a new on possibly the same file.
m_storage->set_cookie_store(0);
+ m_cookieDelegate->setCookieMonster(0);
+ m_cookieDelegate->setClient(m_browserContext->cookieStoreClient());
net::CookieStore* cookieStore = 0;
switch (m_browserContext->persistentCookiesPolicy()) {
@@ -214,7 +213,8 @@ void URLRequestContextGetterQt::generateCookieStore()
content::CreateCookieStore(content::CookieStoreConfig(
base::FilePath(),
content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES,
- NULL, NULL)
+ NULL,
+ m_cookieDelegate.get())
);
break;
case BrowserContextAdapter::AllowPersistentCookies:
@@ -222,7 +222,8 @@ void URLRequestContextGetterQt::generateCookieStore()
content::CreateCookieStore(content::CookieStoreConfig(
toFilePath(m_browserContext->cookiesPath()),
content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES,
- NULL, NULL)
+ NULL,
+ m_cookieDelegate.get())
);
break;
case BrowserContextAdapter::ForcePersistentCookies:
@@ -230,11 +231,16 @@ void URLRequestContextGetterQt::generateCookieStore()
content::CreateCookieStore(content::CookieStoreConfig(
toFilePath(m_browserContext->cookiesPath()),
content::CookieStoreConfig::RESTORED_SESSION_COOKIES,
- NULL, NULL)
+ NULL,
+ m_cookieDelegate.get())
);
break;
}
m_storage->set_cookie_store(cookieStore);
+
+ net::CookieMonster * const cookieMonster = cookieStore->GetCookieMonster();
+ cookieMonster->SetCookieableSchemes(kCookieableSchemes, arraysize(kCookieableSchemes));
+ m_cookieDelegate->setCookieMonster(cookieMonster);
}
void URLRequestContextGetterQt::updateUserAgent()
@@ -243,13 +249,32 @@ void URLRequestContextGetterQt::updateUserAgent()
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE, base::Bind(&URLRequestContextGetterQt::generateUserAgent, this));
}
+class HttpUserAgentSettingsQt : public net::HttpUserAgentSettings
+{
+ const BrowserContextAdapter *m_browserContext;
+public:
+ HttpUserAgentSettingsQt(const BrowserContextAdapter *ctx)
+ : m_browserContext(ctx)
+ {
+ }
+
+ std::string GetAcceptLanguage() const Q_DECL_OVERRIDE
+ {
+ return m_browserContext->httpAcceptLanguage().toStdString();
+ }
+
+ std::string GetUserAgent() const Q_DECL_OVERRIDE
+ {
+ return m_browserContext->httpUserAgent().toStdString();
+ }
+};
+
void URLRequestContextGetterQt::generateUserAgent()
{
Q_ASSERT(m_urlRequestContext);
Q_ASSERT(m_storage);
- m_storage->set_http_user_agent_settings(
- new net::StaticHttpUserAgentSettings("en-us,en", m_browserContext->httpUserAgent().toStdString()));
+ m_storage->set_http_user_agent_settings(new HttpUserAgentSettingsQt(m_browserContext));
}
void URLRequestContextGetterQt::updateHttpCache()
diff --git a/src/core/url_request_context_getter_qt.h b/src/core/url_request_context_getter_qt.h
index 38cfd7957..c7a4366ec 100644
--- a/src/core/url_request_context_getter_qt.h
+++ b/src/core/url_request_context_getter_qt.h
@@ -49,12 +49,14 @@
#include "net/url_request/url_request_job_factory_impl.h"
#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
+#include "cookie_monster_delegate_qt.h"
+#include "network_delegate_qt.h"
+
#include "qglobal.h"
#include <qatomic.h>
namespace net {
class MappedHostResolver;
-class NetworkDelegate;
class ProxyConfigService;
}
@@ -93,10 +95,12 @@ private:
QAtomicPointer<net::ProxyConfigService> m_proxyConfigService;
scoped_ptr<net::URLRequestContext> m_urlRequestContext;
- scoped_ptr<net::NetworkDelegate> m_networkDelegate;
+ scoped_ptr<NetworkDelegateQt> m_networkDelegate;
scoped_ptr<net::URLRequestContextStorage> m_storage;
scoped_ptr<net::URLRequestJobFactoryImpl> m_jobFactory;
scoped_ptr<net::DhcpProxyScriptFetcherFactory> m_dhcpProxyScriptFetcherFactory;
+ scoped_refptr<CookieMonsterDelegateQt> m_cookieDelegate;
+ friend class NetworkDelegateQt;
};
} // namespace QtWebEngineCore
diff --git a/src/core/url_request_custom_job_delegate.cpp b/src/core/url_request_custom_job_delegate.cpp
index 8d344c862..0650242c8 100644
--- a/src/core/url_request_custom_job_delegate.cpp
+++ b/src/core/url_request_custom_job_delegate.cpp
@@ -58,6 +58,11 @@ QUrl URLRequestCustomJobDelegate::url() const
return toQt(m_job->request()->url());
}
+QByteArray URLRequestCustomJobDelegate::method() const
+{
+ return QByteArray::fromStdString(m_job->request()->method());
+}
+
void URLRequestCustomJobDelegate::setReply(const QByteArray &contentType, QIODevice *device)
{
m_job->setReplyMimeType(contentType.toStdString());
diff --git a/src/core/url_request_custom_job_delegate.h b/src/core/url_request_custom_job_delegate.h
index 6c1600592..5b6137820 100644
--- a/src/core/url_request_custom_job_delegate.h
+++ b/src/core/url_request_custom_job_delegate.h
@@ -63,6 +63,7 @@ public:
};
QUrl url() const;
+ QByteArray method() const;
void setReply(const QByteArray &contentType, QIODevice *device);
void redirect(const QUrl& url);
diff --git a/src/core/user_script_controller_host.cpp b/src/core/user_script_controller_host.cpp
index 227a639b1..d57518275 100644
--- a/src/core/user_script_controller_host.cpp
+++ b/src/core/user_script_controller_host.cpp
@@ -52,9 +52,12 @@ namespace QtWebEngineCore {
class UserScriptControllerHost::WebContentsObserverHelper : public content::WebContentsObserver {
public:
WebContentsObserverHelper(UserScriptControllerHost *, content::WebContents *);
- virtual void AboutToNavigateRenderView(content::RenderViewHost* renderViewHost) Q_DECL_OVERRIDE;
- virtual void WebContentsDestroyed() Q_DECL_OVERRIDE;
+ // WebContentsObserver overrides:
+ void RenderViewCreated(content::RenderViewHost *renderViewHost) override;
+ void RenderViewHostChanged(content::RenderViewHost *oldHost, content::RenderViewHost *newHost) override;
+ void WebContentsDestroyed() override;
+
private:
UserScriptControllerHost *m_controllerHost;
};
@@ -65,13 +68,23 @@ UserScriptControllerHost::WebContentsObserverHelper::WebContentsObserverHelper(U
{
}
-void UserScriptControllerHost::WebContentsObserverHelper::AboutToNavigateRenderView(content::RenderViewHost *renderViewHost)
+void UserScriptControllerHost::WebContentsObserverHelper::RenderViewCreated(content::RenderViewHost *renderViewHost)
{
content::WebContents *contents = web_contents();
Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
renderViewHost->Send(new RenderViewObserverHelper_AddScript(renderViewHost->GetRoutingID(), script.data()));
}
+void UserScriptControllerHost::WebContentsObserverHelper::RenderViewHostChanged(content::RenderViewHost *oldHost,
+ content::RenderViewHost *newHost)
+{
+ oldHost->Send(new RenderViewObserverHelper_ClearScripts(oldHost->GetRoutingID()));
+
+ content::WebContents *contents = web_contents();
+ Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents))
+ newHost->Send(new RenderViewObserverHelper_AddScript(newHost->GetRoutingID(), script.data()));
+}
+
void UserScriptControllerHost::WebContentsObserverHelper::WebContentsDestroyed()
{
m_controllerHost->webContentsDestroyed(web_contents());
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 8c13035e8..6fb2f5c97 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -46,6 +46,7 @@
#include "browser_context_qt.h"
#include "media_capture_devices_dispatcher.h"
#include "qt_render_view_observer_host.h"
+#include "qwebenginecallback_p.h"
#include "type_conversion.h"
#include "web_channel_ipc_transport_host.h"
#include "web_contents_adapter_client.h"
@@ -57,6 +58,8 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/devtools_agent_host.h"
+#include <content/public/browser/download_manager.h>
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -66,7 +69,6 @@
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/web_preferences.h"
-#include "ui/shell_dialogs/selected_file_info.h"
#include "third_party/WebKit/public/web/WebFindOptions.h"
#include <QDir>
@@ -165,19 +167,6 @@ static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint6
adapterClient->didRunJavaScript(requestId, fromJSValue(result));
}
-static QStringList listRecursively(const QDir& dir) {
- QStringList ret;
- QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot |QDir::Hidden));
- Q_FOREACH (const QFileInfo &fileInfo, infoList) {
- if (fileInfo.isDir()) {
- ret.append(fileInfo.absolutePath() + QStringLiteral("/.")); // Match chromium's behavior. See chrome/browser/file_select_helper.cc
- ret.append(listRecursively(QDir(fileInfo.absoluteFilePath())));
- } else
- ret.append(fileInfo.absoluteFilePath());
- }
- return ret;
-}
-
static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
{
content::WebContents::CreateParams create_params(browserContext, NULL);
@@ -217,14 +206,11 @@ static void serializeNavigationHistory(const content::NavigationController &cont
output << entry->GetIsOverridingUserAgent();
output << static_cast<qint64>(entry->GetTimestamp().ToInternalValue());
output << entry->GetHttpStatusCode();
- // If you want to navigate a named frame in Chrome, you will first need to
- // add support for persisting it. It is currently only used for layout tests.
- CHECK(entry->GetFrameToNavigate().empty());
}
}
}
-static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, std::vector<content::NavigationEntry*> *entries, content::BrowserContext *browserContext)
+static void deserializeNavigationHistory(QDataStream &input, int *currentIndex, ScopedVector<content::NavigationEntry> *entries, content::BrowserContext *browserContext)
{
int version;
input >> version;
@@ -265,13 +251,13 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
// If we couldn't unpack the entry successfully, abort everything.
if (input.status() != QDataStream::Ok) {
*currentIndex = -1;
- Q_FOREACH (content::NavigationEntry *entry, *entries)
+ for (content::NavigationEntry *entry : *entries)
delete entry;
entries->clear();
return;
}
- content::NavigationEntry *entry = content::NavigationController::CreateNavigationEntry(
+ scoped_ptr<content::NavigationEntry> entry = content::NavigationController::CreateNavigationEntry(
toGurl(virtualUrl),
content::Referrer(toGurl(referrerUrl), static_cast<blink::WebReferrerPolicy>(referrerPolicy)),
// Use a transition type of reload so that we don't incorrectly
@@ -290,7 +276,7 @@ static void deserializeNavigationHistory(QDataStream &input, int *currentIndex,
entry->SetIsOverridingUserAgent(isOverridingUserAgent);
entry->SetTimestamp(base::Time::FromInternalValue(timestamp));
entry->SetHttpStatusCode(httpStatusCode);
- entries->push_back(entry);
+ entries->push_back(entry.release());
}
}
@@ -323,7 +309,7 @@ WebContentsAdapterPrivate::WebContentsAdapterPrivate()
: engineContext(WebEngineContext::current())
, webChannel(0)
, adapterClient(0)
- , nextRequestId(1)
+ , nextRequestId(CallbackDirectory::ReservedCallbackIdsEnd)
, lastFindRequestId(0)
{
}
@@ -335,7 +321,7 @@ WebContentsAdapterPrivate::~WebContentsAdapterPrivate()
QExplicitlySharedDataPointer<WebContentsAdapter> WebContentsAdapter::createFromSerializedNavigationHistory(QDataStream &input, WebContentsAdapterClient *adapterClient)
{
int currentIndex;
- std::vector<content::NavigationEntry*> entries;
+ ScopedVector<content::NavigationEntry> entries;
deserializeNavigationHistory(input, &currentIndex, &entries, adapterClient->browserContextAdapter()->browserContext());
if (currentIndex == -1)
@@ -392,6 +378,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
const int qtCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
rendererPrefs->caret_blink_interval = 0.5 * static_cast<double>(qtCursorFlashTime) / 1000;
rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString();
+ rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString();
d->webContents->GetRenderViewHost()->SyncRendererPrefs();
// Create and attach observers to the WebContents.
@@ -409,7 +396,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
Q_ASSERT(rvh);
if (!rvh->IsRenderViewLive())
- static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, true);
+ static_cast<content::WebContentsImpl*>(d->webContents.get())->CreateRenderViewForRenderManager(rvh, MSG_ROUTING_NONE, MSG_ROUTING_NONE, content::FrameReplicationState(), true);
}
void WebContentsAdapter::reattachRWHV()
@@ -495,7 +482,9 @@ void WebContentsAdapter::setContent(const QByteArray &data, const QString &mimeT
params.base_url_for_data_url = toGurl(baseUrl);
params.virtual_url_for_data_url = baseUrl.isEmpty() ? GURL(url::kAboutBlankURL) : toGurl(baseUrl);
params.can_load_local_resources = true;
+ params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_API);
d->webContents->GetController().LoadURLWithParams(params);
+ d->webContents->Focus();
}
QUrl WebContentsAdapter::activeUrl() const
@@ -772,6 +761,60 @@ void WebContentsAdapter::updateWebPreferences(const content::WebPreferences & we
d->webContents->GetRenderViewHost()->UpdateWebkitPreferences(webPreferences);
}
+void WebContentsAdapter::download(const QUrl &url, const QString &suggestedFileName)
+{
+ content::BrowserContext *bctx = webContents()->GetBrowserContext();
+ content::DownloadManager *dlm = content::BrowserContext::GetDownloadManager(bctx);
+ if (!dlm)
+ return;
+
+ scoped_ptr<content::DownloadUrlParameters> params(
+ content::DownloadUrlParameters::FromWebContents(webContents(), toGurl(url)));
+ params->set_suggested_name(toString16(suggestedFileName));
+ dlm->DownloadUrl(params.Pass());
+}
+
+void WebContentsAdapter::copyImageAt(const QPoint &location)
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->GetRenderViewHost()->CopyImageAt(location.x(), location.y());
+}
+
+ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerNoAction, blink::WebMediaPlayerAction::Unknown)
+ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerPlay, blink::WebMediaPlayerAction::Play)
+ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerMute, blink::WebMediaPlayerAction::Mute)
+ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerLoop, blink::WebMediaPlayerAction::Loop)
+ASSERT_ENUMS_MATCH(WebContentsAdapter::MediaPlayerControls, blink::WebMediaPlayerAction::Controls)
+
+void WebContentsAdapter::executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable)
+{
+ Q_D(WebContentsAdapter);
+ blink::WebMediaPlayerAction blinkAction((blink::WebMediaPlayerAction::Type)action, enable);
+ d->webContents->GetRenderViewHost()->ExecuteMediaPlayerActionAtLocation(toGfx(location), blinkAction);
+}
+
+void WebContentsAdapter::inspectElementAt(const QPoint &location)
+{
+ Q_D(WebContentsAdapter);
+ if (content::DevToolsAgentHost::HasFor(d->webContents.get())) {
+ content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->InspectElement(location.x(), location.y());
+ }
+}
+
+bool WebContentsAdapter::hasInspector() const
+{
+ const Q_D(WebContentsAdapter);
+ if (content::DevToolsAgentHost::HasFor(d->webContents.get()))
+ return content::DevToolsAgentHost::GetOrCreateFor(d->webContents.get())->IsAttached();
+ return false;
+}
+
+void WebContentsAdapter::exitFullScreen()
+{
+ Q_D(WebContentsAdapter);
+ d->webContents->ExitFullscreen();
+}
+
void WebContentsAdapter::wasShown()
{
Q_D(WebContentsAdapter);
@@ -793,7 +836,7 @@ void WebContentsAdapter::grantMediaAccessPermission(const QUrl &securityOrigin,
void WebContentsAdapter::runGeolocationRequestCallback(const QUrl &securityOrigin, bool allowed)
{
Q_D(WebContentsAdapter);
- d->webContentsDelegate->geolocationPermissionReply(securityOrigin, allowed);
+ d->browserContextAdapter->permissionRequestReply(securityOrigin, BrowserContextAdapter::GeolocationPermission, allowed);
}
void WebContentsAdapter::grantMouseLockPermission(bool granted)
@@ -820,21 +863,11 @@ void WebContentsAdapter::dpiScaleChanged()
impl->NotifyScreenInfoChanged();
}
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Open, content::FileChooserParams::Open)
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::OpenMultiple, content::FileChooserParams::OpenMultiple)
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::UploadFolder, content::FileChooserParams::UploadFolder)
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Save, content::FileChooserParams::Save)
-
-void WebContentsAdapter::filesSelectedInChooser(const QStringList &fileList, WebContentsAdapterClient::FileChooserMode mode)
+void WebContentsAdapter::backgroundColorChanged()
{
Q_D(WebContentsAdapter);
- content::RenderViewHost *rvh = d->webContents->GetRenderViewHost();
- Q_ASSERT(rvh);
- QStringList files(fileList);
- if (mode == WebContentsAdapterClient::UploadFolder && !fileList.isEmpty()
- && QFileInfo(fileList.first()).isDir()) // Enumerate the directory
- files = listRecursively(QDir(fileList.first()));
- rvh->FilesSelectedInChooser(toVector<content::FileChooserFileInfo>(files), static_cast<content::FileChooserParams::Mode>(mode));
+ if (content::RenderWidgetHostView *rwhv = d->webContents->GetRenderWidgetHostView())
+ rwhv->SetBackgroundColor(toSk(d->adapterClient->backgroundColor()));
}
content::WebContents *WebContentsAdapter::webContents() const
diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h
index 5ea55c1b8..ecb084e56 100644
--- a/src/core/web_contents_adapter.h
+++ b/src/core/web_contents_adapter.h
@@ -104,7 +104,6 @@ public:
void serializeNavigationHistory(QDataStream &output);
void setZoomFactor(qreal);
qreal currentZoomFactor() const;
- void filesSelectedInChooser(const QStringList &fileList, WebContentsAdapterClient::FileChooserMode);
void runJavaScript(const QString &javaScript);
quint64 runJavaScriptCallbackResult(const QString &javaScript);
quint64 fetchDocumentMarkup();
@@ -112,6 +111,23 @@ public:
quint64 findText(const QString &subString, bool caseSensitively, bool findBackward);
void stopFinding();
void updateWebPreferences(const content::WebPreferences &webPreferences);
+ void download(const QUrl &url, const QString &suggestedFileName);
+
+ // Must match blink::WebMediaPlayerAction::Type.
+ enum MediaPlayerAction {
+ MediaPlayerNoAction,
+ MediaPlayerPlay,
+ MediaPlayerMute,
+ MediaPlayerLoop,
+ MediaPlayerControls,
+ MediaPlayerTypeLast = MediaPlayerControls
+ };
+ void copyImageAt(const QPoint &location);
+ void executeMediaPlayerActionAt(const QPoint &location, MediaPlayerAction action, bool enable);
+
+ void inspectElementAt(const QPoint &location);
+ bool hasInspector() const;
+ void exitFullScreen();
void wasShown();
void wasHidden();
@@ -120,6 +136,7 @@ public:
void grantMouseLockPermission(bool granted);
void dpiScaleChanged();
+ void backgroundColorChanged();
QAccessibleInterface *browserAccessible();
BrowserContextQt* browserContext();
BrowserContextAdapter* browserContextAdapter();
diff --git a/src/core/web_contents_adapter_client.h b/src/core/web_contents_adapter_client.h
index 3ed3ab9ab..8166224a4 100644
--- a/src/core/web_contents_adapter_client.h
+++ b/src/core/web_contents_adapter_client.h
@@ -52,7 +52,9 @@ QT_FORWARD_DECLARE_CLASS(CertificateErrorController)
namespace QtWebEngineCore {
+class AuthenticationDialogController;
class BrowserContextAdapter;
+class FilePickerController;
class JavaScriptDialogController;
class RenderWidgetHostViewQt;
class RenderWidgetHostViewQtDelegate;
@@ -65,10 +67,55 @@ class WebEngineSettings;
class WebEngineContextMenuData {
public:
+ WebEngineContextMenuData()
+ : mediaType(MediaTypeNone)
+ , hasImageContent(false)
+ , mediaFlags(0)
+ {
+ }
+
+ // Must match blink::WebContextMenuData::MediaType:
+ enum MediaType {
+ // No special node is in context.
+ MediaTypeNone,
+ // An image node is selected.
+ MediaTypeImage,
+ // A video node is selected.
+ MediaTypeVideo,
+ // An audio node is selected.
+ MediaTypeAudio,
+ // A canvas node is selected.
+ MediaTypeCanvas,
+ // A file node is selected.
+ MediaTypeFile,
+ // A plugin node is selected.
+ MediaTypePlugin,
+ MediaTypeLast = MediaTypePlugin
+ };
+ // Must match blink::WebContextMenuData::MediaFlags:
+ enum MediaFlags {
+ MediaNone = 0x0,
+ MediaInError = 0x1,
+ MediaPaused = 0x2,
+ MediaMuted = 0x4,
+ MediaLoop = 0x8,
+ MediaCanSave = 0x10,
+ MediaHasAudio = 0x20,
+ MediaCanToggleControls = 0x40,
+ MediaControls = 0x80,
+ MediaCanPrint = 0x100,
+ MediaCanRotate = 0x200,
+ };
+
QPoint pos;
QUrl linkUrl;
QString linkText;
QString selectedText;
+ QUrl mediaUrl;
+ MediaType mediaType;
+ bool hasImageContent;
+ uint mediaFlags;
+ QString suggestedFileName;
// Some likely candidates for future additions as we add support for the related actions:
// bool isImageBlocked;
// bool isEditable;
@@ -104,14 +151,6 @@ public:
InternalAuthorizationDialog = 0x10,
};
- // Must match the ones in file_chooser_params.h
- enum FileChooserMode {
- Open,
- OpenMultiple,
- UploadFolder,
- Save
- };
-
enum NavigationRequestAction {
AcceptRequest,
// Make room in the valid range of the enum for extra actions exposed in Experimental.
@@ -119,7 +158,7 @@ public:
};
enum NavigationType {
- LinkClickedNavigation,
+ LinkNavigation,
TypedNavigation,
FormSubmittedNavigation,
BackForwardNavigation,
@@ -152,6 +191,7 @@ public:
virtual void selectionChanged() = 0;
virtual QRectF viewportRect() const = 0;
virtual qreal dpiScale() const = 0;
+ virtual QColor backgroundColor() const = 0;
virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) = 0;
virtual void loadCommitted() = 0;
virtual void loadVisuallyCommitted() = 0;
@@ -165,7 +205,7 @@ public:
virtual void requestFullScreen(bool) = 0;
virtual bool isFullScreen() const = 0;
virtual void javascriptDialog(QSharedPointer<JavaScriptDialogController>) = 0;
- virtual void runFileChooser(FileChooserMode, const QString &defaultFileName, const QStringList &acceptedMimeTypes) = 0;
+ virtual void runFileChooser(FilePickerController *controller) = 0;
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) = 0;
virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) = 0;
virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) = 0;
@@ -177,7 +217,7 @@ public:
virtual QObject *accessibilityParentObject() = 0;
#endif // QT_NO_ACCESSIBILITY
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) = 0;
- virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) = 0;
+ virtual void authenticationRequired(QSharedPointer<AuthenticationDialogController>) = 0;
virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) = 0;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) = 0;
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) = 0;
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index f9db91b3e..e644d691f 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -41,6 +41,7 @@
#include "web_contents_delegate_qt.h"
#include "browser_context_adapter.h"
+#include "file_picker_controller.h"
#include "media_capture_devices_dispatcher.h"
#include "type_conversion.h"
#include "web_contents_adapter_client.h"
@@ -107,7 +108,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
return target;
}
-void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* source, content::InvalidateTypes changed_flags)
+void WebContentsDelegateQt::NavigationStateChanged(content::WebContents* source, content::InvalidateTypes changed_flags)
{
if (changed_flags & content::INVALIDATE_TYPE_URL)
m_viewClient->urlChanged(toQt(source->GetVisibleURL()));
@@ -126,7 +127,7 @@ void WebContentsDelegateQt::AddNewContents(content::WebContents* source, content
void WebContentsDelegateQt::CloseContents(content::WebContents *source)
{
m_viewClient->close();
- GetJavaScriptDialogManager()->CancelActiveAndPendingDialogs(source);
+ GetJavaScriptDialogManager(source)->CancelActiveAndPendingDialogs(source);
}
void WebContentsDelegateQt::LoadProgressChanged(content::WebContents* source, double progress)
@@ -171,13 +172,14 @@ void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(content::RenderFram
m_viewClient->loadCommitted();
}
-void WebContentsDelegateQt::DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description)
+void WebContentsDelegateQt::DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description, bool was_ignored_by_handler)
{
- DidFailLoad(render_frame_host, validated_url, error_code, error_description);
+ DidFailLoad(render_frame_host, validated_url, error_code, error_description, was_ignored_by_handler);
}
-void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description)
+void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description, bool was_ignored_by_handler)
{
+ Q_UNUSED(was_ignored_by_handler);
if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()) || render_frame_host->GetParent())
return;
@@ -228,36 +230,47 @@ void WebContentsDelegateQt::DidUpdateFaviconURL(const std::vector<content::Favic
}
}
-content::JavaScriptDialogManager *WebContentsDelegateQt::GetJavaScriptDialogManager()
+content::JavaScriptDialogManager *WebContentsDelegateQt::GetJavaScriptDialogManager(content::WebContents *)
{
return JavaScriptDialogManagerQt::GetInstance();
}
-void WebContentsDelegateQt::ToggleFullscreenModeForTab(content::WebContents* web_contents, bool enter_fullscreen)
+void WebContentsDelegateQt::EnterFullscreenModeForTab(content::WebContents *web_contents, const GURL& origin)
{
- if (m_viewClient->isFullScreen() != enter_fullscreen) {
- m_viewClient->requestFullScreen(enter_fullscreen);
+ Q_UNUSED(origin); // FIXME
+ if (!m_viewClient->isFullScreen()) {
+ m_viewClient->requestFullScreen(true);
web_contents->GetRenderViewHost()->WasResized();
}
}
+void WebContentsDelegateQt::ExitFullscreenModeForTab(content::WebContents *web_contents)
+{
+ if (m_viewClient->isFullScreen()) {
+ m_viewClient->requestFullScreen(false);
+ web_contents->GetRenderViewHost()->WasResized();
+ }
+}
+
bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebContents* web_contents) const
{
return m_viewClient->isFullScreen();
}
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Open, content::FileChooserParams::Open)
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Save, content::FileChooserParams::Save)
+ASSERT_ENUMS_MATCH(FilePickerController::Open, content::FileChooserParams::Open)
+ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, content::FileChooserParams::OpenMultiple)
+ASSERT_ENUMS_MATCH(FilePickerController::UploadFolder, content::FileChooserParams::UploadFolder)
+ASSERT_ENUMS_MATCH(FilePickerController::Save, content::FileChooserParams::Save)
void WebContentsDelegateQt::RunFileChooser(content::WebContents *web_contents, const content::FileChooserParams &params)
{
- Q_UNUSED(web_contents)
QStringList acceptedMimeTypes;
acceptedMimeTypes.reserve(params.accept_types.size());
for (std::vector<base::string16>::const_iterator it = params.accept_types.begin(); it < params.accept_types.end(); ++it)
acceptedMimeTypes.append(toQt(*it));
- m_viewClient->runFileChooser(static_cast<WebContentsAdapterClient::FileChooserMode>(params.mode), toQt(params.default_file_name.value()), acceptedMimeTypes);
+ FilePickerController *controller = new FilePickerController(static_cast<FilePickerController::FileChooserMode>(params.mode), web_contents, toQt(params.default_file_name.value()), acceptedMimeTypes);
+ m_viewClient->runFileChooser(controller);
}
bool WebContentsDelegateQt::AddMessageToConsole(content::WebContents *source, int32 level, const base::string16 &message, int32 line_no, const base::string16 &source_id)
@@ -334,28 +347,9 @@ void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<Certifica
m_viewClient->allowCertificateError(errorController);
}
-void WebContentsDelegateQt::requestGeolocationPermission(const GURL &requestingFrameOrigin, const base::Callback<void (bool)> &resultCallback)
+void WebContentsDelegateQt::requestGeolocationPermission(const QUrl &requestingOrigin)
{
- QUrl url = toQt(requestingFrameOrigin);
- bool newRequest = !m_geolocationPermissionRequests.contains(url);
- m_geolocationPermissionRequests[url] = resultCallback;
- if (newRequest)
- m_viewClient->runGeolocationPermissionRequest(url);
-}
-
-void WebContentsDelegateQt::cancelGeolocationPermissionRequest(const GURL &requestingFrameOrigin)
-{
- m_geolocationPermissionRequests.remove(toQt(requestingFrameOrigin));
- // FIXME: Tell the API layer to cancel the permission request?
-}
-
-void WebContentsDelegateQt::geolocationPermissionReply(const QUrl &origin, bool permission)
-{
- auto it = m_geolocationPermissionRequests.find(origin);
- if (it != m_geolocationPermissionRequests.end()) {
- (*it).Run(permission);
- m_geolocationPermissionRequests.erase(it);
- }
+ m_viewClient->runGeolocationPermissionRequest(requestingOrigin);
}
void WebContentsDelegateQt::ShowValidationMessage(content::WebContents *web_contents, const gfx::Rect &anchor_in_root_view, const base::string16 &main_text, const base::string16 &sub_text)
diff --git a/src/core/web_contents_delegate_qt.h b/src/core/web_contents_delegate_qt.h
index 254177d24..1728c447d 100644
--- a/src/core/web_contents_delegate_qt.h
+++ b/src/core/web_contents_delegate_qt.h
@@ -39,6 +39,7 @@
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/permission_status.mojom.h"
#include "base/callback.h"
@@ -72,13 +73,14 @@ public:
// WebContentsDelegate overrides
virtual content::WebContents *OpenURLFromTab(content::WebContents *source, const content::OpenURLParams &params) Q_DECL_OVERRIDE;
- virtual void NavigationStateChanged(const content::WebContents* source, content::InvalidateTypes changed_flags) Q_DECL_OVERRIDE;
+ virtual void NavigationStateChanged(content::WebContents* source, content::InvalidateTypes changed_flags) Q_DECL_OVERRIDE;
virtual void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) Q_DECL_OVERRIDE;
virtual void CloseContents(content::WebContents *source) Q_DECL_OVERRIDE;
virtual void LoadProgressChanged(content::WebContents* source, double progress) Q_DECL_OVERRIDE;
virtual void HandleKeyboardEvent(content::WebContents *source, const content::NativeWebKeyboardEvent &event) Q_DECL_OVERRIDE;
- virtual content::JavaScriptDialogManager *GetJavaScriptDialogManager() Q_DECL_OVERRIDE;
- virtual void ToggleFullscreenModeForTab(content::WebContents* web_contents, bool enter_fullscreen) Q_DECL_OVERRIDE;
+ virtual content::JavaScriptDialogManager *GetJavaScriptDialogManager(content::WebContents *source) Q_DECL_OVERRIDE;
+ virtual void EnterFullscreenModeForTab(content::WebContents* web_contents, const GURL& origin) Q_DECL_OVERRIDE;
+ virtual void ExitFullscreenModeForTab(content::WebContents*) Q_DECL_OVERRIDE;
virtual bool IsFullscreenForTabOrPending(const content::WebContents* web_contents) const Q_DECL_OVERRIDE;
virtual void RunFileChooser(content::WebContents *, const content::FileChooserParams &params) Q_DECL_OVERRIDE;
virtual bool AddMessageToConsole(content::WebContents* source, int32 level, const base::string16& message, int32 line_no, const base::string16& source_id) Q_DECL_OVERRIDE;
@@ -93,23 +95,21 @@ public:
// WebContentsObserver overrides
virtual void DidStartProvisionalLoadForFrame(content::RenderFrameHost *render_frame_host, const GURL &validated_url, bool is_error_page, bool is_iframe_srcdoc) Q_DECL_OVERRIDE;
virtual void DidCommitProvisionalLoadForFrame(content::RenderFrameHost *render_frame_host, const GURL &url, ui::PageTransition transition_type) Q_DECL_OVERRIDE;
- virtual void DidFailProvisionalLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, int error_code, const base::string16 &error_description) Q_DECL_OVERRIDE;
- virtual void DidFailLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url, int error_code, const base::string16 &error_description) Q_DECL_OVERRIDE;
+ virtual void DidFailProvisionalLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url,
+ int error_code, const base::string16 &error_description, bool was_ignored_by_handler) Q_DECL_OVERRIDE;
+ virtual void DidFailLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url,
+ int error_code, const base::string16 &error_description, bool was_ignored_by_handler) Q_DECL_OVERRIDE;
virtual void DidFinishLoad(content::RenderFrameHost *render_frame_host, const GURL &validated_url) Q_DECL_OVERRIDE;
virtual void DidUpdateFaviconURL(const std::vector<content::FaviconURL> &candidates) Q_DECL_OVERRIDE;
virtual void DidNavigateAnyFrame(content::RenderFrameHost *render_frame_host, const content::LoadCommittedDetails &details, const content::FrameNavigateParams &params) Q_DECL_OVERRIDE;
void overrideWebPreferences(content::WebContents *, content::WebPreferences*);
void allowCertificateError(const QSharedPointer<CertificateErrorController> &) ;
- void requestGeolocationPermission(const GURL &requestingFrameOrigin, const base::Callback<void (bool)> &resultCallback);
- void cancelGeolocationPermissionRequest(const GURL &requestingFrameOrigin);
- void geolocationPermissionReply(const QUrl&, bool permission);
+ void requestGeolocationPermission(const QUrl &requestingOrigin);
private:
WebContentsAdapter *createWindow(content::WebContents *new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture);
- QHash<QUrl, base::Callback<void (bool)> > m_geolocationPermissionRequests;
-
WebContentsAdapterClient *m_viewClient;
QString m_lastSearchedString;
int m_lastReceivedFindReply;
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index af0c1fe38..67addacd5 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -53,8 +53,10 @@ void WebContentsViewQt::initialize(WebContentsAdapterClient* client)
m_factoryClient = client;
// Check if a RWHV was created before the initialization.
- if (m_webContents->GetRenderWidgetHostView())
- static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())->setAdapterClient(client);
+ if (auto rwhv = static_cast<RenderWidgetHostViewQt *>(m_webContents->GetRenderWidgetHostView())) {
+ rwhv->setAdapterClient(client);
+ rwhv->SetBackgroundColor(toSk(client->backgroundColor()));
+ }
}
content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack)
@@ -82,6 +84,14 @@ content::RenderWidgetHostViewBase* WebContentsViewQt::CreateViewForPopupWidget(c
return view;
}
+void WebContentsViewQt::RenderViewCreated(content::RenderViewHost* host)
+{
+ // The render process is done creating the RenderView and it's ready to be routed
+ // messages at this point.
+ if (m_client)
+ host->GetView()->SetBackgroundColor(toSk(m_client->backgroundColor()));
+}
+
void WebContentsViewQt::CreateView(const gfx::Size& initial_size, gfx::NativeView context)
{
// This is passed through content::WebContents::CreateParams::context either as the native view's client
@@ -103,6 +113,8 @@ void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const
void WebContentsViewQt::Focus()
{
+ if (content::RenderWidgetHostView *rwhv = m_webContents->GetRenderWidgetHostView())
+ rwhv->Focus();
m_client->focusContainer();
}
@@ -111,6 +123,26 @@ void WebContentsViewQt::SetInitialFocus()
Focus();
}
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeNone, blink::WebContextMenuData::MediaTypeNone)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeImage, blink::WebContextMenuData::MediaTypeImage)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeVideo, blink::WebContextMenuData::MediaTypeVideo)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeAudio, blink::WebContextMenuData::MediaTypeAudio)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeCanvas, blink::WebContextMenuData::MediaTypeCanvas)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypeFile, blink::WebContextMenuData::MediaTypeFile)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaTypePlugin, blink::WebContextMenuData::MediaTypePlugin)
+
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaNone, blink::WebContextMenuData::MediaNone)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaInError, blink::WebContextMenuData::MediaInError)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaPaused, blink::WebContextMenuData::MediaPaused)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaMuted, blink::WebContextMenuData::MediaMuted)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaLoop, blink::WebContextMenuData::MediaLoop)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanSave, blink::WebContextMenuData::MediaCanSave)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaHasAudio, blink::WebContextMenuData::MediaHasAudio)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanToggleControls, blink::WebContextMenuData::MediaCanToggleControls)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaControls, blink::WebContextMenuData::MediaControls)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanPrint, blink::WebContextMenuData::MediaCanPrint)
+ASSERT_ENUMS_MATCH(WebEngineContextMenuData::MediaCanRotate, blink::WebContextMenuData::MediaCanRotate)
+
static WebEngineContextMenuData fromParams(const content::ContextMenuParams &params)
{
WebEngineContextMenuData ret;
@@ -118,6 +150,11 @@ static WebEngineContextMenuData fromParams(const content::ContextMenuParams &par
ret.linkUrl = toQt(params.link_url);
ret.linkText = toQt(params.link_text.data());
ret.selectedText = toQt(params.selection_text.data());
+ ret.mediaUrl = toQt(params.src_url);
+ ret.mediaType = (WebEngineContextMenuData::MediaType)params.media_type;
+ ret.hasImageContent = params.has_image_contents;
+ ret.mediaFlags = params.media_flags;
+ ret.suggestedFileName = toQt(params.suggested_filename.data());
return ret;
}
diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h
index 896955f7d..cbbca2371 100644
--- a/src/core/web_contents_view_qt.h
+++ b/src/core/web_contents_view_qt.h
@@ -43,8 +43,9 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
-#include "web_contents_adapter_client.h"
+#include "qtwebenginecoreglobal_p.h"
#include "render_widget_host_view_qt.h"
+#include "web_contents_adapter_client.h"
#include "web_contents_delegate_qt.h"
#include "web_engine_context.h"
@@ -75,7 +76,7 @@ public:
virtual void SetPageTitle(const base::string16& title) Q_DECL_OVERRIDE { }
- virtual void RenderViewCreated(content::RenderViewHost* host) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
+ virtual void RenderViewCreated(content::RenderViewHost* host) Q_DECL_OVERRIDE;
virtual void RenderViewSwappedIn(content::RenderViewHost* host) Q_DECL_OVERRIDE { QT_NOT_YET_IMPLEMENTED }
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 8bc047321..4e4159cef 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -153,6 +153,7 @@ void WebEngineContext::destroy()
// Flush the UI message loop before quitting.
while (delegate->DoWork()) { }
GLContextHelper::destroy();
+ m_devtools.reset(0);
m_runLoop->AfterRun();
// Force to destroy RenderProcessHostImpl by destroying BrowserMainRunner.
@@ -202,34 +203,35 @@ WebEngineContext::WebEngineContext()
Q_FOREACH (const QString& arg, QCoreApplication::arguments())
args << arg.toUtf8();
+ bool useEmbeddedSwitches = args.removeAll("--enable-embedded-switches");
+#if defined(QTWEBENGINE_EMBEDDED_SWITCHES)
+ useEmbeddedSwitches = !args.removeAll("--disable-embedded-switches");
+#endif
+
QVector<const char*> argv(args.size());
for (int i = 0; i < args.size(); ++i)
argv[i] = args[i].constData();
- CommandLine::Init(argv.size(), argv.constData());
+ base::CommandLine::Init(argv.size(), argv.constData());
- CommandLine* parsedCommandLine = CommandLine::ForCurrentProcess();
+ base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess();
parsedCommandLine->AppendSwitchPath(switches::kBrowserSubprocessPath, WebEngineLibraryInfo::getPath(content::CHILD_PROCESS_EXE));
parsedCommandLine->AppendSwitch(switches::kNoSandbox);
- parsedCommandLine->AppendSwitch(switches::kDisablePlugins);
parsedCommandLine->AppendSwitch(switches::kEnableDelegatedRenderer);
parsedCommandLine->AppendSwitch(switches::kEnableThreadedCompositing);
parsedCommandLine->AppendSwitch(switches::kInProcessGPU);
-#if defined(QTWEBENGINE_MOBILE_SWITCHES)
- // Inspired by the Android port's default switches
- parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar);
- parsedCommandLine->AppendSwitch(switches::kEnablePinch);
- parsedCommandLine->AppendSwitch(switches::kEnableViewport);
- parsedCommandLine->AppendSwitch(switches::kEnableViewportMeta);
- parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
- parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
- parsedCommandLine->AppendSwitch(switches::kDisableGpuShaderDiskCache);
- parsedCommandLine->AppendSwitch(switches::kDisable2dCanvasAntialiasing);
- parsedCommandLine->AppendSwitch(switches::kEnableImplSidePainting);
- parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing);
-
- parsedCommandLine->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
-#endif
+ if (useEmbeddedSwitches) {
+ // Inspired by the Android port's default switches
+ parsedCommandLine->AppendSwitch(switches::kEnableOverlayScrollbar);
+ parsedCommandLine->AppendSwitch(switches::kEnablePinch);
+ parsedCommandLine->AppendSwitch(switches::kEnableViewport);
+ parsedCommandLine->AppendSwitch(switches::kMainFrameResizesAreOrientationChanges);
+ parsedCommandLine->AppendSwitch(switches::kDisableAcceleratedVideoDecode);
+ parsedCommandLine->AppendSwitch(switches::kDisableGpuShaderDiskCache);
+ parsedCommandLine->AppendSwitch(switches::kDisable2dCanvasAntialiasing);
+ parsedCommandLine->AppendSwitch(cc::switches::kDisableCompositedAntialiasing);
+ parsedCommandLine->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
+ }
GLContextHelper::initialize();
@@ -260,13 +262,13 @@ WebEngineContext::WebEngineContext()
contentMainParams.sandbox_info = &sandbox_info;
#endif
m_contentRunner->Initialize(contentMainParams);
- m_browserRunner->Initialize(content::MainFunctionParams(*CommandLine::ForCurrentProcess()));
+ m_browserRunner->Initialize(content::MainFunctionParams(*base::CommandLine::ForCurrentProcess()));
// Once the MessageLoop has been created, attach a top-level RunLoop.
m_runLoop.reset(new base::RunLoop);
m_runLoop->BeforeRun();
- m_devtools.reset(new DevToolsHttpHandlerDelegateQt);
+ m_devtools = createDevToolsHttpHandler();
// Force the initialization of MediaCaptureDevicesDispatcher on the UI
// thread to avoid a thread check assertion in its constructor when it
// first gets referenced on the IO thread.
diff --git a/src/core/web_engine_context.h b/src/core/web_engine_context.h
index dea54ef8a..8f034f18f 100644
--- a/src/core/web_engine_context.h
+++ b/src/core/web_engine_context.h
@@ -41,6 +41,8 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "components/devtools_http_handler/devtools_http_handler.h"
#include <QExplicitlySharedDataPointer>
@@ -59,7 +61,6 @@ namespace QtWebEngineCore {
class BrowserContextAdapter;
class ContentMainDelegateQt;
-class DevToolsHttpHandlerDelegateQt;
class SurfaceFactoryQt;
} // namespace
@@ -84,7 +85,7 @@ private:
scoped_ptr<content::BrowserMainRunner> m_browserRunner;
QObject* m_globalQObject;
QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_defaultBrowserContext;
- scoped_ptr<QtWebEngineCore::DevToolsHttpHandlerDelegateQt> m_devtools;
+ scoped_ptr<devtools_http_handler::DevToolsHttpHandler> m_devtools;
};
#endif // WEB_ENGINE_CONTEXT_H
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 980e9a39a..bc030d8f7 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -162,7 +162,6 @@ QString pluginsPath()
if (!initialized) {
initialized = true;
-
const QStringList directories = QCoreApplication::libraryPaths();
Q_FOREACH (const QString &dir, directories) {
const QString candidate = dir % "/" % QLatin1String("qtwebengine");
@@ -173,7 +172,6 @@ QString pluginsPath()
}
if (pluginsPath.isEmpty()) {
- qWarning("Qt WebEngine Plugins directory not found. Trying fallback directory... Plugins as for example video codecs MAY NOT work.");
pluginsPath = fallbackDir();
}
}
@@ -276,7 +274,7 @@ base::string16 WebEngineLibraryInfo::getApplicationName()
std::string WebEngineLibraryInfo::getApplicationLocale()
{
- CommandLine *parsedCommandLine = CommandLine::ForCurrentProcess();
+ base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
if (!parsedCommandLine->HasSwitch(switches::kLang))
return QLocale().bcp47Name().toStdString();
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index 74c60b778..19558980b 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -213,6 +213,8 @@ void WebEngineSettings::initDefaults(bool offTheRecord)
m_attributes.insert(HyperlinkAuditingEnabled, false);
m_attributes.insert(ScrollAnimatorEnabled, false);
m_attributes.insert(ErrorPageEnabled, true);
+ m_attributes.insert(PluginsEnabled, false);
+ m_attributes.insert(FullScreenSupportEnabled, false);
// Default fonts
QFont defaultFont;
@@ -277,6 +279,8 @@ void WebEngineSettings::applySettingsToWebPreferences(content::WebPreferences *p
prefs->hyperlink_auditing_enabled = testAttribute(HyperlinkAuditingEnabled);
prefs->enable_scroll_animator = testAttribute(ScrollAnimatorEnabled);
prefs->enable_error_page = testAttribute(ErrorPageEnabled);
+ prefs->plugins_enabled = testAttribute(PluginsEnabled);
+ prefs->fullscreen_supported = testAttribute(FullScreenSupportEnabled);
// Fonts settings.
prefs->standard_font_family_map[content::kCommonScript] = toString16(fontFamily(StandardFont));
diff --git a/src/core/web_engine_settings.h b/src/core/web_engine_settings.h
index e9d8010a8..29ef079b7 100644
--- a/src/core/web_engine_settings.h
+++ b/src/core/web_engine_settings.h
@@ -71,6 +71,8 @@ public:
HyperlinkAuditingEnabled,
ScrollAnimatorEnabled,
ErrorPageEnabled,
+ PluginsEnabled,
+ FullScreenSupportEnabled,
};
// Must match the values from the public API in qwebenginesettings.h.
diff --git a/src/core/yuv_video_node.cpp b/src/core/yuv_video_node.cpp
index 23528c8ec..815ea7d51 100644
--- a/src/core/yuv_video_node.cpp
+++ b/src/core/yuv_video_node.cpp
@@ -61,12 +61,16 @@ protected:
"attribute highp vec4 a_position;\n"
"attribute mediump vec2 a_texCoord;\n"
"uniform highp mat4 matrix;\n"
- "varying mediump vec2 v_texCoord;\n"
- "uniform mediump vec2 texScale;\n"
- "uniform mediump vec2 texOffset;\n"
+ "varying mediump vec2 v_yaTexCoord;\n"
+ "varying mediump vec2 v_uvTexCoord;\n"
+ "uniform mediump vec2 yaTexScale;\n"
+ "uniform mediump vec2 yaTexOffset;\n"
+ "uniform mediump vec2 uvTexScale;\n"
+ "uniform mediump vec2 uvTexOffset;\n"
"void main() {\n"
" gl_Position = matrix * a_position;\n"
- " v_texCoord = a_texCoord * texScale + texOffset;\n"
+ " v_yaTexCoord = a_texCoord * yaTexScale + yaTexOffset;\n"
+ " v_uvTexCoord = a_texCoord * uvTexScale + uvTexOffset;\n"
"}";
return shader;
}
@@ -74,19 +78,26 @@ protected:
virtual const char *fragmentShader() const Q_DECL_OVERRIDE {
// Keep in sync with cc::FragmentShaderYUVVideo
static const char *shader =
- "varying mediump vec2 v_texCoord;\n"
+ "varying mediump vec2 v_yaTexCoord;\n"
+ "varying mediump vec2 v_uvTexCoord;\n"
"uniform sampler2D y_texture;\n"
"uniform sampler2D u_texture;\n"
"uniform sampler2D v_texture;\n"
- "uniform lowp float alpha;\n"
- "uniform lowp vec3 yuv_adj;\n"
- "uniform lowp mat3 yuv_matrix;\n"
+ "uniform mediump float alpha;\n"
+ "uniform mediump vec3 yuv_adj;\n"
+ "uniform mediump mat3 yuv_matrix;\n"
+ "uniform mediump vec4 ya_clamp_rect;\n"
+ "uniform mediump vec4 uv_clamp_rect;\n"
"void main() {\n"
- " lowp float y_raw = texture2D(y_texture, v_texCoord).x;\n"
- " lowp float u_unsigned = texture2D(u_texture, v_texCoord).x;\n"
- " lowp float v_unsigned = texture2D(v_texture, v_texCoord).x;\n"
- " lowp vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;\n"
- " lowp vec3 rgb = yuv_matrix * yuv;\n"
+ " mediump vec2 ya_clamped =\n"
+ " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
+ " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
+ " mediump vec2 uv_clamped =\n"
+ " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
+ " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
+ " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
+ " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;\n"
+ " mediump vec3 rgb = yuv_matrix * yuv;\n"
" gl_FragColor = vec4(rgb, 1.0) * alpha;\n"
"}";
return shader;
@@ -94,8 +105,12 @@ protected:
virtual void initialize() Q_DECL_OVERRIDE {
m_id_matrix = program()->uniformLocation("matrix");
- m_id_texScale = program()->uniformLocation("texScale");
- m_id_texOffset = program()->uniformLocation("texOffset");
+ m_id_yaTexScale = program()->uniformLocation("yaTexScale");
+ m_id_uvTexScale = program()->uniformLocation("uvTexScale");
+ m_id_yaTexOffset = program()->uniformLocation("yaTexOffset");
+ m_id_uvTexOffset = program()->uniformLocation("uvTexOffset");
+ m_id_yaClampRect = program()->uniformLocation("ya_clamp_rect");
+ m_id_uvClampRect = program()->uniformLocation("uv_clamp_rect");
m_id_yTexture = program()->uniformLocation("y_texture");
m_id_uTexture = program()->uniformLocation("u_texture");
m_id_vTexture = program()->uniformLocation("v_texture");
@@ -105,8 +120,12 @@ protected:
}
int m_id_matrix;
- int m_id_texScale;
- int m_id_texOffset;
+ int m_id_yaTexScale;
+ int m_id_uvTexScale;
+ int m_id_yaTexOffset;
+ int m_id_uvTexOffset;
+ int m_id_yaClampRect;
+ int m_id_uvClampRect;
int m_id_yTexture;
int m_id_uTexture;
int m_id_vTexture;
@@ -123,21 +142,28 @@ protected:
virtual const char *fragmentShader() const Q_DECL_OVERRIDE {
// Keep in sync with cc::FragmentShaderYUVAVideo
static const char *shader =
- "varying mediump vec2 v_texCoord;\n"
+ "varying mediump vec2 v_yaTexCoord;\n"
+ "varying mediump vec2 v_uvTexCoord;\n"
"uniform sampler2D y_texture;\n"
"uniform sampler2D u_texture;\n"
"uniform sampler2D v_texture;\n"
"uniform sampler2D a_texture;\n"
- "uniform lowp float alpha;\n"
- "uniform lowp vec3 yuv_adj;\n"
- "uniform lowp mat3 yuv_matrix;\n"
+ "uniform mediump float alpha;\n"
+ "uniform mediump vec3 yuv_adj;\n"
+ "uniform mediump mat3 yuv_matrix;\n"
+ "uniform mediump vec4 ya_clamp_rect;\n"
+ "uniform mediump vec4 uv_clamp_rect;\n"
"void main() {\n"
- " lowp float y_raw = texture2D(y_texture, v_texCoord).x;\n"
- " lowp float u_unsigned = texture2D(u_texture, v_texCoord).x;\n"
- " lowp float v_unsigned = texture2D(v_texture, v_texCoord).x;\n"
- " lowp float a_raw = texture2D(a_texture, v_texCoord).x;\n"
- " lowp vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;\n"
- " lowp vec3 rgb = yuv_matrix * yuv;\n"
+ " mediump vec2 ya_clamped =\n"
+ " max(ya_clamp_rect.xy, min(ya_clamp_rect.zw, v_yaTexCoord));\n"
+ " mediump float y_raw = texture2D(y_texture, ya_clamped).x;\n"
+ " mediump vec2 uv_clamped =\n"
+ " max(uv_clamp_rect.xy, min(uv_clamp_rect.zw, v_uvTexCoord));\n"
+ " mediump float u_unsigned = texture2D(u_texture, uv_clamped).x;\n"
+ " mediump float v_unsigned = texture2D(v_texture, uv_clamped).x;\n"
+ " mediump float a_raw = texture2D(a_texture, ya_clamped).x;\n"
+ " mediump vec3 yuv = vec3(y_raw, u_unsigned, v_unsigned) + yuv_adj;\n"
+ " mediump vec3 rgb = yuv_matrix * yuv;\n"
" gl_FragColor = vec4(rgb, 1.0) * (alpha * a_raw);\n"
"}";
return shader;
@@ -156,6 +182,8 @@ void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *
{
Q_UNUSED(oldMaterial);
+ // Keep logic in sync with logic in GLRenderer::DrawYUVVideoQuad:
+
YUVVideoMaterial *mat = static_cast<YUVVideoMaterial *>(newMaterial);
program()->setUniformValue(m_id_yTexture, 0);
program()->setUniformValue(m_id_uTexture, 1);
@@ -170,18 +198,47 @@ void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *
glFuncs.glActiveTexture(GL_TEXTURE0); // Finish with 0 as default texture unit
mat->m_yTexture->bind();
- program()->setUniformValue(m_id_texOffset, mat->m_texCoordRect.topLeft());
- program()->setUniformValue(m_id_texScale, mat->m_texCoordRect.size());
+ const QSizeF yaSizeScale(1.0f / mat->m_yaTexSize.width(), 1.0f / mat->m_yaTexSize.height());
+ const QSizeF uvSizeScale(1.0f / mat->m_uvTexSize.width(), 1.0f / mat->m_uvTexSize.height());
+
+ const QPointF yaTexOffset(mat->m_yaTexCoordRect.left() * yaSizeScale.width(), mat->m_yaTexCoordRect.top() * yaSizeScale.height());
+ const QPointF uvTexOffset(mat->m_uvTexCoordRect.left() * uvSizeScale.width(), mat->m_uvTexCoordRect.top() * uvSizeScale.height());
+ const QSizeF yaTexScale(mat->m_yaTexCoordRect.width() * yaSizeScale.width(), mat->m_yaTexCoordRect.height() * yaSizeScale.height());
+ const QSizeF uvTexScale(mat->m_uvTexCoordRect.width() * uvSizeScale.width(), mat->m_uvTexCoordRect.height() * uvSizeScale.height());
+ program()->setUniformValue(m_id_yaTexOffset, yaTexOffset);
+ program()->setUniformValue(m_id_uvTexOffset, uvTexOffset);
+ program()->setUniformValue(m_id_yaTexScale, yaTexScale);
+ program()->setUniformValue(m_id_uvTexScale, uvTexScale);
+ QRectF yaClampRect(yaTexOffset, yaTexScale);
+ QRectF uvClampRect(uvTexOffset, uvTexScale);
+ yaClampRect = yaClampRect.marginsRemoved(QMarginsF(yaSizeScale.width() * 0.5f, yaSizeScale.height() * 0.5f,
+ yaSizeScale.width() * 0.5f, yaSizeScale.height() * 0.5f));
+ uvClampRect = uvClampRect.marginsRemoved(QMarginsF(uvSizeScale.width() * 0.5f, uvSizeScale.height() * 0.5f,
+ uvSizeScale.width() * 0.5f, uvSizeScale.height() * 0.5f));
+
+ const QVector4D yaClampV(yaClampRect.left(), yaClampRect.top(), yaClampRect.right(), yaClampRect.bottom());
+ const QVector4D uvClampV(uvClampRect.left(), uvClampRect.top(), uvClampRect.right(), uvClampRect.bottom());
+ program()->setUniformValue(m_id_yaClampRect, yaClampV);
+ program()->setUniformValue(m_id_uvClampRect, uvClampV);
// These values are magic numbers that are used in the transformation from YUV
// to RGB color values. They are taken from the following webpage:
// http://www.fourcc.org/fccyvrgb.php
- const float yuv_to_rgb[9] = {
+ const float yuv_to_rgb_rec601[9] = {
1.164f, 0.0f, 1.596f,
1.164f, -.391f, -.813f,
1.164f, 2.018f, 0.0f,
};
- const QMatrix3x3 yuvMatrix(yuv_to_rgb);
+ const float yuv_to_rgb_rec709[9] = {
+ 1.164f, 0.0f, 1.793f,
+ 1.164f, -0.213f, -0.533f,
+ 1.164f, 2.112f, 0.0f,
+ };
+ const float yuv_to_rgb_jpeg[9] = {
+ 1.f, 0.0f, 1.402f,
+ 1.f, -.34414f, -.71414f,
+ 1.f, 1.772f, 0.0f,
+ };
// These values map to 16, 128, and 128 respectively, and are computed
// as a fraction over 256 (e.g. 16 / 256 = 0.0625).
@@ -189,9 +246,35 @@ void YUVVideoMaterialShader::updateState(const RenderState &state, QSGMaterial *
// Y - 16 : Gives 16 values of head and footroom for overshooting
// U - 128 : Turns unsigned U into signed U [-128,127]
// V - 128 : Turns unsigned V into signed V [-128,127]
- const QVector3D yuvAdjust(-0.0625f, -0.5f, -0.5f);
- program()->setUniformValue(m_id_yuvMatrix, yuvMatrix);
- program()->setUniformValue(m_id_yuvAdjust, yuvAdjust);
+ const float yuv_adjust_constrained[3] = {
+ -0.0625f, -0.5f, -0.5f,
+ };
+
+ // Same as above, but without the head and footroom.
+ const float yuv_adjust_full[3] = {
+ 0.0f, -0.5f, -0.5f,
+ };
+
+ const float *yuv_to_rgb = 0;
+ const float *yuv_adjust = 0;
+
+ switch (mat->m_colorSpace) {
+ case YUVVideoMaterial::REC_601:
+ yuv_to_rgb = yuv_to_rgb_rec601;
+ yuv_adjust = yuv_adjust_constrained;
+ break;
+ case YUVVideoMaterial::REC_709:
+ yuv_to_rgb = yuv_to_rgb_rec709;
+ yuv_adjust = yuv_adjust_constrained;
+ break;
+ case YUVVideoMaterial::JPEG:
+ yuv_to_rgb = yuv_to_rgb_jpeg;
+ yuv_adjust = yuv_adjust_full;
+ break;
+ }
+
+ program()->setUniformValue(m_id_yuvMatrix, QMatrix3x3(yuv_to_rgb));
+ program()->setUniformValue(m_id_yuvAdjust, QVector3D(yuv_adjust[0], yuv_adjust[1], yuv_adjust[2]));
if (state.isOpacityDirty())
program()->setUniformValue(m_id_opacity, state.opacity());
@@ -217,11 +300,17 @@ void YUVAVideoMaterialShader::updateState(const RenderState &state, QSGMaterial
}
-YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, const QRectF &texCoordRect)
+YUVVideoMaterial::YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ YUVVideoMaterial::ColorSpace colorspace)
: m_yTexture(yTexture)
, m_uTexture(uTexture)
, m_vTexture(vTexture)
- , m_texCoordRect(texCoordRect)
+ , m_yaTexCoordRect(yaTexCoordRect)
+ , m_uvTexCoordRect(uvTexCoordRect)
+ , m_yaTexSize(yaTexSize)
+ , m_uvTexSize(uvTexSize)
+ , m_colorSpace(colorspace)
{
}
@@ -240,8 +329,10 @@ int YUVVideoMaterial::compare(const QSGMaterial *other) const
return m_vTexture->textureId() - m->m_vTexture->textureId();
}
-YUVAVideoMaterial::YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &texCoordRect)
- : YUVVideoMaterial(yTexture, uTexture, vTexture, texCoordRect)
+YUVAVideoMaterial::YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ YUVVideoMaterial::ColorSpace colorspace)
+ : YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace)
, m_aTexture(aTexture)
{
setFlag(Blending, aTexture);
@@ -260,15 +351,17 @@ int YUVAVideoMaterial::compare(const QSGMaterial *other) const
return (m_aTexture ? m_aTexture->textureId() : 0) - (m->m_aTexture ? m->m_aTexture->textureId() : 0);
}
-YUVVideoNode::YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &texCoordRect)
+YUVVideoNode::YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ YUVVideoMaterial::ColorSpace colorspace)
: m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
{
setGeometry(&m_geometry);
setFlag(QSGNode::OwnsMaterial);
if (aTexture)
- m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, texCoordRect);
+ m_material = new YUVAVideoMaterial(yTexture, uTexture, vTexture, aTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace);
else
- m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, texCoordRect);
+ m_material = new YUVVideoMaterial(yTexture, uTexture, vTexture, yaTexCoordRect, uvTexCoordRect, yaTexSize, uvTexSize, colorspace);
setMaterial(m_material);
}
diff --git a/src/core/yuv_video_node.h b/src/core/yuv_video_node.h
index f96df56ce..457c2c7fe 100644
--- a/src/core/yuv_video_node.h
+++ b/src/core/yuv_video_node.h
@@ -50,7 +50,14 @@ QT_END_NAMESPACE
class YUVVideoMaterial : public QSGMaterial
{
public:
- YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, const QRectF &texCoordRect);
+ enum ColorSpace {
+ REC_601, // SDTV standard with restricted "studio swing" color range.
+ REC_709, // HDTV standard with restricted "studio swing" color range.
+ JPEG // Full color range [0, 255] JPEG color space.
+ };
+ YUVVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ ColorSpace colorspace);
virtual QSGMaterialType *type() const Q_DECL_OVERRIDE {
static QSGMaterialType theType;
@@ -63,13 +70,20 @@ public:
QSGTexture *m_yTexture;
QSGTexture *m_uTexture;
QSGTexture *m_vTexture;
- QRectF m_texCoordRect;
+ QRectF m_yaTexCoordRect;
+ QRectF m_uvTexCoordRect;
+ QSizeF m_yaTexSize;
+ QSizeF m_uvTexSize;
+ ColorSpace m_colorSpace;
+
};
class YUVAVideoMaterial : public YUVVideoMaterial
{
public:
- YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &texCoordRect);
+ YUVAVideoMaterial(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ ColorSpace colorspace);
virtual QSGMaterialType *type() const Q_DECL_OVERRIDE{
static QSGMaterialType theType;
@@ -85,7 +99,9 @@ public:
class YUVVideoNode : public QSGGeometryNode
{
public:
- YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture, const QRectF &texCoordRect);
+ YUVVideoNode(QSGTexture *yTexture, QSGTexture *uTexture, QSGTexture *vTexture, QSGTexture *aTexture,
+ const QRectF &yaTexCoordRect, const QRectF &uvTexCoordRect, const QSizeF &yaTexSize, const QSizeF &uvTexSize,
+ YUVVideoMaterial::ColorSpace colorspace);
void setRect(const QRectF &rect);
private:
diff --git a/src/process/process.pro b/src/process/process.pro
index 7844b1004..7bf06a376 100644
--- a/src/process/process.pro
+++ b/src/process/process.pro
@@ -9,23 +9,7 @@ contains(QT_CONFIG, qt_framework) {
# Deploy the QtWebEngineProcess app bundle into the QtWebEngineCore framework.
DESTDIR = $$MODULE_BASE_OUTDIR/lib/QtWebEngineCore.framework/Versions/5/Helpers
- # FIXME: We can remove those steps in Qt 5.5 once @rpath works
- # "QT += webenginecore" would pull all dependencies that we'd also need to update
- # with install_name_tool on OSX, but we only need access to the private
- # QtWebEngine::processMain. qtAddModule will take care of finding where
- # the library is without pulling additional librarie.
- QT = core
- qtAddModule(webenginecore, LIBS)
- CONFIG -= link_prl
- QMAKE_POST_LINK = \
- "xcrun install_name_tool -change " \
- "`xcrun otool -X -L $(TARGET) | grep QtWebEngineCore | cut -d ' ' -f 1` " \
- "@executable_path/../../../../QtWebEngineCore " \
- "$(TARGET); " \
- "xcrun install_name_tool -change " \
- "`xcrun otool -X -L $(TARGET) | grep QtCore | cut -d ' ' -f 1` " \
- "@executable_path/../../../../../../../QtCore.framework/QtCore " \
- "$(TARGET) "
+ QT += webenginecore
} else {
CONFIG -= app_bundle
win32: DESTDIR = $$MODULE_BASE_OUTDIR/bin
diff --git a/src/webengine/api/qquickwebenginenewviewrequest.cpp b/src/webengine/api/qquickwebenginenewviewrequest.cpp
index 68ea73208..893df7f46 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest.cpp
+++ b/src/webengine/api/qquickwebenginenewviewrequest.cpp
@@ -89,7 +89,7 @@ bool QQuickWebEngineNewViewRequest::isUserInitiated() const
*/
void QQuickWebEngineNewViewRequest::openIn(QQuickWebEngineView *view)
{
- if (!m_adapter) {
+ if (!m_adapter && !m_requestedUrl.isValid()) {
qWarning("Trying to open an empty request, it was either already used or was invalidated."
"\nYou must complete the request synchronously within the newViewRequested signal handler."
" If a view hasn't been adopted before returning, the request will be invalidated.");
@@ -100,6 +100,9 @@ void QQuickWebEngineNewViewRequest::openIn(QQuickWebEngineView *view)
qWarning("Trying to open a WebEngineNewViewRequest in an invalid WebEngineView.");
return;
}
- view->d_func()->adoptWebContents(m_adapter.data());
+ if (m_adapter)
+ view->d_func()->adoptWebContents(m_adapter.data());
+ else
+ view->setUrl(m_requestedUrl);
m_adapter.reset();
}
diff --git a/src/webengine/api/qquickwebenginenewviewrequest_p.h b/src/webengine/api/qquickwebenginenewviewrequest_p.h
index f9fac13e9..b408812ba 100644
--- a/src/webengine/api/qquickwebenginenewviewrequest_p.h
+++ b/src/webengine/api/qquickwebenginenewviewrequest_p.h
@@ -73,6 +73,8 @@ private:
QQuickWebEngineView::NewViewDestination m_destination;
bool m_isUserInitiated;
QExplicitlySharedDataPointer<QtWebEngineCore::WebContentsAdapter> m_adapter;
+ QUrl m_requestedUrl;
+ friend class QQuickWebEngineView;
friend class QQuickWebEngineViewPrivate;
};
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp
index 68884f967..67c74c356 100644
--- a/src/webengine/api/qquickwebengineprofile.cpp
+++ b/src/webengine/api/qquickwebengineprofile.cpp
@@ -40,6 +40,7 @@
#include "qquickwebenginedownloaditem_p_p.h"
#include "qquickwebengineprofile_p_p.h"
#include "qquickwebenginesettings_p.h"
+#include "qwebenginecookiestoreclient.h"
#include <QQmlEngine>
@@ -56,6 +57,9 @@ QQuickWebEngineProfilePrivate::QQuickWebEngineProfilePrivate(BrowserContextAdapt
{
m_browserContextRef->addClient(this);
m_settings->d_ptr->initDefaults(browserContext->isOffTheRecord());
+ // Fullscreen API was implemented before the supported setting, so we must
+ // make it default true to avoid change in default API behavior.
+ m_settings->d_ptr->setAttribute(QtWebEngineCore::WebEngineSettings::FullScreenSupportEnabled, true);
}
QQuickWebEngineProfilePrivate::~QQuickWebEngineProfilePrivate()
@@ -384,6 +388,28 @@ void QQuickWebEngineProfile::setHttpCacheMaximumSize(int maximumSize)
emit httpCacheMaximumSizeChanged();
}
+/*!
+ \qmlproperty QString WebEngineProfile::httpAcceptLanguage
+
+ The value of the Accept-Language HTTP request-header field.
+
+ \since QtWebEngine 1.2
+*/
+QString QQuickWebEngineProfile::httpAcceptLanguage() const
+{
+ Q_D(const QQuickWebEngineProfile);
+ return d->browserContext()->httpAcceptLanguage();
+}
+
+void QQuickWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
+{
+ Q_D(QQuickWebEngineProfile);
+ if (d->browserContext()->httpAcceptLanguage() == httpAcceptLanguage)
+ return;
+ d->browserContext()->setHttpAcceptLanguage(httpAcceptLanguage);
+ emit httpAcceptLanguageChanged();
+}
+
QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile()
{
static QQuickWebEngineProfile *profile = new QQuickWebEngineProfile(
@@ -398,4 +424,10 @@ QQuickWebEngineSettings *QQuickWebEngineProfile::settings() const
return d->settings();
}
+void QQuickWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient* client)
+{
+ Q_D(QQuickWebEngineProfile);
+ d->browserContext()->setCookieStoreClient(client);
+}
+
QT_END_NAMESPACE
diff --git a/src/webengine/api/qquickwebengineprofile_p.h b/src/webengine/api/qquickwebengineprofile_p.h
index 323721bd0..af5762032 100644
--- a/src/webengine/api/qquickwebengineprofile_p.h
+++ b/src/webengine/api/qquickwebengineprofile_p.h
@@ -63,6 +63,7 @@ QT_BEGIN_NAMESPACE
class QQuickWebEngineDownloadItem;
class QQuickWebEngineProfilePrivate;
class QQuickWebEngineSettings;
+class QWebEngineCookieStoreClient;
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject {
Q_OBJECT
@@ -74,6 +75,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineProfile : public QObject {
Q_PROPERTY(QString cachePath READ cachePath WRITE setCachePath NOTIFY cachePathChanged FINAL)
Q_PROPERTY(QString httpUserAgent READ httpUserAgent WRITE setHttpUserAgent NOTIFY httpUserAgentChanged FINAL)
Q_PROPERTY(HttpCacheType httpCacheType READ httpCacheType WRITE setHttpCacheType NOTIFY httpCacheTypeChanged FINAL)
+ Q_PROPERTY(QString httpAcceptLanguage READ httpAcceptLanguage WRITE setHttpAcceptLanguage NOTIFY httpAcceptLanguageChanged FINAL)
Q_PROPERTY(PersistentCookiesPolicy persistentCookiesPolicy READ persistentCookiesPolicy WRITE setPersistentCookiesPolicy NOTIFY persistentCookiesPolicyChanged FINAL)
Q_PROPERTY(int httpCacheMaximumSize READ httpCacheMaximumSize WRITE setHttpCacheMaximumSize NOTIFY httpCacheMaximumSizeChanged FINAL)
public:
@@ -115,8 +117,13 @@ public:
int httpCacheMaximumSize() const;
void setHttpCacheMaximumSize(int maxSize);
+ Q_REVISION(1) QString httpAcceptLanguage() const;
+ Q_REVISION(1) void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
+
static QQuickWebEngineProfile *defaultProfile();
+ Q_REVISION(1) Q_INVOKABLE void setCookieStoreClient(QWebEngineCookieStoreClient* client);
+
signals:
void storageNameChanged();
void offTheRecordChanged();
@@ -126,6 +133,7 @@ signals:
void httpCacheTypeChanged();
void persistentCookiesPolicyChanged();
void httpCacheMaximumSizeChanged();
+ Q_REVISION(1) void httpAcceptLanguageChanged();
void downloadRequested(QQuickWebEngineDownloadItem *download);
void downloadFinished(QQuickWebEngineDownloadItem *download);
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp
index 248713543..539f211b0 100644
--- a/src/webengine/api/qquickwebenginesettings.cpp
+++ b/src/webengine/api/qquickwebenginesettings.cpp
@@ -206,6 +206,31 @@ bool QQuickWebEngineSettings::errorPageEnabled() const
}
/*!
+ \qmlproperty bool WebEngineSettings::pluginsEnabled
+
+ Enables support for Pepper plugins, such as the Flash player.
+
+ Disabled by default.
+*/
+bool QQuickWebEngineSettings::pluginsEnabled() const
+{
+ return d_ptr->testAttribute(WebEngineSettings::PluginsEnabled);
+}
+
+/*!
+ \qmlproperty bool WebEngineSettings::fullscreenSupportEnabled
+ \since QtWebEngine 1.2
+
+ Tells the web engine whether fullscreen is supported in this application or not.
+
+ Enabled by default.
+*/
+bool QQuickWebEngineSettings::fullScreenSupportEnabled() const
+{
+ return d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled);
+}
+
+/*!
\qmlproperty QString WebEngineSettings::defaultTextEncoding
Sets the default encoding. The value must be a string describing an encoding such as "utf-8" or
@@ -309,6 +334,22 @@ void QQuickWebEngineSettings::setErrorPageEnabled(bool on)
Q_EMIT errorPageEnabledChanged();
}
+void QQuickWebEngineSettings::setPluginsEnabled(bool on)
+{
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::PluginsEnabled);
+ d_ptr->setAttribute(WebEngineSettings::PluginsEnabled, on);
+ if (wasOn != on)
+ Q_EMIT pluginsEnabledChanged();
+}
+
+void QQuickWebEngineSettings::setFullScreenSupportEnabled(bool on)
+{
+ bool wasOn = d_ptr->testAttribute(WebEngineSettings::FullScreenSupportEnabled);
+ d_ptr->setAttribute(WebEngineSettings::FullScreenSupportEnabled, on);
+ if (wasOn != on)
+ Q_EMIT fullScreenSupportEnabledChanged();
+}
+
void QQuickWebEngineSettings::setDefaultTextEncoding(QString encoding)
{
const QString oldDefaultTextEncoding = d_ptr->defaultTextEncoding();
diff --git a/src/webengine/api/qquickwebenginesettings_p.h b/src/webengine/api/qquickwebenginesettings_p.h
index 213505078..604e5693d 100644
--- a/src/webengine/api/qquickwebenginesettings_p.h
+++ b/src/webengine/api/qquickwebenginesettings_p.h
@@ -71,6 +71,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_PROPERTY(bool localContentCanAccessFileUrls READ localContentCanAccessFileUrls WRITE setLocalContentCanAccessFileUrls NOTIFY localContentCanAccessFileUrlsChanged)
Q_PROPERTY(bool hyperlinkAuditingEnabled READ hyperlinkAuditingEnabled WRITE setHyperlinkAuditingEnabled NOTIFY hyperlinkAuditingEnabledChanged)
Q_PROPERTY(bool errorPageEnabled READ errorPageEnabled WRITE setErrorPageEnabled NOTIFY errorPageEnabledChanged)
+ Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged)
+ Q_PROPERTY(bool fullScreenSupportEnabled READ fullScreenSupportEnabled WRITE setFullScreenSupportEnabled NOTIFY fullScreenSupportEnabledChanged REVISION 1)
Q_PROPERTY(QString defaultTextEncoding READ defaultTextEncoding WRITE setDefaultTextEncoding NOTIFY defaultTextEncodingChanged)
public:
@@ -87,6 +89,8 @@ public:
bool localContentCanAccessFileUrls() const;
bool hyperlinkAuditingEnabled() const;
bool errorPageEnabled() const;
+ bool pluginsEnabled() const;
+ bool fullScreenSupportEnabled() const;
QString defaultTextEncoding() const;
void setAutoLoadImages(bool on);
@@ -100,6 +104,8 @@ public:
void setLocalContentCanAccessFileUrls(bool on);
void setHyperlinkAuditingEnabled(bool on);
void setErrorPageEnabled(bool on);
+ void setPluginsEnabled(bool on);
+ void setFullScreenSupportEnabled(bool on);
void setDefaultTextEncoding(QString encoding);
signals:
@@ -114,6 +120,8 @@ signals:
void localContentCanAccessFileUrlsChanged();
void hyperlinkAuditingEnabledChanged();
void errorPageEnabledChanged();
+ void pluginsEnabledChanged();
+ Q_REVISION(1) void fullScreenSupportEnabledChanged();
void defaultTextEncodingChanged();
private:
diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h
index 8d52dfa7c..9690e538d 100644
--- a/src/webengine/api/qquickwebenginetestsupport_p.h
+++ b/src/webengine/api/qquickwebenginetestsupport_p.h
@@ -78,6 +78,9 @@ public:
QQuickWebEngineTestSupport();
QQuickWebEngineErrorPage *errorPage() const;
+Q_SIGNALS:
+ void validationMessageShown(const QString &mainText, const QString &subText);
+
private:
QScopedPointer<QQuickWebEngineErrorPage> m_errorPage;
};
diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp
index 6c3452a6a..65b98ca98 100644
--- a/src/webengine/api/qquickwebengineview.cpp
+++ b/src/webengine/api/qquickwebengineview.cpp
@@ -39,6 +39,7 @@
#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
+#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#include "qquickwebenginehistory_p.h"
#include "qquickwebenginecertificateerror_p.h"
@@ -63,7 +64,9 @@
#include "web_engine_settings.h"
#include "web_engine_visited_links_manager.h"
+#include <QClipboard>
#include <QGuiApplication>
+#include <QMimeData>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlEngine>
@@ -102,8 +105,10 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
, loadProgress(0)
, m_isFullScreen(false)
, isLoading(false)
+ , m_activeFocusOnPress(true)
, devicePixelRatio(QGuiApplication::primaryScreen()->devicePixelRatio())
, m_dpiScale(1.0)
+ , m_backgroundColor(Qt::white)
{
// The gold standard for mobile web content is 160 dpi, and the devicePixelRatio expected
// is the (possibly quantized) ratio of device dpi to 160 dpi.
@@ -175,31 +180,101 @@ bool QQuickWebEngineViewPrivate::contextMenuRequested(const WebEngineContextMenu
if (!menu)
return false;
+ contextMenuData = data;
+
// Populate our menu
MenuItemHandler *item = 0;
+ if (!data.linkText.isEmpty() && data.linkUrl.isValid()) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::OpenLinkInThisWindow); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Follow Link"));
+ }
+
if (data.selectedText.isEmpty()) {
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::goBack);
- ui()->addMenuItem(item, QObject::tr("Back"), QStringLiteral("go-previous"), q->canGoBack());
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Back"), QStringLiteral("go-previous"), q->canGoBack());
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::goForward);
- ui()->addMenuItem(item, QObject::tr("Forward"), QStringLiteral("go-next"), q->canGoForward());
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Forward"), QStringLiteral("go-next"), q->canGoForward());
item = new MenuItemHandler(menu);
QObject::connect(item, &MenuItemHandler::triggered, q, &QQuickWebEngineView::reload);
- ui()->addMenuItem(item, QObject::tr("Reload"), QStringLiteral("view-refresh"));
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Reload"), QStringLiteral("view-refresh"));
} else {
- item = new CopyMenuItem(menu, data.selectedText);
- ui()->addMenuItem(item, QObject::tr("Copy..."));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::Copy); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy"));
}
- if (!data.linkText.isEmpty() && data.linkUrl.isValid()) {
- item = new NavigateMenuItem(menu, adapter, data.linkUrl);
- ui()->addMenuItem(item, QObject::tr("Navigate to..."));
- item = new CopyMenuItem(menu, data.linkUrl.toString());
- ui()->addMenuItem(item, QObject::tr("Copy link address"));
+ if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyLinkToClipboard); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Link URL"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadLinkToDisk); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Save Link..."));
+ }
+ if (contextMenuData.mediaUrl.isValid()) {
+ switch (contextMenuData.mediaType) {
+ case WebEngineContextMenuData::MediaTypeImage:
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageUrlToClipboard); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image URL"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageToClipboard); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadImageToDisk); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Save Image"));
+ break;
+ case WebEngineContextMenuData::MediaTypeCanvas:
+ Q_UNREACHABLE(); // mediaUrl is invalid for canvases
+ break;
+ case WebEngineContextMenuData::MediaTypeAudio:
+ case WebEngineContextMenuData::MediaTypeVideo:
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyMediaUrlToClipboard); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Media URL"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::DownloadMediaToDisk); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Download Media"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaPlayPause); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Play/Pause"));
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaLoop); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Looping"));
+ if (contextMenuData.mediaFlags & WebEngineContextMenuData::MediaHasAudio) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaMute); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Mute"));
+ }
+ if (contextMenuData.mediaFlags & WebEngineContextMenuData::MediaCanToggleControls) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ToggleMediaControls); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Toggle Media Controls"));
+ }
+ break;
+ default:
+ break;
+ }
+ } else if (contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeCanvas) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::CopyImageToClipboard); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Copy Image"));
+ }
+ if (adapter->hasInspector()) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::InspectElement); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Inspect Element"));
+ }
+ if (isFullScreen()) {
+ item = new MenuItemHandler(menu);
+ QObject::connect(item, &MenuItemHandler::triggered, [q] { q->triggerWebAction(QQuickWebEngineView::ExitFullScreen); });
+ ui()->addMenuItem(item, QQuickWebEngineView::tr("Exit Full Screen Mode"));
}
// FIXME: expose the context menu data as an attached property to make this more useful
@@ -251,9 +326,9 @@ void QQuickWebEngineViewPrivate::runGeolocationPermissionRequest(const QUrl &url
Q_EMIT q->featurePermissionRequested(url, QQuickWebEngineView::Geolocation);
}
-void QQuickWebEngineViewPrivate::runFileChooser(FileChooserMode mode, const QString &defaultFileName, const QStringList &acceptedMimeTypes)
+void QQuickWebEngineViewPrivate::runFileChooser(FilePickerController* controller)
{
- ui()->showFilePicker(mode, defaultFileName, acceptedMimeTypes, adapter);
+ ui()->showFilePicker(controller);
}
void QQuickWebEngineViewPrivate::passOnFocus(bool reverse)
@@ -310,6 +385,11 @@ qreal QQuickWebEngineViewPrivate::dpiScale() const
return m_dpiScale;
}
+QColor QQuickWebEngineViewPrivate::backgroundColor() const
+{
+ return m_backgroundColor;
+}
+
void QQuickWebEngineViewPrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage)
{
Q_Q(QQuickWebEngineView);
@@ -581,7 +661,7 @@ QQuickWebEngineView::QQuickWebEngineView(QQuickItem *parent)
Q_D(QQuickWebEngineView);
d->e->q_ptr = d->q_ptr = this;
this->setActiveFocusOnTab(true);
- this->setFlag(QQuickItem::ItemIsFocusScope);
+ this->setFlags(QQuickItem::ItemIsFocusScope | QQuickItem::ItemAcceptsInputMethod);
#ifndef QT_NO_ACCESSIBILITY
QQuickAccessibleAttached *accessible = QQuickAccessibleAttached::qmlAttachedProperties(this);
@@ -754,8 +834,23 @@ void QQuickWebEngineView::setTestSupport(QQuickWebEngineTestSupport *testSupport
Q_D(QQuickWebEngineView);
d->m_testSupport = testSupport;
}
+
#endif
+/*!
+ * \qmlproperty bool WebEngineView::activeFocusOnPress
+ * \since QtWebEngine 1.2
+ *
+ * This property specifies whether the view should gain active focus when pressed.
+ * The default value is true.
+ *
+ */
+bool QQuickWebEngineView::activeFocusOnPress() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->m_activeFocusOnPress;
+}
+
void QQuickWebEngineViewPrivate::didRunJavaScript(quint64 requestId, const QVariant &result)
{
Q_Q(QQuickWebEngineView);
@@ -774,6 +869,11 @@ void QQuickWebEngineViewPrivate::didFindText(quint64 requestId, int matchCount)
}
void QQuickWebEngineViewPrivate::showValidationMessage(const QRect &anchor, const QString &mainText, const QString &subText)
{
+#ifdef ENABLE_QML_TESTSUPPORT_API
+ if (m_testSupport)
+ Q_EMIT m_testSupport->validationMessageShown(mainText, subText);
+#endif
+
ui()->showMessageBubble(anchor, mainText, subText);
}
@@ -849,6 +949,34 @@ qreal QQuickWebEngineView::zoomFactor() const
return d->adapter->currentZoomFactor();
}
+/*!
+ \qmlproperty bool WebEngineView::backgroundColor
+ \since QtWebEngine 1.2
+
+ Sets this property to change the color of the WebEngineView's background,
+ behing the document's body. You can set it to "transparent" or to a translucent
+ color to see through the document, or you can set this color to match your
+ web content in an hybrid app to prevent the white flashes that may appear
+ during loading.
+
+ The default value is white.
+*/
+QColor QQuickWebEngineView::backgroundColor() const
+{
+ Q_D(const QQuickWebEngineView);
+ return d->m_backgroundColor;
+}
+
+void QQuickWebEngineView::setBackgroundColor(const QColor &color)
+{
+ Q_D(QQuickWebEngineView);
+ if (color == d->m_backgroundColor)
+ return;
+ d->m_backgroundColor = color;
+ d->ensureContentsAdapter();
+ d->adapter->backgroundColorChanged();
+ emit backgroundColorChanged();
+}
bool QQuickWebEngineView::isFullScreen() const
{
@@ -943,6 +1071,16 @@ void QQuickWebEngineView::grantFeaturePermission(const QUrl &securityOrigin, QQu
}
}
+void QQuickWebEngineView::setActiveFocusOnPress(bool arg)
+{
+ Q_D(QQuickWebEngineView);
+ if (d->m_activeFocusOnPress == arg)
+ return;
+
+ d->m_activeFocusOnPress = arg;
+ emit activeFocusOnPressChanged(arg);
+}
+
void QQuickWebEngineView::goBackOrForward(int offset)
{
Q_D(QQuickWebEngineView);
@@ -988,6 +1126,168 @@ void QQuickWebEngineView::itemChange(ItemChange change, const ItemChangeData &va
QQuickItem::itemChange(change, value);
}
+void QQuickWebEngineView::triggerWebAction(WebAction action)
+{
+ Q_D(QQuickWebEngineView);
+ switch (action) {
+ case Back:
+ d->adapter->navigateToOffset(-1);
+ break;
+ case Forward:
+ d->adapter->navigateToOffset(1);
+ break;
+ case Stop:
+ d->adapter->stop();
+ break;
+ case Reload:
+ d->adapter->reload();
+ break;
+ case ReloadAndBypassCache:
+ d->adapter->reloadAndBypassCache();
+ break;
+ case Cut:
+ d->adapter->cut();
+ break;
+ case Copy:
+ d->adapter->copy();
+ break;
+ case Paste:
+ d->adapter->paste();
+ break;
+ case Undo:
+ d->adapter->undo();
+ break;
+ case Redo:
+ d->adapter->redo();
+ break;
+ case SelectAll:
+ d->adapter->selectAll();
+ break;
+ case PasteAndMatchStyle:
+ d->adapter->pasteAndMatchStyle();
+ break;
+ case OpenLinkInThisWindow:
+ if (d->contextMenuData.linkUrl.isValid())
+ setUrl(d->contextMenuData.linkUrl);
+ break;
+ case OpenLinkInNewWindow:
+ if (d->contextMenuData.linkUrl.isValid()) {
+ QQuickWebEngineNewViewRequest request;
+ request.m_requestedUrl = d->contextMenuData.linkUrl;
+ request.m_isUserInitiated = true;
+ request.m_destination = NewViewInWindow;
+ Q_EMIT newViewRequested(&request);
+ }
+ break;
+ case OpenLinkInNewTab:
+ if (d->contextMenuData.linkUrl.isValid()) {
+ QQuickWebEngineNewViewRequest request;
+ request.m_requestedUrl = d->contextMenuData.linkUrl;
+ request.m_isUserInitiated = true;
+ request.m_destination = NewViewInBackgroundTab;
+ Q_EMIT newViewRequested(&request);
+ }
+ break;
+ case CopyLinkToClipboard:
+ if (d->contextMenuData.linkUrl.isValid()) {
+ QString urlString = d->contextMenuData.linkUrl.toString(QUrl::FullyEncoded);
+ QString title = d->contextMenuData.linkText.toHtmlEscaped();
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\">") + title + QStringLiteral("</a>");
+ data->setHtml(html);
+ data->setUrls(QList<QUrl>() << d->contextMenuData.linkUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case DownloadLinkToDisk:
+ if (d->contextMenuData.linkUrl.isValid())
+ d->adapter->download(d->contextMenuData.linkUrl, d->contextMenuData.suggestedFileName);
+ break;
+ case CopyImageToClipboard:
+ if (d->contextMenuData.hasImageContent &&
+ (d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeImage ||
+ d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeCanvas))
+ {
+ d->adapter->copyImageAt(d->contextMenuData.pos);
+ }
+ break;
+ case CopyImageUrlToClipboard:
+ if (d->contextMenuData.mediaUrl.isValid() && d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeImage) {
+ QString urlString = d->contextMenuData.mediaUrl.toString(QUrl::FullyEncoded);
+ QString title = d->contextMenuData.linkText;
+ if (!title.isEmpty())
+ title = QStringLiteral(" alt=\"%1\"").arg(title.toHtmlEscaped());
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral("></img>");
+ data->setHtml(html);
+ data->setUrls(QList<QUrl>() << d->contextMenuData.mediaUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case DownloadImageToDisk:
+ case DownloadMediaToDisk:
+ if (d->contextMenuData.mediaUrl.isValid())
+ d->adapter->download(d->contextMenuData.mediaUrl, d->contextMenuData.suggestedFileName);
+ break;
+ case CopyMediaUrlToClipboard:
+ if (d->contextMenuData.mediaUrl.isValid() &&
+ (d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ QString urlString = d->contextMenuData.mediaUrl.toString(QUrl::FullyEncoded);
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ if (d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeAudio)
+ data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"></audio>"));
+ else
+ data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"></video>"));
+ data->setUrls(QList<QUrl>() << d->contextMenuData.mediaUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case ToggleMediaControls:
+ if (d->contextMenuData.mediaUrl.isValid() && d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaCanToggleControls) {
+ bool enable = !(d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaControls);
+ d->adapter->executeMediaPlayerActionAt(d->contextMenuData.pos, WebContentsAdapter::MediaPlayerControls, enable);
+ }
+ break;
+ case ToggleMediaLoop:
+ if (d->contextMenuData.mediaUrl.isValid() &&
+ (d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ bool enable = !(d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaLoop);
+ d->adapter->executeMediaPlayerActionAt(d->contextMenuData.pos, WebContentsAdapter::MediaPlayerLoop, enable);
+ }
+ break;
+ case ToggleMediaPlayPause:
+ if (d->contextMenuData.mediaUrl.isValid() &&
+ (d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ bool enable = (d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaPaused);
+ d->adapter->executeMediaPlayerActionAt(d->contextMenuData.pos, WebContentsAdapter::MediaPlayerPlay, enable);
+ }
+ break;
+ case ToggleMediaMute:
+ if (d->contextMenuData.mediaUrl.isValid() && d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaHasAudio) {
+ bool enable = (d->contextMenuData.mediaFlags & WebEngineContextMenuData::MediaMuted);
+ d->adapter->executeMediaPlayerActionAt(d->contextMenuData.pos, WebContentsAdapter::MediaPlayerMute, enable);
+ }
+ break;
+ case InspectElement:
+ d->adapter->inspectElementAt(d->contextMenuData.pos);
+ break;
+ case ExitFullScreen:
+ d->adapter->exitFullScreen();
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
+}
+
void QQuickWebEngineViewPrivate::userScripts_append(QQmlListProperty<QQuickWebEngineScript> *p, QQuickWebEngineScript *script)
{
Q_ASSERT(p && p->data);
diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h
index f85bf64ad..ab2e6a566 100644
--- a/src/webengine/api/qquickwebengineview_p.h
+++ b/src/webengine/api/qquickwebengineview_p.h
@@ -84,6 +84,8 @@ private:
bool m_toggleOn;
};
+#define LATEST_WEBENGINEVIEW_REVISION 2
+
class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
@@ -100,6 +102,8 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_PROPERTY(QQuickWebEngineHistory *navigationHistory READ navigationHistory CONSTANT FINAL REVISION 1)
Q_PROPERTY(QQmlWebChannel *webChannel READ webChannel WRITE setWebChannel NOTIFY webChannelChanged REVISION 1)
Q_PROPERTY(QQmlListProperty<QQuickWebEngineScript> userScripts READ userScripts FINAL REVISION 1)
+ Q_PROPERTY(bool activeFocusOnPress READ activeFocusOnPress WRITE setActiveFocusOnPress NOTIFY activeFocusOnPressChanged REVISION 2)
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged REVISION 2)
#ifdef ENABLE_QML_TESTSUPPORT_API
Q_PROPERTY(QQuickWebEngineTestSupport *testSupport READ testSupport WRITE setTestSupport FINAL)
@@ -113,6 +117,7 @@ class Q_WEBENGINE_PRIVATE_EXPORT QQuickWebEngineView : public QQuickItem {
Q_ENUMS(Feature);
Q_ENUMS(JavaScriptConsoleMessageLevel);
Q_FLAGS(FindFlags);
+ Q_ENUMS(WebAction);
public:
QQuickWebEngineView(QQuickItem *parent = 0);
@@ -129,6 +134,8 @@ public:
bool isFullScreen() const;
qreal zoomFactor() const;
void setZoomFactor(qreal arg);
+ QColor backgroundColor() const;
+ void setBackgroundColor(const QColor &color);
QQuickWebEngineViewExperimental *experimental() const;
@@ -181,6 +188,47 @@ public:
Geolocation
};
+ enum WebAction {
+ NoWebAction = - 1,
+ Back,
+ Forward,
+ Stop,
+ Reload,
+
+ Cut,
+ Copy,
+ Paste,
+
+ Undo,
+ Redo,
+ SelectAll,
+ ReloadAndBypassCache,
+
+ PasteAndMatchStyle,
+
+ OpenLinkInThisWindow,
+ OpenLinkInNewWindow,
+ OpenLinkInNewTab,
+ CopyLinkToClipboard,
+ DownloadLinkToDisk,
+
+ CopyImageToClipboard,
+ CopyImageUrlToClipboard,
+ DownloadImageToDisk,
+
+ CopyMediaUrlToClipboard,
+ ToggleMediaControls,
+ ToggleMediaLoop,
+ ToggleMediaPlayPause,
+ ToggleMediaMute,
+ DownloadMediaToDisk,
+
+ InspectElement,
+ ExitFullScreen,
+
+ WebActionCount
+ };
+
// must match WebContentsAdapterClient::JavaScriptConsoleMessageLevel
enum JavaScriptConsoleMessageLevel {
InfoMessageLevel = 0,
@@ -211,6 +259,8 @@ public:
void setTestSupport(QQuickWebEngineTestSupport *testSupport);
#endif
+ bool activeFocusOnPress() const;
+
public Q_SLOTS:
void runJavaScript(const QString&, const QJSValue & = QJSValue());
void loadHtml(const QString &html, const QUrl &baseUrl = QUrl());
@@ -223,6 +273,8 @@ public Q_SLOTS:
Q_REVISION(1) void findText(const QString &subString, FindFlags options = 0, const QJSValue &callback = QJSValue());
Q_REVISION(1) void fullScreenCancelled();
Q_REVISION(1) void grantFeaturePermission(const QUrl &securityOrigin, Feature, bool granted);
+ Q_REVISION(2) void setActiveFocusOnPress(bool arg);
+ Q_REVISION(2) void triggerWebAction(WebAction action);
Q_SIGNALS:
void titleChanged();
@@ -241,7 +293,8 @@ Q_SIGNALS:
Q_REVISION(1) void zoomFactorChanged(qreal arg);
Q_REVISION(1) void profileChanged();
Q_REVISION(1) void webChannelChanged();
-
+ Q_REVISION(2) void activeFocusOnPressChanged(bool);
+ Q_REVISION(2) void backgroundColorChanged();
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h
index 60aa0d9f4..6db6b199e 100644
--- a/src/webengine/api/qquickwebengineview_p_p.h
+++ b/src/webengine/api/qquickwebengineview_p_p.h
@@ -134,6 +134,7 @@ public:
virtual void selectionChanged() Q_DECL_OVERRIDE { }
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
+ virtual QColor backgroundColor() const Q_DECL_OVERRIDE;
virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE;
virtual void loadCommitted() Q_DECL_OVERRIDE;
virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE;
@@ -147,14 +148,14 @@ public:
virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE;
- virtual void runFileChooser(FileChooserMode, const QString &defaultFileName, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
+ virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE;
virtual void didRunJavaScript(quint64, const QVariant&) Q_DECL_OVERRIDE;
virtual void didFetchDocumentMarkup(quint64, const QString&) Q_DECL_OVERRIDE { }
virtual void didFetchDocumentInnerText(quint64, const QString&) Q_DECL_OVERRIDE { }
virtual void didFindText(quint64, int) Q_DECL_OVERRIDE;
virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE;
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
- virtual void authenticationRequired(const QUrl&, const QString&, bool, const QString&, QString*, QString*) Q_DECL_OVERRIDE { }
+ virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE { }
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE;
#ifndef QT_NO_ACCESSIBILITY
@@ -190,11 +191,13 @@ public:
QQuickWebEngineTestSupport *m_testSupport;
#endif
QQmlComponent *contextMenuExtraItems;
+ QtWebEngineCore::WebEngineContextMenuData contextMenuData;
QUrl explicitUrl;
QUrl icon;
int loadProgress;
bool m_isFullScreen;
bool isLoading;
+ bool m_activeFocusOnPress;
qreal devicePixelRatio;
QMap<quint64, QJSValue> m_callbacks;
QList<QSharedPointer<CertificateErrorController> > m_certificateErrorControllers;
@@ -203,6 +206,7 @@ private:
QScopedPointer<QtWebEngineCore::UIDelegatesManager> m_uIDelegatesManager;
QList<QQuickWebEngineScript *> m_userScripts;
qreal m_dpiScale;
+ QColor m_backgroundColor;
};
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/webengine/doc/images/qtwebengine-architecture.png b/src/webengine/doc/images/qtwebengine-architecture.png
new file mode 100644
index 000000000..37ca2da16
--- /dev/null
+++ b/src/webengine/doc/images/qtwebengine-architecture.png
Binary files differ
diff --git a/src/webengine/doc/qtwebengine.qdocconf b/src/webengine/doc/qtwebengine.qdocconf
index ad6898440..527983ca1 100644
--- a/src/webengine/doc/qtwebengine.qdocconf
+++ b/src/webengine/doc/qtwebengine.qdocconf
@@ -17,23 +17,49 @@ qhp.QtWebEngine.indexRoot =
qhp.QtWebEngine.filterAttributes = qtwebengine $QT_VERSION qtrefdoc
qhp.QtWebEngine.customFilters.Qt.name = QtWebEngine $QT_VERSION
qhp.QtWebEngine.customFilters.Qt.filterAttributes = qtwebengine $QT_VERSION
-qhp.QtWebEngine.subprojects = qmltypes examples
+
+qhp.QtWebEngine.subprojects = classes qmltypes examples
+
+qhp.QtWebEngine.subprojects.classes.title = C++ Classes
+qhp.QtWebEngine.subprojects.classes.indexTitle = Qt WebEngine C++ Classes
+qhp.QtWebEngine.subprojects.classes.selectors = class doc:headerfile
+qhp.QtWebEngine.subprojects.classes.sortPages = true
+
qhp.QtWebEngine.subprojects.qmltypes.title = QML Types
qhp.QtWebEngine.subprojects.qmltypes.indexTitle = Qt WebEngine QML Types
-qhp.QtWebEngine.subprojects.qmltypes.selectors = qmlclass
+qhp.QtWebEngine.subprojects.qmltypes.selectors = qmltype
qhp.QtWebEngine.subprojects.qmltypes.sortPages = true
+
qhp.QtWebEngine.subprojects.examples.title = Examples
qhp.QtWebEngine.subprojects.examples.indexTitle = Qt WebEngine Examples
-qhp.QtWebEngine.subprojects.examples.selectors = fake:example
+qhp.QtWebEngine.subprojects.examples.selectors = doc:example
qhp.QtWebEngine.subprojects.examples.sortPages = true
tagfile = ../../../doc/qtwebengine/qtwebengine.tags
-depends += qtcore qtgui qtquick qtquickcontrols qtdoc
+depends += qtcore \
+ qtgui \
+ qtqml \
+ qtquick \
+ qtquickcontrols \
+ qtdoc \
+ qtwebchannel \
+ qtwebenginewidgets
+
+headerdirs += . \
+ ../api \
+ ../../core/api
+
+sourcedirs += . \
+ ../api \
+ ../../core/api \
+ ../../core/doc/src
-headerdirs += . ../api
-sourcedirs += . ../api
-exampledirs += ../../../examples/webengine .
+exampledirs += . \
+ ../../../examples/webengine \
+ snippets \
+ ../../core/doc/snippets
navigation.landingpage = "Qt WebEngine"
+navigation.cppclassespage = "Qt WebEngine C++ Classes"
navigation.qmltypespage = "Qt WebEngine QML Types"
diff --git a/src/webengine/doc/src/qtwebengine.qdoc b/src/webengine/doc/src/qtwebengine-examples.qdoc
index e381178f6..ec49577e4 100644
--- a/src/webengine/doc/src/qtwebengine.qdoc
+++ b/src/webengine/doc/src/qtwebengine-examples.qdoc
@@ -24,22 +24,6 @@
*/
/*!
- \qmlmodule QtWebEngine 1.1
- \title Qt WebEngine QML Types
- \brief Provides QML types for rendering web content within a QML application
-
- The QML types can be imported into your application using the following
- import statement in your .qml file:
-
- \code
- import QtQuick 2.0
- import QtWebEngine 1.1
- \endcode
-
- \sa {Qt WebEngine Examples}
-*/
-
-/*!
\group webengine-examples
\title Qt WebEngine Examples
\brief Examples demonstrating the Qt WebEngine usage
@@ -49,5 +33,6 @@
from displaying Web pages within a QML user interface to an implementation of
a basic function Web browser.
- \sa {Qt WebEngine QML Types}
+ For widget-based applications, Qt provides an integrated Web browser component based on
+ Chromium, the popular open source browser engine.
*/
diff --git a/src/webengine/doc/src/qtwebengine-index.qdoc b/src/webengine/doc/src/qtwebengine-index.qdoc
new file mode 100644
index 000000000..e6f071913
--- /dev/null
+++ b/src/webengine/doc/src/qtwebengine-index.qdoc
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtwebengine-index.html
+ \title Qt WebEngine
+ \ingroup modules
+
+ \brief Provides functionality for rendering regions of dynamic web content.
+
+ \e {Qt WebEngine} provides functionality for rendering regions of dynamic web content.
+
+ The functionality in Qt WebEngine is divided into the following modules:
+
+ \annotatedlist qtwebengine-modules
+
+ For Qt Quick applications, Qt WebEngine provides the following QML modules:
+
+ \annotatedlist qtwebengine-qmlmodules
+
+ \section1 Getting Started
+
+ To include the definitions of the Qt WebEngineCore and Qt WebEngineWidgets modules' classes, use
+ the following directives:
+
+ \badcode
+ #include <QtWebEngineCore>
+ #include <QtWebEngineWidgets>
+ \endcode
+
+ To import the Qt WebEngine module's QML types, add the following import statement to your .qml
+ file:
+
+ \badcode
+ import QtWebEngine 1.2
+ \endcode
+
+ To link against the modules, add QT variables to your qmake .pro file:
+
+ \badcode
+ QT += webengine webenginecore webenginewidgets
+ \endcode
+
+ \section1 Articles and Guides
+
+ \list
+ \li \l{Qt WebEngine Overview}
+ \li \l{Porting from Qt WebKit to Qt WebEngine}
+ \endlist
+
+ \section1 Examples
+
+ \list
+ \li \l{Qt WebEngine Examples}
+ \li \l{Qt WebEngine Widgets Examples}
+ \endlist
+
+ \section1 API References
+
+ \list
+ \li \l{Qt WebEngine Core C++ Classes}
+ \li \l{Qt WebEngine Widgets C++ Classes}
+ \li \l{Qt WebEngine QML Types}
+ \endlist
+*/
diff --git a/src/webengine/doc/src/qtwebengine-overview.qdoc b/src/webengine/doc/src/qtwebengine-overview.qdoc
new file mode 100644
index 000000000..656dd13f1
--- /dev/null
+++ b/src/webengine/doc/src/qtwebengine-overview.qdoc
@@ -0,0 +1,171 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page qtwebengine-overview.html
+ \title Qt WebEngine Overview
+
+ The Qt WebEngine module provides a web browser engine that makes it easy to embed content from
+ the World Wide Web into your Qt application on platforms that do not have a native web engine.
+ The web engine is not intended to function as a \e {Web Runtime}; to display web content in a
+ QML application by using APIs native to the platform, use the \l{Qt WebView} module, instead.
+
+ Qt WebEngine provides C++ classes and QML types for rendering HTML, XHTML, and SVG documents,
+ styled using Cascading Style Sheets (CSS) and scripted with JavaScript. HTML documents can be
+ made fully editable by the user through the use of the \c{contenteditable} attribute on HTML
+ elements.
+
+ Qt WebEngine supercedes the \l{Qt WebKit Widgets}{Qt WebKit} module, which is based on the
+ WebKit project, but has not been actively synchronized with the upstream WebKit code since
+ Qt 5.2 and has been deprecated in Qt 5.5. For tips on how to change a Qt WebKit widgets
+ application to use Qt WebEngine widgets, see \l{Porting from Qt WebKit to Qt WebEngine}. For new
+ applications, we recommend using Qt Quick and the WebEngineView QML type.
+
+ \section1 Qt WebEngine Architecture
+
+ \image qtwebengine-architecture.png
+
+ The functionality in Qt WebEngine is divided into the following modules:
+
+ \list
+ \li \l{Qt WebEngine Widgets}, which provides a web browser engine and C++ classes to render
+ web content and to interact with it
+ \li \l{Qt WebEngine}, which provides QML types for rendering web content within a QML
+ application
+ \li \l{Qt WebEngine Core}, which provides common API used by Qt WebEngine and
+ Qt WebEngine Widgets
+ \endlist
+
+ The Qt WebEngine core is based on the \l{http://www.chromium.org}{Chromium Project}. Chromium
+ provides its own network and painting engines and is developed tightly together with its
+ dependent modules, and therefore Qt WebEngine provides better and more reliable support for the
+ latest HTML5 specification than Qt WebKit. However, Qt WebEngine is thus heavier than Qt WebKit
+ and does not provide direct access to the network stack and the HTML document through C++ APIs.
+
+ Chromium is tightly integrated to the \l{Qt Quick Scene Graph}{Qt Quick scene graph}, which is
+ based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides you with one-pass
+ compositing of web content and all the Qt Quick UI. The integration to Chromium is transparent
+ to developers, who just work with Qt and JavaScript.
+
+ To expose QObjects to JavaScript, developers can use the \l {Qt WebChannel} module.
+
+ \section1 Embedding Web Content into Widget Based Applications
+
+ Use the QWebEngineView class to display web pages in the simplest way. Because it is a widget,
+ you can embed QWebEngineView into your forms and use its convenience functions to download and
+ display web sites.
+
+ \code
+ QWebEngineView *view = new QWebEngineView(parent);
+ view->load(QUrl("http://www.qt.io/"));
+ view->show();
+ \endcode
+
+ An instance of QWebEngineView has one QWebEnginePage. QWebEnginePage provides access to the
+ page's navigation history and the ability to run JavaScript code in the context of the page's
+ main frame and enables customization of handlers for specific events like showing custom
+ authentication dialogs.
+
+ \section1 Embedding Web Content into Qt Quick Applications
+
+ The WebEngineView QML type allows QML applications to render regions of dynamic web content. A
+ \e{WebEngineView} type may share the screen with other QML types or encompass the full screen
+ as specified within the QML application.
+
+ An application can load pages into the WebEngineView, using either an URL or HTML string, and
+ navigate within session history. By default, links to different pages load within the same
+ WebEngineView object, but web sites may request them to be opened as a new tab, window, or
+ dialog.
+
+ The following sample QML application loads a web page and responds to session history context:
+
+ \code
+ import QtQuick 2.1
+ import QtQuick.Controls 1.1
+ import QtWebEngine 1.1
+
+ ApplicationWindow {
+ width: 1280
+ height: 720
+ visible: true
+ WebEngineView {
+ id: webview
+ url: "http://www.qt.io"
+ anchors.fill: parent
+ }
+ }
+ \endcode
+
+ \section1 Using WebEngine Core
+
+ Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets.
+
+ \section1 License Information
+
+ Qt WebEngine module is a snapshot of the integration of Chromium into Qt.
+
+ Qt Commercial Edition licensees that wish to distribute applications that
+ use the Qt WebEngine module need to be aware of their obligations under the
+ GNU Library General Public License (LGPLv2).
+
+ Developers using the Open Source Edition can choose to redistribute
+ the module under the GNU LGPLv3 or GPLv2 and up.
+
+ \legalese
+
+ Chromium is licensed under the following license:
+
+ Copyright (c) 2013 The Chromium Authors. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following disclaimer
+ in the documentation and/or other materials provided with the
+ distribution.
+ * Neither the name of Google Inc. nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ \endlegalese
+*/
diff --git a/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
new file mode 100644
index 000000000..6d3d71896
--- /dev/null
+++ b/src/webengine/doc/src/qtwebengine-qmlmodule.qdoc
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*!
+ \qmlmodule QtWebEngine 1.1
+ \title Qt WebEngine QML Types
+ \brief Provides QML types for rendering web content within a QML application
+ \ingroup qtwebengine-qmlmodules
+
+ The QML types can be imported into your application using the following import statements in
+ your .qml file:
+
+ \code
+ import QtQuick 2.0
+ import QtWebEngine 1.1
+ \endcode
+*/
diff --git a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview.qdoc
index 212d9010a..76c742aa0 100644
--- a/src/webengine/doc/src/qquickwebengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview.qdoc
@@ -24,54 +24,6 @@
// by its LGPL license.
/*!
- \page qtwebengine-index.html
- \title Qt WebEngine
-
- The Qt WebEngine module provides the WebEngineView API which allows QML applications
- to render regions of dynamic web content. A \e{WebEngineView} component may share
- the screen with other QML components or encompass the full screen as
- specified within the QML application.
-
- It allows an application to load pages into the WebEngineView, either by URL or with
- an HTML string, and navigate within session history. By default,
- links to different pages load within the same WebEngineView, but web sites may
- request them to be opened as a new tab, window or dialog.
-
- The following sample QML application loads a web page, responds to session
- history context.
-
- \code
- import QtQuick 2.1
- import QtQuick.Controls 1.1
- import QtWebEngine 1.1
-
- ApplicationWindow {
- width: 1280
- height: 720
- visible: true
- WebEngineView {
- id: webview
- url: "http://www.qt-project.org"
- anchors.fill: parent
- }
- }
- \endcode
-
- \section1 API References
-
- \list
- \li \l{Qt WebEngine QML Types}{QML Types}
- \endlist
-
- \section1 Examples
-
- There are several Qt WebEngine examples located in the
- \l{Qt WebEngine Examples} page.
-
-*/
-
-
-/*!
\qmltype WebEngineView
\instantiates QQuickWebEngineView
\inqmlmodule QtWebEngine 1.1
diff --git a/src/webengine/plugin/experimental/experimental.pro b/src/webengine/plugin/experimental/experimental.pro
index 36162e359..d1b59326a 100644
--- a/src/webengine/plugin/experimental/experimental.pro
+++ b/src/webengine/plugin/experimental/experimental.pro
@@ -6,7 +6,7 @@ IMPORT_VERSION = 1.0
QT += webengine qml quick
QT_PRIVATE += webengine-private
-INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/core/api $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api
SOURCES = plugin.cpp
diff --git a/src/webengine/plugin/experimental/plugin.cpp b/src/webengine/plugin/experimental/plugin.cpp
index 29b5413f4..f9525e656 100644
--- a/src/webengine/plugin/experimental/plugin.cpp
+++ b/src/webengine/plugin/experimental/plugin.cpp
@@ -63,12 +63,12 @@ public:
qmlRegisterExtendedType<QQuickWebEngineView, QQuickWebEngineViewExperimentalExtension>(uri, 1, 0, "WebEngineView");
qmlRegisterUncreatableType<QQuickWebEngineViewExperimental>(uri, 1, 0, "WebEngineViewExperimental",
- QObject::tr("Cannot create a separate instance of WebEngineViewExperimental"));
+ tr("Cannot create a separate instance of WebEngineViewExperimental"));
qmlRegisterUncreatableType<QQuickWebEngineViewport>(uri, 1, 0, "WebEngineViewport",
- QObject::tr("Cannot create a separate instance of WebEngineViewport"));
+ tr("Cannot create a separate instance of WebEngineViewport"));
// Use the latest revision of QQuickWebEngineView when importing QtWebEngine.experimental 1.0
- qmlRegisterRevision<QQuickWebEngineView, 1>(uri, 1, 0);
+ qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, 0);
}
};
diff --git a/src/webengine/plugin/plugin.cpp b/src/webengine/plugin/plugin.cpp
index c5ef11a5e..c42eb63d5 100644
--- a/src/webengine/plugin/plugin.cpp
+++ b/src/webengine/plugin/plugin.cpp
@@ -65,24 +65,30 @@ public:
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine"));
qmlRegisterType<QQuickWebEngineView>(uri, 1, 0, "WebEngineView");
- qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", QObject::tr("Cannot create separate instance of WebEngineLoadRequest"));
- qmlRegisterUncreatableType<QQuickWebEngineNavigationRequest>(uri, 1, 0, "WebEngineNavigationRequest", QObject::tr("Cannot create separate instance of WebEngineNavigationRequest"));
+ qmlRegisterUncreatableType<QQuickWebEngineLoadRequest>(uri, 1, 0, "WebEngineLoadRequest", tr("Cannot create separate instance of WebEngineLoadRequest"));
+ qmlRegisterUncreatableType<QQuickWebEngineNavigationRequest>(uri, 1, 0, "WebEngineNavigationRequest", tr("Cannot create separate instance of WebEngineNavigationRequest"));
qmlRegisterType<QQuickWebEngineView, 1>(uri, 1, 1, "WebEngineView");
+ qmlRegisterType<QQuickWebEngineView, 2>(uri, 1, 2, "WebEngineView");
qmlRegisterType<QQuickWebEngineProfile>(uri, 1, 1, "WebEngineProfile");
+ qmlRegisterType<QQuickWebEngineProfile, 1>(uri, 1, 2, "WebEngineProfile");
qmlRegisterType<QQuickWebEngineScript>(uri, 1, 1, "WebEngineScript");
- qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", QObject::tr("Cannot create separate instance of WebEngineCertificateError"));
+ qmlRegisterUncreatableType<QQuickWebEngineCertificateError>(uri, 1, 1, "WebEngineCertificateError", tr("Cannot create separate instance of WebEngineCertificateError"));
qmlRegisterUncreatableType<QQuickWebEngineDownloadItem>(uri, 1, 1, "WebEngineDownloadItem",
- QObject::tr("Cannot create a separate instance of WebEngineDownloadItem"));
- qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", QObject::tr("Cannot create separate instance of WebEngineNewViewRequest"));
- qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", QObject::tr("Cannot create a separate instance of WebEngineSettings"));
+ tr("Cannot create a separate instance of WebEngineDownloadItem"));
+ qmlRegisterUncreatableType<QQuickWebEngineNewViewRequest>(uri, 1, 1, "WebEngineNewViewRequest", tr("Cannot create separate instance of WebEngineNewViewRequest"));
+ qmlRegisterUncreatableType<QQuickWebEngineSettings>(uri, 1, 1, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
+ qmlRegisterUncreatableType<QQuickWebEngineSettings, 1>(uri, 1, 2, "WebEngineSettings", tr("Cannot create a separate instance of WebEngineSettings"));
qmlRegisterSingletonType<QQuickWebEngineSingleton>(uri, 1, 1, "WebEngine", webEngineSingletonProvider);
qmlRegisterUncreatableType<QQuickWebEngineHistory>(uri, 1, 1, "NavigationHistory",
- QObject::tr("Cannot create a separate instance of NavigationHistory"));
+ tr("Cannot create a separate instance of NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineHistoryListModel>(uri, 1, 1, "NavigationHistoryListModel",
- QObject::tr("Cannot create a separate instance of NavigationHistory"));
+ tr("Cannot create a separate instance of NavigationHistory"));
qmlRegisterUncreatableType<QQuickWebEngineFullScreenRequest>(uri, 1, 1, "FullScreenRequest",
- QObject::tr("Cannot create a separate instance of FullScreenRequest"));
+ tr("Cannot create a separate instance of FullScreenRequest"));
+
+ // For now (1.x import), the latest revision matches the minor version of the import.
+ qmlRegisterRevision<QQuickWebEngineView, LATEST_WEBENGINEVIEW_REVISION>(uri, 1, LATEST_WEBENGINEVIEW_REVISION);
}
};
diff --git a/src/webengine/plugin/plugin.pro b/src/webengine/plugin/plugin.pro
index 123c45511..b6acc760f 100644
--- a/src/webengine/plugin/plugin.pro
+++ b/src/webengine/plugin/plugin.pro
@@ -1,12 +1,12 @@
CXX_MODULE = qml
TARGET = qtwebengineplugin
TARGETPATH = QtWebEngine
-IMPORT_VERSION = 1.1
+IMPORT_VERSION = 1.2
QT += webengine qml quick
QT_PRIVATE += webengine-private
-INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api $$QTWEBENGINE_ROOT/include/QtWebEngine
+INCLUDEPATH += $$QTWEBENGINE_ROOT/src/core $$QTWEBENGINE_ROOT/src/core/api $$QTWEBENGINE_ROOT/src/webengine $$QTWEBENGINE_ROOT/src/webengine/api $$QTWEBENGINE_ROOT/include/QtWebEngine
SOURCES = plugin.cpp
diff --git a/src/webengine/plugin/testsupport/plugin.cpp b/src/webengine/plugin/testsupport/plugin.cpp
index 98a1d3ca6..28001db54 100644
--- a/src/webengine/plugin/testsupport/plugin.cpp
+++ b/src/webengine/plugin/testsupport/plugin.cpp
@@ -54,7 +54,7 @@ public:
qmlRegisterType<QQuickWebEngineTestSupport>(uri, 1, 0, "WebEngineTestSupport");
qmlRegisterUncreatableType<QQuickWebEngineErrorPage>(uri, 1, 0, "WebEngineErrorPage",
- QObject::tr("Cannot create a separate instance of WebEngineErrorPage"));
+ tr("Cannot create a separate instance of WebEngineErrorPage"));
}
};
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
index a3999ccab..9fc1ed3eb 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.cpp
@@ -64,10 +64,14 @@ RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderW
void RenderWidgetHostViewQtDelegateQuick::initAsChild(WebContentsAdapterClient* container)
{
- QQuickWebEngineViewPrivate *viewPrivate = static_cast<QQuickWebEngineViewPrivate *>(container);
- setParentItem(viewPrivate->q_func());
- setSize(viewPrivate->q_func()->boundingRect().size());
+ QQuickWebEngineView *view = static_cast<QQuickWebEngineViewPrivate *>(container)->q_func();
+ setParentItem(view);
+ setSize(view->boundingRect().size());
+ // Focus on creation if the view accepts it
+ if (view->activeFocusOnPress())
+ setFocus(true);
m_initialized = true;
+
}
void RenderWidgetHostViewQtDelegateQuick::initAsPopup(const QRect &r)
@@ -176,9 +180,11 @@ void RenderWidgetHostViewQtDelegateQuick::inputMethodStateChanged(bool editorVis
if (qApp->inputMethod()->isVisible() == editorVisible)
return;
- setFlag(QQuickItem::ItemAcceptsInputMethod, editorVisible);
- qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints);
- qApp->inputMethod()->setVisible(editorVisible);
+ if (parentItem() && parentItem()->flags() & QQuickItem::ItemAcceptsInputMethod) {
+ qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints);
+ qApp->inputMethod()->setVisible(editorVisible);
+ }
+
}
void RenderWidgetHostViewQtDelegateQuick::focusInEvent(QFocusEvent *event)
@@ -193,7 +199,7 @@ void RenderWidgetHostViewQtDelegateQuick::focusOutEvent(QFocusEvent *event)
void RenderWidgetHostViewQtDelegateQuick::mousePressEvent(QMouseEvent *event)
{
- if (!m_isPopup)
+ if (!m_isPopup && (parentItem() && parentItem()->property("activeFocusOnPress").toBool()))
forceActiveFocus();
m_client->forwardEvent(event);
}
@@ -225,7 +231,8 @@ void RenderWidgetHostViewQtDelegateQuick::wheelEvent(QWheelEvent *event)
void RenderWidgetHostViewQtDelegateQuick::touchEvent(QTouchEvent *event)
{
- if (event->type() == QEvent::TouchBegin && !m_isPopup)
+ if (event->type() == QEvent::TouchBegin && !m_isPopup
+ && (parentItem() && parentItem()->property("activeFocusOnPress").toBool()))
forceActiveFocus();
m_client->forwardEvent(event);
}
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quick.h b/src/webengine/render_widget_host_view_qt_delegate_quick.h
index ddd0e4d9e..eb2860b27 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quick.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quick.h
@@ -70,6 +70,8 @@ public:
virtual void move(const QPoint&) Q_DECL_OVERRIDE { }
virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE;
virtual void setTooltip(const QString&) Q_DECL_OVERRIDE { }
+ // The QtQuick view doesn't have a backbuffer of its own and doesn't need this
+ virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { }
protected:
virtual void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
index cda51a1ab..a4b08482f 100644
--- a/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
+++ b/src/webengine/render_widget_host_view_qt_delegate_quickwindow.h
@@ -73,6 +73,7 @@ public:
virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE;
virtual void inputMethodStateChanged(bool) Q_DECL_OVERRIDE {}
virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
+ virtual void setClearColor(const QColor &) Q_DECL_OVERRIDE { }
private:
QScopedPointer<RenderWidgetHostViewQtDelegate> m_realDelegate;
diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp
index d22e6546f..95010d8cb 100644
--- a/src/webengine/ui_delegates_manager.cpp
+++ b/src/webengine/ui_delegates_manager.cpp
@@ -37,12 +37,14 @@
#include "ui_delegates_manager.h"
#include "api/qquickwebengineview_p.h"
+#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#include <QAbstractListModel>
#include <QClipboard>
#include <QFileInfo>
#include <QGuiApplication>
+#include <QMimeData>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQmlProperty>
@@ -107,32 +109,6 @@ MenuItemHandler::MenuItemHandler(QObject *parent)
{
}
-
-CopyMenuItem::CopyMenuItem(QObject *parent, const QString &textToCopy)
- : MenuItemHandler(parent)
- , m_textToCopy(textToCopy)
-{
- connect(this, &MenuItemHandler::triggered, this, &CopyMenuItem::onTriggered);
-}
-
-void CopyMenuItem::onTriggered()
-{
- qApp->clipboard()->setText(m_textToCopy);
-}
-
-NavigateMenuItem::NavigateMenuItem(QObject *parent, const QExplicitlySharedDataPointer<WebContentsAdapter> &adapter, const QUrl &targetUrl)
- : MenuItemHandler(parent)
- , m_adapter(adapter)
- , m_targetUrl(targetUrl)
-{
- connect(this, &MenuItemHandler::triggered, this, &NavigateMenuItem::onTriggered);
-}
-
-void NavigateMenuItem::onTriggered()
-{
- m_adapter->load(m_targetUrl);
-}
-
#define COMPONENT_MEMBER_INIT(TYPE, COMPONENT) \
, COMPONENT##Component(0)
@@ -272,15 +248,15 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
switch (dialogController->type()) {
case WebContentsAdapterClient::AlertDialog:
dialogComponentType = AlertDialog;
- title = QObject::tr("Javascript Alert - %1").arg(m_view->url().toString());
+ title = QCoreApplication::translate("UIDelegatesManager", "Javascript Alert - %1").arg(m_view->url().toString());
break;
case WebContentsAdapterClient::ConfirmDialog:
dialogComponentType = ConfirmDialog;
- title = QObject::tr("Javascript Confirm - %1").arg(m_view->url().toString());
+ title = QCoreApplication::translate("UIDelegatesManager", "Javascript Confirm - %1").arg(m_view->url().toString());
break;
case WebContentsAdapterClient::PromptDialog:
dialogComponentType = PromptDialog;
- title = QObject::tr("Javascript Prompt - %1").arg(m_view->url().toString());
+ title = QCoreApplication::translate("UIDelegatesManager", "Javascript Prompt - %1").arg(m_view->url().toString());
break;
case WebContentsAdapterClient::InternalAuthorizationDialog:
dialogComponentType = ConfirmDialog;
@@ -341,50 +317,8 @@ void UIDelegatesManager::showDialog(QSharedPointer<JavaScriptDialogController> d
QMetaObject::invokeMethod(dialog, "open");
}
-namespace {
-class FilePickerController : public QObject {
- Q_OBJECT
-public:
- FilePickerController(WebContentsAdapterClient::FileChooserMode, const QExplicitlySharedDataPointer<WebContentsAdapter> &, QObject * = 0);
-
-public Q_SLOTS:
- void accepted(const QVariant &files);
- void rejected();
-
-private:
- QExplicitlySharedDataPointer<WebContentsAdapter> m_adapter;
- WebContentsAdapterClient::FileChooserMode m_mode;
-
-};
-
-
-FilePickerController::FilePickerController(WebContentsAdapterClient::FileChooserMode mode, const QExplicitlySharedDataPointer<WebContentsAdapter> &adapter, QObject *parent)
- : QObject(parent)
- , m_adapter(adapter)
- , m_mode(mode)
-{
-}
-
-void FilePickerController::accepted(const QVariant &files)
-{
- QStringList stringList;
- Q_FOREACH (const QUrl &url, files.value<QList<QUrl> >())
- stringList.append(url.toLocalFile());
- m_adapter->filesSelectedInChooser(stringList, m_mode);
-}
-
-void FilePickerController::rejected()
-{
- m_adapter->filesSelectedInChooser(QStringList(), m_mode);
-}
-
-} // namespace
-
-
-void UIDelegatesManager::showFilePicker(WebContentsAdapterClient::FileChooserMode mode, const QString &defaultFileName, const QStringList &acceptedMimeTypes, const QExplicitlySharedDataPointer<WebContentsAdapter> &adapter)
+void UIDelegatesManager::showFilePicker(FilePickerController *controller)
{
- Q_UNUSED(defaultFileName);
- Q_UNUSED(acceptedMimeTypes);
if (!ensureComponentLoaded(FilePicker))
return;
@@ -397,23 +331,24 @@ void UIDelegatesManager::showFilePicker(WebContentsAdapterClient::FileChooserMod
filePickerComponent->completeCreate();
// Fine-tune some properties depending on the mode.
- switch (mode) {
- case WebContentsAdapterClient::Open:
+ switch (controller->mode()) {
+ case FilePickerController::Open:
break;
- case WebContentsAdapterClient::Save:
+ case FilePickerController::Save:
filePicker->setProperty("selectExisting", false);
break;
- case WebContentsAdapterClient::OpenMultiple:
+ case FilePickerController::OpenMultiple:
filePicker->setProperty("selectMultiple", true);
break;
- case WebContentsAdapterClient::UploadFolder:
+ case FilePickerController::UploadFolder:
filePicker->setProperty("selectFolder", true);
break;
default:
Q_UNREACHABLE();
}
- FilePickerController *controller = new FilePickerController(mode, adapter, filePicker);
+ controller->setParent(filePicker);
+
QQmlProperty filesPickedSignal(filePicker, QStringLiteral("onFilesSelected"));
CHECK_QML_SIGNAL_PROPERTY(filesPickedSignal, filePickerComponent->url());
QQmlProperty rejectSignal(filePicker, QStringLiteral("onRejected"));
@@ -464,5 +399,3 @@ void UIDelegatesManager::moveMessageBubble(const QRect &anchor)
}
} // namespace QtWebEngineCore
-
-#include "ui_delegates_manager.moc"
diff --git a/src/webengine/ui_delegates_manager.h b/src/webengine/ui_delegates_manager.h
index f2b78f792..37cbb85df 100644
--- a/src/webengine/ui_delegates_manager.h
+++ b/src/webengine/ui_delegates_manager.h
@@ -73,6 +73,7 @@ QT_END_NAMESPACE
namespace QtWebEngineCore {
class JavaScriptDialogController;
+class FilePickerController;
const char *defaultPropertyName(QObject *obj);
@@ -85,29 +86,6 @@ Q_SIGNALS:
void triggered();
};
-class CopyMenuItem : public MenuItemHandler {
- Q_OBJECT
-public:
- CopyMenuItem(QObject *parent, const QString &textToCopy);
-
-private:
- void onTriggered();
-
- QString m_textToCopy;
-};
-
-class NavigateMenuItem : public MenuItemHandler {
- Q_OBJECT
-public:
- NavigateMenuItem(QObject *parent, const QExplicitlySharedDataPointer<WebContentsAdapter> &adapter, const QUrl &targetUrl);
-
-private:
- void onTriggered();
-
- QExplicitlySharedDataPointer<WebContentsAdapter> m_adapter;
- QUrl m_targetUrl;
-};
-
class UIDelegatesManager {
public:
@@ -124,8 +102,7 @@ public:
QObject *addMenu(QObject *parentMenu, const QString &title, const QPoint &pos = QPoint());
QQmlContext *creationContextForComponent(QQmlComponent *);
void showDialog(QSharedPointer<JavaScriptDialogController>);
- void showFilePicker(WebContentsAdapterClient::FileChooserMode, const QString &defaultFileName, const QStringList &acceptedMimeTypes
- , const QExplicitlySharedDataPointer<WebContentsAdapter> &);
+ void showFilePicker(FilePickerController *controller);
void showMessageBubble(const QRect &anchor, const QString &mainText, const QString &subText);
void hideMessageBubble();
void moveMessageBubble(const QRect &anchor);
diff --git a/src/webengine/webengine.pro b/src/webengine/webengine.pro
index 6cba9c5d9..8bb5a8e77 100644
--- a/src/webengine/webengine.pro
+++ b/src/webengine/webengine.pro
@@ -3,12 +3,12 @@ TARGET = QtWebEngine
# For our export macros
DEFINES += QT_BUILD_WEBENGINE_LIB
-QT += qml quick
-QT_PRIVATE += webenginecore quick-private gui-private core-private
+QT += qml quick webenginecore
+QT_PRIVATE += quick-private gui-private core-private
QMAKE_DOCS = $$PWD/doc/qtwebengine.qdocconf
-INCLUDEPATH += $$PWD api ../core
+INCLUDEPATH += $$PWD api ../core ../core/api
SOURCES = \
api/qquickwebenginecertificateerror.cpp \
diff --git a/src/webenginewidgets/api/qwebenginecertificateerror.h b/src/webenginewidgets/api/qwebenginecertificateerror.h
index 90b23208c..7706ea32d 100644
--- a/src/webenginewidgets/api/qwebenginecertificateerror.h
+++ b/src/webenginewidgets/api/qwebenginecertificateerror.h
@@ -37,10 +37,10 @@
#ifndef QWEBENGINECERTIFICATEERROR_H
#define QWEBENGINECERTIFICATEERROR_H
-#include "qtwebenginewidgetsglobal.h"
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QtCore/QScopedPointer>
-#include <QtCore/QUrl>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qurl.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index d362131f2..1428ad4c3 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -37,9 +37,9 @@
#ifndef QWEBENGINEDOWNLOADITEM_H
#define QWEBENGINEDOWNLOADITEM_H
-#include "qtwebenginewidgetsglobal.h"
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QObject>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 6207a2b30..bd3b2772a 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -23,8 +23,10 @@
#include "qwebenginepage.h"
#include "qwebenginepage_p.h"
+#include "authentication_dialog_controller.h"
#include "browser_context_adapter.h"
#include "certificate_error_controller.h"
+#include "file_picker_controller.h"
#include "javascript_dialog_controller.h"
#include "qwebenginehistory.h"
#include "qwebenginehistory_p.h"
@@ -54,6 +56,7 @@
#include <QLayout>
#include <QMenu>
#include <QMessageBox>
+#include <QMimeData>
#include <QStandardPaths>
#include <QStyle>
#include <QUrl>
@@ -77,106 +80,6 @@ static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::Wind
}
}
-CallbackDirectory::~CallbackDirectory()
-{
- // "Cancel" pending callbacks by calling them with an invalid value.
- // This guarantees that each callback is called exactly once.
- Q_FOREACH (const CallbackSharedDataPointer &sharedPtr, m_callbackMap) {
- switch (sharedPtr.type) {
- case CallbackSharedDataPointer::Variant:
- (*sharedPtr.variantCallback)(QVariant());
- break;
- case CallbackSharedDataPointer::String:
- (*sharedPtr.stringCallback)(QString());
- break;
- case CallbackSharedDataPointer::Bool:
- (*sharedPtr.boolCallback)(false);
- break;
- default:
- Q_UNREACHABLE();
- }
- }
-}
-
-void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<VariantCallback> &callback)
-{
- m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data()));
-}
-
-void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<StringCallback> &callback)
-{
- m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data()));
-}
-
-void CallbackDirectory::registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<BoolCallback> &callback)
-{
- m_callbackMap.insert(requestId, CallbackSharedDataPointer(callback.data()));
-}
-
-void CallbackDirectory::invoke(quint64 requestId, const QVariant &result)
-{
- CallbackSharedDataPointer sharedPtr = m_callbackMap.take(requestId);
- if (sharedPtr) {
- Q_ASSERT(sharedPtr.type == CallbackSharedDataPointer::Variant);
- (*sharedPtr.variantCallback)(result);
- }
-}
-
-void CallbackDirectory::invoke(quint64 requestId, const QString &result)
-{
- CallbackSharedDataPointer sharedPtr = m_callbackMap.take(requestId);
- if (sharedPtr) {
- Q_ASSERT(sharedPtr.type == CallbackSharedDataPointer::String);
- (*sharedPtr.stringCallback)(result);
- }
-}
-
-void CallbackDirectory::invoke(quint64 requestId, bool result)
-{
- CallbackSharedDataPointer sharedPtr = m_callbackMap.take(requestId);
- if (sharedPtr) {
- Q_ASSERT(sharedPtr.type == CallbackSharedDataPointer::Bool);
- (*sharedPtr.boolCallback)(result);
- }
-}
-
-void CallbackDirectory::CallbackSharedDataPointer::doRef()
-{
- switch (type) {
- case None:
- break;
- case Variant:
- variantCallback->ref.ref();
- break;
- case String:
- stringCallback->ref.ref();
- break;
- case Bool:
- boolCallback->ref.ref();
- break;
- }
-}
-
-void CallbackDirectory::CallbackSharedDataPointer::doDeref()
-{
- switch (type) {
- case None:
- break;
- case Variant:
- if (!variantCallback->ref.deref())
- delete variantCallback;
- break;
- case String:
- if (!stringCallback->ref.deref())
- delete stringCallback;
- break;
- case Bool:
- if (!boolCallback->ref.deref())
- delete boolCallback;
- break;
- }
-}
-
QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
: adapter(new WebContentsAdapter)
, history(new QWebEngineHistory(new QWebEngineHistoryPrivate(this)))
@@ -185,6 +88,8 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, view(0)
, isLoading(false)
, scriptCollection(new QWebEngineScriptCollectionPrivate(browserContextAdapter()->userScriptController(), adapter.data()))
+ , m_backgroundColor(Qt::white)
+ , m_fullscreenRequested(false)
{
memset(actions, 0, sizeof(actions));
}
@@ -247,6 +152,11 @@ qreal QWebEnginePagePrivate::dpiScale() const
return 1.0;
}
+QColor QWebEnginePagePrivate::backgroundColor() const
+{
+ return m_backgroundColor;
+}
+
void QWebEnginePagePrivate::loadStarted(const QUrl &provisionalUrl, bool isErrorPage)
{
Q_UNUSED(provisionalUrl);
@@ -340,18 +250,24 @@ void QWebEnginePagePrivate::passOnFocus(bool reverse)
view->focusNextPrevChild(!reverse);
}
-void QWebEnginePagePrivate::authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword)
+void QWebEnginePagePrivate::authenticationRequired(QSharedPointer<AuthenticationDialogController> controller)
{
Q_Q(QWebEnginePage);
QAuthenticator networkAuth;
- networkAuth.setRealm(realm);
+ networkAuth.setRealm(controller->realm());
- if (isProxy)
- Q_EMIT q->proxyAuthenticationRequired(requestUrl, &networkAuth, challengingHost);
+ if (controller->isProxy())
+ Q_EMIT q->proxyAuthenticationRequired(controller->url(), &networkAuth, controller->host());
else
- Q_EMIT q->authenticationRequired(requestUrl, &networkAuth);
- *outUser = networkAuth.user();
- *outPassword = networkAuth.password();
+ Q_EMIT q->authenticationRequired(controller->url(), &networkAuth);
+
+ // Authentication has been cancelled
+ if (networkAuth.isNull()) {
+ controller->reject();
+ return;
+ }
+
+ controller->accept(networkAuth.user(), networkAuth.password());
}
void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &securityOrigin, WebContentsAdapterClient::MediaRequestFlags requestFlags)
@@ -531,6 +447,33 @@ void QWebEnginePage::setWebChannel(QWebChannel *channel)
d->adapter->setWebChannel(channel);
}
+/*!
+ \property QWebEnginePage::backgroundColor
+ \brief the page's background color, behing the document's body.
+ \since 5.6
+
+ You can set it to Qt::transparent or to a translucent
+ color to see through the document, or you can set this color to match your
+ web content in an hybrid app to prevent the white flashes that may appear
+ during loading.
+
+ The default value is white.
+*/
+QColor QWebEnginePage::backgroundColor() const
+{
+ Q_D(const QWebEnginePage);
+ return d->m_backgroundColor;
+}
+
+void QWebEnginePage::setBackgroundColor(const QColor &color)
+{
+ Q_D(QWebEnginePage);
+ if (d->m_backgroundColor == color)
+ return;
+ d->m_backgroundColor = color;
+ d->adapter->backgroundColorChanged();
+}
+
void QWebEnginePage::setView(QWidget *view)
{
QWebEngineViewPrivate::bind(qobject_cast<QWebEngineView*>(view), this);
@@ -614,6 +557,54 @@ QAction *QWebEnginePage::action(WebAction action) const
case PasteAndMatchStyle:
text = tr("Paste and Match Style");
break;
+ case OpenLinkInThisWindow:
+ text = tr("Open Link in This Window");
+ break;
+ case OpenLinkInNewWindow:
+ text = tr("Open Link in New Window");
+ break;
+ case OpenLinkInNewTab:
+ text = tr("Open Link in New Tab");
+ break;
+ case CopyLinkToClipboard:
+ text = tr("Copy Link URL");
+ break;
+ case DownloadLinkToDisk:
+ text = tr("Save Link...");
+ break;
+ case CopyImageToClipboard:
+ text = tr("Copy Image");
+ break;
+ case CopyImageUrlToClipboard:
+ text = tr("Copy Image URL");
+ break;
+ case DownloadImageToDisk:
+ text = tr("Save Image");
+ break;
+ case CopyMediaUrlToClipboard:
+ text = tr("Copy Media URL");
+ break;
+ case ToggleMediaControls:
+ text = tr("Toggle Media Controls");
+ break;
+ case ToggleMediaLoop:
+ text = tr("Toggle Looping");
+ break;
+ case ToggleMediaPlayPause:
+ text = tr("Toggle Play/Pause");
+ break;
+ case ToggleMediaMute:
+ text = tr("Toggle Mute");
+ break;
+ case DownloadMediaToDisk:
+ text = tr("Download Media");
+ break;
+ case InspectElement:
+ text = tr("Inspect Element");
+ break;
+ case ExitFullScreen:
+ text = tr("Exit Full Screen Mode");
+ break;
default:
break;
}
@@ -671,6 +662,119 @@ void QWebEnginePage::triggerAction(WebAction action, bool)
case PasteAndMatchStyle:
d->adapter->pasteAndMatchStyle();
break;
+ case OpenLinkInThisWindow:
+ if (d->m_menuData.linkUrl.isValid())
+ setUrl(d->m_menuData.linkUrl);
+ break;
+ case OpenLinkInNewWindow:
+ if (d->m_menuData.linkUrl.isValid()) {
+ QWebEnginePage *newPage = createWindow(WebBrowserWindow);
+ if (newPage)
+ newPage->setUrl(d->m_menuData.linkUrl);
+ }
+ break;
+ case OpenLinkInNewTab:
+ if (d->m_menuData.linkUrl.isValid()) {
+ QWebEnginePage *newPage = createWindow(WebBrowserTab);
+ if (newPage)
+ newPage->setUrl(d->m_menuData.linkUrl);
+ }
+ break;
+ case CopyLinkToClipboard:
+ if (d->m_menuData.linkUrl.isValid()) {
+ QString urlString = d->m_menuData.linkUrl.toString(QUrl::FullyEncoded);
+ QString title = d->m_menuData.linkText.toHtmlEscaped();
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ QString html = QStringLiteral("<a href=\"") + urlString + QStringLiteral("\">") + title + QStringLiteral("</a>");
+ data->setHtml(html);
+ data->setUrls(QList<QUrl>() << d->m_menuData.linkUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case DownloadLinkToDisk:
+ if (d->m_menuData.linkUrl.isValid())
+ d->adapter->download(d->m_menuData.linkUrl, d->m_menuData.suggestedFileName);
+ break;
+ case CopyImageToClipboard:
+ if (d->m_menuData.hasImageContent &&
+ (d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeImage ||
+ d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeCanvas))
+ {
+ d->adapter->copyImageAt(d->m_menuData.pos);
+ }
+ break;
+ case CopyImageUrlToClipboard:
+ if (d->m_menuData.mediaUrl.isValid() && d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeImage) {
+ QString urlString = d->m_menuData.mediaUrl.toString(QUrl::FullyEncoded);
+ QString title = d->m_menuData.linkText;
+ if (!title.isEmpty())
+ title = QStringLiteral(" alt=\"%1\"").arg(title.toHtmlEscaped());
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ QString html = QStringLiteral("<img src=\"") + urlString + QStringLiteral("\"") + title + QStringLiteral("></img>");
+ data->setHtml(html);
+ data->setUrls(QList<QUrl>() << d->m_menuData.mediaUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case DownloadImageToDisk:
+ case DownloadMediaToDisk:
+ if (d->m_menuData.mediaUrl.isValid())
+ d->adapter->download(d->m_menuData.mediaUrl, d->m_menuData.suggestedFileName);
+ break;
+ case CopyMediaUrlToClipboard:
+ if (d->m_menuData.mediaUrl.isValid() &&
+ (d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ QString urlString = d->m_menuData.mediaUrl.toString(QUrl::FullyEncoded);
+ QMimeData *data = new QMimeData();
+ data->setText(urlString);
+ if (d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeAudio)
+ data->setHtml(QStringLiteral("<audio src=\"") + urlString + QStringLiteral("\"></audio>"));
+ else
+ data->setHtml(QStringLiteral("<video src=\"") + urlString + QStringLiteral("\"></video>"));
+ data->setUrls(QList<QUrl>() << d->m_menuData.mediaUrl);
+ qApp->clipboard()->setMimeData(data);
+ }
+ break;
+ case ToggleMediaControls:
+ if (d->m_menuData.mediaUrl.isValid() && d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaCanToggleControls) {
+ bool enable = !(d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaControls);
+ d->adapter->executeMediaPlayerActionAt(d->m_menuData.pos, WebContentsAdapter::MediaPlayerControls, enable);
+ }
+ break;
+ case ToggleMediaLoop:
+ if (d->m_menuData.mediaUrl.isValid() &&
+ (d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ bool enable = !(d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaLoop);
+ d->adapter->executeMediaPlayerActionAt(d->m_menuData.pos, WebContentsAdapter::MediaPlayerLoop, enable);
+ }
+ break;
+ case ToggleMediaPlayPause:
+ if (d->m_menuData.mediaUrl.isValid() &&
+ (d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeAudio ||
+ d->m_menuData.mediaType == WebEngineContextMenuData::MediaTypeVideo))
+ {
+ bool enable = (d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaPaused);
+ d->adapter->executeMediaPlayerActionAt(d->m_menuData.pos, WebContentsAdapter::MediaPlayerPlay, enable);
+ }
+ break;
+ case ToggleMediaMute:
+ if (d->m_menuData.mediaUrl.isValid() && d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaHasAudio) {
+ bool enable = (d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaMuted);
+ d->adapter->executeMediaPlayerActionAt(d->m_menuData.pos, WebContentsAdapter::MediaPlayerMute, enable);
+ }
+ break;
+ case InspectElement:
+ d->adapter->inspectElementAt(d->m_menuData.pos);
+ break;
+ case ExitFullScreen:
+ d->adapter->exitFullScreen();
+ break;
default:
Q_UNREACHABLE();
}
@@ -681,12 +785,10 @@ void QWebEnginePage::findText(const QString &subString, FindFlags options, const
Q_D(QWebEnginePage);
if (subString.isEmpty()) {
d->adapter->stopFinding();
- if (resultCallback.d)
- (*resultCallback.d)(false);
+ d->m_callbacks.invokeEmpty(resultCallback);
} else {
quint64 requestId = d->adapter->findText(subString, options & FindCaseSensitively, options & FindBackward);
- if (resultCallback.d)
- d->m_callbacks.registerCallback(requestId, resultCallback.d);
+ d->m_callbacks.registerCallback(requestId, resultCallback);
}
}
@@ -703,6 +805,7 @@ bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData
if (!view)
return false;
+ m_menuData = WebEngineContextMenuData();
QContextMenuEvent event(QContextMenuEvent::Mouse, data.pos, view->mapToGlobal(data.pos));
switch (view->contextMenuPolicy()) {
case Qt::PreventContextMenu:
@@ -727,7 +830,6 @@ bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData
}
Q_ASSERT(view->d_func()->m_pendingContextMenuEvent);
view->d_func()->m_pendingContextMenuEvent = false;
- m_menuData = WebEngineContextMenuData();
return true;
}
@@ -738,6 +840,18 @@ void QWebEnginePagePrivate::navigationRequested(int navigationType, const QUrl &
navigationRequestAction = accepted ? WebContentsAdapterClient::AcceptRequest : WebContentsAdapterClient::IgnoreRequest;
}
+void QWebEnginePagePrivate::requestFullScreen(bool fullScreen)
+{
+ Q_Q(QWebEnginePage);
+ m_fullscreenRequested = fullScreen;
+ Q_EMIT q->fullScreenRequested(fullScreen);
+}
+
+bool QWebEnginePagePrivate::isFullScreen() const
+{
+ return m_fullscreenRequested && q_ptr->isFullScreen();
+}
+
void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller)
{
Q_Q(QWebEnginePage);
@@ -807,42 +921,18 @@ void QWebEnginePagePrivate::moveValidationMessage(const QRect &anchor)
#endif
}
-namespace {
-class SaveToClipboardFunctor
-{
- QString m_text;
-public:
- SaveToClipboardFunctor(const QString &text)
- : m_text(text)
- {}
- void operator()() const
- {
- qApp->clipboard()->setText(m_text);
- }
-};
-
-class LoadUrlFunctor
-{
- QWebEnginePage *m_page;
- QUrl m_url;
-public:
- LoadUrlFunctor(QWebEnginePage *page, const QUrl &url)
- : m_page(page)
- , m_url(url)
- {}
- void operator()() const
- {
- m_page->load(m_url);
- }
-};
-}
-
QMenu *QWebEnginePage::createStandardContextMenu()
{
Q_D(QWebEnginePage);
QMenu *menu = new QMenu(d->view);
QAction *action = 0;
WebEngineContextMenuData contextMenuData(d->m_menuData);
+ if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) {
+ action = QWebEnginePage::action(OpenLinkInThisWindow);
+ action->setText(tr("Follow Link"));
+ menu->addAction(action);
+ menu->addAction(QWebEnginePage::action(DownloadLinkToDisk));
+ }
if (contextMenuData.selectedText.isEmpty()) {
action = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), tr("&Back"), menu);
connect(action, &QAction::triggered, d->view, &QWebEngineView::back);
@@ -858,20 +948,46 @@ QMenu *QWebEnginePage::createStandardContextMenu()
connect(action, &QAction::triggered, d->view, &QWebEngineView::reload);
menu->addAction(action);
} else {
- action = new QAction(tr("Copy..."), menu);
- connect(action, &QAction::triggered, SaveToClipboardFunctor(contextMenuData.selectedText));
- menu->addAction(action);
+ menu->addAction(QWebEnginePage::action(Copy));
}
if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) {
- menu->addSeparator();
- action = new QAction(tr("Navigate to..."), menu);
- connect(action, &QAction::triggered, LoadUrlFunctor(this, contextMenuData.linkUrl));
- menu->addAction(action);
- action = new QAction(tr("Copy link address"), menu);
- connect(action, &QAction::triggered, SaveToClipboardFunctor(contextMenuData.linkUrl.toString()));
- menu->addAction(action);
+ menu->addAction(QWebEnginePage::action(CopyLinkToClipboard));
}
+ if (contextMenuData.mediaUrl.isValid()) {
+ switch (contextMenuData.mediaType) {
+ case WebEngineContextMenuData::MediaTypeImage:
+ menu->addAction(QWebEnginePage::action(DownloadImageToDisk));
+ menu->addAction(QWebEnginePage::action(CopyImageUrlToClipboard));
+ menu->addAction(QWebEnginePage::action(CopyImageToClipboard));
+ break;
+ case WebEngineContextMenuData::MediaTypeCanvas:
+ Q_UNREACHABLE(); // mediaUrl is invalid for canvases
+ break;
+ case WebEngineContextMenuData::MediaTypeAudio:
+ case WebEngineContextMenuData::MediaTypeVideo:
+ menu->addAction(QWebEnginePage::action(DownloadMediaToDisk));
+ menu->addAction(QWebEnginePage::action(CopyMediaUrlToClipboard));
+ menu->addAction(QWebEnginePage::action(ToggleMediaPlayPause));
+ menu->addAction(QWebEnginePage::action(ToggleMediaLoop));
+ if (d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaHasAudio)
+ menu->addAction(QWebEnginePage::action(ToggleMediaMute));
+ if (d->m_menuData.mediaFlags & WebEngineContextMenuData::MediaCanToggleControls)
+ menu->addAction(QWebEnginePage::action(ToggleMediaControls));
+ break;
+ default:
+ break;
+ }
+ } else if (contextMenuData.mediaType == WebEngineContextMenuData::MediaTypeCanvas) {
+ menu->addAction(QWebEnginePage::action(CopyImageToClipboard));
+ }
+
+ if (d->adapter->hasInspector())
+ menu->addAction(QWebEnginePage::action(InspectElement));
+
+ if (d->isFullScreen())
+ menu->addAction(QWebEnginePage::action(ExitFullScreen));
+
return menu;
}
@@ -914,17 +1030,22 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
}
}
-static inline QWebEnginePage::FileSelectionMode toPublic(WebContentsAdapterClient::FileChooserMode mode)
+static inline QWebEnginePage::FileSelectionMode toPublic(FilePickerController::FileChooserMode mode)
{
// Should the underlying values change, we'll need a switch here.
return static_cast<QWebEnginePage::FileSelectionMode>(mode);
}
-void QWebEnginePagePrivate::runFileChooser(WebContentsAdapterClient::FileChooserMode mode, const QString &defaultFileName, const QStringList &acceptedMimeTypes)
+void QWebEnginePagePrivate::runFileChooser(FilePickerController *controller)
{
Q_Q(QWebEnginePage);
- QStringList selectedFileNames = q->chooseFiles(toPublic(mode), (QStringList() << defaultFileName), acceptedMimeTypes);
- adapter->filesSelectedInChooser(selectedFileNames, mode);
+
+ QStringList selectedFileNames = q->chooseFiles(toPublic(controller->mode()), (QStringList() << controller->defaultFileName()), controller->acceptedMimeTypes());
+
+ if (!selectedFileNames.empty())
+ controller->accepted(selectedFileNames);
+ else
+ controller->rejected();
}
WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
@@ -942,14 +1063,14 @@ void QWebEnginePage::toHtml(const QWebEngineCallback<const QString &> &resultCal
{
Q_D(const QWebEnginePage);
quint64 requestId = d->adapter->fetchDocumentMarkup();
- d->m_callbacks.registerCallback(requestId, resultCallback.d);
+ d->m_callbacks.registerCallback(requestId, resultCallback);
}
void QWebEnginePage::toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
{
Q_D(const QWebEnginePage);
quint64 requestId = d->adapter->fetchDocumentInnerText();
- d->m_callbacks.registerCallback(requestId, resultCallback.d);
+ d->m_callbacks.registerCallback(requestId, resultCallback);
}
void QWebEnginePage::setHtml(const QString &html, const QUrl &baseUrl)
@@ -1016,7 +1137,7 @@ void QWebEnginePage::runJavaScript(const QString& scriptSource, const QWebEngine
{
Q_D(QWebEnginePage);
quint64 requestId = d->adapter->runJavaScriptCallbackResult(scriptSource);
- d->m_callbacks.registerCallback(requestId, resultCallback.d);
+ d->m_callbacks.registerCallback(requestId, resultCallback);
}
/*!
@@ -1041,8 +1162,8 @@ QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type)
return 0;
}
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Open, QWebEnginePage::FileSelectOpen)
-ASSERT_ENUMS_MATCH(WebContentsAdapterClient::OpenMultiple, QWebEnginePage::FileSelectOpenMultiple)
+ASSERT_ENUMS_MATCH(FilePickerController::Open, QWebEnginePage::FileSelectOpen)
+ASSERT_ENUMS_MATCH(FilePickerController::OpenMultiple, QWebEnginePage::FileSelectOpenMultiple)
QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
{
@@ -1051,23 +1172,23 @@ QStringList QWebEnginePage::chooseFiles(FileSelectionMode mode, const QStringLis
Q_UNUSED(acceptedMimeTypes);
QStringList ret;
QString str;
- switch (static_cast<WebContentsAdapterClient::FileChooserMode>(mode)) {
- case WebContentsAdapterClient::OpenMultiple:
+ switch (static_cast<FilePickerController::FileChooserMode>(mode)) {
+ case FilePickerController::OpenMultiple:
ret = QFileDialog::getOpenFileNames(view(), QString());
break;
// Chromium extension, not exposed as part of the public API for now.
- case WebContentsAdapterClient::UploadFolder:
+ case FilePickerController::UploadFolder:
str = QFileDialog::getExistingDirectory(view(), tr("Select folder to upload")) + QLatin1Char('/');
if (!str.isNull())
ret << str;
break;
- case WebContentsAdapterClient::Save:
+ case FilePickerController::Save:
str = QFileDialog::getSaveFileName(view(), QString(), (QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + oldFiles.first()));
if (!str.isNull())
ret << str;
break;
default:
- case WebContentsAdapterClient::Open:
+ case FilePickerController::Open:
str = QFileDialog::getOpenFileName(view(), QString(), oldFiles.first());
if (!str.isNull())
ret << str;
@@ -1118,6 +1239,12 @@ bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, NavigationType typ
return true;
}
+bool QWebEnginePage::isFullScreen()
+{
+ Q_D(const QWebEnginePage);
+ return d->view ? d->view->isFullScreen() : false;
+}
+
QT_END_NAMESPACE
#include "moc_qwebenginepage.cpp"
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index b4cf52298..d027998ee 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -39,6 +39,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginecertificateerror.h>
+#include <QtWebEngineCore/qwebenginecallback.h>
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
@@ -56,37 +57,6 @@ class QWebEngineProfile;
class QWebEngineScriptCollection;
class QWebEngineSettings;
-namespace QtWebEnginePrivate {
-
-template <typename T>
-class QWebEngineCallbackPrivateBase : public QSharedData {
-public:
- virtual ~QWebEngineCallbackPrivateBase() {}
- virtual void operator()(T) = 0;
-};
-
-template <typename T, typename F>
-class QWebEngineCallbackPrivate : public QWebEngineCallbackPrivateBase<T> {
-public:
- QWebEngineCallbackPrivate(F callable) : m_callable(callable) {}
- virtual void operator()(T value) Q_DECL_OVERRIDE { m_callable(value); }
-private:
- F m_callable;
-};
-
-} // namespace QtWebEnginePrivate
-
-template <typename T>
-class QWebEngineCallback {
-public:
- template <typename F>
- QWebEngineCallback(F f) : d(new QtWebEnginePrivate::QWebEngineCallbackPrivate<T, F>(f)) { }
- QWebEngineCallback() { }
-private:
- QExplicitlySharedDataPointer<QtWebEnginePrivate::QWebEngineCallbackPrivateBase<T> > d;
- friend class QWebEnginePage;
-};
-
class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_OBJECT
Q_PROPERTY(QString selectedText READ selectedText)
@@ -98,6 +68,7 @@ class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_PROPERTY(QString title READ title)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
Q_PROPERTY(QUrl iconUrl READ iconUrl)
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
public:
enum WebAction {
@@ -118,6 +89,26 @@ public:
PasteAndMatchStyle,
+ OpenLinkInThisWindow,
+ OpenLinkInNewWindow,
+ OpenLinkInNewTab,
+ CopyLinkToClipboard,
+ DownloadLinkToDisk,
+
+ CopyImageToClipboard,
+ CopyImageUrlToClipboard,
+ DownloadImageToDisk,
+
+ CopyMediaUrlToClipboard,
+ ToggleMediaControls,
+ ToggleMediaLoop,
+ ToggleMediaPlayPause,
+ ToggleMediaMute,
+ DownloadMediaToDisk,
+
+ InspectElement,
+ ExitFullScreen,
+
WebActionCount
};
@@ -236,6 +227,8 @@ public:
QWebChannel *webChannel() const;
void setWebChannel(QWebChannel *);
+ QColor backgroundColor() const;
+ void setBackgroundColor(const QColor &color);
Q_SIGNALS:
void loadStarted();
@@ -244,6 +237,7 @@ Q_SIGNALS:
void linkHovered(const QString &url);
void selectionChanged();
+ void fullScreenRequested(bool fullScreen);
void geometryChangeRequested(const QRect& geom);
void windowCloseRequested();
@@ -261,7 +255,6 @@ Q_SIGNALS:
protected:
virtual QWebEnginePage *createWindow(WebWindowType type);
-
virtual QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes);
virtual void javaScriptAlert(const QUrl &securityOrigin, const QString& msg);
virtual bool javaScriptConfirm(const QUrl &securityOrigin, const QString& msg);
@@ -269,8 +262,9 @@ protected:
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID);
virtual bool certificateError(const QWebEngineCertificateError &certificateError);
virtual bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
-
+ virtual bool isFullScreen();
private:
+ Q_DISABLE_COPY(QWebEnginePage)
Q_DECLARE_PRIVATE(QWebEnginePage)
QScopedPointer<QWebEnginePagePrivate> d_ptr;
#ifndef QT_NO_ACTION
diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h
index 0fcd05d3c..a72debee2 100644
--- a/src/webenginewidgets/api/qwebenginepage_p.h
+++ b/src/webenginewidgets/api/qwebenginepage_p.h
@@ -50,10 +50,10 @@
#include "qwebenginepage.h"
+#include "qwebenginecallback_p.h"
#include "qwebenginescriptcollection.h"
#include "web_contents_adapter_client.h"
#include <QtCore/qcompilerdetection.h>
-#include <QSharedData>
namespace QtWebEngineCore {
class RenderWidgetHostViewQtDelegate;
@@ -67,49 +67,6 @@ class QWebEngineProfile;
class QWebEngineSettings;
class QWebEngineView;
-class CallbackDirectory {
-public:
- typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QVariant&> VariantCallback;
- typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<const QString&> StringCallback;
- typedef QtWebEnginePrivate::QWebEngineCallbackPrivateBase<bool> BoolCallback;
-
- ~CallbackDirectory();
- void registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<VariantCallback> &callback);
- void registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<StringCallback> &callback);
- void registerCallback(quint64 requestId, const QExplicitlySharedDataPointer<BoolCallback> &callback);
- void invoke(quint64 requestId, const QVariant &result);
- void invoke(quint64 requestId, const QString &result);
- void invoke(quint64 requestId, bool result);
-
-private:
- struct CallbackSharedDataPointer {
- enum {
- None,
- Variant,
- String,
- Bool
- } type;
- union {
- VariantCallback *variantCallback;
- StringCallback *stringCallback;
- BoolCallback *boolCallback;
- };
- CallbackSharedDataPointer() : type(None) { }
- CallbackSharedDataPointer(VariantCallback *callback) : type(Variant), variantCallback(callback) { callback->ref.ref(); }
- CallbackSharedDataPointer(StringCallback *callback) : type(String), stringCallback(callback) { callback->ref.ref(); }
- CallbackSharedDataPointer(BoolCallback *callback) : type(Bool), boolCallback(callback) { callback->ref.ref(); }
- CallbackSharedDataPointer(const CallbackSharedDataPointer &other) : type(other.type), variantCallback(other.variantCallback) { doRef(); }
- ~CallbackSharedDataPointer() { doDeref(); }
- operator bool () const { return type != None; }
-
- private:
- void doRef();
- void doDeref();
- };
-
- QHash<quint64, CallbackSharedDataPointer> m_callbackMap;
-};
-
class QWebEnginePagePrivate : public QtWebEngineCore::WebContentsAdapterClient
{
public:
@@ -129,6 +86,7 @@ public:
virtual void selectionChanged() Q_DECL_OVERRIDE;
virtual QRectF viewportRect() const Q_DECL_OVERRIDE;
virtual qreal dpiScale() const Q_DECL_OVERRIDE;
+ virtual QColor backgroundColor() const Q_DECL_OVERRIDE;
virtual void loadStarted(const QUrl &provisionalUrl, bool isErrorPage = false) Q_DECL_OVERRIDE;
virtual void loadCommitted() Q_DECL_OVERRIDE;
virtual void loadVisuallyCommitted() Q_DECL_OVERRIDE { }
@@ -139,17 +97,17 @@ public:
virtual void close() Q_DECL_OVERRIDE;
virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &data) Q_DECL_OVERRIDE;
virtual void navigationRequested(int navigationType, const QUrl &url, int &navigationRequestAction, bool isMainFrame) Q_DECL_OVERRIDE;
- virtual void requestFullScreen(bool) Q_DECL_OVERRIDE { }
- virtual bool isFullScreen() const Q_DECL_OVERRIDE { return false; }
+ virtual void requestFullScreen(bool) Q_DECL_OVERRIDE;
+ virtual bool isFullScreen() const Q_DECL_OVERRIDE;
virtual void javascriptDialog(QSharedPointer<QtWebEngineCore::JavaScriptDialogController>) Q_DECL_OVERRIDE;
- virtual void runFileChooser(FileChooserMode, const QString &defaultFileName, const QStringList &acceptedMimeTypes) Q_DECL_OVERRIDE;
+ virtual void runFileChooser(QtWebEngineCore::FilePickerController *controller) Q_DECL_OVERRIDE;
virtual void didRunJavaScript(quint64 requestId, const QVariant& result) Q_DECL_OVERRIDE;
virtual void didFetchDocumentMarkup(quint64 requestId, const QString& result) Q_DECL_OVERRIDE;
virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) Q_DECL_OVERRIDE;
virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE;
virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE;
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE;
- virtual void authenticationRequired(const QUrl &requestUrl, const QString &realm, bool isProxy, const QString &challengingHost, QString *outUser, QString *outPassword) Q_DECL_OVERRIDE;
+ virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE;
virtual void runMediaAccessPermissionRequest(const QUrl &securityOrigin, MediaRequestFlags requestFlags) Q_DECL_OVERRIDE;
virtual void runGeolocationPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE;
virtual void runMouseLockPermissionRequest(const QUrl &securityOrigin) Q_DECL_OVERRIDE;
@@ -176,13 +134,14 @@ public:
QWebEngineProfile *profile;
QWebEngineSettings *settings;
QWebEngineView *view;
- QSize viewportSize;
QUrl explicitUrl;
QtWebEngineCore::WebEngineContextMenuData m_menuData;
bool isLoading;
QWebEngineScriptCollection scriptCollection;
+ QColor m_backgroundColor;
+ bool m_fullscreenRequested;
- mutable CallbackDirectory m_callbacks;
+ mutable QtWebEngineCore::CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];
};
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 2e5f685fd..a38a78cf7 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -36,12 +36,13 @@
#include "qwebengineprofile.h"
+#include "qwebenginecookiestoreclient.h"
#include "qwebenginedownloaditem.h"
#include "qwebenginedownloaditem_p.h"
#include "qwebenginepage.h"
#include "qwebengineprofile_p.h"
#include "qwebenginesettings.h"
-#include "qwebengineurlschemehandler_p_p.h"
+#include "qwebengineurlschemehandler_p.h"
#include "qwebenginescriptcollection_p.h"
#include "browser_context_adapter.h"
@@ -59,30 +60,36 @@ using QtWebEngineCore::BrowserContextAdapter;
\inmodule QtWebEngineWidgets
- QWebEngineProfile contains settings and history shared by all QWebEnginePages that belong
+ QWebEngineProfile contains settings and history shared by all web engine pages that belong
to the profile.
- A default profile is built-in that all web pages not specifically created with another profile
- belongs to.
+ The default profile is a built-in profile that all web pages not specifically created with
+ another profile belong to.
*/
/*!
\enum QWebEngineProfile::HttpCacheType
- This enum describes the HTTP cache types QtWebEngine can be configured to use.
+ This enum describes the HTTP cache type:
- \value MemoryHttpCache Use a in-memory cache. This is the only setting possible if off-the-record is set or no cache path is available.
+ \value MemoryHttpCache Use an in-memory cache. This is the only setting possible if
+ \c off-the-record is set or no cache path is available.
\value DiskHttpCache Use a disk cache. This is the default.
*/
/*!
\enum QWebEngineProfile::PersistentCookiesPolicy
- This enum describes policy for cookie persistency.
+ This enum describes policy for cookie persistency:
- \value NoPersistentCookies Both session and persistent cookies are stored in memory. This is the only setting possible if off-the-record is set or no persistent data path is available.
- \value AllowPersistentCookies Cookies marked persistent are save and restored from disk, session cookies are only stored to disk for crash recovery. This is the default setting.
- \value ForcePersistentCookies Both session and persistent cookies are save and restored from disk.
+ \value NoPersistentCookies
+ Both session and persistent cookies are stored in memory. This is the only setting
+ possible if \c off-the-record is set or no persistent data path is available.
+ \value AllowPersistentCookies
+ Cookies marked persistent are saved to and restored from disk, whereas session cookies
+ are only stored to disk for crash recovery. This is the default setting.
+ \value ForcePersistentCookies
+ Both session and persistent cookies are saved to and restored from disk.
*/
/*!
@@ -92,12 +99,11 @@ using QtWebEngineCore::BrowserContextAdapter;
This signal is emitted whenever a download has been triggered.
The \a download argument holds the state of the download.
- The \a download either has to be explicitly accepted with
- QWebEngineDownloadItem::accept(), else the download will be
+ The download has to be explicitly accepted with QWebEngineDownloadItem::accept() or it will be
cancelled by default.
- The download item is parented by the profile, but if not accepted
+ The download item is parented by the profile. If it is not accepted, it
will be deleted immediately after the signal emission.
- This signal can not be used with a queued connection.
+ This signal cannot be used with a queued connection.
\sa QWebEngineDownloadItem
*/
@@ -183,10 +189,10 @@ void QWebEngineProfilePrivate::downloadUpdated(const DownloadItemInfo &info)
}
/*!
- Constructs a new off-the-record profile.
+ Constructs a new off-the-record profile with the parent \a parent.
An off-the-record profile leaves no record on the local machine, and has no persistent data or cache.
- Thus, the HTTP cache can only be in memory and the cookies only be non-persistent, trying to change
+ Thus, the HTTP cache can only be in memory and the cookies can only be non-persistent. Trying to change
these settings will have no effect.
\sa isOffTheRecord()
@@ -199,7 +205,7 @@ QWebEngineProfile::QWebEngineProfile(QObject *parent)
}
/*!
- Constructs a new profile with storage name \a storageName.
+ Constructs a new profile with the storage name \a storageName and parent \a parent.
The storage name must be unique.
@@ -242,7 +248,7 @@ QString QWebEngineProfile::storageName() const
}
/*!
- Returns true if this is an off-the-record profile that leaves no record on the computer.
+ Returns \c true if this is an off-the-record profile that leaves no record on the computer.
This will force cookies and HTTP cache to be in memory, but also force all other normally
persistent data to be stored in memory.
@@ -256,9 +262,10 @@ bool QWebEngineProfile::isOffTheRecord() const
/*!
Returns the path used to store persistent data for the browser and web content.
- Persistent data includes persistent cookies, HTML5 local storage and visited links.
+ Persistent data includes persistent cookies, HTML5 local storage, and visited links.
- By default this is below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a storage name specific directory.
+ By default, this is below QStandardPaths::writableLocation() in a storage name specific
+ directory.
\sa setPersistentStoragePath(), storageName(), QStandardPaths::writableLocation()
*/
@@ -271,7 +278,7 @@ QString QWebEngineProfile::persistentStoragePath() const
/*!
Overrides the default path used to store persistent web engine data.
- If set to the null string, the default path is restored.
+ If \a path is set to the null string, the default path is restored.
\sa persistentStoragePath()
*/
@@ -284,7 +291,8 @@ void QWebEngineProfile::setPersistentStoragePath(const QString &path)
/*!
Returns the path used for caches.
- By default this is below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a storage name specific directory.
+ By default, this is below QStandardPaths::writableLocation() in a storage name specific
+ directory.
\sa setCachePath(), storageName(), QStandardPaths::writableLocation()
*/
@@ -295,7 +303,7 @@ QString QWebEngineProfile::cachePath() const
}
/*!
- Overrides the default path used for disk caches.
+ Overrides the default path used for disk caches, setting it to \a path.
If set to the null string, the default path is restored.
@@ -308,7 +316,7 @@ void QWebEngineProfile::setCachePath(const QString &path)
}
/*!
- Returns the user-agent string send with HTTP to identify the browser.
+ Returns the user-agent string sent with HTTP to identify the browser.
\sa setHttpUserAgent()
*/
@@ -332,7 +340,7 @@ void QWebEngineProfile::setHttpUserAgent(const QString &userAgent)
/*!
Returns the type of HTTP cache used.
- If the profile is off-the-record MemoryHttpCache is returned.
+ If the profile is off-the-record, MemoryHttpCache is returned.
\sa setHttpCacheType(), cachePath()
*/
@@ -354,9 +362,31 @@ void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCa
}
/*!
+ Sets the value of the Accept-Language HTTP request-header field to \a httpAcceptLanguage.
+
+ \since 5.6
+ */
+void QWebEngineProfile::setHttpAcceptLanguage(const QString &httpAcceptLanguage)
+{
+ Q_D(QWebEngineProfile);
+ d->browserContext()->setHttpAcceptLanguage(httpAcceptLanguage);
+}
+
+/*!
+ Returns the value of the Accept-Language HTTP request-header field.
+
+ \since 5.6
+ */
+QString QWebEngineProfile::httpAcceptLanguage() const
+{
+ Q_D(const QWebEngineProfile);
+ return d->browserContext()->httpAcceptLanguage();
+}
+
+/*!
Returns the current policy for persistent cookies.
- If the profile is off-the-record NoPersistentCookies is returned.
+ If the profile is off-the-record, NoPersistentCookies is returned.
\sa setPersistentCookiesPolicy()
*/
@@ -380,7 +410,7 @@ void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::Persistent
/*!
Returns the maximum size of the HTTP size.
- Will return 0 if the size is automatically controlled by QtWebEngine.
+ Will return \c 0 if the size is automatically controlled by QtWebEngine.
\sa setHttpCacheMaximumSize(), httpCacheType()
*/
@@ -393,7 +423,7 @@ int QWebEngineProfile::httpCacheMaximumSize() const
/*!
Sets the maximum size of the HTTP cache to \a maxSize.
- Setting it to 0 means the size will be controlled automatically by QtWebEngine.
+ Setting it to \c 0 means the size will be controlled automatically by QtWebEngine.
\sa httpCacheMaximumSize(), setHttpCacheType()
*/
@@ -404,6 +434,44 @@ void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize)
}
/*!
+ Returns the cookie store client singleton, if one has been set.
+*/
+
+QWebEngineCookieStoreClient* QWebEngineProfile::cookieStoreClient()
+{
+ Q_D(QWebEngineProfile);
+ return d->browserContext()->cookieStoreClient();
+}
+
+/*!
+ Registers a cookie store client singleton \a client to access Chromium's cookies.
+
+ The profile does not take ownership of the pointer.
+
+ \sa QtWebEngineCore::QWebEngineCookieStoreClient
+*/
+
+void QWebEngineProfile::setCookieStoreClient(QWebEngineCookieStoreClient *client)
+{
+ Q_D(QWebEngineProfile);
+ d->browserContext()->setCookieStoreClient(client);
+}
+
+/*!
+ Registers a request interceptor singleton \a interceptor to intercept URL requests.
+
+ The profile does not take ownership of the pointer.
+
+ \sa QtWebEngineCore::QWebEngineUrlRequestInfo
+*/
+
+void QWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
+{
+ Q_D(QWebEngineProfile);
+ d->browserContext()->setRequestInterceptor(interceptor);
+}
+
+/*!
Clears all links from the visited links database.
\sa clearVisitedLinks()
@@ -426,7 +494,7 @@ void QWebEngineProfile::clearVisitedLinks(const QList<QUrl> &urls)
}
/*!
- Returns true if \a url is considered a visited link by this profile.
+ Returns \c true if \a url is considered a visited link by this profile.
*/
bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl &url) const
{
@@ -468,10 +536,16 @@ QWebEngineSettings *QWebEngineProfile::settings() const
return d->settings();
}
-QWebEngineUrlSchemeHandler *QWebEngineProfilePrivate::urlSchemeHandler(const QByteArray &protocol)
+/*!
+ \since 5.6
+
+ Returns the custom URL scheme handler register for the URL scheme \a scheme.
+*/
+const QWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const
{
- if (m_urlSchemeHandlers.contains(protocol))
- return m_urlSchemeHandlers.value(protocol);
+ const Q_D(QWebEngineProfile);
+ if (d->m_urlSchemeHandlers.contains(scheme))
+ return d->m_urlSchemeHandlers.value(scheme);
return 0;
}
@@ -485,8 +559,14 @@ static bool checkInternalScheme(const QByteArray &scheme)
return internalSchemes.contains(scheme);
}
-void QWebEngineProfilePrivate::installUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
+/*!
+ \since 5.6
+
+ Installs the custom URL scheme handler \a handler in the profile.
+*/
+void QWebEngineProfile::installUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
{
+ Q_D(QWebEngineProfile);
Q_ASSERT(handler);
QByteArray scheme = handler->scheme();
if (checkInternalScheme(scheme)) {
@@ -494,29 +574,51 @@ void QWebEngineProfilePrivate::installUrlSchemeHandler(QWebEngineUrlSchemeHandle
return;
}
- if (m_urlSchemeHandlers.contains(scheme)) {
+ if (d->m_urlSchemeHandlers.contains(scheme)) {
qWarning() << "URL scheme handler already installed for the scheme: " << scheme;
return;
}
- m_urlSchemeHandlers.insert(scheme, handler);
- browserContext()->customUrlSchemeHandlers().append(handler->d_func());
- browserContext()->updateCustomUrlSchemeHandlers();
+ d->m_urlSchemeHandlers.insert(scheme, handler);
+ d->browserContext()->customUrlSchemeHandlers().append(handler->d_func());
+ d->browserContext()->updateCustomUrlSchemeHandlers();
+ connect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(destroyedUrlSchemeHandler(QObject*)));
}
-void QWebEngineProfilePrivate::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
+/*!
+ \since 5.6
+
+ Removes the custom URL scheme handler \a handler from the profile
+*/
+void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
{
- int count = m_urlSchemeHandlers.remove(handler->scheme());
+ Q_D(QWebEngineProfile);
+ Q_ASSERT(handler);
+ if (!handler)
+ return;
+ int count = d->m_urlSchemeHandlers.remove(handler->scheme());
if (!count)
return;
- browserContext()->customUrlSchemeHandlers().removeOne(handler->d_func());
- browserContext()->updateCustomUrlSchemeHandlers();
+ disconnect(handler, SIGNAL(destroyed(QObject*)), this, SLOT(destroyedUrlSchemeHandler(QObject*)));
+ d->browserContext()->removeCustomUrlSchemeHandler(handler->d_func());
+ d->browserContext()->updateCustomUrlSchemeHandlers();
+}
+
+/*!
+ \since 5.6
+
+ Removes all custom URL scheme handlers installed in the profile.
+*/
+void QWebEngineProfile::clearUrlSchemeHandlers()
+{
+ Q_D(QWebEngineProfile);
+ d->m_urlSchemeHandlers.clear();
+ d->browserContext()->customUrlSchemeHandlers().clear();
+ d->browserContext()->updateCustomUrlSchemeHandlers();
}
-void QWebEngineProfilePrivate::clearUrlSchemeHandlers()
+void QWebEngineProfile::destroyedUrlSchemeHandler(QObject *obj)
{
- m_urlSchemeHandlers.clear();
- browserContext()->customUrlSchemeHandlers().clear();
- browserContext()->updateCustomUrlSchemeHandlers();
+ removeUrlSchemeHandler(qobject_cast<QWebEngineUrlSchemeHandler*>(obj));
}
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebengineprofile.h b/src/webenginewidgets/api/qwebengineprofile.h
index 4308fe75d..5532f12ee 100644
--- a/src/webenginewidgets/api/qwebengineprofile.h
+++ b/src/webenginewidgets/api/qwebengineprofile.h
@@ -37,22 +37,25 @@
#ifndef QWEBENGINEPROFILE_H
#define QWEBENGINEPROFILE_H
-#include "qtwebenginewidgetsglobal.h"
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
-#include <QObject>
-#include <QScopedPointer>
-#include <QString>
+#include <QtCore/qobject.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
class QObject;
class QUrl;
+class QWebEngineCookieStoreClient;
class QWebEngineDownloadItem;
class QWebEnginePage;
class QWebEnginePagePrivate;
class QWebEngineProfilePrivate;
class QWebEngineSettings;
class QWebEngineScriptCollection;
+class QWebEngineUrlRequestInterceptor;
+class QWebEngineUrlSchemeHandler;
class QWEBENGINEWIDGETS_EXPORT QWebEngineProfile : public QObject {
Q_OBJECT
@@ -87,12 +90,19 @@ public:
HttpCacheType httpCacheType() const;
void setHttpCacheType(QWebEngineProfile::HttpCacheType);
+ void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
+ QString httpAcceptLanguage() const;
+
PersistentCookiesPolicy persistentCookiesPolicy() const;
void setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy);
int httpCacheMaximumSize() const;
void setHttpCacheMaximumSize(int maxSize);
+ QWebEngineCookieStoreClient* cookieStoreClient();
+ void setCookieStoreClient(QWebEngineCookieStoreClient *client);
+ void setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor);
+
void clearAllVisitedLinks();
void clearVisitedLinks(const QList<QUrl> &urls);
bool visitedLinksContainsUrl(const QUrl &url) const;
@@ -100,12 +110,21 @@ public:
QWebEngineSettings *settings() const;
QWebEngineScriptCollection *scripts() const;
+ const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &) const;
+ void installUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
+ void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
+ void clearUrlSchemeHandlers();
+
static QWebEngineProfile *defaultProfile();
Q_SIGNALS:
void downloadRequested(QWebEngineDownloadItem *download);
+private Q_SLOTS:
+ void destroyedUrlSchemeHandler(QObject *obj);
+
private:
+ Q_DISABLE_COPY(QWebEngineProfile)
Q_DECLARE_PRIVATE(QWebEngineProfile)
QWebEngineProfile(QWebEngineProfilePrivate *, QObject *parent = 0);
diff --git a/src/webenginewidgets/api/qwebengineprofile_p.h b/src/webenginewidgets/api/qwebengineprofile_p.h
index ee3ea57d8..8ba64c438 100644
--- a/src/webenginewidgets/api/qwebengineprofile_p.h
+++ b/src/webenginewidgets/api/qwebengineprofile_p.h
@@ -79,18 +79,13 @@ public:
void downloadRequested(DownloadItemInfo &info) Q_DECL_OVERRIDE;
void downloadUpdated(const DownloadItemInfo &info) Q_DECL_OVERRIDE;
- QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &);
- void installUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
- void removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *);
- void clearUrlSchemeHandlers();
-
private:
QWebEngineProfile *q_ptr;
QWebEngineSettings *m_settings;
QScopedPointer<QWebEngineScriptCollection> m_scriptCollection;
QExplicitlySharedDataPointer<QtWebEngineCore::BrowserContextAdapter> m_browserContextRef;
QMap<quint32, QPointer<QWebEngineDownloadItem> > m_ongoingDownloads;
- QMap<QByteArray, QPointer<QWebEngineUrlSchemeHandler> > m_urlSchemeHandlers;
+ QMap<QByteArray, QWebEngineUrlSchemeHandler *> m_urlSchemeHandlers;
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginescript.cpp b/src/webenginewidgets/api/qwebenginescript.cpp
index e47766f4c..1bd56604d 100644
--- a/src/webenginewidgets/api/qwebenginescript.cpp
+++ b/src/webenginewidgets/api/qwebenginescript.cpp
@@ -47,24 +47,27 @@ using QtWebEngineCore::UserScript;
\since 5.5
\brief The QWebEngineScript class encapsulates a JavaScript program.
- QWebEngineScript allows the programmatic injection of so called "user scripts" in the
- javascript engine at different points, determined by injectionPoint(), during the loading of web contents.
- Scripts can be executed either in the main javascript world, along with the rest of the JavaScript coming
- from the web contents, or in their own isolated world. While the DOM of the page can be accessed from any world,
- JavaScript variables a function defined in one world are not accessible from a different one.
- ScriptWorldId provides some predefined ids for this purpose.
+ QWebEngineScript enables the programmatic injection of so called \e {user scripts} in the
+ JavaScript engine at different points, determined by injectionPoint(), during the loading of web
+ contents.
+
+ Scripts can be executed either in the main JavaScript \e world, along with the rest of the
+ JavaScript coming from the web contents, or in their own isolated world. While the DOM of the
+ page can be accessed from any world, JavaScript variables of a function defined in one world are
+ not accessible from a different one. ScriptWorldId provides some predefined IDs for this
+ purpose.
*/
/*!
\enum QWebEngineScript::InjectionPoint
- This enum describes the timing for when the script injection should happen.
+ This enum describes the timing of the script injection:
\value DocumentCreation The script will be executed as soon as the document is created. This is not suitable for
any DOM operation.
- \value DocumentReady The script will run as soon as the DOM is ready. This is equivalent to the DOMContentLoaded
- event firing in JavaScript.
+ \value DocumentReady The script will run as soon as the DOM is ready. This is equivalent to the
+ \c DOMContentLoaded event firing in JavaScript.
\value Deferred The script will run when the page load finishes, or 500ms after the document is ready, whichever
comes first.
@@ -72,20 +75,30 @@ using QtWebEngineCore::UserScript;
/*!
\enum QWebEngineScript::ScriptWorldId
- This enum provides pre defined world ids for isolating user scripts into different worlds.
+ This enum provides pre-defined world IDs for isolating user scripts into different worlds:
\value MainWorld The world used by the page's web contents. It can be useful in order to expose custom functionality
to web contents in certain scenarios.
\value ApplicationWorld The default isolated world used for application level functionality implemented in JavaScript.
\value UserWorld The first isolated world to be used by scripts set by users if the application is not making use
- of more worlds. As a rule of thumbs, if that functionality is exposed to the application users, each individual script
+ of more worlds. As a rule of thumb, if that functionality is exposed to the application users, each individual script
should probably get its own isolated world.
*/
/*!
- * \brief QWebEngineScript::QWebEngineScript
- *
+ \fn QWebEngineScript::operator!=(const QWebEngineScript &other) const
+
+ Returns \c true if the script is not equal to \a other, otherwise returns \c false.
+*/
+
+/*!
+ \fn QWebEngineScript::swap(QWebEngineScript &other)
+
+ Swaps the contents of the script with the contents of \a other.
+*/
+
+/*!
* Constructs a null script.
*/
@@ -93,34 +106,42 @@ QWebEngineScript::QWebEngineScript()
: d(new UserScript)
{
}
+
/*!
- * \brief QWebEngineScript::isNull
- * \return \c true is the script is null, \c false otherwise.
+ * Constructs a user script using the contents of \a other.
*/
-
QWebEngineScript::QWebEngineScript(const QWebEngineScript &other)
: d(other.d)
{
}
+/*!
+ Destroys a script.
+*/
QWebEngineScript::~QWebEngineScript()
{
}
+/*!
+ Assigns \a other to the script.
+*/
QWebEngineScript &QWebEngineScript::operator=(const QWebEngineScript &other)
{
d = other.d;
return *this;
}
+/*!
+ Returns \c true is the script is null; otherwise returns \c false.
+*/
bool QWebEngineScript::isNull() const
{
return d->isNull();
}
/*!
- * \brief QWebEngineScript::name
- * \return The name of the script. Can be useful to retrieve a given script from a QWebEngineScriptCollection.
+ * Returns the name of the script. Can be useful to retrieve a particular script from a
+ * QWebEngineScriptCollection.
*
* \sa QWebEngineScriptCollection::findScript(), QWebEngineScriptCollection::findScripts()
*/
@@ -131,9 +152,6 @@ QString QWebEngineScript::name() const
}
/*!
- * \brief QWebEngineScript::setName
- * \param scriptName
- *
* Sets the script name to \a scriptName.
*/
void QWebEngineScript::setName(const QString &scriptName)
@@ -144,8 +162,7 @@ void QWebEngineScript::setName(const QString &scriptName)
}
/*!
- * \brief QWebEngineScript::sourceCode
- * \return the source of the script.
+ Returns the source of the script.
*/
QString QWebEngineScript::sourceCode() const
{
@@ -153,8 +170,6 @@ QString QWebEngineScript::sourceCode() const
}
/*!
- * \brief QWebEngineScript::setSourceCode
- * \param scriptSource
* Sets the script source to \a scriptSource.
*/
void QWebEngineScript::setSourceCode(const QString &scriptSource)
@@ -169,8 +184,7 @@ ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentReady, UserScript::DocumentLoadFini
ASSERT_ENUMS_MATCH(QWebEngineScript::DocumentCreation, UserScript::DocumentElementCreation)
/*!
- * \brief QWebEngineScript::injectionPoint
- * \return the point in the loading process at which the script will be executed.
+ * Returns the point in the loading process at which the script will be executed.
* The default value is QWebEngineScript::Deferred.
*
* \sa setInjectionPoint
@@ -180,9 +194,7 @@ QWebEngineScript::InjectionPoint QWebEngineScript::injectionPoint() const
return static_cast<QWebEngineScript::InjectionPoint>(d->injectionPoint());
}
/*!
- * \brief QWebEngineScript::setInjectionPoint
- * \param p
- * Sets the point at which to execute the script to be \p.
+ * Sets the point at which to execute the script to be \a p.
*
* \sa QWebEngineScript::InjectionPoint
*/
@@ -194,8 +206,7 @@ void QWebEngineScript::setInjectionPoint(QWebEngineScript::InjectionPoint p)
}
/*!
- * \brief QWebEngineScript::worldId
- * \return the world id defining which world the script is executed in.
+ Returns the world ID defining which world the script is executed in.
*/
quint32 QWebEngineScript::worldId() const
{
@@ -203,9 +214,7 @@ quint32 QWebEngineScript::worldId() const
}
/*!
- * \brief QWebEngineScript::setWorldId
- * \param id
- * Sets the world id of the isolated world to use when running this script.
+ Sets the world ID of the isolated world to \a id when running this script.
*/
void QWebEngineScript::setWorldId(quint32 id)
{
@@ -215,8 +224,8 @@ void QWebEngineScript::setWorldId(quint32 id)
}
/*!
- * \brief QWebEngineScript::runsOnSubFrames
- * \return \c true if the script is executed on every frame in the page, \c false if it is only ran for the main frame.
+ Returns \c true if the script is executed on every frame in the page, or \c false if it is only
+ ran for the main frame.
*/
bool QWebEngineScript::runsOnSubFrames() const
{
@@ -224,9 +233,7 @@ bool QWebEngineScript::runsOnSubFrames() const
}
/*!
- * \brief QWebEngineScript::setRunsOnSubFrames
- * \param on
- * Sets whether or not the script is executed on sub frames in addition to the main frame.
+ * Executes the script on sub frames in addition to the main frame if \a on returns \c true.
*/
void QWebEngineScript::setRunsOnSubFrames(bool on)
{
@@ -236,9 +243,7 @@ void QWebEngineScript::setRunsOnSubFrames(bool on)
}
/*!
- * \brief QWebEngineScript::operator ==
- * \param other
- * \return \c true if this QWebEngineScript is equal to \a other, otherwise returns \c false.
+ Returns \c true if the script is equal to \a other, otherwise returns \c false.
*/
bool QWebEngineScript::operator==(const QWebEngineScript &other) const
{
diff --git a/src/webenginewidgets/api/qwebenginescript.h b/src/webenginewidgets/api/qwebenginescript.h
index 2b03cd06f..4cff2631d 100644
--- a/src/webenginewidgets/api/qwebenginescript.h
+++ b/src/webenginewidgets/api/qwebenginescript.h
@@ -36,10 +36,11 @@
#ifndef QWEBENGINESCRIPT_H
#define QWEBENGINESCRIPT_H
-#include "qtwebenginewidgetsglobal.h"
-#include <QtCore/QSharedDataPointer>
-#include <QtCore/QString>
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+
+#include <QtCore/qshareddata.h>
+#include <QtCore/qstring.h>
namespace QtWebEngineCore {
class UserScript;
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.cpp b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
index 21cb0d05e..80a7f9b6e 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.cpp
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.cpp
@@ -49,18 +49,32 @@ using QtWebEngineCore::UserScript;
*/
+/*!
+ \fn QWebEngineScriptCollection::isEmpty() const
+
+ Returns \c true if the collection is empty; otherwise returns \c false.
+*/
+
+/*!
+ \fn QWebEngineScriptCollection::size() const
+
+ Returns the number of elements in the collection.
+*/
+
QWebEngineScriptCollection::QWebEngineScriptCollection(QWebEngineScriptCollectionPrivate *collectionPrivate)
:d(collectionPrivate)
{
}
+/*!
+ Destroys the collection.
+*/
QWebEngineScriptCollection::~QWebEngineScriptCollection()
{
}
/*!
- * \brief QWebEngineScriptCollection::count
- * \return the number of elements in the collection.
+ Returns the number of elements in the collection.
*/
int QWebEngineScriptCollection::count() const
@@ -69,9 +83,8 @@ int QWebEngineScriptCollection::count() const
}
/*!
- * \brief QWebEngineScriptCollection::contains
- * \param value
- * \return \c true if the collection contains an occurrence of \a value; otherwise returns false.
+ Returns \c true if the collection contains an occurrence of \a value; otherwise returns
+ \c false.
*/
bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const
@@ -80,11 +93,10 @@ bool QWebEngineScriptCollection::contains(const QWebEngineScript &value) const
}
/*!
- * \brief QWebEngineScriptCollection::findScript
- * \param name
- * \return the first script found in collection the name property of which is \a name, or a null QWebEngineScript if none was found.
- * \note the order in which the script collection is traversed is undefined, which means this should be used when the unicity is
- * guaranteed at the application level.
+ * Returns the first script found in the collection with the name \a name, or a null
+ * QWebEngineScript if none was found.
+ * \note The order in which the script collection is traversed is undefined, which means this should
+ * be used when the unicity is guaranteed at the application level.
* \sa findScripts()
*/
@@ -94,9 +106,8 @@ QWebEngineScript QWebEngineScriptCollection::findScript(const QString &name) con
}
/*!
- * \brief QWebEngineScriptCollection::findScripts
- * \param name
- * \return the list of scripts in the collection the name property of which is \a name, or an empty list if none was found.
+ Returns the list of scripts in the collection with the name \a name, or an empty list if none
+ was found.
*/
QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &name) const
@@ -104,20 +115,14 @@ QList<QWebEngineScript> QWebEngineScriptCollection::findScripts(const QString &n
return d->toList(name);
}
/*!
- * \brief QWebEngineScriptCollection::insert
- * \param s
- *
- * Inserts script \c s into the collection.
+ Inserts the script \a s into the collection.
*/
void QWebEngineScriptCollection::insert(const QWebEngineScript &s)
{
d->insert(s);
}
/*!
- * \brief QWebEngineScriptCollection::insert
- * \param list
- *
- * Inserts scripts \c list into the collection.
+ Inserts scripts from the list \a list into the collection.
*/
void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
{
@@ -127,10 +132,10 @@ void QWebEngineScriptCollection::insert(const QList<QWebEngineScript> &list)
}
/*!
- * \brief QWebEngineScriptCollection::remove
- * \param script
- * Removes \a script from the collection, if it is present.
- * \return \c true if the script was found and successfully removed from the collection, \c false otherwise.
+ Removes \a script from the collection.
+
+ Returns \c true if the script was found and successfully removed from the collection; otherwise
+ returns \c false.
*/
bool QWebEngineScriptCollection::remove(const QWebEngineScript &script)
{
@@ -138,7 +143,6 @@ bool QWebEngineScriptCollection::remove(const QWebEngineScript &script)
}
/*!
- * \brief QWebEngineScriptCollection::clear
* Removes all scripts from this collection.
*/
void QWebEngineScriptCollection::clear()
@@ -147,8 +151,7 @@ void QWebEngineScriptCollection::clear()
}
/*!
- * \brief QWebEngineScriptCollection::toList
- * \return a QList with the values of the scripts used in this collection.
+ Returns a list with the values of the scripts used in this collection.
*/
QList<QWebEngineScript> QWebEngineScriptCollection::toList() const
{
diff --git a/src/webenginewidgets/api/qwebenginescriptcollection.h b/src/webenginewidgets/api/qwebenginescriptcollection.h
index fe3ce2861..40196b478 100644
--- a/src/webenginewidgets/api/qwebenginescriptcollection.h
+++ b/src/webenginewidgets/api/qwebenginescriptcollection.h
@@ -37,12 +37,12 @@
#ifndef QWEBENGINESCRIPTCOLLECTION_H
#define QWEBENGINESCRIPTCOLLECTION_H
-#include "qtwebenginewidgetsglobal.h"
+#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
+#include <QtWebEngineWidgets/qwebenginescript.h>
-#include "qwebenginescript.h"
-#include <QtCore/QScopedPointer>
-#include <QtCore/QList>
-#include <QtCore/QSet>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qset.h>
QT_BEGIN_NAMESPACE
class QWebEngineScriptCollectionPrivate;
diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp
index 164bf8db6..430d64185 100644
--- a/src/webenginewidgets/api/qwebenginesettings.cpp
+++ b/src/webenginewidgets/api/qwebenginesettings.cpp
@@ -72,6 +72,10 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web
return WebEngineSettings::ScrollAnimatorEnabled;
case QWebEngineSettings::ErrorPageEnabled:
return WebEngineSettings::ErrorPageEnabled;
+ case QWebEngineSettings::PluginsEnabled:
+ return WebEngineSettings::PluginsEnabled;
+ case QWebEngineSettings::FullScreenSupportEnabled:
+ return WebEngineSettings::FullScreenSupportEnabled;
default:
return WebEngineSettings::UnsupportedInCoreSettings;
}
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h
index 44339a2f6..327fd447b 100644
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ b/src/webenginewidgets/api/qwebenginesettings.h
@@ -58,7 +58,9 @@ public:
LocalContentCanAccessFileUrls,
HyperlinkAuditingEnabled,
ScrollAnimatorEnabled,
- ErrorPageEnabled
+ ErrorPageEnabled,
+ PluginsEnabled,
+ FullScreenSupportEnabled
};
enum FontSize {
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index 6b37dbf39..0d8f9fc17 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -120,6 +120,7 @@ protected:
virtual bool event(QEvent*) Q_DECL_OVERRIDE;
private:
+ Q_DISABLE_COPY(QWebEngineView)
Q_DECLARE_PRIVATE(QWebEngineView)
QScopedPointer<QWebEngineViewPrivate> d_ptr;
diff --git a/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf b/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf
index ad1e46f1c..df01f449e 100644
--- a/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf
+++ b/src/webenginewidgets/doc/qtwebenginewidgets.qdocconf
@@ -32,8 +32,10 @@ tagfile = ../../../doc/qtwebenginewidgets/qtwebenginewidgets.tag
depends += qtwebengine qtcore qtnetwork qtgui qtwidgets qtwebkit qtdoc
headerdirs += ../api
-sourcedirs += ../api
-exampledirs += ../../../examples/webenginewidgets .
+sourcedirs += ../api src
+
+exampledirs += ../../../examples/webenginewidgets \
+ snippets
navigation.landingpage = "Qt WebEngine Widgets"
navigation.cppclassespage = "Qt WebEngine Widgets C++ Classes"
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc
new file mode 100644
index 000000000..eff22be26
--- /dev/null
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*!
+ \group webengine-widgetexamples
+ \title Qt WebEngine Widgets Examples
+ \brief Examples demonstrating the Qt WebEngine Widgets usage
+ \ingroup all-examples
+
+ Qt provides an integrated Web browser component based on Chromium, the popular
+ open source browser engine.
+
+ These examples and demonstrations show a range of different uses for Qt WebEngine,
+ from displaying Web pages within a Qt user interface to an implementation of
+ a basic function Web browser.
+*/
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc
index 1e8cda065..77596a370 100644
--- a/src/webenginewidgets/doc/src/qtwebenginewidgets.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc
@@ -26,74 +26,29 @@
****************************************************************************/
/*!
- \module QtWebEngineWidgets
- \title Qt WebEngine Widgets C++ Classes
- \qtvariable webenginewidgets
- \brief Provides a web browser engine as well as C++ classes to render and
- interact with web content
-
- To include the definitions of the module's classes, use the
- following directive:
-
- \snippet snippets/qtwebengine_build_snippet.qdoc 1
-
- To link against the module, add this line to your \l qmake \c
- .pro file:
-
- \snippet snippets/qtwebengine_build_snippet.qdoc 0
-*/
-
-/*!
\page qtwebenginewidgets-index.html
\title Qt WebEngine Widgets
\ingroup modules
- \brief The Qt WebEngine Widgets module provides a web browser engine as
- well as C++ classes to display and interact with web content.
-
- Qt WebEngine Widgets gives you a Web browser engine that you can use to
- embed content easily from the World Wide Web into your Qt application.
-
- Qt WebEngine Widgets lets you display HyperText Markup Language version 5
- (HTML5), Extensible HyperText Markup Language (XHTML) and Scalable Vector
- Graphics (SVG) documents, styled using Cascading Style Sheets (CSS) and
- scripted with JavaScript.
-
- HTML and XHTML documents can also be made fully editable to the user by
- using the \c{contenteditable} attribute on HTML elements.
+ \brief Provides a web browser engine as well as C++ classes to render web content and interact
+ with it.
- Qt WebEngine is based on the Chromium project. See the
- \l{http://www.chromium.org}{Chromium Project} Web site for more information.
-
- \section1 Including In Your Project
+ \section1 Getting Started
To include the definitions of the module's classes, use the
following directive:
- \snippet snippets/qtwebengine_build_snippet.qdoc 1
-
- To link against the module, add this line to your \l qmake \c
- .pro file:
-
- \snippet snippets/qtwebengine_build_snippet.qdoc 0
+ \snippet qtwebengine_build_snippet.qdoc 1
- \section1 Architecture
+ To link against the module, add this line to your qmake project file:
- Use the QWebEngineView class to display web pages in the simplest way.
- Because it's a widget, you can embed QWebEngineView into your forms and use
- its convenience functions to download and display web sites.
+ \snippet qtwebengine_build_snippet.qdoc 0
- \snippet snippets/simple/main.cpp Using QWebEngineView
-
- An instance of QWebEngineView has one QWebEnginePage. QWebEnginePage
- provides access to the page's navigation history, ability to run JavaScript
- code in the context of the page's main frame, and enables customization of
- handlers for specific events like showing custom authentication dialogs.
-
- \section1 Reference Documentation
+ \section1 Articles and Guides
\list
- \li \l {Qt WebEngine Widgets C++ Classes}
+ \li \l{Qt WebEngine Overview}
+ \li \l{Porting from Qt WebKit to Qt WebEngine}
\endlist
\section1 Examples
@@ -102,7 +57,14 @@
\li \l {Qt WebEngine Widgets Examples}
\endlist
+ \section1 API Reference
+
+ \list
+ \li \l {Qt WebEngine Widgets C++ Classes}
+ \endlist
+
\section1 License Information
+
This is a snapshot of the integration of Chromium into Qt.
Qt Commercial Edition licensees that wish to distribute applications that
@@ -146,17 +108,3 @@
\endlegalese
*/
-
-/*!
- \group webengine-widgetexamples
- \title Qt WebEngine Widgets Examples
- \brief Examples demonstrating the Qt WebEngine Widgets usage
- \ingroup all-examples
-
- Qt provides an integrated Web browser component based on Chromium, the popular
- open source browser engine.
-
- These examples and demonstrations show a range of different uses for Qt WebEngine,
- from displaying Web pages within a Qt user interface to an implementation of
- a basic function Web browser.
-*/
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc
new file mode 100644
index 000000000..6373389f3
--- /dev/null
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: http://www.gnu.org/copyleft/fdl.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \module QtWebEngineWidgets
+ \title Qt WebEngine Widgets C++ Classes
+ \brief Provides a web browser engine as well as C++ classes to render and
+ interact with web content
+ \ingroup qtwebengine-modules
+
+ To include the definitions of the module's classes, use the
+ following directive:
+
+ \snippet qtwebengine_build_snippet.qdoc 1
+
+ To link against the module, add the following to your qmake project file:
+
+ \snippet qtwebengine_build_snippet.qdoc 0
+*/
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 40c5c8d04..37fc880c0 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -98,6 +98,24 @@
\value SelectAll Selects all content.
\value PasteAndMatchStyle Paste content from the clipboard with current style.
+ \value OpenLinkInThisWindow Open the current link in the current window. (Added in Qt 5.6)
+ \value OpenLinkInNewWindow Open the current link in a new window. (Added in Qt 5.6)
+ \value OpenLinkInNewTab Open the current link in a new tab. (Added in Qt 5.6)
+ \value CopyLinkToClipboard Copy the current link to the clipboard. (Added in Qt 5.6)
+
+ \value CopyImageToClipboard Copy the clicked image to the clipboard. (Added in Qt 5.6)
+ \value CopyImageUrlToClipboard Copy the clicked image's URL to the clipboard. (Added in Qt 5.6)
+ \value CopyMediaUrlToClipboard Copy the hovered audio or video's URL to the clipboard. (Added in Qt 5.6)
+ \value ToggleMediaControls Toggles between showing and hiding the controls for the hovered audio or video element. (Added in Qt 5.6)
+ \value ToggleMediaLoop Toggles whether the hovered audio or video should loop on completetion or not. (Added in Qt 5.6)
+ \value ToggleMediaPlayPause Toggles the play/pause state of the hovered audio or video element. (Added in Qt 5.6)
+ \value ToggleMediaMute Mutes or unmutes the hovered audio or video element. (Added in Qt 5.6)
+ \value DownloadLinkToDisk Download the current link to the disk. (Added in Qt 5.6)
+ \value DownloadImageToDisk Download the highlighted image to the disk. (Added in Qt 5.6)
+ \value DownloadMediaToDisk Download the hovered audio or video to the disk. (Added in Qt 5.6)
+
+ \value InspectElement Triggers any attached Web Inspector to inspect the highlighed element. (Added in Qt 5.6)
+
\omitvalue WebActionCount
*/
@@ -335,7 +353,7 @@
was found; otherwise the callback value will be false.
For example:
- \snippet snippets/qtwebengine_qwebenginepage_snippet.cpp 0
+ \snippet qtwebengine_qwebenginepage_snippet.cpp 0
*/
/*!
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
index 567f26e20..c65c37f55 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
@@ -119,6 +119,8 @@
Enables animated scrolling. Disabled by default.
\value ErrorPageEnabled
Enables displaying the built-in error pages of Chromium. Enabled by default.
+ \value PluginsEnabled
+ Enables support for Pepper plugins, such as the Flash player. Disabled by default.
*/
/*!
diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
index 163e9a28e..76878e077 100644
--- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
@@ -41,7 +41,7 @@
Qt widgets, the show() function must be invoked in order to display
QWebEngineView. The snippet below illustrates this:
- \snippet snippets/simple/main.cpp Using QWebEngineView
+ \snippet simple/main.cpp Using QWebEngineView
Alternatively, setUrl() can also be used to load a web site. If you have
the HTML content readily available, you can use setHtml() instead.
@@ -170,7 +170,7 @@
It is equivalent to
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 0
+ \snippet qtwebengine_qwebengineview_snippet.cpp 0
*/
/*!
@@ -231,7 +231,7 @@
The following example triggers the copy action and therefore copies any
selected text to the clipboard.
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 2
+ \snippet qtwebengine_qwebengineview_snippet.cpp 2
\sa pageAction()
*/
@@ -268,7 +268,7 @@
It is equivalent to
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 3
+ \snippet qtwebengine_qwebengineview_snippet.cpp 3
\sa reload(), pageAction(), loadFinished()
*/
@@ -280,7 +280,7 @@
It is equivalent to
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 4
+ \snippet qtwebengine_qwebengineview_snippet.cpp 4
\sa forward(), pageAction()
*/
@@ -292,7 +292,7 @@
It is equivalent to
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 5
+ \snippet qtwebengine_qwebengineview_snippet.cpp 5
\sa back(), pageAction()
*/
@@ -386,7 +386,7 @@
It is equivalent to
- \snippet snippets/qtwebengine_qwebengineview_snippet.cpp 6
+ \snippet qtwebengine_qwebengineview_snippet.cpp 6
\sa QWebEngineSettings::globalSettings()
*/
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index dba37cea7..76ca8d354 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -59,6 +59,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
, m_rootNode(new QSGRootNode)
, m_sgEngine(new QSGEngine)
, m_isPopup(false)
+ , m_clearColor(Qt::white)
{
setFocusPolicy(Qt::StrongFocus);
@@ -218,6 +219,19 @@ void RenderWidgetHostViewQtDelegateWidget::setTooltip(const QString &tooltip)
setToolTip(wrappedTip);
}
+void RenderWidgetHostViewQtDelegateWidget::setClearColor(const QColor &color)
+{
+ m_clearColor = color;
+ // QOpenGLWidget is usually blended by punching holes into widgets
+ // above it to simulate the visual stacking order. If we want it to be
+ // transparent we have to throw away the proper stacking order and always
+ // blend the complete normal widgets backing store under it.
+ bool isTranslucent = color.alpha() < 255;
+ setAttribute(Qt::WA_AlwaysStackOnTop, isTranslucent);
+ setAttribute(Qt::WA_OpaquePaintEvent, !isTranslucent);
+ update();
+}
+
QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const
{
return m_client->inputMethodQuery(query);
@@ -270,7 +284,7 @@ void RenderWidgetHostViewQtDelegateWidget::initializeGL()
m_sgEngine->initialize(QOpenGLContext::currentContext());
m_sgRenderer.reset(m_sgEngine->createRenderer());
m_sgRenderer->setRootNode(m_rootNode.data());
- m_sgRenderer->setClearColor(Qt::white);
+ m_sgRenderer->setClearColor(m_clearColor);
}
void RenderWidgetHostViewQtDelegateWidget::paintGL()
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
index d0dfdc689..d228bd487 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
@@ -78,6 +78,7 @@ public:
virtual void move(const QPoint &screenPos) Q_DECL_OVERRIDE;
virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE;
virtual void setTooltip(const QString &tooltip) Q_DECL_OVERRIDE;
+ virtual void setClearColor(const QColor &color) Q_DECL_OVERRIDE;
protected:
bool event(QEvent *event) Q_DECL_OVERRIDE;
@@ -98,6 +99,7 @@ private:
QScopedPointer<QSGEngine> m_sgEngine;
QScopedPointer<QSGAbstractRenderer> m_sgRenderer;
bool m_isPopup;
+ QColor m_clearColor;
QList<QMetaObject::Connection> m_windowConnections;
};
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
index 1f7974bd2..c32185563 100644
--- a/src/webenginewidgets/webenginewidgets.pro
+++ b/src/webenginewidgets/webenginewidgets.pro
@@ -3,12 +3,12 @@ TARGET = QtWebEngineWidgets
# For our export macros
DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
-QT += webengine widgets network quick
-QT_PRIVATE += webenginecore quick-private gui-private core-private
+QT += webengine webenginecore widgets network quick
+QT_PRIVATE += quick-private gui-private core-private
QMAKE_DOCS = $$PWD/doc/qtwebenginewidgets.qdocconf
-INCLUDEPATH += $$PWD api ../core ../webengine/api
+INCLUDEPATH += $$PWD api ../core ../core/api ../webengine/api
SOURCES = \
api/qtwebenginewidgetsglobal.cpp \
@@ -20,8 +20,6 @@ SOURCES = \
api/qwebenginescript.cpp \
api/qwebenginescriptcollection.cpp \
api/qwebenginesettings.cpp \
- api/qwebengineurlrequestjob.cpp \
- api/qwebengineurlschemehandler.cpp \
api/qwebengineview.cpp \
render_widget_host_view_qt_delegate_widget.cpp
@@ -38,9 +36,6 @@ HEADERS = \
api/qwebenginescriptcollection.h \
api/qwebenginescriptcollection_p.h \
api/qwebenginesettings.h \
- api/qwebengineurlrequestjob_p.h \
- api/qwebengineurlschemehandler_p.h \
- api/qwebengineurlschemehandler_p_p.h \
api/qwebengineview.h \
api/qwebengineview_p.h \
render_widget_host_view_qt_delegate_widget.h
diff --git a/sync.profile b/sync.profile
index 774941d56..11d7b0548 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,10 +1,12 @@
%modules = ( # path to module name map
"QtWebEngine" => "$basedir/src/webengine",
"QtWebEngineWidgets" => "$basedir/src/webenginewidgets",
+ "QtWebEngineCore" => "$basedir/src/core",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
"QtWebEngine" => "api",
"QtWebEngineWidgets" => "api",
+ "QtWebEngineCore" => "api",
);
%classnames = (
);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index f14305f72..06430cf8e 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -4,4 +4,6 @@ SUBDIRS = quick
qtHaveModule(webenginewidgets) {
SUBDIRS += widgets
+# core tests depend on widgets for now
+ SUBDIRS += core
}
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro
new file mode 100644
index 000000000..ed0a61532
--- /dev/null
+++ b/tests/auto/core/core.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+
+CONFIG += ordered
+
+SUBDIRS += \
+ qwebenginecookiestoreclient \
+ qwebengineurlrequestinterceptor \
diff --git a/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro b/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro
new file mode 100644
index 000000000..e99c7f493
--- /dev/null
+++ b/tests/auto/core/qwebenginecookiestoreclient/qwebenginecookiestoreclient.pro
@@ -0,0 +1 @@
+include(../tests.pri)
diff --git a/tests/auto/core/qwebenginecookiestoreclient/resources/content.html b/tests/auto/core/qwebenginecookiestoreclient/resources/content.html
new file mode 100644
index 000000000..360ad65ef
--- /dev/null
+++ b/tests/auto/core/qwebenginecookiestoreclient/resources/content.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<a>This is test content</a>
+</body>
+</html>
diff --git a/tests/auto/core/qwebenginecookiestoreclient/resources/index.html b/tests/auto/core/qwebenginecookiestoreclient/resources/index.html
new file mode 100644
index 000000000..d41866712
--- /dev/null
+++ b/tests/auto/core/qwebenginecookiestoreclient/resources/index.html
@@ -0,0 +1,38 @@
+<html>
+ <head>
+ <script type="text/javascript">
+ function generateCookieString(key, value, options) {
+ key = key.replace(/[^#$&+\^`|]/g, encodeURIComponent);
+ key = key.replace(/\(/g, '%28').replace(/\)/g, '%29');
+ value = (value + '').replace(/[^!#$&-+\--:<-\[\]-~]/g, encodeURIComponent);
+ options = options || {};
+
+ var cookieString = key + '=' + value;
+ cookieString += options.path ? '; Path=' + options.path : '';
+ cookieString += options.domain ? '; Domain=' + options.domain : '';
+ cookieString += options.expires ? '; Expires=' + options.expires.toUTCString() : '';
+ cookieString += options.secure ? '; Secure' : '';
+
+ console.log(cookieString)
+ return cookieString;
+};
+function setCookie() {
+ var name = "SessionCookie"
+ var value = "QtWebEngineCookieTest"
+ document.cookie = generateCookieString(name, value, {})
+
+ name = "CookieWithExpiresField"
+ value = "QtWebEngineCookieTest"
+ var daysValid = 10;
+ var date = new Date();
+ date.setTime(date.getTime() + (daysValid*24*60*60*1000));
+ var expires = date;
+ var options = {};
+ options.expires = expires;
+ document.cookie = generateCookieString(name, value, options)
+}
+</script>
+ </head>
+ <body onload="setCookie()">
+ </body>
+</html>
diff --git a/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp
new file mode 100644
index 000000000..0f007d643
--- /dev/null
+++ b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.cpp
@@ -0,0 +1,212 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../../widgets/util.h"
+#include <QtTest/QtTest>
+#include <QtWebEngineCore/qwebenginecallback.h>
+#include <QtWebEngineCore/qwebenginecookiestoreclient.h>
+#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineWidgets/qwebengineprofile.h>
+#include <QtWebEngineWidgets/qwebengineview.h>
+
+class tst_QWebEngineCookieStoreClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebEngineCookieStoreClient();
+ ~tst_QWebEngineCookieStoreClient();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void initTestCase();
+ void cleanupTestCase();
+ void cookieSignals();
+ void setAndDeleteCookie();
+ void batchCookieTasks();
+};
+
+tst_QWebEngineCookieStoreClient::tst_QWebEngineCookieStoreClient()
+{
+}
+
+tst_QWebEngineCookieStoreClient::~tst_QWebEngineCookieStoreClient()
+{
+}
+
+void tst_QWebEngineCookieStoreClient::init()
+{
+}
+
+void tst_QWebEngineCookieStoreClient::cleanup()
+{
+}
+
+void tst_QWebEngineCookieStoreClient::initTestCase()
+{
+}
+
+void tst_QWebEngineCookieStoreClient::cleanupTestCase()
+{
+}
+
+void tst_QWebEngineCookieStoreClient::cookieSignals()
+{
+ QWebEngineView view;
+ QWebEngineCookieStoreClient client;
+
+ QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
+ QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
+
+ view.page()->profile()->setCookieStoreClient(&client);
+
+ view.load(QUrl("qrc:///resources/index.html"));
+
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QVariant success = loadSpy.takeFirst().takeFirst();
+ QVERIFY(success.toBool());
+ QTRY_COMPARE(cookieAddedSpy.count(), 2);
+
+ // try whether updating a cookie to be expired results in that cookie being removed.
+ QNetworkCookie expiredCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
+ client.setCookie(expiredCookie, QUrl("qrc:///resources/index.html"));
+ QTRY_COMPARE(cookieRemovedSpy.count(), 1);
+ cookieRemovedSpy.clear();
+
+ // try removing the other cookie.
+ QNetworkCookie nonSessionCookie(QNetworkCookie::parseCookies(QByteArrayLiteral("CookieWithExpiresField=QtWebEngineCookieTest; path=///resources")).first());
+ client.deleteCookie(nonSessionCookie, QUrl("qrc:///resources/index.html"));
+ QTRY_COMPARE(cookieRemovedSpy.count(), 1);
+}
+
+void tst_QWebEngineCookieStoreClient::setAndDeleteCookie()
+{
+ QWebEngineView view;
+ QWebEngineCookieStoreClient client;
+
+ QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
+ QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
+
+ QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first());
+ QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first());
+ QNetworkCookie cookie3(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=QtWebEngineCookieTest; Path=///resources")).first());
+ QNetworkCookie expiredCookie3(QNetworkCookie::parseCookies(QByteArrayLiteral("SessionCookie=delete; expires=Thu, 01-Jan-1970 00:00:00 GMT; path=///resources")).first());
+
+ // check if pending cookies are set and removed
+ client.setCookieWithCallback(cookie1, [](bool success) { QVERIFY(success); });
+ client.setCookieWithCallback(cookie2, [](bool success) { QVERIFY(success); });
+ client.deleteCookie(cookie1);
+
+ view.page()->profile()->setCookieStoreClient(&client);
+ view.load(QUrl("qrc:///resources/content.html"));
+
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QVariant success = loadSpy.takeFirst().takeFirst();
+ QVERIFY(success.toBool());
+ QTRY_COMPARE(cookieAddedSpy.count(), 2);
+ QTRY_COMPARE(cookieRemovedSpy.count(), 1);
+ cookieAddedSpy.clear();
+ cookieRemovedSpy.clear();
+
+ client.setCookieWithCallback(cookie3, [](bool success) { QVERIFY(success); });
+ // updating a cookie with an expired 'expires' field should remove the cookie with the same name
+ client.setCookieWithCallback(expiredCookie3, [](bool success) { QVERIFY(success); });
+ client.deleteCookie(cookie2);
+ QTRY_COMPARE(cookieAddedSpy.count(), 1);
+ QTRY_COMPARE(cookieRemovedSpy.count(), 2);
+}
+
+void tst_QWebEngineCookieStoreClient::batchCookieTasks()
+{
+ QWebEngineView view;
+ QWebEngineCookieStoreClient client;
+
+ QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
+ QSignalSpy cookieAddedSpy(&client, SIGNAL(cookieAdded(const QNetworkCookie &)));
+ QSignalSpy cookieRemovedSpy(&client, SIGNAL(cookieRemoved(const QNetworkCookie &)));
+
+ QNetworkCookie cookie1(QNetworkCookie::parseCookies(QByteArrayLiteral("khaos=I9GX8CWI; Domain=.example.com; Path=/docs")).first());
+ QNetworkCookie cookie2(QNetworkCookie::parseCookies(QByteArrayLiteral("Test%20Cookie=foobar; domain=example.com; Path=/")).first());
+
+ int capture = 0;
+
+ client.setCookieWithCallback(cookie1, [&capture](bool success) { QVERIFY(success); ++capture; });
+ client.setCookieWithCallback(cookie2, [&capture](bool success) { QVERIFY(success); ++capture; });
+
+ view.page()->profile()->setCookieStoreClient(&client);
+ view.load(QUrl("qrc:///resources/index.html"));
+
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QVariant success = loadSpy.takeFirst().takeFirst();
+ QVERIFY(success.toBool());
+ QTRY_COMPARE(cookieAddedSpy.count(), 4);
+ QTRY_COMPARE(cookieRemovedSpy.count(), 0);
+ QTRY_COMPARE(capture, 2);
+ capture = 0;
+
+ cookieAddedSpy.clear();
+ cookieRemovedSpy.clear();
+
+ client.getAllCookies([&capture](const QByteArray& cookieLine) {
+ ++capture;
+ QCOMPARE(QNetworkCookie::parseCookies(cookieLine).count(), 4);
+ });
+
+ client.deleteSessionCookiesWithCallback([&capture](int numDeleted) {
+ ++capture;
+ QCOMPARE(numDeleted, 3);
+ });
+
+ client.deleteAllCookiesWithCallback([&capture](int numDeleted) {
+ ++capture;
+ QCOMPARE(numDeleted, 1);
+ });
+
+ QTRY_COMPARE(capture, 3);
+}
+
+QTEST_MAIN(tst_QWebEngineCookieStoreClient)
+#include "tst_qwebenginecookiestoreclient.moc"
diff --git a/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.qrc b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.qrc
new file mode 100644
index 000000000..afeae268b
--- /dev/null
+++ b/tests/auto/core/qwebenginecookiestoreclient/tst_qwebenginecookiestoreclient.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/index.html</file>
+ <file>resources/content.html</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro b/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro
new file mode 100644
index 000000000..e99c7f493
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/qwebengineurlrequestinterceptor.pro
@@ -0,0 +1 @@
+include(../tests.pri)
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html
new file mode 100644
index 000000000..360ad65ef
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/content.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+<a>This is test content</a>
+</body>
+</html>
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/resources/index.html b/tests/auto/core/qwebengineurlrequestinterceptor/resources/index.html
new file mode 100644
index 000000000..a744dbd99
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/resources/index.html
@@ -0,0 +1,16 @@
+<html>
+ <head>
+ <script type="text/javascript">
+ function post() {
+ var form = document.createElement("form");
+ form.setAttribute("method", "POST");
+ document.body.appendChild(form);
+ form.submit();
+ return true;
+ }
+</script>
+ </head>
+ <body>
+ <h1>Test page</h1>
+ </body>
+</html>
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
new file mode 100644
index 000000000..ed7d7ad09
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.cpp
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "../../widgets/util.h"
+#include <QtTest/QtTest>
+#include <QtWebEngineCore/qwebengineurlrequestinterceptor.h>
+#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineWidgets/qwebengineprofile.h>
+#include <QtWebEngineWidgets/qwebengineview.h>
+
+class tst_QWebEngineUrlRequestInterceptor : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QWebEngineUrlRequestInterceptor();
+ ~tst_QWebEngineUrlRequestInterceptor();
+
+public Q_SLOTS:
+ void init();
+ void cleanup();
+
+private Q_SLOTS:
+ void initTestCase();
+ void cleanupTestCase();
+ void interceptRequest();
+};
+
+tst_QWebEngineUrlRequestInterceptor::tst_QWebEngineUrlRequestInterceptor()
+{
+}
+
+tst_QWebEngineUrlRequestInterceptor::~tst_QWebEngineUrlRequestInterceptor()
+{
+}
+
+void tst_QWebEngineUrlRequestInterceptor::init()
+{
+}
+
+void tst_QWebEngineUrlRequestInterceptor::cleanup()
+{
+}
+
+void tst_QWebEngineUrlRequestInterceptor::initTestCase()
+{
+}
+
+void tst_QWebEngineUrlRequestInterceptor::cleanupTestCase()
+{
+}
+
+class TestRequestInterceptor: public QWebEngineUrlRequestInterceptor
+{
+public:
+ QList<QUrl> observedUrls;
+ bool shouldIntercept;
+
+ bool interceptRequest(QWebEngineUrlRequestInfo &info) override
+ {
+ info.block(info.requestMethod() != QByteArrayLiteral("GET"));
+ if (info.requestUrl().toString().endsWith(QLatin1String("__placeholder__")))
+ info.redirect(QUrl("qrc:///resources/content.html"));
+
+ observedUrls.append(info.requestUrl());
+ return shouldIntercept;
+ }
+ TestRequestInterceptor(bool intercept)
+ : shouldIntercept(intercept)
+ {
+ }
+};
+
+void tst_QWebEngineUrlRequestInterceptor::interceptRequest()
+{
+ QWebEngineView view;
+ TestRequestInterceptor interceptor(/* intercept */ true);
+
+ QSignalSpy loadSpy(&view, SIGNAL(loadFinished(bool)));
+ view.page()->profile()->setRequestInterceptor(&interceptor);
+ view.load(QUrl("qrc:///resources/index.html"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ QVariant success = loadSpy.takeFirst().takeFirst();
+ QVERIFY(success.toBool());
+ loadSpy.clear();
+ QVariant ok;
+
+ view.page()->runJavaScript("post();", [&ok](const QVariant result){ ok = result; });
+ QTRY_VERIFY(ok.toBool());
+ QTRY_COMPARE(loadSpy.count(), 1);
+ success = loadSpy.takeFirst().takeFirst();
+ // We block non-GET requests, so this should not succeed.
+ QVERIFY(!success.toBool());
+ loadSpy.clear();
+
+ view.load(QUrl("qrc:///resources/__placeholder__"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ success = loadSpy.takeFirst().takeFirst();
+ // The redirection for __placeholder__ should succeed.
+ QVERIFY(success.toBool());
+ loadSpy.clear();
+ QCOMPARE(interceptor.observedUrls.count(), 4);
+
+
+ // Make sure that registering an observer does not modify the request.
+ TestRequestInterceptor observer(/* intercept */ false);
+ view.page()->profile()->setRequestInterceptor(&observer);
+ view.load(QUrl("qrc:///resources/__placeholder__"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+ success = loadSpy.takeFirst().takeFirst();
+ // Since we do not intercept, loading an invalid path should not succeed.
+ QVERIFY(!success.toBool());
+ QCOMPARE(observer.observedUrls.count(), 1);
+}
+
+QTEST_MAIN(tst_QWebEngineUrlRequestInterceptor)
+#include "tst_qwebengineurlrequestinterceptor.moc"
diff --git a/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc
new file mode 100644
index 000000000..afeae268b
--- /dev/null
+++ b/tests/auto/core/qwebengineurlrequestinterceptor/tst_qwebengineurlrequestinterceptor.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>resources/index.html</file>
+ <file>resources/content.html</file>
+</qresource>
+</RCC>
diff --git a/tests/auto/core/tests.pri b/tests/auto/core/tests.pri
new file mode 100644
index 000000000..cd6ef8615
--- /dev/null
+++ b/tests/auto/core/tests.pri
@@ -0,0 +1,17 @@
+TEMPLATE = app
+
+# FIXME: Re-enable once we want to run tests on the CI
+# CONFIG += testcase
+
+CONFIG += c++11
+
+VPATH += $$_PRO_FILE_PWD_
+TARGET = tst_$$TARGET
+
+SOURCES += $${TARGET}.cpp
+INCLUDEPATH += $$PWD
+
+exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc
+
+QT += testlib network webenginewidgets widgets
+osx: CONFIG -= app_bundle
diff --git a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
index 28a77d8cd..b5894a248 100644
--- a/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
+++ b/tests/auto/quick/inspectorserver/tst_inspectorserver.cpp
@@ -86,7 +86,7 @@ void tst_InspectorServer::prepareWebViewComponent()
m_component.reset(new QQmlComponent(engine, this));
m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n"
- "import QtWebEngine 1.1\n"
+ "import QtWebEngine 1.2\n"
"WebEngineView { }")
, QUrl());
}
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index a97739404..8a01dfa09 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
import QtWebEngine.experimental 1.0
WebEngineView {
diff --git a/tests/auto/quick/qmltests/data/directoryupload.html b/tests/auto/quick/qmltests/data/directoryupload.html
new file mode 100644
index 000000000..6a6e4580c
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/directoryupload.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+<meta name="viewport" initial-scale=1">
+<title> Directory Upload </title>
+<script src = "./titleupdate.js">
+</script>
+
+<body>
+<input type="file" id="upfile" webkitdirectory="" directory="" onchange="updateTitle()">
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/forms.html b/tests/auto/quick/qmltests/data/forms.html
new file mode 100644
index 000000000..8dc3472f2
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/forms.html
@@ -0,0 +1,40 @@
+<html>
+<head>
+ <title>Forms</title>
+ <script type="text/javascript">
+ function updateFocus() {
+ var name = window.location.hash.substring(1);
+ var element = document.getElementsByName(name)[0];
+
+ element.focus();
+ }
+ </script>
+</head>
+<body onload="updateFocus();">
+ <form>
+ <input type="url" required/>
+ <input type="submit" name="url_empty"/>
+ </form>
+ <form>
+ <input type="url" value="invalid" required/>
+ <input type="submit" name="url_invalid"/>
+ </form>
+ <form>
+ <input type="url" value="invalid" title="url_title" required/>
+ <input type="submit" name="url_title"/>
+ </form>
+
+ <form>
+ <input type="email" required/>
+ <input type="submit" name="email_empty"/>
+ </form>
+ <form>
+ <input type="email" value="invalid" required/>
+ <input type="submit" name="email_invalid"/>
+ </form>
+ <form>
+ <input type="email" value="invalid" title="email_title" required/>
+ <input type="submit" name="email_title"/>
+ </form>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/multifileupload.html b/tests/auto/quick/qmltests/data/multifileupload.html
new file mode 100644
index 000000000..cc87d8f41
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/multifileupload.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<meta name="viewport" initial-scale=1">
+<title> Mutli-file Upload </title>
+<script src = "./titleupdate.js">
+</script>
+
+<body>
+<input type="file" name="file" id="upfile" onchange="updateTitle()" multiple/>
+
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/singlefileupload.html b/tests/auto/quick/qmltests/data/singlefileupload.html
new file mode 100644
index 000000000..8469aa128
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/singlefileupload.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<meta name="viewport" initial-scale=1">
+<title> Single File Upload </title>
+<script src = "./titleupdate.js">
+</script>
+
+<body>
+<input type="file" name="file" id="upfile" onchange="updateTitle()"/>
+
+<script>
+window.onload = function() {
+document.getElementById("upfile").focus()
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/quick/qmltests/data/titleupdate.js b/tests/auto/quick/qmltests/data/titleupdate.js
new file mode 100644
index 000000000..cfcc52c60
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/titleupdate.js
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+function updateTitle()
+{
+ var inp = document.getElementById("upfile");
+ var allfiles = new String("");
+ var name = new String("");
+ for (var i = 0; i < inp.files.length; ++i) {
+ name = inp.files.item(i).name;
+ if (allfiles.length == 0)
+ allfiles = name;
+ else
+ allfiles = allfiles + "," + name;
+ }
+ document.title = allfiles;
+}
diff --git a/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml b/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml
new file mode 100644
index 000000000..eaca8822b
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_activeFocusOnPress.qml
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtTest 1.0
+
+Item {
+ id: root
+ width: 300
+ height: 400
+ TextInput {
+ id: textInput
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+ focus: true
+ text: "foo"
+ }
+
+ TestWebEngineView {
+ id: webEngineView
+ activeFocusOnPress: false
+ anchors {
+ top: textInput.bottom
+ left: parent.left
+ right: parent.right
+ bottom: parent.bottom
+ }
+
+ TestCase {
+ name: "ActiveFocusOnPress"
+ when:windowShown
+
+ function test_activeFocusOnPress() {
+ textInput.forceActiveFocus()
+ verify(textInput.activeFocus)
+ mouseClick(root, 150, 300, Qt.LeftButton)
+ verify(textInput.activeFocus)
+ }
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
index dfb983c43..51c1d5580 100644
--- a/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
+++ b/tests/auto/quick/qmltests/data/tst_desktopBehaviorLoadHtml.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_favIconLoad.qml b/tests/auto/quick/qmltests/data/tst_favIconLoad.qml
index 73190f1bd..df5479eec 100644
--- a/tests/auto/quick/qmltests/data/tst_favIconLoad.qml
+++ b/tests/auto/quick/qmltests/data/tst_favIconLoad.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
new file mode 100644
index 000000000..02b2dd024
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.2
+import "../mock-delegates/TestParams" 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: titleSpy
+ target: webEngineView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ name: "WebEngineViewSingleFileUpload"
+ when: windowShown
+
+ function init() {
+ FilePickerParams.filePickerOpened = false
+ FilePickerParams.selectFiles = false
+ FilePickerParams.selectedFilesUrl = []
+ titleSpy.clear()
+ }
+
+ // FIXME: Almost every second url loading progress does get stuck at about 90 percent, so the loadFinished signal won't arrive.
+ // This cleanup function is a workaround for this problem.
+ function cleanup() {
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ webEngineView.waitForLoadSucceeded()
+ }
+
+ function test_acceptSingleFileSelection() {
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ FilePickerParams.selectFiles = true
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html"))
+
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ wait(100) // The ui delegate is invoked asynchronously
+ verify(FilePickerParams.filePickerOpened)
+ titleSpy.wait()
+ compare(webEngineView.title, "test1.html")
+ }
+
+ function test_acceptMultipleFilesSelection() {
+ webEngineView.url = Qt.resolvedUrl("multifileupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ FilePickerParams.selectFiles = true
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test1.html"))
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("test2.html"))
+
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ wait(100)
+ verify(FilePickerParams.filePickerOpened)
+ titleSpy.wait()
+ compare(webEngineView.title, "test1.html,test2.html")
+ }
+
+ function test_acceptDirectory() {
+ webEngineView.url = Qt.resolvedUrl("directoryupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ FilePickerParams.selectFiles = true
+ FilePickerParams.selectedFilesUrl.push(Qt.resolvedUrl("../data"))
+
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ wait(100) // The ui delegate is invoked asynchronously
+ verify(FilePickerParams.filePickerOpened)
+ titleSpy.wait()
+ compare(webEngineView.title, "data")
+ }
+
+ function test_reject() {
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ titleSpy.clear()
+ keyPress(Qt.Key_Enter) // Focus is on the button. Open FileDialog.
+ wait(100)
+ compare(titleSpy.count, 0)
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_findText.qml b/tests/auto/quick/qmltests/data/tst_findText.qml
index b51da0b2e..9c4aa48c1 100644
--- a/tests/auto/quick/qmltests/data/tst_findText.qml
+++ b/tests/auto/quick/qmltests/data/tst_findText.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_formValidation.qml b/tests/auto/quick/qmltests/data/tst_formValidation.qml
new file mode 100644
index 000000000..4acb7ce63
--- /dev/null
+++ b/tests/auto/quick/qmltests/data/tst_formValidation.qml
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebEngine 1.2
+import QtWebEngine.testsupport 1.0
+
+TestWebEngineView {
+ id: webEngineView
+ width: 400
+ height: 300
+
+ testSupport: WebEngineTestSupport {
+ id: testSupportAPI
+ }
+
+ SignalSpy {
+ id: showSpy
+ target: testSupportAPI
+ signalName: "validationMessageShown"
+ }
+
+ TestCase {
+ name: "WebEngineViewFormValidation"
+ when: windowShown
+
+ function init() {
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+ showSpy.clear()
+ }
+
+ function test_urlForm() {
+ webEngineView.url = Qt.resolvedUrl("forms.html#url_empty")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[0][0], "Please fill out this field.")
+
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.url = Qt.resolvedUrl("forms.html#url_invalid")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[1][0], "Please enter a URL.")
+
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.url = Qt.resolvedUrl("forms.html#url_title")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[2][1], "url_title")
+ }
+
+ function test_emailForm() {
+ webEngineView.url = Qt.resolvedUrl("forms.html#email_empty")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[0][0], "Please fill out this field.")
+
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.url = Qt.resolvedUrl("forms.html#email_invalid")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[1][0], "Please include an '@' in the email address. 'invalid' is missing an '@'.")
+
+ webEngineView.url = Qt.resolvedUrl("about:blank")
+ verify(webEngineView.waitForLoadSucceeded())
+
+ webEngineView.url = Qt.resolvedUrl("forms.html#email_title")
+ verify(webEngineView.waitForLoadSucceeded())
+ keyPress(Qt.Key_Enter)
+ showSpy.wait()
+ compare(showSpy.signalArguments[2][1], "email_title")
+ }
+ }
+}
diff --git a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
index 58a49da5a..75b45bfac 100644
--- a/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
+++ b/tests/auto/quick/qmltests/data/tst_javaScriptDialogs.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.0
+import QtWebEngine 1.2
import "../mock-delegates/TestParams" 1.0
TestWebEngineView {
diff --git a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
index 230ee9635..c127d7391 100644
--- a/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
+++ b/tests/auto/quick/qmltests/data/tst_keyboardModifierMapping.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_linkHovered.qml b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
index c9fbd5520..31d90615b 100644
--- a/tests/auto/quick/qmltests/data/tst_linkHovered.qml
+++ b/tests/auto/quick/qmltests/data/tst_linkHovered.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_loadFail.qml b/tests/auto/quick/qmltests/data/tst_loadFail.qml
index 0885fc193..c2a4b6e13 100644
--- a/tests/auto/quick/qmltests/data/tst_loadFail.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadFail.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
import QtWebEngine.experimental 1.0
import QtWebEngine.testsupport 1.0
diff --git a/tests/auto/quick/qmltests/data/tst_loadHtml.qml b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
index b8acd0dd7..ee1149b16 100644
--- a/tests/auto/quick/qmltests/data/tst_loadHtml.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadHtml.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_loadProgress.qml b/tests/auto/quick/qmltests/data/tst_loadProgress.qml
index 9f8b6f6f7..096861c4d 100644
--- a/tests/auto/quick/qmltests/data/tst_loadProgress.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadProgress.qml
@@ -41,22 +41,39 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
width: 400
height: 300
+ property var loadProgressArray: []
+
+ onLoadProgressChanged: {
+ loadProgressArray.push(webEngineView.loadProgress)
+ }
+
TestCase {
name: "WebEngineViewLoadProgress"
function test_loadProgress() {
compare(webEngineView.loadProgress, 0)
+ loadProgressArray = []
+
webEngineView.url = Qt.resolvedUrl("test1.html")
- compare(webEngineView.loadProgress, 0)
verify(webEngineView.waitForLoadSucceeded())
- compare(webEngineView.loadProgress, 100)
+
+ // Test whether the chromium emits progress numbers in ascending order
+ var loadProgressMin = 0
+ for (var i in loadProgressArray) {
+ var loadProgress = loadProgressArray[i]
+ verify(loadProgressMin <= loadProgress)
+ loadProgressMin = loadProgress
+ }
+
+ // The progress must be 100% at the end
+ compare(loadProgressArray[loadProgressArray.length - 1], 100)
}
}
}
diff --git a/tests/auto/quick/qmltests/data/tst_loadProgressSignal.qml b/tests/auto/quick/qmltests/data/tst_loadProgressSignal.qml
index 8e2e99b64..7b0bac61b 100644
--- a/tests/auto/quick/qmltests/data/tst_loadProgressSignal.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadProgressSignal.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml b/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
index 2400a5ed6..fb692c472 100644
--- a/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadRecursionCrash.qml
@@ -41,7 +41,7 @@
import QtQuick 2.3
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
Item {
width: 300
diff --git a/tests/auto/quick/qmltests/data/tst_loadUrl.qml b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
index 922925b48..c8abf2bb0 100644
--- a/tests/auto/quick/qmltests/data/tst_loadUrl.qml
+++ b/tests/auto/quick/qmltests/data/tst_loadUrl.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
import QtWebEngine.experimental 1.0
TestWebEngineView {
diff --git a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
index 3acde3abc..f7875bb78 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationHistory.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
index 72eb0aac9..7d49cda90 100644
--- a/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
+++ b/tests/auto/quick/qmltests/data/tst_navigationRequested.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_properties.qml b/tests/auto/quick/qmltests/data/tst_properties.qml
index 738ef532d..9418252cb 100644
--- a/tests/auto/quick/qmltests/data/tst_properties.qml
+++ b/tests/auto/quick/qmltests/data/tst_properties.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
index 6cf3a71fb..07e7130c6 100644
--- a/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
+++ b/tests/auto/quick/qmltests/data/tst_runJavaScript.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_titleChanged.qml b/tests/auto/quick/qmltests/data/tst_titleChanged.qml
index adc8564c0..8d9dae0a4 100644
--- a/tests/auto/quick/qmltests/data/tst_titleChanged.qml
+++ b/tests/auto/quick/qmltests/data/tst_titleChanged.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
TestWebEngineView {
id: webEngineView
diff --git a/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml b/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
index 1c32c73a9..5fefd0fe5 100644
--- a/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
+++ b/tests/auto/quick/qmltests/data/tst_unhandledKeyEventPropagation.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
Item {
id: parentItem
diff --git a/tests/auto/quick/qmltests/data/tst_userScripts.qml b/tests/auto/quick/qmltests/data/tst_userScripts.qml
index a9ed933d9..8a3b8207f 100644
--- a/tests/auto/quick/qmltests/data/tst_userScripts.qml
+++ b/tests/auto/quick/qmltests/data/tst_userScripts.qml
@@ -41,7 +41,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
Item {
WebEngineScript {
diff --git a/tests/auto/quick/qmltests/data/tst_webchannel.qml b/tests/auto/quick/qmltests/data/tst_webchannel.qml
index dce585b67..51e37d50e 100644
--- a/tests/auto/quick/qmltests/data/tst_webchannel.qml
+++ b/tests/auto/quick/qmltests/data/tst_webchannel.qml
@@ -40,7 +40,7 @@
import QtQuick 2.0
import QtTest 1.0
-import QtWebEngine 1.1
+import QtWebEngine 1.2
import QtWebEngine.experimental 1.0
import QtWebChannel 1.0
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml
new file mode 100644
index 000000000..5ee231c19
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import "../../TestParams" 1.0
+
+QtObject {
+ property bool selectMultiple: false;
+ property bool selectExisting: false;
+ property bool selectFolder: false;
+
+ signal filesSelected(var fileList);
+ signal rejected();
+
+ function open() {
+ FilePickerParams.filePickerOpened = true;
+ if (FilePickerParams.selectFiles)
+ filesSelected(FilePickerParams.selectedFilesUrl)
+ else
+ rejected()
+ }
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/qmldir b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/qmldir
index 1ebabd335..cf8ac0512 100644
--- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/qmldir
+++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/UIDelegates/qmldir
@@ -1,4 +1,5 @@
module QtWebEngine.UIDelegates
AlertDialog 1.0 AlertDialog.qml
ConfirmDialog 1.0 ConfirmDialog.qml
+FilePicker 1.0 FilePicker.qml
PromptDialog 1.0 PromptDialog.qml
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
new file mode 100644
index 000000000..f0f2d9368
--- /dev/null
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/FilePickerParams.qml
@@ -0,0 +1,49 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+pragma Singleton
+import QtQuick 2.0
+
+QtObject {
+ property var selectedFilesUrl: [];
+ property bool selectFiles: false;
+ property bool filePickerOpened: false;
+}
diff --git a/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
index f2ed87a75..a21dd8236 100644
--- a/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
+++ b/tests/auto/quick/qmltests/mock-delegates/TestParams/qmldir
@@ -1,4 +1,5 @@
# QML module so that the autotests can set testing parameters
module TestParams
+singleton FilePickerParams 1.0 FilePickerParams.qml
singleton JSDialogParams 1.0 JSDialogParams.qml
diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro
index 9f6f55275..01517af47 100644
--- a/tests/auto/quick/qmltests/qmltests.pro
+++ b/tests/auto/quick/qmltests/qmltests.pro
@@ -12,23 +12,30 @@ OTHER_FILES += \
$$PWD/data/change-document-title.js \
$$PWD/data/download.zip \
$$PWD/data/confirm.html \
+ $$PWD/data/directoryupload.html \
$$PWD/data/favicon.html \
$$PWD/data/favicon.png \
$$PWD/data/favicon2.html \
+ $$PWD/data/forms.html \
$$PWD/data/geolocation.html \
$$PWD/data/javascript.html \
$$PWD/data/link.html \
$$PWD/data/prompt.html \
+ $$PWD/data/multifileupload.html \
$$PWD/data/redirect.html \
+ $$PWD/data/singlefileupload.html \
$$PWD/data/small-favicon.png \
$$PWD/data/test1.html \
$$PWD/data/test2.html \
$$PWD/data/test3.html \
$$PWD/data/test4.html \
$$PWD/data/keyboardModifierMapping.html \
+ $$PWD/data/titleupdate.js \
$$PWD/data/tst_desktopBehaviorLoadHtml.qml \
$$PWD/data/tst_download.qml \
$$PWD/data/tst_favIconLoad.qml \
+ $$PWD/data/tst_filePicker.qml \
+ $$PWD/data/tst_formValidation.qml \
$$PWD/data/tst_geopermission.qml \
$$PWD/data/tst_javaScriptDialogs.qml \
$$PWD/data/tst_linkHovered.qml \
@@ -49,12 +56,13 @@ OTHER_FILES += \
$$PWD/data/tst_keyboardModifierMapping.qml \
$$PWD/mock-delegates/QtWebEngine/UIDelegates/AlertDialog.qml \
$$PWD/mock-delegates/QtWebEngine/UIDelegates/ConfirmDialog.qml \
+ $$PWD/mock-delegates/QtWebEngine/UIDelegates/FilePicker.qml \
$$PWD/mock-delegates/QtWebEngine/UIDelegates/PromptDialog.qml \
$$PWD/mock-delegates/QtWebEngine/UIDelegates/qmldir \
+ $$PWD/mock-delegates/TestParams/FilePickerParams.qml \
$$PWD/mock-delegates/TestParams/JSDialogParams.qml \
$$PWD/mock-delegates/TestParams/qmldir \
-
load(qt_build_paths)
DEFINES += QUICK_TEST_SOURCE_DIR=\\\"$$re_escape($$PWD$${QMAKE_DIR_SEP}data)\\\"
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 2cbcf0979..40dc3cb61 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -73,7 +73,7 @@ tst_QQuickWebEngineView::tst_QQuickWebEngineView()
static QQmlEngine *engine = new QQmlEngine(this);
m_component.reset(new QQmlComponent(engine, this));
m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n"
- "import QtWebEngine 1.1\n"
+ "import QtWebEngine 1.2\n"
"WebEngineView {}")
, QUrl());
}
@@ -335,12 +335,10 @@ void tst_QQuickWebEngineView::titleUpdate()
webEngineView()->setUrl(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "html/file_that_does_not_exist.html")));
QVERIFY(waitForLoadFailed(webEngineView()));
QCOMPARE(titleSpy.size(), 0);
-
}
void tst_QQuickWebEngineView::transparentWebEngineViews()
{
-
showWebEngineView();
// This should not crash.
@@ -348,13 +346,10 @@ void tst_QQuickWebEngineView::transparentWebEngineViews()
webEngineView1->setParentItem(m_window->contentItem());
QScopedPointer<QQuickWebEngineView> webEngineView2(newWebEngineView());
webEngineView2->setParentItem(m_window->contentItem());
-#if !defined(QQUICKWEBENGINEVIEW_EXPERIMENTAL_TRANSPARENTBACKGROUND)
- QWARN("QQUICKWEBENGINEVIEW_EXPERIMENTAL_TRANSPARENTBACKGROUND");
-#else
- QVERIFY(!webEngineView1->experimental()->transparentBackground());
- webEngineView2->experimental()->setTransparentBackground(true);
- QVERIFY(webEngineView2->experimental()->transparentBackground());
-#endif
+
+ QVERIFY(webEngineView1->backgroundColor() != Qt::transparent);
+ webEngineView2->setBackgroundColor(Qt::transparent);
+ QVERIFY(webEngineView2->backgroundColor() == Qt::transparent);
webEngineView1->setSize(QSizeF(300, 400));
webEngineView1->loadHtml("<html><body bgcolor=\"red\"></body></html>");
@@ -367,7 +362,24 @@ void tst_QQuickWebEngineView::transparentWebEngineViews()
webEngineView2->setVisible(true);
QTest::qWait(200);
- // FIXME: test actual rendering results; https://bugs.webkit.org/show_bug.cgi?id=80609.
+
+ // Result image: black text on red background.
+ QImage grabbedWindow = m_window->grabWindow();
+
+ QSet<int> redComponents;
+ for (int i = 0, width = grabbedWindow.width(); i < width; i++) {
+ for (int j = 0, height = grabbedWindow.height(); j < height; j++) {
+ QColor color(grabbedWindow.pixel(i, j));
+ redComponents.insert(color.red());
+ // There are no green or blue components between red and black.
+ QVERIFY(color.green() == 0);
+ QVERIFY(color.blue() == 0);
+ }
+ }
+
+ QVERIFY(redComponents.count() > 1);
+ QVERIFY(redComponents.contains(0)); // black
+ QVERIFY(redComponents.contains(255)); // red
}
void tst_QQuickWebEngineView::inputMethod()
diff --git a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
index 5d15537b3..e0e876fc8 100644
--- a/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
+++ b/tests/auto/quick/qquickwebengineviewgraphics/tst_qquickwebengineviewgraphics.cpp
@@ -184,7 +184,7 @@ void tst_QQuickWebEngineViewGraphics::reparentToOtherWindow()
void tst_QQuickWebEngineViewGraphics::setHtml(const QString &html)
{
QString htmlData = QUrl::toPercentEncoding(html);
- QString qmlData = QUrl::toPercentEncoding(QStringLiteral("import QtQuick 2.0; import QtWebEngine 1.1; WebEngineView { width: 150; height: 150; url: loadUrl }"));
+ QString qmlData = QUrl::toPercentEncoding(QStringLiteral("import QtQuick 2.0; import QtWebEngine 1.2; WebEngineView { width: 150; height: 150; url: loadUrl }"));
m_view->rootContext()->setContextProperty("loadUrl", QUrl(QStringLiteral("data:text/html,%1").arg(htmlData)));
m_view->setSource(QUrl(QStringLiteral("data:text/plain,%1").arg(qmlData)));
m_view->create();
diff --git a/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro b/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro
+++ b/tests/auto/widgets/qwebengineaccessibility/qwebengineaccessibility.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebengineframe/qwebengineframe.pro b/tests/auto/widgets/qwebengineframe/qwebengineframe.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebengineframe/qwebengineframe.pro
+++ b/tests/auto/widgets/qwebengineframe/qwebengineframe.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro b/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro
+++ b/tests/auto/widgets/qwebenginehistory/qwebenginehistory.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro b/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro
+++ b/tests/auto/widgets/qwebenginehistoryinterface/qwebenginehistoryinterface.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro b/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro
+++ b/tests/auto/widgets/qwebengineinspector/qwebengineinspector.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro
index e56bbe8f7..70786e70f 100644
--- a/tests/auto/widgets/qwebenginepage/qwebenginepage.pro
+++ b/tests/auto/widgets/qwebenginepage/qwebenginepage.pro
@@ -1,3 +1,2 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
QT *= core-private gui-private
diff --git a/tests/auto/widgets/qwebenginepage/resources/fullscreen.html b/tests/auto/widgets/qwebenginepage/resources/fullscreen.html
new file mode 100644
index 000000000..84771ca85
--- /dev/null
+++ b/tests/auto/widgets/qwebenginepage/resources/fullscreen.html
@@ -0,0 +1,10 @@
+<html>
+<body onkeypress='onKeyPress()'>
+<a>This is test content</a>
+<script>
+function onKeyPress() {
+ document.documentElement.webkitRequestFullScreen();
+}
+</script>
+</body>
+</html>
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 9562871b3..ba5366460 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -192,6 +192,7 @@ private Q_SLOTS:
#endif
void runJavaScript();
+ void fullScreenRequested();
private:
QWebEngineView* m_view;
@@ -1176,6 +1177,10 @@ public:
int isSelectionCollapsed() {
return evaluateJavaScriptSync(this, "window.getSelection().getRangeAt(0).collapsed").toBool();
}
+ bool hasSelection()
+ {
+ return !selectedText().isEmpty();
+ }
};
void tst_QWebEnginePage::cursorMovements()
@@ -1380,17 +1385,19 @@ void tst_QWebEnginePage::cursorMovements()
void tst_QWebEnginePage::textSelection()
{
-#if !defined(QWEBENGINEPAGE_EVALUATEJAVASCRIPT)
- QSKIP("QWEBENGINEPAGE_EVALUATEJAVASCRIPT");
-#else
- CursorTrackedPage* page = new CursorTrackedPage;
+ QWebEngineView *view = new QWebEngineView;
+ CursorTrackedPage *page = new CursorTrackedPage;
QString content("<html><body><p id=one>The quick brown fox</p>" \
"<p id=two>jumps over the lazy dog</p>" \
"<p>May the source<br/>be with you!</p></body></html>");
+ page->setView(view);
+ QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool)));
page->setHtml(content);
+ QTRY_COMPARE(loadSpy.count(), 1);
// these actions must exist
QVERIFY(page->action(QWebEnginePage::SelectAll) != 0);
+#if defined(QWEBENGINEPAGE_SELECTACTIONS)
QVERIFY(page->action(QWebEnginePage::SelectNextChar) != 0);
QVERIFY(page->action(QWebEnginePage::SelectPreviousChar) != 0);
QVERIFY(page->action(QWebEnginePage::SelectNextWord) != 0);
@@ -1418,6 +1425,7 @@ void tst_QWebEnginePage::textSelection()
QCOMPARE(page->action(QWebEnginePage::SelectEndOfBlock)->isEnabled(), false);
QCOMPARE(page->action(QWebEnginePage::SelectStartOfDocument)->isEnabled(), false);
QCOMPARE(page->action(QWebEnginePage::SelectEndOfDocument)->isEnabled(), false);
+#endif
// ..but SelectAll is awalys enabled
QCOMPARE(page->action(QWebEnginePage::SelectAll)->isEnabled(), true);
@@ -1432,13 +1440,15 @@ void tst_QWebEnginePage::textSelection()
"getSelection().addRange(range);";
evaluateJavaScriptSync(page, selectScript);
QCOMPARE(page->selectedText().trimmed(), QString::fromLatin1("The quick brown fox"));
+#if defined(QWEBENGINEPAGE_SELECTEDHTML)
QRegExp regExp(" style=\".*\"");
regExp.setMinimal(true);
QCOMPARE(page->selectedHtml().trimmed().replace(regExp, ""), QString::fromLatin1("<p id=\"one\">The quick brown fox</p>"));
-
+#endif
// Make sure hasSelection returns true, since there is selected text now...
QCOMPARE(page->hasSelection(), true);
+#if defined(QWEBENGINEPAGE_SELECTACTIONS)
// here the actions are enabled after a selection has been created
QCOMPARE(page->action(QWebEnginePage::SelectNextChar)->isEnabled(), true);
QCOMPARE(page->action(QWebEnginePage::SelectPreviousChar)->isEnabled(), true);
@@ -1474,9 +1484,10 @@ void tst_QWebEnginePage::textSelection()
QCOMPARE(page->action(QWebEnginePage::SelectEndOfBlock)->isEnabled(), true);
QCOMPARE(page->action(QWebEnginePage::SelectStartOfDocument)->isEnabled(), true);
QCOMPARE(page->action(QWebEnginePage::SelectEndOfDocument)->isEnabled(), true);
+#endif
delete page;
-#endif
+ delete view;
}
void tst_QWebEnginePage::textEditing()
@@ -3109,13 +3120,16 @@ void tst_QWebEnginePage::testStopScheduledPageRefresh()
void tst_QWebEnginePage::findText()
{
- m_view->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>"));
-#if defined(QWEBENGINEPAGE_TRIGGERACTION_SELECTALL)
+ QSignalSpy loadSpy(m_page, SIGNAL(loadFinished(bool)));
+ m_page->setHtml(QString("<html><head></head><body><div>foo bar</div></body></html>"));
+ QTRY_COMPARE(loadSpy.count(), 1);
m_page->triggerAction(QWebEnginePage::SelectAll);
- QVERIFY(!m_page->selectedText().isEmpty());
+ QTRY_COMPARE(m_page->hasSelection(), true);
+#if defined(QWEBENGINEPAGE_SELECTEDHTML)
QVERIFY(!m_page->selectedHtml().isEmpty());
#endif
m_page->findText("");
+ QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue);
QVERIFY(m_page->selectedText().isEmpty());
#if defined(QWEBENGINEPAGE_SELECTEDHTML)
QVERIFY(m_page->selectedHtml().isEmpty());
@@ -3129,6 +3143,7 @@ void tst_QWebEnginePage::findText()
QVERIFY(m_page->selectedHtml().contains(subString));
#endif
m_page->findText("");
+ QEXPECT_FAIL("", "Unsupported: findText only highlights and doesn't update the selection.", Continue);
QVERIFY(m_page->selectedText().isEmpty());
#if defined(QWEBENGINEPAGE_SELECTEDHTML)
QVERIFY(m_page->selectedHtml().isEmpty());
@@ -3674,41 +3689,115 @@ void tst_QWebEnginePage::cssMediaTypePageSetting()
#endif
}
-class JavaScriptCallback
+class JavaScriptCallbackBase
+{
+public:
+ JavaScriptCallbackBase()
+ {
+ if (watcher)
+ QMetaObject::invokeMethod(watcher, "add");
+ }
+
+ void operator() (const QVariant &result)
+ {
+ check(result);
+ if (watcher)
+ QMetaObject::invokeMethod(watcher, "notify");
+ }
+
+protected:
+ virtual void check(const QVariant &result) = 0;
+
+private:
+ friend class JavaScriptCallbackWatcher;
+ static QPointer<QObject> watcher;
+};
+
+QPointer<QObject> JavaScriptCallbackBase::watcher = 0;
+
+class JavaScriptCallback : public JavaScriptCallbackBase
{
public:
JavaScriptCallback() { }
JavaScriptCallback(const QVariant& _expected) : expected(_expected) { }
- virtual void operator() (const QVariant& result) {
+
+ void check(const QVariant& result) Q_DECL_OVERRIDE
+ {
QVERIFY(result.isValid());
QCOMPARE(result, expected);
}
+
private:
QVariant expected;
};
-class JavaScriptCallbackNull
+class JavaScriptCallbackNull : public JavaScriptCallbackBase
{
public:
- virtual void operator() (const QVariant& result) {
+ void check(const QVariant& result) Q_DECL_OVERRIDE
+ {
QVERIFY(result.isNull());
// FIXME: Returned null values are currently invalid QVariants.
// QVERIFY(result.isValid());
}
};
-class JavaScriptCallbackUndefined
+class JavaScriptCallbackUndefined : public JavaScriptCallbackBase
{
public:
- virtual void operator() (const QVariant& result) {
+ void check(const QVariant& result) Q_DECL_OVERRIDE
+ {
QVERIFY(result.isNull());
QVERIFY(!result.isValid());
}
};
+class JavaScriptCallbackWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ JavaScriptCallbackWatcher()
+ {
+ Q_ASSERT(!JavaScriptCallbackBase::watcher);
+ JavaScriptCallbackBase::watcher = this;
+ }
+
+ Q_INVOKABLE void add()
+ {
+ available++;
+ }
+
+ Q_INVOKABLE void notify()
+ {
+ called++;
+ if (called == available)
+ emit allCalled();
+ }
+
+ bool wait(int maxSeconds = 30)
+ {
+ if (called == available)
+ return true;
+
+ QTestEventLoop loop;
+ connect(this, SIGNAL(allCalled()), &loop, SLOT(exitLoop()));
+ loop.enterLoop(maxSeconds);
+ return !loop.timeout();
+ }
+
+signals:
+ void allCalled();
+
+private:
+ int available = 0;
+ int called = 0;
+};
+
+
void tst_QWebEnginePage::runJavaScript()
{
TestPage page;
+ JavaScriptCallbackWatcher watcher;
JavaScriptCallback callbackBool(QVariant(false));
page.runJavaScript("false", QWebEngineCallback<const QVariant&>(callbackBool));
@@ -3734,10 +3823,63 @@ void tst_QWebEnginePage::runJavaScript()
JavaScriptCallbackNull callbackNull;
page.runJavaScript("null", QWebEngineCallback<const QVariant&>(callbackNull));
- JavaScriptCallbackNull callbackUndefined;
+ JavaScriptCallbackUndefined callbackUndefined;
page.runJavaScript("undefined", QWebEngineCallback<const QVariant&>(callbackUndefined));
+ QVERIFY(watcher.wait());
+}
+
+class FullScreenPage : public QWebEnginePage {
+ Q_OBJECT
+public:
+ FullScreenPage(QObject* parent = 0)
+ : QWebEnginePage(parent)
+ , m_isFullScreen(true)
+ { }
+
+ void setIsFullScreen(bool b) { m_isFullScreen = b; }
+
+protected:
+ bool isFullScreen() override
+ {
+ return m_isFullScreen;
+ }
+ bool m_isFullScreen;
+};
+
+void tst_QWebEnginePage::fullScreenRequested()
+{
+ JavaScriptCallbackWatcher watcher;
+ FullScreenPage* page = new FullScreenPage;
+ QWebEngineView* view = new QWebEngineView;
+ view->setPage(page);
+ view->show();
+
+ page->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
+
+ QSignalSpy loadSpy(view, SIGNAL(loadFinished(bool)));
+ page->load(QUrl("qrc:///resources/fullscreen.html"));
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true));
+ page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(false));
+ QVERIFY(watcher.wait());
+
+ // FullscreenRequest must be a user gesture
+ QTest::keyPress(qApp->focusWindow(), Qt::Key_Space);
QTest::qWait(100);
+ page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(true));
+ page->runJavaScript("document.webkitExitFullscreen()", JavaScriptCallbackUndefined());
+ QVERIFY(watcher.wait());
+ page->setIsFullScreen(false);
+ page->runJavaScript("document.webkitFullscreenEnabled", JavaScriptCallback(true));
+ QTest::keyPress(qApp->focusWindow(), Qt::Key_Space);
+ QVERIFY(watcher.wait());
+ page->runJavaScript("document.webkitIsFullScreen", JavaScriptCallback(false));
+ QVERIFY(watcher.wait());
+
+ delete view;
+ delete page;
}
QTEST_MAIN(tst_QWebEnginePage)
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
index 994d71b43..0a8995090 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc
@@ -1,5 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
+ <file>resources/content.html</file>
<file>resources/index.html</file>
<file>resources/frame_a.html</file>
<file>resources/frame_c.html</file>
@@ -7,7 +8,7 @@
<file>resources/iframe2.html</file>
<file>resources/iframe3.html</file>
<file>resources/framedindex.html</file>
- <file>resources/content.html</file>
+ <file>resources/fullscreen.html</file>
<file>resources/script.html</file>
<file>resources/user.css</file>
</qresource>
diff --git a/tests/auto/widgets/qwebenginescript/qwebenginescript.pro b/tests/auto/widgets/qwebenginescript/qwebenginescript.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebenginescript/qwebenginescript.pro
+++ b/tests/auto/widgets/qwebenginescript/qwebenginescript.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/qwebengineview/qwebengineview.pro b/tests/auto/widgets/qwebengineview/qwebengineview.pro
index ff6c49628..e99c7f493 100644
--- a/tests/auto/widgets/qwebengineview/qwebengineview.pro
+++ b/tests/auto/widgets/qwebengineview/qwebengineview.pro
@@ -1,2 +1 @@
include(../tests.pri)
-exists($${TARGET}.qrc):RESOURCES += $${TARGET}.qrc
diff --git a/tests/auto/widgets/tests.pri b/tests/auto/widgets/tests.pri
index 8d86ac93e..afdf46f42 100644
--- a/tests/auto/widgets/tests.pri
+++ b/tests/auto/widgets/tests.pri
@@ -11,6 +11,8 @@ TARGET = tst_$$TARGET
SOURCES += $${TARGET}.cpp
INCLUDEPATH += $$PWD
+exists($$_PRO_FILE_PWD_/$${TARGET}.qrc): RESOURCES += $${TARGET}.qrc
+
QT += testlib network webenginewidgets widgets
macx: CONFIG -= app_bundle
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index 83067fe8d..2b485fc0f 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -166,6 +166,9 @@ static inline QUrl baseUrlSync(QWebEnginePage *page)
#define W_QSKIP(a, b) QSKIP(a)
#define W_QTEST_MAIN(TestObject, params) \
+QT_BEGIN_NAMESPACE \
+QTEST_ADD_GPU_BLACKLIST_SUPPORT_DEFS \
+QT_END_NAMESPACE \
int main(int argc, char *argv[]) \
{ \
QVector<const char *> w_argv(argc); \
@@ -178,6 +181,8 @@ int main(int argc, char *argv[]) \
QApplication app(w_argc, const_cast<char **>(w_argv.data())); \
app.setAttribute(Qt::AA_Use96Dpi, true); \
QTEST_DISABLE_KEYPAD_NAVIGATION \
+ QTEST_ADD_GPU_BLACKLIST_SUPPORT \
TestObject tc; \
+ QTEST_SET_MAIN_SOURCE_PATH \
return QTest::qExec(&tc, argc, argv); \
}
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 2dbb498d1..b2df0880d 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -4,7 +4,6 @@ CONFIG += ordered
SUBDIRS += \
qwebengineaccessibility \
- qwebengineframe \
qwebenginepage \
qwebenginehistoryinterface \
qwebengineview \
diff --git a/tests/quicktestbrowser/ApplicationRoot.qml b/tests/quicktestbrowser/ApplicationRoot.qml
index 71737694d..5641b89a3 100644
--- a/tests/quicktestbrowser/ApplicationRoot.qml
+++ b/tests/quicktestbrowser/ApplicationRoot.qml
@@ -44,6 +44,8 @@ import QtWebEngine 1.1
QtObject {
id: root
+ property bool thirdPartyCookiesEnabled: true
+
property QtObject testProfile: WebEngineProfile {
storageName: "Test"
}
diff --git a/tests/quicktestbrowser/BrowserWindow.qml b/tests/quicktestbrowser/BrowserWindow.qml
index f93a6ccd1..ca0b6499b 100644
--- a/tests/quicktestbrowser/BrowserWindow.qml
+++ b/tests/quicktestbrowser/BrowserWindow.qml
@@ -39,7 +39,7 @@
****************************************************************************/
import QtQuick 2.1
-import QtWebEngine 1.1
+import QtWebEngine 1.2
import QtWebEngine.experimental 1.0
import QtQuick.Controls 1.0
@@ -76,6 +76,8 @@ ApplicationWindow {
property alias autoLoadImages: loadImages.checked;
property alias javaScriptEnabled: javaScriptEnabled.checked;
property alias errorPageEnabled: errorPageEnabled.checked;
+ property alias pluginsEnabled: pluginsEnabled.checked;
+ property alias thirdPartyCookiesEnabled: thirdPartyCookiesEnabled.checked;
}
// Make sure the Qt.WindowFullscreenButtonHint is set on OS X.
@@ -245,6 +247,19 @@ ApplicationWindow {
checked: true
}
MenuItem {
+ id: pluginsEnabled
+ text: "Plugins On"
+ checkable: true
+ checked: true
+ }
+ MenuItem {
+ id: thirdPartyCookiesEnabled
+ text: "Third party cookies enabled"
+ checkable: true
+ checked: true
+ onToggled: applicationRoot.thirdPartyCookiesEnabled = checked
+ }
+ MenuItem {
id: offTheRecordEnabled
text: "Off The Record"
checkable: true
@@ -347,6 +362,7 @@ ApplicationWindow {
settings.autoLoadImages: appSettings.autoLoadImages
settings.javascriptEnabled: appSettings.javaScriptEnabled
settings.errorPageEnabled: appSettings.errorPageEnabled
+ settings.pluginsEnabled: appSettings.pluginsEnabled
onCertificateError: {
if (!acceptedCertificates.shouldAutoAccept(error)){
diff --git a/tests/quicktestbrowser/main.cpp b/tests/quicktestbrowser/main.cpp
index 7171baf77..166da4d5b 100644
--- a/tests/quicktestbrowser/main.cpp
+++ b/tests/quicktestbrowser/main.cpp
@@ -50,7 +50,9 @@ typedef QGuiApplication Application;
#endif
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
+#include <QtQml/QQmlComponent>
#include <QtWebEngine/qtwebengineglobal.h>
+#include <QtWebEngineCore/qwebenginecookiestoreclient.h>
static QUrl startupUrl()
{
@@ -67,6 +69,24 @@ static QUrl startupUrl()
return QUrl(QStringLiteral("http://qt.io/"));
}
+class CookieClient: public QWebEngineCookieStoreClient
+{
+ QMetaProperty m_settingProperty;
+ const QObject *m_object;
+public:
+ CookieClient(const QObject *object)
+ : m_object(object)
+ {
+ const QMetaObject *rootMeta = object->metaObject();
+ int index = rootMeta->indexOfProperty("thirdPartyCookiesEnabled");
+ Q_ASSERT(index != -1);
+ m_settingProperty = rootMeta->property(index);
+ }
+ virtual bool acceptCookieFromUrl(const QByteArray &, const QUrl &) {
+ return m_settingProperty.read(m_object).toBool();
+ }
+};
+
int main(int argc, char **argv)
{
Application app(argc, argv);
@@ -80,7 +100,25 @@ int main(int argc, char **argv)
Utils utils;
appEngine.rootContext()->setContextProperty("utils", &utils);
appEngine.load(QUrl("qrc:/ApplicationRoot.qml"));
- QMetaObject::invokeMethod(appEngine.rootObjects().first(), "load", Q_ARG(QVariant, startupUrl()));
+ QObject *rootObject = appEngine.rootObjects().first();
+
+ QQmlComponent component(&appEngine);
+ component.setData(QByteArrayLiteral("import QtQuick 2.0\n"
+ "import QtWebEngine 1.1\n"
+ "WebEngineProfile {\n"
+ "storageName: \"Test\"\n"
+ "}")
+ , QUrl());
+ QObject *profile = component.create();
+ CookieClient client(rootObject);
+ QMetaObject::invokeMethod(profile, "setCookieStoreClient", Q_ARG(QWebEngineCookieStoreClient*, &client));
+ const QMetaObject *rootMeta = rootObject->metaObject();
+ int index = rootMeta->indexOfProperty("testProfile");
+ Q_ASSERT(index != -1);
+ QMetaProperty profileProperty = rootMeta->property(index);
+ profileProperty.write(rootObject, qVariantFromValue(profile));
+
+ QMetaObject::invokeMethod(rootObject, "load", Q_ARG(QVariant, startupUrl()));
return app.exec();
}
diff --git a/tools/buildscripts/gyp_qtwebengine b/tools/buildscripts/gyp_qtwebengine
index 970cce54e..39d9cc4b4 100755
--- a/tools/buildscripts/gyp_qtwebengine
+++ b/tools/buildscripts/gyp_qtwebengine
@@ -86,6 +86,11 @@ if __name__ == '__main__':
if 'qt_cross_compile=1' in sys.argv:
os.environ['GYP_CROSSCOMPILE'] = '1'
+ sysroot = 'sysroot='
+ for opt in sys.argv:
+ if opt.startswith(sysroot):
+ os.environ['PKG_CONFIG_SYSROOT_DIR'] = opt[len(sysroot):]
+
gyp_helper.apply_chromium_gyp_env()
# This could give false positives since it doesn't actually do real option
@@ -140,6 +145,8 @@ if __name__ == '__main__':
args.extend(['-D', 'linux_use_bundled_binutils=0'])
args.extend(['-D', 'linux_use_gold_flags=0'])
args.extend(['-D', 'clang_use_chrome_plugins=0'])
+ # We do not want to ship more external binary blobs, so let v8 embed its startup data.
+ args.extend(['-D', 'v8_use_external_startup_data=0'])
# Trigger Qt-specific build conditions.
args.extend(['-D', 'use_qt=1'])
# Tweak the output location and format (hardcode ninja for now if not set)
diff --git a/tools/qmake/config.tests/khr/khr.cpp b/tools/qmake/config.tests/khr/khr.cpp
index 6182df286..01c0c26ca 100644
--- a/tools/qmake/config.tests/khr/khr.cpp
+++ b/tools/qmake/config.tests/khr/khr.cpp
@@ -38,7 +38,5 @@
int main(int, char **)
{
- const khronos_boolean_enum_t kfalse = KHRONOS_FALSE;
- const khronos_boolean_enum_t ktrue = KHRONOS_TRUE;
- return kfalse == ktrue;
+ return 0;
}
diff --git a/tools/qmake/config.tests/snappy/snappy.cpp b/tools/qmake/config.tests/snappy/snappy.cpp
new file mode 100644
index 000000000..7948303fc
--- /dev/null
+++ b/tools/qmake/config.tests/snappy/snappy.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <snappy.h>
+
+int main(int, char **)
+{
+ snappy::Source* src = 0;
+ snappy::Sink* sink = 0;
+ return 0;
+}
diff --git a/tools/qmake/config.tests/snappy/snappy.pro b/tools/qmake/config.tests/snappy/snappy.pro
new file mode 100644
index 000000000..890174a13
--- /dev/null
+++ b/tools/qmake/config.tests/snappy/snappy.pro
@@ -0,0 +1,3 @@
+linux:SOURCES += snappy.cpp
+LIBS += -lsnappy
+CONFIG -= qt
diff --git a/tools/qmake/config.tests/srtp/srtp.cpp b/tools/qmake/config.tests/srtp/srtp.cpp
new file mode 100644
index 000000000..12400f126
--- /dev/null
+++ b/tools/qmake/config.tests/srtp/srtp.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <srtp/srtp.h>
+
+int main(int, char **)
+{
+ err_status_t status = srtp_init();
+ return status == err_status_ok;
+}
diff --git a/tools/qmake/config.tests/srtp/srtp.pro b/tools/qmake/config.tests/srtp/srtp.pro
new file mode 100644
index 000000000..2151d64aa
--- /dev/null
+++ b/tools/qmake/config.tests/srtp/srtp.pro
@@ -0,0 +1,3 @@
+linux:SOURCES += srtp.cpp
+LIBS += -lsrtp
+CONFIG -= qt
diff --git a/tools/qmake/mkspecs/features/configure.prf b/tools/qmake/mkspecs/features/configure.prf
index 7b111b78f..17bdc8ba1 100644
--- a/tools/qmake/mkspecs/features/configure.prf
+++ b/tools/qmake/mkspecs/features/configure.prf
@@ -23,10 +23,70 @@ defineTest(runConfigure) {
linux:!config_libcap:skipBuild("libcap development package appears to be missing")
linux:!config_khr:skipBuild("khronos development headers appear to be missing (mesa/libegl1-mesa-dev)")
contains(QT_CONFIG, xcb) {
- for(package, $$list("libdrm xcomposite xi xrandr")) {
+ for(package, $$list("libdrm xcomposite xi xrandr xscrnsaver")) {
!packagesExist($$package):skipBuild("Unmet dependency: $$package")
}
}
- isEmpty(skipBuildReason):cache(CONFIG, add, $$list(webengine_successfully_configured))
+
+ linux {
+ packagesExist(minizip, zlib): WEBENGINE_CONFIG += config_system_minizip
+ else: log("System zlib or minizip not found. Using Chromium's copies.$${EOL}")
+ packagesExist(libwebp,libwebpdemux): WEBENGINE_CONFIG += config_system_libwebp
+ else: log("System libwebp or libwebpdemux not found. Using Chromium's copies.$${EOL}")
+ packagesExist(libxml-2.0,libxslt): WEBENGINE_CONFIG += config_system_libxslt
+ else: log("System libxml2 or libxslt not found. Using Chromium's copies.$${EOL}")
+ for(package, $$list("libevent flac jsoncpp opus speex")) {
+ packagesExist($$package): WEBENGINE_CONFIG += config_system_$$package
+ else: log("System $$package not found. Using Chromium's copy.$${EOL}")
+ }
+ packagesExist("\'vpx >= 1.4\'"): WEBENGINE_CONFIG += config_system_vpx
+ else: log("System vpx >= 1.4 not found. Using Chromium's copy.$${EOL}")
+ config_srtp: WEBENGINE_CONFIG += config_system_libsrtp
+ else: log("System libsrtp not found. Using Chromium's copy.$${EOL}")
+ config_snappy: WEBENGINE_CONFIG += config_system_snappy
+ else: log("System snappy not found. Using Chromium's copy.$${EOL}")
+ }
+
+ isEmpty(skipBuildReason): {
+ cache(CONFIG, add, $$list(webengine_successfully_configured))
+ !isEmpty(WEBENGINE_CONFIG): cache(CONFIG, add, $$list($$WEBENGINE_CONFIG))
+ }
+}
+
+# This is called from default_post, at which point we've also parsed
+# command line options
+defineTest(finalizeConfigure) {
+ linux {
+ contains(WEBENGINE_CONFIG, use_system_icu) {
+ packagesExist("icu-uc icu-i18n") {
+ log("ICU............................... Using system version$${EOL}")
+ } else {
+ log("ICU............................... System ICU not found$${EOL}")
+ skipBuild("Unmet dependencies: icu-uc, icu-i18n")
+ }
+ } else {
+ log("ICU............................... Using internal copy (Default, force system ICU with WEBENGINE_CONFIG += use_system_icu)$${EOL}")
+ }
+ contains(WEBENGINE_CONFIG, use_system_ffmpeg) {
+ packagesExist("libavcodec libavformat libavutil") {
+ packagesExist("libwebp, libwebpdemux, opus, \'vpx >= 1.4\'"){
+ log("FFMPEG............................ Using system version$${EOL}")
+ } else {
+ log("FFMPEG............................ Conflicting FFMPEG dependencies$${EOL}")
+ skipBuild("Unmet dependencies: opus, vpx, libwebp, libwebpdemux")
+ }
+ } else {
+ log("FFMPEG............................ System FFMPEG not found$${EOL}")
+ skipBuild("Unmet dependencies: libavcodec, libavformat, libavutil")
+ }
+ } else {
+ log("FFMPEG............................ Using internal copy (Default, force system FFMPEG with WEBENGINE_CONFIG += use_system_ffmpeg)$${EOL}")
+ }
+ }
+ contains(WEBENGINE_CONFIG, use_proprietary_codecs) {
+ log("Proprietary codecs (H264, MP3).... Enabled$${EOL}")
+ } else {
+ log("Proprietary codecs (H264, MP3).... Not enabled (Default, enable with WEBENGINE_CONFIG += use_proprietary_codecs)$${EOL}")
+ }
}
diff --git a/tools/qmake/mkspecs/features/default_post.prf b/tools/qmake/mkspecs/features/default_post.prf
index d09ba05fd..64e8cb1fe 100644
--- a/tools/qmake/mkspecs/features/default_post.prf
+++ b/tools/qmake/mkspecs/features/default_post.prf
@@ -1,4 +1,7 @@
load(default_post)
+load(functions)
+
+root_project_file:isPlatformSupported(): finalizeConfigure()
!isEmpty(skipBuildReason) {
SUBDIRS =
diff --git a/tools/qmake/mkspecs/features/default_pre.prf b/tools/qmake/mkspecs/features/default_pre.prf
index 2e556c2a6..6506e67ad 100644
--- a/tools/qmake/mkspecs/features/default_pre.prf
+++ b/tools/qmake/mkspecs/features/default_pre.prf
@@ -16,7 +16,9 @@ load(default_pre)
load(functions)
# Check platform support and run config tests early enough to bail
-equals(_PRO_FILE_, "$$QTWEBENGINE_ROOT/qtwebengine.pro"): isPlatformSupported() {
+equals(_PRO_FILE_, "$$QTWEBENGINE_ROOT/qtwebengine.pro"): CONFIG += root_project_file
+
+root_project_file:isPlatformSupported() {
load(configure)
runConfigure()
}
diff --git a/tools/qmake/mkspecs/features/functions.prf b/tools/qmake/mkspecs/features/functions.prf
index ef0320da1..417f81925 100644
--- a/tools/qmake/mkspecs/features/functions.prf
+++ b/tools/qmake/mkspecs/features/functions.prf
@@ -14,7 +14,7 @@ defineTest(isPlatformSupported) {
linux-g++*:!isGCCVersionSupported(): return(false)
!isPythonVersionSupported(): return(false)
- linux-g++*|win32-msvc2013|macx-clang: return(true)
+ linux-g++*|linux-clang|win32-msvc2013|macx-clang: return(true)
boot2qt: return(true)
skipBuild("Qt WebEngine can currently only be built for Linux (GCC), Windows (MSVC 2013), OS X (XCode 5.1+) or Qt for Device Creation.")
diff --git a/tools/scripts/take_snapshot.py b/tools/scripts/take_snapshot.py
index bd2ec4e56..71dcc43c2 100755
--- a/tools/scripts/take_snapshot.py
+++ b/tools/scripts/take_snapshot.py
@@ -78,7 +78,7 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('third_party/android_tools')
or '/tests/' in file_path
or ('/test/' in file_path and
- not '/webrtc/test/testsupport/' in file_path and
+ not '/webrtc/' in file_path and
not file_path.startswith('net/test/') and
not file_path.endswith('mock_chrome_application_mac.h') and
not file_path.endswith('perftimer.h') and
@@ -100,9 +100,9 @@ def isInChromiumBlacklist(file_path):
not 'repack_locales' in file_path and
not 'third_party/chromevox' in file_path and
not 'media/desktop_media_list.h' in file_path and
- not 'media/desktop_streams_registry.cc' in file_path and
- not 'media/desktop_streams_registry.h' in file_path and
- not 'common/localized_error' in file_path and
+ not 'media/desktop_streams_registry.' in file_path and
+ not 'common/chrome_switches.' in file_path and
+ not 'common/localized_error.' in file_path and
not file_path.endswith('cf_resources.rc') and
not file_path.endswith('version.py') and
not file_path.endswith('.grd') and
@@ -113,16 +113,24 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('chromeos')
or file_path.startswith('cloud_print')
or (file_path.startswith('components') and
+ not file_path.startswith('components/device_event_log') and
+ not file_path.startswith('components/devtools_') and
+ not file_path.startswith('components/error_page') and
+ not file_path.startswith('components/mime_util') and
+ not file_path.startswith('components/printing') and
+ not file_path.startswith('components/resources') and
+ not file_path.startswith('components/scheduler') and
+ not file_path.startswith('components/strings') and
not file_path.startswith('components/tracing') and
not file_path.startswith('components/visitedlink') and
- not file_path.startswith('components/error_page') and
+ not file_path.startswith('components/webcrypto') and
not file_path.endswith('.grdp') and
not 'components_strings' in file_path)
or file_path.startswith('content/public/android/java')
- or file_path.startswith('content/shell')
+ or (file_path.startswith('content/shell') and
+ not file_path.startswith('content/shell/common'))
or file_path.startswith('courgette')
or (file_path.startswith('extensions') and
- # Included by generated sources of ui/accessibility/ax_enums.idl
not 'browser/extension_function_registry.h' in file_path and
not 'browser/extension_function_histogram_value.h' in file_path)
or file_path.startswith('google_update')
@@ -136,19 +144,14 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('sync')
or file_path.startswith('testing/android')
or file_path.startswith('testing/buildbot')
- or file_path.startswith('third_party/accessibility-developer-tools')
- or file_path.startswith('third_party/GTM')
or file_path.startswith('third_party/WebKit/LayoutTests')
or file_path.startswith('third_party/WebKit/ManualTests')
or file_path.startswith('third_party/WebKit/PerformanceTests')
- or file_path.startswith('third_party/active_doc')
- or file_path.startswith('third_party/android_crazy_linker')
- or file_path.startswith('third_party/android_platform')
- or file_path.startswith('third_party/android_testrunner')
- or file_path.startswith('third_party/aosp')
- or file_path.startswith('third_party/apache-mime4j')
+ or file_path.startswith('third_party/accessibility-audit')
+ or file_path.startswith('third_party/android_')
or file_path.startswith('third_party/apache-win32')
or file_path.startswith('third_party/apple_sample_code')
+ or file_path.startswith('third_party/ashmem')
or file_path.startswith('third_party/binutils')
or file_path.startswith('third_party/bison')
or (file_path.startswith('third_party/cacheinvalidation') and
@@ -157,26 +160,20 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('third_party/cld_2')
or file_path.startswith('third_party/codesighs')
or file_path.startswith('third_party/colorama')
- or file_path.startswith('third_party/cros_dbus_cplusplus')
or file_path.startswith('third_party/cros_system_api')
or file_path.startswith('third_party/cygwin')
or file_path.startswith('third_party/cython')
+ or file_path.startswith('third_party/deqp')
or file_path.startswith('third_party/elfutils')
- or file_path.startswith('third_party/eyesfree')
- or file_path.startswith('third_party/findbugs')
or file_path.startswith('third_party/google_input_tools')
or file_path.startswith('third_party/gperf')
or file_path.startswith('third_party/gnu_binutils')
or file_path.startswith('third_party/gtk+')
or file_path.startswith('third_party/google_appengine_cloudstorage')
or file_path.startswith('third_party/google_toolbox_for_mac')
- or file_path.startswith('third_party/guava/src')
- or file_path.startswith('third_party/httpcomponents-client')
- or file_path.startswith('third_party/httpcomponents-core')
- or file_path.startswith('third_party/hunspell')
or file_path.startswith('third_party/hunspell_dictionaries')
+ or file_path.startswith('third_party/hunspell')
or file_path.startswith('third_party/instrumented_libraries')
- or file_path.startswith('third_party/jarjar')
or file_path.startswith('third_party/jsr-305/src')
or file_path.startswith('third_party/junit')
or file_path.startswith('third_party/libphonenumber')
@@ -188,21 +185,20 @@ def isInChromiumBlacklist(file_path):
or file_path.startswith('third_party/markdown')
or file_path.startswith('third_party/mingw-w64')
or file_path.startswith('third_party/nacl_sdk_binaries')
- or file_path.startswith('third_party/polymer')
+ or (file_path.startswith('third_party/polymer') and
+ not file_path.startswith('third_party/polymer/v1_0/components-chromium/'))
or file_path.startswith('third_party/pdfsqueeze')
or file_path.startswith('third_party/pefile')
or file_path.startswith('third_party/perl')
or file_path.startswith('third_party/pdfium')
or file_path.startswith('third_party/psyco_win32')
- or file_path.startswith('third_party/python_26')
or file_path.startswith('third_party/scons-2.0.1')
- or file_path.startswith('third_party/syzygy')
- or file_path.startswith('third_party/swig')
- or file_path.startswith('third_party/webgl')
or file_path.startswith('third_party/trace-viewer')
- or file_path.startswith('third_party/xulrunner-sdk')
+ or file_path.startswith('third_party/undoview')
+ or file_path.startswith('third_party/webgl')
or (file_path.startswith('tools') and
not file_path.startswith('tools/clang') and
+ not file_path.startswith('tools/compile_test') and
not file_path.startswith('tools/generate_library_loader') and
not file_path.startswith('tools/generate_shim_headers') and
not file_path.startswith('tools/generate_stubs') and
@@ -214,9 +210,12 @@ def isInChromiumBlacklist(file_path):
not file_path.startswith('tools/protoc_wrapper'))
or file_path.startswith('ui/android/java')
or file_path.startswith('ui/app_list')
+ or file_path.startswith('ui/base/ime/chromeos')
or file_path.startswith('ui/chromeos')
or file_path.startswith('ui/display/chromeos')
+ or file_path.startswith('ui/events/ozone/chromeos')
or file_path.startswith('ui/file_manager')
+ or file_path.startswith('ui/gfx/chromeos')
):
return True
diff --git a/tools/scripts/version_resolver.py b/tools/scripts/version_resolver.py
index 419fb72d1..f6aaedf64 100644
--- a/tools/scripts/version_resolver.py
+++ b/tools/scripts/version_resolver.py
@@ -51,8 +51,8 @@ import json
import urllib2
import git_submodule as GitSubmodule
-chromium_version = '40.0.2214.115'
-chromium_branch = '2214'
+chromium_version = '45.0.2454.79'
+chromium_branch = '2454'
ninja_version = 'v1.5.3'
json_url = 'http://omahaproxy.appspot.com/all.json'
@@ -64,6 +64,7 @@ upstream_src_dir = os.path.abspath(snapshot_src_dir + '_upstream')
submodule_blacklist = [
'third_party/WebKit/LayoutTests/w3c/csswg-test'
, 'third_party/WebKit/LayoutTests/w3c/web-platform-tests'
+ , 'third_party/jsoncpp/source'
, 'chrome/tools/test/reference_build/chrome_mac'
, 'chrome/tools/test/reference_build/chrome_linux'
, 'chrome/tools/test/reference_build/chrome_win'
@@ -91,7 +92,7 @@ def readReleaseChannels():
return channels
def readSubmodules():
- git_deps = subprocess.check_output(['git', 'show', chromium_version +':.DEPS.git'])
+ git_deps = subprocess.check_output(['git', 'show', chromium_version +':DEPS'])
parser = GitSubmodule.DEPSParser()
git_submodules = parser.parse(git_deps)