summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-01-06 14:44:00 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-01-06 14:44:00 +0100
commit40736c5763bf61337c8c14e16d8587db021a87d4 (patch)
treeb17a9c00042ad89cb1308e2484491799aa14e9f8 /Source/WebKit2/UIProcess/API
Imported WebKit commit 2ea9d364d0f6efa8fa64acf19f451504c59be0e4 (http://svn.webkit.org/repository/webkit/trunk@104285)
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAPICast.h358
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp60
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp77
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardList.h52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.cpp302
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.h164
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContextPrivate.h82
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp77
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCookieManager.h75
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredential.cpp57
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredential.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp154
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h108
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDownload.cpp53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDownload.h49
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp42
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.cpp185
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.h95
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h60
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGrammarDetail.cpp65
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGrammarDetail.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp68
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKHitTestResult.h50
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp72
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKIconDatabase.h66
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.cpp111
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.h70
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNativeEvent.h52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNavigationData.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotification.cpp58
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotification.h46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp57
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotificationManager.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h61
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp48
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h49
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp663
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h456
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp59
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPageGroup.h48
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPagePrivate.h94
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp65
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h55
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.cpp713
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.h200
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h163
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp72
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h50
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h64
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp60
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKTextChecker.h89
-rw-r--r--Source/WebKit2/UIProcess/API/C/WebKit2.h68
-rw-r--r--Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp48
-rw-r--r--Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/gtk/WKAPICastGtk.h42
-rw-r--r--Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp47
-rw-r--r--Source/WebKit2/UIProcess/API/C/gtk/WKView.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/mac/WKInspectorMac.h39
-rw-r--r--Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp37
-rw-r--r--Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h41
-rw-r--r--Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h35
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h51
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp43
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.cpp127
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.h96
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp37
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h42
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h251
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp43
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h30
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp43
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h31
-rw-r--r--Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp258
-rw-r--r--Source/WebKit2/UIProcess/API/efl/PageClientImpl.h108
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.cpp468
-rw-r--r--Source/WebKit2/UIProcess/API/efl/ewk_view.h142
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp295
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h109
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp303
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h88
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp165
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h67
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h38
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h47
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp59
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitError.h103
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h43
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp1905
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h291
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h34
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp186
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h52
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp132
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h66
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp216
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h69
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h36
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp161
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h94
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h38
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp161
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.h51
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp1207
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h212
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp520
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h72
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h55
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h46
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp565
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h85
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h43
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml30
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt299
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types10
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am78
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp140
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h59
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp275
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp39
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h66
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp211
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp39
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp261
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp381
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h43
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp115
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h50
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h41
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list8
-rw-r--r--Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h77
-rw-r--r--Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm249
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.h96
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.mm671
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.h138
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm496
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h107
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm373
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerInternal.h33
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerPrivate.h44
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h52
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm93
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h32
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h52
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKConnection.h48
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKConnection.mm119
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKConnectionInternal.h32
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKPrintingView.h62
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm628
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKProcessGroup.h50
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKProcessGroup.mm124
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKProcessGroupInternal.h32
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h45
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm183
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.h48
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm2859
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewInternal.h96
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h52
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquicknetworkreply.cpp180
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquicknetworkreply_p.h75
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquicknetworkrequest_p.h50
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp54
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h58
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp339
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h76
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h53
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp988
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h254
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h168
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebdownloaditem.cpp96
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h86
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p_p.h53
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp66
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h33
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory.cpp160
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h86
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p_p.h70
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp92
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h57
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp106
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h67
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp404
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h141
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h75
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp114
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h74
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html66
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.pngbin0 -> 10585 bytes
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html29
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml9
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml85
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml60
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml108
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml151
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml41
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml86
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml60
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml54
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml119
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml125
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml35
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml28
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml28
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml38
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml108
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml101
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml34
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml35
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html8
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html19
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zipbin0 -> 325 bytes
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html10
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.pngbin0 -> 3961 bytes
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html10
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html29
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html8
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html9
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html15
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html13
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html18
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.pngbin0 -> 891 bytes
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html18
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro31
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp45
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp290
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/tests.pri15
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/testwindow.h54
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/util.cpp67
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/util.h41
262 files changed, 32396 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKAPICast.h b/Source/WebKit2/UIProcess/API/C/WKAPICast.h
new file mode 100644
index 000000000..0e7175a42
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h
@@ -0,0 +1,358 @@
+/*
+ * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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.
+ */
+
+#ifndef WKAPICast_h
+#define WKAPICast_h
+
+#include "CacheModel.h"
+#include "FontSmoothingLevel.h"
+#include "HTTPCookieAcceptPolicy.h"
+#include "ResourceCachesToClear.h"
+#include "WebGrammarDetail.h"
+#include "WKContext.h"
+#include "WKCookieManager.h"
+#include "WKCredentialTypes.h"
+#include "WKPage.h"
+#include "WKPreferencesPrivate.h"
+#include "WKProtectionSpaceTypes.h"
+#include "WKResourceCacheManager.h"
+#include "WKSharedAPICast.h"
+#include <WebCore/CookieJar.h>
+#include <WebCore/Credential.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/ProtectionSpace.h>
+#include <WebCore/Settings.h>
+
+namespace WebKit {
+
+class AuthenticationChallengeProxy;
+class AuthenticationDecisionListener;
+class DownloadProxy;
+class GeolocationPermissionRequestProxy;
+class NotificationPermissionRequest;
+class WebApplicationCacheManagerProxy;
+class WebBackForwardList;
+class WebBackForwardListItem;
+class WebResourceCacheManagerProxy;
+class WebContext;
+class WebCookieManagerProxy;
+class WebCredential;
+class WebDatabaseManagerProxy;
+class WebFormSubmissionListenerProxy;
+class WebFramePolicyListenerProxy;
+class WebFrameProxy;
+class WebGeolocationManagerProxy;
+class WebGeolocationPosition;
+class WebGrammarDetail;
+class WebHitTestResult;
+class WebIconDatabase;
+class WebInspectorProxy;
+class WebKeyValueStorageManagerProxy;
+class WebMediaCacheManagerProxy;
+class WebNavigationData;
+class WebNotification;
+class WebNotificationProvider;
+class WebNotificationManagerProxy;
+class WebOpenPanelParameters;
+class WebOpenPanelResultListenerProxy;
+class WebPageGroup;
+class WebPageProxy;
+class WebPluginSiteDataManager;
+class WebPreferences;
+class WebProtectionSpace;
+class WebTextChecker;
+
+WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy)
+WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
+WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
+WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
+WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
+WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
+WK_ADD_API_MAPPING(WKContextRef, WebContext)
+WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
+WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
+WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy)
+WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
+WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
+WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
+WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
+WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
+WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy)
+WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
+WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail)
+WK_ADD_API_MAPPING(WKHitTestResultRef, WebHitTestResult)
+WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
+WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManagerProxy)
+WK_ADD_API_MAPPING(WKMediaCacheManagerRef, WebMediaCacheManagerProxy)
+WK_ADD_API_MAPPING(WKNavigationDataRef, WebNavigationData)
+WK_ADD_API_MAPPING(WKNotificationManagerRef, WebNotificationManagerProxy)
+WK_ADD_API_MAPPING(WKNotificationPermissionRequestRef, NotificationPermissionRequest)
+WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
+WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
+WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
+WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
+WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
+WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
+WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager)
+WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
+WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
+WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
+
+#if ENABLE(INSPECTOR)
+WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
+#endif
+
+/* Enum conversions */
+
+inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
+{
+ switch (wkCacheModel) {
+ case kWKCacheModelDocumentViewer:
+ return CacheModelDocumentViewer;
+ case kWKCacheModelDocumentBrowser:
+ return CacheModelDocumentBrowser;
+ case kWKCacheModelPrimaryWebBrowser:
+ return CacheModelPrimaryWebBrowser;
+ }
+
+ ASSERT_NOT_REACHED();
+ return CacheModelDocumentViewer;
+}
+
+inline WKCacheModel toAPI(CacheModel cacheModel)
+{
+ switch (cacheModel) {
+ case CacheModelDocumentViewer:
+ return kWKCacheModelDocumentViewer;
+ case CacheModelDocumentBrowser:
+ return kWKCacheModelDocumentBrowser;
+ case CacheModelPrimaryWebBrowser:
+ return kWKCacheModelPrimaryWebBrowser;
+ }
+
+ return kWKCacheModelDocumentViewer;
+}
+
+inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel)
+{
+ switch (wkLevel) {
+ case kWKFontSmoothingLevelNoSubpixelAntiAliasing:
+ return FontSmoothingLevelNoSubpixelAntiAliasing;
+ case kWKFontSmoothingLevelLight:
+ return FontSmoothingLevelLight;
+ case kWKFontSmoothingLevelMedium:
+ return FontSmoothingLevelMedium;
+ case kWKFontSmoothingLevelStrong:
+ return FontSmoothingLevelStrong;
+#if PLATFORM(WIN)
+ case kWKFontSmoothingLevelWindows:
+ return FontSmoothingLevelWindows;
+#endif
+ }
+
+ ASSERT_NOT_REACHED();
+ return FontSmoothingLevelMedium;
+}
+
+
+inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level)
+{
+ switch (level) {
+ case FontSmoothingLevelNoSubpixelAntiAliasing:
+ return kWKFontSmoothingLevelNoSubpixelAntiAliasing;
+ case FontSmoothingLevelLight:
+ return kWKFontSmoothingLevelLight;
+ case FontSmoothingLevelMedium:
+ return kWKFontSmoothingLevelMedium;
+ case FontSmoothingLevelStrong:
+ return kWKFontSmoothingLevelStrong;
+#if PLATFORM(WIN)
+ case FontSmoothingLevelWindows:
+ return kWKFontSmoothingLevelWindows;
+#endif
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKFontSmoothingLevelMedium;
+}
+
+inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
+{
+ switch (behavior) {
+ case WebCore::EditableLinkDefaultBehavior:
+ return kWKEditableLinkBehaviorDefault;
+ case WebCore::EditableLinkAlwaysLive:
+ return kWKEditableLinkBehaviorAlwaysLive;
+ case WebCore::EditableLinkOnlyLiveWithShiftKey:
+ return kWKEditableLinkBehaviorOnlyLiveWithShiftKey;
+ case WebCore::EditableLinkLiveWhenNotFocused:
+ return kWKEditableLinkBehaviorLiveWhenNotFocused;
+ case WebCore::EditableLinkNeverLive:
+ return kWKEditableLinkBehaviorNeverLive;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKEditableLinkBehaviorNeverLive;
+}
+
+inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior)
+{
+ switch (wkBehavior) {
+ case kWKEditableLinkBehaviorDefault:
+ return WebCore::EditableLinkDefaultBehavior;
+ case kWKEditableLinkBehaviorAlwaysLive:
+ return WebCore::EditableLinkAlwaysLive;
+ case kWKEditableLinkBehaviorOnlyLiveWithShiftKey:
+ return WebCore::EditableLinkOnlyLiveWithShiftKey;
+ case kWKEditableLinkBehaviorLiveWhenNotFocused:
+ return WebCore::EditableLinkLiveWhenNotFocused;
+ case kWKEditableLinkBehaviorNeverLive:
+ return WebCore::EditableLinkNeverLive;
+ }
+
+ ASSERT_NOT_REACHED();
+ return WebCore::EditableLinkNeverLive;
+}
+
+inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type)
+{
+ switch (type) {
+ case WebCore::ProtectionSpaceServerHTTP:
+ return kWKProtectionSpaceServerTypeHTTP;
+ case WebCore::ProtectionSpaceServerHTTPS:
+ return kWKProtectionSpaceServerTypeHTTPS;
+ case WebCore::ProtectionSpaceServerFTP:
+ return kWKProtectionSpaceServerTypeFTP;
+ case WebCore::ProtectionSpaceServerFTPS:
+ return kWKProtectionSpaceServerTypeFTPS;
+ case WebCore::ProtectionSpaceProxyHTTP:
+ return kWKProtectionSpaceProxyTypeHTTP;
+ case WebCore::ProtectionSpaceProxyHTTPS:
+ return kWKProtectionSpaceProxyTypeHTTPS;
+ case WebCore::ProtectionSpaceProxyFTP:
+ return kWKProtectionSpaceProxyTypeFTP;
+ case WebCore::ProtectionSpaceProxySOCKS:
+ return kWKProtectionSpaceProxyTypeSOCKS;
+ }
+ return kWKProtectionSpaceServerTypeHTTP;
+}
+
+inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type)
+{
+ switch (type) {
+ case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
+ return kWKProtectionSpaceAuthenticationSchemeDefault;
+ case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
+ return kWKProtectionSpaceAuthenticationSchemeHTTPBasic;
+ case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
+ return kWKProtectionSpaceAuthenticationSchemeHTTPDigest;
+ case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
+ return kWKProtectionSpaceAuthenticationSchemeHTMLForm;
+ case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
+ return kWKProtectionSpaceAuthenticationSchemeNTLM;
+ case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
+ return kWKProtectionSpaceAuthenticationSchemeNegotiate;
+ case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
+ return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested;
+ case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
+ return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
+ default:
+ return kWKProtectionSpaceAuthenticationSchemeUnknown;
+ }
+}
+
+inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type)
+{
+ switch (type) {
+ case kWKCredentialPersistenceNone:
+ return WebCore::CredentialPersistenceNone;
+ case kWKCredentialPersistenceForSession:
+ return WebCore::CredentialPersistenceForSession;
+ case kWKCredentialPersistencePermanent:
+ return WebCore::CredentialPersistencePermanent;
+ default:
+ return WebCore::CredentialPersistenceNone;
+ }
+}
+
+inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
+{
+ switch (wkResourceCachesToClear) {
+ case WKResourceCachesToClearAll:
+ return AllResourceCaches;
+ case WKResourceCachesToClearInMemoryOnly:
+ return InMemoryResourceCachesOnly;
+ }
+
+ ASSERT_NOT_REACHED();
+ return AllResourceCaches;
+}
+
+inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
+{
+ switch (policy) {
+ case kWKHTTPCookieAcceptPolicyAlways:
+ return HTTPCookieAcceptPolicyAlways;
+ case kWKHTTPCookieAcceptPolicyNever:
+ return HTTPCookieAcceptPolicyNever;
+ case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+ return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+ }
+
+ ASSERT_NOT_REACHED();
+ return HTTPCookieAcceptPolicyAlways;
+}
+
+inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
+{
+ switch (policy) {
+ case HTTPCookieAcceptPolicyAlways:
+ return kWKHTTPCookieAcceptPolicyAlways;
+ case HTTPCookieAcceptPolicyNever:
+ return kWKHTTPCookieAcceptPolicyNever;
+ case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
+ return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKHTTPCookieAcceptPolicyAlways;
+}
+
+inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
+{
+ return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
+}
+
+} // namespace WebKit
+
+#if defined(WIN32) || defined(_WIN32)
+#include "WKAPICastWin.h"
+#endif
+
+#if defined(BUILDING_GTK__)
+#include "WKAPICastGtk.h"
+#endif
+#endif // WKAPICast_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp
new file mode 100644
index 000000000..2d95c6721
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKApplicationCacheManager.h"
+
+#include "WKAPICast.h"
+#include "WebApplicationCacheManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKApplicationCacheManagerGetTypeID()
+{
+ return toAPI(WebApplicationCacheManagerProxy::APIType);
+}
+
+void WKApplicationCacheManagerGetApplicationCacheOrigins(WKApplicationCacheManagerRef applicationCacheManagerRef, void* context, WKApplicationCacheManagerGetApplicationCacheOriginsFunction callback)
+{
+ toImpl(applicationCacheManagerRef)->getApplicationCacheOrigins(ArrayCallback::create(context, callback));
+}
+
+void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRef applicationCacheManagerRef, WKSecurityOriginRef originRef)
+{
+ toImpl(applicationCacheManagerRef)->deleteEntriesForOrigin(toImpl(originRef));
+}
+
+void WKApplicationCacheManagerDeleteAllEntries(WKApplicationCacheManagerRef applicationCacheManagerRef)
+{
+ toImpl(applicationCacheManagerRef)->deleteAllEntries();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h
new file mode 100644
index 000000000..c40039e37
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKApplicationCacheManager.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKApplicationCacheManager_h
+#define WKApplicationCacheManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKApplicationCacheManagerGetTypeID();
+
+typedef void (*WKApplicationCacheManagerGetApplicationCacheOriginsFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKApplicationCacheManagerGetApplicationCacheOrigins(WKApplicationCacheManagerRef applicationCacheManager, void* context, WKApplicationCacheManagerGetApplicationCacheOriginsFunction function);
+
+WK_EXPORT void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRef applicationCacheManager, WKSecurityOriginRef origin);
+WK_EXPORT void WKApplicationCacheManagerDeleteAllEntries(WKApplicationCacheManagerRef applicationCacheManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKApplicationCacheManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp
new file mode 100644
index 000000000..c42b85732
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKAuthenticationChallenge.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "WebCertificateInfo.h"
+#include "WebCredential.h"
+#include "WebProtectionSpace.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKAuthenticationChallengeGetTypeID()
+{
+ return toAPI(AuthenticationChallengeProxy::APIType);
+}
+
+WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef challenge)
+{
+ return toAPI(toImpl(challenge)->listener());
+}
+
+WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef challenge)
+{
+ return toAPI(toImpl(challenge)->protectionSpace());
+}
+
+WKCredentialRef WKAuthenticationChallengeGetProposedCredential(WKAuthenticationChallengeRef challenge)
+{
+ return toAPI(toImpl(challenge)->proposedCredential());
+}
+
+int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef challenge)
+{
+ return toImpl(challenge)->previousFailureCount();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h
new file mode 100644
index 000000000..3802f417f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKAuthenticationChallenge_h
+#define WKAuthenticationChallenge_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKAuthenticationChallengeGetTypeID();
+
+WK_EXPORT WKAuthenticationDecisionListenerRef WKAuthenticationChallengeGetDecisionListener(WKAuthenticationChallengeRef);
+WK_EXPORT WKProtectionSpaceRef WKAuthenticationChallengeGetProtectionSpace(WKAuthenticationChallengeRef);
+WK_EXPORT WKCredentialRef WKAuthenticationChallengeGetProposedCredential(WKAuthenticationChallengeRef);
+WK_EXPORT int WKAuthenticationChallengeGetPreviousFailureCount(WKAuthenticationChallengeRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKAuthenticationChallenge_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp
new file mode 100644
index 000000000..bcb175dfd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKAuthenticationDecisionListener.h"
+
+#include "AuthenticationDecisionListener.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKAuthenticationDecisionListenerGetTypeID()
+{
+ return toAPI(AuthenticationDecisionListener::APIType);
+}
+
+void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential)
+{
+ toImpl(authenticationListener)->useCredential(toImpl(credential));
+}
+
+void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener)
+{
+ toImpl(authenticationListener)->cancel();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h
new file mode 100644
index 000000000..f0724610b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKAuthenticationDecisionListener_h
+#define WKAuthenticationDecisionListener_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKAuthenticationDecisionListenerGetTypeID();
+
+WK_EXPORT void WKAuthenticationDecisionListenerUseCredential(WKAuthenticationDecisionListenerRef authenticationListener, WKCredentialRef credential);
+WK_EXPORT void WKAuthenticationDecisionListenerCancel(WKAuthenticationDecisionListenerRef authenticationListener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKFramePolicyListener_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp
new file mode 100644
index 000000000..f7129b866
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKBackForwardList.h"
+
+#include "WebBackForwardList.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKBackForwardListGetTypeID()
+{
+ return toAPI(WebBackForwardList::APIType);
+}
+
+WKBackForwardListItemRef WKBackForwardListGetCurrentItem(WKBackForwardListRef listRef)
+{
+ return toAPI(toImpl(listRef)->currentItem());
+}
+
+WKBackForwardListItemRef WKBackForwardListGetBackItem(WKBackForwardListRef listRef)
+{
+ return toAPI(toImpl(listRef)->backItem());
+}
+
+WKBackForwardListItemRef WKBackForwardListGetForwardItem(WKBackForwardListRef listRef)
+{
+ return toAPI(toImpl(listRef)->forwardItem());
+}
+
+WKBackForwardListItemRef WKBackForwardListGetItemAtIndex(WKBackForwardListRef listRef, int index)
+{
+ return toAPI(toImpl(listRef)->itemAtIndex(index));
+}
+
+unsigned WKBackForwardListGetBackListCount(WKBackForwardListRef listRef)
+{
+ return toImpl(listRef)->backListCount();
+}
+
+unsigned WKBackForwardListGetForwardListCount(WKBackForwardListRef listRef)
+{
+ return toImpl(listRef)->forwardListCount();
+}
+
+WKArrayRef WKBackForwardListCopyBackListWithLimit(WKBackForwardListRef listRef, unsigned limit)
+{
+ return toAPI(toImpl(listRef)->backListAsImmutableArrayWithLimit(limit).leakRef());
+}
+
+WKArrayRef WKBackForwardListCopyForwardListWithLimit(WKBackForwardListRef listRef, unsigned limit)
+{
+ return toAPI(toImpl(listRef)->forwardListAsImmutableArrayWithLimit(limit).leakRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h
new file mode 100644
index 000000000..214a6bc81
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKBackForwardList_h
+#define WKBackForwardList_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBackForwardListGetTypeID();
+
+WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetCurrentItem(WKBackForwardListRef list);
+WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetBackItem(WKBackForwardListRef list);
+WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetForwardItem(WKBackForwardListRef list);
+WK_EXPORT WKBackForwardListItemRef WKBackForwardListGetItemAtIndex(WKBackForwardListRef list, int index);
+
+WK_EXPORT unsigned WKBackForwardListGetBackListCount(WKBackForwardListRef list);
+WK_EXPORT unsigned WKBackForwardListGetForwardListCount(WKBackForwardListRef list);
+
+WK_EXPORT WKArrayRef WKBackForwardListCopyBackListWithLimit(WKBackForwardListRef list, unsigned limit);
+WK_EXPORT WKArrayRef WKBackForwardListCopyForwardListWithLimit(WKBackForwardListRef list, unsigned limit);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKBackForwardList_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp
new file mode 100644
index 000000000..00dc6da41
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#include "config.h"
+#include "WKBackForwardListItem.h"
+
+#include "WKAPICast.h"
+#include "WebBackForwardListItem.h"
+
+using namespace WebKit;
+
+WKTypeID WKBackForwardListItemGetTypeID()
+{
+ return toAPI(WebBackForwardListItem::APIType);
+}
+
+WKURLRef WKBackForwardListItemCopyURL(WKBackForwardListItemRef itemRef)
+{
+ return toCopiedURLAPI(toImpl(itemRef)->url());
+}
+
+WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef itemRef)
+{
+ return toCopiedAPI(toImpl(itemRef)->title());
+}
+
+WKURLRef WKBackForwardListItemCopyOriginalURL(WKBackForwardListItemRef itemRef)
+{
+ return toCopiedURLAPI(toImpl(itemRef)->originalURL());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h
new file mode 100644
index 000000000..3810d1523
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#ifndef WKBackForwardListItem_h
+#define WKBackForwardListItem_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKBackForwardListItemGetTypeID();
+
+WK_EXPORT WKURLRef WKBackForwardListItemCopyURL(WKBackForwardListItemRef item);
+WK_EXPORT WKStringRef WKBackForwardListItemCopyTitle(WKBackForwardListItemRef item);
+WK_EXPORT WKURLRef WKBackForwardListItemCopyOriginalURL(WKBackForwardListItemRef item);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKBackForwardListItem_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.cpp b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
new file mode 100644
index 000000000..cef897714
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -0,0 +1,302 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#include "config.h"
+#include "WKContext.h"
+#include "WKContextPrivate.h"
+
+#include "WKAPICast.h"
+#include "WebContext.h"
+#include "WebURLRequest.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+extern "C" {
+// For binary compatibility with Safari 5.1. Should be removed eventually.
+WK_EXPORT void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory);
+WK_EXPORT void _WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context, WKStringRef urlScheme);
+WK_EXPORT void _WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef context, bool alwaysUseComplexTextCodePath);
+WK_EXPORT void _WKContextSetHTTPPipeliningEnabled(WKContextRef context, bool enabled);
+}
+
+WKTypeID WKContextGetTypeID()
+{
+ return toAPI(WebContext::APIType);
+}
+
+WKContextRef WKContextCreate()
+{
+ RefPtr<WebContext> context = WebContext::create(String());
+ return toAPI(context.release().leakRef());
+}
+
+WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
+{
+ RefPtr<WebContext> context = WebContext::create(toImpl(pathRef)->string());
+ return toAPI(context.release().leakRef());
+}
+
+WKContextRef WKContextGetSharedProcessContext()
+{
+ return toAPI(WebContext::sharedProcessContext());
+}
+
+WKContextRef WKContextGetSharedThreadContext()
+{
+ return toAPI(WebContext::sharedThreadContext());
+}
+
+void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
+{
+ toImpl(contextRef)->initializeInjectedBundleClient(wkClient);
+}
+
+void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryClient* wkClient)
+{
+ toImpl(contextRef)->initializeHistoryClient(wkClient);
+}
+
+void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownloadClient* wkClient)
+{
+ toImpl(contextRef)->initializeDownloadClient(wkClient);
+}
+
+void WKContextSetConnectionClient(WKContextRef contextRef, const WKContextConnectionClient* wkClient)
+{
+ toImpl(contextRef)->initializeConnectionClient(wkClient);
+}
+
+WKDownloadRef WKContextDownloadURLRequest(WKContextRef contextRef, const WKURLRequestRef requestRef)
+{
+ return toAPI(toImpl(contextRef)->download(0, toImpl(requestRef)->resourceRequest()));
+}
+
+void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef contextRef, WKTypeRef userDataRef)
+{
+ toImpl(contextRef)->setInjectedBundleInitializationUserData(toImpl(userDataRef));
+}
+
+void WKContextPostMessageToInjectedBundle(WKContextRef contextRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
+{
+ toImpl(contextRef)->postMessageToInjectedBundle(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
+}
+
+void WKContextGetGlobalStatistics(WKContextStatistics* statistics)
+{
+ const WebContext::Statistics& webContextStatistics = WebContext::statistics();
+
+ statistics->wkViewCount = webContextStatistics.wkViewCount;
+ statistics->wkPageCount = webContextStatistics.wkPageCount;
+ statistics->wkFrameCount = webContextStatistics.wkViewCount;
+}
+
+void WKContextAddVisitedLink(WKContextRef contextRef, WKStringRef visitedURL)
+{
+ toImpl(contextRef)->addVisitedLink(toImpl(visitedURL)->string());
+}
+
+void WKContextSetCacheModel(WKContextRef contextRef, WKCacheModel cacheModel)
+{
+ toImpl(contextRef)->setCacheModel(toCacheModel(cacheModel));
+}
+
+WKCacheModel WKContextGetCacheModel(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->cacheModel());
+}
+
+void WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef contextRef, bool alwaysUseComplexTextCodePath)
+{
+ toImpl(contextRef)->setAlwaysUsesComplexTextCodePath(alwaysUseComplexTextCodePath);
+}
+
+void WKContextSetShouldUseFontSmoothing(WKContextRef contextRef, bool useFontSmoothing)
+{
+ toImpl(contextRef)->setShouldUseFontSmoothing(useFontSmoothing);
+}
+
+void WKContextSetAdditionalPluginsDirectory(WKContextRef contextRef, WKStringRef pluginsDirectory)
+{
+ toImpl(contextRef)->setAdditionalPluginsDirectory(toImpl(pluginsDirectory)->string());
+}
+
+void WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef contextRef, WKStringRef urlScheme)
+{
+ toImpl(contextRef)->registerURLSchemeAsEmptyDocument(toImpl(urlScheme)->string());
+}
+
+void WKContextRegisterURLSchemeAsSecure(WKContextRef contextRef, WKStringRef urlScheme)
+{
+ toImpl(contextRef)->registerURLSchemeAsSecure(toImpl(urlScheme)->string());
+}
+
+void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme)
+{
+ toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string());
+}
+
+WKCookieManagerRef WKContextGetCookieManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->cookieManagerProxy());
+}
+
+WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->applicationCacheManagerProxy());
+}
+
+WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->databaseManagerProxy());
+}
+
+WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->geolocationManagerProxy());
+}
+
+WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->iconDatabase());
+}
+
+WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->keyValueStorageManagerProxy());
+}
+
+WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->mediaCacheManagerProxy());
+}
+
+WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->notificationManagerProxy());
+}
+
+WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->pluginSiteDataManager());
+}
+
+WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->resourceCacheManagerProxy());
+}
+
+void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval)
+{
+ toImpl(contextRef)->startMemorySampler(toImpl(interval)->value());
+}
+
+void WKContextStopMemorySampler(WKContextRef contextRef)
+{
+ toImpl(contextRef)->stopMemorySampler();
+}
+
+void WKContextSetIconDatabasePath(WKContextRef contextRef, WKStringRef iconDatabasePath)
+{
+ toImpl(contextRef)->setIconDatabasePath(toImpl(iconDatabasePath)->string());
+}
+
+void WKContextSetDatabaseDirectory(WKContextRef contextRef, WKStringRef databaseDirectory)
+{
+ toImpl(contextRef)->setDatabaseDirectory(toImpl(databaseDirectory)->string());
+}
+
+void WKContextSetLocalStorageDirectory(WKContextRef contextRef, WKStringRef localStorageDirectory)
+{
+ toImpl(contextRef)->setLocalStorageDirectory(toImpl(localStorageDirectory)->string());
+}
+
+void WKContextSetOverrideWebInspectorBaseDirectory(WKContextRef contextRef, WKStringRef webInspectorBaseDirectory)
+{
+ toImpl(contextRef)->setOverrideWebInspectorBaseDirectory(toImpl(webInspectorBaseDirectory)->string());
+}
+
+void WKContextSetOverrideWebInspectorPagePath(WKContextRef contextRef, WKStringRef webInspectorPagePath)
+{
+ toImpl(contextRef)->setOverrideWebInspectorPagePath(toImpl(webInspectorPagePath)->string());
+}
+
+void WKContextSetOverrideWebInspectorLocalizedStringsPath(WKContextRef contextRef, WKStringRef webInspectorLocalizedStringsPath)
+{
+ toImpl(contextRef)->setOverrideWebInspectorLocalizedStringsPath(toImpl(webInspectorLocalizedStringsPath)->string());
+}
+
+void WKContextDisableProcessTermination(WKContextRef contextRef)
+{
+ toImpl(contextRef)->disableProcessTermination();
+}
+
+void WKContextEnableProcessTermination(WKContextRef contextRef)
+{
+ toImpl(contextRef)->enableProcessTermination();
+}
+
+void WKContextSetHTTPPipeliningEnabled(WKContextRef contextRef, bool enabled)
+{
+ toImpl(contextRef)->setHTTPPipeliningEnabled(enabled);
+}
+
+void WKContextWarmInitialProcess(WKContextRef contextRef)
+{
+ toImpl(contextRef)->warmInitialProcess();
+}
+
+void WKContextGetStatistics(WKContextRef contextRef, void* context, WKContextGetStatisticsFunction callback)
+{
+ toImpl(contextRef)->getWebCoreStatistics(DictionaryCallback::create(context, callback));
+}
+
+void WKContextGarbageCollectJavaScriptObjects(WKContextRef contextRef)
+{
+ toImpl(contextRef)->garbageCollectJavaScriptObjects();
+}
+
+// Deprecated functions.
+void _WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory)
+{
+ WKContextSetAdditionalPluginsDirectory(context, pluginsDirectory);
+}
+
+void _WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context, WKStringRef urlScheme)
+{
+ WKContextRegisterURLSchemeAsEmptyDocument(context, urlScheme);
+}
+
+void _WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef context, bool alwaysUseComplexTextCodePath)
+{
+ WKContextSetAlwaysUsesComplexTextCodePath(context, alwaysUseComplexTextCodePath);
+}
+
+void _WKContextSetHTTPPipeliningEnabled(WKContextRef context, bool enabled)
+{
+ WKContextSetHTTPPipeliningEnabled(context, enabled);
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h
new file mode 100644
index 000000000..f0ae59456
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#ifndef WKContext_h
+#define WKContext_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKCacheModelDocumentViewer = 0,
+ kWKCacheModelDocumentBrowser = 1,
+ kWKCacheModelPrimaryWebBrowser = 2
+};
+typedef uint32_t WKCacheModel;
+
+// Injected Bundle Client
+typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
+typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
+
+struct WKContextInjectedBundleClient {
+ int version;
+ const void * clientInfo;
+ WKContextDidReceiveMessageFromInjectedBundleCallback didReceiveMessageFromInjectedBundle;
+ WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback didReceiveSynchronousMessageFromInjectedBundle;
+};
+typedef struct WKContextInjectedBundleClient WKContextInjectedBundleClient;
+
+enum { kWKContextInjectedBundleClientCurrentVersion = 0 };
+
+// History Client
+typedef void (*WKContextDidNavigateWithNavigationDataCallback)(WKContextRef context, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKContextDidPerformClientRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKContextDidPerformServerRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKContextDidUpdateHistoryTitleCallback)(WKContextRef context, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKContextPopulateVisitedLinksCallback)(WKContextRef context, const void *clientInfo);
+
+struct WKContextHistoryClient {
+ int version;
+ const void * clientInfo;
+ WKContextDidNavigateWithNavigationDataCallback didNavigateWithNavigationData;
+ WKContextDidPerformClientRedirectCallback didPerformClientRedirect;
+ WKContextDidPerformServerRedirectCallback didPerformServerRedirect;
+ WKContextDidUpdateHistoryTitleCallback didUpdateHistoryTitle;
+ WKContextPopulateVisitedLinksCallback populateVisitedLinks;
+};
+typedef struct WKContextHistoryClient WKContextHistoryClient;
+
+enum { kWKContextHistoryClientCurrentVersion = 0 };
+
+// Download Client
+typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
+typedef void (*WKContextDownloadDidReceiveAuthenticationChallengeCallback)(WKContextRef context, WKDownloadRef download, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
+typedef void (*WKContextDownloadDidReceiveResponseCallback)(WKContextRef context, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo);
+typedef void (*WKContextDownloadDidReceiveDataCallback)(WKContextRef context, WKDownloadRef download, uint64_t length, const void *clientInfo);
+typedef bool (*WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback)(WKContextRef context, WKDownloadRef download, WKStringRef mimeType, const void *clientInfo);
+typedef WKStringRef (*WKContextDownloadDecideDestinationWithSuggestedFilenameCallback)(WKContextRef context, WKDownloadRef download, WKStringRef filename, bool* allowOverwrite, const void *clientInfo);
+typedef void (*WKContextDownloadDidCreateDestinationCallback)(WKContextRef context, WKDownloadRef download, WKStringRef path, const void *clientInfo);
+typedef void (*WKContextDownloadDidFinishCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
+typedef void (*WKContextDownloadDidFailCallback)(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void *clientInfo);
+typedef void (*WKContextDownloadDidCancel)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
+typedef void (*WKContextDownloadProcessDidCrashCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
+
+struct WKContextDownloadClient {
+ int version;
+ const void * clientInfo;
+ WKContextDownloadDidStartCallback didStart;
+ WKContextDownloadDidReceiveAuthenticationChallengeCallback didReceiveAuthenticationChallenge;
+ WKContextDownloadDidReceiveResponseCallback didReceiveResponse;
+ WKContextDownloadDidReceiveDataCallback didReceiveData;
+ WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType;
+ WKContextDownloadDecideDestinationWithSuggestedFilenameCallback decideDestinationWithSuggestedFilename;
+ WKContextDownloadDidCreateDestinationCallback didCreateDestination;
+ WKContextDownloadDidFinishCallback didFinish;
+ WKContextDownloadDidFailCallback didFail;
+ WKContextDownloadDidCancel didCancel;
+ WKContextDownloadProcessDidCrashCallback processDidCrash;
+};
+typedef struct WKContextDownloadClient WKContextDownloadClient;
+
+enum { kWKContextDownloadClientCurrentVersion = 0 };
+
+// Connection Client
+typedef void (*WKContextDidCreateConnection)(WKContextRef context, WKConnectionRef connection, const void* clientInfo);
+
+struct WKContextConnectionClient {
+ int version;
+ const void * clientInfo;
+ WKContextDidCreateConnection didCreateConnection;
+};
+typedef struct WKContextConnectionClient WKContextConnectionClient;
+
+enum { kWKContextConnectionClientCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKContextGetTypeID();
+
+WK_EXPORT WKContextRef WKContextCreate();
+WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path);
+WK_EXPORT WKContextRef WKContextGetSharedProcessContext();
+
+WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
+WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
+WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client);
+WK_EXPORT void WKContextSetConnectionClient(WKContextRef context, const WKContextConnectionClient* client);
+
+WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, const WKURLRequestRef request);
+
+WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData);
+WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody);
+
+WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visitedURL);
+
+WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
+WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);
+
+WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
+WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
+
+WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context);
+WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
+WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context);
+WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
+WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
+WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
+WK_EXPORT WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef context);
+WK_EXPORT WKNotificationManagerRef WKContextGetNotificationManager(WKContextRef context);
+WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context);
+WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
+
+typedef void (*WKContextGetStatisticsFunction)(WKDictionaryRef statistics, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKContextGetStatistics(WKContextRef context, void* functionContext, WKContextGetStatisticsFunction function);
+
+WK_EXPORT void WKContextGarbageCollectJavaScriptObjects(WKContextRef context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKContext_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
new file mode 100644
index 000000000..ad69da1de
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKContextPrivate_h
+#define WKContextPrivate_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKContext.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct WKContextStatistics {
+ unsigned wkViewCount;
+ unsigned wkPageCount;
+ unsigned wkFrameCount;
+};
+typedef struct WKContextStatistics WKContextStatistics;
+
+WK_EXPORT void WKContextGetGlobalStatistics(WKContextStatistics* statistics);
+
+WK_EXPORT WKContextRef WKContextGetSharedThreadContext();
+
+WK_EXPORT void WKContextSetAdditionalPluginsDirectory(WKContextRef context, WKStringRef pluginsDirectory);
+
+WK_EXPORT void WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context, WKStringRef urlScheme);
+
+WK_EXPORT void WKContextSetAlwaysUsesComplexTextCodePath(WKContextRef context, bool alwaysUseComplexTextCodePath);
+
+WK_EXPORT void WKContextSetShouldUseFontSmoothing(WKContextRef context, bool useFontSmoothing);
+
+WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme);
+
+WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
+
+WK_EXPORT void WKContextSetIconDatabasePath(WKContextRef context, WKStringRef iconDatabasePath);
+
+// FIXME: These functions are only effective if called before the Web process is launched. But
+// we should really change these settings to be on WebPreferences and changeable at runtime.
+WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory);
+WK_EXPORT void WKContextSetLocalStorageDirectory(WKContextRef context, WKStringRef localStorageDirectory);
+WK_EXPORT void WKContextSetOverrideWebInspectorBaseDirectory(WKContextRef context, WKStringRef webInspectorBaseDirectory);
+WK_EXPORT void WKContextSetOverrideWebInspectorPagePath(WKContextRef context, WKStringRef webInspectorPagePath);
+WK_EXPORT void WKContextSetOverrideWebInspectorLocalizedStringsPath(WKContextRef context, WKStringRef webInspectorLocalizedStringsPath);
+
+// FIXME: This is a workaround for testing purposes only and should be removed once a better
+// solution has been found for testing.
+WK_EXPORT void WKContextDisableProcessTermination(WKContextRef context);
+WK_EXPORT void WKContextEnableProcessTermination(WKContextRef context);
+
+WK_EXPORT void WKContextSetHTTPPipeliningEnabled(WKContextRef context, bool enabled);
+
+WK_EXPORT void WKContextWarmInitialProcess(WKContextRef context);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKContextPrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp b/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
new file mode 100644
index 000000000..49ce6ac0c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKCookieManager.h"
+
+#include "WKAPICast.h"
+#include "WebCookieManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKCookieManagerGetTypeID()
+{
+ return toAPI(WebCookieManagerProxy::APIType);
+}
+
+void WKCookieManagerSetClient(WKCookieManagerRef cookieManagerRef, const WKCookieManagerClient* wkClient)
+{
+ toImpl(cookieManagerRef)->initializeClient(wkClient);
+}
+
+void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManagerRef, void* context, WKCookieManagerGetCookieHostnamesFunction callback)
+{
+ toImpl(cookieManagerRef)->getHostnamesWithCookies(ArrayCallback::create(context, callback));
+}
+
+void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManagerRef, WKStringRef hostname)
+{
+ toImpl(cookieManagerRef)->deleteCookiesForHostname(toImpl(hostname)->string());
+}
+
+void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManagerRef)
+{
+ toImpl(cookieManagerRef)->deleteAllCookies();
+}
+
+void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy)
+{
+ toImpl(cookieManager)->setHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+}
+
+void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback)
+{
+ toImpl(cookieManager)->getHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyCallback::create(context, callback));
+}
+
+void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager)
+{
+ toImpl(cookieManager)->startObservingCookieChanges();
+}
+
+void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager)
+{
+ toImpl(cookieManager)->stopObservingCookieChanges();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKCookieManager.h b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h
new file mode 100644
index 000000000..88f56dc37
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCookieManager.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKCookieManager_h
+#define WKCookieManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKHTTPCookieAcceptPolicyAlways = 0,
+ kWKHTTPCookieAcceptPolicyNever = 1,
+ kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain = 2
+};
+typedef uint32_t WKHTTPCookieAcceptPolicy;
+
+// Cookie Manager Client
+typedef void (*WKCookieManagerCookiesDidChangeCallback)(WKCookieManagerRef cookieManager, const void *clientInfo);
+
+struct WKCookieManagerClient {
+ int version;
+ const void * clientInfo;
+ WKCookieManagerCookiesDidChangeCallback cookiesDidChange;
+};
+typedef struct WKCookieManagerClient WKCookieManagerClient;
+
+enum { kWKCookieManagerClientCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKCookieManagerGetTypeID();
+
+WK_EXPORT void WKCookieManagerSetClient(WKCookieManagerRef cookieManager, const WKCookieManagerClient* client);
+
+typedef void (*WKCookieManagerGetCookieHostnamesFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKCookieManagerGetHostnamesWithCookies(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetCookieHostnamesFunction function);
+
+WK_EXPORT void WKCookieManagerDeleteCookiesForHostname(WKCookieManagerRef cookieManager, WKStringRef hostname);
+WK_EXPORT void WKCookieManagerDeleteAllCookies(WKCookieManagerRef cookieManager);
+
+WK_EXPORT void WKCookieManagerSetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, WKHTTPCookieAcceptPolicy policy);
+typedef void (*WKCookieManagerGetHTTPCookieAcceptPolicyFunction)(WKHTTPCookieAcceptPolicy, WKErrorRef, void*);
+WK_EXPORT void WKCookieManagerGetHTTPCookieAcceptPolicy(WKCookieManagerRef cookieManager, void* context, WKCookieManagerGetHTTPCookieAcceptPolicyFunction callback);
+
+WK_EXPORT void WKCookieManagerStartObservingCookieChanges(WKCookieManagerRef cookieManager);
+WK_EXPORT void WKCookieManagerStopObservingCookieChanges(WKCookieManagerRef cookieManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKCookieManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKCredential.cpp b/Source/WebKit2/UIProcess/API/C/WKCredential.cpp
new file mode 100644
index 000000000..8b4c33ba1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCredential.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKCredential.h"
+
+#include "WebCertificateInfo.h"
+#include "WebCredential.h"
+#include "WebString.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKCredentialGetTypeID()
+{
+ return toAPI(WebCredential::APIType);
+}
+
+WKCredentialRef WKCredentialCreate(WKStringRef username, WKStringRef password, WKCredentialPersistence persistence)
+{
+ RefPtr<WebCredential> credential = WebCredential::create(toImpl(username), toImpl(password), toCredentialPersistence(persistence));
+ return toAPI(credential.release().leakRef());
+}
+
+WKCredentialRef WKCredentialCreateWithCertificateInfo(WKCertificateInfoRef certificateInfo)
+{
+ RefPtr<WebCredential> credential = WebCredential::create(toImpl(certificateInfo));
+ return toAPI(credential.release().leakRef());
+}
+
+WKStringRef WKCredentialCopyUser(WKCredentialRef credentialRef)
+{
+ return toCopiedAPI(toImpl(credentialRef)->user());
+}
+
diff --git a/Source/WebKit2/UIProcess/API/C/WKCredential.h b/Source/WebKit2/UIProcess/API/C/WKCredential.h
new file mode 100644
index 000000000..560fc419a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCredential.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKCredential_h
+#define WKCredential_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKCredentialTypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKCredentialGetTypeID();
+
+WK_EXPORT WKCredentialRef WKCredentialCreate(WKStringRef username, WKStringRef password, WKCredentialPersistence);
+WK_EXPORT WKCredentialRef WKCredentialCreateWithCertificateInfo(WKCertificateInfoRef certificateInfo);
+
+WK_EXPORT WKStringRef WKCredentialCopyUser(WKCredentialRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKCredential_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h b/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h
new file mode 100644
index 000000000..bba31ac58
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKCredentialTypes_h
+#define WKCredentialTypes_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKCredentialPersistenceNone,
+ kWKCredentialPersistenceForSession,
+ kWKCredentialPersistencePermanent
+};
+typedef uint32_t WKCredentialPersistence;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKCredentialTypes_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp
new file mode 100644
index 000000000..8075a1c0d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKDatabaseManager.h"
+
+#include "WebDatabaseManagerProxy.h"
+#include "WKAPICast.h"
+
+#ifdef __BLOCKS__
+#include <Block.h>
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKDatabaseManagerGetTypeID()
+{
+ return toAPI(WebDatabaseManagerProxy::APIType);
+}
+
+WKStringRef WKDatabaseManagerGetOriginKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::originKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetOriginQuotaKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::originQuotaKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetOriginUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::originUsageKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).leakRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).leakRef();
+ return toAPI(key);
+}
+
+void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManagerRef, const WKDatabaseManagerClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(databaseManagerRef)->initializeClient(wkClient);
+}
+
+void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabasesByOriginFunction callback)
+{
+ toImpl(databaseManagerRef)->getDatabasesByOrigin(ArrayCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetDatabasesByOriginBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
+{
+ WKDatabaseManagerGetDatabasesByOriginBlock block = (WKDatabaseManagerGetDatabasesByOriginBlock)context;
+ block(resultValue, errorRef);
+ Block_release(block);
+}
+
+void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabasesByOriginBlock block)
+{
+ WKDatabaseManagerGetDatabasesByOrigin(databaseManagerRef, Block_copy(block), callGetDatabasesByOriginBlockAndDispose);
+}
+#endif
+
+void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef databaseManagerRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction callback)
+{
+ toImpl(databaseManagerRef)->getDatabaseOrigins(ArrayCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetDatabaseOriginsBlockBlockAndDispose(WKArrayRef resultValue, WKErrorRef errorRef, void* context)
+{
+ WKDatabaseManagerGetDatabaseOriginsBlock block = (WKDatabaseManagerGetDatabaseOriginsBlock)context;
+ block(resultValue, errorRef);
+ Block_release(block);
+}
+
+void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManagerRef, WKDatabaseManagerGetDatabaseOriginsBlock block)
+{
+ WKDatabaseManagerGetDatabaseOrigins(databaseManagerRef, Block_copy(block), callGetDatabaseOriginsBlockBlockAndDispose);
+}
+#endif
+
+void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManagerRef, WKStringRef databaseNameRef, WKSecurityOriginRef originRef)
+{
+ toImpl(databaseManagerRef)->deleteDatabaseWithNameForOrigin(toWTFString(databaseNameRef), toImpl(originRef));
+}
+
+void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef)
+{
+ toImpl(databaseManagerRef)->deleteDatabasesForOrigin(toImpl(originRef));
+}
+
+void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManagerRef)
+{
+ toImpl(databaseManagerRef)->deleteAllDatabases();
+}
+
+void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManagerRef, WKSecurityOriginRef originRef, uint64_t quota)
+{
+ toImpl(databaseManagerRef)->setQuotaForOrigin(toImpl(originRef), quota);
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h
new file mode 100644
index 000000000..820f0f870
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKDatabaseManager_h
+#define WKDatabaseManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Value type: WKSecurityOriginRef */
+WK_EXPORT WKStringRef WKDatabaseManagerGetOriginKey();
+
+/* Value type: WKUInt64Ref */
+WK_EXPORT WKStringRef WKDatabaseManagerGetOriginQuotaKey();
+
+/* Value type: WKUInt64Ref */
+WK_EXPORT WKStringRef WKDatabaseManagerGetOriginUsageKey();
+
+/* Value type: WKArrayRef (array of WKDictionaryRef's with keys that include:
+ - WKDatabaseManagerGetDatabaseNameKey()
+ - WKDatabaseManagerGetDatabaseDisplayNameKey()
+ - WKDatabaseManagerGetDatabaseExpectedUsageKey()
+ - WKDatabaseManagerGetDatabaseCurrentUsageKey()
+ */
+WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsKey();
+
+/* Value type: WKStringRef */
+WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey();
+
+/* Value type: WKStringRef */
+WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey();
+
+/* Value type: WKUInt64Ref */
+WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey();
+
+/* Value type: WKUInt64Ref */
+WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey();
+
+
+// Database Manager Client
+typedef void (*WKDatabaseManagerDidModifyOriginCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, const void *clientInfo);
+typedef void (*WKDatabaseManagerDidModifyDatabaseCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, WKStringRef databaseIdentifier, const void *clientInfo);
+
+struct WKDatabaseManagerClient {
+ int version;
+ const void * clientInfo;
+ WKDatabaseManagerDidModifyOriginCallback didModifyOrigin;
+ WKDatabaseManagerDidModifyDatabaseCallback didModifyDatabase;
+};
+typedef struct WKDatabaseManagerClient WKDatabaseManagerClient;
+
+enum { kWKDatabaseManagerClientCurrentVersion = 0 };
+
+
+WK_EXPORT WKTypeID WKDatabaseManagerGetTypeID();
+
+WK_EXPORT void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManager, const WKDatabaseManagerClient* client);
+
+typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKDatabaseManagerGetDatabasesByOriginBlock)(WKArrayRef, WKErrorRef);
+WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabasesByOriginBlock block);
+#endif
+
+typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKDatabaseManagerGetDatabaseOriginsBlock)(WKArrayRef, WKErrorRef);
+WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabaseOriginsBlock block);
+#endif
+
+WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin);
+WK_EXPORT void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin);
+WK_EXPORT void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManager);
+
+WK_EXPORT void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, uint64_t quota);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKDatabaseManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKDownload.cpp b/Source/WebKit2/UIProcess/API/C/WKDownload.cpp
new file mode 100644
index 000000000..45dea68ec
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDownload.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKDownload.h"
+
+#include "DownloadProxy.h"
+#include "WKAPICast.h"
+#include "WebURLRequest.h"
+
+using namespace WebKit;
+
+WKTypeID WKDownloadGetTypeID()
+{
+ return toAPI(DownloadProxy::APIType);
+}
+
+WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download)
+{
+ return toAPI(WebURLRequest::create(toImpl(download)->request()).leakRef());
+}
+
+WKDataRef WKDownloadGetResumeData(WKDownloadRef download)
+{
+ return toAPI(toImpl(download)->resumeData());
+}
+
+void WKDownloadCancel(WKDownloadRef download)
+{
+ return toImpl(download)->cancel();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKDownload.h b/Source/WebKit2/UIProcess/API/C/WKDownload.h
new file mode 100644
index 000000000..b81268156
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDownload.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKDownload_h
+#define WKDownload_h
+
+#include <WebKit2/WKBase.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKDownloadGetTypeID();
+
+WK_EXPORT WKURLRequestRef WKDownloadCopyRequest(WKDownloadRef download);
+WK_EXPORT WKDataRef WKDownloadGetResumeData(WKDownloadRef download);
+WK_EXPORT void WKDownloadCancel(WKDownloadRef download);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKDownload_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp
new file mode 100644
index 000000000..842c53458
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKFormSubmissionListener.h"
+
+#include "WKAPICast.h"
+#include "WebFormSubmissionListenerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKFormSubmissionListenerGetTypeID()
+{
+ return toAPI(WebFormSubmissionListenerProxy::APIType);
+}
+
+void WKFormSubmissionListenerContinue(WKFormSubmissionListenerRef submissionListener)
+{
+ toImpl(submissionListener)->continueSubmission();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h
new file mode 100644
index 000000000..4b9b79acb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKFormSubmissionListener_h
+#define WKFormSubmissionListener_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKFormSubmissionListenerGetTypeID();
+
+WK_EXPORT void WKFormSubmissionListenerContinue(WKFormSubmissionListenerRef submissionListener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKFormSubmissionListener_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.cpp b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
new file mode 100644
index 000000000..067c090c7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
@@ -0,0 +1,185 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKFrame.h"
+
+#include "WKAPICast.h"
+#include "WebFrameProxy.h"
+
+#ifdef __BLOCKS__
+#include <Block.h>
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKFrameGetTypeID()
+{
+ return toAPI(WebFrameProxy::APIType);
+}
+
+bool WKFrameIsMainFrame(WKFrameRef frameRef)
+{
+ return toImpl(frameRef)->isMainFrame();
+}
+
+WKFrameLoadState WKFrameGetFrameLoadState(WKFrameRef frameRef)
+{
+ WebFrameProxy* frame = toImpl(frameRef);
+ switch (frame->loadState()) {
+ case WebFrameProxy::LoadStateProvisional:
+ return kWKFrameLoadStateProvisional;
+ case WebFrameProxy::LoadStateCommitted:
+ return kWKFrameLoadStateCommitted;
+ case WebFrameProxy::LoadStateFinished:
+ return kWKFrameLoadStateFinished;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKFrameLoadStateFinished;
+}
+
+WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frameRef)
+{
+ return toCopiedURLAPI(toImpl(frameRef)->provisionalURL());
+}
+
+WKURLRef WKFrameCopyURL(WKFrameRef frameRef)
+{
+ return toCopiedURLAPI(toImpl(frameRef)->url());
+}
+
+WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frameRef)
+{
+ return toCopiedURLAPI(toImpl(frameRef)->unreachableURL());
+}
+
+void WKFrameStopLoading(WKFrameRef frameRef)
+{
+ toImpl(frameRef)->stopLoading();
+}
+
+WKStringRef WKFrameCopyMIMEType(WKFrameRef frameRef)
+{
+ return toCopiedAPI(toImpl(frameRef)->mimeType());
+}
+
+WKStringRef WKFrameCopyTitle(WKFrameRef frameRef)
+{
+ return toCopiedAPI(toImpl(frameRef)->title());
+}
+
+WKPageRef WKFrameGetPage(WKFrameRef frameRef)
+{
+ return toAPI(toImpl(frameRef)->page());
+}
+
+WKArrayRef WKFrameCopyChildFrames(WKFrameRef frameRef)
+{
+ return toAPI(toImpl(frameRef)->childFrames().leakRef());
+}
+
+WKFrameRef WKFrameGetParentFrame(WKFrameRef frameRef)
+{
+ return toAPI(toImpl(frameRef)->parentFrame());
+}
+
+WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frameRef)
+{
+ return toAPI(toImpl(frameRef)->certificateInfo());
+}
+
+bool WKFrameCanProvideSource(WKFrameRef frameRef)
+{
+ return toImpl(frameRef)->canProvideSource();
+}
+
+bool WKFrameCanShowMIMEType(WKFrameRef frameRef, WKStringRef mimeTypeRef)
+{
+ return toImpl(frameRef)->canShowMIMEType(toWTFString(mimeTypeRef));
+}
+
+bool WKFrameIsDisplayingStandaloneImageDocument(WKFrameRef frameRef)
+{
+ return toImpl(frameRef)->isDisplayingStandaloneImageDocument();
+}
+
+bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frameRef)
+{
+ return toImpl(frameRef)->isDisplayingMarkupDocument();
+}
+
+bool WKFrameIsFrameSet(WKFrameRef frameRef)
+{
+ return toImpl(frameRef)->isFrameSet();
+}
+
+void WKFrameGetMainResourceData(WKFrameRef frameRef, WKFrameGetResourceDataFunction callback, void* context)
+{
+ toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback));
+}
+
+void WKFrameGetResourceData(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataFunction callback, void* context)
+{
+ toImpl(frameRef)->getResourceData(toImpl(resourceURL), DataCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
+{
+ WKFrameGetResourceDataBlock block = (WKFrameGetResourceDataBlock)context;
+ block(data, error);
+ Block_release(block);
+}
+
+void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetResourceDataBlock block)
+{
+ WKFrameGetMainResourceData(frameRef, callGetResourceDataBlockAndDispose, Block_copy(block));
+}
+
+void WKFrameGetResourceData_b(WKFrameRef frameRef, WKURLRef resourceURL, WKFrameGetResourceDataBlock block)
+{
+ WKFrameGetResourceData(frameRef, resourceURL, callGetResourceDataBlockAndDispose, Block_copy(block));
+}
+#endif
+
+void WKFrameGetWebArchive(WKFrameRef frameRef, WKFrameGetWebArchiveFunction callback, void* context)
+{
+ toImpl(frameRef)->getWebArchive(DataCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetWebArchiveBlockAndDispose(WKDataRef archiveData, WKErrorRef error, void* context)
+{
+ WKFrameGetWebArchiveBlock block = (WKFrameGetWebArchiveBlock)context;
+ block(archiveData, error);
+ Block_release(block);
+}
+
+void WKFrameGetWebArchive_b(WKFrameRef frameRef, WKFrameGetWebArchiveBlock block)
+{
+ WKFrameGetWebArchive(frameRef, callGetWebArchiveBlockAndDispose, Block_copy(block));
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/API/C/WKFrame.h b/Source/WebKit2/UIProcess/API/C/WKFrame.h
new file mode 100644
index 000000000..eec939e6c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKFrame_h
+#define WKFrame_h
+
+#include <WebKit2/WKBase.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKFrameLoadStateProvisional = 0,
+ kWKFrameLoadStateCommitted = 1,
+ kWKFrameLoadStateFinished = 2
+};
+typedef uint32_t WKFrameLoadState;
+
+WK_EXPORT WKTypeID WKFrameGetTypeID();
+
+WK_EXPORT bool WKFrameIsMainFrame(WKFrameRef frame);
+WK_EXPORT WKFrameLoadState WKFrameGetFrameLoadState(WKFrameRef frame);
+WK_EXPORT WKURLRef WKFrameCopyProvisionalURL(WKFrameRef frame);
+WK_EXPORT WKURLRef WKFrameCopyURL(WKFrameRef frame);
+WK_EXPORT WKURLRef WKFrameCopyUnreachableURL(WKFrameRef frame);
+
+WK_EXPORT void WKFrameStopLoading(WKFrameRef frame);
+
+WK_EXPORT WKStringRef WKFrameCopyMIMEType(WKFrameRef frame);
+WK_EXPORT WKStringRef WKFrameCopyTitle(WKFrameRef frame);
+
+WK_EXPORT WKPageRef WKFrameGetPage(WKFrameRef frame);
+
+WK_EXPORT WKArrayRef WKFrameCopyChildFrames(WKFrameRef frame);
+
+WK_EXPORT WKFrameRef WKFrameGetParentFrame(WKFrameRef frame);
+
+WK_EXPORT WKCertificateInfoRef WKFrameGetCertificateInfo(WKFrameRef frame);
+
+WK_EXPORT bool WKFrameCanProvideSource(WKFrameRef frame);
+WK_EXPORT bool WKFrameCanShowMIMEType(WKFrameRef frame, WKStringRef mimeType);
+
+WK_EXPORT bool WKFrameIsDisplayingStandaloneImageDocument(WKFrameRef frame);
+WK_EXPORT bool WKFrameIsDisplayingMarkupDocument(WKFrameRef frame);
+
+WK_EXPORT bool WKFrameIsFrameSet(WKFrameRef frame);
+
+typedef void (*WKFrameGetResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetResourceDataFunction function, void* functionContext);
+WK_EXPORT void WKFrameGetResourceData(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataFunction function, void* functionContext);
+#ifdef __BLOCKS__
+typedef void (^WKFrameGetResourceDataBlock)(WKDataRef data, WKErrorRef error);
+WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetResourceDataBlock block);
+WK_EXPORT void WKFrameGetResourceData_b(WKFrameRef frame, WKURLRef resourceURL, WKFrameGetResourceDataBlock block);
+#endif
+
+typedef void (*WKFrameGetWebArchiveFunction)(WKDataRef archiveData, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKFrameGetWebArchive(WKFrameRef frame, WKFrameGetWebArchiveFunction function, void* functionContext);
+#ifdef __BLOCKS__
+typedef void (^WKFrameGetWebArchiveBlock)(WKDataRef archiveData, WKErrorRef error);
+WK_EXPORT void WKFrameGetWebArchive_b(WKFrameRef frame, WKFrameGetWebArchiveBlock block);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKFrame_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp
new file mode 100644
index 000000000..3bb673099
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKFramePolicyListener.h"
+
+#include "WKAPICast.h"
+#include "WebFramePolicyListenerProxy.h"
+#include "WebFrameProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKFramePolicyListenerGetTypeID()
+{
+ return toAPI(WebFramePolicyListenerProxy::APIType);
+}
+
+void WKFramePolicyListenerUse(WKFramePolicyListenerRef policyListenerRef)
+{
+ toImpl(policyListenerRef)->use();
+}
+
+void WKFramePolicyListenerDownload(WKFramePolicyListenerRef policyListenerRef)
+{
+ toImpl(policyListenerRef)->download();
+}
+
+void WKFramePolicyListenerIgnore(WKFramePolicyListenerRef policyListenerRef)
+{
+ toImpl(policyListenerRef)->ignore();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h
new file mode 100644
index 000000000..99b013d54
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKFramePolicyListener_h
+#define WKFramePolicyListener_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKFramePolicyListenerGetTypeID();
+
+WK_EXPORT void WKFramePolicyListenerUse(WKFramePolicyListenerRef policyListener);
+WK_EXPORT void WKFramePolicyListenerDownload(WKFramePolicyListenerRef policyListener);
+WK_EXPORT void WKFramePolicyListenerIgnore(WKFramePolicyListenerRef policyListener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKFramePolicyListener_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp
new file mode 100644
index 000000000..ee84090b9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKGeolocationManager.h"
+
+#include "WKAPICast.h"
+#include "WebGeolocationManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKGeolocationManagerGetTypeID()
+{
+ return toAPI(WebGeolocationManagerProxy::APIType);
+}
+
+void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManagerRef, const WKGeolocationProvider* wkProvider)
+{
+ toImpl(geolocationManagerRef)->initializeProvider(wkProvider);
+}
+
+void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManagerRef, WKGeolocationPositionRef positionRef)
+{
+ toImpl(geolocationManagerRef)->providerDidChangePosition(toImpl(positionRef));
+}
+
+void WKGeolocationManagerProviderDidFailToDeterminePosition(WKGeolocationManagerRef geolocationManagerRef)
+{
+ toImpl(geolocationManagerRef)->providerDidFailToDeterminePosition();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h
new file mode 100644
index 000000000..bc2bdd910
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKGeolocationManager_h
+#define WKGeolocationManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Provider.
+typedef void (*WKGeolocationProviderStartUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo);
+typedef void (*WKGeolocationProviderStopUpdatingCallback)(WKGeolocationManagerRef geolocationManager, const void* clientInfo);
+
+struct WKGeolocationProvider {
+ int version;
+ const void * clientInfo;
+ WKGeolocationProviderStartUpdatingCallback startUpdating;
+ WKGeolocationProviderStopUpdatingCallback stopUpdating;
+};
+typedef struct WKGeolocationProvider WKGeolocationProvider;
+
+enum { kWKGeolocationProviderCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKGeolocationManagerGetTypeID();
+
+WK_EXPORT void WKGeolocationManagerSetProvider(WKGeolocationManagerRef geolocationManager, const WKGeolocationProvider* provider);
+
+WK_EXPORT void WKGeolocationManagerProviderDidChangePosition(WKGeolocationManagerRef geolocationManager, WKGeolocationPositionRef position);
+WK_EXPORT void WKGeolocationManagerProviderDidFailToDeterminePosition(WKGeolocationManagerRef geolocationManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKGeolocationManager_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp
new file mode 100644
index 000000000..cd1757c27
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKGeolocationPermissionRequest.h"
+
+#include "GeolocationPermissionRequestProxy.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKGeolocationPermissionRequestGetTypeID()
+{
+ return toAPI(GeolocationPermissionRequestProxy::APIType);
+}
+
+void WKGeolocationPermissionRequestAllow(WKGeolocationPermissionRequestRef geolocationPermissionRequestRef)
+{
+ return toImpl(geolocationPermissionRequestRef)->allow();
+}
+
+void WKGeolocationPermissionRequestDeny(WKGeolocationPermissionRequestRef geolocationPermissionRequestRef)
+{
+ return toImpl(geolocationPermissionRequestRef)->deny();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h
new file mode 100644
index 000000000..ee27b66ec
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKGeolocationPermissionRequest_h
+#define WKGeolocationPermissionRequest_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKGeolocationPermissionRequestGetTypeID();
+
+WK_EXPORT void WKGeolocationPermissionRequestAllow(WKGeolocationPermissionRequestRef geolocationPermissionRequest);
+WK_EXPORT void WKGeolocationPermissionRequestDeny(WKGeolocationPermissionRequestRef geolocationPermissionRequest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKGeolocationPermissionRequest_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp
new file mode 100644
index 000000000..99195c79c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKGeolocationPosition.h"
+
+#include "WKAPICast.h"
+#include "WebGeolocationPosition.h"
+
+using namespace WebKit;
+
+WKTypeID WKGeolocationPositionGetTypeID()
+{
+ return toAPI(WebGeolocationPosition::APIType);
+}
+
+WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy)
+{
+ RefPtr<WebGeolocationPosition> position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy);
+ return toAPI(position.release().leakRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h
new file mode 100644
index 000000000..85183fd60
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKGeolocationPosition_h
+#define WKGeolocationPosition_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKGeolocationPositionGetTypeID();
+
+WK_EXPORT WKGeolocationPositionRef WKGeolocationPositionCreate(double timestamp, double latitude, double longitude, double accuracy);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKGeolocationPosition_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.cpp b/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.cpp
new file mode 100644
index 000000000..9bf8315b3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKGrammarDetail.h"
+
+#include "APIObject.h"
+#include "ImmutableArray.h"
+#include "WKAPICast.h"
+#include "WebGrammarDetail.h"
+
+using namespace WebKit;
+
+WKTypeID WKGrammarDetailGetTypeID()
+{
+ return toAPI(APIObject::TypeGrammarDetail);
+}
+
+WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription)
+{
+ RefPtr<WebGrammarDetail> detail = WebGrammarDetail::create(location, length, toImpl(guesses), toWTFString(userDescription));
+ return toAPI(detail.release().leakRef());
+}
+
+int WKGrammarDetailGetLocation(WKGrammarDetailRef grammarDetailRef)
+{
+ return toImpl(grammarDetailRef)->location();
+}
+
+int WKGrammarDetailGetLength(WKGrammarDetailRef grammarDetailRef)
+{
+ return toImpl(grammarDetailRef)->length();
+}
+
+WKArrayRef WKGrammarDetailCopyGuesses(WKGrammarDetailRef grammarDetailRef)
+{
+ return toAPI(toImpl(grammarDetailRef)->guesses().leakRef());
+}
+
+WKStringRef WKGrammarDetailCopyUserDescription(WKGrammarDetailRef grammarDetailRef)
+{
+ return toCopiedAPI(toImpl(grammarDetailRef)->userDescription());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.h b/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.h
new file mode 100644
index 000000000..c187ce6ad
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGrammarDetail.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKGrammarDetail_h
+#define WKGrammarDetail_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKGrammarDetailGetTypeID();
+WK_EXPORT WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription);
+
+WK_EXPORT int WKGrammarDetailGetLocation(WKGrammarDetailRef grammarDetailRef);
+WK_EXPORT int WKGrammarDetailGetLength(WKGrammarDetailRef grammarDetailRef);
+WK_EXPORT WKArrayRef WKGrammarDetailCopyGuesses(WKGrammarDetailRef grammarDetailRef);
+WK_EXPORT WKStringRef WKGrammarDetailCopyUserDescription(WKGrammarDetailRef grammarDetailRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKGrammarDetail_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
new file mode 100644
index 000000000..a87b6e35b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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.
+ */
+
+#include "config.h"
+#include "WKHitTestResult.h"
+
+#include "WKAPICast.h"
+#include "WebHitTestResult.h"
+
+using namespace WebKit;
+
+WKTypeID WKHitTestResultGetTypeID()
+{
+ return toAPI(WebHitTestResult::APIType);
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteImageURL());
+}
+
+WKURLRef WKHitTestResultCopyAbsolutePDFURL(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedURLAPI(toImpl(hitTestResultRef)->absolutePDFURL());
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteLinkURL());
+}
+
+WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteMediaURL());
+}
+
+WKStringRef WKHitTestResultCopyLinkLabel(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedAPI(toImpl(hitTestResultRef)->linkLabel());
+}
+
+WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResultRef)
+{
+ return toCopiedAPI(toImpl(hitTestResultRef)->linkTitle());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKHitTestResult.h b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
new file mode 100644
index 000000000..0ba23df6c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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.
+ */
+
+#ifndef WKHitTestResult_h
+#define WKHitTestResult_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKHitTestResultGetTypeID();
+
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsolutePDFURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTestResult);
+
+WK_EXPORT WKStringRef WKHitTestResultCopyLinkLabel(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKStringRef WKHitTestResultCopyLinkTitle(WKHitTestResultRef hitTestResult);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKHitTestResult_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp
new file mode 100644
index 000000000..d667bb752
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKIconDatabase.h"
+
+#include "WKAPICast.h"
+#include "WebIconDatabase.h"
+
+using namespace WebKit;
+
+WKTypeID WKIconDatabaseGetTypeID()
+{
+ return toAPI(WebIconDatabase::APIType);
+}
+
+void WKIconDatabaseSetIconDatabaseClient(WKIconDatabaseRef iconDatabaseRef, const WKIconDatabaseClient* wkClient)
+{
+ toImpl(iconDatabaseRef)->initializeIconDatabaseClient(wkClient);
+}
+
+void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef pageURLRef)
+{
+ toImpl(iconDatabaseRef)->retainIconForPageURL(toWTFString(pageURLRef));
+}
+
+void WKIconDatabaseReleaseIconForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef pageURLRef)
+{
+ toImpl(iconDatabaseRef)->releaseIconForPageURL(toWTFString(pageURLRef));
+}
+
+void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabaseRef)
+{
+ toImpl(iconDatabaseRef)->enableDatabaseCleanup();
+}
+
+void WKIconDatabaseRemoveAllIcons(WKIconDatabaseRef iconDatabaseRef)
+{
+ toImpl(iconDatabaseRef)->removeAllIcons();
+}
+
+void WKIconDatabaseCheckIntegrityBeforeOpening(WKIconDatabaseRef iconDatabaseRef)
+{
+ toImpl(iconDatabaseRef)->checkIntegrityBeforeOpening();
+}
+
+void WKIconDatabaseClose(WKIconDatabaseRef iconDatabaseRef)
+{
+ toImpl(iconDatabaseRef)->close();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h
new file mode 100644
index 000000000..45ceec765
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKIconDatabase.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKIconDatabase_h
+#define WKIconDatabase_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// IconDatabase Client.
+typedef void (*WKIconDatabaseDidChangeIconForPageURLCallback)(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo);
+typedef void (*WKIconDatabaseDidRemoveAllIconsCallback)(WKIconDatabaseRef iconDatabase, const void* clientInfo);
+
+struct WKIconDatabaseClient {
+ int version;
+ const void * clientInfo;
+ WKIconDatabaseDidChangeIconForPageURLCallback didChangeIconForPageURL;
+ WKIconDatabaseDidRemoveAllIconsCallback didRemoveAllIcons;
+};
+typedef struct WKIconDatabaseClient WKIconDatabaseClient;
+
+enum { kWKIconDatabaseClientCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKIconDatabaseGetTypeID();
+
+WK_EXPORT void WKIconDatabaseSetIconDatabaseClient(WKIconDatabaseRef iconDatabase, const WKIconDatabaseClient* client);
+
+WK_EXPORT void WKIconDatabaseRetainIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL);
+WK_EXPORT void WKIconDatabaseReleaseIconForURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL);
+WK_EXPORT void WKIconDatabaseEnableDatabaseCleanup(WKIconDatabaseRef iconDatabase);
+
+WK_EXPORT void WKIconDatabaseRemoveAllIcons(WKIconDatabaseRef iconDatabase);
+WK_EXPORT void WKIconDatabaseCheckIntegrityBeforeOpening(WKIconDatabaseRef iconDatabase);
+
+WK_EXPORT void WKIconDatabaseClose(WKIconDatabaseRef iconDatabase);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKIconDatabase_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
new file mode 100644
index 000000000..325db5ae9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKInspector.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WKAPICast.h"
+#include "WebInspectorProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKInspectorGetTypeID()
+{
+ return toAPI(WebInspectorProxy::APIType);
+}
+
+WKPageRef WKInspectorGetPage(WKInspectorRef inspectorRef)
+{
+ return toAPI(toImpl(inspectorRef)->page());
+}
+
+bool WKInspectorIsVisible(WKInspectorRef inspectorRef)
+{
+ return toImpl(inspectorRef)->isVisible();
+}
+
+void WKInspectorShow(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->show();
+}
+
+void WKInspectorClose(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->close();
+}
+
+void WKInspectorShowConsole(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->showConsole();
+}
+
+bool WKInspectorIsAttached(WKInspectorRef inspectorRef)
+{
+ return toImpl(inspectorRef)->isAttached();
+}
+
+void WKInspectorAttach(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->attach();
+}
+
+void WKInspectorDetach(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->detach();
+}
+
+bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspectorRef)
+{
+ return toImpl(inspectorRef)->isDebuggingJavaScript();
+}
+
+void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->toggleJavaScriptDebugging();
+}
+
+bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspectorRef)
+{
+ return toImpl(inspectorRef)->isProfilingJavaScript();
+}
+
+void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->toggleJavaScriptProfiling();
+}
+
+bool WKInspectorIsProfilingPage(WKInspectorRef inspectorRef)
+{
+ return toImpl(inspectorRef)->isProfilingPage();
+}
+
+void WKInspectorTogglePageProfiling(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->togglePageProfiling();
+}
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.h b/Source/WebKit2/UIProcess/API/C/WKInspector.h
new file mode 100644
index 000000000..c147015f0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKInspector.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKInspector_h
+#define WKInspector_h
+
+#include <WebKit2/WKBase.h>
+
+#if ENABLE(INSPECTOR)
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKInspectorGetTypeID();
+
+WK_EXPORT WKPageRef WKInspectorGetPage(WKInspectorRef inspector);
+
+WK_EXPORT bool WKInspectorIsVisible(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorShow(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorClose(WKInspectorRef inspector);
+
+WK_EXPORT void WKInspectorShowConsole(WKInspectorRef inspector);
+
+WK_EXPORT bool WKInspectorIsAttached(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorAttach(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorDetach(WKInspectorRef inspector);
+
+WK_EXPORT bool WKInspectorIsDebuggingJavaScript(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorToggleJavaScriptDebugging(WKInspectorRef inspector);
+
+WK_EXPORT bool WKInspectorIsProfilingJavaScript(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorToggleJavaScriptProfiling(WKInspectorRef inspector);
+
+WK_EXPORT bool WKInspectorIsProfilingPage(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorTogglePageProfiling(WKInspectorRef inspector);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // WKInspector_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp
new file mode 100644
index 000000000..f050692b4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKKeyValueStorageManager.h"
+
+#include "WKAPICast.h"
+#include "WebKeyValueStorageManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKKeyValueStorageManagerGetTypeID()
+{
+ return toAPI(WebKeyValueStorageManagerProxy::APIType);
+}
+
+void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManagerRef, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction callback)
+{
+ toImpl(keyValueStorageManagerRef)->getKeyValueStorageOrigins(ArrayCallback::create(context, callback));
+}
+
+void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef keyValueStorageManagerRef, WKSecurityOriginRef originRef)
+{
+ toImpl(keyValueStorageManagerRef)->deleteEntriesForOrigin(toImpl(originRef));
+}
+
+void WKKeyValueStorageManagerDeleteAllEntries(WKKeyValueStorageManagerRef keyValueStorageManagerRef)
+{
+ toImpl(keyValueStorageManagerRef)->deleteAllEntries();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h
new file mode 100644
index 000000000..a0ee27825
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKKeyValueStorageManager.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKKeyValueStorageManager_h
+#define WKKeyValueStorageManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKKeyValueStorageManagerGetTypeID();
+
+typedef void (*WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKKeyValueStorageManagerGetKeyValueStorageOrigins(WKKeyValueStorageManagerRef keyValueStorageManager, void* context, WKKeyValueStorageManagerGetKeyValueStorageOriginsFunction function);
+
+WK_EXPORT void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef keyValueStorageManager, WKSecurityOriginRef origin);
+WK_EXPORT void WKKeyValueStorageManagerDeleteAllEntries(WKKeyValueStorageManagerRef keyValueStorageManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKKeyValueStorageManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp
new file mode 100644
index 000000000..6e2ecce06
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKMediaCacheManager.h"
+
+#include "WKAPICast.h"
+#include "WebMediaCacheManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKMediaCacheManagerGetTypeID()
+{
+ return toAPI(WebMediaCacheManagerProxy::APIType);
+}
+
+void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManagerRef, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction callback)
+{
+ toImpl(mediaCacheManagerRef)->getHostnamesWithMediaCache(ArrayCallback::create(context, callback));
+}
+
+void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManagerRef, WKStringRef hostname)
+{
+ toImpl(mediaCacheManagerRef)->clearCacheForHostname(toWTFString(hostname));
+}
+
+void WKMediaCacheManagerClearCacheForAllHostnames(WKMediaCacheManagerRef mediaCacheManagerRef)
+{
+ toImpl(mediaCacheManagerRef)->clearCacheForAllHostnames();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h
new file mode 100644
index 000000000..eee1b9291
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKMediaCacheManager.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKMediaCacheManager_h
+#define WKMediaCacheManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKMediaCacheManagerGetTypeID();
+
+typedef void (*WKMediaCacheManagerGetHostnamesWithMediaCacheFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKMediaCacheManagerGetHostnamesWithMediaCache(WKMediaCacheManagerRef mediaCacheManager, void* context, WKMediaCacheManagerGetHostnamesWithMediaCacheFunction function);
+
+WK_EXPORT void WKMediaCacheManagerClearCacheForHostname(WKMediaCacheManagerRef mediaCacheManager, WKStringRef hostname);
+WK_EXPORT void WKMediaCacheManagerClearCacheForAllHostnames(WKMediaCacheManagerRef mediaCacheManager);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKMediaCacheManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h
new file mode 100644
index 000000000..ee0bd1777
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKNativeEvent_h
+#define WKNativeEvent_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef __APPLE__
+#ifdef __OBJC__
+@class NSEvent;
+#elif __cplusplus
+class NSEvent;
+#else
+struct NSEvent;
+#endif
+typedef NSEvent *WKNativeEventPtr;
+#elif defined(WIN32) || defined(_WIN32)
+typedef const struct tagMSG* WKNativeEventPtr;
+#else
+typedef const void* WKNativeEventPtr;
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKNativeEvent_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp b/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp
new file mode 100644
index 000000000..ba09d4d81
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKNavigationData.h"
+
+#include "WKAPICast.h"
+#include "WebNavigationData.h"
+#include "WebURLRequest.h"
+
+using namespace WebKit;
+
+WKTypeID WKNavigationDataGetTypeID()
+{
+ return toAPI(WebNavigationData::APIType);
+}
+
+WKStringRef WKNavigationDataCopyTitle(WKNavigationDataRef navigationDataRef)
+{
+ return toCopiedAPI(toImpl(navigationDataRef)->title());
+}
+
+WKURLRef WKNavigationDataCopyURL(WKNavigationDataRef navigationDataRef)
+{
+ return toCopiedURLAPI(toImpl(navigationDataRef)->url());
+}
+
+WKURLRequestRef WKNavigationDataCopyOriginalRequest(WKNavigationDataRef navigationData)
+{
+ return toAPI(WebURLRequest::create(toImpl(navigationData)->originalRequest()).leakRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNavigationData.h b/Source/WebKit2/UIProcess/API/C/WKNavigationData.h
new file mode 100644
index 000000000..cf5d1e53a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKNavigationData_h
+#define WKNavigationData_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNavigationDataGetTypeID();
+
+WK_EXPORT WKStringRef WKNavigationDataCopyTitle(WKNavigationDataRef navigationData);
+WK_EXPORT WKURLRef WKNavigationDataCopyURL(WKNavigationDataRef navigationData);
+WK_EXPORT WKURLRequestRef WKNavigationDataCopyOriginalRequest(WKNavigationDataRef navigationData);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKNavigationData_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotification.cpp b/Source/WebKit2/UIProcess/API/C/WKNotification.cpp
new file mode 100644
index 000000000..db7d1f02f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotification.cpp
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKNotification.h"
+
+#include "WKAPICast.h"
+#include "WebNotification.h"
+#include "WebSecurityOrigin.h"
+
+using namespace WebKit;
+
+WKTypeID WKNotificationGetTypeID()
+{
+ return toAPI(WebNotification::APIType);
+}
+
+WKStringRef WKNotificationCopyTitle(WKNotificationRef notification)
+{
+ return toCopiedAPI(toImpl(notification)->title());
+}
+
+WKStringRef WKNotificationCopyBody(WKNotificationRef notification)
+{
+ return toCopiedAPI(toImpl(notification)->body());
+}
+
+WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification)
+{
+ return toAPI(toImpl(notification)->origin());
+}
+
+uint64_t WKNotificationGetID(WKNotificationRef notification)
+{
+ return toImpl(notification)->notificationID();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotification.h b/Source/WebKit2/UIProcess/API/C/WKNotification.h
new file mode 100644
index 000000000..07311af3f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotification.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKNotification_h
+#define WKNotification_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNotificationGetTypeID();
+
+WK_EXPORT WKStringRef WKNotificationCopyTitle(WKNotificationRef notification);
+WK_EXPORT WKStringRef WKNotificationCopyBody(WKNotificationRef notification);
+WK_EXPORT WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification);
+WK_EXPORT uint64_t WKNotificationGetID(WKNotificationRef notification);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKNotification_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp b/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp
new file mode 100644
index 000000000..6ddfa4cc8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotificationManager.cpp
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKNotificationManager.h"
+
+#include "WKAPICast.h"
+#include "WebNotificationManagerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKNotificationManagerGetTypeID()
+{
+ return toAPI(WebNotificationManagerProxy::APIType);
+}
+
+void WKNotificationManagerSetProvider(WKNotificationManagerRef managerRef, const WKNotificationProvider* wkProvider)
+{
+ toImpl(managerRef)->initializeProvider(wkProvider);
+}
+
+void WKNotificationManagerProviderDidShowNotification(WKNotificationManagerRef managerRef, uint64_t notificationID)
+{
+ toImpl(managerRef)->providerDidShowNotification(notificationID);
+}
+
+void WKNotificationManagerProviderDidClickNotification(WKNotificationManagerRef managerRef, uint64_t notificationID)
+{
+ toImpl(managerRef)->providerDidClickNotification(notificationID);
+}
+
+void WKNotificationManagerProviderDidCloseNotifications(WKNotificationManagerRef managerRef, WKArrayRef notificationIDs)
+{
+ toImpl(managerRef)->providerDidCloseNotifications(toImpl(notificationIDs));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h b/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h
new file mode 100644
index 000000000..7360dad01
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotificationManager.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKNotificationManager_h
+#define WKNotificationManager_h
+
+#include "WKNotificationProvider.h"
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNotificationManagerGetTypeID();
+WK_EXPORT void WKNotificationManagerSetProvider(WKNotificationManagerRef managerRef, const WKNotificationProvider* wkProvider);
+
+WK_EXPORT void WKNotificationManagerProviderDidShowNotification(WKNotificationManagerRef managerRef, uint64_t notificationID);
+WK_EXPORT void WKNotificationManagerProviderDidClickNotification(WKNotificationManagerRef managerRef, uint64_t notificationID);
+WK_EXPORT void WKNotificationManagerProviderDidCloseNotifications(WKNotificationManagerRef managerRef, WKArrayRef notificationIDs);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKNotificationManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.cpp
new file mode 100644
index 000000000..596348d72
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKNotificationPermissionRequest.h"
+
+#include "NotificationPermissionRequest.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKNotificationPermissionRequestGetTypeID()
+{
+ return toAPI(NotificationPermissionRequest::APIType);
+}
+
+void WKNotificationPermissionRequestAllow(WKNotificationPermissionRequestRef notificationPermissionRequest)
+{
+ return toImpl(notificationPermissionRequest)->allow();
+}
+
+void WKNotificationPermissionRequestDeny(WKNotificationPermissionRequestRef notificationPermissionRequest)
+{
+ return toImpl(notificationPermissionRequest)->deny();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.h b/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.h
new file mode 100644
index 000000000..1947a06aa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotificationPermissionRequest.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKNotificationPermissionRequest_h
+#define WKNotificationPermissionRequest_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKNotificationPermissionRequestGetTypeID();
+
+WK_EXPORT void WKNotificationPermissionRequestAllow(WKNotificationPermissionRequestRef notificationPermissionRequest);
+WK_EXPORT void WKNotificationPermissionRequestDeny(WKNotificationPermissionRequestRef notificationPermissionRequest);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKNotificationPermissionRequest_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h b/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h
new file mode 100644
index 000000000..580608ccf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKNotificationProvider_h
+#define WKNotificationProvider_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*WKNotificationProviderShowCallback)(WKPageRef page, WKNotificationRef notification, const void* clientInfo);
+typedef void (*WKNotificationProviderCancelCallback)(WKNotificationRef notification, const void* clientInfo);
+typedef void (*WKNotificationProviderDidDestroyNotificationCallback)(WKNotificationRef notification, const void* clientInfo);
+typedef int (*WKNotificationProviderPolicyForNotificationPermissionAtOriginCallback)(WKSecurityOriginRef origin, const void *clientInfo);
+typedef void (*WKNotificationProviderAddNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo);
+typedef void (*WKNotificationProviderRemoveNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo);
+
+struct WKNotificationProvider {
+ int version;
+ const void* clientInfo;
+ WKNotificationProviderShowCallback show;
+ WKNotificationProviderCancelCallback cancel;
+ WKNotificationProviderDidDestroyNotificationCallback didDestroyNotification;
+ WKNotificationProviderPolicyForNotificationPermissionAtOriginCallback policyForNotificationPermissionAtOrigin;
+ WKNotificationProviderAddNotificationManagerCallback addNotificationManager;
+ WKNotificationProviderRemoveNotificationManagerCallback removeNotificationManager;
+};
+typedef struct WKNotificationProvider WKNotificationProvider;
+
+enum { kWKNotificationProviderCurrentVersion = 0 };
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // WKNotificationProvider_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp
new file mode 100644
index 000000000..c6f7a661c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKOpenPanelParameters.h"
+
+#include "ImmutableArray.h"
+#include "WKAPICast.h"
+#include "WebOpenPanelParameters.h"
+
+using namespace WebKit;
+
+WKTypeID WKOpenPanelParametersGetTypeID()
+{
+ return toAPI(WebOpenPanelParameters::APIType);
+}
+
+bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef)
+{
+ return toImpl(parametersRef)->allowMultipleFiles();
+}
+
+WKArrayRef WKOpenPanelParametersCopyAcceptedMIMETypes(WKOpenPanelParametersRef parametersRef)
+{
+ return toAPI(toImpl(parametersRef)->acceptMIMETypes().leakRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h
new file mode 100644
index 000000000..64577bad9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKOpenPanelParameters_h
+#define WKOpenPanelParameters_h
+
+#include <WebKit2/WKBase.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKOpenPanelParametersGetTypeID();
+
+WK_EXPORT bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parameters);
+
+WK_EXPORT WKArrayRef WKOpenPanelParametersCopyAcceptedMIMETypes(WKOpenPanelParametersRef parameters);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKOpenPanelParameters_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp
new file mode 100644
index 000000000..8c793182d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKOpenPanelResultListener.h"
+
+#include "WKAPICast.h"
+#include "WebOpenPanelResultListenerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKOpenPanelResultListenerGetTypeID()
+{
+ return toAPI(WebOpenPanelResultListenerProxy::APIType);
+}
+
+void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listenerRef, WKArrayRef fileURLsRef)
+{
+ toImpl(listenerRef)->chooseFiles(toImpl(fileURLsRef));
+}
+
+void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listenerRef)
+{
+ toImpl(listenerRef)->cancel();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h
new file mode 100644
index 000000000..d581738a5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKOpenPanelResultListener_h
+#define WKOpenPanelResultListener_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKOpenPanelResultListenerGetTypeID();
+
+WK_EXPORT void WKOpenPanelResultListenerChooseFiles(WKOpenPanelResultListenerRef listener, WKArrayRef fileURLs);
+WK_EXPORT void WKOpenPanelResultListenerCancel(WKOpenPanelResultListenerRef listener);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKOpenPanelResultListener_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
new file mode 100644
index 000000000..9c7a02916
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -0,0 +1,663 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKPage.h"
+#include "WKPagePrivate.h"
+
+#include "PrintInfo.h"
+#include "WKAPICast.h"
+#include "WebBackForwardList.h"
+#include "WebData.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include <WebCore/Page.h>
+
+#ifdef __BLOCKS__
+#include <Block.h>
+#endif
+
+using namespace WebCore;
+using namespace WebKit;
+
+WKTypeID WKPageGetTypeID()
+{
+ return toAPI(WebPageProxy::APIType);
+}
+
+WKContextRef WKPageGetContext(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->process()->context());
+}
+
+WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->pageGroup());
+}
+
+void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
+{
+ toImpl(pageRef)->loadURL(toWTFString(URLRef));
+}
+
+void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef)
+{
+ toImpl(pageRef)->loadURLRequest(toImpl(urlRequestRef));
+}
+
+void WKPageLoadHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef)
+{
+ toImpl(pageRef)->loadHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef));
+}
+
+void WKPageLoadAlternateHTMLString(WKPageRef pageRef, WKStringRef htmlStringRef, WKURLRef baseURLRef, WKURLRef unreachableURLRef)
+{
+ toImpl(pageRef)->loadAlternateHTMLString(toWTFString(htmlStringRef), toWTFString(baseURLRef), toWTFString(unreachableURLRef));
+}
+
+void WKPageLoadPlainTextString(WKPageRef pageRef, WKStringRef plainTextStringRef)
+{
+ toImpl(pageRef)->loadPlainTextString(toWTFString(plainTextStringRef));
+}
+
+void WKPageStopLoading(WKPageRef pageRef)
+{
+ toImpl(pageRef)->stopLoading();
+}
+
+void WKPageReload(WKPageRef pageRef)
+{
+ toImpl(pageRef)->reload(false);
+}
+
+void WKPageReloadFromOrigin(WKPageRef pageRef)
+{
+ toImpl(pageRef)->reload(true);
+}
+
+bool WKPageTryClose(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->tryClose();
+}
+
+void WKPageClose(WKPageRef pageRef)
+{
+ toImpl(pageRef)->close();
+}
+
+bool WKPageIsClosed(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->isClosed();
+}
+
+void WKPageGoForward(WKPageRef pageRef)
+{
+ toImpl(pageRef)->goForward();
+}
+
+bool WKPageCanGoForward(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->canGoForward();
+}
+
+void WKPageGoBack(WKPageRef pageRef)
+{
+ toImpl(pageRef)->goBack();
+}
+
+bool WKPageCanGoBack(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->canGoBack();
+}
+
+void WKPageGoToBackForwardListItem(WKPageRef pageRef, WKBackForwardListItemRef itemRef)
+{
+ toImpl(pageRef)->goToBackForwardItem(toImpl(itemRef));
+}
+
+void WKPageTryRestoreScrollPosition(WKPageRef pageRef)
+{
+ toImpl(pageRef)->tryRestoreScrollPosition();
+}
+
+WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->backForwardList());
+}
+
+bool WKPageWillHandleHorizontalScrollEvents(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->willHandleHorizontalScrollEvents();
+}
+
+WKStringRef WKPageCopyTitle(WKPageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->pageTitle());
+}
+
+WKFrameRef WKPageGetMainFrame(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->mainFrame());
+}
+
+WKFrameRef WKPageGetFocusedFrame(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->focusedFrame());
+}
+
+WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->frameSetLargestFrame());
+}
+
+uint64_t WKPageGetRenderTreeSize(WKPageRef page)
+{
+ return toImpl(page)->renderTreeSize();
+}
+
+#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
+WKInspectorRef WKPageGetInspector(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->inspector());
+}
+#endif
+
+double WKPageGetEstimatedProgress(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->estimatedProgress();
+}
+
+void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef pageRef, bool memoryCacheClientCallsEnabled)
+{
+ toImpl(pageRef)->setMemoryCacheClientCallsEnabled(memoryCacheClientCallsEnabled);
+}
+
+WKStringRef WKPageCopyUserAgent(WKPageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->userAgent());
+}
+
+WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->applicationNameForUserAgent());
+}
+
+void WKPageSetApplicationNameForUserAgent(WKPageRef pageRef, WKStringRef applicationNameRef)
+{
+ toImpl(pageRef)->setApplicationNameForUserAgent(toWTFString(applicationNameRef));
+}
+
+WKStringRef WKPageCopyCustomUserAgent(WKPageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->customUserAgent());
+}
+
+void WKPageSetCustomUserAgent(WKPageRef pageRef, WKStringRef userAgentRef)
+{
+ toImpl(pageRef)->setCustomUserAgent(toWTFString(userAgentRef));
+}
+
+bool WKPageSupportsTextEncoding(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->supportsTextEncoding();
+}
+
+WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef pageRef)
+{
+ return toCopiedAPI(toImpl(pageRef)->customTextEncodingName());
+}
+
+void WKPageSetCustomTextEncodingName(WKPageRef pageRef, WKStringRef encodingNameRef)
+{
+ toImpl(pageRef)->setCustomTextEncodingName(toWTFString(encodingNameRef));
+}
+
+void WKPageTerminate(WKPageRef pageRef)
+{
+ toImpl(pageRef)->terminateProcess();
+}
+
+WKStringRef WKPageGetSessionHistoryURLValueType()
+{
+ static WebString* sessionHistoryURLValueType = WebString::create("SessionHistoryURL").leakRef();
+ return toAPI(sessionHistoryURLValueType);
+}
+
+WKDataRef WKPageCopySessionState(WKPageRef pageRef, void *context, WKPageSessionStateFilterCallback filter)
+{
+ return toAPI(toImpl(pageRef)->sessionStateData(filter, context).leakRef());
+}
+
+void WKPageRestoreFromSessionState(WKPageRef pageRef, WKDataRef sessionStateData)
+{
+ toImpl(pageRef)->restoreFromSessionStateData(toImpl(sessionStateData));
+}
+
+double WKPageGetTextZoomFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->textZoomFactor();
+}
+
+double WKPageGetBackingScaleFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->deviceScaleFactor();
+}
+
+void WKPageSetCustomBackingScaleFactor(WKPageRef pageRef, double customScaleFactor)
+{
+ toImpl(pageRef)->setCustomDeviceScaleFactor(customScaleFactor);
+}
+
+bool WKPageSupportsTextZoom(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->supportsTextZoom();
+}
+
+void WKPageSetTextZoomFactor(WKPageRef pageRef, double zoomFactor)
+{
+ toImpl(pageRef)->setTextZoomFactor(zoomFactor);
+}
+
+double WKPageGetPageZoomFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->pageZoomFactor();
+}
+
+void WKPageSetPageZoomFactor(WKPageRef pageRef, double zoomFactor)
+{
+ toImpl(pageRef)->setPageZoomFactor(zoomFactor);
+}
+
+void WKPageSetPageAndTextZoomFactors(WKPageRef pageRef, double pageZoomFactor, double textZoomFactor)
+{
+ toImpl(pageRef)->setPageAndTextZoomFactors(pageZoomFactor, textZoomFactor);
+}
+
+void WKPageSetScaleFactor(WKPageRef pageRef, double scale, WKPoint origin)
+{
+ toImpl(pageRef)->scalePage(scale, toIntPoint(origin));
+}
+
+double WKPageGetScaleFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->pageScaleFactor();
+}
+
+void WKPageSetUseFixedLayout(WKPageRef pageRef, bool fixed)
+{
+ toImpl(pageRef)->setUseFixedLayout(fixed);
+}
+
+void WKPageSetFixedLayoutSize(WKPageRef pageRef, WKSize size)
+{
+ toImpl(pageRef)->setFixedLayoutSize(toIntSize(size));
+}
+
+bool WKPageUseFixedLayout(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->useFixedLayout();
+}
+
+WKSize WKPageFixedLayoutSize(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->fixedLayoutSize());
+}
+
+bool WKPageHasHorizontalScrollbar(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->hasHorizontalScrollbar();
+}
+
+bool WKPageHasVerticalScrollbar(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->hasVerticalScrollbar();
+}
+
+bool WKPageIsPinnedToLeftSide(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->isPinnedToLeftSide();
+}
+
+bool WKPageIsPinnedToRightSide(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->isPinnedToRightSide();
+}
+
+void WKPageSetPaginationMode(WKPageRef pageRef, WKPaginationMode paginationMode)
+{
+ Page::Pagination::Mode mode;
+ switch (paginationMode) {
+ case kWKPaginationModeUnpaginated:
+ mode = Page::Pagination::Unpaginated;
+ break;
+ case kWKPaginationModeHorizontal:
+ mode = Page::Pagination::HorizontallyPaginated;
+ break;
+ case kWKPaginationModeVertical:
+ mode = Page::Pagination::VerticallyPaginated;
+ break;
+ default:
+ return;
+ }
+ toImpl(pageRef)->setPaginationMode(mode);
+}
+
+WKPaginationMode WKPageGetPaginationMode(WKPageRef pageRef)
+{
+ switch (toImpl(pageRef)->paginationMode()) {
+ case Page::Pagination::Unpaginated:
+ return kWKPaginationModeUnpaginated;
+ case Page::Pagination::HorizontallyPaginated:
+ return kWKPaginationModeHorizontal;
+ case Page::Pagination::VerticallyPaginated:
+ return kWKPaginationModeVertical;
+ }
+
+ ASSERT_NOT_REACHED();
+ return kWKPaginationModeUnpaginated;
+}
+
+void WKPageSetPageLength(WKPageRef pageRef, double pageLength)
+{
+ toImpl(pageRef)->setPageLength(pageLength);
+}
+
+double WKPageGetPageLength(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->pageLength();
+}
+
+void WKPageSetGapBetweenPages(WKPageRef pageRef, double gap)
+{
+ toImpl(pageRef)->setGapBetweenPages(gap);
+}
+
+double WKPageGetGapBetweenPages(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->gapBetweenPages();
+}
+
+unsigned WKPageGetPageCount(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->pageCount();
+}
+
+bool WKPageCanDelete(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->canDelete();
+}
+
+bool WKPageHasSelectedRange(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->hasSelectedRange();
+}
+
+bool WKPageIsContentEditable(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->isContentEditable();
+}
+
+void WKPageSetMaintainsInactiveSelection(WKPageRef pageRef, bool newValue)
+{
+ return toImpl(pageRef)->setMaintainsInactiveSelection(newValue);
+}
+
+void WKPageCenterSelectionInVisibleArea(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->centerSelectionInVisibleArea();
+}
+
+void WKPageFindString(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
+{
+ toImpl(pageRef)->findString(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
+}
+
+void WKPageHideFindUI(WKPageRef pageRef)
+{
+ toImpl(pageRef)->hideFindUI();
+}
+
+void WKPageCountStringMatches(WKPageRef pageRef, WKStringRef string, WKFindOptions options, unsigned maxMatchCount)
+{
+ toImpl(pageRef)->countStringMatches(toImpl(string)->string(), toFindOptions(options), maxMatchCount);
+}
+
+void WKPageSetPageContextMenuClient(WKPageRef pageRef, const WKPageContextMenuClient* wkClient)
+{
+ toImpl(pageRef)->initializeContextMenuClient(wkClient);
+}
+
+void WKPageSetPageFindClient(WKPageRef pageRef, const WKPageFindClient* wkClient)
+{
+ toImpl(pageRef)->initializeFindClient(wkClient);
+}
+
+void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClient* wkClient)
+{
+ toImpl(pageRef)->initializeFormClient(wkClient);
+}
+
+void WKPageSetPageLoaderClient(WKPageRef pageRef, const WKPageLoaderClient* wkClient)
+{
+ toImpl(pageRef)->initializeLoaderClient(wkClient);
+}
+
+void WKPageSetPagePolicyClient(WKPageRef pageRef, const WKPagePolicyClient* wkClient)
+{
+ toImpl(pageRef)->initializePolicyClient(wkClient);
+}
+
+void WKPageSetPageResourceLoadClient(WKPageRef pageRef, const WKPageResourceLoadClient* wkClient)
+{
+ toImpl(pageRef)->initializeResourceLoadClient(wkClient);
+}
+
+void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient* wkClient)
+{
+ toImpl(pageRef)->initializeUIClient(wkClient);
+}
+
+void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
+{
+ toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), ScriptValueCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callRunJavaScriptBlockAndRelease(WKSerializedScriptValueRef resultValue, WKErrorRef error, void* context)
+{
+ WKPageRunJavaScriptBlock block = (WKPageRunJavaScriptBlock)context;
+ block(resultValue, error);
+ Block_release(block);
+}
+
+void WKPageRunJavaScriptInMainFrame_b(WKPageRef pageRef, WKStringRef scriptRef, WKPageRunJavaScriptBlock block)
+{
+ WKPageRunJavaScriptInMainFrame(pageRef, scriptRef, Block_copy(block), callRunJavaScriptBlockAndRelease);
+}
+#endif
+
+void WKPageRenderTreeExternalRepresentation(WKPageRef pageRef, void* context, WKPageRenderTreeExternalRepresentationFunction callback)
+{
+ toImpl(pageRef)->getRenderTreeExternalRepresentation(StringCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callRenderTreeExternalRepresentationBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
+{
+ WKPageRenderTreeExternalRepresentationBlock block = (WKPageRenderTreeExternalRepresentationBlock)context;
+ block(resultValue, error);
+ Block_release(block);
+}
+
+void WKPageRenderTreeExternalRepresentation_b(WKPageRef pageRef, WKPageRenderTreeExternalRepresentationBlock block)
+{
+ WKPageRenderTreeExternalRepresentation(pageRef, Block_copy(block), callRenderTreeExternalRepresentationBlockAndDispose);
+}
+#endif
+
+void WKPageGetSourceForFrame(WKPageRef pageRef, WKFrameRef frameRef, void* context, WKPageGetSourceForFrameFunction callback)
+{
+ toImpl(pageRef)->getSourceForFrame(toImpl(frameRef), StringCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetSourceForFrameBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
+{
+ WKPageGetSourceForFrameBlock block = (WKPageGetSourceForFrameBlock)context;
+ block(resultValue, error);
+ Block_release(block);
+}
+
+void WKPageGetSourceForFrame_b(WKPageRef pageRef, WKFrameRef frameRef, WKPageGetSourceForFrameBlock block)
+{
+ WKPageGetSourceForFrame(pageRef, frameRef, Block_copy(block), callGetSourceForFrameBlockBlockAndDispose);
+}
+#endif
+
+void WKPageGetContentsAsString(WKPageRef pageRef, void* context, WKPageGetContentsAsStringFunction callback)
+{
+ toImpl(pageRef)->getContentsAsString(StringCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callContentsAsStringBlockBlockAndDispose(WKStringRef resultValue, WKErrorRef error, void* context)
+{
+ WKPageGetContentsAsStringBlock block = (WKPageGetContentsAsStringBlock)context;
+ block(resultValue, error);
+ Block_release(block);
+}
+
+void WKPageGetContentsAsString_b(WKPageRef pageRef, WKPageGetSourceForFrameBlock block)
+{
+ WKPageGetContentsAsString(pageRef, Block_copy(block), callContentsAsStringBlockBlockAndDispose);
+}
+#endif
+
+void WKPageForceRepaint(WKPageRef pageRef, void* context, WKPageForceRepaintFunction callback)
+{
+ toImpl(pageRef)->forceRepaint(VoidCallback::create(context, callback));
+}
+
+WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef pageRef)
+{
+ if (toImpl(pageRef)->pendingAPIRequestURL().isNull())
+ return 0;
+ return toCopiedURLAPI(toImpl(pageRef)->pendingAPIRequestURL());
+}
+
+WKURLRef WKPageCopyActiveURL(WKPageRef pageRef)
+{
+ return toCopiedURLAPI(toImpl(pageRef)->activeURL());
+}
+
+WKURLRef WKPageCopyProvisionalURL(WKPageRef pageRef)
+{
+ return toCopiedURLAPI(toImpl(pageRef)->provisionalURL());
+}
+
+WKURLRef WKPageCopyCommittedURL(WKPageRef pageRef)
+{
+ return toCopiedURLAPI(toImpl(pageRef)->committedURL());
+}
+
+void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags)
+{
+ WebPageProxy::setDebugPaintFlags(flags);
+}
+
+WKPageDebugPaintFlags WKPageGetDebugPaintFlags()
+{
+ return WebPageProxy::debugPaintFlags();
+}
+
+WKStringRef WKPageCopyStandardUserAgentWithApplicationName(WKStringRef applicationName)
+{
+ return toCopiedAPI(WebPageProxy::standardUserAgent(toImpl(applicationName)->string()));
+}
+
+void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
+{
+ toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create(context, callback));
+}
+
+void WKPageExecuteCommand(WKPageRef pageRef, WKStringRef command)
+{
+ toImpl(pageRef)->executeEditCommand(toImpl(command)->string());
+}
+
+#if PLATFORM(MAC) || PLATFORM(WIN)
+struct ComputedPagesContext {
+ ComputedPagesContext(WKPageComputePagesForPrintingFunction callback, void* context)
+ : callback(callback)
+ , context(context)
+ {
+ }
+ WKPageComputePagesForPrintingFunction callback;
+ void* context;
+};
+
+static void computedPagesCallback(const Vector<WebCore::IntRect>& rects, double scaleFactor, WKErrorRef error, void* untypedContext)
+{
+ OwnPtr<ComputedPagesContext> context = adoptPtr(static_cast<ComputedPagesContext*>(untypedContext));
+ Vector<WKRect> wkRects(rects.size());
+ for (size_t i = 0; i < rects.size(); ++i)
+ wkRects[i] = toAPI(rects[i]);
+ context->callback(wkRects.data(), wkRects.size(), scaleFactor, error, context->context);
+}
+
+static PrintInfo printInfoFromWKPrintInfo(const WKPrintInfo& printInfo)
+{
+ PrintInfo result;
+ result.pageSetupScaleFactor = printInfo.pageSetupScaleFactor;
+ result.availablePaperWidth = printInfo.availablePaperWidth;
+ result.availablePaperHeight = printInfo.availablePaperHeight;
+ return result;
+}
+
+void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
+{
+ toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create(new ComputedPagesContext(callback, context), computedPagesCallback));
+}
+
+void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo)
+{
+ toImpl(page)->beginPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo));
+}
+
+void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context)
+{
+ toImpl(page)->drawPagesToPDF(toImpl(frame), printInfoFromWKPrintInfo(printInfo), first, count, DataCallback::create(context, callback));
+}
+#endif
+
+WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef)
+{
+ return 0;
+}
+
+void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync)
+{
+ toImpl(page)->setShouldSendEventsSynchronously(sync);
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
new file mode 100644
index 000000000..1de70628c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -0,0 +1,456 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#ifndef WKPage_h
+#define WKPage_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKEvent.h>
+#include <WebKit2/WKFindOptions.h>
+#include <WebKit2/WKGeometry.h>
+#include <WebKit2/WKNativeEvent.h>
+#include <WebKit2/WKPageLoadTypes.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKFocusDirectionBackward = 0,
+ kWKFocusDirectionForward = 1
+};
+typedef uint32_t WKFocusDirection;
+
+typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
+
+// FrameLoad Client
+typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageDidDetectXSSForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
+typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
+typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
+typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
+typedef void (*WKPageDidFailToInitializePluginCallback)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
+
+struct WKPageLoaderClient {
+ int version;
+ const void * clientInfo;
+ WKPageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
+ WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
+ WKPageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
+ WKPageDidCommitLoadForFrameCallback didCommitLoadForFrame;
+ WKPageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame;
+ WKPageDidFinishLoadForFrameCallback didFinishLoadForFrame;
+ WKPageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame;
+ WKPageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame;
+ WKPageDidReceiveTitleForFrameCallback didReceiveTitleForFrame;
+ WKPageDidFirstLayoutForFrameCallback didFirstLayoutForFrame;
+ WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame;
+ WKPageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy;
+ WKPageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame;
+ WKPageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame;
+ WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback canAuthenticateAgainstProtectionSpaceInFrame;
+ WKPageDidReceiveAuthenticationChallengeInFrameCallback didReceiveAuthenticationChallengeInFrame;
+
+ // FIXME: Move to progress client.
+ WKPageCallback didStartProgress;
+ WKPageCallback didChangeProgress;
+ WKPageCallback didFinishProgress;
+
+ // FIXME: These three functions should not be part of this client.
+ WKPageCallback processDidBecomeUnresponsive;
+ WKPageCallback processDidBecomeResponsive;
+ WKPageCallback processDidCrash;
+ WKPageDidChangeBackForwardListCallback didChangeBackForwardList;
+ WKPageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem;
+ WKPageDidFailToInitializePluginCallback didFailToInitializePlugin;
+
+ // Version 1
+ WKPageDidDetectXSSForFrameCallback didDetectXSSForFrame;
+};
+typedef struct WKPageLoaderClient WKPageLoaderClient;
+
+enum { kWKPageLoaderClientCurrentVersion = 1 };
+
+// Policy Client.
+typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
+typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
+typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
+typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);
+
+struct WKPagePolicyClient {
+ int version;
+ const void * clientInfo;
+ WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
+ WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
+ WKPageDecidePolicyForResponseCallback decidePolicyForResponse;
+ WKPageUnableToImplementPolicyCallback unableToImplementPolicy;
+};
+typedef struct WKPagePolicyClient WKPagePolicyClient;
+
+enum { kWKPagePolicyClientCurrentVersion = 0 };
+
+// Form Client.
+typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
+
+struct WKPageFormClient {
+ int version;
+ const void * clientInfo;
+ WKPageWillSubmitFormCallback willSubmitForm;
+};
+typedef struct WKPageFormClient WKPageFormClient;
+
+enum { kWKPageFormClientCurrentVersion = 0 };
+
+// Resource Load Client.
+typedef void (*WKPageDidInitiateLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, bool pageIsProvisionallyLoading, const void* clientInfo);
+typedef void (*WKPageDidSendRequestForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo);
+typedef void (*WKPageDidReceiveResponseForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLResponseRef response, const void* clientInfo);
+typedef void (*WKPageDidReceiveContentLengthForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo);
+typedef void (*WKPageDidFinishLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo);
+typedef void (*WKPageDidFailLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo);
+
+struct WKPageResourceLoadClient {
+ int version;
+ const void * clientInfo;
+ WKPageDidInitiateLoadForResourceCallback didInitiateLoadForResource;
+ WKPageDidSendRequestForResourceCallback didSendRequestForResource;
+ WKPageDidReceiveResponseForResourceCallback didReceiveResponseForResource;
+ WKPageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource;
+ WKPageDidFinishLoadForResourceCallback didFinishLoadForResource;
+ WKPageDidFailLoadForResourceCallback didFailLoadForResource;
+};
+typedef struct WKPageResourceLoadClient WKPageResourceLoadClient;
+
+enum { kWKPageResourceLoadClientCurrentVersion = 0 };
+
+// UI Client
+typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
+typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
+typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
+typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
+typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
+typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
+typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
+typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
+typedef void (*WKPageDidNotHandleWheelEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
+typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo);
+typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo);
+typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo);
+typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo);
+typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
+typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
+typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo);
+typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
+typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
+typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
+typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
+typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
+typedef bool (*WKPageShouldInterruptJavaScriptCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageDecidePolicyForNotificationPermissionRequestCallback)(WKPageRef page, WKSecurityOriginRef origin, WKNotificationPermissionRequestRef permissionRequest, const void *clientInfo);
+
+// Deprecated
+typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
+typedef void (*WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
+
+struct WKPageUIClient {
+ int version;
+ const void * clientInfo;
+
+ // Version 0
+ WKPageCreateNewPageCallback_deprecatedForUseWithV0 createNewPage_deprecatedForUseWithV0;
+ WKPageCallback showPage;
+ WKPageCallback close;
+ WKPageTakeFocusCallback takeFocus;
+ WKPageFocusCallback focus;
+ WKPageUnfocusCallback unfocus;
+ WKPageRunJavaScriptAlertCallback runJavaScriptAlert;
+ WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm;
+ WKPageRunJavaScriptPromptCallback runJavaScriptPrompt;
+ WKPageSetStatusTextCallback setStatusText;
+ WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0 mouseDidMoveOverElement_deprecatedForUseWithV0;
+ WKPageMissingPluginButtonClickedCallback missingPluginButtonClicked;
+ WKPageDidNotHandleKeyEventCallback didNotHandleKeyEvent;
+ WKPageDidNotHandleWheelEventCallback didNotHandleWheelEvent;
+ WKPageGetToolbarsAreVisibleCallback toolbarsAreVisible;
+ WKPageSetToolbarsAreVisibleCallback setToolbarsAreVisible;
+ WKPageGetMenuBarIsVisibleCallback menuBarIsVisible;
+ WKPageSetMenuBarIsVisibleCallback setMenuBarIsVisible;
+ WKPageGetStatusBarIsVisibleCallback statusBarIsVisible;
+ WKPageSetStatusBarIsVisibleCallback setStatusBarIsVisible;
+ WKPageGetIsResizableCallback isResizable;
+ WKPageSetIsResizableCallback setIsResizable;
+ WKPageGetWindowFrameCallback getWindowFrame;
+ WKPageSetWindowFrameCallback setWindowFrame;
+ WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel;
+ WKPageCallback didDraw;
+ WKPageCallback pageDidScroll;
+ WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota;
+ WKPageRunOpenPanelCallback runOpenPanel;
+ WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest;
+ WKPageHeaderHeightCallback headerHeight;
+ WKPageFooterHeightCallback footerHeight;
+ WKPageDrawHeaderCallback drawHeader;
+ WKPageDrawFooterCallback drawFooter;
+ WKPagePrintFrameCallback printFrame;
+ WKPageCallback runModal;
+ void* unused1; // Used to be didCompleteRubberBandForMainFrame
+ WKPageSaveDataToFileInDownloadsFolderCallback saveDataToFileInDownloadsFolder;
+ WKPageShouldInterruptJavaScriptCallback shouldInterruptJavaScript;
+
+ // Version 1
+ WKPageCreateNewPageCallback createNewPage;
+ WKPageMouseDidMoveOverElementCallback mouseDidMoveOverElement;
+ WKPageDecidePolicyForNotificationPermissionRequestCallback decidePolicyForNotificationPermissionRequest;
+};
+typedef struct WKPageUIClient WKPageUIClient;
+
+enum { kWKPageUIClientCurrentVersion = 1 };
+
+// Find client.
+typedef void (*WKPageDidFindStringCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
+typedef void (*WKPageDidFailToFindStringCallback)(WKPageRef page, WKStringRef string, const void* clientInfo);
+typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
+
+struct WKPageFindClient {
+ int version;
+ const void * clientInfo;
+ WKPageDidFindStringCallback didFindString;
+ WKPageDidFailToFindStringCallback didFailToFindString;
+ WKPageDidCountStringMatchesCallback didCountStringMatches;
+};
+typedef struct WKPageFindClient WKPageFindClient;
+
+enum { kWKPageFindClientCurrentVersion = 0 };
+
+enum {
+ kWKMoreThanMaximumMatchCount = -1
+};
+
+// ContextMenu client
+typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
+typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
+typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
+
+struct WKPageContextMenuClient {
+ int version;
+ const void * clientInfo;
+
+ // Version 0
+ WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
+ WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
+
+ // Version 1
+ WKPageContextMenuDismissedCallback contextMenuDismissed;
+};
+typedef struct WKPageContextMenuClient WKPageContextMenuClient;
+
+enum { kWKPageContextMenuClientCurrentVersion = 1 };
+
+WK_EXPORT WKTypeID WKPageGetTypeID();
+
+WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page);
+WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page);
+
+WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
+WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest);
+WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL);
+WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL);
+WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString);
+
+WK_EXPORT void WKPageStopLoading(WKPageRef page);
+WK_EXPORT void WKPageReload(WKPageRef page);
+WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
+
+WK_EXPORT bool WKPageTryClose(WKPageRef page);
+WK_EXPORT void WKPageClose(WKPageRef page);
+WK_EXPORT bool WKPageIsClosed(WKPageRef page);
+
+WK_EXPORT void WKPageGoForward(WKPageRef page);
+WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
+WK_EXPORT void WKPageGoBack(WKPageRef page);
+WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
+WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
+WK_EXPORT void WKPageTryRestoreScrollPosition(WKPageRef page);
+WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
+WK_EXPORT bool WKPageWillHandleHorizontalScrollEvents(WKPageRef page);
+
+WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
+
+WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
+
+WK_EXPORT WKURLRef WKPageCopyActiveURL(WKPageRef page);
+WK_EXPORT WKURLRef WKPageCopyProvisionalURL(WKPageRef page);
+WK_EXPORT WKURLRef WKPageCopyCommittedURL(WKPageRef page);
+
+WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
+WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
+WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
+WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
+
+WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page);
+
+WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled);
+
+#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
+WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
+#endif
+
+WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
+
+WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page);
+WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName);
+
+WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page);
+WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
+
+WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page);
+WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page);
+WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName);
+
+WK_EXPORT void WKPageTerminate(WKPageRef page);
+
+WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void);
+
+typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context);
+WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
+WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData);
+
+WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page);
+WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor);
+
+WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
+WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
+WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);
+WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
+WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
+WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
+
+WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
+WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
+
+WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
+WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
+WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
+WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
+
+WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
+WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
+
+WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page);
+WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page);
+
+WK_EXPORT bool WKPageCanDelete(WKPageRef page);
+WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
+WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
+
+WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
+WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page);
+
+WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
+WK_EXPORT void WKPageHideFindUI(WKPageRef page);
+WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
+
+WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client);
+WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client);
+WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client);
+WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client);
+WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClient* client);
+WK_EXPORT void WKPageSetPageResourceLoadClient(WKPageRef page, const WKPageResourceLoadClient* client);
+WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client);
+
+typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*);
+WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef);
+WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
+#endif
+
+typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
+WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
+WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
+#endif
+
+typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
+WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
+WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
+#endif
+
+typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
+WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
+
+/*
+ Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported:
+
+ "Cut"
+ "Copy"
+ "Paste"
+ "SelectAll"
+ "Undo"
+ "Redo"
+*/
+
+// state represents the state of the command in a menu (on is 1, off is 0, and mixed is -1), typically used to add a checkmark next to the menu item.
+typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context);
+WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
+WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPage_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
new file mode 100644
index 000000000..8a4d86a05
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKPageGroup.h"
+
+#include "WKAPICast.h"
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
+
+using namespace WebKit;
+
+WKTypeID WKPageGroupGetTypeID()
+{
+ return toAPI(WebPageGroup::APIType);
+}
+
+WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier)
+{
+ RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(toWTFString(identifier));
+ return toAPI(pageGroup.release().leakRef());
+}
+
+WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroupRef)
+{
+ return toCopiedAPI(toImpl(pageGroupRef)->identifier());
+}
+
+void WKPageGroupSetPreferences(WKPageGroupRef pageGroupRef, WKPreferencesRef preferencesRef)
+{
+ toImpl(pageGroupRef)->setPreferences(toImpl(preferencesRef));
+}
+
+WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroupRef)
+{
+ return toAPI(toImpl(pageGroupRef)->preferences());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPageGroup.h b/Source/WebKit2/UIProcess/API/C/WKPageGroup.h
new file mode 100644
index 000000000..705df083e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKPageGroup_h
+#define WKPageGroup_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKPageGroupGetTypeID();
+
+WK_EXPORT WKPageGroupRef WKPageGroupCreateWithIdentifier(WKStringRef identifier);
+
+WK_EXPORT WKStringRef WKPageGroupCopyIdentifier(WKPageGroupRef pageGroup);
+
+WK_EXPORT void WKPageGroupSetPreferences(WKPageGroupRef pageGroup, WKPreferencesRef preferences);
+WK_EXPORT WKPreferencesRef WKPageGroupGetPreferences(WKPageGroupRef pageGroup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPageGroup_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
new file mode 100644
index 000000000..d378adef6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKPagePrivate_h
+#define WKPagePrivate_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKPage.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (*WKPageRenderTreeExternalRepresentationFunction)(WKStringRef, WKErrorRef, void*);
+WK_EXPORT void WKPageRenderTreeExternalRepresentation(WKPageRef page, void *context, WKPageRenderTreeExternalRepresentationFunction function);
+
+#ifdef __BLOCKS__
+typedef void (^WKPageRenderTreeExternalRepresentationBlock)(WKStringRef, WKErrorRef);
+WK_EXPORT void WKPageRenderTreeExternalRepresentation_b(WKPageRef page, WKPageRenderTreeExternalRepresentationBlock block);
+#endif
+
+enum {
+ kWKDebugFlashViewUpdates = 1 << 0,
+ kWKDebugFlashBackingStoreUpdates = 1 << 1
+};
+typedef unsigned WKPageDebugPaintFlags;
+
+WK_EXPORT void WKPageSetDebugPaintFlags(WKPageDebugPaintFlags flags);
+WK_EXPORT WKPageDebugPaintFlags WKPageGetDebugPaintFlags(void);
+
+WK_EXPORT WKStringRef WKPageCopyStandardUserAgentWithApplicationName(WKStringRef);
+
+enum {
+ kWKPaginationModeUnpaginated,
+ kWKPaginationModeHorizontal,
+ kWKPaginationModeVertical,
+};
+typedef uint32_t WKPaginationMode;
+
+WK_EXPORT void WKPageSetPaginationMode(WKPageRef page, WKPaginationMode paginationMode);
+WK_EXPORT WKPaginationMode WKPageGetPaginationMode(WKPageRef page);
+WK_EXPORT void WKPageSetPageLength(WKPageRef page, double pagesPerView);
+WK_EXPORT double WKPageGetPageLength(WKPageRef page);
+WK_EXPORT void WKPageSetGapBetweenPages(WKPageRef page, double gap);
+WK_EXPORT double WKPageGetGapBetweenPages(WKPageRef page);
+
+WK_EXPORT unsigned WKPageGetPageCount(WKPageRef page);
+
+struct WKPrintInfo {
+ float pageSetupScaleFactor;
+ float availablePaperWidth;
+ float availablePaperHeight;
+};
+typedef struct WKPrintInfo WKPrintInfo;
+
+typedef void (*WKPageComputePagesForPrintingFunction)(WKRect* pageRects, uint32_t pageCount, double resultPageScaleFactor, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo, WKPageComputePagesForPrintingFunction, void* context);
+
+typedef void (*WKPageDrawToPDFFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo);
+WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context);
+
+// FIXME https://bugs.webkit.org/show_bug.cgi?id=66979: Remove this sync call.
+WK_EXPORT WKImageRef WKPageCreateSnapshotOfVisibleContent(WKPageRef page);
+
+WK_EXPORT void WKPageSetShouldSendEventsSynchronously(WKPageRef page, bool sync);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPagePrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp
new file mode 100644
index 000000000..8cfe143e5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKPluginSiteDataManager.h"
+
+#include "WKAPICast.h"
+#include "WebPluginSiteDataManager.h"
+#include <WebCore/npapi.h>
+
+using namespace WebKit;
+using namespace std;
+
+WKTypeID WKPluginSiteDataManagerGetTypeID()
+{
+ return toAPI(WebPluginSiteDataManager::APIType);
+}
+
+void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction callback)
+{
+ toImpl(managerRef)->getSitesWithData(ArrayCallback::create(context, callback));
+}
+
+static uint64_t toNPClearSiteDataFlags(WKClearSiteDataFlags flags)
+{
+ if (flags == kWKClearSiteDataFlagsClearAll)
+ return NP_CLEAR_ALL;
+
+ uint64_t result = 0;
+ if (flags & kWKClearSiteDataFlagsClearCache)
+ result |= NP_CLEAR_CACHE;
+ return result;
+}
+
+void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef managerRef, WKArrayRef sitesRef, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
+{
+ toImpl(managerRef)->clearSiteData(toImpl(sitesRef), toNPClearSiteDataFlags(flags), maxAgeInSeconds, VoidCallback::create(context, function));
+}
+
+void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
+{
+ toImpl(managerRef)->clearSiteData(0, NP_CLEAR_ALL, numeric_limits<uint64_t>::max(), VoidCallback::create(context, function));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h
new file mode 100644
index 000000000..66e76fbcd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPluginSiteDataManager.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKPluginSiteDataManager_h
+#define WKPluginSiteDataManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKPluginSiteDataManagerGetTypeID();
+
+typedef void (*WKPluginSiteDataManagerGetSitesWithDataFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef manager, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction function);
+
+enum {
+ kWKClearSiteDataFlagsClearAll = 0,
+ kWKClearSiteDataFlagsClearCache = 1 << 0,
+};
+typedef uint64_t WKClearSiteDataFlags;
+
+typedef void (*WKPluginSiteDataManagerClearSiteDataFunction)(WKErrorRef, void*);
+
+WK_EXPORT void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef manager, WKArrayRef sites, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function);
+WK_EXPORT void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef manager, void* context, WKPluginSiteDataManagerClearSiteDataFunction function);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKPluginSiteDataManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
new file mode 100644
index 000000000..35eb5d923
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -0,0 +1,713 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKPreferences.h"
+#include "WKPreferencesPrivate.h"
+
+#include "WKAPICast.h"
+#include "WebPreferences.h"
+#include <WebCore/Settings.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebKit;
+
+WKTypeID WKPreferencesGetTypeID()
+{
+ return toAPI(WebPreferences::APIType);
+}
+
+WKPreferencesRef WKPreferencesCreate()
+{
+ RefPtr<WebPreferences> preferences = WebPreferences::create();
+ return toAPI(preferences.release().leakRef());
+}
+
+WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef)
+{
+ RefPtr<WebPreferences> preferences = WebPreferences::create(toWTFString(identifierRef));
+ return toAPI(preferences.release().leakRef());
+}
+
+void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferencesRef, bool javaScriptEnabled)
+{
+ toImpl(preferencesRef)->setJavaScriptEnabled(javaScriptEnabled);
+}
+
+bool WKPreferencesGetJavaScriptEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->javaScriptEnabled();
+}
+
+void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef preferencesRef, bool loadsImagesAutomatically)
+{
+ toImpl(preferencesRef)->setLoadsImagesAutomatically(loadsImagesAutomatically);
+}
+
+bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->loadsImagesAutomatically();
+}
+
+void WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef, bool loadsSiteIconsIgnoringImageLoadingPreference)
+{
+ toImpl(preferencesRef)->setLoadsSiteIconsIgnoringImageLoadingPreference(loadsSiteIconsIgnoringImageLoadingPreference);
+}
+
+bool WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->loadsSiteIconsIgnoringImageLoadingPreference();
+}
+
+void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef, bool offlineWebApplicationCacheEnabled)
+{
+ toImpl(preferencesRef)->setOfflineWebApplicationCacheEnabled(offlineWebApplicationCacheEnabled);
+}
+
+bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->offlineWebApplicationCacheEnabled();
+}
+
+void WKPreferencesSetLocalStorageEnabled(WKPreferencesRef preferencesRef, bool localStorageEnabled)
+{
+ toImpl(preferencesRef)->setLocalStorageEnabled(localStorageEnabled);
+}
+
+bool WKPreferencesGetLocalStorageEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->localStorageEnabled();
+}
+
+void WKPreferencesSetDatabasesEnabled(WKPreferencesRef preferencesRef, bool databasesEnabled)
+{
+ toImpl(preferencesRef)->setDatabasesEnabled(databasesEnabled);
+}
+
+bool WKPreferencesGetDatabasesEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->databasesEnabled();
+}
+
+void WKPreferencesSetXSSAuditorEnabled(WKPreferencesRef preferencesRef, bool xssAuditorEnabled)
+{
+ toImpl(preferencesRef)->setXSSAuditorEnabled(xssAuditorEnabled);
+}
+
+bool WKPreferencesGetXSSAuditorEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->xssAuditorEnabled();
+}
+
+void WKPreferencesSetFrameFlatteningEnabled(WKPreferencesRef preferencesRef, bool frameFlatteningEnabled)
+{
+ toImpl(preferencesRef)->setFrameFlatteningEnabled(frameFlatteningEnabled);
+}
+
+bool WKPreferencesGetFrameFlatteningEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->frameFlatteningEnabled();
+}
+
+void WKPreferencesSetPluginsEnabled(WKPreferencesRef preferencesRef, bool pluginsEnabled)
+{
+ toImpl(preferencesRef)->setPluginsEnabled(pluginsEnabled);
+}
+
+bool WKPreferencesGetPluginsEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->pluginsEnabled();
+}
+
+void WKPreferencesSetJavaEnabled(WKPreferencesRef preferencesRef, bool javaEnabled)
+{
+ toImpl(preferencesRef)->setJavaEnabled(javaEnabled);
+}
+
+bool WKPreferencesGetJavaEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->javaEnabled();
+}
+
+void WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef, bool javaScriptCanOpenWindowsAutomatically)
+{
+ toImpl(preferencesRef)->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
+}
+
+bool WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->javaScriptCanOpenWindowsAutomatically();
+}
+
+void WKPreferencesSetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef, bool hyperlinkAuditingEnabled)
+{
+ toImpl(preferencesRef)->setHyperlinkAuditingEnabled(hyperlinkAuditingEnabled);
+}
+
+bool WKPreferencesGetHyperlinkAuditingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->hyperlinkAuditingEnabled();
+}
+
+void WKPreferencesSetStandardFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setStandardFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopyStandardFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->standardFontFamily());
+}
+
+void WKPreferencesSetFixedFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setFixedFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopyFixedFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->fixedFontFamily());
+}
+
+void WKPreferencesSetSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setSerifFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopySerifFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->serifFontFamily());
+}
+
+void WKPreferencesSetSansSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setSansSerifFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopySansSerifFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->sansSerifFontFamily());
+}
+
+void WKPreferencesSetCursiveFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setCursiveFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopyCursiveFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->cursiveFontFamily());
+}
+
+void WKPreferencesSetFantasyFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setFantasyFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopyFantasyFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->fantasyFontFamily());
+}
+
+void WKPreferencesSetPictographFontFamily(WKPreferencesRef preferencesRef, WKStringRef family)
+{
+ toImpl(preferencesRef)->setPictographFontFamily(toWTFString(family));
+}
+
+WKStringRef WKPreferencesCopyPictographFontFamily(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->pictographFontFamily());
+}
+
+void WKPreferencesSetDefaultFontSize(WKPreferencesRef preferencesRef, uint32_t size)
+{
+ toImpl(preferencesRef)->setDefaultFontSize(size);
+}
+
+uint32_t WKPreferencesGetDefaultFontSize(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->defaultFontSize();
+}
+
+void WKPreferencesSetDefaultFixedFontSize(WKPreferencesRef preferencesRef, uint32_t size)
+{
+ toImpl(preferencesRef)->setDefaultFixedFontSize(size);
+}
+
+uint32_t WKPreferencesGetDefaultFixedFontSize(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->defaultFixedFontSize();
+}
+
+void WKPreferencesSetMinimumFontSize(WKPreferencesRef preferencesRef, uint32_t size)
+{
+ toImpl(preferencesRef)->setMinimumFontSize(size);
+}
+
+uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->minimumFontSize();
+}
+
+void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior wkBehavior)
+{
+ toImpl(preferencesRef)->setEditableLinkBehavior(toEditableLinkBehavior(wkBehavior));
+}
+
+WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef)
+{
+ return toAPI(static_cast<WebCore::EditableLinkBehavior>(toImpl(preferencesRef)->editableLinkBehavior()));
+}
+
+void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name)
+{
+ toImpl(preferencesRef)->setDefaultTextEncodingName(toWTFString(name));
+}
+
+WKStringRef WKPreferencesCopyDefaultTextEncodingName(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->defaultTextEncodingName());
+}
+
+void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setPrivateBrowsingEnabled(enabled);
+}
+
+bool WKPreferencesGetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->privateBrowsingEnabled();
+}
+
+void WKPreferencesSetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setDeveloperExtrasEnabled(enabled);
+}
+
+bool WKPreferencesGetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->developerExtrasEnabled();
+}
+
+void WKPreferencesSetTextAreasAreResizable(WKPreferencesRef preferencesRef, bool resizable)
+{
+ toImpl(preferencesRef)->setTextAreasAreResizable(resizable);
+}
+
+bool WKPreferencesGetTextAreasAreResizable(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->textAreasAreResizable();
+}
+
+void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef preferencesRef, WKFontSmoothingLevel wkLevel)
+{
+ toImpl(preferencesRef)->setFontSmoothingLevel(toFontSmoothingLevel(wkLevel));
+}
+
+WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef preferencesRef)
+{
+ return toAPI(static_cast<FontSmoothingLevel>(toImpl(preferencesRef)->fontSmoothingLevel()));
+}
+
+void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setAcceleratedDrawingEnabled(flag);
+}
+
+bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->acceleratedDrawingEnabled();
+}
+
+void WKPreferencesSetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setCanvasUsesAcceleratedDrawing(flag);
+}
+
+bool WKPreferencesGetCanvasUsesAcceleratedDrawing(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->canvasUsesAcceleratedDrawing();
+}
+
+void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setAcceleratedCompositingEnabled(flag);
+}
+
+bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->acceleratedCompositingEnabled();
+}
+
+void WKPreferencesSetCompositingBordersVisible(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setCompositingBordersVisible(flag);
+}
+
+bool WKPreferencesGetCompositingBordersVisible(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->compositingBordersVisible();
+}
+
+void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setCompositingRepaintCountersVisible(flag);
+}
+
+bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->compositingRepaintCountersVisible();
+}
+
+void WKPreferencesSetWebGLEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setWebGLEnabled(flag);
+}
+
+bool WKPreferencesGetWebGLEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->webGLEnabled();
+}
+
+void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setNeedsSiteSpecificQuirks(flag);
+}
+
+bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->needsSiteSpecificQuirks();
+}
+
+void WKPreferencesSetForceFTPDirectoryListings(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setForceFTPDirectoryListings(flag);
+}
+
+bool WKPreferencesGetForceFTPDirectoryListings(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->forceFTPDirectoryListings();
+}
+
+void WKPreferencesSetFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef, WKStringRef pathRef)
+{
+ toImpl(preferencesRef)->setFTPDirectoryTemplatePath(toWTFString(pathRef));
+}
+
+WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferencesRef)
+{
+ return toCopiedAPI(toImpl(preferencesRef)->ftpDirectoryTemplatePath());
+}
+
+void WKPreferencesSetTabsToLinks(WKPreferencesRef preferencesRef, bool tabsToLinks)
+{
+ toImpl(preferencesRef)->setTabsToLinks(tabsToLinks);
+}
+
+bool WKPreferencesGetTabsToLinks(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->tabsToLinks();
+}
+
+void WKPreferencesSetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setDNSPrefetchingEnabled(enabled);
+}
+
+bool WKPreferencesGetDNSPrefetchingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->dnsPrefetchingEnabled();
+}
+
+void WKPreferencesSetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setAuthorAndUserStylesEnabled(enabled);
+}
+
+bool WKPreferencesGetAuthorAndUserStylesEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->authorAndUserStylesEnabled();
+}
+
+void WKPreferencesSetShouldPrintBackgrounds(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setShouldPrintBackgrounds(flag);
+}
+
+bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->shouldPrintBackgrounds();
+}
+
+void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setWebArchiveDebugModeEnabled(enabled);
+}
+
+bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->webArchiveDebugModeEnabled();
+}
+
+void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setLocalFileContentSniffingEnabled(enabled);
+}
+
+bool WKPreferencesGetLocalFileContentSniffingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->localFileContentSniffingEnabled();
+}
+
+void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setUsesPageCache(enabled);
+}
+
+bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->usesPageCache();
+}
+
+void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef, bool pageCacheSupportsPlugins)
+{
+ toImpl(preferencesRef)->setPageCacheSupportsPlugins(pageCacheSupportsPlugins);
+}
+
+bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->pageCacheSupportsPlugins();
+}
+
+void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setPaginateDuringLayoutEnabled(enabled);
+}
+
+bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->paginateDuringLayoutEnabled();
+}
+
+void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setDOMPasteAllowed(enabled);
+}
+
+bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->domPasteAllowed();
+}
+
+void WKPreferencesSetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setJavaScriptCanAccessClipboard(enabled);
+}
+
+bool WKPreferencesGetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->javaScriptCanAccessClipboard();
+}
+
+void WKPreferencesSetFullScreenEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setFullScreenEnabled(enabled);
+}
+
+bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->fullScreenEnabled();
+}
+
+void WKPreferencesSetAVFoundationEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setAVFoundationEnabled(enabled);
+}
+
+bool WKPreferencesGetAVFoundationEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->isAVFoundationEnabled();
+}
+
+void WKPreferencesSetWebSecurityEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setWebSecurityEnabled(enabled);
+}
+
+bool WKPreferencesGetWebSecurityEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->webSecurityEnabled();
+}
+
+void WKPreferencesSetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
+{
+ toImpl(preferencesRef)->setAllowUniversalAccessFromFileURLs(allowed);
+}
+
+bool WKPreferencesGetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->allowUniversalAccessFromFileURLs();
+}
+
+void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef, bool allowed)
+{
+ toImpl(preferencesRef)->setAllowFileAccessFromFileURLs(allowed);
+}
+
+bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->allowFileAccessFromFileURLs();
+}
+
+void WKPreferencesSetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setHixie76WebSocketProtocolEnabled(enabled);
+}
+
+bool WKPreferencesGetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->hixie76WebSocketProtocolEnabled();
+}
+
+void WKPreferencesSetMediaPlaybackRequiresUserGesture(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setMediaPlaybackRequiresUserGesture(flag);
+}
+
+bool WKPreferencesGetMediaPlaybackRequiresUserGesture(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->mediaPlaybackRequiresUserGesture();
+}
+
+void WKPreferencesSetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setMediaPlaybackAllowsInline(flag);
+}
+
+bool WKPreferencesGetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->mediaPlaybackAllowsInline();
+}
+
+void WKPreferencesSetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setShowsToolTipOverTruncatedText(flag);
+}
+
+bool WKPreferencesGetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->showsToolTipOverTruncatedText();
+}
+
+void WKPreferencesSetMockScrollbarsEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setMockScrollbarsEnabled(flag);
+}
+
+bool WKPreferencesGetMockScrollbarsEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->mockScrollbarsEnabled();
+}
+
+void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setWebAudioEnabled(enabled);
+}
+
+bool WKPreferencesGetWebAudioEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->webAudioEnabled();
+}
+
+void WKPreferencesSetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setApplicationChromeModeEnabled(enabled);
+}
+
+bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->applicationChromeMode();
+}
+
+void WKPreferencesSetSuppressIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setSuppressIncrementalRendering(enabled);
+}
+
+bool WKPreferencesGetSuppressIncrementalRendering(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->suppressIncrementalRendering();
+}
+
+void WKPreferencesSetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setBackspaceKeyNavigationEnabled(enabled);
+}
+
+bool WKPreferencesGetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->backspaceKeyNavigationEnabled();
+}
+
+void WKPreferencesSetCaretBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setCaretBrowsingEnabled(enabled);
+}
+
+bool WKPreferencesGetCaretBrowsingEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->caretBrowsingEnabled();
+}
+
+void WKPreferencesSetShouldDisplaySubtitles(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setShouldDisplaySubtitles(enabled);
+}
+
+bool WKPreferencesGetShouldDisplaySubtitles(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->shouldDisplaySubtitles();
+}
+
+void WKPreferencesSetShouldDisplayCaptions(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setShouldDisplayCaptions(enabled);
+}
+
+bool WKPreferencesGetShouldDisplayCaptions(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->shouldDisplayCaptions();
+}
+
+void WKPreferencesSetShouldDisplayTextDescriptions(WKPreferencesRef preferencesRef, bool enabled)
+{
+ toImpl(preferencesRef)->setShouldDisplayTextDescriptions(enabled);
+}
+
+bool WKPreferencesGetShouldDisplayTextDescriptions(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->shouldDisplayTextDescriptions();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
new file mode 100644
index 000000000..00fc89df8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKPreferences_h
+#define WKPreferences_h
+
+#include <WebKit2/WKBase.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKPreferencesGetTypeID();
+
+WK_EXPORT WKPreferencesRef WKPreferencesCreate();
+WK_EXPORT WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifier);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferences, bool javaScriptEnabled);
+WK_EXPORT bool WKPreferencesGetJavaScriptEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetLoadsImagesAutomatically(WKPreferencesRef preferences, bool loadsImagesAutomatically);
+WK_EXPORT bool WKPreferencesGetLoadsImagesAutomatically(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferences, bool loadsSiteIconsIgnoringImageLoadingPreference);
+WK_EXPORT bool WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences, bool offlineWebApplicationCacheEnabled);
+WK_EXPORT bool WKPreferencesGetOfflineWebApplicationCacheEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetLocalStorageEnabled(WKPreferencesRef preferences, bool localStorageEnabled);
+WK_EXPORT bool WKPreferencesGetLocalStorageEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetDatabasesEnabled(WKPreferencesRef preferences, bool databasesEnabled);
+WK_EXPORT bool WKPreferencesGetDatabasesEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetXSSAuditorEnabled(WKPreferencesRef preferences, bool xssAuditorEnabled);
+WK_EXPORT bool WKPreferencesGetXSSAuditorEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetFrameFlatteningEnabled(WKPreferencesRef preferences, bool frameFlatteningEnabled);
+WK_EXPORT bool WKPreferencesGetFrameFlatteningEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetPluginsEnabled(WKPreferencesRef preferences, bool pluginsEnabled);
+WK_EXPORT bool WKPreferencesGetPluginsEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetJavaEnabled(WKPreferencesRef preferences, bool javaEnabled);
+WK_EXPORT bool WKPreferencesGetJavaEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferences, bool javaScriptCanOpenWindowsAutomatically);
+WK_EXPORT bool WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetHyperlinkAuditingEnabled(WKPreferencesRef preferences, bool hyperlinkAuditingEnabled);
+WK_EXPORT bool WKPreferencesGetHyperlinkAuditingEnabled(WKPreferencesRef preferences);
+
+WK_EXPORT void WKPreferencesSetStandardFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopyStandardFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetFixedFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopyFixedFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopySerifFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetSansSerifFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopySansSerifFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetCursiveFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopyCursiveFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetFantasyFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopyFantasyFontFamily(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetPictographFontFamily(WKPreferencesRef preferencesRef, WKStringRef family);
+WK_EXPORT WKStringRef WKPreferencesCopyPictographFontFamily(WKPreferencesRef preferencesRef);
+
+// Defaults to 16.
+WK_EXPORT void WKPreferencesSetDefaultFontSize(WKPreferencesRef preferencesRef, uint32_t);
+WK_EXPORT uint32_t WKPreferencesGetDefaultFontSize(WKPreferencesRef preferencesRef);
+
+// Defaults to 13.
+WK_EXPORT void WKPreferencesSetDefaultFixedFontSize(WKPreferencesRef preferencesRef, uint32_t);
+WK_EXPORT uint32_t WKPreferencesGetDefaultFixedFontSize(WKPreferencesRef preferencesRef);
+
+// Defaults to 0.
+WK_EXPORT void WKPreferencesSetMinimumFontSize(WKPreferencesRef preferencesRef, uint32_t);
+WK_EXPORT uint32_t WKPreferencesGetMinimumFontSize(WKPreferencesRef preferencesRef);
+
+WK_EXPORT void WKPreferencesSetDefaultTextEncodingName(WKPreferencesRef preferencesRef, WKStringRef name);
+WK_EXPORT WKStringRef WKPreferencesCopyDefaultTextEncodingName(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetPrivateBrowsingEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetDeveloperExtrasEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetTextAreasAreResizable(WKPreferencesRef preferencesRef, bool resizable);
+WK_EXPORT bool WKPreferencesGetTextAreasAreResizable(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetTabsToLinks(WKPreferencesRef preferences, bool tabsToLinks);
+WK_EXPORT bool WKPreferencesGetTabsToLinks(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetDNSPrefetchingEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetDNSPrefetchingEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetAuthorAndUserStylesEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetAuthorAndUserStylesEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetShouldPrintBackgrounds(WKPreferencesRef preferences, bool shouldPrintBackgrounds);
+WK_EXPORT bool WKPreferencesGetShouldPrintBackgrounds(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetJavaScriptCanAccessClipboard(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetFullScreenEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetFullScreenEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetAVFoundationEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetAVFoundationEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebAudioEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetSuppressIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetSuppressIncrementalRendering(WKPreferencesRef preferencesRef);
+
+// Defaults to true
+WK_EXPORT void WKPreferencesSetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetCaretBrowsingEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetCaretBrowsingEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetShouldDisplaySubtitles(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetShouldDisplaySubtitles(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetShouldDisplayCaptions(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetShouldDisplayCaptions(WKPreferencesRef preferencesRef);
+
+// Defaults to false
+WK_EXPORT void WKPreferencesSetShouldDisplayTextDescriptions(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetShouldDisplayTextDescriptions(WKPreferencesRef preferencesRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPreferences_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
new file mode 100644
index 000000000..f11fb3af2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKPreferencesPrivate_h
+#define WKPreferencesPrivate_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum WKFontSmoothingLevel {
+ kWKFontSmoothingLevelNoSubpixelAntiAliasing = 0,
+ kWKFontSmoothingLevelLight = 1,
+ kWKFontSmoothingLevelMedium = 2,
+ kWKFontSmoothingLevelStrong = 3,
+#if defined(WIN32) || defined(_WIN32)
+ kWKFontSmoothingLevelWindows = 4,
+#endif
+};
+typedef enum WKFontSmoothingLevel WKFontSmoothingLevel;
+
+enum WKEditableLinkBehavior {
+ kWKEditableLinkBehaviorDefault,
+ kWKEditableLinkBehaviorAlwaysLive,
+ kWKEditableLinkBehaviorOnlyLiveWithShiftKey,
+ kWKEditableLinkBehaviorLiveWhenNotFocused,
+ kWKEditableLinkBehaviorNeverLive
+};
+typedef enum WKEditableLinkBehavior WKEditableLinkBehavior;
+
+// Defaults to kWKFontSmoothingLevelWindows on Windows, kWKFontSmoothingLevelMedium on other platforms.
+WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel);
+WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef);
+
+// Defaults to EditableLinkNeverLive.
+WK_EXPORT void WKPreferencesSetEditableLinkBehavior(WKPreferencesRef preferencesRef, WKEditableLinkBehavior);
+WK_EXPORT WKEditableLinkBehavior WKPreferencesGetEditableLinkBehavior(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetAcceleratedDrawingEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetAcceleratedDrawingEnabled(WKPreferencesRef);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetCanvasUsesAcceleratedDrawing(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetCanvasUsesAcceleratedDrawing(WKPreferencesRef);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetAcceleratedCompositingEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetAcceleratedCompositingEnabled(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetCompositingBordersVisible(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetCompositingBordersVisible(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetCompositingRepaintCountersVisible(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetCompositingRepaintCountersVisible(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetWebGLEnabled(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetWebGLEnabled(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef, bool);
+WK_EXPORT bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetForceFTPDirectoryListings(WKPreferencesRef preferences, bool force);
+WK_EXPORT bool WKPreferencesGetForceFTPDirectoryListings(WKPreferencesRef preferences);
+
+// Defaults to the empty string.
+WK_EXPORT void WKPreferencesSetFTPDirectoryTemplatePath(WKPreferencesRef preferences, WKStringRef path);
+WK_EXPORT WKStringRef WKPreferencesCopyFTPDirectoryTemplatePath(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetWebArchiveDebugModeEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebArchiveDebugModeEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetLocalFileContentSniffingEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetLocalFileContentSniffingEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetPageCacheEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetPageCacheEnabled(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetPageCacheSupportsPlugins(WKPreferencesRef preferences, bool pageCacheSupportsPlugins);
+WK_EXPORT bool WKPreferencesGetPageCacheSupportsPlugins(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetPaginateDuringLayoutEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetPaginateDuringLayoutEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetDOMPasteAllowed(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetDOMPasteAllowed(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetWebSecurityEnabled(WKPreferencesRef preferences, bool enabled);
+WK_EXPORT bool WKPreferencesGetWebSecurityEnabled(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
+WK_EXPORT bool WKPreferencesGetUniversalAccessFromFileURLsAllowed(WKPreferencesRef preferences);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences, bool allowed);
+WK_EXPORT bool WKPreferencesGetFileAccessFromFileURLsAllowed(WKPreferencesRef preferences);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetHixie76WebSocketProtocolEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetMediaPlaybackRequiresUserGesture(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetMediaPlaybackRequiresUserGesture(WKPreferencesRef preferencesRef);
+
+// Defaults to true.
+WK_EXPORT void WKPreferencesSetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetMediaPlaybackAllowsInline(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetShowsToolTipOverTruncatedText(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetMockScrollbarsEnabled(WKPreferencesRef preferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetMockScrollbarsEnabled(WKPreferencesRef preferencesRef);
+
+// Defaults to false.
+WK_EXPORT void WKPreferencesSetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPreferencesPrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp
new file mode 100644
index 000000000..7e764b900
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKProtectionSpace.h"
+
+#include "WebProtectionSpace.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKProtectionSpaceGetTypeID()
+{
+ return toAPI(WebProtectionSpace::APIType);
+}
+
+WKStringRef WKProtectionSpaceCopyHost(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toCopiedAPI(toImpl(protectionSpaceRef)->host());
+}
+
+int WKProtectionSpaceGetPort(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toImpl(protectionSpaceRef)->port();
+}
+
+WKStringRef WKProtectionSpaceCopyRealm(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toCopiedAPI(toImpl(protectionSpaceRef)->realm());
+}
+
+bool WKProtectionSpaceGetIsProxy(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toImpl(protectionSpaceRef)->isProxy();
+}
+
+WKProtectionSpaceServerType WKProtectionSpaceGetServerType(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toAPI(toImpl(protectionSpaceRef)->serverType());
+}
+
+bool WKProtectionSpaceGetReceivesCredentialSecurely(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toImpl(protectionSpaceRef)->receivesCredentialSecurely();
+}
+
+WKProtectionSpaceAuthenticationScheme WKProtectionSpaceGetAuthenticationScheme(WKProtectionSpaceRef protectionSpaceRef)
+{
+ return toAPI(toImpl(protectionSpaceRef)->authenticationScheme());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h
new file mode 100644
index 000000000..c77d93ba0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKProtectionSpace_h
+#define WKProtectionSpace_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKProtectionSpaceTypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKProtectionSpaceGetTypeID();
+
+WK_EXPORT WKStringRef WKProtectionSpaceCopyHost(WKProtectionSpaceRef);
+WK_EXPORT int WKProtectionSpaceGetPort(WKProtectionSpaceRef);
+WK_EXPORT WKStringRef WKProtectionSpaceCopyRealm(WKProtectionSpaceRef);
+WK_EXPORT bool WKProtectionSpaceGetIsProxy(WKProtectionSpaceRef);
+WK_EXPORT WKProtectionSpaceServerType WKProtectionSpaceGetServerType(WKProtectionSpaceRef);
+WK_EXPORT bool WKProtectionSpaceGetReceivesCredentialSecurely(WKProtectionSpaceRef);
+WK_EXPORT WKProtectionSpaceAuthenticationScheme WKProtectionSpaceGetAuthenticationScheme(WKProtectionSpaceRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKProtectionSpace_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h b/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h
new file mode 100644
index 000000000..fd1bd09d2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKProtectionSpaceTypes_h
+#define WKProtectionSpaceTypes_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ kWKProtectionSpaceServerTypeHTTP = 1,
+ kWKProtectionSpaceServerTypeHTTPS,
+ kWKProtectionSpaceServerTypeFTP,
+ kWKProtectionSpaceServerTypeFTPS,
+ kWKProtectionSpaceProxyTypeHTTP,
+ kWKProtectionSpaceProxyTypeHTTPS,
+ kWKProtectionSpaceProxyTypeFTP,
+ kWKProtectionSpaceProxyTypeSOCKS,
+};
+typedef uint32_t WKProtectionSpaceServerType;
+
+enum {
+ kWKProtectionSpaceAuthenticationSchemeDefault = 1,
+ kWKProtectionSpaceAuthenticationSchemeHTTPBasic,
+ kWKProtectionSpaceAuthenticationSchemeHTTPDigest,
+ kWKProtectionSpaceAuthenticationSchemeHTMLForm,
+ kWKProtectionSpaceAuthenticationSchemeNTLM,
+ kWKProtectionSpaceAuthenticationSchemeNegotiate,
+ kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested,
+ kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested,
+ kWKProtectionSpaceAuthenticationSchemeUnknown = 100,
+};
+typedef uint32_t WKProtectionSpaceAuthenticationScheme;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKProtectionSpaceTypes_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp
new file mode 100644
index 000000000..a5711e014
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKResourceCacheManager.h"
+
+#include "WebResourceCacheManagerProxy.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKResourceCacheManagerGetTypeID()
+{
+ return toAPI(WebResourceCacheManagerProxy::APIType);
+}
+
+void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef cacheManagerRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction callback)
+{
+ toImpl(cacheManagerRef)->getCacheOrigins(ArrayCallback::create(context, callback));
+}
+
+void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManagerRef, WKSecurityOriginRef originRef, WKResourceCachesToClear cachesToClear)
+{
+ toImpl(cacheManagerRef)->clearCacheForOrigin(toImpl(originRef), toResourceCachesToClear(cachesToClear));
+}
+
+void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManagerRef, WKResourceCachesToClear cachesToClear)
+{
+ toImpl(cacheManagerRef)->clearCacheForAllOrigins(toResourceCachesToClear(cachesToClear));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h
new file mode 100644
index 000000000..80c4531ff
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKResourceCacheManager_h
+#define WKResourceCacheManager_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ WKResourceCachesToClearAll = 0,
+ WKResourceCachesToClearInMemoryOnly = 1
+};
+typedef uint32_t WKResourceCachesToClear;
+
+WK_EXPORT WKTypeID WKResourceCacheManagerGetTypeID();
+
+typedef void (*WKResourceCacheManagerGetCacheOriginsFunction)(WKArrayRef, WKErrorRef, void*);
+WK_EXPORT void WKResourceCacheManagerGetCacheOrigins(WKResourceCacheManagerRef contextRef, void* context, WKResourceCacheManagerGetCacheOriginsFunction function);
+
+WK_EXPORT void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheManger, WKSecurityOriginRef origin, WKResourceCachesToClear cachesToClear);
+WK_EXPORT void WKResourceCacheManagerClearCacheForAllOrigins(WKResourceCacheManagerRef cacheManager, WKResourceCachesToClear cachesToClear);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKResourceCacheManager_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp b/Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp
new file mode 100644
index 000000000..3329da2e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKTextChecker.h"
+
+#include "WKAPICast.h"
+#include "WebPageProxy.h"
+#include "WebTextChecker.h"
+
+using namespace WebKit;
+
+void WKTextCheckerSetClient(const WKTextCheckerClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ WebTextChecker::shared()->setClient(wkClient);
+}
+
+void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ WebTextChecker::shared()->continuousSpellCheckingEnabledStateChanged(enabled);
+}
+
+void WKTextCheckerGrammarCheckingEnabledStateChanged(bool enabled)
+{
+ WebTextChecker::shared()->grammarCheckingEnabledStateChanged(enabled);
+}
+
+void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection)
+{
+ WebTextChecker::shared()->checkSpelling(toImpl(page), startBeforeSelection);
+}
+
+void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word)
+{
+ WebTextChecker::shared()->changeSpellingToWord(toImpl(page), toWTFString(word));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKTextChecker.h b/Source/WebKit2/UIProcess/API/C/WKTextChecker.h
new file mode 100644
index 000000000..6a05ed98a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKTextChecker.h
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKTextChecker_h
+#define WKTextChecker_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// TextChecker Client
+typedef bool (*WKTextCheckerContinousSpellCheckingAllowed)(const void *clientInfo);
+typedef bool (*WKTextCheckerContinousSpellCheckingEnabled)(const void *clientInfo);
+typedef void (*WKTextCheckerSetContinousSpellCheckingEnabled)(bool enabled, const void *clientInfo);
+typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo);
+typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo);
+typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(WKPageRef page, const void *clientInfo);
+typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, const void *clientInfo);
+typedef void (*WKTextCheckerCheckSpellingOfString)(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void *clientInfo);
+typedef void (*WKTextCheckerCheckGrammarOfString)(uint64_t tag, WKStringRef text, WKArrayRef* grammarDetails, int32_t* badGrammarLocation, int32_t* badGrammarLength, const void *clientInfo);
+typedef bool (*WKTextCheckerSpellingUIIsShowing)(const void *clientInfo);
+typedef void (*WKTextCheckerToggleSpellingUIIsShowing)(const void *clientInfo);
+typedef void (*WKTextCheckerUpdateSpellingUIWithMisspelledWord)(uint64_t tag, WKStringRef misspelledWord, const void *clientInfo);
+typedef void (*WKTextCheckerUpdateSpellingUIWithGrammarString)(uint64_t tag, WKStringRef badGrammarPhrase, WKGrammarDetailRef grammarDetail, const void *clientInfo);
+typedef WKArrayRef (*WKTextCheckerGuessesForWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
+typedef void (*WKTextCheckerLearnWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
+typedef void (*WKTextCheckerIgnoreWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
+
+struct WKTextCheckerClient {
+ int version;
+ const void * clientInfo;
+ WKTextCheckerContinousSpellCheckingAllowed continuousSpellCheckingAllowed;
+ WKTextCheckerContinousSpellCheckingEnabled continuousSpellCheckingEnabled;
+ WKTextCheckerSetContinousSpellCheckingEnabled setContinuousSpellCheckingEnabled;
+ WKTextCheckerGrammarCheckingEnabled grammarCheckingEnabled;
+ WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled;
+ WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag;
+ WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag;
+ WKTextCheckerCheckSpellingOfString checkSpellingOfString;
+ WKTextCheckerCheckGrammarOfString checkGrammarOfString;
+ WKTextCheckerSpellingUIIsShowing spellingUIIsShowing;
+ WKTextCheckerToggleSpellingUIIsShowing toggleSpellingUIIsShowing;
+ WKTextCheckerUpdateSpellingUIWithMisspelledWord updateSpellingUIWithMisspelledWord;
+ WKTextCheckerUpdateSpellingUIWithGrammarString updateSpellingUIWithGrammarString;
+ WKTextCheckerGuessesForWord guessesForWord;
+ WKTextCheckerLearnWord learnWord;
+ WKTextCheckerIgnoreWord ignoreWord;
+};
+typedef struct WKTextCheckerClient WKTextCheckerClient;
+
+enum { kWKTextCheckerClientCurrentVersion = 0 };
+
+WK_EXPORT void WKTextCheckerSetClient(const WKTextCheckerClient* client);
+
+WK_EXPORT void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool);
+WK_EXPORT void WKTextCheckerGrammarCheckingEnabledStateChanged(bool);
+
+WK_EXPORT void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection);
+WK_EXPORT void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKTextChecker_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WebKit2.h b/Source/WebKit2/UIProcess/API/C/WebKit2.h
new file mode 100644
index 000000000..5209e794f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WebKit2.h
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WebKit2_h
+#define WebKit2_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKType.h>
+
+#include <WebKit2/WKArray.h>
+#include <WebKit2/WKBackForwardList.h>
+#include <WebKit2/WKBackForwardListItem.h>
+#include <WebKit2/WKConnectionRef.h>
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKData.h>
+#include <WebKit2/WKDictionary.h>
+#include <WebKit2/WKError.h>
+#include <WebKit2/WKFormSubmissionListener.h>
+#include <WebKit2/WKFrame.h>
+#include <WebKit2/WKFramePolicyListener.h>
+#include <WebKit2/WKGeolocationManager.h>
+#include <WebKit2/WKGeolocationPermissionRequest.h>
+#include <WebKit2/WKGeolocationPosition.h>
+#include <WebKit2/WKGraphicsContext.h>
+#include <WebKit2/WKHitTestResult.h>
+#include <WebKit2/WKMutableArray.h>
+#include <WebKit2/WKMutableDictionary.h>
+#include <WebKit2/WKNavigationData.h>
+#include <WebKit2/WKNumber.h>
+#include <WebKit2/WKOpenPanelParameters.h>
+#include <WebKit2/WKOpenPanelResultListener.h>
+#include <WebKit2/WKPage.h>
+#include <WebKit2/WKPageGroup.h>
+#include <WebKit2/WKPreferences.h>
+#include <WebKit2/WKString.h>
+#include <WebKit2/WKURL.h>
+#include <WebKit2/WKURLRequest.h>
+#include <WebKit2/WKURLResponse.h>
+
+#if defined(__OBJC__) && __OBJC__
+#import <WebKit2/WKView.h>
+#elif !((defined(__APPLE__) && __APPLE__) || defined(BUILDING_QT__))
+#include <WebKit2/WKView.h>
+#endif
+
+#endif /* WebKit2_h */
diff --git a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp
new file mode 100644
index 000000000..0f6de7a14
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 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 MERCHANTAwBILITY 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.
+ */
+
+#include "config.h"
+#include "WKIconDatabaseCG.h"
+
+#include "WebIconDatabase.h"
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+#include <WebCore/Image.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
+{
+ Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
+ return image ? image->getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0;
+}
+
+CFArrayRef WKIconDatabaseTryCopyCGImageArrayForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
+{
+ Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
+ return image ? image->getCGImageArray().leakRef() : 0;
+}
+
diff --git a/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h
new file mode 100644
index 000000000..af0f2598b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKIconDatabaseCG_h
+#define WKIconDatabaseCG_h
+
+#include <CoreFoundation/CFArray.h>
+#include <CoreGraphics/CGImage.h>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKGeometry.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef url, WKSize size);
+WK_EXPORT CFArrayRef WKIconDatabaseTryCopyCGImageArrayForURL(WKIconDatabaseRef iconDatabase, WKURLRef url);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKIconDatabaseCG_h */
diff --git a/Source/WebKit2/UIProcess/API/C/gtk/WKAPICastGtk.h b/Source/WebKit2/UIProcess/API/C/gtk/WKAPICastGtk.h
new file mode 100644
index 000000000..9eb0c78ad
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/gtk/WKAPICastGtk.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, 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.
+ */
+
+#ifndef WKAPICastGtk_h
+#define WKAPICastGtk_h
+
+#ifndef WKAPICast_h
+#error "Please #include \"WKAPICast.h\" instead of this file directly."
+#endif
+
+typedef struct _WebKitWebViewBase WebKitWebViewBase;
+
+namespace WebKit {
+
+WK_ADD_API_MAPPING(WKViewRef, WebKitWebViewBase)
+
+}
+
+#endif // WKAPICastGtk_h
diff --git a/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp b/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp
new file mode 100644
index 000000000..092914460
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "WKView.h"
+
+#include "WKAPICast.h"
+#include "WebKitWebViewBasePrivate.h"
+
+using namespace WebKit;
+using namespace WebCore;
+
+WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+ return toAPI(webkitWebViewBaseCreate(toImpl(contextRef), toImpl(pageGroupRef)));
+}
+
+WKPageRef WKViewGetPage(WKViewRef viewRef)
+{
+ return toAPI(webkitWebViewBaseGetPage(toImpl(viewRef)));
+}
+
+
diff --git a/Source/WebKit2/UIProcess/API/C/gtk/WKView.h b/Source/WebKit2/UIProcess/API/C/gtk/WKView.h
new file mode 100644
index 000000000..291dfe1b6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/gtk/WKView.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WKView_h
+#define WKView_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup);
+
+WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKView_h */
diff --git a/Source/WebKit2/UIProcess/API/C/mac/WKInspectorMac.h b/Source/WebKit2/UIProcess/API/C/mac/WKInspectorMac.h
new file mode 100644
index 000000000..ec5a35afb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/mac/WKInspectorMac.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKInspectorMac_h
+#define WKInspectorMac_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const NSInteger WKInspectorViewTag = 1000;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // WKInspectorMac_h
diff --git a/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp b/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp
new file mode 100644
index 000000000..d881cdd32
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include "config.h"
+#include "WKPagePrivateMac.h"
+
+#include "WKAPICast.h"
+#include "WebPageProxy.h"
+
+using namespace WebKit;
+
+pid_t WKPageGetProcessIdentifier(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->processIdentifier();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h b/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h
new file mode 100644
index 000000000..1890da5ea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/mac/WKPagePrivateMac.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#ifndef WKPagePrivateMac_h
+#define WKPagePrivateMac_h
+
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT pid_t WKPageGetProcessIdentifier(WKPageRef page);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPagePrivateMac_h */
diff --git a/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h
new file mode 100644
index 000000000..78df4ac42
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+ */
+
+#ifndef WKNativeEvent_h
+#define WKNativeEvent_h
+
+// a Qt specific WKNativeEvent.h file is needed because that the use of __APPLE__
+// in original WKNativeEvent.h file breaks Qt build in MacOS
+
+class QEvent;
+typedef const QEvent* WKNativeEventPtr;
+
+#endif /* WKNativeEvent_h */
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
new file mode 100644
index 000000000..5b71cf303
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKAPICastWin_h
+#define WKAPICastWin_h
+
+#ifndef WKAPICast_h
+#error "Please #include \"WKAPICast.h\" instead of this file directly."
+#endif
+
+namespace WebKit {
+
+class WebView;
+class WebEditCommandProxy;
+
+WK_ADD_API_MAPPING(WKViewRef, WebView)
+WK_ADD_API_MAPPING(WKEditCommandRef, WebEditCommandProxy)
+
+} // namespace WebKit
+
+#endif // WKAPICastWin_h
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h
new file mode 100644
index 000000000..0d49ac99a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKContextPrivateWin_h
+#define WKContextPrivateWin_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKCookieManager.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Defaults to true.
+WK_EXPORT void WKContextSetShouldPaintNativeControls(WKContextRef, bool);
+
+// Defaults to WKHTTPCookieAcceptPolicyAlways.
+WK_EXPORT void WKContextSetInitialHTTPCookieAcceptPolicy(WKContextRef, WKHTTPCookieAcceptPolicy);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKContextPrivateWin_h */
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp
new file mode 100644
index 000000000..4971540e4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKContext.h"
+#include "WKContextPrivateWin.h"
+
+#include "WKAPICast.h"
+#include "WebContext.h"
+
+using namespace WebKit;
+
+void WKContextSetShouldPaintNativeControls(WKContextRef contextRef, bool b)
+{
+ toImpl(contextRef)->setShouldPaintNativeControls(b);
+}
+
+void WKContextSetInitialHTTPCookieAcceptPolicy(WKContextRef contextRef, WKHTTPCookieAcceptPolicy policy)
+{
+ toImpl(contextRef)->setInitialHTTPCookieAcceptPolicy(toHTTPCookieAcceptPolicy(policy));
+}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.cpp b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
new file mode 100644
index 000000000..16b1c1980
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKView.h"
+
+#include "WKAPICast.h"
+#include "WebView.h"
+
+using namespace WebKit;
+
+WKTypeID WKViewGetTypeID()
+{
+ return toAPI(APIObject::TypeView);
+}
+
+WKViewRef WKViewCreate(RECT rect, WKContextRef contextRef, WKPageGroupRef pageGroupRef, HWND parentWindow)
+{
+ RefPtr<WebView> view = WebView::create(rect, toImpl(contextRef), toImpl(pageGroupRef), parentWindow);
+ return toAPI(view.release().leakRef());
+}
+
+HWND WKViewGetWindow(WKViewRef viewRef)
+{
+ return toImpl(viewRef)->window();
+}
+
+WKPageRef WKViewGetPage(WKViewRef viewRef)
+{
+ return toAPI(toImpl(viewRef)->page());
+}
+
+void WKViewSetParentWindow(WKViewRef viewRef, HWND hostWindow)
+{
+ toImpl(viewRef)->setParentWindow(hostWindow);
+}
+
+void WKViewWindowAncestryDidChange(WKViewRef viewRef)
+{
+ toImpl(viewRef)->windowAncestryDidChange();
+}
+
+void WKViewSetIsInWindow(WKViewRef viewRef, bool isInWindow)
+{
+ toImpl(viewRef)->setIsInWindow(isInWindow);
+}
+
+void WKViewSetInitialFocus(WKViewRef viewRef, bool forward)
+{
+ bool isKeyboardEventValid = false;
+ toImpl(viewRef)->setInitialFocus(forward, isKeyboardEventValid, WebKeyboardEvent());
+}
+
+void WKViewSetScrollOffsetOnNextResize(WKViewRef viewRef, WKSize scrollOffset)
+{
+ toImpl(viewRef)->setScrollOffsetOnNextResize(toIntSize(scrollOffset));
+}
+
+void WKViewSetFindIndicatorCallback(WKViewRef viewRef, WKViewFindIndicatorCallback callback, void* context)
+{
+ toImpl(viewRef)->setFindIndicatorCallback(callback, context);
+}
+
+WKViewFindIndicatorCallback WKViewGetFindIndicatorCallback(WKViewRef viewRef, void** context)
+{
+ return toImpl(viewRef)->getFindIndicatorCallback(context);
+}
+
+bool WKViewIsPageOverlayInstalled(WKViewRef viewRef)
+{
+ return toImpl(viewRef)->pageOverlayInstalled();
+}
+
+void WKViewSetViewUndoClient(WKViewRef viewRef, const WKViewUndoClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(viewRef)->initializeUndoClient(wkClient);
+}
+
+void WKViewReapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
+{
+ toImpl(viewRef)->reapplyEditCommand(toImpl(command));
+}
+
+void WKViewUnapplyEditCommand(WKViewRef viewRef, WKEditCommandRef command)
+{
+ toImpl(viewRef)->unapplyEditCommand(toImpl(command));
+}
+
+void WKViewSetDrawsTransparentBackground(WKViewRef viewRef, bool drawsTransparentBackground)
+{
+ toImpl(viewRef)->page()->setDrawsTransparentBackground(drawsTransparentBackground);
+}
+
+bool WKViewDrawsTransparentBackground(WKViewRef viewRef)
+{
+ return toImpl(viewRef)->page()->drawsTransparentBackground();
+}
+
+void WKViewSetCustomDropTarget(WKViewRef viewRef, IDropTarget* dropTarget)
+{
+ return toImpl(viewRef)->setCustomDropTarget(dropTarget);
+}
+
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKView.h b/Source/WebKit2/UIProcess/API/C/win/WKView.h
new file mode 100644
index 000000000..b54093f63
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKView_h
+#define WKView_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKGeometry.h>
+#include <windows.h>
+
+struct IDropTarget;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Undo Client.
+enum {
+ kWKViewUndo = 0,
+ kWKViewRedo = 1
+};
+typedef uint32_t WKViewUndoType;
+
+typedef void (*WKViewRegisterEditCommandCallback)(WKViewRef, WKEditCommandRef, WKViewUndoType undoOrRedo, const void *clientInfo);
+typedef void (*WKViewClearAllEditCommandsCallback)(WKViewRef, const void *clientInfo);
+typedef bool (*WKViewCanUndoRedoCallback)(WKViewRef, WKViewUndoType undoOrRedo, const void *clientInfo);
+typedef void (*WKViewExecuteUndoRedoCallback)(WKViewRef, WKViewUndoType undoOrRedo, const void *clientInfo);
+
+struct WKViewUndoClient {
+ int version;
+ const void * clientInfo;
+ WKViewRegisterEditCommandCallback registerEditCommand;
+ WKViewClearAllEditCommandsCallback clearAllEditCommands;
+ WKViewCanUndoRedoCallback canUndoRedo;
+ WKViewExecuteUndoRedoCallback executeUndoRedo;
+};
+typedef struct WKViewUndoClient WKViewUndoClient;
+
+enum { kWKViewUndoClientCurrentVersion = 0 };
+
+WK_EXPORT WKTypeID WKViewGetTypeID();
+
+WK_EXPORT WKViewRef WKViewCreate(RECT rect, WKContextRef context, WKPageGroupRef pageGroup, HWND parentWindow);
+
+WK_EXPORT HWND WKViewGetWindow(WKViewRef view);
+
+WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
+
+WK_EXPORT void WKViewSetViewUndoClient(WKViewRef view, const WKViewUndoClient* client);
+WK_EXPORT void WKViewReapplyEditCommand(WKViewRef view, WKEditCommandRef command);
+WK_EXPORT void WKViewUnapplyEditCommand(WKViewRef view, WKEditCommandRef command);
+
+WK_EXPORT void WKViewSetParentWindow(WKViewRef view, HWND parentWindow);
+WK_EXPORT void WKViewWindowAncestryDidChange(WKViewRef view);
+WK_EXPORT void WKViewSetIsInWindow(WKViewRef view, bool isInWindow);
+WK_EXPORT void WKViewSetInitialFocus(WKViewRef view, bool forward);
+WK_EXPORT void WKViewSetScrollOffsetOnNextResize(WKViewRef view, WKSize scrollOffset);
+
+typedef void (*WKViewFindIndicatorCallback)(WKViewRef, HBITMAP selectionBitmap, RECT selectionRectInWindowCoordinates, bool fadeout, void*);
+WK_EXPORT void WKViewSetFindIndicatorCallback(WKViewRef view, WKViewFindIndicatorCallback callback, void* context);
+WK_EXPORT WKViewFindIndicatorCallback WKViewGetFindIndicatorCallback(WKViewRef view, void** context);
+
+WK_EXPORT bool WKViewIsPageOverlayInstalled(WKViewRef view);
+
+WK_EXPORT void WKViewSetDrawsTransparentBackground(WKViewRef view, bool drawsTransparentBackground);
+WK_EXPORT bool WKViewDrawsTransparentBackground(WKViewRef view);
+
+WK_EXPORT void WKViewSetCustomDropTarget(WKViewRef view, IDropTarget*);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKView_h */
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp
new file mode 100644
index 000000000..7b3cf6e82
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#include "config.h"
+#include "WKViewPrivate.h"
+
+#include "WKAPICast.h"
+#include "WebView.h"
+
+using namespace WebKit;
+
+void WKViewSetOverrideCursor(WKViewRef viewRef, HCURSOR overrideCursor)
+{
+ toImpl(viewRef)->setOverrideCursor(overrideCursor);
+}
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h
new file mode 100644
index 000000000..5f89fd4e1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKViewPrivate_h
+#define WKViewPrivate_h
+
+#include <WebKit2/WKBase.h>
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT void WKViewSetOverrideCursor(WKViewRef viewRef, HCURSOR overrideCursor);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKViewPrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
new file mode 100644
index 000000000..d5dbdf029
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef WKRetainPtr_h
+#define WKRetainPtr_h
+
+#include <WebKit2/WKType.h>
+#include <algorithm>
+
+namespace WebKit {
+
+enum WKAdoptTag { AdoptWK };
+
+template<typename T> class WKRetainPtr {
+public:
+ typedef T PtrType;
+
+ WKRetainPtr()
+ : m_ptr(0)
+ {
+ }
+
+ WKRetainPtr(PtrType ptr)
+ : m_ptr(ptr)
+ {
+ if (ptr)
+ WKRetain(ptr);
+ }
+
+ WKRetainPtr(WKAdoptTag, PtrType ptr)
+ : m_ptr(ptr)
+ {
+ }
+
+ template<typename U> WKRetainPtr(const WKRetainPtr<U>& o)
+ : m_ptr(o.get())
+ {
+ if (PtrType ptr = m_ptr)
+ WKRetain(ptr);
+ }
+
+ WKRetainPtr(const WKRetainPtr& o)
+ : m_ptr(o.m_ptr)
+ {
+ if (PtrType ptr = m_ptr)
+ WKRetain(ptr);
+ }
+
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ template<typename U> WKRetainPtr(WKRetainPtr<U>&& o)
+ : m_ptr(o.leakRef())
+ {
+ }
+
+ WKRetainPtr(WKRetainPtr&& o)
+ : m_ptr(o.leakRef())
+ {
+ }
+#endif
+
+ ~WKRetainPtr()
+ {
+ if (PtrType ptr = m_ptr)
+ WKRelease(ptr);
+ }
+
+ PtrType get() const { return m_ptr; }
+
+ void clear()
+ {
+ PtrType ptr = m_ptr;
+ m_ptr = 0;
+ if (ptr)
+ WKRelease(ptr);
+ }
+
+ PtrType leakRef()
+ {
+ PtrType ptr = m_ptr;
+ m_ptr = 0;
+ return ptr;
+ }
+
+ PtrType operator->() const { return m_ptr; }
+ bool operator!() const { return !m_ptr; }
+
+ // This conversion operator allows implicit conversion to bool but not to other integer types.
+ typedef PtrType WKRetainPtr::*UnspecifiedBoolType;
+ operator UnspecifiedBoolType() const { return m_ptr ? &WKRetainPtr::m_ptr : 0; }
+
+ WKRetainPtr& operator=(const WKRetainPtr&);
+ template<typename U> WKRetainPtr& operator=(const WKRetainPtr<U>&);
+ WKRetainPtr& operator=(PtrType);
+ template<typename U> WKRetainPtr& operator=(U*);
+
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+ WKRetainPtr& operator=(WKRetainPtr&&);
+ template<typename U> WKRetainPtr& operator=(WKRetainPtr<U>&&);
+#endif
+
+ void adopt(PtrType);
+ void swap(WKRetainPtr&);
+
+private:
+ PtrType m_ptr;
+};
+
+template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(const WKRetainPtr<T>& o)
+{
+ PtrType optr = o.get();
+ if (optr)
+ WKRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+ return *this;
+}
+
+template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(const WKRetainPtr<U>& o)
+{
+ PtrType optr = o.get();
+ if (optr)
+ WKRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+ return *this;
+}
+
+template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(PtrType optr)
+{
+ if (optr)
+ WKRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+ return *this;
+}
+
+template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(U* optr)
+{
+ if (optr)
+ WKRetain(optr);
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+ return *this;
+}
+
+#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
+template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(WKRetainPtr<T>&& o)
+{
+ adopt(o.leakRef());
+ return *this;
+}
+
+template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(WKRetainPtr<U>&& o)
+{
+ adopt(o.leakRef());
+ return *this;
+}
+#endif
+
+template<typename T> inline void WKRetainPtr<T>::adopt(PtrType optr)
+{
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+}
+
+template<typename T> inline void WKRetainPtr<T>::swap(WKRetainPtr<T>& o)
+{
+ std::swap(m_ptr, o.m_ptr);
+}
+
+template<typename T> inline void swap(WKRetainPtr<T>& a, WKRetainPtr<T>& b)
+{
+ a.swap(b);
+}
+
+template<typename T, typename U> inline bool operator==(const WKRetainPtr<T>& a, const WKRetainPtr<U>& b)
+{
+ return a.get() == b.get();
+}
+
+template<typename T, typename U> inline bool operator==(const WKRetainPtr<T>& a, U* b)
+{
+ return a.get() == b;
+}
+
+template<typename T, typename U> inline bool operator==(T* a, const WKRetainPtr<U>& b)
+{
+ return a == b.get();
+}
+
+template<typename T, typename U> inline bool operator!=(const WKRetainPtr<T>& a, const WKRetainPtr<U>& b)
+{
+ return a.get() != b.get();
+}
+
+template<typename T, typename U> inline bool operator!=(const WKRetainPtr<T>& a, U* b)
+{
+ return a.get() != b;
+}
+
+template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr<U>& b)
+{
+ return a != b.get();
+}
+
+template<typename T> inline WKRetainPtr<T> adoptWK(T) WARN_UNUSED_RETURN;
+
+template<typename T> inline WKRetainPtr<T> adoptWK(T o)
+{
+ return WKRetainPtr<T>(AdoptWK, o);
+}
+
+} // namespace WebKit
+
+using WebKit::WKRetainPtr;
+using WebKit::AdoptWK;
+using WebKit::adoptWK;
+
+#endif // WKRetainPtr_h
diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
new file mode 100644
index 000000000..f2f188354
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "WKStringQt.h"
+
+#include "WKAPICast.h"
+#include <QString>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+WKStringRef WKStringCreateWithQString(const QString& qString)
+{
+ WTF::String string(qString);
+ return toCopiedAPI(string);
+}
+
+QString WKStringCopyQString(WKStringRef stringRef)
+{
+ if (!stringRef)
+ return QString();
+ const WTF::String& string = toImpl(stringRef)->string();
+ return QString(reinterpret_cast<const QChar*>(string.characters()), string.length());
+}
diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h
new file mode 100644
index 000000000..cc46e4250
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WKStringQt_h
+#define WKStringQt_h
+
+#include <QString>
+#include <WebKit2/WKBase.h>
+
+WK_EXPORT WKStringRef WKStringCreateWithQString(const QString& string);
+WK_EXPORT QString WKStringCopyQString(WKStringRef string);
+
+#endif /* WKStringQt_h */
diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp
new file mode 100644
index 000000000..f9111f7ea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "WKURLQt.h"
+
+#include "WKAPICast.h"
+#include <QString>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+WKURLRef WKURLCreateWithQUrl(const QUrl& qURL)
+{
+ WTF::String urlString(qURL.toString());
+ return toCopiedURLAPI(urlString);
+}
+
+QUrl WKURLCopyQUrl(WKURLRef urlRef)
+{
+ if (!urlRef)
+ return QUrl();
+ const WTF::String& string = toImpl(urlRef)->string();
+ return QUrl(QString(reinterpret_cast<const QChar*>(string.characters()), string.length()));
+}
diff --git a/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h
new file mode 100644
index 000000000..2e4147330
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef WKURLQt_h
+#define WKURLQt_h
+
+#include <QUrl>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKURL.h>
+
+WK_EXPORT WKURLRef WKURLCreateWithQUrl(const QUrl& url);
+QUrl WKURLCopyQUrl(WKURLRef url);
+
+#endif /* WKURLCF_h */
diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
new file mode 100644
index 000000000..aaee9563d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.cpp
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "PageClientImpl.h"
+
+#include "DrawingAreaProxyImpl.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NotImplemented.h"
+#include "WebContext.h"
+#include "WebContextMenuProxy.h"
+#include "WebPageProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PageClientImpl::PageClientImpl(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewObject)
+ : m_viewObject(viewObject)
+{
+ m_page = context->createWebPage(this, pageGroup);
+ m_page->initializeWebPage();
+}
+
+PageClientImpl::~PageClientImpl()
+{
+}
+
+// PageClient
+PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
+{
+ return DrawingAreaProxyImpl::create(m_page.get());
+}
+
+void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ evas_object_image_data_update_add(m_viewObject, rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+void PageClientImpl::displayView()
+{
+ notImplemented();
+}
+
+void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize&)
+{
+ setViewNeedsDisplay(scrollRect);
+}
+
+WebCore::IntSize PageClientImpl::viewSize()
+{
+ int width, height;
+ evas_object_geometry_get(m_viewObject, 0, 0, &width, &height);
+ return IntSize(width, height);
+}
+
+bool PageClientImpl::isViewWindowActive()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewFocused()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewVisible()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewInWindow()
+{
+ notImplemented();
+ return true;
+}
+
+void PageClientImpl::processDidCrash()
+{
+ notImplemented();
+}
+
+void PageClientImpl::didRelaunchProcess()
+{
+ notImplemented();
+}
+
+void PageClientImpl::pageClosed()
+{
+ notImplemented();
+}
+
+void PageClientImpl::toolTipChanged(const String&, const String&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::setCursor(const Cursor&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::setCursorHiddenUntilMouseMoves(bool)
+{
+ notImplemented();
+}
+
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+}
+
+void PageClientImpl::clearAllEditCommands()
+{
+ notImplemented();
+}
+
+bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+ return false;
+}
+
+void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+}
+
+FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
+{
+ notImplemented();
+ return viewRect;
+}
+
+FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
+{
+ notImplemented();
+ return viewRect;
+}
+
+IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
+{
+ notImplemented();
+ return point;
+}
+
+IntRect PageClientImpl::windowToScreen(const IntRect&)
+{
+ notImplemented();
+ return IntRect();
+}
+
+void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent&, bool)
+{
+ notImplemented();
+}
+
+PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool, bool)
+{
+ notImplemented();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::exitAcceleratedCompositingMode()
+{
+ notImplemented();
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void PageClientImpl::didChangeScrollbarsForMainFrame() const
+{
+ notImplemented();
+}
+
+void PageClientImpl::didCommitLoadForMainFrame(bool)
+{
+ notImplemented();
+}
+
+void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&)
+{
+ notImplemented();
+}
+
+double PageClientImpl::customRepresentationZoomFactor()
+{
+ notImplemented();
+ return 0;
+}
+
+void PageClientImpl::setCustomRepresentationZoomFactor(double)
+{
+ notImplemented();
+}
+
+void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+ notImplemented();
+}
+
+void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
new file mode 100644
index 000000000..01a2483c7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/PageClientImpl.h
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2011 Samsung Electronics
+ *
+ * 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.
+ */
+
+#ifndef PageClientImpl_h
+#define PageClientImpl_h
+
+#include "PageClient.h"
+#include <Evas.h>
+
+namespace WebKit {
+
+class PageClientImpl : public PageClient {
+public:
+ static PassOwnPtr<PageClientImpl> create(WebContext* context, WebPageGroup* pageGroup, Evas_Object* viewObject)
+ {
+ return adoptPtr(new PageClientImpl(context, pageGroup, viewObject));
+ }
+ ~PageClientImpl();
+
+ Evas_Object* viewObject() const { return m_viewObject; }
+
+ WebPageProxy* page() const { return m_page.get(); }
+
+private:
+ PageClientImpl(WebContext*, WebPageGroup*, Evas_Object*);
+
+ // PageClient
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect&, const WebCore::IntSize&);
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+
+ virtual void processDidCrash();
+ virtual void didRelaunchProcess();
+ virtual void pageClosed();
+
+ virtual void toolTipChanged(const String&, const String&);
+
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setCursorHiddenUntilMouseMoves(bool);
+ virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+
+ virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool);
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool, bool);
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+#endif
+
+ virtual void didChangeScrollbarsForMainFrame() const;
+
+ virtual void didCommitLoadForMainFrame(bool);
+ virtual void didFinishLoadingDataForCustomRepresentation(const String&, const CoreIPC::DataReference&);
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>&);
+ virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
+ virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
+
+private:
+ RefPtr<WebPageProxy> m_page;
+ Evas_Object* m_viewObject;
+};
+
+} // namespace WebKit
+
+#endif // PageClientImpl_h
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
new file mode 100644
index 000000000..c5bca11b4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp
@@ -0,0 +1,468 @@
+/*
+ Copyright (C) 2011 Samsung Electronics
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "ewk_view.h"
+
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "PageClientImpl.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+using namespace WebCore;
+
+static const char EWK_VIEW_TYPE_STR[] = "EWK2_View";
+
+struct _Ewk_View_Private_Data {
+ OwnPtr<PageClientImpl> pageClient;
+};
+
+#define EWK_VIEW_TYPE_CHECK(ewkView, result) \
+ bool result = true; \
+ do { \
+ const char* _tmp_otype = evas_object_type_get(ewkView); \
+ const Evas_Smart* _tmp_s = evas_object_smart_smart_get(ewkView); \
+ if (EINA_UNLIKELY(!_tmp_s)) { \
+ EINA_LOG_CRIT \
+ ("%p (%s) is not a smart object!", \
+ ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
+ result = false; \
+ } \
+ const Evas_Smart_Class* _tmp_sc = evas_smart_class_get(_tmp_s); \
+ if (EINA_UNLIKELY(!_tmp_sc)) { \
+ EINA_LOG_CRIT \
+ ("%p (%s) is not a smart object!", \
+ ewkView, _tmp_otype ? _tmp_otype : "(null)"); \
+ result = false; \
+ } \
+ if (EINA_UNLIKELY(_tmp_sc->data != EWK_VIEW_TYPE_STR)) { \
+ EINA_LOG_CRIT \
+ ("%p (%s) is not of an ewk_view (need %p, got %p)!", \
+ ewkView, _tmp_otype ? _tmp_otype : "(null)", \
+ EWK_VIEW_TYPE_STR, _tmp_sc->data); \
+ result = false; \
+ } \
+ } while (0)
+
+#define EWK_VIEW_SD_GET(ewkView, smartData) \
+ EWK_VIEW_TYPE_CHECK(ewkView, _tmp_result); \
+ Ewk_View_Smart_Data* smartData = 0; \
+ if (_tmp_result) \
+ smartData = (Ewk_View_Smart_Data*)evas_object_smart_data_get(ewkView);
+
+#define EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, ...) \
+ EWK_VIEW_SD_GET(ewkView, smartData); \
+ if (!smartData) { \
+ EINA_LOG_CRIT("no smart data for object %p (%s)", \
+ ewkView, evas_object_type_get(ewkView)); \
+ return __VA_ARGS__; \
+ }
+
+#define EWK_VIEW_PRIV_GET(smartData, priv) \
+ Ewk_View_Private_Data* priv = smartData->priv
+
+#define EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, ...) \
+ if (!smartData) { \
+ EINA_LOG_CRIT("smart data is null"); \
+ return __VA_ARGS__; \
+ } \
+ EWK_VIEW_PRIV_GET(smartData, priv); \
+ if (!priv) { \
+ EINA_LOG_CRIT("no private data for object %p (%s)", \
+ smartData->self, evas_object_type_get(smartData->self)); \
+ return __VA_ARGS__; \
+ }
+
+static void _ewk_view_smart_changed(Ewk_View_Smart_Data* smartData)
+{
+ if (smartData->changed.any)
+ return;
+ smartData->changed.any = true;
+ evas_object_smart_changed(smartData->self);
+}
+
+// Default Event Handling.
+static Eina_Bool _ewk_view_smart_focus_in(Ewk_View_Smart_Data* smartData)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_focus_out(Ewk_View_Smart_Data* smartData)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ priv->pageClient->page()->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_mouse_wheel(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Wheel* wheelEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ Evas_Point position = {smartData->view.x, smartData->view.y};
+ priv->pageClient->page()->handleWheelEvent(NativeWebWheelEvent(wheelEvent, &position));
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_mouse_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Down* downEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ Evas_Point position = {smartData->view.x, smartData->view.y};
+ priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(downEvent, &position));
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_mouse_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Up* upEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ Evas_Point position = {smartData->view.x, smartData->view.y};
+ priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(upEvent, &position));
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_mouse_move(Ewk_View_Smart_Data* smartData, const Evas_Event_Mouse_Move* moveEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ Evas_Point position = {smartData->view.x, smartData->view.y};
+ priv->pageClient->page()->handleMouseEvent(NativeWebMouseEvent(moveEvent, &position));
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_key_down(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Down* downEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(downEvent));
+ return true;
+}
+
+static Eina_Bool _ewk_view_smart_key_up(Ewk_View_Smart_Data* smartData, const Evas_Event_Key_Up* upEvent)
+{
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, false)
+
+ priv->pageClient->page()->handleKeyboardEvent(NativeWebKeyboardEvent(upEvent));
+ return true;
+}
+
+// Event Handling.
+static void _ewk_view_on_focus_in(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_in);
+ smartData->api->focus_in(smartData);
+}
+
+static void _ewk_view_on_focus_out(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->focus_out);
+ smartData->api->focus_out(smartData);
+}
+
+static void _ewk_view_on_mouse_wheel(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Mouse_Wheel* wheelEvent = static_cast<Evas_Event_Mouse_Wheel*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_wheel);
+ smartData->api->mouse_wheel(smartData, wheelEvent);
+}
+
+static void _ewk_view_on_mouse_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Mouse_Down* downEvent = static_cast<Evas_Event_Mouse_Down*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_down);
+ smartData->api->mouse_down(smartData, downEvent);
+}
+
+static void _ewk_view_on_mouse_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Mouse_Up* upEvent = static_cast<Evas_Event_Mouse_Up*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_up);
+ smartData->api->mouse_up(smartData, upEvent);
+}
+
+static void _ewk_view_on_mouse_move(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Mouse_Move* moveEvent = static_cast<Evas_Event_Mouse_Move*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->mouse_move);
+ smartData->api->mouse_move(smartData, moveEvent);
+}
+
+static void _ewk_view_on_key_down(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Key_Down* downEvent = static_cast<Evas_Event_Key_Down*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_down);
+ smartData->api->key_down(smartData, downEvent);
+}
+
+static void _ewk_view_on_key_up(void* data, Evas* canvas, Evas_Object* ewkView, void* eventInfo)
+{
+ Evas_Event_Key_Up* upEvent = static_cast<Evas_Event_Key_Up*>(eventInfo);
+ Ewk_View_Smart_Data* smartData = static_cast<Ewk_View_Smart_Data*>(data);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api);
+ EINA_SAFETY_ON_NULL_RETURN(smartData->api->key_up);
+ smartData->api->key_up(smartData, upEvent);
+}
+
+static Evas_Smart_Class g_parentSmartClass = EVAS_SMART_CLASS_INIT_NULL;
+
+static Ewk_View_Private_Data* _ewk_view_priv_new(Ewk_View_Smart_Data* smartData)
+{
+ Ewk_View_Private_Data* priv =
+ static_cast<Ewk_View_Private_Data*>(calloc(1, sizeof(Ewk_View_Private_Data)));
+ if (!priv) {
+ EINA_LOG_CRIT("could not allocate Ewk_View_Private_Data");
+ return 0;
+ }
+
+ return priv;
+}
+
+static void _ewk_view_priv_del(Ewk_View_Private_Data* priv)
+{
+ if (!priv)
+ return;
+
+ priv->pageClient = nullptr;
+ free(priv);
+}
+
+static void _ewk_view_smart_add(Evas_Object* ewkView)
+{
+ const Evas_Smart* smart = evas_object_smart_smart_get(ewkView);
+ const Evas_Smart_Class* smartClass = evas_smart_class_get(smart);
+ const Ewk_View_Smart_Class* api = reinterpret_cast<const Ewk_View_Smart_Class*>(smartClass);
+ EWK_VIEW_SD_GET(ewkView, smartData);
+
+ if (!smartData) {
+ smartData = static_cast<Ewk_View_Smart_Data*>(calloc(1, sizeof(Ewk_View_Smart_Data)));
+ if (!smartData) {
+ EINA_LOG_CRIT("could not allocate Ewk_View_Smart_Data");
+ return;
+ }
+ evas_object_smart_data_set(ewkView, smartData);
+ }
+
+ smartData->self = ewkView;
+ smartData->priv = _ewk_view_priv_new(smartData);
+ smartData->api = api;
+
+ if (!smartData->priv) {
+ EINA_LOG_CRIT("could not allocate _Ewk_View_Private_Data");
+ evas_object_smart_data_set(ewkView, 0);
+ free(smartData);
+ return;
+ }
+
+ g_parentSmartClass.add(ewkView);
+
+ // Create evas_object_image to draw web contents.
+ smartData->image = evas_object_image_add(smartData->base.evas);
+ evas_object_image_alpha_set(smartData->image, false);
+ evas_object_image_filled_set(smartData->image, true);
+ evas_object_smart_member_add(smartData->image, ewkView);
+ evas_object_show(smartData->image);
+
+#define CONNECT(s, c) evas_object_event_callback_add(ewkView, s, c, smartData)
+ CONNECT(EVAS_CALLBACK_FOCUS_IN, _ewk_view_on_focus_in);
+ CONNECT(EVAS_CALLBACK_FOCUS_OUT, _ewk_view_on_focus_out);
+ CONNECT(EVAS_CALLBACK_MOUSE_WHEEL, _ewk_view_on_mouse_wheel);
+ CONNECT(EVAS_CALLBACK_MOUSE_DOWN, _ewk_view_on_mouse_down);
+ CONNECT(EVAS_CALLBACK_MOUSE_UP, _ewk_view_on_mouse_up);
+ CONNECT(EVAS_CALLBACK_MOUSE_MOVE, _ewk_view_on_mouse_move);
+ CONNECT(EVAS_CALLBACK_KEY_DOWN, _ewk_view_on_key_down);
+ CONNECT(EVAS_CALLBACK_KEY_UP, _ewk_view_on_key_up);
+#undef CONNECT
+}
+
+static void _ewk_view_smart_del(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET(ewkView, smartData);
+ if (smartData && smartData->priv)
+ _ewk_view_priv_del(smartData->priv);
+
+ g_parentSmartClass.del(ewkView);
+}
+
+static void _ewk_view_smart_resize(Evas_Object* ewkView, Evas_Coord width, Evas_Coord height)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ evas_object_resize(smartData->image, width, height);
+ evas_object_image_size_set(smartData->image, width, height);
+ evas_object_image_fill_set(smartData->image, 0, 0, width, height);
+
+ smartData->changed.size = true;
+ _ewk_view_smart_changed(smartData);
+}
+
+static void _ewk_view_smart_move(Evas_Object* ewkView, Evas_Coord x, Evas_Coord y)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ smartData->changed.position = true;
+ _ewk_view_smart_changed(smartData);
+}
+
+static void _ewk_view_smart_calculate(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv);
+ Evas_Coord x, y, width, height;
+
+ smartData->changed.any = false;
+
+ evas_object_geometry_get(ewkView, &x, &y, &width, &height);
+ Evas_Object* clip = evas_object_clip_get(smartData->image);
+
+ if (smartData->changed.size) {
+ if (priv->pageClient->page()->drawingArea())
+ priv->pageClient->page()->drawingArea()->setSize(IntSize(width, height), IntSize());
+ smartData->view.w = width;
+ smartData->view.h = height;
+ evas_object_resize(clip, width, height);
+ smartData->changed.size = false;
+ }
+
+ if (smartData->changed.position) {
+ evas_object_move(smartData->image, x, y);
+ evas_object_move(clip, x, y);
+ smartData->view.x = x;
+ smartData->view.y = y;
+ smartData->changed.position = false;
+ }
+}
+
+static void _ewk_view_smart_show(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ if (evas_object_clipees_get(smartData->base.clipper))
+ evas_object_show(smartData->base.clipper);
+ evas_object_show(smartData->image);
+}
+
+static void _ewk_view_smart_hide(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData);
+
+ evas_object_hide(smartData->base.clipper);
+ evas_object_hide(smartData->image);
+}
+
+Eina_Bool ewk_view_smart_class_init(Ewk_View_Smart_Class* api)
+{
+ EINA_SAFETY_ON_NULL_RETURN_VAL(api, false);
+
+ if (api->version != EWK_VIEW_SMART_CLASS_VERSION) {
+ EINA_LOG_CRIT("Ewk_View_Smart_Class %p is version %lu while %lu was expected.",
+ api, api->version, EWK_VIEW_SMART_CLASS_VERSION);
+ return false;
+ }
+
+ if (EINA_UNLIKELY(!g_parentSmartClass.add))
+ evas_object_smart_clipped_smart_set(&g_parentSmartClass);
+
+ evas_object_smart_clipped_smart_set(&api->sc);
+
+ // Set Evas_Smart_Class functions.
+ api->sc.add = _ewk_view_smart_add;
+ api->sc.del = _ewk_view_smart_del;
+ api->sc.move = _ewk_view_smart_move;
+ api->sc.resize = _ewk_view_smart_resize;
+ api->sc.show = _ewk_view_smart_show;
+ api->sc.hide = _ewk_view_smart_hide;
+ api->sc.calculate = _ewk_view_smart_calculate;
+ api->sc.data = EWK_VIEW_TYPE_STR; // It is used by type checking.
+
+ // Set Ewk_View_Smart_Class functions.
+ api->focus_in = _ewk_view_smart_focus_in;
+ api->focus_out = _ewk_view_smart_focus_out;
+ api->mouse_wheel = _ewk_view_smart_mouse_wheel;
+ api->mouse_down = _ewk_view_smart_mouse_down;
+ api->mouse_up = _ewk_view_smart_mouse_up;
+ api->mouse_move = _ewk_view_smart_mouse_move;
+ api->key_down = _ewk_view_smart_key_down;
+ api->key_up = _ewk_view_smart_key_up;
+
+ return true;
+}
+
+static inline Evas_Smart* _ewk_view_smart_class_new(void)
+{
+ static Ewk_View_Smart_Class api = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Ewk_View");
+ static Evas_Smart* smart = 0;
+
+ if (EINA_UNLIKELY(!smart)) {
+ ewk_view_smart_class_init(&api);
+ smart = evas_smart_class_new(&api.sc);
+ }
+
+ return smart;
+}
+
+Evas_Object* ewk_view_add(Evas* canvas, WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+ Evas_Object* ewkView = evas_object_smart_add(canvas, _ewk_view_smart_class_new());
+ if (!ewkView)
+ return 0;
+
+ EWK_VIEW_SD_GET(ewkView, smartData);
+ if (!smartData) {
+ evas_object_del(ewkView);
+ return 0;
+ }
+
+ EWK_VIEW_PRIV_GET(smartData, priv);
+ if (!priv) {
+ evas_object_del(ewkView);
+ return 0;
+ }
+
+ priv->pageClient = PageClientImpl::create(toImpl(contextRef), toImpl(pageGroupRef), smartData->image);
+
+ return ewkView;
+}
+
+WKPageRef ewk_view_page_get(Evas_Object* ewkView)
+{
+ EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, 0);
+ EWK_VIEW_PRIV_GET_OR_RETURN(smartData, priv, 0);
+
+ return toAPI(priv->pageClient->page());
+}
diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
new file mode 100644
index 000000000..c8956bca7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h
@@ -0,0 +1,142 @@
+/*
+ Copyright (C) 2011 Samsung Electronics
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ewk_view_h
+#define ewk_view_h
+
+#include <Evas.h>
+#include <WebKit2/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _Ewk_View_Smart_Data Ewk_View_Smart_Data;
+typedef struct _Ewk_View_Smart_Class Ewk_View_Smart_Class;
+
+/// Ewk view's class, to be overridden by sub-classes.
+struct _Ewk_View_Smart_Class {
+ Evas_Smart_Class sc; /**< all but 'data' is free to be changed. */
+ unsigned long version;
+
+ // event handling:
+ // - returns true if handled
+ // - if overridden, have to call parent method if desired
+ Eina_Bool (*focus_in)(Ewk_View_Smart_Data *sd);
+ Eina_Bool (*focus_out)(Ewk_View_Smart_Data *sd);
+ Eina_Bool (*mouse_wheel)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Wheel *ev);
+ Eina_Bool (*mouse_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Down *ev);
+ Eina_Bool (*mouse_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Up *ev);
+ Eina_Bool (*mouse_move)(Ewk_View_Smart_Data *sd, const Evas_Event_Mouse_Move *ev);
+ Eina_Bool (*key_down)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Down *ev);
+ Eina_Bool (*key_up)(Ewk_View_Smart_Data *sd, const Evas_Event_Key_Up *ev);
+};
+
+/**
+ * The version you have to put into the version field
+ * in the @a Ewk_View_Smart_Class structure.
+ */
+#define EWK_VIEW_SMART_CLASS_VERSION 1UL
+
+/**
+ * Initializer for whole Ewk_View_Smart_Class structure.
+ *
+ * @param smart_class_init initializer to use for the "base" field
+ * (Evas_Smart_Class).
+ *
+ * @see EWK_VIEW_SMART_CLASS_INIT_NULL
+ * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
+ * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
+ */
+#define EWK_VIEW_SMART_CLASS_INIT(smart_class_init) {smart_class_init, EWK_VIEW_SMART_CLASS_VERSION, 0, 0, 0, 0, 0, 0, 0, 0}
+
+/**
+ * Initializer to zero a whole Ewk_View_Smart_Class structure.
+ *
+ * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
+ * @see EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION
+ * @see EWK_VIEW_SMART_CLASS_INIT
+ */
+#define EWK_VIEW_SMART_CLASS_INIT_NULL EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
+
+/**
+ * Initializer to zero a whole Ewk_View_Smart_Class structure and set
+ * name and version.
+ *
+ * Similar to EWK_VIEW_SMART_CLASS_INIT_NULL, but will set version field of
+ * Evas_Smart_Class (base field) to latest EVAS_SMART_CLASS_VERSION and name
+ * to the specific value.
+ *
+ * It will keep a reference to name field as a "const char *", that is,
+ * name must be available while the structure is used (hint: static or global!)
+ * and will not be modified.
+ *
+ * @see EWK_VIEW_SMART_CLASS_INIT_NULL
+ * @see EWK_VIEW_SMART_CLASS_INIT_VERSION
+ * @see EWK_VIEW_SMART_CLASS_INIT
+ */
+#define EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION(name) EWK_VIEW_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NAME_VERSION(name))
+
+typedef struct _Ewk_View_Private_Data Ewk_View_Private_Data;
+/**
+ * @brief Contains an internal View data.
+ *
+ * It is to be considered private by users, but may be extended or
+ * changed by sub-classes (that's why it's in public header file).
+ */
+struct _Ewk_View_Smart_Data {
+ Evas_Object_Smart_Clipped_Data base;
+ const Ewk_View_Smart_Class* api; /**< reference to casted class instance */
+ Evas_Object* self; /**< reference to owner object */
+ Evas_Object* image; /**< reference to evas_object_image for drawing web contents */
+ Ewk_View_Private_Data* priv; /**< should never be accessed, c++ stuff */
+ struct {
+ Evas_Coord x, y, w, h; /**< last used viewport */
+ } view;
+ struct { /**< what changed since last smart_calculate */
+ Eina_Bool any:1;
+ Eina_Bool size:1;
+ Eina_Bool position:1;
+ } changed;
+};
+
+/**
+ * Creates a new EFL WebKit View object.
+ *
+ * @param e canvas object where to create the view object
+ * @param context WKContext's Reference pointer
+ * @param page_group WKPageGroup's Reference pointer
+ *
+ * @return view object on success or @c 0 on failure
+ */
+EAPI Evas_Object* ewk_view_add(Evas* e, WKContextRef context, WKPageGroupRef page_group);
+
+/**
+ * Gets the WKPageRef of this view.
+ *
+ * @param o the view object to get the WKPageRef
+ *
+ * @return the WKPageRef of this view
+ */
+EAPI WKPageRef ewk_view_page_get(Evas_Object* o);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // ewk_view_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
new file mode 100644
index 000000000..c3ad3f764
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "PageClientImpl.h"
+
+#include "DrawingAreaProxyImpl.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NotImplemented.h"
+#include "WebContext.h"
+#include "WebContextMenuProxyGtk.h"
+#include "WebEventFactory.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebPageProxy.h"
+#include "WebPopupMenuProxyGtk.h"
+#include <WebCore/Cursor.h>
+#include <WebCore/GtkUtilities.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PageClientImpl::PageClientImpl(GtkWidget* viewWidget)
+ : m_viewWidget(viewWidget)
+{
+}
+
+PageClientImpl::~PageClientImpl()
+{
+}
+
+void PageClientImpl::getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent& event, const AtomicString& eventType, Vector<WTF::String>& commandList)
+{
+ ASSERT(eventType == eventNames().keydownEvent || eventType == eventNames().keypressEvent);
+
+ KeyBindingTranslator::EventType type = eventType == eventNames().keydownEvent ?
+ KeyBindingTranslator::KeyDown : KeyBindingTranslator::KeyPress;
+ m_keyBindingTranslator.getEditorCommandsForKeyEvent(const_cast<GdkEventKey*>(&event.nativeEvent()->key), type, commandList);
+}
+
+// PageClient's pure virtual functions
+PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
+{
+ return DrawingAreaProxyImpl::create(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget)));
+}
+
+void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ gtk_widget_queue_draw_area(m_viewWidget, rect.x(), rect.y(), rect.width(), rect.height());
+}
+
+void PageClientImpl::displayView()
+{
+ notImplemented();
+}
+
+void PageClientImpl::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+ setViewNeedsDisplay(scrollRect);
+}
+
+WebCore::IntSize PageClientImpl::viewSize()
+{
+ if (!gtk_widget_get_realized(m_viewWidget))
+ return IntSize();
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(m_viewWidget, &allocation);
+ return IntSize(allocation.width, allocation.height);
+}
+
+bool PageClientImpl::isViewWindowActive()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewFocused()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewVisible()
+{
+ notImplemented();
+ return true;
+}
+
+bool PageClientImpl::isViewInWindow()
+{
+ notImplemented();
+ return true;
+}
+
+void PageClientImpl::PageClientImpl::processDidCrash()
+{
+ notImplemented();
+}
+
+void PageClientImpl::didRelaunchProcess()
+{
+ notImplemented();
+}
+
+void PageClientImpl::takeFocus(bool)
+{
+ notImplemented();
+}
+
+void PageClientImpl::toolTipChanged(const String&, const String& newToolTip)
+{
+ webkitWebViewBaseSetTooltipText(WEBKIT_WEB_VIEW_BASE(m_viewWidget), newToolTip.utf8().data());
+}
+
+void PageClientImpl::setCursor(const Cursor& cursor)
+{
+ // [GTK] Widget::setCursor() gets called frequently
+ // http://bugs.webkit.org/show_bug.cgi?id=16388
+ // Setting the cursor may be an expensive operation in some backends,
+ // so don't re-set the cursor if it's already set to the target value.
+ GdkWindow* window = gtk_widget_get_window(m_viewWidget);
+ GdkCursor* currentCursor = gdk_window_get_cursor(window);
+ GdkCursor* newCursor = cursor.platformCursor().get();
+ if (currentCursor != newCursor)
+ gdk_window_set_cursor(window, newCursor);
+}
+
+void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+ notImplemented();
+}
+
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+}
+
+void PageClientImpl::clearAllEditCommands()
+{
+ notImplemented();
+}
+
+bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+ return false;
+}
+
+void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo)
+{
+ notImplemented();
+}
+
+FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& viewRect)
+{
+ notImplemented();
+ return viewRect;
+}
+
+FloatRect PageClientImpl::convertToUserSpace(const FloatRect& viewRect)
+{
+ notImplemented();
+ return viewRect;
+}
+
+IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
+{
+ IntPoint widgetPositionOnScreen = convertWidgetPointToScreenPoint(m_viewWidget, IntPoint());
+ IntPoint result(point);
+ result.move(-widgetPositionOnScreen.x(), -widgetPositionOnScreen.y());
+ return result;
+}
+
+IntRect PageClientImpl::windowToScreen(const IntRect& rect)
+{
+ return IntRect(convertWidgetPointToScreenPoint(m_viewWidget, rect.location()), rect.size());
+}
+
+void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled)
+{
+ if (wasEventHandled)
+ return;
+
+ WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
+ webkitWebViewBaseForwardNextKeyEvent(webkitWebViewBase);
+ gtk_main_do_event(event.nativeEvent());
+}
+
+PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
+{
+ return WebPopupMenuProxyGtk::create(m_viewWidget, page);
+}
+
+PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
+{
+ return WebContextMenuProxyGtk::create(m_viewWidget, page);
+}
+
+void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate)
+{
+ notImplemented();
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::exitAcceleratedCompositingMode()
+{
+ notImplemented();
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+}
+
+void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&)
+{
+}
+
+double PageClientImpl::customRepresentationZoomFactor()
+{
+ notImplemented();
+ return 0;
+}
+
+void PageClientImpl::setCustomRepresentationZoomFactor(double)
+{
+ notImplemented();
+}
+
+void PageClientImpl::pageClosed()
+{
+ notImplemented();
+}
+
+void PageClientImpl::didChangeScrollbarsForMainFrame() const
+{
+}
+
+void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+ notImplemented();
+}
+
+void PageClientImpl::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+ notImplemented();
+}
+
+void PageClientImpl::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ webkitWebViewBaseStartDrag(WEBKIT_WEB_VIEW_BASE(m_viewWidget), dragData, dragImage);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
new file mode 100644
index 000000000..291ba212b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef PageClientImpl_h
+#define PageClientImpl_h
+
+#include "KeyBindingTranslator.h"
+#include "PageClient.h"
+#include "WebPageProxy.h"
+#include "WindowsKeyboardCodes.h"
+#include <WebCore/IntSize.h>
+#include <gtk/gtk.h>
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+class WebPageNamespace;
+
+class PageClientImpl : public PageClient {
+public:
+ ~PageClientImpl();
+ static PassOwnPtr<PageClientImpl> create(GtkWidget* viewWidget)
+ {
+ return adoptPtr(new PageClientImpl(viewWidget));
+ }
+
+ GtkWidget* viewWidget() { return m_viewWidget; }
+
+private:
+ PageClientImpl(GtkWidget*);
+
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+ virtual void processDidCrash();
+ virtual void didRelaunchProcess();
+ virtual void pageClosed();
+ virtual void takeFocus(bool direction);
+ virtual void toolTipChanged(const WTF::String&, const WTF::String&);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setCursorHiddenUntilMouseMoves(bool);
+ virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+ virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled);
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
+ virtual void didChangeScrollbarsForMainFrame() const;
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+ virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&);
+ virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned);
+ virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned);
+ virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+#endif
+
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+
+ // Members of PageClientImpl class
+ GtkWidget* m_viewWidget;
+ WebCore::KeyBindingTranslator m_keyBindingTranslator;
+};
+
+} // namespace WebKit
+
+#endif // PageClientImpl_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp
new file mode 100644
index 000000000..fab54fb21
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.cpp
@@ -0,0 +1,303 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitBackForwardList.h"
+
+#include "WebKitBackForwardListPrivate.h"
+#include "WebKitMarshal.h"
+#include <WebKit2/WKBackForwardList.h>
+#include <wtf/gobject/GRefPtr.h>
+
+/**
+ * SECTION: WebKitBackForwardList
+ * @Short_description: List of visited pages
+ * @Title: WebKitBackForwardList
+ * @See_also: #WebKitWebView, #WebKitBackForwardListItem
+ *
+ * WebKitBackForwardList maintains a list of visited pages used to
+ * navigate to recent pages. Items are inserted in the list in the
+ * order they are visited.
+ *
+ * WebKitBackForwardList also maintains the notion of the current item
+ * (which is always at index 0), the preceding item (which is at index -1),
+ * and the following item (which is at index 1).
+ * Methods webkit_web_view_go_back() and webkit_web_view_go_forward() move
+ * the current item backward or forward by one. Method
+ * webkit_web_view_go_to_back_forward_list_item() sets the current item to the
+ * specified item. All other methods returning #WebKitBackForwardListItem<!-- -->s
+ * do not change the value of the current item, they just return the requested
+ * item or items.
+ */
+
+enum {
+ CHANGED,
+
+ LAST_SIGNAL
+};
+
+typedef HashMap<WKBackForwardListItemRef, GRefPtr<WebKitBackForwardListItem> > BackForwardListItemsMap;
+
+struct _WebKitBackForwardListPrivate {
+ WKBackForwardListRef wkList;
+ BackForwardListItemsMap itemsMap;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE(WebKitBackForwardList, webkit_back_forward_list, G_TYPE_OBJECT)
+
+static void webkitBackForwardListFinalize(GObject* object)
+{
+ WEBKIT_BACK_FORWARD_LIST(object)->priv->~WebKitBackForwardListPrivate();
+ G_OBJECT_CLASS(webkit_back_forward_list_parent_class)->finalize(object);
+}
+
+static void webkit_back_forward_list_init(WebKitBackForwardList* list)
+{
+ WebKitBackForwardListPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(list, WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListPrivate);
+ list->priv = priv;
+ new (priv) WebKitBackForwardListPrivate();
+}
+
+static void webkit_back_forward_list_class_init(WebKitBackForwardListClass* listClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(listClass);
+
+ gObjectClass->finalize = webkitBackForwardListFinalize;
+
+ /**
+ * WebKitBackForwardList::changed:
+ * @back_forward_list: the #WebKitBackForwardList on which the signal was emitted
+ * @item_added: (allow-none): the #WebKitBackForwardListItem added or %NULL
+ * @items_removed: a #GList of #WebKitBackForwardListItem<!-- -->s
+ *
+ * This signal is emitted when @back_forward_list changes. This happens
+ * when the current item is updated, a new item is added or one or more
+ * items are removed. Note that both @item_added and @items_removed can
+ * %NULL when only the current item is updated. Items are only removed
+ * when the list is cleared or the maximum items limit is reached.
+ */
+ signals[CHANGED] =
+ g_signal_new("changed",
+ G_TYPE_FROM_CLASS(listClass),
+ G_SIGNAL_RUN_LAST,
+ 0, 0, 0,
+ webkit_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE, 2,
+ WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM,
+ G_TYPE_POINTER);
+
+ g_type_class_add_private(listClass, sizeof(WebKitBackForwardListPrivate));
+}
+
+static WebKitBackForwardListItem* webkitBackForwardListGetOrCreateItem(WebKitBackForwardList* list, WKBackForwardListItemRef wkListItem)
+{
+ if (!wkListItem)
+ return 0;
+
+ WebKitBackForwardListPrivate* priv = list->priv;
+ GRefPtr<WebKitBackForwardListItem> listItem = priv->itemsMap.get(wkListItem);
+ if (listItem)
+ return listItem.get();
+
+ listItem = webkitBackForwardListItemGetOrCreate(wkListItem);
+ priv->itemsMap.set(wkListItem, listItem);
+
+ return listItem.get();
+}
+
+static GList* webkitBackForwardListCreateList(WebKitBackForwardList* list, WKArrayRef wkList)
+{
+ if (!wkList)
+ return 0;
+
+ GList* returnValue = 0;
+ for (size_t i = 0; i < WKArrayGetSize(wkList); ++i) {
+ WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkList, i));
+ returnValue = g_list_prepend(returnValue, webkitBackForwardListGetOrCreateItem(list, wkItem));
+ }
+
+ return returnValue;
+}
+
+WebKitBackForwardList* webkitBackForwardListCreate(WKBackForwardListRef wkList)
+{
+ WebKitBackForwardList* list = WEBKIT_BACK_FORWARD_LIST(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST, NULL));
+ list->priv->wkList = wkList;
+
+ return list;
+}
+
+void webkitBackForwardListChanged(WebKitBackForwardList* backForwardList, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems)
+{
+ WebKitBackForwardListItem* addedItem = webkitBackForwardListGetOrCreateItem(backForwardList, wkAddedItem);
+ GList* removedItems = 0;
+
+ size_t removedItemsSize = wkRemovedItems ? WKArrayGetSize(wkRemovedItems) : 0;
+ WebKitBackForwardListPrivate* priv = backForwardList->priv;
+ for (size_t i = 0; i < removedItemsSize; ++i) {
+ WKBackForwardListItemRef wkItem = static_cast<WKBackForwardListItemRef>(WKArrayGetItemAtIndex(wkRemovedItems, i));
+ removedItems = g_list_prepend(removedItems, g_object_ref(G_OBJECT(priv->itemsMap.get(wkItem).get())));
+ priv->itemsMap.remove(wkItem);
+ }
+
+ g_signal_emit(backForwardList, signals[CHANGED], 0, addedItem, removedItems, NULL);
+ g_list_free_full(removedItems, static_cast<GDestroyNotify>(g_object_unref));
+}
+
+/**
+ * webkit_back_forward_list_get_current_item:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns the current item in @back_forward_list.
+ *
+ * Returns: (transfer none): a #WebKitBackForwardListItem
+ * or %NULL if @back_forward_list is empty.
+ */
+WebKitBackForwardListItem* webkit_back_forward_list_get_current_item(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetCurrentItem(backForwardList->priv->wkList));
+}
+
+/**
+ * webkit_back_forward_list_get_back_item:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns the item that precedes the current item.
+ *
+ * Returns: (transfer none): the #WebKitBackForwardListItem
+ * preceding the current item or %NULL.
+ */
+WebKitBackForwardListItem* webkit_back_forward_list_get_back_item(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetBackItem(backForwardList->priv->wkList));
+}
+
+/**
+ * webkit_back_forward_list_get_forward_item:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns the item that follows the current item.
+ *
+ * Returns: (transfer none): the #WebKitBackForwardListItem
+ * following the current item or %NULL.
+ */
+WebKitBackForwardListItem* webkit_back_forward_list_get_forward_item(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetForwardItem(backForwardList->priv->wkList));
+}
+
+/**
+ * webkit_back_forward_list_get_nth_item:
+ * @back_forward_list: a #WebKitBackForwardList
+ * @index: the index of the item
+ *
+ * Returns the item at a given index relative to the current item.
+ *
+ * Returns: (transfer none): the #WebKitBackForwardListItem
+ * located at the specified index relative to the current item.
+ */
+WebKitBackForwardListItem* webkit_back_forward_list_get_nth_item(WebKitBackForwardList* backForwardList, gint index)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListGetOrCreateItem(backForwardList, WKBackForwardListGetItemAtIndex(backForwardList->priv->wkList, index));
+}
+
+/**
+ * webkit_back_forward_list_get_length:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns: the length of @back_forward_list.
+ */
+guint webkit_back_forward_list_get_length(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ WebKitBackForwardListPrivate* priv = backForwardList->priv;
+ guint currentItem = webkit_back_forward_list_get_current_item(backForwardList) ? 1 : 0;
+ return WKBackForwardListGetBackListCount(priv->wkList) + WKBackForwardListGetForwardListCount(priv->wkList) + currentItem;
+}
+
+/**
+ * webkit_back_forward_list_get_back_list:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
+ * items preceding the current item.
+ */
+GList* webkit_back_forward_list_get_back_list(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ guint limit = WKBackForwardListGetBackListCount(backForwardList->priv->wkList);
+ return webkitBackForwardListCreateList(backForwardList, WKBackForwardListCopyBackListWithLimit(backForwardList->priv->wkList, limit));
+}
+
+/**
+ * webkit_back_forward_list_get_back_list_with_limit:
+ * @back_forward_list: a #WebKitBackForwardList
+ * @limit: the number of items to retrieve
+ *
+ * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
+ * items preceding the current item limited by @limit.
+ */
+GList* webkit_back_forward_list_get_back_list_with_limit(WebKitBackForwardList* backForwardList, guint limit)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListCreateList(backForwardList, WKBackForwardListCopyBackListWithLimit(backForwardList->priv->wkList, limit));
+}
+
+/**
+ * webkit_back_forward_list_get_forward_list:
+ * @back_forward_list: a #WebKitBackForwardList
+ *
+ * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
+ * items following the current item.
+ */
+GList* webkit_back_forward_list_get_forward_list(WebKitBackForwardList* backForwardList)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ guint limit = WKBackForwardListGetForwardListCount(backForwardList->priv->wkList);
+ return webkitBackForwardListCreateList(backForwardList, WKBackForwardListCopyForwardListWithLimit(backForwardList->priv->wkList, limit));
+}
+
+/**
+ * webkit_back_forward_list_get_forward_list_with_limit:
+ * @back_forward_list: a #WebKitBackForwardList
+ * @limit: the number of items to retrieve
+ *
+ * Returns: (element-type WebKit.BackForwardListItem) (transfer container): a #GList of
+ * items following the current item limited by @limit.
+ */
+GList* webkit_back_forward_list_get_forward_list_with_limit(WebKitBackForwardList* backForwardList, guint limit)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST(backForwardList), 0);
+
+ return webkitBackForwardListCreateList(backForwardList, WKBackForwardListCopyForwardListWithLimit(backForwardList->priv->wkList, limit));
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h
new file mode 100644
index 000000000..4cdb089e4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardList.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitBackForwardList_h
+#define WebKitBackForwardList_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitBackForwardListItem.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_BACK_FORWARD_LIST (webkit_back_forward_list_get_type())
+#define WEBKIT_BACK_FORWARD_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardList))
+#define WEBKIT_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass))
+#define WEBKIT_IS_BACK_FORWARD_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST))
+#define WEBKIT_IS_BACK_FORWARD_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_BACK_FORWARD_LIST))
+#define WEBKIT_BACK_FORWARD_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_BACK_FORWARD_LIST, WebKitBackForwardListClass))
+
+typedef struct _WebKitBackForwardList WebKitBackForwardList;
+typedef struct _WebKitBackForwardListClass WebKitBackForwardListClass;
+typedef struct _WebKitBackForwardListPrivate WebKitBackForwardListPrivate;
+
+struct _WebKitBackForwardList {
+ GObject parent;
+
+ WebKitBackForwardListPrivate *priv;
+};
+
+struct _WebKitBackForwardListClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_back_forward_list_get_type (void);
+
+WEBKIT_API WebKitBackForwardListItem *
+webkit_back_forward_list_get_current_item (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API WebKitBackForwardListItem *
+webkit_back_forward_list_get_back_item (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API WebKitBackForwardListItem *
+webkit_back_forward_list_get_forward_item (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API WebKitBackForwardListItem *
+webkit_back_forward_list_get_nth_item (WebKitBackForwardList *back_forward_list,
+ gint index);
+WEBKIT_API guint
+webkit_back_forward_list_get_length (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API GList *
+webkit_back_forward_list_get_back_list (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API GList *
+webkit_back_forward_list_get_back_list_with_limit (WebKitBackForwardList *back_forward_list,
+ guint limit);
+
+WEBKIT_API GList *
+webkit_back_forward_list_get_forward_list (WebKitBackForwardList *back_forward_list);
+
+WEBKIT_API GList *
+webkit_back_forward_list_get_forward_list_with_limit (WebKitBackForwardList *back_forward_list,
+ guint limit);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp
new file mode 100644
index 000000000..ed44f1f1e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.cpp
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitBackForwardListItem.h"
+
+#include "WebKitBackForwardListPrivate.h"
+#include <WebKit2/WKBackForwardListItem.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <wtf/HashMap.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+struct _WebKitBackForwardListItemPrivate {
+ WKRetainPtr<WKBackForwardListItemRef> wkListItem;
+ CString uri;
+ CString title;
+ CString originalURI;
+};
+
+G_DEFINE_TYPE(WebKitBackForwardListItem, webkit_back_forward_list_item, G_TYPE_INITIALLY_UNOWNED)
+
+static void webkitBackForwardListItemFinalize(GObject* object)
+{
+ WEBKIT_BACK_FORWARD_LIST_ITEM(object)->priv->~WebKitBackForwardListItemPrivate();
+ G_OBJECT_CLASS(webkit_back_forward_list_item_parent_class)->finalize(object);
+}
+
+static void webkit_back_forward_list_item_init(WebKitBackForwardListItem* listItem)
+{
+ WebKitBackForwardListItemPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(listItem, WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemPrivate);
+ listItem->priv = priv;
+ new (priv) WebKitBackForwardListItemPrivate();
+}
+
+static void webkit_back_forward_list_item_class_init(WebKitBackForwardListItemClass* listItemClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(listItemClass);
+
+ gObjectClass->finalize = webkitBackForwardListItemFinalize;
+
+ g_type_class_add_private(listItemClass, sizeof(WebKitBackForwardListItemPrivate));
+}
+
+typedef HashMap<WKBackForwardListItemRef, WebKitBackForwardListItem*> HistoryItemsMap;
+
+static HistoryItemsMap& historyItemsMap()
+{
+ DEFINE_STATIC_LOCAL(HistoryItemsMap, itemsMap, ());
+ return itemsMap;
+}
+
+static void webkitBackForwardListItemFinalized(gpointer wkListItem, GObject* finalizedListItem)
+{
+ ASSERT(G_OBJECT(historyItemsMap().get(static_cast<WKBackForwardListItemRef>(wkListItem))) == finalizedListItem);
+ historyItemsMap().remove(static_cast<WKBackForwardListItemRef>(wkListItem));
+}
+
+WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WKBackForwardListItemRef wkListItem)
+{
+ if (!wkListItem)
+ return 0;
+
+ WebKitBackForwardListItem* listItem = historyItemsMap().get(wkListItem);
+ if (listItem)
+ return listItem;
+
+ listItem = WEBKIT_BACK_FORWARD_LIST_ITEM(g_object_new(WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, NULL));
+ listItem->priv->wkListItem = wkListItem;
+
+ g_object_weak_ref(G_OBJECT(listItem), webkitBackForwardListItemFinalized,
+ const_cast<OpaqueWKBackForwardListItem*>(wkListItem));
+ historyItemsMap().set(wkListItem, listItem);
+
+ return listItem;
+}
+
+WKBackForwardListItemRef webkitBackForwardListItemGetWKItem(WebKitBackForwardListItem* listItem)
+{
+ return listItem->priv->wkListItem.get();
+}
+
+/**
+ * webkit_back_forward_list_item_get_uri:
+ * @list_item: a #WebKitBackForwardListItem
+ *
+ * This URI may differ from the original URI if the page was,
+ * for example, redirected to a new location.
+ * See also webkit_back_forward_list_item_get_original_uri().
+ *
+ * Returns: the URI of @list_item or %NULL
+ * when the URI is empty.
+ */
+const gchar* webkit_back_forward_list_item_get_uri(WebKitBackForwardListItem* listItem)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
+
+ WebKitBackForwardListItemPrivate* priv = listItem->priv;
+ WKRetainPtr<WKURLRef> wkURI(AdoptWK, WKBackForwardListItemCopyURL(priv->wkListItem.get()));
+ if (toImpl(wkURI.get())->string().isEmpty())
+ return 0;
+
+ priv->uri = toImpl(wkURI.get())->string().utf8();
+ return priv->uri.data();
+}
+
+/**
+ * webkit_back_forward_list_item_get_title:
+ * @list_item: a #WebKitBackForwardListItem
+ *
+ * Returns: the page title of @list_item or %NULL
+ * when the title is empty.
+ */
+const gchar* webkit_back_forward_list_item_get_title(WebKitBackForwardListItem* listItem)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
+
+ WebKitBackForwardListItemPrivate* priv = listItem->priv;
+ WKRetainPtr<WKStringRef> wkTitle(AdoptWK, WKBackForwardListItemCopyTitle(priv->wkListItem.get()));
+ if (toImpl(wkTitle.get())->string().isEmpty())
+ return 0;
+
+ priv->title = toImpl(wkTitle.get())->string().utf8();
+ return priv->title.data();
+}
+
+/**
+ * webkit_back_forward_list_item_get_original_uri:
+ * @list_item: a #WebKitBackForwardListItem
+ *
+ * See also webkit_back_forward_list_item_get_uri().
+ *
+ * Returns: the original URI of @list_item or %NULL
+ * when the original URI is empty.
+ */
+const gchar* webkit_back_forward_list_item_get_original_uri(WebKitBackForwardListItem* listItem)
+{
+ g_return_val_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem), 0);
+
+ WebKitBackForwardListItemPrivate* priv = listItem->priv;
+ WKRetainPtr<WKURLRef> wkOriginalURI(AdoptWK, WKBackForwardListItemCopyOriginalURL(priv->wkListItem.get()));
+ if (toImpl(wkOriginalURI.get())->string().isEmpty())
+ return 0;
+
+ priv->originalURI = toImpl(wkOriginalURI.get())->string().utf8();
+ return priv->originalURI.data();
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h
new file mode 100644
index 000000000..43fcc7f8f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListItem.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitBackForwardListItem_h
+#define WebKitBackForwardListItem_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM (webkit_back_forward_list_item_get_type())
+#define WEBKIT_BACK_FORWARD_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItem))
+#define WEBKIT_BACK_FORWARD_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass))
+#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM))
+#define WEBKIT_IS_BACK_FORWARD_LIST_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM))
+#define WEBKIT_BACK_FORWARD_LIST_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM, WebKitBackForwardListItemClass))
+
+typedef struct _WebKitBackForwardListItem WebKitBackForwardListItem;
+typedef struct _WebKitBackForwardListItemClass WebKitBackForwardListItemClass;
+typedef struct _WebKitBackForwardListItemPrivate WebKitBackForwardListItemPrivate;
+
+struct _WebKitBackForwardListItem {
+ GInitiallyUnowned parent;
+
+ WebKitBackForwardListItemPrivate *priv;
+};
+
+struct _WebKitBackForwardListItemClass {
+ GInitiallyUnownedClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_back_forward_list_item_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_back_forward_list_item_get_uri (WebKitBackForwardListItem* list_item);
+
+WEBKIT_API const gchar *
+webkit_back_forward_list_item_get_title (WebKitBackForwardListItem* list_item);
+
+WEBKIT_API const gchar *
+webkit_back_forward_list_item_get_original_uri (WebKitBackForwardListItem* list_item);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h
new file mode 100644
index 000000000..e01909201
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitBackForwardListPrivate.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitBackForwardListPrivate_h
+#define WebKitBackForwardListPrivate_h
+
+#include "WebBackForwardList.h"
+#include "WebKitBackForwardList.h"
+#include <WebKit2/WebKit2.h>
+
+WebKitBackForwardList* webkitBackForwardListCreate(WKBackForwardListRef);
+WebKitBackForwardListItem* webkitBackForwardListItemGetOrCreate(WKBackForwardListItemRef);
+WKBackForwardListItemRef webkitBackForwardListItemGetWKItem(WebKitBackForwardListItem*);
+void webkitBackForwardListChanged(WebKitBackForwardList*, WKBackForwardListItemRef wkAddedItem, WKArrayRef wkRemovedItems);
+
+#endif // WebKitBackForwardListPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h
new file mode 100644
index 000000000..79b338360
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitDefines_h
+#define WebKitDefines_h
+
+#include <glib.h>
+
+#ifdef G_OS_WIN32
+# ifdef BUILDING_WEBKIT
+# define WEBKIT_API __declspec(dllexport)
+# else
+# define WEBKIT_API __declspec(dllimport)
+# endif
+# define WEBKIT_OBSOLETE_API WEBKIT_API
+#else
+# define WEBKIT_API __attribute__((visibility("default")))
+# define WEBKIT_OBSOLETE_API WEBKIT_API __attribute__((deprecated))
+#endif
+
+#endif // WebKitDefines_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp
new file mode 100644
index 000000000..6c24aa12e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitError.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitError.h"
+
+#include "WebKitPrivate.h"
+#include <WebCore/ErrorsGtk.h>
+
+GQuark webkit_network_error_quark()
+{
+ return g_quark_from_static_string(WebCore::errorDomainNetwork);
+}
+
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FAILED, NetworkErrorFailed);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_TRANSPORT, NetworkErrorTransport);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL, NetworkErrorUnknownProtocol);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_CANCELLED, NetworkErrorCancelled);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST, NetworkErrorFileDoesNotExist);
+
+GQuark webkit_policy_error_quark()
+{
+ return g_quark_from_static_string(WebCore::errorDomainPolicy);
+}
+
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FAILED, PolicyErrorFailed);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE, PolicyErrorCannotShowMimeType);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI, PolicyErrorCannotShowURL);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE, PolicyErrorFrameLoadInterruptedByPolicyChange);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT, PolicyErrorCannotUseRestrictedPort);
+
+GQuark webkit_plugin_error_quark()
+{
+ return g_quark_from_static_string(WebCore::errorDomainPlugin);
+}
+
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_FAILED, PluginErrorFailed);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN, PluginErrorCannotFindPlugin);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN, PluginErrorCannotLoadPlugin);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE, PluginErrorJavaUnavailable);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED, PluginErrorConnectionCancelled);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD, PluginErrorWillHandleLoad);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitError.h b/Source/WebKit2/UIProcess/API/gtk/WebKitError.h
new file mode 100644
index 000000000..3ce0e20f1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitError.h
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitError_h
+#define WebKitError_h
+
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_NETWORK_ERROR webkit_network_error_quark ()
+#define WEBKIT_POLICY_ERROR webkit_policy_error_quark ()
+#define WEBKIT_PLUGIN_ERROR webkit_plugin_error_quark ()
+
+/**
+ * WebKitNetworkError:
+ * @WEBKIT_NETWORK_ERROR_FAILED: Generic load failure
+ * @WEBKIT_NETWORK_ERROR_TRANSPORT: Load failure due to transport error
+ * @WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL: Load failure due to unknown protocol
+ * @WEBKIT_NETWORK_ERROR_CANCELLED: Load failure due to cancellation
+ * @WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST: Load failure due to missing file
+ *
+ * Enum values used to denote the various network errors.
+ **/
+typedef enum {
+ WEBKIT_NETWORK_ERROR_FAILED = 399,
+ WEBKIT_NETWORK_ERROR_TRANSPORT = 300,
+ WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL = 301,
+ WEBKIT_NETWORK_ERROR_CANCELLED = 302,
+ WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST = 303
+} WebKitNetworkError;
+
+/**
+ * WebKitPolicyError:
+ * @WEBKIT_POLICY_ERROR_FAILED: Generic load failure due to policy error
+ * @WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE: Load failure due to unsupported mime type
+ * @WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI: Load failure due to URI that can not be shown
+ * @WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE: Load failure due to frame load interruption by policy change
+ * @WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT: Load failure due to port restriction
+ *
+ * Enum values used to denote the various policy errors.
+ **/
+typedef enum {
+ WEBKIT_POLICY_ERROR_FAILED = 199,
+ WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE = 100,
+ WEBKIT_POLICY_ERROR_CANNOT_SHOW_URI = 101,
+ WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE = 102,
+ WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT = 103
+} WebKitPolicyError;
+
+/**
+ * WebKitPluginError:
+ * @WEBKIT_PLUGIN_ERROR_FAILED: Generic plugin load failure
+ * @WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN: Load failure due to missing plugin
+ * @WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN: Load failure due to inability to load plugin
+ * @WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE: Load failue due to missing Java support that is required to load plugin
+ * @WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED: Load failure due to connection cancellation
+ * @WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD: Load failure since plugin handles the load
+ *
+ * Enum values used to denote the various plugin errors.
+ **/
+typedef enum {
+ WEBKIT_PLUGIN_ERROR_FAILED = 299,
+ WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN = 200,
+ WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN = 201,
+ WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE = 202,
+ WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED = 203,
+ WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD = 204,
+} WebKitPluginError;
+
+WEBKIT_API GQuark
+webkit_network_error_quark (void);
+
+WEBKIT_API GQuark
+webkit_policy_error_quark (void);
+
+WEBKIT_API GQuark
+webkit_plugin_error_quark (void);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
new file mode 100644
index 000000000..423c464b0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitPrivate_h
+#define WebKitPrivate_h
+
+#include <glib.h>
+#include <wtf/Assertions.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB))
+#define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB))
+#define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB))
+
+#define COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \
+ COMPILE_ASSERT(int(webkitName) == int(WebCore::webcoreName), mismatchingEnums)
+
+G_END_DECLS
+
+#endif // WebKitPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
new file mode 100644
index 000000000..837a9a1e5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
@@ -0,0 +1,1905 @@
+/*
+ * Copyright (c) 2011 Motorola Mobility, 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:
+ *
+ * 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 Motorola Mobility, 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 HOLDER 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.
+ */
+
+#include "config.h"
+#include "WebKitSettings.h"
+
+#include "WebKitPrivate.h"
+#include "WebKitSettingsPrivate.h"
+#include <WebKit2/WKAPICast.h>
+#include <WebKit2/WKString.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <glib/gi18n-lib.h>
+#include <wtf/text/CString.h>
+
+struct _WebKitSettingsPrivate {
+ WKRetainPtr<WKPreferencesRef> preferences;
+ CString defaultFontFamily;
+ CString monospaceFontFamily;
+ CString serifFontFamily;
+ CString sansSerifFontFamily;
+ CString cursiveFontFamily;
+ CString fantasyFontFamily;
+ CString pictographFontFamily;
+ CString defaultCharset;
+};
+
+/**
+ * SECTION:WebKitSettings
+ * @short_description: Control the behaviour of a #WebKitWebView
+ *
+ * #WebKitSettings can be applied to a #WebKitWebView to control text charset,
+ * color, font sizes, printing mode, script support, loading of images and various other things.
+ * After creation, a #WebKitSettings object contains default settings.
+ *
+ * <informalexample><programlisting>
+ * /<!-- -->* Create a new #WebKitSettings and disable JavaScript. *<!-- -->/
+ * WebKitSettings *settings = webkit_settings_new ();
+ * g_object_set (G_OBJECT (settings), "enable-javascript", FALSE, NULL);
+ *
+ * webkit_web_view_set_settings (WEBKIT_WEB_VIEW (my_webview), settings);
+ * </programlisting></informalexample>
+ */
+
+
+G_DEFINE_TYPE(WebKitSettings, webkit_settings, G_TYPE_OBJECT)
+
+enum {
+ PROP_0,
+
+ PROP_ENABLE_JAVASCRIPT,
+ PROP_AUTO_LOAD_IMAGES,
+ PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING,
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
+ PROP_ENABLE_HTML5_LOCAL_STORAGE,
+ PROP_ENABLE_HTML5_DATABASE,
+ PROP_ENABLE_XSS_AUDITOR,
+ PROP_ENABLE_FRAME_FLATTENING,
+ PROP_ENABLE_PLUGINS,
+ PROP_ENABLE_JAVA,
+ PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
+ PROP_ENABLE_HYPERLINK_AUDITING,
+ PROP_DEFAULT_FONT_FAMILY,
+ PROP_MONOSPACE_FONT_FAMILY,
+ PROP_SERIF_FONT_FAMILY,
+ PROP_SANS_SERIF_FONT_FAMILY,
+ PROP_CURSIVE_FONT_FAMILY,
+ PROP_FANTASY_FONT_FAMILY,
+ PROP_PICTOGRAPH_FONT_FAMILY,
+ PROP_DEFAULT_FONT_SIZE,
+ PROP_DEFAULT_MONOSPACE_FONT_SIZE,
+ PROP_MINIMUM_FONT_SIZE,
+ PROP_DEFAULT_CHARSET,
+ PROP_ENABLE_PRIVATE_BROWSING,
+ PROP_ENABLE_DEVELOPER_EXTRAS,
+ PROP_ENABLE_RESIZABLE_TEXT_AREAS,
+ PROP_ENABLE_TABS_TO_LINKS,
+ PROP_ENABLE_DNS_PREFETCHING,
+ PROP_ENABLE_CARET_BROWSING,
+ PROP_ENABLE_FULLSCREEN
+};
+
+static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitSettings* settings = WEBKIT_SETTINGS(object);
+
+ switch (propId) {
+ case PROP_ENABLE_JAVASCRIPT:
+ webkit_settings_set_enable_javascript(settings, g_value_get_boolean(value));
+ break;
+ case PROP_AUTO_LOAD_IMAGES:
+ webkit_settings_set_auto_load_images(settings, g_value_get_boolean(value));
+ break;
+ case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING:
+ webkit_settings_set_load_icons_ignoring_image_load_setting(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
+ webkit_settings_set_enable_offline_web_application_cache(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_HTML5_LOCAL_STORAGE:
+ webkit_settings_set_enable_html5_local_storage(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_HTML5_DATABASE:
+ webkit_settings_set_enable_html5_database(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_XSS_AUDITOR:
+ webkit_settings_set_enable_xss_auditor(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_FRAME_FLATTENING:
+ webkit_settings_set_enable_frame_flattening(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_PLUGINS:
+ webkit_settings_set_enable_plugins(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_JAVA:
+ webkit_settings_set_enable_java(settings, g_value_get_boolean(value));
+ break;
+ case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
+ webkit_settings_set_javascript_can_open_windows_automatically(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_HYPERLINK_AUDITING:
+ webkit_settings_set_enable_hyperlink_auditing(settings, g_value_get_boolean(value));
+ break;
+ case PROP_DEFAULT_FONT_FAMILY:
+ webkit_settings_set_default_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_MONOSPACE_FONT_FAMILY:
+ webkit_settings_set_monospace_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_SERIF_FONT_FAMILY:
+ webkit_settings_set_serif_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_SANS_SERIF_FONT_FAMILY:
+ webkit_settings_set_sans_serif_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_CURSIVE_FONT_FAMILY:
+ webkit_settings_set_cursive_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_FANTASY_FONT_FAMILY:
+ webkit_settings_set_fantasy_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_PICTOGRAPH_FONT_FAMILY:
+ webkit_settings_set_pictograph_font_family(settings, g_value_get_string(value));
+ break;
+ case PROP_DEFAULT_FONT_SIZE:
+ webkit_settings_set_default_font_size(settings, g_value_get_uint(value));
+ break;
+ case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
+ webkit_settings_set_default_monospace_font_size(settings, g_value_get_uint(value));
+ break;
+ case PROP_MINIMUM_FONT_SIZE:
+ webkit_settings_set_minimum_font_size(settings, g_value_get_uint(value));
+ break;
+ case PROP_DEFAULT_CHARSET:
+ webkit_settings_set_default_charset(settings, g_value_get_string(value));
+ break;
+ case PROP_ENABLE_PRIVATE_BROWSING:
+ webkit_settings_set_enable_private_browsing(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_DEVELOPER_EXTRAS:
+ webkit_settings_set_enable_developer_extras(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
+ webkit_settings_set_enable_resizable_text_areas(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_TABS_TO_LINKS:
+ webkit_settings_set_enable_tabs_to_links(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_DNS_PREFETCHING:
+ webkit_settings_set_enable_dns_prefetching(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_CARET_BROWSING:
+ webkit_settings_set_enable_caret_browsing(settings, g_value_get_boolean(value));
+ break;
+ case PROP_ENABLE_FULLSCREEN:
+ webkit_settings_set_enable_fullscreen(settings, g_value_get_boolean(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ break;
+ }
+}
+
+static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitSettings* settings = WEBKIT_SETTINGS(object);
+
+ switch (propId) {
+ case PROP_ENABLE_JAVASCRIPT:
+ g_value_set_boolean(value, webkit_settings_get_enable_javascript(settings));
+ break;
+ case PROP_AUTO_LOAD_IMAGES:
+ g_value_set_boolean(value, webkit_settings_get_auto_load_images(settings));
+ break;
+ case PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING:
+ g_value_set_boolean(value, webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
+ break;
+ case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
+ g_value_set_boolean(value, webkit_settings_get_enable_offline_web_application_cache(settings));
+ break;
+ case PROP_ENABLE_HTML5_LOCAL_STORAGE:
+ g_value_set_boolean(value, webkit_settings_get_enable_html5_local_storage(settings));
+ break;
+ case PROP_ENABLE_HTML5_DATABASE:
+ g_value_set_boolean(value, webkit_settings_get_enable_html5_database(settings));
+ break;
+ case PROP_ENABLE_XSS_AUDITOR:
+ g_value_set_boolean(value, webkit_settings_get_enable_xss_auditor(settings));
+ break;
+ case PROP_ENABLE_FRAME_FLATTENING:
+ g_value_set_boolean(value, webkit_settings_get_enable_frame_flattening(settings));
+ break;
+ case PROP_ENABLE_PLUGINS:
+ g_value_set_boolean(value, webkit_settings_get_enable_plugins(settings));
+ break;
+ case PROP_ENABLE_JAVA:
+ g_value_set_boolean(value, webkit_settings_get_enable_java(settings));
+ break;
+ case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
+ g_value_set_boolean(value, webkit_settings_get_javascript_can_open_windows_automatically(settings));
+ break;
+ case PROP_ENABLE_HYPERLINK_AUDITING:
+ g_value_set_boolean(value, webkit_settings_get_enable_hyperlink_auditing(settings));
+ break;
+ case PROP_DEFAULT_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_default_font_family(settings));
+ break;
+ case PROP_MONOSPACE_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_monospace_font_family(settings));
+ break;
+ case PROP_SERIF_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_serif_font_family(settings));
+ break;
+ case PROP_SANS_SERIF_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_sans_serif_font_family(settings));
+ break;
+ case PROP_CURSIVE_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_cursive_font_family(settings));
+ break;
+ case PROP_FANTASY_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_fantasy_font_family(settings));
+ break;
+ case PROP_PICTOGRAPH_FONT_FAMILY:
+ g_value_set_string(value, webkit_settings_get_pictograph_font_family(settings));
+ break;
+ case PROP_DEFAULT_FONT_SIZE:
+ g_value_set_uint(value, webkit_settings_get_default_font_size(settings));
+ break;
+ case PROP_DEFAULT_MONOSPACE_FONT_SIZE:
+ g_value_set_uint(value, webkit_settings_get_default_monospace_font_size(settings));
+ break;
+ case PROP_MINIMUM_FONT_SIZE:
+ g_value_set_uint(value, webkit_settings_get_minimum_font_size(settings));
+ break;
+ case PROP_DEFAULT_CHARSET:
+ g_value_set_string(value, webkit_settings_get_default_charset(settings));
+ break;
+ case PROP_ENABLE_PRIVATE_BROWSING:
+ g_value_set_boolean(value, webkit_settings_get_enable_private_browsing(settings));
+ break;
+ case PROP_ENABLE_DEVELOPER_EXTRAS:
+ g_value_set_boolean(value, webkit_settings_get_enable_developer_extras(settings));
+ break;
+ case PROP_ENABLE_RESIZABLE_TEXT_AREAS:
+ g_value_set_boolean(value, webkit_settings_get_enable_resizable_text_areas(settings));
+ break;
+ case PROP_ENABLE_TABS_TO_LINKS:
+ g_value_set_boolean(value, webkit_settings_get_enable_tabs_to_links(settings));
+ break;
+ case PROP_ENABLE_DNS_PREFETCHING:
+ g_value_set_boolean(value, webkit_settings_get_enable_dns_prefetching(settings));
+ break;
+ case PROP_ENABLE_CARET_BROWSING:
+ g_value_set_boolean(value, webkit_settings_get_enable_caret_browsing(settings));
+ break;
+ case PROP_ENABLE_FULLSCREEN:
+ g_value_set_boolean(value, webkit_settings_get_enable_fullscreen(settings));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ break;
+ }
+}
+
+static void webKitSettingsFinalize(GObject* object)
+{
+ WEBKIT_SETTINGS(object)->priv->~WebKitSettingsPrivate();
+ G_OBJECT_CLASS(webkit_settings_parent_class)->finalize(object);
+}
+
+static void webkit_settings_class_init(WebKitSettingsClass* klass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(klass);
+ gObjectClass->set_property = webKitSettingsSetProperty;
+ gObjectClass->get_property = webKitSettingsGetProperty;
+ gObjectClass->finalize = webKitSettingsFinalize;
+
+ GParamFlags readWriteConstructParamFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+
+ /**
+ * WebKitSettings:enable-javascript:
+ *
+ * Determines whether or not JavaScript executes within a page.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_JAVASCRIPT,
+ g_param_spec_boolean("enable-javascript",
+ _("Enable JavaScript"),
+ _("Enable JavaScript."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:auto-load-images:
+ *
+ * Determines whether images should be automatically loaded or not.
+ * On devices where network bandwidth is of concern, it might be
+ * useful to turn this property off.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_AUTO_LOAD_IMAGES,
+ g_param_spec_boolean("auto-load-images",
+ _("Auto load images"),
+ _("Load images automatically."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:load-icons-ignoring-image-load-setting:
+ *
+ * Determines whether a site can load favicons irrespective
+ * of the value of #WebKitSettings:auto-load-images.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_LOAD_ICONS_IGNORING_IMAGE_LOAD_SETTING,
+ g_param_spec_boolean("load-icons-ignoring-image-load-setting",
+ _("Load icons ignoring image load setting"),
+ _("Whether to load site icons ignoring image load setting."),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-offline-web-application-cache:
+ *
+ * Whether to enable HTML5 offline web application cache support. Offline
+ * web application cache allows web applications to run even when
+ * the user is not connected to the network.
+ *
+ * HTML5 offline web application specification is available at
+ * http://dev.w3.org/html5/spec/offline.html.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
+ g_param_spec_boolean("enable-offline-web-application-cache",
+ _("Enable offline web application cache"),
+ _("Whether to enable offline web application cache."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-html5-local-storage:
+ *
+ * Whether to enable HTML5 local storage support. Local storage provides
+ * simple synchronous storage access.
+ *
+ * HTML5 local storage specification is available at
+ * http://dev.w3.org/html5/webstorage/.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_HTML5_LOCAL_STORAGE,
+ g_param_spec_boolean("enable-html5-local-storage",
+ _("Enable HTML5 local storage"),
+ _("Whether to enable HTML5 Local Storage support."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-html5-database:
+ *
+ * Whether to enable HTML5 client-side SQL database support. Client-side
+ * SQL database allows web pages to store structured data and be able to
+ * use SQL to manipulate that data asynchronously.
+ *
+ * HTML5 database specification is available at
+ * http://www.w3.org/TR/webdatabase/.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_HTML5_DATABASE,
+ g_param_spec_boolean("enable-html5-database",
+ _("Enable HTML5 database"),
+ _("Whether to enable HTML5 database support."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-xss-auditor:
+ *
+ * Whether to enable the XSS auditor. This feature filters some kinds of
+ * reflective XSS attacks on vulnerable web sites.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_XSS_AUDITOR,
+ g_param_spec_boolean("enable-xss-auditor",
+ _("Enable XSS auditor"),
+ _("Whether to enable the XSS auditor."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+
+ /**
+ * WebKitSettings:enable-frame-flattening:
+ *
+ * Whether to enable the frame flattening. With this setting each subframe is expanded
+ * to its contents, which will flatten all the frames to become one scrollable page.
+ * On touch devices scrollable subframes on a page can result in a confusing user experience.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_FRAME_FLATTENING,
+ g_param_spec_boolean("enable-frame-flattening",
+ _("Enable frame flattening"),
+ _("Whether to enable frame flattening."),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-plugins:
+ *
+ * Determines whether or not plugins on the page are enabled.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_PLUGINS,
+ g_param_spec_boolean("enable-plugins",
+ _("Enable plugins"),
+ _("Enable embedded plugin objects."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-java:
+ *
+ * Determines whether or not Java is enabled on the page.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_JAVA,
+ g_param_spec_boolean("enable-java",
+ _("Enable Java"),
+ _("Whether Java support should be enabled."),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:javascript-can-open-windows-automatically:
+ *
+ * Whether JavaScript can open popup windows automatically without user
+ * intervention.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
+ g_param_spec_boolean("javascript-can-open-windows-automatically",
+ _("JavaScript can open windows automatically"),
+ _("Whether JavaScript can open windows automatically."),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-hyperlink-auditing:
+ *
+ * Determines whether or not hyperlink auditing is enabled.
+ *
+ * The hyperlink auditing specification is available at
+ * http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_HYPERLINK_AUDITING,
+ g_param_spec_boolean("enable-hyperlink-auditing",
+ _("Enable hyperlink auditing"),
+ _("Whether <a ping> should be able to send pings."),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:default-font-family:
+ *
+ * The font family to use as the default for content that does not specify a font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_DEFAULT_FONT_FAMILY,
+ g_param_spec_string("default-font-family",
+ _("Default font family"),
+ _("The font family to use as the default for content that does not specify a font."),
+ "sans-serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:monospace-font-family:
+ *
+ * The font family used as the default for content using a monospace font.
+ *
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_MONOSPACE_FONT_FAMILY,
+ g_param_spec_string("monospace-font-family",
+ _("Monospace font family"),
+ _("The font family used as the default for content using monospace font."),
+ "monospace",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:serif-font-family:
+ *
+ * The font family used as the default for content using a serif font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_SERIF_FONT_FAMILY,
+ g_param_spec_string("serif-font-family",
+ _("Serif font family"),
+ _("The font family used as the default for content using serif font."),
+ "serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:sans-serif-font-family:
+ *
+ * The font family used as the default for content using a sans-serif font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_SANS_SERIF_FONT_FAMILY,
+ g_param_spec_string("sans-serif-font-family",
+ _("Sans-serif font family"),
+ _("The font family used as the default for content using sans-serif font."),
+ "sans-serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:cursive-font-family:
+ *
+ * The font family used as the default for content using a cursive font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_CURSIVE_FONT_FAMILY,
+ g_param_spec_string("cursive-font-family",
+ _("Cursive font family"),
+ _("The font family used as the default for content using cursive font."),
+ "serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:fantasy-font-family:
+ *
+ * The font family used as the default for content using a fantasy font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_FANTASY_FONT_FAMILY,
+ g_param_spec_string("fantasy-font-family",
+ _("Fantasy font family"),
+ _("The font family used as the default for content using fantasy font."),
+ "serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:pictograph-font-family:
+ *
+ * The font family used as the default for content using a pictograph font.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_PICTOGRAPH_FONT_FAMILY,
+ g_param_spec_string("pictograph-font-family",
+ _("Pictograph font family"),
+ _("The font family used as the default for content using pictograph font."),
+ "serif",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:default-font-size:
+ *
+ * The default font size in pixels to use for content displayed if
+ * no font size is specified.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_DEFAULT_FONT_SIZE,
+ g_param_spec_uint("default-font-size",
+ _("Default font size"),
+ _("The default font size used to display text."),
+ 0, G_MAXUINT, 16,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:default-monospace-font-size:
+ *
+ * The default font size in pixels to use for content displayed in
+ * monospace font if no font size is specified.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_DEFAULT_MONOSPACE_FONT_SIZE,
+ g_param_spec_uint("default-monospace-font-size",
+ _("Default monospace font size"),
+ _("The default font size used to display monospace text."),
+ 0, G_MAXUINT, 13,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitWebSettings:minimum-font-size:
+ *
+ * The minimum font size in points used to display text. This setting
+ * controls the absolute smallest size. Values other than 0 can
+ * potentially break page layouts.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_MINIMUM_FONT_SIZE,
+ g_param_spec_uint("minimum-font-size",
+ _("Minimum font size"),
+ _("The minimum font size used to display text."),
+ 0, G_MAXUINT, 0,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:default-charset:
+ *
+ * The default text charset used when interpreting content with an unspecified charset.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_DEFAULT_CHARSET,
+ g_param_spec_string("default-charset",
+ _("Default charset"),
+ _("The default text charset used when interpreting content with unspecified charset."),
+ "iso-8859-1",
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-private-browsing:
+ *
+ * Determines whether or not private browsing is enabled. Private browsing
+ * will disable history, cache and form auto-fill for any pages visited.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_PRIVATE_BROWSING,
+ g_param_spec_boolean("enable-private-browsing",
+ _("Enable private browsing"),
+ _("Whether to enable private browsing"),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-developer-extras:
+ *
+ * Determines whether or not developer tools, such as the Web Inspector, are enabled.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_DEVELOPER_EXTRAS,
+ g_param_spec_boolean("enable-developer-extras",
+ _("Enable developer extras"),
+ _("Whether to enable developer extras"),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-resizable-text-areas:
+ *
+ * Determines whether or not text areas can be resized.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_RESIZABLE_TEXT_AREAS,
+ g_param_spec_boolean("enable-resizable-text-areas",
+ _("Enable resizable text areas"),
+ _("Whether to enable resizable text areas"),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-tabs-to-links:
+ *
+ * Determines whether the tab key cycles through the elements on the page.
+ * When this setting is enabled, users will be able to focus the next element
+ * in the page by pressing the tab key. If the selected element is editable,
+ * then pressing tab key will insert the tab character.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_TABS_TO_LINKS,
+ g_param_spec_boolean("enable-tabs-to-links",
+ _("Enable tabs to links"),
+ _("Whether to enable tabs to links"),
+ TRUE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-dns-prefetching:
+ *
+ * Determines whether or not to prefetch domain names. DNS prefetching attempts
+ * to resolve domain names before a user tries to follow a link.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_DNS_PREFETCHING,
+ g_param_spec_boolean("enable-dns-prefetching",
+ _("Enable DNS prefetching"),
+ _("Whether to enable DNS prefetching"),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-caret-browsing:
+ *
+ * Whether to enable accessibility enhanced keyboard navigation.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_CARET_BROWSING,
+ g_param_spec_boolean("enable-caret-browsing",
+ _("Enable Caret Browsing"),
+ _("Whether to enable accessibility enhanced keyboard navigation"),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ /**
+ * WebKitSettings:enable-fullscreen:
+ *
+ * Whether to enable the Javascript Fullscreen API. The API
+ * allows any HTML element to request fullscreen display. See also
+ * the current draft of the spec:
+ * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_FULLSCREEN,
+ g_param_spec_boolean("enable-fullscreen",
+ _("Enable Fullscreen"),
+ _("Whether to enable the Javascriipt Fullscreen API"),
+ FALSE,
+ readWriteConstructParamFlags));
+
+ g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate));
+}
+
+static void webkit_settings_init(WebKitSettings* settings)
+{
+ WebKitSettingsPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(settings, WEBKIT_TYPE_SETTINGS, WebKitSettingsPrivate);
+ settings->priv = priv;
+ new (priv) WebKitSettingsPrivate();
+
+ priv->preferences = adoptWK(WKPreferencesCreate());
+
+ WKRetainPtr<WKStringRef> defaultFontFamilyRef = WKPreferencesCopyStandardFontFamily(priv->preferences.get());
+ priv->defaultFontFamily = WebKit::toImpl(defaultFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> monospaceFontFamilyRef = WKPreferencesCopyFixedFontFamily(priv->preferences.get());
+ priv->monospaceFontFamily = WebKit::toImpl(monospaceFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> serifFontFamilyRef = WKPreferencesCopySerifFontFamily(priv->preferences.get());
+ priv->serifFontFamily = WebKit::toImpl(serifFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> sansSerifFontFamilyRef = WKPreferencesCopySansSerifFontFamily(priv->preferences.get());
+ priv->sansSerifFontFamily = WebKit::toImpl(sansSerifFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> cursiveFontFamilyRef = WKPreferencesCopyCursiveFontFamily(priv->preferences.get());
+ priv->cursiveFontFamily = WebKit::toImpl(cursiveFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> fantasyFontFamilyRef = WKPreferencesCopyFantasyFontFamily(priv->preferences.get());
+ priv->fantasyFontFamily = WebKit::toImpl(fantasyFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> pictographFontFamilyRef = WKPreferencesCopyPictographFontFamily(priv->preferences.get());
+ priv->pictographFontFamily = WebKit::toImpl(pictographFontFamilyRef.get())->string().utf8();
+
+ WKRetainPtr<WKStringRef> defaultCharsetRef = WKPreferencesCopyDefaultTextEncodingName(priv->preferences.get());
+ priv->defaultCharset = WebKit::toImpl(defaultCharsetRef.get())->string().utf8();
+}
+
+void webkitSettingsAttachSettingsToPage(WebKitSettings* settings, WKPageRef wkPage)
+{
+ WKPageGroupSetPreferences(WKPageGetPageGroup(wkPage), settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_new:
+ *
+ * Creates a new #WebKitSettings instance with default values. It must
+ * be manually attached to a #WebKitWebView.
+ * See also webkit_settings_new_with_settings().
+ *
+ * Returns: a new #WebKitSettings instance.
+ */
+WebKitSettings* webkit_settings_new()
+{
+ return WEBKIT_SETTINGS(g_object_new(WEBKIT_TYPE_SETTINGS, NULL));
+}
+
+/**
+ * webkit_settings_new_with_settings:
+ * @first_setting_name: name of first setting to set
+ * @...: value of first setting, followed by more settings,
+ * %NULL-terminated
+ *
+ * Creates a new #WebKitSettings instance with the given settings. It must
+ * be manually attached to a #WebKitWebView.
+ *
+ * Returns: a new #WebKitSettings instance.
+ */
+WebKitSettings* webkit_settings_new_with_settings(const gchar* firstSettingName, ...)
+{
+ va_list args;
+ va_start(args, firstSettingName);
+ WebKitSettings* settings = WEBKIT_SETTINGS(g_object_new_valist(WEBKIT_TYPE_SETTINGS, firstSettingName, args));
+ va_end(args);
+ return settings;
+}
+
+/**
+ * webkit_settings_get_enable_javascript:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-javascript property.
+ *
+ * Returns: %TRUE If JavaScript is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_javascript(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetJavaScriptEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_javascript:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-javascript property.
+ */
+void webkit_settings_set_enable_javascript(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetJavaScriptEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetJavaScriptEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-javascript");
+}
+
+/**
+ * webkit_settings_get_auto_load_images:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:auto-load-images property.
+ *
+ * Returns: %TRUE If auto loading of images is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_auto_load_images(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetLoadsImagesAutomatically(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_auto_load_images:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:auto-load-images property.
+ */
+void webkit_settings_set_auto_load_images(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetLoadsImagesAutomatically(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetLoadsImagesAutomatically(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "auto-load-images");
+}
+
+/**
+ * webkit_settings_get_load_icons_ignoring_image_load_setting:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:load-icons-ignoring-image-load-setting property.
+ *
+ * Returns: %TRUE If site icon can be loaded irrespective of image loading preference or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_load_icons_ignoring_image_load_setting(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_load_icons_ignoring_image_load_setting:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:load-icons-ignoring-image-load-setting property.
+ */
+void webkit_settings_set_load_icons_ignoring_image_load_setting(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetLoadsSiteIconsIgnoringImageLoadingPreference(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetLoadsSiteIconsIgnoringImageLoadingPreference(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "load-icons-ignoring-image-load-setting");
+}
+
+/**
+ * webkit_settings_get_enable_offline_web_application_cache:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-offline-web-application-cache property.
+ *
+ * Returns: %TRUE If HTML5 offline web application cache support is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_offline_web_application_cache(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetOfflineWebApplicationCacheEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_offline_web_application_cache:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-offline-web-application-cache property.
+ */
+void webkit_settings_set_enable_offline_web_application_cache(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetOfflineWebApplicationCacheEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetOfflineWebApplicationCacheEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-offline-web-application-cache");
+}
+
+/**
+ * webkit_settings_get_enable_html5_local_storage:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-html5-local-storage property.
+ *
+ * Returns: %TRUE If HTML5 local storage support is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_html5_local_storage(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetLocalStorageEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_html5_local_storage:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-html5-local-storage property.
+ */
+void webkit_settings_set_enable_html5_local_storage(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetLocalStorageEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetLocalStorageEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-html5-local-storage");
+}
+
+/**
+ * webkit_settings_get_enable_html5_database:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-html5-database property.
+ *
+ * Returns: %TRUE If HTML5 database support is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_html5_database(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetDatabasesEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_html5_database:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-html5-database property.
+ */
+void webkit_settings_set_enable_html5_database(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetDatabasesEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetDatabasesEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-html5-database");
+}
+
+/**
+ * webkit_settings_get_enable_xss_auditor:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-xss-auditor property.
+ *
+ * Returns: %TRUE If XSS auditing is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_xss_auditor(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetXSSAuditorEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_xss_auditor:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-xss-auditor property.
+ */
+void webkit_settings_set_enable_xss_auditor(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetXSSAuditorEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetXSSAuditorEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-xss-auditor");
+}
+
+/**
+ * webkit_settings_get_enable_frame_flattening:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-frame-flattening property.
+ *
+ * Returns: %TRUE If frame flattening is enabled or %FALSE otherwise.
+ *
+ **/
+gboolean webkit_settings_get_enable_frame_flattening(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetFrameFlatteningEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_frame_flattening:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-frame-flattening property.
+ */
+void webkit_settings_set_enable_frame_flattening(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetFrameFlatteningEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetFrameFlatteningEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-frame-flattening");
+}
+
+/**
+ * webkit_settings_get_enable_plugins:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-plugins property.
+ *
+ * Returns: %TRUE If plugins are enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_plugins(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetPluginsEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_plugins:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-plugins property.
+ */
+void webkit_settings_set_enable_plugins(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetPluginsEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetPluginsEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-plugins");
+}
+
+/**
+ * webkit_settings_get_enable_java:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-java property.
+ *
+ * Returns: %TRUE If Java is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_java(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetJavaEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_java:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-java property.
+ */
+void webkit_settings_set_enable_java(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetJavaEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetJavaEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-java");
+}
+
+/**
+ * webkit_settings_get_javascript_can_open_windows_automatically:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:javascript-can-open-windows-automatically property.
+ *
+ * Returns: %TRUE If JavaScript can open window automatically or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_javascript_can_open_windows_automatically(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_javascript_can_open_windows_automatically:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:javascript-can-open-windows-automatically property.
+ */
+void webkit_settings_set_javascript_can_open_windows_automatically(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetJavaScriptCanOpenWindowsAutomatically(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "javascript-can-open-windows-automatically");
+}
+
+/**
+ * webkit_settings_get_enable_hyperlink_auditing:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-hyperlink-auditing property.
+ *
+ * Returns: %TRUE If hyper link auditing is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_hyperlink_auditing(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetHyperlinkAuditingEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_hyperlink_auditing:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-hyperlink-auditing property.
+ */
+void webkit_settings_set_enable_hyperlink_auditing(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetHyperlinkAuditingEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetHyperlinkAuditingEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-hyperlink-auditing");
+}
+
+/**
+ * webkit_web_settings_get_default_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:default-font-family property.
+ *
+ * Returns: The default font family used to display content that does not specify a font.
+ */
+const gchar* webkit_settings_get_default_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->defaultFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_default_font_family:
+ * @settings: a #WebKitSettings
+ * @default_font_family: the new default font family
+ *
+ * Set the #WebKitSettings:default-font-family property.
+ */
+void webkit_settings_set_default_font_family(WebKitSettings* settings, const gchar* defaultFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(defaultFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->defaultFontFamily.data(), defaultFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> standardFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(defaultFontFamily));
+ WKPreferencesSetStandardFontFamily(priv->preferences.get(), standardFontFamilyRef.get());
+ priv->defaultFontFamily = WebKit::toImpl(standardFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "default-font-family");
+}
+
+/**
+ * webkit_settings_get_monospace_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:monospace-font-family property.
+ *
+ * Returns: Default font family used to display content marked with monospace font.
+ */
+const gchar* webkit_settings_get_monospace_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->monospaceFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_monospace_font_family:
+ * @settings: a #WebKitSettings
+ * @monospace_font_family: the new default monospace font family
+ *
+ * Set the #WebKitSettings:monospace-font-family property.
+ */
+void webkit_settings_set_monospace_font_family(WebKitSettings* settings, const gchar* monospaceFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(monospaceFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->monospaceFontFamily.data(), monospaceFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> fixedFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(monospaceFontFamily));
+ WKPreferencesSetFixedFontFamily(priv->preferences.get(), fixedFontFamilyRef.get());
+ priv->monospaceFontFamily = WebKit::toImpl(fixedFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "monospace-font-family");
+}
+
+/**
+ * webkit_settings_get_serif_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:serif-font-family property.
+ *
+ * Returns: The default font family used to display content marked with serif font.
+ */
+const gchar* webkit_settings_get_serif_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->serifFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_serif_font_family:
+ * @settings: a #WebKitSettings
+ * @serif_font_family: the new default serif font family
+ *
+ * Set the #WebKitSettings:serif-font-family property.
+ */
+void webkit_settings_set_serif_font_family(WebKitSettings* settings, const gchar* serifFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(serifFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->serifFontFamily.data(), serifFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> serifFontFamilyRef = WKStringCreateWithUTF8CString(serifFontFamily);
+ WKPreferencesSetSerifFontFamily(priv->preferences.get(), serifFontFamilyRef.get());
+ priv->serifFontFamily = WebKit::toImpl(serifFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "serif-font-family");
+}
+
+/**
+ * webkit_settings_get_sans_serif_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:sans-serif-font-family property.
+ *
+ * Returns: The default font family used to display content marked with sans-serif font.
+ */
+const gchar* webkit_settings_get_sans_serif_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->sansSerifFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_sans_serif_font_family:
+ * @settings: a #WebKitSettings
+ * @sans_serif_font_family: the new default sans-serif font family
+ *
+ * Set the #WebKitSettings:sans-serif-font-family property.
+ */
+void webkit_settings_set_sans_serif_font_family(WebKitSettings* settings, const gchar* sansSerifFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(sansSerifFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->sansSerifFontFamily.data(), sansSerifFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> sansSerifFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(sansSerifFontFamily));
+ WKPreferencesSetSansSerifFontFamily(priv->preferences.get(), sansSerifFontFamilyRef.get());
+ priv->sansSerifFontFamily = WebKit::toImpl(sansSerifFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "sans-serif-font-family");
+}
+
+/**
+ * webkit_settings_get_cursive_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:cursive-font-family property.
+ *
+ * Returns: The default font family used to display content marked with cursive font.
+ */
+const gchar* webkit_settings_get_cursive_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->cursiveFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_cursive_font_family:
+ * @settings: a #WebKitSettings
+ * @cursive_font_family: the new default cursive font family
+ *
+ * Set the #WebKitSettings:cursive-font-family property.
+ */
+void webkit_settings_set_cursive_font_family(WebKitSettings* settings, const gchar* cursiveFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(cursiveFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->cursiveFontFamily.data(), cursiveFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> cursiveFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(cursiveFontFamily));
+ WKPreferencesSetCursiveFontFamily(priv->preferences.get(), cursiveFontFamilyRef.get());
+ priv->cursiveFontFamily = WebKit::toImpl(cursiveFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "cursive-font-family");
+}
+
+/**
+ * webkit_settings_get_fantasy_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:fantasy-font-family property.
+ *
+ * Returns: The default font family used to display content marked with fantasy font.
+ */
+const gchar* webkit_settings_get_fantasy_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->fantasyFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_fantasy_font_family:
+ * @settings: a #WebKitSettings
+ * @fantasy_font_family: the new default fantasy font family
+ *
+ * Set the #WebKitSettings:fantasy-font-family property.
+ */
+void webkit_settings_set_fantasy_font_family(WebKitSettings* settings, const gchar* fantasyFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(fantasyFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->fantasyFontFamily.data(), fantasyFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> fantasyFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(fantasyFontFamily));
+ WKPreferencesSetFantasyFontFamily(priv->preferences.get(), fantasyFontFamilyRef.get());
+ priv->fantasyFontFamily = WebKit::toImpl(fantasyFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "fantasy-font-family");
+}
+
+/**
+ * webkit_settings_get_pictograph_font_family:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:pictograph-font-family property.
+ *
+ * Returns: The default font family used to display content marked with pictograph font.
+ */
+const gchar* webkit_settings_get_pictograph_font_family(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->pictographFontFamily.data();
+}
+
+/**
+ * webkit_settings_set_pictograph_font_family:
+ * @settings: a #WebKitSettings
+ * @pictograph_font_family: the new default pictograph font family
+ *
+ * Set the #WebKitSettings:pictograph-font-family property.
+ */
+void webkit_settings_set_pictograph_font_family(WebKitSettings* settings, const gchar* pictographFontFamily)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(pictographFontFamily);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->pictographFontFamily.data(), pictographFontFamily))
+ return;
+
+ WKRetainPtr<WKStringRef> pictographFontFamilyRef = adoptWK(WKStringCreateWithUTF8CString(pictographFontFamily));
+ WKPreferencesSetPictographFontFamily(priv->preferences.get(), pictographFontFamilyRef.get());
+ priv->pictographFontFamily = WebKit::toImpl(pictographFontFamilyRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "pictograph-font-family");
+}
+
+/**
+ * webkit_settings_get_default_font_size:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:default-font-size property.
+ *
+ * Returns: The default font size.
+ */
+guint32 webkit_settings_get_default_font_size(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return WKPreferencesGetDefaultFontSize(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_default_font_size:
+ * @settings: a #WebKitSettings
+ * @font_size: default font size to be set in pixels
+ *
+ * Set the #WebKitSettings:default-font-size property.
+ */
+void webkit_settings_set_default_font_size(WebKitSettings* settings, guint32 fontSize)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+
+ uint32_t currentSize = WKPreferencesGetDefaultFontSize(priv->preferences.get());
+ if (currentSize == fontSize)
+ return;
+
+ WKPreferencesSetDefaultFontSize(priv->preferences.get(), fontSize);
+ g_object_notify(G_OBJECT(settings), "default-font-size");
+}
+
+/**
+ * webkit_settings_get_default_monospace_font_size:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:default-monospace-font-size property.
+ *
+ * Returns: Default monospace font size.
+ */
+guint32 webkit_settings_get_default_monospace_font_size(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return WKPreferencesGetDefaultFixedFontSize(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_default_monospace_font_size:
+ * @settings: a #WebKitSettings
+ * @font_size: default monospace font size to be set in pixels
+ *
+ * Set the #WebKitSettings:default-monospace-font-size property.
+ */
+void webkit_settings_set_default_monospace_font_size(WebKitSettings* settings, guint32 fontSize)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+
+ uint32_t currentSize = WKPreferencesGetDefaultFixedFontSize(priv->preferences.get());
+ if (currentSize == fontSize)
+ return;
+
+ WKPreferencesSetDefaultFixedFontSize(priv->preferences.get(), fontSize);
+ g_object_notify(G_OBJECT(settings), "default-monospace-font-size");
+}
+
+/**
+ * webkit_settings_get_minimum_font_size:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:minimum-font-size property.
+ *
+ * Returns: Minimum font size.
+ */
+guint32 webkit_settings_get_minimum_font_size(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return WKPreferencesGetMinimumFontSize(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_minimum_font_size:
+ * @settings: a #WebKitSettings
+ * @font_size: minimum font size to be set in points
+ *
+ * Set the #WebKitSettings:minimum-font-size property.
+ */
+void webkit_settings_set_minimum_font_size(WebKitSettings* settings, guint32 fontSize)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+
+ uint32_t currentSize = WKPreferencesGetMinimumFontSize(priv->preferences.get());
+ if (currentSize == fontSize)
+ return;
+
+ WKPreferencesSetMinimumFontSize(priv->preferences.get(), fontSize);
+ g_object_notify(G_OBJECT(settings), "minimum-font-size");
+}
+
+/**
+ * webkit_settings_get_default_charset:
+ * @settings: a #WebKitSettings
+ *
+ * Gets the #WebKitSettings:default-charset property.
+ *
+ * Returns: Default charset.
+ */
+const gchar* webkit_settings_get_default_charset(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), 0);
+
+ return settings->priv->defaultCharset.data();
+}
+
+/**
+ * webkit_settings_set_default_charset:
+ * @settings: a #WebKitSettings
+ * @default_charset: default charset to be set
+ *
+ * Set the #WebKitSettings:default-charset property.
+ */
+void webkit_settings_set_default_charset(WebKitSettings* settings, const gchar* defaultCharset)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+ g_return_if_fail(defaultCharset);
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ if (!g_strcmp0(priv->defaultCharset.data(), defaultCharset))
+ return;
+
+ WKRetainPtr<WKStringRef> defaultCharsetRef = adoptWK(WKStringCreateWithUTF8CString(defaultCharset));
+ WKPreferencesSetDefaultTextEncodingName(priv->preferences.get(), defaultCharsetRef.get());
+ priv->defaultCharset = WebKit::toImpl(defaultCharsetRef.get())->string().utf8();
+
+ g_object_notify(G_OBJECT(settings), "default-charset");
+}
+
+/**
+ * webkit_settings_get_enable_private_browsing:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-private-browsing property.
+ *
+ * Returns: %TRUE If private browsing is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_private_browsing(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetPrivateBrowsingEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_private_caret_browsing:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-private-browsing property.
+ */
+void webkit_settings_set_enable_private_browsing(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetPrivateBrowsingEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetPrivateBrowsingEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-private-browsing");
+}
+
+/**
+ * webkit_settings_get_enable_developer_extras:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-developer-extras property.
+ *
+ * Returns: %TRUE If developer extras is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_developer_extras(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetDeveloperExtrasEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_developer_extras:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-developer-extras property.
+ */
+void webkit_settings_set_enable_developer_extras(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetDeveloperExtrasEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetDeveloperExtrasEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-developer-extras");
+}
+
+/**
+ * webkit_settings_get_enable_resizable_text_areas:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-resizable-text-areas property.
+ *
+ * Returns: %TRUE If text areas can be resized or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_resizable_text_areas(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetTextAreasAreResizable(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_resizable_text_areas:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-resizable-text-areas property.
+ */
+void webkit_settings_set_enable_resizable_text_areas(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetTextAreasAreResizable(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetTextAreasAreResizable(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-resizable-text-areas");
+}
+
+/**
+ * webkit_settings_get_enable_tabs_to_links:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-tabs-to-links property.
+ *
+ * Returns: %TRUE If tabs to link is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_tabs_to_links(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetTabsToLinks(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_tabs_to_links:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-tabs-to-links property.
+ */
+void webkit_settings_set_enable_tabs_to_links(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetTabsToLinks(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetTabsToLinks(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-tabs-to-links");
+}
+
+/**
+ * webkit_settings_get_enable_dns_prefetching:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-dns-prefetching property.
+ *
+ * Returns: %TRUE If DNS prefetching is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_dns_prefetching(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetDNSPrefetchingEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_dns_prefetching:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-dns-prefetching property.
+ */
+void webkit_settings_set_enable_dns_prefetching(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetDNSPrefetchingEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetDNSPrefetchingEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-dns-prefetching");
+}
+
+/**
+ * webkit_settings_get_enable_caret_browsing:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-caret-browsing property.
+ *
+ * Returns: %TRUE If caret browsing is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_caret_browsing(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetCaretBrowsingEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_caret_browsing:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-caret-browsing property.
+ */
+void webkit_settings_set_enable_caret_browsing(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetCaretBrowsingEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetCaretBrowsingEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-caret-browsing");
+}
+
+/**
+ * webkit_settings_get_enable_fullscreen:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-fullscreen property.
+ *
+ * Returns: %TRUE If fullscreen support is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_fullscreen(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetFullScreenEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_fullscreen
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-fullscreen property.
+ */
+void webkit_settings_set_enable_fullscreen(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetFullScreenEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetFullScreenEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-fullscreen");
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
new file mode 100644
index 000000000..8b19a465b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
@@ -0,0 +1,291 @@
+/*
+ * Copyright (c) 2011 Motorola Mobility, 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:
+ *
+ * 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 Motorola Mobility, 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 HOLDER 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitSettings_h
+#define WebKitSettings_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_SETTINGS (webkit_settings_get_type())
+#define WEBKIT_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_SETTINGS, WebKitSettings))
+#define WEBKIT_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_SETTINGS, WebKitSettingsClass))
+#define WEBKIT_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_SETTINGS))
+#define WEBKIT_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_SETTINGS))
+#define WEBKIT_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_SETTINGS, WebKitSettingsClass))
+
+typedef struct _WebKitSettings WebKitSettings;
+typedef struct _WebKitSettingsClass WebKitSettingsClass;
+typedef struct _WebKitSettingsPrivate WebKitSettingsPrivate;
+
+struct _WebKitSettings {
+ GObject parent_instance;
+
+ WebKitSettingsPrivate *priv;
+};
+
+struct _WebKitSettingsClass {
+ GObjectClass parent_class;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+};
+
+WEBKIT_API GType
+webkit_settings_get_type(void);
+
+WEBKIT_API WebKitSettings *
+webkit_settings_new (void);
+
+WEBKIT_API WebKitSettings *
+webkit_settings_new_with_settings (const gchar *first_setting_name,
+ ...);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_javascript (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_javascript (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_auto_load_images (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_auto_load_images (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_load_icons_ignoring_image_load_setting (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_load_icons_ignoring_image_load_setting (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_offline_web_application_cache (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_offline_web_application_cache (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_html5_local_storage (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_html5_local_storage (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_html5_database (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_html5_database (WebKitSettings *settings,
+ gboolean enabled);
+WEBKIT_API gboolean
+webkit_settings_get_enable_xss_auditor (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_xss_auditor (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_frame_flattening (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_frame_flattening (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_plugins (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_plugins (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_java (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_java (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_javascript_can_open_windows_automatically (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_javascript_can_open_windows_automatically (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_hyperlink_auditing (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_hyperlink_auditing (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API const gchar *
+webkit_settings_get_default_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_default_font_family (WebKitSettings *settings,
+ const gchar *default_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_monospace_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_monospace_font_family (WebKitSettings *settings,
+ const gchar *monospace_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_serif_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_serif_font_family (WebKitSettings *settings,
+ const gchar *serif_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_sans_serif_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_sans_serif_font_family (WebKitSettings *settings,
+ const gchar *sans_serif_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_cursive_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_cursive_font_family (WebKitSettings *settings,
+ const gchar *cursive_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_fantasy_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_fantasy_font_family (WebKitSettings *settings,
+ const gchar *fantasy_font_family);
+
+WEBKIT_API const gchar *
+webkit_settings_get_pictograph_font_family (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_pictograph_font_family (WebKitSettings *settings,
+ const gchar *pictograph_font_family);
+
+WEBKIT_API guint32
+webkit_settings_get_default_font_size (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_default_font_size (WebKitSettings *settings,
+ guint32 font_size);
+
+WEBKIT_API guint32
+webkit_settings_get_default_monospace_font_size (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_default_monospace_font_size (WebKitSettings *settings,
+ guint32 font_size);
+
+WEBKIT_API guint32
+webkit_settings_get_minimum_font_size (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_minimum_font_size (WebKitSettings *settings,
+ guint32 font_size);
+
+WEBKIT_API const gchar *
+webkit_settings_get_default_charset (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_default_charset (WebKitSettings *settings,
+ const gchar *default_charset);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_private_browsing (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_private_browsing (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_developer_extras (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_developer_extras (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_resizable_text_areas (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_resizable_text_areas (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_tabs_to_links (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_tabs_to_links (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_dns_prefetching (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_dns_prefetching (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_caret_browsing (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_caret_browsing (WebKitSettings *settings,
+ gboolean enabled);
+
+WEBKIT_API gboolean
+webkit_settings_get_enable_fullscreen (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_fullscreen (WebKitSettings *settings,
+ gboolean enabled);
+
+G_END_DECLS
+
+#endif /* WebKitSettings_h */
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h
new file mode 100644
index 000000000..a47ac7f74
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitSettingsPrivate_h
+#define WebKitSettingsPrivate_h
+
+#include "WebKitSettings.h"
+#include <WebKit2/WebKit2.h>
+
+void webkitSettingsAttachSettingsToPage(WebKitSettings*, WKPageRef);
+
+#endif // WebKitSettingsPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
new file mode 100644
index 000000000..fcfdddb53
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
@@ -0,0 +1,186 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitUIClient.h"
+
+#include "WebKitWebViewPrivate.h"
+#include "WebKitWindowPropertiesPrivate.h"
+#include "WebPageProxy.h"
+#include <WebKit2/WKBase.h>
+
+using namespace WebKit;
+
+G_DEFINE_TYPE(WebKitUIClient, webkit_ui_client, G_TYPE_OBJECT)
+
+static WKPageRef createNewPage(WKPageRef page, WKURLRequestRef, WKDictionaryRef wkWindowFeatures, WKEventModifiers, WKEventMouseButton, const void*)
+{
+ return webkitWebViewCreateNewPage(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), wkWindowFeatures);
+}
+
+static void showPage(WKPageRef page, const void*)
+{
+ webkitWebViewReadyToShowPage(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+}
+
+static void closePage(WKPageRef page, const void*)
+{
+ webkitWebViewClosePage(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+}
+
+static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef, const void*)
+{
+ webkitWebViewRunJavaScriptAlert(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(message)->string().utf8());
+}
+
+static bool runJavaScriptConfirm(WKPageRef page, WKStringRef message, WKFrameRef, const void*)
+{
+ return webkitWebViewRunJavaScriptConfirm(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(message)->string().utf8());
+}
+
+static WKStringRef runJavaScriptPrompt(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void*)
+{
+ return webkitWebViewRunJavaScriptPrompt(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(message)->string().utf8(),
+ toImpl(defaultValue)->string().utf8());
+}
+
+static bool toolbarsAreVisible(WKPageRef page, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ return webkit_window_properties_get_toolbar_visible(windowProperties);
+}
+
+static void setToolbarsAreVisible(WKPageRef page, bool toolbarsVisible, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ webkitWindowPropertiesSetToolbarVisible(windowProperties, toolbarsVisible);
+}
+
+static bool menuBarIsVisible(WKPageRef page, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ return webkit_window_properties_get_menubar_visible(windowProperties);
+}
+
+static void setMenuBarIsVisible(WKPageRef page, bool menuBarVisible, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ webkitWindowPropertiesSetMenubarVisible(windowProperties, menuBarVisible);
+}
+
+static bool statusBarIsVisible(WKPageRef page, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ return webkit_window_properties_get_statusbar_visible(windowProperties);
+}
+
+static void setStatusBarIsVisible(WKPageRef page, bool statusBarVisible, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ webkitWindowPropertiesSetStatusbarVisible(windowProperties, statusBarVisible);
+}
+
+static bool isResizable(WKPageRef page, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ return webkit_window_properties_get_resizable(windowProperties);
+}
+
+static void setIsResizable(WKPageRef page, bool resizable, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ webkitWindowPropertiesSetResizable(windowProperties, resizable);
+}
+
+static WKRect getWindowFrame(WKPageRef page, const void*)
+{
+ GdkRectangle geometry = { 0, 0, 0, 0 };
+ GtkWidget* window = gtk_widget_get_toplevel(toImpl(page)->viewWidget());
+ if (gtk_widget_is_toplevel(window) && gtk_widget_get_visible(window)) {
+ gtk_window_get_position(GTK_WINDOW(window), &geometry.x, &geometry.y);
+ gtk_window_get_size(GTK_WINDOW(window), &geometry.width, &geometry.height);
+ }
+ return WKRectMake(geometry.x, geometry.y, geometry.width, geometry.height);
+}
+
+static void setWindowFrame(WKPageRef page, WKRect frame, const void*)
+{
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+ GdkRectangle geometry = { frame.origin.x, frame.origin.y, frame.size.width, frame.size.height };
+ webkitWindowPropertiesSetGeometry(windowProperties, &geometry);
+}
+
+void webkitUIClientAttachUIClientToPage(WebKitUIClient* uiClient, WKPageRef wkPage)
+{
+ WKPageUIClient wkUIClient = {
+ kWKPageUIClientCurrentVersion,
+ uiClient, // clientInfo
+ 0, // createNewPage_deprecatedForUseWithV0
+ showPage,
+ closePage,
+ 0, // takeFocus
+ 0, // focus
+ 0, // unfocus
+ runJavaScriptAlert,
+ runJavaScriptConfirm,
+ runJavaScriptPrompt,
+ 0, // setStatusText
+ 0, // mouseDidMoveOverElement_deprecatedForUseWithV0
+ 0, // missingPluginButtonClicked
+ 0, // didNotHandleKeyEvent
+ 0, // didNotHandleWheelEvent
+ toolbarsAreVisible,
+ setToolbarsAreVisible,
+ menuBarIsVisible,
+ setMenuBarIsVisible,
+ statusBarIsVisible,
+ setStatusBarIsVisible,
+ isResizable,
+ setIsResizable,
+ getWindowFrame,
+ setWindowFrame,
+ 0, // runBeforeUnloadConfirmPanel
+ 0, // didDraw
+ 0, // pageDidScroll
+ 0, // exceededDatabaseQuota
+ 0, // runOpenPanel
+ 0, // decidePolicyForGeolocationPermissionRequest
+ 0, // headerHeight
+ 0, // footerHeight
+ 0, // drawHeader
+ 0, // drawFooter
+ 0, // printFrame
+ 0, // runModal
+ 0, // didCompleteRubberBandForMainFrame
+ 0, // saveDataToFileInDownloadsFolder
+ 0, // shouldInterruptJavaScript
+ createNewPage,
+ 0, // mouseDidMoveOverElement
+ 0, // decidePolicyForNotificationPermissionRequest
+ };
+ WKPageSetPageUIClient(wkPage, &wkUIClient);
+}
+
+static void webkit_ui_client_init(WebKitUIClient* client)
+{
+}
+
+static void webkit_ui_client_class_init(WebKitUIClientClass* clientClass)
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h
new file mode 100644
index 000000000..41ef3ec25
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitUIClient_h
+#define WebKitUIClient_h
+
+#include <WebKit2/WebKit2.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_UI_CLIENT (webkit_ui_client_get_type())
+#define WEBKIT_UI_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_UI_CLIENT, WebKitUIClient))
+#define WEBKIT_UI_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_UI_CLIENT, WebKitUIClientClass))
+#define WEBKIT_IS_UI_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_UI_CLIENT))
+#define WEBKIT_IS_UI_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_UI_CLIENT))
+#define WEBKIT_UI_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_UI_CLIENT, WebKitUIClientClass))
+
+typedef struct _WebKitUIClient WebKitUIClient;
+typedef struct _WebKitUIClientClass WebKitUIClientClass;
+
+struct _WebKitUIClient {
+ GObject parent;
+};
+
+struct _WebKitUIClientClass {
+ GObjectClass parent_class;
+};
+
+GType webkit_ui_client_get_type (void);
+
+void webkitUIClientAttachUIClientToPage(WebKitUIClient*, WKPageRef);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp
new file mode 100644
index 000000000..154532a83
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitURIRequest.h"
+
+#include "WebKitPrivate.h"
+#include "WebURLRequest.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+enum {
+ PROP_0,
+
+ PROP_URI
+};
+
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitURIRequest, webkit_uri_request, G_TYPE_OBJECT)
+
+struct _WebKitURIRequestPrivate {
+ CString uri;
+};
+
+static void webkitURIRequestFinalize(GObject* object)
+{
+ WEBKIT_URI_REQUEST(object)->priv->~WebKitURIRequestPrivate();
+ G_OBJECT_CLASS(webkit_uri_request_parent_class)->finalize(object);
+}
+
+static void webkitURIRequestGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitURIRequest* request = WEBKIT_URI_REQUEST(object);
+
+ switch (propId) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_uri_request_get_uri(request));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitURIRequestSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitURIRequest* request = WEBKIT_URI_REQUEST(object);
+
+ switch (propId) {
+ case PROP_URI:
+ request->priv->uri = g_value_get_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_uri_request_class_init(WebKitURIRequestClass* requestClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+
+ objectClass->finalize = webkitURIRequestFinalize;
+ objectClass->get_property = webkitURIRequestGetProperty;
+ objectClass->set_property = webkitURIRequestSetProperty;
+
+ /**
+ * WebKitURIRequest:uri:
+ *
+ * The URI to which the request will be made.
+ */
+ g_object_class_install_property(objectClass, PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The URI to which the request will be made."),
+ 0,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ g_type_class_add_private(requestClass, sizeof(WebKitURIRequestPrivate));
+}
+
+static void webkit_uri_request_init(WebKitURIRequest* request)
+{
+ WebKitURIRequestPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_URI_REQUEST, WebKitURIRequestPrivate);
+ request->priv = priv;
+ new (priv) WebKitURIRequestPrivate();
+}
+
+/**
+ * webkit_uri_request_new:
+ * @uri: an URI
+ *
+ * Creates a new #WebKitURIRequest for the given URI.
+ *
+ * Returns: a new #WebKitURIRequest
+ */
+WebKitURIRequest* webkit_uri_request_new(const gchar* uri)
+{
+ g_return_val_if_fail(uri, 0);
+
+ return WEBKIT_URI_REQUEST(g_object_new(WEBKIT_TYPE_URI_REQUEST, "uri", uri, NULL));
+}
+
+/**
+ * webkit_uri_request_get_uri:
+ * @request: a #WebKitURIRequest
+ *
+ * Returns: the uri of the #WebKitURIRequest
+ */
+const gchar* webkit_uri_request_get_uri(WebKitURIRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_REQUEST(request), 0);
+
+ return request->priv->uri.data();
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h
new file mode 100644
index 000000000..5236069b3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitURIRequest_h
+#define WebKitURIRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_URI_REQUEST (webkit_uri_request_get_type())
+#define WEBKIT_URI_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequest))
+#define WEBKIT_IS_URI_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_REQUEST))
+#define WEBKIT_URI_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequestClass))
+#define WEBKIT_IS_URI_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_REQUEST))
+#define WEBKIT_URI_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_REQUEST, WebKitURIRequestClass))
+
+typedef struct _WebKitURIRequest WebKitURIRequest;
+typedef struct _WebKitURIRequestClass WebKitURIRequestClass;
+typedef struct _WebKitURIRequestPrivate WebKitURIRequestPrivate;
+
+struct _WebKitURIRequest {
+ GObject parent;
+
+ /*< private >*/
+ WebKitURIRequestPrivate *priv;
+};
+
+struct _WebKitURIRequestClass {
+ GObjectClass parent_class;
+
+};
+
+WEBKIT_API GType
+webkit_uri_request_get_type (void);
+
+WEBKIT_API WebKitURIRequest *
+webkit_uri_request_new (const gchar *uri);
+
+WEBKIT_API const gchar *
+webkit_uri_request_get_uri (WebKitURIRequest *request);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp
new file mode 100644
index 000000000..2a74cd03a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitURIResponse.h"
+
+#include "WebKitPrivate.h"
+#include "WebKitURIResponsePrivate.h"
+#include "WebURLResponse.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_STATUS_CODE,
+ PROP_CONTENT_LENGTH
+};
+
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitURIResponse, webkit_uri_response, G_TYPE_OBJECT)
+
+struct _WebKitURIResponsePrivate {
+ CString uri;
+ GRefPtr<SoupMessage> message;
+ guint64 contentLength;
+};
+
+static void webkitURIResponseFinalize(GObject* object)
+{
+ WEBKIT_URI_RESPONSE(object)->priv->~WebKitURIResponsePrivate();
+ G_OBJECT_CLASS(webkit_uri_response_parent_class)->finalize(object);
+}
+
+static void webkitURIResponseGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitURIResponse* response = WEBKIT_URI_RESPONSE(object);
+
+ switch (propId) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_uri_response_get_uri(response));
+ break;
+ case PROP_STATUS_CODE:
+ g_value_set_uint(value, webkit_uri_response_get_status_code(response));
+ break;
+ case PROP_CONTENT_LENGTH:
+ g_value_set_uint64(value, webkit_uri_response_get_content_length(response));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitURIResponseSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitURIResponse* response = WEBKIT_URI_RESPONSE(object);
+
+ switch (propId) {
+ case PROP_URI:
+ response->priv->uri = g_value_get_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_uri_response_class_init(WebKitURIResponseClass* responseClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(responseClass);
+
+ objectClass->finalize = webkitURIResponseFinalize;
+ objectClass->get_property = webkitURIResponseGetProperty;
+ objectClass->set_property = webkitURIResponseSetProperty;
+
+ /**
+ * WebKitURIResponse:uri:
+ *
+ * The URI for which the response was made.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The URI for which the response was made."),
+ 0,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+ /**
+ * WebKitURIResponse:status-code:
+ *
+ * The status code of the response as returned by the server.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_STATUS_CODE,
+ g_param_spec_uint("status-code",
+ _("Status Code"),
+ _("The status code of the response as returned by the server."),
+ 0, G_MAXUINT, SOUP_STATUS_NONE,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitURIResponse:content-length:
+ *
+ * The expected content length of the response.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_CONTENT_LENGTH,
+ g_param_spec_uint64("content-length",
+ _("Content Length"),
+ _("The expected content length of the response."),
+ 0, G_MAXUINT64, 0,
+ WEBKIT_PARAM_READABLE));
+
+ g_type_class_add_private(responseClass, sizeof(WebKitURIResponsePrivate));
+}
+
+static void webkit_uri_response_init(WebKitURIResponse* response)
+{
+ WebKitURIResponsePrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(response, WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponsePrivate);
+ response->priv = priv;
+ new (priv) WebKitURIResponsePrivate();
+}
+
+/**
+ * webkit_uri_response_get_uri:
+ * @response: a #WebKitURIResponse
+ *
+ * Returns: the uri of the #WebKitURIResponse
+ */
+const gchar* webkit_uri_response_get_uri(WebKitURIResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0);
+
+ return response->priv->uri.data();
+}
+
+/**
+ * webkit_uri_response_get_status_code:
+ * @response: a #WebKitURIResponse
+ *
+ * Get the status code of the #WebKitURIResponse as returned by
+ * the server. It will normally be a #SoupKnownStatusCode, for
+ * example %SOUP_STATUS_OK, though the server can respond with any
+ * unsigned integer.
+ *
+ * Returns: the status code of @response
+ */
+guint webkit_uri_response_get_status_code(WebKitURIResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), SOUP_STATUS_NONE);
+
+ if (!response->priv->message)
+ return SOUP_STATUS_NONE;
+
+ return response->priv->message->status_code;
+}
+
+/**
+ * webkit_uri_response_get_content_length:
+ * @response: a #WebKitURIResponse
+ *
+ * Get the expected content length of the #WebKitURIResponse. It can
+ * be 0 if the server provided an incorrect or missing Content-Length.
+ *
+ * Returns: the expected content length of @response.
+ */
+guint64 webkit_uri_response_get_content_length(WebKitURIResponse* response)
+{
+ g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), 0);
+
+ if (response->priv->contentLength)
+ return response->priv->contentLength;
+
+ if (!response->priv->message)
+ return 0;
+
+ SoupMessage* message = response->priv->message.get();
+ return static_cast<guint64>(soup_message_headers_get_content_length(message->response_headers));
+}
+
+WebKitURIResponse* webkitURIResponseCreateForSoupMessage(SoupMessage* message)
+{
+ GOwnPtr<char> uri(soup_uri_to_string(soup_message_get_uri(message), FALSE));
+ WebKitURIResponse* response = WEBKIT_URI_RESPONSE(g_object_new(WEBKIT_TYPE_URI_RESPONSE, "uri", uri.get(), NULL));
+ response->priv->message = message;
+ return response;
+}
+
+SoupMessage* webkitURIResponseGetSoupMessage(WebKitURIResponse* response)
+{
+ return response->priv->message.get();
+}
+
+void webkitURIResponseSetContentLength(WebKitURIResponse* response, guint64 contentLength)
+{
+ response->priv->contentLength = contentLength;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h
new file mode 100644
index 000000000..cfbe4d819
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitURIResponse_h
+#define WebKitURIResponse_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_URI_RESPONSE (webkit_uri_response_get_type())
+#define WEBKIT_URI_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponse))
+#define WEBKIT_IS_URI_RESPONSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_RESPONSE))
+#define WEBKIT_URI_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponseClass))
+#define WEBKIT_IS_URI_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_URI_RESPONSE))
+#define WEBKIT_URI_RESPONSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_URI_RESPONSE, WebKitURIResponseClass))
+
+typedef struct _WebKitURIResponse WebKitURIResponse;
+typedef struct _WebKitURIResponseClass WebKitURIResponseClass;
+typedef struct _WebKitURIResponsePrivate WebKitURIResponsePrivate;
+
+struct _WebKitURIResponse {
+ GObject parent;
+
+ /*< private >*/
+ WebKitURIResponsePrivate *priv;
+};
+
+struct _WebKitURIResponseClass {
+ GObjectClass parent_class;
+
+};
+
+WEBKIT_API GType
+webkit_uri_response_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_uri_response_get_uri (WebKitURIResponse *response);
+
+WEBKIT_API guint
+webkit_uri_response_get_status_code (WebKitURIResponse *response);
+
+WEBKIT_API guint64
+webkit_uri_response_get_content_length (WebKitURIResponse *response);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h
new file mode 100644
index 000000000..fe84f8b1c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponsePrivate.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitURIResponsePrivate_h
+#define WebKitURIResponsePrivate_h
+
+#include "WebKitURIResponse.h"
+#include <libsoup/soup.h>
+
+WebKitURIResponse* webkitURIResponseCreateForSoupMessage(SoupMessage*);
+SoupMessage* webkitURIResponseGetSoupMessage(WebKitURIResponse*);
+void webkitURIResponseSetContentLength(WebKitURIResponse*, guint64 contentLength);
+
+#endif // WebKitURIResponsePrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
new file mode 100644
index 000000000..1f9590c52
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitWebContext.h"
+
+#include "WebKitWebContextPrivate.h"
+#include <WebKit2/WKContext.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKType.h>
+
+struct _WebKitWebContextPrivate {
+ WKRetainPtr<WKContextRef> context;
+};
+
+G_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
+
+static void webkitWebContextFinalize(GObject* object)
+{
+ WEBKIT_WEB_CONTEXT(object)->priv->~WebKitWebContextPrivate();
+ G_OBJECT_CLASS(webkit_web_context_parent_class)->finalize(object);
+}
+
+static void webkit_web_context_init(WebKitWebContext* webContext)
+{
+ WebKitWebContextPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(webContext, WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextPrivate);
+ webContext->priv = priv;
+ new (priv) WebKitWebContextPrivate();
+}
+
+static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(webContextClass);
+ gObjectClass->finalize = webkitWebContextFinalize;
+
+ g_type_class_add_private(webContextClass, sizeof(WebKitWebContextPrivate));
+}
+
+
+static gpointer createDefaultWebContext(gpointer)
+{
+ WebKitWebContext* webContext = WEBKIT_WEB_CONTEXT(g_object_new(WEBKIT_TYPE_WEB_CONTEXT, NULL));
+ webContext->priv->context = WKContextGetSharedProcessContext();
+ WKContextSetCacheModel(webContext->priv->context.get(), kWKCacheModelPrimaryWebBrowser);
+ return webContext;
+}
+
+/**
+ * webkit_web_context_get_default:
+ *
+ * Gets the default web context
+ *
+ * Returns: (transfer none) a #WebKitWebContext
+ */
+WebKitWebContext* webkit_web_context_get_default(void)
+{
+ static GOnce onceInit = G_ONCE_INIT;
+ return WEBKIT_WEB_CONTEXT(g_once(&onceInit, createDefaultWebContext, 0));
+}
+
+/**
+ * webkit_web_context_set_cache_model:
+ * @context: the #WebKitWebContext
+ * @cache_model: a #WebKitCacheModel
+ *
+ * Specifies a usage model for WebViews, which WebKit will use to
+ * determine its caching behavior. All web views follow the cache
+ * model. This cache model determines the RAM and disk space to use
+ * for caching previously viewed content .
+ *
+ * Research indicates that users tend to browse within clusters of
+ * documents that hold resources in common, and to revisit previously
+ * visited documents. WebKit and the frameworks below it include
+ * built-in caches that take advantage of these patterns,
+ * substantially improving document load speed in browsing
+ * situations. The WebKit cache model controls the behaviors of all of
+ * these caches, including various WebCore caches.
+ *
+ * Browsers can improve document load speed substantially by
+ * specifying WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a
+ * browsing interface can reduce memory usage substantially by
+ * specifying WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. The default value is
+ * WEBKIT_CACHE_MODEL_WEB_BROWSER.
+ *
+ */
+void webkit_web_context_set_cache_model(WebKitWebContext* context, WebKitCacheModel model)
+{
+ WKCacheModel cacheModel;
+
+ g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+ switch (model) {
+ case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER:
+ cacheModel = kWKCacheModelDocumentViewer;
+ break;
+ case WEBKIT_CACHE_MODEL_WEB_BROWSER:
+ cacheModel = kWKCacheModelPrimaryWebBrowser;
+ break;
+ case WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER:
+ cacheModel = kWKCacheModelDocumentBrowser;
+ break;
+ default:
+ g_assert_not_reached();
+ }
+ WebKitWebContextPrivate* priv = context->priv;
+ if (cacheModel != WKContextGetCacheModel(priv->context.get()))
+ WKContextSetCacheModel(priv->context.get(), cacheModel);
+}
+
+/**
+ * webkit_web_context_get_cache_model:
+ * @context: the #WebKitWebContext
+ *
+ * Returns the current cache model. For more information about this
+ * value check the documentation of the function
+ * webkit_web_context_set_cache_model().
+ *
+ * Returns: the current #WebKitCacheModel
+ */
+WebKitCacheModel webkit_web_context_get_cache_model(WebKitWebContext* context)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_CACHE_MODEL_WEB_BROWSER);
+
+ WebKitWebContextPrivate* priv = context->priv;
+ switch (WKContextGetCacheModel(priv->context.get())) {
+ case kWKCacheModelDocumentViewer:
+ return WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER;
+ case kWKCacheModelPrimaryWebBrowser:
+ return WEBKIT_CACHE_MODEL_WEB_BROWSER;
+ case kWKCacheModelDocumentBrowser:
+ return WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER;
+ default:
+ g_assert_not_reached();
+ }
+
+ return WEBKIT_CACHE_MODEL_WEB_BROWSER;
+}
+
+WKContextRef webkitWebContextGetWKContext(WebKitWebContext* context)
+{
+ g_assert(WEBKIT_IS_WEB_CONTEXT(context));
+
+ return context->priv->context.get();
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
new file mode 100644
index 000000000..2f38dbc25
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitWebContext_h
+#define WebKitWebContext_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_CONTEXT (webkit_web_context_get_type())
+#define WEBKIT_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContext))
+#define WEBKIT_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass))
+#define WEBKIT_IS_WEB_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_CONTEXT))
+#define WEBKIT_IS_WEB_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_CONTEXT))
+#define WEBKIT_WEB_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_CONTEXT, WebKitWebContextClass))
+
+/**
+ * WebKitCacheModel:
+ * @WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER: Disable the cache completely, which
+ * substantially reduces memory usage. Useful for applications that only
+ * access a single local file, with no navigation to other pages. No remote
+ * resources will be cached.
+ * @WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER: A cache model optimized for viewing
+ * a series of local files -- for example, a documentation viewer or a website
+ * designer. WebKit will cache a moderate number of resources.
+ * @WEBKIT_CACHE_MODEL_WEB_BROWSER: Improve document load speed substantially
+ * by caching a very large number of resources and previously viewed content.
+ *
+ * Enum values used for determining the webview cache model.
+ */
+typedef enum {
+ WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER,
+ WEBKIT_CACHE_MODEL_WEB_BROWSER,
+ WEBKIT_CACHE_MODEL_DOCUMENT_BROWSER
+} WebKitCacheModel;
+
+typedef struct _WebKitWebContext WebKitWebContext;
+typedef struct _WebKitWebContextClass WebKitWebContextClass;
+typedef struct _WebKitWebContextPrivate WebKitWebContextPrivate;
+
+struct _WebKitWebContext {
+ GObject parent;
+
+ /*< private >*/
+ WebKitWebContextPrivate *priv;
+};
+
+struct _WebKitWebContextClass {
+ GObjectClass parent;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_context_get_type (void);
+
+WEBKIT_API WebKitWebContext *
+webkit_web_context_get_default (void);
+
+WEBKIT_API void
+webkit_web_context_set_cache_model (WebKitWebContext *context,
+ WebKitCacheModel cache_model);
+WEBKIT_API WebKitCacheModel
+webkit_web_context_get_cache_model (WebKitWebContext *context);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
new file mode 100644
index 000000000..86d7dec8b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContextPrivate.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitWebContextPrivate_h
+#define WebKitWebContextPrivate_h
+
+#include "WebKitWebContext.h"
+#include <WebKit2/WebKit2.h>
+
+G_BEGIN_DECLS
+
+WKContextRef webkitWebContextGetWKContext(WebKitWebContext*);
+
+G_END_DECLS
+
+#endif // WebKitWebContextPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp
new file mode 100644
index 000000000..d27560f53
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.cpp
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitWebLoaderClient.h"
+
+#include "WebKitBackForwardListPrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitWebLoaderClient, webkit_web_loader_client, G_TYPE_OBJECT)
+
+static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_STARTED);
+}
+
+static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_REDIRECTED);
+}
+
+static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ const ResourceError& resourceError = toImpl(error)->platformError();
+ GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
+ resourceError.errorCode(),
+ resourceError.localizedDescription().utf8().data()));
+ webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_STARTED,
+ resourceError.failingURL().utf8().data(), webError.get());
+}
+
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_COMMITTED);
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ webkitWebViewLoadChanged(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_FINISHED);
+}
+
+static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ const ResourceError& resourceError = toImpl(error)->platformError();
+ GOwnPtr<GError> webError(g_error_new_literal(g_quark_from_string(resourceError.domain().utf8().data()),
+ resourceError.errorCode(),
+ resourceError.localizedDescription().utf8().data()));
+ webkitWebViewLoadFailed(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), WEBKIT_LOAD_COMMITTED,
+ resourceError.failingURL().utf8().data(), webError.get());
+}
+
+static void didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType, WKTypeRef, const void*)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ webkitWebViewUpdateURI(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()));
+}
+
+static void didReceiveTitleForFrame(WKPageRef page, WKStringRef titleRef, WKFrameRef frameRef, WKTypeRef, const void*)
+{
+ if (!WKFrameIsMainFrame(frameRef))
+ return;
+
+ webkitWebViewSetTitle(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), toImpl(titleRef)->string().utf8());
+}
+
+static void didChangeProgress(WKPageRef page, const void* clientInfo)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(toImpl(page)->viewWidget());
+ webkitWebViewSetEstimatedLoadProgress(webView, WKPageGetEstimatedProgress(page));
+}
+
+static void didChangeBackForwardList(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void* clientInfo)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(toImpl(page)->viewWidget());
+ webkitBackForwardListChanged(webkit_web_view_get_back_forward_list(webView), addedItem, removedItems);
+}
+
+void webkitWebLoaderClientAttachLoaderClientToPage(WebKitWebLoaderClient* loaderClient, WKPageRef wkPage)
+{
+ WKPageLoaderClient wkLoaderClient = {
+ kWKPageLoaderClientCurrentVersion,
+ loaderClient, // clientInfo
+ didStartProvisionalLoadForFrame,
+ didReceiveServerRedirectForProvisionalLoadForFrame,
+ didFailProvisionalLoadWithErrorForFrame,
+ didCommitLoadForFrame,
+ 0, // didFinishDocumentLoadForFrame
+ didFinishLoadForFrame,
+ didFailLoadWithErrorForFrame,
+ didSameDocumentNavigationForFrame,
+ didReceiveTitleForFrame,
+ 0, // didFirstLayoutForFrame
+ 0, // didFirstVisuallyNonEmptyLayoutForFrame
+ 0, // didRemoveFrameFromHierarchy
+ 0, // didDisplayInsecureContentForFrame
+ 0, // didRunInsecureContentForFrame
+ 0, // canAuthenticateAgainstProtectionSpaceInFrame
+ 0, // didReceiveAuthenticationChallengeInFrame
+ didChangeProgress, // didStartProgress
+ didChangeProgress,
+ didChangeProgress, // didFinishProgress
+ 0, // didBecomeUnresponsive
+ 0, // didBecomeResponsive
+ 0, // processDidCrash
+ didChangeBackForwardList,
+ 0, // shouldGoToBackForwardListItem
+ 0, // didFailToInitializePlugin
+ 0 // didDetectXSSForFrame
+ };
+ WKPageSetPageLoaderClient(wkPage, &wkLoaderClient);
+}
+
+static void webkit_web_loader_client_init(WebKitWebLoaderClient*)
+{
+}
+
+static void webkit_web_loader_client_class_init(WebKitWebLoaderClientClass*)
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.h
new file mode 100644
index 000000000..c6044bc07
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebLoaderClient.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitWebLoaderClient_h
+#define WebKitWebLoaderClient_h
+
+#include <glib-object.h>
+#include <WebKit2/WebKit2.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_LOADER_CLIENT (webkit_web_loader_client_get_type())
+#define WEBKIT_WEB_LOADER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_LOADER_CLIENT, WebKitWebLoaderClient))
+#define WEBKIT_WEB_LOADER_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_LOADER_CLIENT, WebKitWebLoaderClientClass))
+#define WEBKIT_IS_WEB_LOADER_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_LOADER_CLIENT))
+#define WEBKIT_IS_WEB_LOADER_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_LOADER_CLIENT))
+#define WEBKIT_WEB_LOADER_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_LOADER_CLIENT, WebKitWebLoaderClientClass))
+
+typedef struct _WebKitWebLoaderClient WebKitWebLoaderClient;
+typedef struct _WebKitWebLoaderClientClass WebKitWebLoaderClientClass;
+
+struct _WebKitWebLoaderClient {
+ GObject parent;
+};
+
+struct _WebKitWebLoaderClientClass {
+ GObjectClass parentClass;
+};
+
+GType webkit_web_loader_client_get_type (void);
+void webkitWebLoaderClientAttachLoaderClientToPage(WebKitWebLoaderClient*, WKPageRef);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
new file mode 100644
index 000000000..fd2bb5190
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -0,0 +1,1207 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitWebView.h"
+
+#include "WebKitBackForwardListPrivate.h"
+#include "WebKitEnumTypes.h"
+#include "WebKitError.h"
+#include "WebKitMarshal.h"
+#include "WebKitSettingsPrivate.h"
+#include "WebKitUIClient.h"
+#include "WebKitWebContextPrivate.h"
+#include "WebKitWebLoaderClient.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebKitWebViewPrivate.h"
+#include "WebKitWindowPropertiesPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebPageProxy.h"
+#include <WebCore/DragIcon.h>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKURL.h>
+#include <glib/gi18n-lib.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+enum {
+ LOAD_CHANGED,
+ LOAD_FAILED,
+
+ CREATE,
+ READY_TO_SHOW,
+ CLOSE,
+
+ SCRIPT_ALERT,
+ SCRIPT_CONFIRM,
+ SCRIPT_PROMPT,
+
+ LAST_SIGNAL
+};
+
+enum {
+ PROP_0,
+
+ PROP_WEB_CONTEXT,
+ PROP_TITLE,
+ PROP_ESTIMATED_LOAD_PROGRESS,
+ PROP_URI,
+ PROP_ZOOM_LEVEL
+};
+
+struct _WebKitWebViewPrivate {
+ WebKitWebContext* context;
+ CString title;
+ CString customTextEncoding;
+ double estimatedLoadProgress;
+ CString activeURI;
+ bool replacingContent;
+
+ GRefPtr<WebKitWebLoaderClient> loaderClient;
+ GRefPtr<WebKitUIClient> uiClient;
+ GRefPtr<WebKitBackForwardList> backForwardList;
+ GRefPtr<WebKitSettings> settings;
+ GRefPtr<WebKitWindowProperties> windowProperties;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE)
+
+static gboolean webkitWebViewLoadFail(WebKitWebView* webView, WebKitLoadEvent, const char* failingURI, GError* error)
+{
+ if (g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED)
+ || g_error_matches(error, WEBKIT_POLICY_ERROR, WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE)
+ || g_error_matches(error, WEBKIT_PLUGIN_ERROR, WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD))
+ return FALSE;
+
+ GOwnPtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message));
+ webkit_web_view_replace_content(webView, htmlString.get(), failingURI, 0);
+
+ return TRUE;
+}
+
+static GtkWidget* webkitWebViewCreate(WebKitWebView*)
+{
+ return 0;
+}
+
+static GtkWidget* webkitWebViewCreateJavaScriptDialog(WebKitWebView* webView, GtkMessageType type, GtkButtonsType buttons, int defaultResponse, const char* message)
+{
+ GtkWidget* parent = gtk_widget_get_toplevel(GTK_WIDGET(webView));
+ GtkWidget* dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(parent) ? GTK_WINDOW(parent) : 0,
+ GTK_DIALOG_DESTROY_WITH_PARENT, type, buttons, "%s", message);
+ GOwnPtr<char> title(g_strdup_printf("JavaScript - %s", webkit_web_view_get_uri(webView)));
+ gtk_window_set_title(GTK_WINDOW(dialog), title.get());
+ gtk_dialog_set_default_response(GTK_DIALOG(dialog), defaultResponse);
+
+ return dialog;
+}
+
+static gboolean webkitWebViewScriptAlert(WebKitWebView* webView, const char* message)
+{
+ GtkWidget* dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_WARNING, GTK_BUTTONS_CLOSE, GTK_RESPONSE_CLOSE, message);
+ gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ return TRUE;
+}
+
+static gboolean webkitWebViewScriptConfirm(WebKitWebView* webView, const char* message, gboolean* confirmed)
+{
+ GtkWidget* dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, message);
+ *confirmed = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK;
+ gtk_widget_destroy(dialog);
+ return TRUE;
+}
+
+static gboolean webkitWebViewScriptPrompt(WebKitWebView* webView, const char* message, const char* defaultText, char** text)
+{
+ GtkWidget* dialog = webkitWebViewCreateJavaScriptDialog(webView, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, GTK_RESPONSE_OK, message);
+ GtkWidget* entry = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(entry), defaultText);
+ gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry);
+ gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
+ gtk_widget_show(entry);
+
+ *text = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) ? g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))) : 0;
+ return TRUE;
+}
+
+static void webkitWebViewSetLoaderClient(WebKitWebView* webView, WebKitWebLoaderClient* loaderClient, WKPageRef wkPage)
+{
+ webView->priv->loaderClient = loaderClient;
+ webkitWebLoaderClientAttachLoaderClientToPage(loaderClient, wkPage);
+}
+
+static void webkitWebViewConstructed(GObject* object)
+{
+ if (G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed)
+ G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
+
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
+ WebKitWebViewPrivate* priv = webView->priv;
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
+
+ webkitWebViewBaseCreateWebPage(webViewBase, webkitWebContextGetWKContext(priv->context), 0);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
+
+ static GRefPtr<WebKitWebLoaderClient> defaultLoaderClient = adoptGRef(WEBKIT_WEB_LOADER_CLIENT(g_object_new(WEBKIT_TYPE_WEB_LOADER_CLIENT, NULL)));
+ webkitWebViewSetLoaderClient(webView, defaultLoaderClient.get(), toAPI(page));
+
+ static GRefPtr<WebKitUIClient> defaultUIClient = adoptGRef(WEBKIT_UI_CLIENT(g_object_new(WEBKIT_TYPE_UI_CLIENT, NULL)));
+ priv->uiClient = defaultUIClient.get();
+ webkitUIClientAttachUIClientToPage(priv->uiClient.get(), toAPI(page));
+
+ priv->backForwardList = adoptGRef(webkitBackForwardListCreate(WKPageGetBackForwardList(toAPI(page))));
+ priv->settings = adoptGRef(webkit_settings_new());
+ webkitSettingsAttachSettingsToPage(priv->settings.get(), toAPI(page));
+}
+
+static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
+
+ switch (propId) {
+ case PROP_WEB_CONTEXT:
+ webView->priv->context = WEBKIT_WEB_CONTEXT(g_value_get_object(value));
+ break;
+ case PROP_ZOOM_LEVEL:
+ webkit_web_view_set_zoom_level(webView, g_value_get_double(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
+
+ switch (propId) {
+ case PROP_WEB_CONTEXT:
+ g_value_take_object(value, webView->priv->context);
+ break;
+ case PROP_TITLE:
+ g_value_set_string(value, webView->priv->title.data());
+ break;
+ case PROP_ESTIMATED_LOAD_PROGRESS:
+ g_value_set_double(value, webkit_web_view_get_estimated_load_progress(webView));
+ break;
+ case PROP_URI:
+ g_value_set_string(value, webkit_web_view_get_uri(webView));
+ break;
+ case PROP_ZOOM_LEVEL:
+ g_value_set_double(value, webkit_web_view_get_zoom_level(webView));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitWebViewFinalize(GObject* object)
+{
+ WEBKIT_WEB_VIEW(object)->priv->~WebKitWebViewPrivate();
+ G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
+}
+
+static void webkit_web_view_init(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(webView, WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate);
+ webView->priv = priv;
+ new (priv) WebKitWebViewPrivate();
+
+ webView->priv->windowProperties = adoptGRef(webkitWindowPropertiesCreate());
+}
+
+static gboolean webkitWebViewAccumulatorObjectHandled(GSignalInvocationHint*, GValue* returnValue, const GValue* handlerReturn, gpointer)
+{
+ void* object = g_value_get_object(handlerReturn);
+ if (object)
+ g_value_set_object(returnValue, object);
+
+ return !object;
+}
+
+static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(webViewClass);
+
+ gObjectClass->constructed = webkitWebViewConstructed;
+ gObjectClass->set_property = webkitWebViewSetProperty;
+ gObjectClass->get_property = webkitWebViewGetProperty;
+ gObjectClass->finalize = webkitWebViewFinalize;
+
+ webViewClass->load_failed = webkitWebViewLoadFail;
+ webViewClass->create = webkitWebViewCreate;
+ webViewClass->script_alert = webkitWebViewScriptAlert;
+ webViewClass->script_confirm = webkitWebViewScriptConfirm;
+ webViewClass->script_prompt = webkitWebViewScriptPrompt;
+
+ g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
+
+ /**
+ * WebKitWebView:web-context:
+ *
+ * The #WebKitWebContext of the view.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_WEB_CONTEXT,
+ g_param_spec_object("web-context",
+ _("Web Context"),
+ _("The web context for the view"),
+ WEBKIT_TYPE_WEB_CONTEXT,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitWebView:title:
+ *
+ * The main frame document title of this #WebKitWebView. If
+ * the title has not been received yet, it will be %NULL.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_TITLE,
+ g_param_spec_string("title",
+ _("Title"),
+ _("Main frame document title"),
+ 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebView:estimated-load-progress:
+ *
+ * An estimate of the percent completion for the current loading operation.
+ * This value will range from 0.0 to 1.0 and, once a load completes,
+ * will remain at 1.0 until a new load starts, at which point it
+ * will be reset to 0.0.
+ * The value is an estimate based on the total number of bytes expected
+ * to be received for a document, including all its possible subresources
+ * and child documents.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ESTIMATED_LOAD_PROGRESS,
+ g_param_spec_double("estimated-load-progress",
+ _("Estimated Load Progress"),
+ _("An estimate of the percent completion for a document load"),
+ 0.0, 1.0, 0.0,
+ WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebView:uri:
+ *
+ * The current active URI of the #WebKitWebView.
+ * See webkit_web_view_get_uri() for more details.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The current active URI of the view"),
+ 0,
+ WEBKIT_PARAM_READABLE));
+
+ /**
+ * WebKitWebView::load-changed:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @load_event: the #WebKitLoadEvent
+ *
+ * Emitted when the a load operation in @web_view changes.
+ * The signal is always emitted with %WEBKIT_LOAD_STARTED when a
+ * new load request is made and %WEBKIT_LOAD_FINISHED when the load
+ * finishes successfully or due to an error. When the ongoing load
+ * operation fails #WebKitWebView::load-failed signal is emitted
+ * before #WebKitWebView::load-changed is emitted with
+ * %WEBKIT_LOAD_FINISHED.
+ * If a redirection is received from the server, this signal is emitted
+ * with %WEBKIT_LOAD_REDIRECTED after the initial emission with
+ * %WEBKIT_LOAD_STARTED and before %WEBKIT_LOAD_COMMITTED.
+ * When the page content starts arriving the signal is emitted with
+ * %WEBKIT_LOAD_COMMITTED event.
+ *
+ * You can handle this signal and use a switch to track any ongoing
+ * load operation.
+ *
+ * <informalexample><programlisting>
+ * static void web_view_load_changed (WebKitWebView *web_view,
+ * WebKitLoadEvent load_event,
+ * gpointer user_data)
+ * {
+ * switch (load_event) {
+ * case WEBKIT_LOAD_STARTED:
+ * /<!-- -->* New load, we have now a provisional URI *<!-- -->/
+ * provisional_uri = webkit_web_view_get_uri (web_view);
+ * /<!-- -->* Here we could start a spinner or update the
+ * <!-- -->* location bar with the provisional URI *<!-- -->/
+ * break;
+ * case WEBKIT_LOAD_REDIRECTED:
+ * redirected_uri = webkit_web_view_get_uri (web_view);
+ * break;
+ * case WEBKIT_LOAD_COMMITTED:
+ * /<!-- -->* The load is being performed. Current URI is
+ * <!-- -->* the final one and it won't change unless a new
+ * <!-- -->* load is requested or a navigation within the
+ * <!-- -->* same page is performed *<!-- -->/
+ * uri = webkit_web_view_get_uri (web_view);
+ * break;
+ * case WEBKIT_LOAD_FINISHED:
+ * /<!-- -->* Load finished, we can now stop the spinner *<!-- -->/
+ * break;
+ * }
+ * }
+ * </programlisting></informalexample>
+ */
+ signals[LOAD_CHANGED] =
+ g_signal_new("load-changed",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, load_changed),
+ 0, 0,
+ g_cclosure_marshal_VOID__ENUM,
+ G_TYPE_NONE, 1,
+ WEBKIT_TYPE_LOAD_EVENT);
+
+ /**
+ * WebKitWebView::load-failed:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @load_event: the #WebKitLoadEvent of the load operation
+ * @failing_uri: the URI that failed to load
+ * @error: the #GError that was triggered
+ *
+ * Emitted when an error occurs during a load operation.
+ * If the error happened when starting to load data for a page
+ * @load_event will be %WEBKIT_LOAD_STARTED. If it happened while
+ * loading a committed data source @load_event will be %WEBKIT_LOAD_COMMITTED.
+ * Since a load error causes the load operation to finish, the signal
+ * WebKitWebView::load-changed will always be emitted with
+ * %WEBKIT_LOAD_FINISHED event right after this one.
+ *
+ * By default, if the signal is not handled, a stock error page will be displayed.
+ * You need to handle the signal if you want to provide your own error page.
+ */
+ signals[LOAD_FAILED] =
+ g_signal_new("load-failed",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, load_failed),
+ g_signal_accumulator_true_handled, 0,
+ webkit_marshal_BOOLEAN__ENUM_STRING_POINTER,
+ G_TYPE_BOOLEAN, 3,
+ WEBKIT_TYPE_LOAD_EVENT,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+
+ /**
+ * WebKitWebView:zoom-level:
+ *
+ * The zoom level of the #WebKitWebView content.
+ * See webkit_web_view_set_zoom_level() for more details.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ZOOM_LEVEL,
+ g_param_spec_double("zoom-level",
+ "Zoom level",
+ "The zoom level of the view content",
+ 0, G_MAXDOUBLE, 1,
+ WEBKIT_PARAM_READWRITE));
+
+ /**
+ * WebKitWebView::create:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ *
+ * Emitted when the creation of a new #WebKitWebView is requested.
+ * If this signal is handled the signal handler should return the
+ * newly created #WebKitWebView.
+ *
+ * The new #WebKitWebView should not be displayed to the user
+ * until the #WebKitWebView::ready-to-show signal is emitted.
+ *
+ * Returns: (transfer full): a newly allocated #WebKitWebView widget
+ * or %NULL to propagate the event further.
+ */
+ signals[CREATE] =
+ g_signal_new("create",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, create),
+ webkitWebViewAccumulatorObjectHandled, 0,
+ webkit_marshal_OBJECT__VOID,
+ GTK_TYPE_WIDGET, 0);
+
+ /**
+ * WebKitWebView::ready-to-show:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ *
+ * Emitted after #WebKitWebView::create on the newly created #WebKitWebView
+ * when it should be displayed to the user. When this signal is emitted
+ * all the information about how the window should look, including
+ * size, position, whether the location, status and scrollbars
+ * should be displayed, is already set on the #WebKitWindowProperties
+ * of @web_view. See also webkit_web_view_get_window_properties().
+ */
+ signals[READY_TO_SHOW] =
+ g_signal_new("ready-to-show",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, ready_to_show),
+ 0, 0,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::close:
+ * @webView: the #WebKitWebView on which the signal is emitted
+ *
+ * Emitted when closing a #WebKitWebView is requested. This occurs when a
+ * call is made from JavaScript's <function>window.close</function> function.
+ * It is the owner's responsibility to handle this signal to hide or
+ * destroy the #WebKitWebView, if necessary.
+ */
+ signals[CLOSE] =
+ g_signal_new("close",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, close),
+ 0, 0,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ /**
+ * WebKitWebView::script-alert:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @message: the message text
+ *
+ * Emitted when JavaScript code calls <function>window.alert</function>. If the
+ * signal is not handled a message dialog with a single Close button will be
+ * shown with the message text.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
+ signals[SCRIPT_ALERT] =
+ g_signal_new("script-alert",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
+ g_signal_accumulator_true_handled, 0,
+ webkit_marshal_BOOLEAN__STRING,
+ G_TYPE_BOOLEAN, 1,
+ G_TYPE_STRING);
+
+ /**
+ * WebKitWebView::script-confirm:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @message: the message text
+ * @confirmed: (out): return location for confirm dialog response
+ *
+ * Emitted when JavaScript code calls <function>confirm</function>. If the
+ * signal is not handled a message dialog with OK and Cancel buttons will be
+ * shown with the message text. If OK button is clicked @confirmed will be
+ * set to %TRUE, otherwise it will be %FALSE.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
+ signals[SCRIPT_CONFIRM] =
+ g_signal_new("script-confirm",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
+ g_signal_accumulator_true_handled, 0,
+ webkit_marshal_BOOLEAN__STRING_POINTER,
+ G_TYPE_BOOLEAN, 2,
+ G_TYPE_STRING, G_TYPE_POINTER);
+
+ /**
+ * WebKitWebView::script-prompt:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @message: the message text
+ * @default (allow-none): the default text
+ * @text: (out): return location for prompt dialog text response
+ *
+ * Emitted when JavaScript code calls <function>prompt</function>. If the
+ * signal is not handled a message dialog with OK and Cancel buttons and
+ * a text entry will be shown with the message text. If OK button is clicked
+ * @text will contain the text entered by the user, otherwise it will be %NULL.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
+ signals[SCRIPT_PROMPT] =
+ g_signal_new("script-prompt",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
+ g_signal_accumulator_true_handled, 0,
+ webkit_marshal_BOOLEAN__STRING_STRING_POINTER,
+ G_TYPE_BOOLEAN, 3,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);
+
+}
+
+void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
+{
+ if (webView->priv->replacingContent) {
+ if (loadEvent == WEBKIT_LOAD_FINISHED)
+ webView->priv->replacingContent = false;
+ return;
+ }
+
+ if (loadEvent != WEBKIT_LOAD_FINISHED)
+ webkitWebViewUpdateURI(webView);
+ g_signal_emit(webView, signals[LOAD_CHANGED], 0, loadEvent);
+}
+
+void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error)
+{
+ if (webView->priv->replacingContent)
+ return;
+
+ gboolean returnValue;
+ g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue);
+ g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED);
+}
+
+void webkitWebViewSetTitle(WebKitWebView* webView, const CString& title)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (priv->title == title)
+ return;
+
+ priv->title = title;
+ g_object_notify(G_OBJECT(webView), "title");
+}
+
+void webkitWebViewSetEstimatedLoadProgress(WebKitWebView* webView, double estimatedLoadProgress)
+{
+ if (webView->priv->replacingContent)
+ return;
+
+ if (webView->priv->estimatedLoadProgress == estimatedLoadProgress)
+ return;
+
+ webView->priv->estimatedLoadProgress = estimatedLoadProgress;
+ g_object_notify(G_OBJECT(webView), "estimated-load-progress");
+}
+
+void webkitWebViewUpdateURI(WebKitWebView* webView)
+{
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKPageCopyActiveURL(toAPI(page)));
+ CString activeURI;
+ if (wkURL)
+ activeURI = toImpl(wkURL.get())->string().utf8();
+
+ if (webView->priv->activeURI == activeURI)
+ return;
+
+ webView->priv->activeURI = activeURI;
+ g_object_notify(G_OBJECT(webView), "uri");
+}
+
+WKPageRef webkitWebViewCreateNewPage(WebKitWebView* webView, WKDictionaryRef wkWindowFeatures)
+{
+ WebKitWebView* newWebView;
+ g_signal_emit(webView, signals[CREATE], 0, &newWebView);
+ if (!newWebView)
+ return 0;
+
+ webkitWindowPropertiesUpdateFromWKWindowFeatures(newWebView->priv->windowProperties.get(), wkWindowFeatures);
+
+ return static_cast<WKPageRef>(WKRetain(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(newWebView)))));
+}
+
+void webkitWebViewReadyToShowPage(WebKitWebView* webView)
+{
+ g_signal_emit(webView, signals[READY_TO_SHOW], 0, NULL);
+}
+
+void webkitWebViewClosePage(WebKitWebView* webView)
+{
+ g_signal_emit(webView, signals[CLOSE], 0, NULL);
+}
+
+void webkitWebViewRunJavaScriptAlert(WebKitWebView* webView, const CString& message)
+{
+ gboolean returnValue;
+ g_signal_emit(webView, signals[SCRIPT_ALERT], 0, message.data(), &returnValue);
+}
+
+bool webkitWebViewRunJavaScriptConfirm(WebKitWebView* webView, const CString& message)
+{
+ gboolean returnValue, confirmed;
+ g_signal_emit(webView, signals[SCRIPT_CONFIRM], 0, message.data(), &confirmed, &returnValue);
+ return confirmed;
+}
+
+WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView* webView, const CString& message, const CString& defaultText)
+{
+ gboolean returnValue;
+ GOwnPtr<char> text;
+ g_signal_emit(webView, signals[SCRIPT_PROMPT], 0, message.data(), defaultText.data(), &text.outPtr(), &returnValue);
+ return text ? WKStringCreateWithUTF8CString(text.get()) : 0;
+}
+
+/**
+ * webkit_web_view_new:
+ *
+ * Creates a new #WebKitWebView with the default #WebKitWebContext.
+ * See also webkit_web_view_new_with_context().
+ *
+ * Returns: The newly created #WebKitWebView widget
+ */
+GtkWidget* webkit_web_view_new()
+{
+ return webkit_web_view_new_with_context(webkit_web_context_get_default());
+}
+
+/**
+ * webkit_web_view_new_with_context:
+ * @context: the #WebKitWebContext to be used by the #WebKitWebView
+ *
+ * Creates a new #WebKitWebView with the given #WebKitWebContext.
+ *
+ * Returns: The newly created #WebKitWebView widget
+ */
+GtkWidget* webkit_web_view_new_with_context(WebKitWebContext* context)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+
+ return GTK_WIDGET(g_object_new(WEBKIT_TYPE_WEB_VIEW, "web-context", context, NULL));
+}
+
+/**
+ * webkit_web_view_get_context:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the web context of @web_view.
+ *
+ * Returns: (transfer none): the #WebKitWebContext of the view
+ */
+WebKitWebContext* webkit_web_view_get_context(WebKitWebView *webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->context;
+}
+
+/**
+ * webkit_web_view_load_uri:
+ * @web_view: a #WebKitWebView
+ * @uri: an URI string
+ *
+ * Requests loading of the specified URI string.
+ * You can monitor the load operation by connecting to
+ * #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(uri);
+
+ WKRetainPtr<WKURLRef> url(AdoptWK, WKURLCreateWithUTF8CString(uri));
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKPageLoadURL(toAPI(page), url.get());
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_load_html:
+ * @web_view: a #WebKitWebView
+ * @content: The HTML string to load
+ * @base_uri: (allow-none): The base URI for relative locations or %NULL
+ *
+ * Load the given @content string with the specified @base_uri.
+ * Relative URLs in the @content will be resolved against @base_uri.
+ * When @base_uri is %NULL, it defaults to "about:blank". The mime type
+ * of the document will be "text/html". You can monitor the load operation
+ * by connecting to #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_load_html(WebKitWebView* webView, const gchar* content, const gchar* baseURI)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(content);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> contentRef(AdoptWK, WKStringCreateWithUTF8CString(content));
+ WKRetainPtr<WKURLRef> baseURIRef = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0;
+ WKPageLoadHTMLString(toAPI(page), contentRef.get(), baseURIRef.get());
+}
+
+/**
+ * webkit_web_view_load_plain_text:
+ * @web_view: a #WebKitWebView
+ * @plain_text: The plain text to load
+ *
+ * Load the specified @plain_text string into @web_view. The mime type of
+ * document will be "text/plain". You can monitor the load
+ * operation by connecting to #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_load_plain_text(WebKitWebView* webView, const gchar* plainText)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(plainText);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> plainTextRef(AdoptWK, WKStringCreateWithUTF8CString(plainText));
+ WKPageLoadPlainTextString(toAPI(page), plainTextRef.get());
+}
+
+/**
+ * webkit_web_view_load_request:
+ * @web_view: a #WebKitWebView
+ * @request: a #WebKitURIRequest to load
+ *
+ * Requests loading of the specified #WebKitURIRequest.
+ * You can monitor the load operation by connecting to
+ * #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_load_request(WebKitWebView* webView, WebKitURIRequest* request)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(WEBKIT_IS_URI_REQUEST(request));
+
+ WKRetainPtr<WKURLRef> wkURL(AdoptWK, WKURLCreateWithUTF8CString(webkit_uri_request_get_uri(request)));
+ WKRetainPtr<WKURLRequestRef> wkRequest(AdoptWK, WKURLRequestCreateWithWKURL(wkURL.get()));
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKPageLoadURLRequest(toAPI(page), wkRequest.get());
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_replace_content:
+ * @web_view: a #WebKitWebView
+ * @content: the new content to display as the main page of the @web_view
+ * @content_uri: the URI for the page content
+ * @base_uri: (allow-none): the base URI for relative locations or %NULL
+ *
+ * Replace the content of @web_view with @content using @content_uri as page URI.
+ * This allows clients to display page-loading errors in the #WebKitWebView itself.
+ * This is typically called from #WebKitWebView::load-failed signal. The URI passed in
+ * @base_uri has to be an absolute URI. The mime type of the document will be "text/html".
+ * Signals #WebKitWebView::load-changed and #WebKitWebView::load-failed are not emitted
+ * when replacing content of a #WebKitWebView using this method.
+ */
+void webkit_web_view_replace_content(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(content);
+ g_return_if_fail(contentURI);
+
+ webView->priv->replacingContent = true;
+
+ WKRetainPtr<WKStringRef> htmlString(AdoptWK, WKStringCreateWithUTF8CString(content));
+ WKRetainPtr<WKURLRef> contentURL(AdoptWK, WKURLCreateWithUTF8CString(contentURI));
+ WKRetainPtr<WKURLRef> baseURL = baseURI ? adoptWK(WKURLCreateWithUTF8CString(baseURI)) : 0;
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKPageLoadAlternateHTMLString(toAPI(page), htmlString.get(), baseURL.get(), contentURL.get());
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_get_title:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the value of the #WebKitWebView:title property.
+ * You can connect to notify::title signal of @web_view to
+ * be notified when the title has been received.
+ *
+ * Returns: The main frame document title of @web_view.
+ */
+const gchar* webkit_web_view_get_title(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->title.data();
+}
+
+/**
+ * webkit_web_view_reload:
+ * @web_view: a #WebKitWebView
+ *
+ * Reloads the current contents of @web_view.
+ * See also webkit_web_view_reload_bypass_cache().
+ */
+void webkit_web_view_reload(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageReload(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_reload_bypass_cache:
+ * @web_view: a #WebKitWebView
+ *
+ * Reloads the current contents of @web_view without
+ * using any cached data.
+ */
+void webkit_web_view_reload_bypass_cache(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageReloadFromOrigin(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_stop_loading:
+ * @web_view: a #WebKitWebView
+ *
+ * Stops any ongoing loading operation in @web_view.
+ * This method does nothing if no content is being loaded.
+ * If there is a loading operation in progress, it will be cancelled and
+ * #WebKitWebView::load-failed signal will be emitted with
+ * %WEBKIT_NETWORK_ERROR_CANCELLED error.
+ */
+void webkit_web_view_stop_loading(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageStopLoading(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+}
+
+/**
+ * webkit_web_view_go_back:
+ * @web_view: a #WebKitWebView
+ *
+ * Loads the previous history item.
+ * You can monitor the load operation by connecting to
+ * #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_go_back(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageGoBack(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_can_go_back:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether @web_view has a previous history item.
+ *
+ * Returns: %TRUE if able to move back or %FALSE otherwise.
+ */
+gboolean webkit_web_view_can_go_back(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ return WKPageCanGoBack(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+}
+
+/**
+ * webkit_web_view_go_forward:
+ * @web_view: a #WebKitWebView
+ *
+ * Loads the next history item.
+ * You can monitor the load operation by connecting to
+ * #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_go_forward(WebKitWebView* webView)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageGoForward(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_can_go_forward:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines whether @web_view has a next history item.
+ *
+ * Returns: %TRUE if able to move forward or %FALSE otherwise.
+ */
+gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
+
+ return WKPageCanGoForward(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+}
+
+/**
+ * webkit_web_view_get_uri:
+ * @web_view: a #WebKitWebView
+ *
+ * Returns the current active URI of @web_view. The active URI might change during
+ * a load operation:
+ *
+ * <orderedlist>
+ * <listitem><para>
+ * When nothing has been loaded yet on @web_view the active URI is %NULL.
+ * </para></listitem>
+ * <listitem><para>
+ * When a new load operation starts the active URI is the requested URI:
+ * <itemizedlist>
+ * <listitem><para>
+ * If the load operation was started by webkit_web_view_load_uri(),
+ * the requested URI is the given one.
+ * </para></listitem>
+ * <listitem><para>
+ * If the load operation was started by webkit_web_view_load_html(),
+ * the requested URI is "about:blank".
+ * </para></listitem>
+ * <listitem><para>
+ * If the load operation was started by webkit_web_view_go_back() or
+ * webkit_web_view_go_forward(), the requested URI is the original URI
+ * of the previous/next item in the #WebKitBackForwardList of @web_view.
+ * </para></listitem>
+ * <listitem><para>
+ * If the load operation was started by
+ * webkit_web_view_go_to_back_forward_list_item(), the requested URI
+ * is the opriginal URI of the given #WebKitBackForwardListItem.
+ * </para></listitem>
+ * </itemizedlist>
+ * </para></listitem>
+ * <listitem><para>
+ * If there is a server redirection during the load operation,
+ * the active URI is the redirected URI. When the signal
+ * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_REDIRECTED
+ * event, the active URI is already updated to the redirected URI.
+ * </para></listitem>
+ * <listitem><para>
+ * When the signal #WebKitWebView::load-changed is emitted
+ * with %WEBKIT_LOAD_COMMITTED event, the active URI is the final
+ * one and it will not change unless a new load operation is started
+ * or a navigation action within the same page is performed.
+ * </para></listitem>
+ * <listitem><para>
+ * When the page content is replaced using webkit_web_view_replace_content(),
+ * the active URI is the content_uri provided.
+ * </para></listitem>
+ * </orderedlist>
+ *
+ * You can monitor the active URI by connecting to the notify::uri
+ * signal of @web_view.
+ *
+ * Returns: the current active URI of @web_view or %NULL
+ * if nothing has been loaded yet.
+ */
+const gchar* webkit_web_view_get_uri(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->activeURI.data();
+}
+
+/**
+ * webkit_web_view_get_custom_charset:
+ * @web_view: a #WebKitWebView
+ *
+ * Returns the current custom character encoding name of @web_view.
+ *
+ * Returns: the current custom character encoding name or %NULL if no
+ * custom character encoding has been set.
+ */
+const gchar* webkit_web_view_get_custom_charset(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> wkCustomEncoding(AdoptWK, WKPageCopyCustomTextEncodingName(toAPI(page)));
+ if (WKStringIsEmpty(wkCustomEncoding.get()))
+ return 0;
+
+ webView->priv->customTextEncoding = toImpl(wkCustomEncoding.get())->string().utf8();
+ return webView->priv->customTextEncoding.data();
+}
+
+/**
+ * webkit_web_view_set_custom_charset:
+ * @web_view: a #WebKitWebView
+ * @charset: (allow-none): a character encoding name or %NULL
+ *
+ * Sets the current custom character encoding override of @web_view. The custom
+ * character encoding will override any text encoding detected via HTTP headers or
+ * META tags. Calling this method will stop any current load operation and reload the
+ * current page. Setting the custom character encoding to %NULL removes the character
+ * encoding override.
+ */
+void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* charset)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView));
+ WKRetainPtr<WKStringRef> wkEncodingName = charset ? adoptWK(WKStringCreateWithUTF8CString(charset)) : 0;
+ WKPageSetCustomTextEncodingName(toAPI(page), wkEncodingName.get());
+}
+
+/**
+ * webkit_web_view_get_estimated_load_progress:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the value of the #WebKitWebView:estimated-load-progress property.
+ * You can monitor the estimated progress of a load operation by
+ * connecting to the notify::estimated-load-progress signal of @web_view.
+ *
+ * Returns: an estimate of the of the percent complete for a document
+ * load as a range from 0.0 to 1.0.
+ */
+gdouble webkit_web_view_get_estimated_load_progress(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+ return webView->priv->estimatedLoadProgress;
+}
+
+/**
+ * webkit_web_view_get_back_forward_list:
+ * @web_view: a #WebKitWebView
+ *
+ * Obtains the #WebKitBackForwardList associated with the given #WebKitWebView. The
+ * #WebKitBackForwardList is owned by the #WebKitWebView.
+ *
+ * Returns: (transfer none): the #WebKitBackForwardList
+ */
+WebKitBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->backForwardList.get();
+}
+
+/**
+ * webkit_web_view_go_to_back_forward_list_item:
+ * @web_view: a #WebKitWebView
+ * @list_item: a #WebKitBackForwardListItem
+ *
+ * Loads the specific history item @list_item.
+ * You can monitor the load operation by connecting to
+ * #WebKitWebView::load-changed signal.
+ */
+void webkit_web_view_go_to_back_forward_list_item(WebKitWebView* webView, WebKitBackForwardListItem* listItem)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem));
+
+ WKPageGoToBackForwardListItem(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))),
+ webkitBackForwardListItemGetWKItem(listItem));
+ webkitWebViewUpdateURI(webView);
+}
+
+/**
+ * webkit_web_view_set_settings:
+ * @web_view: a #WebKitWebView
+ * @settings: a #WebKitSettings
+ *
+ * Sets the #WebKitSettings to be applied to @web_view. The
+ * existing #WebKitSettings of @web_view will be replaced by
+ * @settings. New settings are applied immediately on @web_view.
+ * The same #WebKitSettings object can be shared
+ * by multiple #WebKitWebView<!-- -->s.
+ */
+void webkit_web_view_set_settings(WebKitWebView* webView, WebKitSettings* settings)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ if (webView->priv->settings == settings)
+ return;
+
+ webView->priv->settings = settings;
+ webkitSettingsAttachSettingsToPage(settings, toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))));
+}
+
+/**
+ * webkit_web_view_get_settings:
+ * @web_view: a #WebKitWebView
+ *
+ * Gets the #WebKitSettings currently applied to @web_view.
+ * If no other #WebKitSettings have been explicitly applied to
+ * @web_view with webkit_web_view_set_settings(), the default
+ * #WebKitSettings will be returned. This method always returns
+ * a valid #WebKitSettings object.
+ * To modify any of the @web_view settings, you can either create
+ * a new #WebKitSettings object with webkit_settings_new(), setting
+ * the desired preferences, and then replace the existing @web_view
+ * settings with webkit_web_view_set_settings() or get the existing
+ * @web_view settings and update it directly. #WebKitSettings objects
+ * can be shared by multiple #WebKitWebView<!-- -->s, so modifying
+ * the settings of a #WebKitWebView would affect other
+ * #WebKitWebView<!-- -->s using the same #WebKitSettings.
+ *
+ * Returns: (transfer none): the #WebKitSettings attached to @web_view
+ */
+WebKitSettings* webkit_web_view_get_settings(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->settings.get();
+}
+
+/**
+ * webkit_web_view_get_window_properties:
+ * @web_view: a #WebKitWebView
+ *
+ * Get the #WebKitWindowProperties object containing the properties
+ * that the window containing @web_view should have.
+ *
+ * Returns: (transfer none): the #WebKitWindowProperties of @web_view
+ */
+WebKitWindowProperties* webkit_web_view_get_window_properties(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return webView->priv->windowProperties.get();
+}
+
+/**
+ * webkit_web_view_set_zoom_level:
+ * @web_view: a #WebKitWebView
+ * @zoom_level: the zoom level
+ *
+ * Set the zoom level of @web_view, i.e. the factor by which the
+ * view contents are scaled with respect to their original size.
+ */
+void webkit_web_view_set_zoom_level(WebKitWebView* webView, gdouble zoomLevel)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ if (WKPageGetPageZoomFactor(wkPage) == zoomLevel)
+ return;
+
+ WKPageSetPageZoomFactor(wkPage, zoomLevel);
+ g_object_notify(G_OBJECT(webView), "zoom-level");
+}
+
+/**
+ * webkit_web_view_get_zoom_level:
+ * @web_view: a #WebKitWebView
+ *
+ * Get the zoom level of @web_view, i.e. the factor by which the
+ * view contents are scaled with respect to their original size.
+ *
+ * Returns: the current zoom level of @web_view
+ */
+gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1);
+
+ WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
+ return WKPageGetPageZoomFactor(wkPage);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
new file mode 100644
index 000000000..a25c438dd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2007 Holger Hans Peter Freyther
+ * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
+ * Copyright (C) 2008 Collabora Ltd.
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitWebView_h
+#define WebKitWebView_h
+
+#include <webkit2/WebKitBackForwardList.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitWebContext.h>
+#include <webkit2/WebKitSettings.h>
+#include <webkit2/WebKitURIRequest.h>
+#include <webkit2/WebKitWebViewBase.h>
+#include <webkit2/WebKitWindowProperties.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type())
+#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
+#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
+#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW))
+#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW))
+#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
+
+typedef struct _WebKitWebView WebKitWebView;
+typedef struct _WebKitWebViewClass WebKitWebViewClass;
+typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
+
+/**
+ * WebKitLoadEvent
+ * @WEBKIT_LOAD_STARTED: A new load request has been made.
+ * No data has been received yet, empty structures have
+ * been allocated to perform the load; the load may still
+ * fail due to transport issues such as not being able to
+ * resolve a name, or connect to a port.
+ * @WEBKIT_LOAD_REDIRECTED: A provisional data source received
+ * a server redirect.
+ * @WEBKIT_LOAD_COMMITTED: The content started arriving for a page load.
+ * The necessary transport requirements are stabilished, and the
+ * load is being performed.
+ * @WEBKIT_LOAD_FINISHED: Load completed. All resources are done loading
+ * or there was an error during the load operation.
+ */
+typedef enum {
+ WEBKIT_LOAD_STARTED,
+ WEBKIT_LOAD_REDIRECTED,
+ WEBKIT_LOAD_COMMITTED,
+ WEBKIT_LOAD_FINISHED
+} WebKitLoadEvent;
+
+struct _WebKitWebView {
+ WebKitWebViewBase parent;
+
+ /*< private >*/
+ WebKitWebViewPrivate *priv;
+};
+
+struct _WebKitWebViewClass {
+ WebKitWebViewBaseClass parent;
+
+ void (* load_changed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event);
+ gboolean (* load_failed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event,
+ const gchar *failing_uri,
+ GError *error);
+
+ GtkWidget *(* create) (WebKitWebView *web_view);
+ void (* ready_to_show) (WebKitWebView *web_view);
+ void (* close) (WebKitWebView *web_view);
+
+ gboolean (* script_alert) (WebKitWebView *web_view,
+ const gchar *message);
+ gboolean (* script_confirm) (WebKitWebView *web_view,
+ const gchar *message,
+ gboolean *confirmed);
+ gboolean (* script_prompt) (WebKitWebView *web_view,
+ const gchar *message,
+ const gchar *default_text,
+ gchar **text);
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+ void (*_webkit_reserved4) (void);
+ void (*_webkit_reserved5) (void);
+ void (*_webkit_reserved6) (void);
+ void (*_webkit_reserved7) (void);
+};
+
+WEBKIT_API GType
+webkit_web_view_get_type (void);
+
+WEBKIT_API GtkWidget *
+webkit_web_view_new (void);
+
+WEBKIT_API GtkWidget *
+webkit_web_view_new_with_context (WebKitWebContext *context);
+
+WEBKIT_API WebKitWebContext *
+webkit_web_view_get_context (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_load_uri (WebKitWebView *web_view,
+ const gchar *uri);
+
+WEBKIT_API void
+webkit_web_view_load_html (WebKitWebView *web_view,
+ const gchar *content,
+ const gchar *base_uri);
+
+WEBKIT_API void
+webkit_web_view_load_plain_text (WebKitWebView *web_view,
+ const gchar *plain_text);
+
+WEBKIT_API void
+webkit_web_view_load_request (WebKitWebView *web_view,
+ WebKitURIRequest *request);
+
+WEBKIT_API void
+webkit_web_view_stop_loading (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_replace_content (WebKitWebView *web_view,
+ const gchar *content,
+ const gchar *content_uri,
+ const gchar *base_uri);
+
+WEBKIT_API const gchar *
+webkit_web_view_get_title (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_reload (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_reload_bypass_cache (WebKitWebView *web_view);
+
+WEBKIT_API gdouble
+webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_go_back (WebKitWebView *web_view);
+
+WEBKIT_API gboolean
+webkit_web_view_can_go_back (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_go_forward (WebKitWebView *web_view);
+
+WEBKIT_API gboolean
+webkit_web_view_can_go_forward (WebKitWebView *web_view);
+
+WEBKIT_API WebKitBackForwardList *
+webkit_web_view_get_back_forward_list (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view,
+ WebKitBackForwardListItem *list_item);
+WEBKIT_API const gchar *
+webkit_web_view_get_uri (WebKitWebView *web_view);
+
+WEBKIT_API const gchar *
+webkit_web_view_get_custom_charset (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_set_custom_charset (WebKitWebView *web_view,
+ const gchar *charset);
+
+WEBKIT_API void
+webkit_web_view_set_settings (WebKitWebView *web_view,
+ WebKitSettings *settings);
+
+WEBKIT_API WebKitSettings *
+webkit_web_view_get_settings (WebKitWebView *web_view);
+
+WEBKIT_API WebKitWindowProperties *
+webkit_web_view_get_window_properties (WebKitWebView *web_view);
+
+WEBKIT_API void
+webkit_web_view_set_zoom_level (WebKitWebView *web_view,
+ gdouble zoom_level);
+WEBKIT_API gdouble
+webkit_web_view_get_zoom_level (WebKitWebView *web_view);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
new file mode 100644
index 000000000..86607162f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp
@@ -0,0 +1,520 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "WebKitWebViewBase.h"
+
+#include "DrawingAreaProxyImpl.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "PageClientImpl.h"
+#include "WebContext.h"
+#include "WebEventFactory.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebPageProxy.h"
+#include <WebCore/ClipboardGtk.h>
+#include <WebCore/ClipboardUtilitiesGtk.h>
+#include <WebCore/DataObjectGtk.h>
+#include <WebCore/DragData.h>
+#include <WebCore/DragIcon.h>
+#include <WebCore/GtkClickCounter.h>
+#include <WebCore/GtkDragAndDropHelper.h>
+#include <WebCore/GtkUtilities.h>
+#include <WebCore/GtkVersioning.h>
+#include <WebCore/NotImplemented.h>
+#include <WebCore/PasteboardHelper.h>
+#include <WebCore/RefPtrCairo.h>
+#include <WebCore/Region.h>
+#include <WebKit2/WKContext.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+struct _WebKitWebViewBasePrivate {
+ OwnPtr<PageClientImpl> pageClient;
+ RefPtr<WebPageProxy> pageProxy;
+ bool isPageActive;
+ bool shouldForwardNextKeyEvent;
+ GRefPtr<GtkIMContext> imContext;
+ GtkClickCounter clickCounter;
+ CString tooltipText;
+ GtkDragAndDropHelper dragAndDropHelper;
+ DragIcon dragIcon;
+ IntSize resizerSize;
+};
+
+G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER)
+
+static void webkitWebViewBaseNotifyResizerSizeForWindow(WebKitWebViewBase* webViewBase, GtkWindow* window)
+{
+ gboolean resizerVisible;
+ g_object_get(G_OBJECT(window), "resize-grip-visible", &resizerVisible, NULL);
+
+ IntSize resizerSize;
+ if (resizerVisible) {
+ GdkRectangle resizerRect;
+ gtk_window_get_resize_grip_area(window, &resizerRect);
+ GdkRectangle allocation;
+ gtk_widget_get_allocation(GTK_WIDGET(webViewBase), &allocation);
+ if (gdk_rectangle_intersect(&resizerRect, &allocation, 0))
+ resizerSize = IntSize(resizerRect.width, resizerRect.height);
+ }
+
+ if (resizerSize != webViewBase->priv->resizerSize) {
+ webViewBase->priv->resizerSize = resizerSize;
+ webViewBase->priv->pageProxy->setWindowResizerSize(resizerSize);
+ }
+}
+
+static void toplevelWindowResizeGripVisibilityChanged(GObject* object, GParamSpec*, WebKitWebViewBase* webViewBase)
+{
+ webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(object));
+}
+
+static void webkitWebViewBaseRealize(GtkWidget* widget)
+{
+ gtk_widget_set_realized(widget, TRUE);
+
+ GtkAllocation allocation;
+ gtk_widget_get_allocation(widget, &allocation);
+
+ GdkWindowAttr attributes;
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.visual = gtk_widget_get_visual(widget);
+ attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK
+ | GDK_EXPOSURE_MASK
+ | GDK_BUTTON_PRESS_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_POINTER_MOTION_MASK
+ | GDK_KEY_PRESS_MASK
+ | GDK_KEY_RELEASE_MASK
+ | GDK_BUTTON_MOTION_MASK
+ | GDK_BUTTON1_MOTION_MASK
+ | GDK_BUTTON2_MOTION_MASK
+ | GDK_BUTTON3_MOTION_MASK;
+
+ gint attributesMask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
+
+ GdkWindow* window = gdk_window_new(gtk_widget_get_parent_window(widget), &attributes, attributesMask);
+ gtk_widget_set_window(widget, window);
+ gdk_window_set_user_data(window, widget);
+
+ gtk_style_context_set_background(gtk_widget_get_style_context(widget), window);
+
+ WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webView->priv;
+ gtk_im_context_set_client_window(priv->imContext.get(), window);
+
+ GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
+ if (gtk_widget_is_toplevel(toplevel) && GTK_IS_WINDOW(toplevel)) {
+ webkitWebViewBaseNotifyResizerSizeForWindow(webView, GTK_WINDOW(toplevel));
+ g_signal_connect(toplevel, "notify::resize-grip-visible",
+ G_CALLBACK(toplevelWindowResizeGripVisibilityChanged), webView);
+ }
+}
+
+static void webkitWebViewBaseContainerAdd(GtkContainer* container, GtkWidget* widget)
+{
+ gtk_widget_set_parent(widget, GTK_WIDGET(container));
+}
+
+static void webkitWebViewBaseFinalize(GObject* gobject)
+{
+ WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(gobject);
+ webkitWebViewBase->priv->pageProxy->close();
+
+ webkitWebViewBase->priv->~WebKitWebViewBasePrivate();
+ G_OBJECT_CLASS(webkit_web_view_base_parent_class)->finalize(gobject);
+}
+
+static void webkit_web_view_base_init(WebKitWebViewBase* webkitWebViewBase)
+{
+ WebKitWebViewBasePrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(webkitWebViewBase, WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBasePrivate);
+ webkitWebViewBase->priv = priv;
+ new (priv) WebKitWebViewBasePrivate();
+
+ priv->isPageActive = TRUE;
+ priv->shouldForwardNextKeyEvent = FALSE;
+
+ GtkWidget* viewWidget = GTK_WIDGET(webkitWebViewBase);
+ gtk_widget_set_double_buffered(viewWidget, FALSE);
+ gtk_widget_set_can_focus(viewWidget, TRUE);
+ priv->imContext = adoptGRef(gtk_im_multicontext_new());
+
+ priv->pageClient = PageClientImpl::create(viewWidget);
+
+ priv->dragAndDropHelper.setWidget(viewWidget);
+
+ gtk_drag_dest_set(viewWidget, static_cast<GtkDestDefaults>(0), 0, 0,
+ static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK | GDK_ACTION_PRIVATE));
+ gtk_drag_dest_set_target_list(viewWidget, PasteboardHelper::defaultPasteboardHelper()->targetList());
+}
+
+static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr)
+{
+ DrawingAreaProxy* drawingArea = WEBKIT_WEB_VIEW_BASE(widget)->priv->pageProxy->drawingArea();
+ if (!drawingArea)
+ return FALSE;
+
+ GdkRectangle clipRect;
+ if (!gdk_cairo_get_clip_rectangle(cr, &clipRect))
+ return FALSE;
+
+ WebCore::Region unpaintedRegion; // This is simply unused.
+ static_cast<DrawingAreaProxyImpl*>(drawingArea)->paint(cr, clipRect, unpaintedRegion);
+
+ return FALSE;
+}
+
+static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ if (!priv->pageProxy->drawingArea())
+ return;
+
+ GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation);
+ priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize());
+
+ GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
+ if (gtk_widget_is_toplevel(toplevel) && GTK_IS_WINDOW(toplevel))
+ webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel));
+}
+
+static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
+ if (gtk_widget_is_toplevel(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
+ gtk_im_context_focus_in(priv->imContext.get());
+ if (!priv->isPageActive) {
+ priv->isPageActive = TRUE;
+ priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ }
+ }
+
+ return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_in_event(widget, event);
+}
+
+static gboolean webkitWebViewBaseFocusOutEvent(GtkWidget* widget, GdkEventFocus* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ priv->isPageActive = FALSE;
+ priv->pageProxy->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ if (priv->imContext)
+ gtk_im_context_focus_out(priv->imContext.get());
+
+ return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->focus_out_event(widget, event);
+}
+
+static gboolean webkitWebViewBaseKeyPressEvent(GtkWidget* widget, GdkEventKey* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ // Since WebProcess key event handling is not synchronous, handle the event in two passes.
+ // When WebProcess processes the input event, it will call PageClientImpl::doneWithKeyEvent
+ // with event handled status which determines whether to pass the input event to parent or not
+ // using gtk_main_do_event().
+ if (priv->shouldForwardNextKeyEvent) {
+ priv->shouldForwardNextKeyEvent = FALSE;
+ return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_press_event(widget, event);
+ }
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event)));
+ return TRUE;
+}
+
+static gboolean webkitWebViewBaseKeyReleaseEvent(GtkWidget* widget, GdkEventKey* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ if (gtk_im_context_filter_keypress(priv->imContext.get(), event))
+ return TRUE;
+
+ if (priv->shouldForwardNextKeyEvent) {
+ priv->shouldForwardNextKeyEvent = FALSE;
+ return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->key_release_event(widget, event);
+ }
+ priv->pageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(reinterpret_cast<GdkEvent*>(event)));
+ return TRUE;
+}
+
+static gboolean webkitWebViewBaseButtonPressEvent(GtkWidget* widget, GdkEventButton* buttonEvent)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ gtk_widget_grab_focus(widget);
+
+ if (!priv->clickCounter.shouldProcessButtonEvent(buttonEvent))
+ return TRUE;
+ priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(buttonEvent),
+ priv->clickCounter.clickCountForGdkButtonEvent(widget, buttonEvent)));
+ return FALSE;
+}
+
+static gboolean webkitWebViewBaseButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ gtk_widget_grab_focus(widget);
+ priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */));
+
+ return FALSE;
+}
+
+static gboolean webkitWebViewBaseScrollEvent(GtkWidget* widget, GdkEventScroll* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ priv->pageProxy->handleWheelEvent(NativeWebWheelEvent(reinterpret_cast<GdkEvent*>(event)));
+
+ return FALSE;
+}
+
+static gboolean webkitWebViewBaseMotionNotifyEvent(GtkWidget* widget, GdkEventMotion* event)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ priv->pageProxy->handleMouseEvent(NativeWebMouseEvent(reinterpret_cast<GdkEvent*>(event), 0 /* currentClickCount */));
+
+ return FALSE;
+}
+
+static gboolean webkitWebViewBaseQueryTooltip(GtkWidget* widget, gint x, gint y, gboolean keyboardMode, GtkTooltip* tooltip)
+{
+ WebKitWebViewBasePrivate* priv = WEBKIT_WEB_VIEW_BASE(widget)->priv;
+
+ if (keyboardMode) {
+ // TODO: https://bugs.webkit.org/show_bug.cgi?id=61732.
+ notImplemented();
+ return FALSE;
+ }
+
+ if (priv->tooltipText.length() <= 0)
+ return FALSE;
+
+ // TODO: set the tip area when WKPageMouseDidMoveOverElementCallback
+ // receives a hit test result.
+ gtk_tooltip_set_text(tooltip, priv->tooltipText.data());
+ return TRUE;
+}
+
+static void webkitWebViewBaseDragDataGet(GtkWidget* widget, GdkDragContext* context, GtkSelectionData* selectionData, guint info, guint time)
+{
+ WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleGetDragData(context, selectionData, info);
+}
+
+static void webkitWebViewBaseDragEnd(GtkWidget* widget, GdkDragContext* context)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ if (!webViewBase->priv->dragAndDropHelper.handleDragEnd(context))
+ return;
+
+ GdkDevice* device = gdk_drag_context_get_device(context);
+ int x = 0, y = 0;
+ gdk_device_get_window_at_position(device, &x, &y);
+ int xRoot = 0, yRoot = 0;
+ gdk_device_get_position(device, 0, &xRoot, &yRoot);
+ webViewBase->priv->pageProxy->dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot),
+ gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
+}
+
+static void webkitWebViewBaseDragDataReceived(GtkWidget* widget, GdkDragContext* context, gint x, gint y, GtkSelectionData* selectionData, guint info, guint time)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragDataReceived(context, selectionData, info));
+ if (!dragData)
+ return;
+
+ webViewBase->priv->pageProxy->resetDragOperation();
+ webViewBase->priv->pageProxy->dragEntered(dragData.get());
+ DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation;
+ gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
+}
+
+static gboolean webkitWebViewBaseDragMotion(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragMotion(context, IntPoint(x, y), time));
+ if (!dragData)
+ return TRUE;
+
+ webViewBase->priv->pageProxy->dragUpdated(dragData.get());
+ DragOperation operation = webViewBase->priv->pageProxy->dragSession().operation;
+ gdk_drag_status(context, dragOperationToSingleGdkDragAction(operation), time);
+ return TRUE;
+}
+
+static void dragExitedCallback(GtkWidget* widget, DragData* dragData, bool dropHappened)
+{
+ // Don't call dragExited if we have just received a drag-drop signal. This
+ // happens in the case of a successful drop onto the view.
+ if (dropHappened)
+ return;
+
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ webViewBase->priv->pageProxy->dragExited(dragData);
+ webViewBase->priv->pageProxy->resetDragOperation();
+}
+
+static void webkitWebViewBaseDragLeave(GtkWidget* widget, GdkDragContext* context, guint time)
+{
+ WEBKIT_WEB_VIEW_BASE(widget)->priv->dragAndDropHelper.handleDragLeave(context, dragExitedCallback);
+}
+
+static gboolean webkitWebViewBaseDragDrop(GtkWidget* widget, GdkDragContext* context, gint x, gint y, guint time)
+{
+ WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
+ OwnPtr<DragData> dragData(webViewBase->priv->dragAndDropHelper.handleDragDrop(context, IntPoint(x, y)));
+ if (!dragData)
+ return FALSE;
+
+ SandboxExtension::Handle handle;
+ webViewBase->priv->pageProxy->performDrag(dragData.get(), String(), handle);
+ gtk_drag_finish(context, TRUE, FALSE, time);
+ return TRUE;
+}
+
+static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebViewBaseClass)
+{
+ GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webkitWebViewBaseClass);
+ widgetClass->realize = webkitWebViewBaseRealize;
+ widgetClass->draw = webkitWebViewBaseDraw;
+ widgetClass->size_allocate = webkitWebViewBaseSizeAllocate;
+ widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent;
+ widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent;
+ widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent;
+ widgetClass->key_release_event = webkitWebViewBaseKeyReleaseEvent;
+ widgetClass->button_press_event = webkitWebViewBaseButtonPressEvent;
+ widgetClass->button_release_event = webkitWebViewBaseButtonReleaseEvent;
+ widgetClass->scroll_event = webkitWebViewBaseScrollEvent;
+ widgetClass->motion_notify_event = webkitWebViewBaseMotionNotifyEvent;
+ widgetClass->query_tooltip = webkitWebViewBaseQueryTooltip;
+ widgetClass->drag_end = webkitWebViewBaseDragEnd;
+ widgetClass->drag_data_get = webkitWebViewBaseDragDataGet;
+ widgetClass->drag_motion = webkitWebViewBaseDragMotion;
+ widgetClass->drag_leave = webkitWebViewBaseDragLeave;
+ widgetClass->drag_drop = webkitWebViewBaseDragDrop;
+ widgetClass->drag_data_received = webkitWebViewBaseDragDataReceived;
+
+ GObjectClass* gobjectClass = G_OBJECT_CLASS(webkitWebViewBaseClass);
+ gobjectClass->finalize = webkitWebViewBaseFinalize;
+
+ GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webkitWebViewBaseClass);
+ containerClass->add = webkitWebViewBaseContainerAdd;
+
+ g_type_class_add_private(webkitWebViewBaseClass, sizeof(WebKitWebViewBasePrivate));
+}
+
+WebKitWebViewBase* webkitWebViewBaseCreate(WebContext* context, WebPageGroup* pageGroup)
+{
+ WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(g_object_new(WEBKIT_TYPE_WEB_VIEW_BASE, NULL));
+ webkitWebViewBaseCreateWebPage(webkitWebViewBase, toAPI(context), toAPI(pageGroup));
+ return webkitWebViewBase;
+}
+
+GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase* webkitWebViewBase)
+{
+ return webkitWebViewBase->priv->imContext.get();
+}
+
+WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase* webkitWebViewBase)
+{
+ return webkitWebViewBase->priv->pageProxy.get();
+}
+
+void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WKContextRef context, WKPageGroupRef pageGroup)
+{
+ WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
+
+ priv->pageProxy = toImpl(context)->createWebPage(priv->pageClient.get(), toImpl(pageGroup));
+ priv->pageProxy->initializeWebPage();
+}
+
+void webkitWebViewBaseSetTooltipText(WebKitWebViewBase* webViewBase, const char* tooltip)
+{
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+ if (tooltip && tooltip[0] != '\0') {
+ priv->tooltipText = tooltip;
+ gtk_widget_set_has_tooltip(GTK_WIDGET(webViewBase), TRUE);
+ } else {
+ priv->tooltipText = "";
+ gtk_widget_set_has_tooltip(GTK_WIDGET(webViewBase), FALSE);
+ }
+
+ gtk_widget_trigger_tooltip_query(GTK_WIDGET(webViewBase));
+}
+
+void webkitWebViewBaseStartDrag(WebKitWebViewBase* webViewBase, const DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ WebKitWebViewBasePrivate* priv = webViewBase->priv;
+
+ RefPtr<DataObjectGtk> dataObject(dragData.platformData());
+ GRefPtr<GtkTargetList> targetList(PasteboardHelper::defaultPasteboardHelper()->targetListForDataObject(dataObject.get()));
+ GOwnPtr<GdkEvent> currentEvent(gtk_get_current_event());
+ GdkDragContext* context = gtk_drag_begin(GTK_WIDGET(webViewBase),
+ targetList.get(),
+ dragOperationToGdkDragActions(dragData.draggingSourceOperationMask()),
+ 1, /* button */
+ currentEvent.get());
+ priv->dragAndDropHelper.startedDrag(context, dataObject.get());
+
+
+ // A drag starting should prevent a double-click from happening. This might
+ // happen if a drag is followed very quickly by another click (like in the DRT).
+ priv->clickCounter.reset();
+
+ if (dragImage) {
+ RefPtr<cairo_surface_t> image(dragImage->createCairoSurface());
+ priv->dragIcon.setImage(image.get());
+ priv->dragIcon.useForDrag(context);
+ } else
+ gtk_drag_set_icon_default(context);
+}
+
+void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase* webkitWebViewBase)
+{
+ webkitWebViewBase->priv->shouldForwardNextKeyEvent = TRUE;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h
new file mode 100644
index 000000000..99c4d30cf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitWebViewBase_h
+#define WebKitWebViewBase_h
+
+#include <gtk/gtk.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WEB_VIEW_BASE (webkit_web_view_base_get_type())
+#define WEBKIT_WEB_VIEW_BASE(object) (G_TYPE_CHECK_INSTANCE_CAST((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBase))
+#define WEBKIT_WEB_VIEW_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass))
+#define WEBKIT_IS_WEB_VIEW_BASE(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), WEBKIT_TYPE_WEB_VIEW_BASE))
+#define WEBKIT_IS_WEB_VIEW_BASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW_BASE))
+#define WEBKIT_WEB_VIEW_BASE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), WEBKIT_TYPE_WEB_VIEW_BASE, WebKitWebViewBaseClass))
+
+typedef struct _WebKitWebViewBase WebKitWebViewBase;
+typedef struct _WebKitWebViewBaseClass WebKitWebViewBaseClass;
+typedef struct _WebKitWebViewBasePrivate WebKitWebViewBasePrivate;
+
+struct _WebKitWebViewBase {
+ GtkContainer parentInstance;
+ /*< private >*/
+ WebKitWebViewBasePrivate* priv;
+};
+
+struct _WebKitWebViewBaseClass {
+ GtkContainerClass parentClass;
+
+ /* Padding for future expansion */
+ void (*_webkit_reserved0) (void);
+ void (*_webkit_reserved1) (void);
+ void (*_webkit_reserved2) (void);
+ void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_web_view_base_get_type();
+
+G_END_DECLS
+
+#endif // WebKitWebViewBase_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
new file mode 100644
index 000000000..3a9a40b86
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WebKitWebViewBasePrivate_h
+#define WebKitWebViewBasePrivate_h
+
+#include "WebKitWebViewBase.h"
+#include "WebPageProxy.h"
+#include <WebKit2/WebKit2.h>
+
+using namespace WebKit;
+
+G_BEGIN_DECLS
+
+WebKitWebViewBase* webkitWebViewBaseCreate(WebContext*, WebPageGroup*);
+
+GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*);
+
+WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
+
+void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WKContextRef, WKPageGroupRef);
+
+void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
+
+void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);
+
+void webkitWebViewBaseStartDrag(WebKitWebViewBase*, const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+
+G_END_DECLS
+
+#endif // WebKitWebViewBasePrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
new file mode 100644
index 000000000..5c8161afd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, 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.
+ */
+
+#ifndef WebKitWebViewPrivate_h
+#define WebKitWebViewPrivate_h
+
+#include "WebKitWebView.h"
+#include <WebKit2/WebKit2.h>
+#include <wtf/text/CString.h>
+
+void webkitWebViewLoadChanged(WebKitWebView*, WebKitLoadEvent);
+void webkitWebViewLoadFailed(WebKitWebView*, WebKitLoadEvent, const char* failingURI, GError*);
+void webkitWebViewSetEstimatedLoadProgress(WebKitWebView*, double estimatedLoadProgress);
+void webkitWebViewSetTitle(WebKitWebView*, const CString&);
+void webkitWebViewUpdateURI(WebKitWebView*);
+WKPageRef webkitWebViewCreateNewPage(WebKitWebView*, WKDictionaryRef wkWindowFeatures);
+void webkitWebViewReadyToShowPage(WebKitWebView*);
+void webkitWebViewClosePage(WebKitWebView*);
+void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message);
+bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message);
+WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
+
+#endif // WebKitWebViewPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
new file mode 100644
index 000000000..c99f6d6e8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
@@ -0,0 +1,565 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitWindowProperties.h"
+
+#include "WebKitPrivate.h"
+#include "WebKitWindowPropertiesPrivate.h"
+#include "WebURLRequest.h"
+#include <WebCore/IntRect.h>
+#include <WebKit2/WKDictionary.h>
+#include <WebKit2/WKNumber.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKString.h>
+#include <glib/gi18n-lib.h>
+
+/**
+ * SECTION: WebKitWindowProperties
+ * @short_description: Window properties of a #WebKitWebView
+ * @title: WebKitWindowProperties
+ * @see_also: #WebKitWebView::ready-to-show
+ *
+ * The content of a #WebKitWebView can request to change certain
+ * properties of the window containing the view. This can include the x, y position
+ * of the window, the width and height but also if a toolbar,
+ * scrollbar, statusbar, locationbar should be visible to the user,
+ * and the request to show the #WebKitWebView fullscreen.
+ *
+ * The #WebKitWebView:ready-to-show signal handler is the proper place
+ * to apply the initial window properties. Then you can monitor the
+ * #WebKitWindowProperties by connecting to ::notify signal.
+ *
+ * <informalexample><programlisting>
+ * static void ready_to_show_cb (WebKitWebView *web_view, gpointer user_data)
+ * {
+ * GtkWidget *window;
+ * WebKitWindowProperties *window_properties;
+ * gboolean visible;
+ *
+ * /<!-- -->* Create the window to contain the WebKitWebView *<!-- -->/
+ * window = browser_window_new ();
+ * gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (web_view));
+ * gtk_widget_show (GTK_WIDGET (web_view));
+ *
+ * /<!-- -->* Get the WebKitWindowProperties of the web view and monitor it *<!-- -->/
+ * window_properties = webkit_web_view_get_window_properties (web_view);
+ * g_signal_connect (window_properties, "notify::geometry",
+ * G_CALLBACK (window_geometry_changed), window);
+ * g_signal_connect (window_properties, "notify::toolbar-visible",
+ * G_CALLBACK (window_toolbar_visibility_changed), window);
+ * g_signal_connect (window_properties, "notify::menubar-visible",
+ * G_CALLBACK (window_menubar_visibility_changed), window);
+ * ....
+ *
+ * /<!-- -->* Apply the window properties before showing the window *<!-- -->/
+ * visible = webkit_window_properties_get_toolbar_visible (window_properties);
+ * browser_window_set_toolbar_visible (BROWSER_WINDOW (window), visible);
+ * visible = webkit_window_properties_get_menubar_visible (window_properties);
+ * browser_window_set_menubar_visible (BROWSER_WINDOW (window), visible);
+ * ....
+ *
+ * if (webkit_window_properties_get_fullscreen (window_properties)) {
+ * gtk_window_fullscreen (GTK_WINDOW (window));
+ * } else {
+ * GdkRectangle geometry;
+ *
+ * gtk_window_set_resizable (GTK_WINDOW (window),
+ * webkit_window_properties_get_resizable (window_properties));
+ * webkit_window_properties_get_geometry (window_properties, &geometry);
+ * gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y);
+ * gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height);
+ * }
+ *
+ * gtk_widget_show (window);
+ * }
+ * </programlisting></informalexample>
+ */
+
+enum {
+ PROP_0,
+
+ PROP_GEOMETRY,
+ PROP_TOOLBAR_VISIBLE,
+ PROP_STATUSBAR_VISIBLE,
+ PROP_SCROLLBARS_VISIBLE,
+ PROP_MENUBAR_VISIBLE,
+ PROP_LOCATIONBAR_VISIBLE,
+ PROP_RESIZABLE,
+ PROP_FULLSCREEN
+};
+
+using namespace WebCore;
+
+G_DEFINE_TYPE(WebKitWindowProperties, webkit_window_properties, G_TYPE_OBJECT)
+
+struct _WebKitWindowPropertiesPrivate {
+ GdkRectangle geometry;
+
+ bool toolbarVisible : 1;
+ bool statusbarVisible : 1;
+ bool scrollbarsVisible : 1;
+ bool menubarVisible : 1;
+ bool locationbarVisible : 1;
+
+ bool resizable : 1;
+ bool fullscreen : 1;
+};
+
+static void webkitWindowPropertiesFinalize(GObject* object)
+{
+ WEBKIT_WINDOW_PROPERTIES(object)->priv->~WebKitWindowPropertiesPrivate();
+ G_OBJECT_CLASS(webkit_window_properties_parent_class)->finalize(object);
+}
+
+static void webkitWindowPropertiesGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitWindowProperties* windowProperties = WEBKIT_WINDOW_PROPERTIES(object);
+
+ switch (propId) {
+ case PROP_GEOMETRY:
+ g_value_set_boxed(value, &windowProperties->priv->geometry);
+ break;
+ case PROP_TOOLBAR_VISIBLE:
+ g_value_set_boolean(value, webkit_window_properties_get_toolbar_visible(windowProperties));
+ break;
+ case PROP_STATUSBAR_VISIBLE:
+ g_value_set_boolean(value, webkit_window_properties_get_statusbar_visible(windowProperties));
+ break;
+ case PROP_SCROLLBARS_VISIBLE:
+ g_value_set_boolean(value, webkit_window_properties_get_scrollbars_visible(windowProperties));
+ break;
+ case PROP_MENUBAR_VISIBLE:
+ g_value_set_boolean(value, webkit_window_properties_get_menubar_visible(windowProperties));
+ break;
+ case PROP_LOCATIONBAR_VISIBLE:
+ g_value_set_boolean(value, webkit_window_properties_get_locationbar_visible(windowProperties));
+ break;
+ case PROP_RESIZABLE:
+ g_value_set_boolean(value, webkit_window_properties_get_resizable(windowProperties));
+ break;
+ case PROP_FULLSCREEN:
+ g_value_set_boolean(value, webkit_window_properties_get_fullscreen(windowProperties));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitWindowPropertiesSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitWindowProperties* windowProperties = WEBKIT_WINDOW_PROPERTIES(object);
+
+ switch (propId) {
+ case PROP_GEOMETRY:
+ if (GdkRectangle* geometry = static_cast<GdkRectangle*>(g_value_get_boxed(value)))
+ windowProperties->priv->geometry = *geometry;
+ break;
+ case PROP_TOOLBAR_VISIBLE:
+ windowProperties->priv->toolbarVisible = g_value_get_boolean(value);
+ break;
+ case PROP_STATUSBAR_VISIBLE:
+ windowProperties->priv->statusbarVisible = g_value_get_boolean(value);
+ break;
+ case PROP_SCROLLBARS_VISIBLE:
+ windowProperties->priv->scrollbarsVisible = g_value_get_boolean(value);
+ break;
+ case PROP_MENUBAR_VISIBLE:
+ windowProperties->priv->menubarVisible = g_value_get_boolean(value);
+ break;
+ case PROP_LOCATIONBAR_VISIBLE:
+ windowProperties->priv->locationbarVisible = g_value_get_boolean(value);
+ break;
+ case PROP_RESIZABLE:
+ windowProperties->priv->resizable = g_value_get_boolean(value);
+ break;
+ case PROP_FULLSCREEN:
+ windowProperties->priv->fullscreen = g_value_get_boolean(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_window_properties_class_init(WebKitWindowPropertiesClass* requestClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+
+ objectClass->finalize = webkitWindowPropertiesFinalize;
+ objectClass->get_property = webkitWindowPropertiesGetProperty;
+ objectClass->set_property = webkitWindowPropertiesSetProperty;
+
+ GParamFlags paramFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * WebKitWebWindowProperties:geometry:
+ *
+ * The size and position of the window on the screen.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_GEOMETRY,
+ g_param_spec_boxed("geometry",
+ _("Geometry"),
+ _("The size and position of the window on the screen."),
+ GDK_TYPE_RECTANGLE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:toolbar-visible:
+ *
+ * Whether the toolbar should be visible for the window.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_TOOLBAR_VISIBLE,
+ g_param_spec_boolean("toolbar-visible",
+ _("Toolbar Visible"),
+ _("Whether the toolbar should be visible for the window."),
+ TRUE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:statusbar-visible:
+ *
+ * Whether the statusbar should be visible for the window.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_STATUSBAR_VISIBLE,
+ g_param_spec_boolean("statusbar-visible",
+ _("Statusbar Visible"),
+ _("Whether the statusbar should be visible for the window."),
+ TRUE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:scrollbars-visible:
+ *
+ * Whether the scrollbars should be visible for the window.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_SCROLLBARS_VISIBLE,
+ g_param_spec_boolean("scrollbars-visible",
+ _("Scrollbars Visible"),
+ _("Whether the scrollbars should be visible for the window."),
+ TRUE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:menubar-visible:
+ *
+ * Whether the menubar should be visible for the window.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_MENUBAR_VISIBLE,
+ g_param_spec_boolean("menubar-visible",
+ _("Menubar Visible"),
+ _("Whether the menubar should be visible for the window."),
+ TRUE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:locationbar-visible:
+ *
+ * Whether the locationbar should be visible for the window.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_LOCATIONBAR_VISIBLE,
+ g_param_spec_boolean("locationbar-visible",
+ _("Locationbar Visible"),
+ _("Whether the locationbar should be visible for the window."),
+ TRUE,
+ paramFlags));
+ /**
+ * WebKitWebWindowProperties:resizable:
+ *
+ * Whether the window can be resized.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_RESIZABLE,
+ g_param_spec_boolean("resizable",
+ _("Resizable"),
+ _("Whether the window can be resized."),
+ TRUE,
+ paramFlags));
+
+ /**
+ * WebKitWebWindowProperties:fullscreen:
+ *
+ * Whether window will be displayed fullscreen.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_FULLSCREEN,
+ g_param_spec_boolean("fullscreen",
+ _("Fullscreen"),
+ _("Whether window will be displayed fullscreen."),
+ FALSE,
+ paramFlags));
+
+ g_type_class_add_private(requestClass, sizeof(WebKitWindowPropertiesPrivate));
+}
+
+static void webkit_window_properties_init(WebKitWindowProperties* request)
+{
+ WebKitWindowPropertiesPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(request, WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowPropertiesPrivate);
+ request->priv = priv;
+ new (priv) WebKitWindowPropertiesPrivate();
+}
+
+WebKitWindowProperties* webkitWindowPropertiesCreate()
+{
+ return WEBKIT_WINDOW_PROPERTIES(g_object_new(WEBKIT_TYPE_WINDOW_PROPERTIES, NULL));
+}
+
+void webkitWindowPropertiesSetGeometry(WebKitWindowProperties* windowProperties, GdkRectangle* geometry)
+{
+ if (windowProperties->priv->geometry.x == geometry->x
+ && windowProperties->priv->geometry.y == geometry->y
+ && windowProperties->priv->geometry.width == geometry->width
+ && windowProperties->priv->geometry.height == geometry->height)
+ return;
+ windowProperties->priv->geometry = *geometry;
+ g_object_notify(G_OBJECT(windowProperties), "geometry");
+}
+
+void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties* windowProperties, bool toolbarsVisible)
+{
+ if (windowProperties->priv->toolbarVisible == toolbarsVisible)
+ return;
+ windowProperties->priv->toolbarVisible = toolbarsVisible;
+ g_object_notify(G_OBJECT(windowProperties), "toolbar-visible");
+}
+
+void webkitWindowPropertiesSetMenubarVisible(WebKitWindowProperties* windowProperties, bool menuBarVisible)
+{
+ if (windowProperties->priv->menubarVisible == menuBarVisible)
+ return;
+ windowProperties->priv->menubarVisible = menuBarVisible;
+ g_object_notify(G_OBJECT(windowProperties), "menubar-visible");
+}
+
+void webkitWindowPropertiesSetStatusbarVisible(WebKitWindowProperties* windowProperties, bool statusBarVisible)
+{
+ if (windowProperties->priv->statusbarVisible == statusBarVisible)
+ return;
+ windowProperties->priv->statusbarVisible = statusBarVisible;
+ g_object_notify(G_OBJECT(windowProperties), "statusbar-visible");
+}
+
+void webkitWindowPropertiesSetLocationbarVisible(WebKitWindowProperties* windowProperties, bool locationBarVisible)
+{
+ if (windowProperties->priv->locationbarVisible == locationBarVisible)
+ return;
+ windowProperties->priv->locationbarVisible = locationBarVisible;
+ g_object_notify(G_OBJECT(windowProperties), "locationbar-visible");
+}
+
+void webkitWindowPropertiesSetScrollbarsVisible(WebKitWindowProperties* windowProperties, bool scrollBarsVisible)
+{
+ if (windowProperties->priv->scrollbarsVisible == scrollBarsVisible)
+ return;
+ windowProperties->priv->scrollbarsVisible = scrollBarsVisible;
+ g_object_notify(G_OBJECT(windowProperties), "scrollbars-visible");
+}
+
+void webkitWindowPropertiesSetResizable(WebKitWindowProperties* windowProperties, bool resizable)
+{
+ if (windowProperties->priv->resizable == resizable)
+ return;
+ windowProperties->priv->resizable = resizable;
+ g_object_notify(G_OBJECT(windowProperties), "resizable-visible");
+}
+
+void webkitWindowPropertiesSetFullscreen(WebKitWindowProperties* windowProperties, bool fullscreen)
+{
+ if (windowProperties->priv->fullscreen == fullscreen)
+ return;
+ windowProperties->priv->fullscreen = fullscreen;
+ g_object_notify(G_OBJECT(windowProperties), "fullscreen");
+}
+
+void webkitWindowPropertiesUpdateFromWKWindowFeatures(WebKitWindowProperties* windowProperties, WKDictionaryRef wkFeatures)
+{
+ GdkRectangle geometry = windowProperties->priv->geometry;
+
+ WKDoubleRef doubleValue;
+ WKRetainPtr<WKStringRef> xKey(AdoptWK, WKStringCreateWithUTF8CString("x"));
+ if (doubleValue = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(wkFeatures, xKey.get())))
+ geometry.x = WKDoubleGetValue(doubleValue);
+
+ WKRetainPtr<WKStringRef> yKey(AdoptWK, WKStringCreateWithUTF8CString("y"));
+ if (doubleValue = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(wkFeatures, yKey.get())))
+ geometry.y = WKDoubleGetValue(doubleValue);
+
+ WKRetainPtr<WKStringRef> widthKey(AdoptWK, WKStringCreateWithUTF8CString("width"));
+ if (doubleValue = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(wkFeatures, widthKey.get())))
+ geometry.width = WKDoubleGetValue(doubleValue);
+
+ WKRetainPtr<WKStringRef> heightKey(AdoptWK, WKStringCreateWithUTF8CString("height"));
+ if (doubleValue = static_cast<WKDoubleRef>(WKDictionaryGetItemForKey(wkFeatures, heightKey.get())))
+ geometry.height = WKDoubleGetValue(doubleValue);
+ webkitWindowPropertiesSetGeometry(windowProperties, &geometry);
+
+ WKBooleanRef booleanValue;
+ WKRetainPtr<WKStringRef> menuBarVisibleKey(AdoptWK, WKStringCreateWithUTF8CString("menuBarVisible"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, menuBarVisibleKey.get())))
+ webkitWindowPropertiesSetMenubarVisible(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> statusBarVisibleKey(AdoptWK, WKStringCreateWithUTF8CString("statusBarVisible"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, statusBarVisibleKey.get())))
+ webkitWindowPropertiesSetStatusbarVisible(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> toolBarVisibleKey(AdoptWK, WKStringCreateWithUTF8CString("toolBarVisible"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, toolBarVisibleKey.get())))
+ webkitWindowPropertiesSetToolbarVisible(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> locationBarVisibleKey(AdoptWK, WKStringCreateWithUTF8CString("locationBarVisible"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, locationBarVisibleKey.get())))
+ webkitWindowPropertiesSetLocationbarVisible(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> scrollbarsVisibleKey(AdoptWK, WKStringCreateWithUTF8CString("scrollbarsVisible"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, scrollbarsVisibleKey.get())))
+ webkitWindowPropertiesSetScrollbarsVisible(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> resizableKey(AdoptWK, WKStringCreateWithUTF8CString("resizable"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, resizableKey.get())))
+ webkitWindowPropertiesSetResizable(windowProperties, WKBooleanGetValue(booleanValue));
+
+ WKRetainPtr<WKStringRef> fullscreenKey(AdoptWK, WKStringCreateWithUTF8CString("fullscreen"));
+ if (booleanValue = static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(wkFeatures, fullscreenKey.get())))
+ webkitWindowPropertiesSetFullscreen(windowProperties, WKBooleanGetValue(booleanValue));
+}
+
+/**
+ * webkit_window_properties_get_geometry:
+ * @window_properties: a #WebKitWindowProperties
+ * @geometry: (out): return location for the window geometry
+ *
+ * Get the geometry the window should have on the screen when shown.
+ */
+void webkit_window_properties_get_geometry(WebKitWindowProperties* windowProperties, GdkRectangle* geometry)
+{
+ g_return_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties));
+ g_return_if_fail(geometry);
+
+ *geometry = windowProperties->priv->geometry;
+}
+
+/**
+ * webkit_window_properties_get_toolbar_visible:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should have the toolbar visible or not.
+ *
+ * Returns: %TRUE if toolbar should be visible or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_toolbar_visible(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->toolbarVisible;
+}
+
+/**
+ * webkit_window_properties_get_statusbar_visible:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should have the statusbar visible or not.
+ *
+ * Returns: %TRUE if statusbar should be visible or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_statusbar_visible(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->statusbarVisible;
+}
+
+/**
+ * webkit_window_properties_get_scrollbars_visible:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should have the scrollbars visible or not.
+ *
+ * Returns: %TRUE if scrollbars should be visible or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_scrollbars_visible(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->scrollbarsVisible;
+}
+
+/**
+ * webkit_window_properties_get_menubar_visible:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should have the menubar visible or not.
+ *
+ * Returns: %TRUE if menubar should be visible or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_menubar_visible(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->menubarVisible;
+}
+
+/**
+ * webkit_window_properties_get_locationbar_visible:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should have the locationbar visible or not.
+ *
+ * Returns: %TRUE if locationbar should be visible or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_locationbar_visible(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->locationbarVisible;
+}
+
+/**
+ * webkit_window_properties_get_resizable:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should be resizable by the user or not.
+ *
+ * Returns: %TRUE if the window should be resizable or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_resizable(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), TRUE);
+
+ return windowProperties->priv->resizable;
+}
+
+/**
+ * webkit_window_properties_get_fullscreen:
+ * @window_properties: a #WebKitWindowProperties
+ *
+ * Get whether the window should be shown in fullscreen state or not.
+ *
+ * Returns: %TRUE if the window should be fullscreen or %FALSE otherwise.
+ */
+gboolean webkit_window_properties_get_fullscreen(WebKitWindowProperties* windowProperties)
+{
+ g_return_val_if_fail(WEBKIT_IS_WINDOW_PROPERTIES(windowProperties), FALSE);
+
+ return windowProperties->priv->fullscreen;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h
new file mode 100644
index 000000000..11d71fb9a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitWindowProperties_h
+#define WebKitWindowProperties_h
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_WINDOW_PROPERTIES (webkit_window_properties_get_type())
+#define WEBKIT_WINDOW_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowProperties))
+#define WEBKIT_IS_WINDOW_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WINDOW_PROPERTIES))
+#define WEBKIT_WINDOW_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowPropertiesClass))
+#define WEBKIT_IS_WINDOW_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WINDOW_PROPERTIES))
+#define WEBKIT_WINDOW_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WINDOW_PROPERTIES, WebKitWindowPropertiesClass))
+
+typedef struct _WebKitWindowProperties WebKitWindowProperties;
+typedef struct _WebKitWindowPropertiesClass WebKitWindowPropertiesClass;
+typedef struct _WebKitWindowPropertiesPrivate WebKitWindowPropertiesPrivate;
+
+struct _WebKitWindowProperties {
+ GObject parent;
+
+ /*< private >*/
+ WebKitWindowPropertiesPrivate *priv;
+};
+
+struct _WebKitWindowPropertiesClass {
+ GObjectClass parent_class;
+
+};
+
+WEBKIT_API GType
+webkit_window_properties_get_type (void);
+
+WEBKIT_API void
+webkit_window_properties_get_geometry (WebKitWindowProperties *window_properties,
+ GdkRectangle *geometry);
+WEBKIT_API gboolean
+webkit_window_properties_get_toolbar_visible (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_statusbar_visible (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_scrollbars_visible (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_menubar_visible (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_locationbar_visible (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_resizable (WebKitWindowProperties *window_properties);
+
+WEBKIT_API gboolean
+webkit_window_properties_get_fullscreen (WebKitWindowProperties *window_properties);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h
new file mode 100644
index 000000000..7b178953d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowPropertiesPrivate.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, 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.
+ */
+
+#ifndef WebKitWindowPropertiesPrivate_h
+#define WebKitWindowPropertiesPrivate_h
+
+#include "WebKitWindowProperties.h"
+#include <WebKit2/WKBase.h>
+
+WebKitWindowProperties* webkitWindowPropertiesCreate();
+void webkitWindowPropertiesUpdateFromWKWindowFeatures(WebKitWindowProperties*, WKDictionaryRef wkFeatures);
+void webkitWindowPropertiesSetGeometry(WebKitWindowProperties*, GdkRectangle*);
+void webkitWindowPropertiesSetToolbarVisible(WebKitWindowProperties*, bool toolbarsVisible);
+void webkitWindowPropertiesSetMenubarVisible(WebKitWindowProperties*, bool menuBarVisible);
+void webkitWindowPropertiesSetStatusbarVisible(WebKitWindowProperties*, bool statusBarVisible);
+void webkitWindowPropertiesSetScrollbarsVisible(WebKitWindowProperties*, bool scrollBarsVisible);
+void webkitWindowPropertiesSetResizable(WebKitWindowProperties*, bool resizable);
+void webkitWindowPropertiesSetFullscreen(WebKitWindowProperties*, bool fullscreen);
+
+#endif // WebKitWindowPropertiesPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
new file mode 100644
index 000000000..c513959c2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+<!ENTITY version SYSTEM "version.xml">
+]>
+<book id="index" xmlns:xi="http://www.w3.org/2003/XInclude">
+ <bookinfo>
+ <title>WebKit2GTK+ Reference Manual</title>
+ <releaseinfo>for WebKit2GTK+ &version;</releaseinfo>
+ </bookinfo>
+
+ <chapter>
+ <title>Class Overview</title>
+ <xi:include href="xml/WebKitWebContext.xml"/>
+ <xi:include href="xml/WebKitWebView.xml"/>
+ <xi:include href="xml/WebKitWebViewBase.xml"/>
+ <xi:include href="xml/WebKitBackForwardList.xml"/>
+ <xi:include href="xml/WebKitBackForwardListItem.xml"/>
+ <xi:include href="xml/WebKitSettings.xml"/>
+ <xi:include href="xml/WebKitURIRequest.xml"/>
+ <xi:include href="xml/WebKitURIResponse.xml"/>
+ <xi:include href="xml/WebKitWindowProperties.xml"/>
+ <xi:include href="xml/WebKitError.xml"/>
+ </chapter>
+
+ <index id="index-all">
+ <title>Index</title>
+ </index>
+ <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
+</book>
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
new file mode 100644
index 000000000..84468945d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -0,0 +1,299 @@
+<SECTION>
+<FILE>WebKitWebViewBase</FILE>
+<TITLE>WebKitWebViewBase</TITLE>
+WebKitWebViewBase
+
+<SUBSECTION Standard>
+WebKitWebViewBaseClass
+WEBKIT_WEB_VIEW_BASE
+WEBKIT_IS_WEB_VIEW_BASE
+WEBKIT_TYPE_WEB_VIEW_BASE
+WEBKIT_WEB_VIEW_BASE_CLASS
+WEBKIT_IS_WEB_VIEW_BASE_CLASS
+WEBKIT_WEB_VIEW_BASE_GET_CLASS
+
+<SUBSECTION Private>
+webkit_web_view_base_get_type
+WebKitWebViewBasePrivate
+WEBKIT_API
+WEBKIT_OBSOLETE_API
+</SECTION>
+
+<SECTION>
+<FILE>WebKitWebContext</FILE>
+<TITLE>WebKitWebContext</TITLE>
+WebKitWebContext
+WebKitCacheModel
+webkit_web_context_get_default
+webkit_web_context_get_cache_model
+webkit_web_context_set_cache_model
+
+<SUBSECTION Standard>
+WebKitWebContextClass
+WEBKIT_WEB_CONTEXT
+WEBKIT_IS_WEB_CONTEXT
+WEBKIT_TYPE_WEB_CONTEXT
+WEBKIT_WEB_CONTEXT_CLASS
+WEBKIT_IS_WEB_CONTEXT_CLASS
+WEBKIT_WEB_CONTEXT_GET_CLASS
+
+<SUBSECTION Private>
+WebKitWebContextPrivate
+webkit_web_context_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitWebView</FILE>
+<TITLE>WebKitWebView</TITLE>
+WebKitWebView
+WebKitLoadEvent
+webkit_web_view_new
+webkit_web_view_new_with_context
+webkit_web_view_get_context
+webkit_web_view_load_uri
+webkit_web_view_load_html
+webkit_web_view_load_plain_text
+webkit_web_view_load_request
+webkit_web_view_replace_content
+webkit_web_view_can_go_back
+webkit_web_view_go_back
+webkit_web_view_can_go_forward
+webkit_web_view_go_forward
+webkit_web_view_get_title
+webkit_web_view_reload
+webkit_web_view_reload_bypass_cache
+webkit_web_view_stop_loading
+webkit_web_view_get_estimated_load_progress
+webkit_web_view_get_custom_charset
+webkit_web_view_set_custom_charset
+webkit_web_view_get_back_forward_list
+webkit_web_view_go_to_back_forward_list_item
+webkit_web_view_get_uri
+webkit_web_view_set_settings
+webkit_web_view_get_settings
+webkit_web_view_get_window_properties
+webkit_web_view_set_zoom_level
+webkit_web_view_get_zoom_level
+
+<SUBSECTION Standard>
+WebKitWebViewClass
+WEBKIT_WEB_VIEW
+WEBKIT_IS_WEB_VIEW
+WEBKIT_TYPE_WEB_VIEW
+WEBKIT_WEB_VIEW_CLASS
+WEBKIT_IS_WEB_VIEW_CLASS
+WEBKIT_WEB_VIEW_GET_CLASS
+
+<SUBSECTION Private>
+webkit_web_view_get_type
+WebKitWebViewPrivate
+</SECTION>
+
+<SECTION>
+<FILE>WebKitBackForwardList</FILE>
+WebKitBackForwardList
+webkit_back_forward_list_get_length
+webkit_back_forward_list_get_current_item
+webkit_back_forward_list_get_back_item
+webkit_back_forward_list_get_forward_item
+webkit_back_forward_list_get_nth_item
+webkit_back_forward_list_get_back_list
+webkit_back_forward_list_get_back_list_with_limit
+webkit_back_forward_list_get_forward_list
+webkit_back_forward_list_get_forward_list_with_limit
+
+<SUBSECTION Standard>
+WebKitBackForwardListClass
+WEBKIT_TYPE_BACK_FORWARD_LIST
+WEBKIT_BACK_FORWARD_LIST
+WEBKIT_IS_BACK_FORWARD_LIST
+WEBKIT_BACK_FORWARD_LIST_CLASS
+WEBKIT_IS_BACK_FORWARD_LIST_CLASS
+WEBKIT_BACK_FORWARD_LIST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitBackForwardListPrivate
+webkit_back_forward_list_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitBackForwardListItem</FILE>
+WebKitBackForwardListItem
+webkit_back_forward_list_item_get_title
+webkit_back_forward_list_item_get_uri
+webkit_back_forward_list_item_get_original_uri
+
+<SUBSECTION Standard>
+WebKitBackForwardListItemClass
+WEBKIT_TYPE_BACK_FORWARD_LIST_ITEM
+WEBKIT_BACK_FORWARD_LIST_ITEM
+WEBKIT_IS_BACK_FORWARD_LIST_ITEM
+WEBKIT_BACK_FORWARD_LIST_ITEM_CLASS
+WEBKIT_IS_BACK_FORWARD_LIST_ITEM_CLASS
+WEBKIT_BACK_FORWARD_LIST_ITEM_GET_CLASS
+
+<SUBSECTION Private>
+WebKitBackForwardListItemPrivate
+webkit_back_forward_list_item_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitSettings</FILE>
+WebKitSettings
+webkit_settings_new
+webkit_settings_new_with_settings
+webkit_settings_get_auto_load_images
+webkit_settings_set_auto_load_images
+webkit_settings_get_enable_frame_flattening
+webkit_settings_set_enable_frame_flattening
+webkit_settings_get_enable_html5_database
+webkit_settings_set_enable_html5_database
+webkit_settings_get_enable_html5_local_storage
+webkit_settings_set_enable_html5_local_storage
+webkit_settings_get_enable_hyperlink_auditing
+webkit_settings_set_enable_hyperlink_auditing
+webkit_settings_get_enable_java
+webkit_settings_set_enable_java
+webkit_settings_get_enable_javascript
+webkit_settings_set_enable_javascript
+webkit_settings_get_enable_offline_web_application_cache
+webkit_settings_set_enable_offline_web_application_cache
+webkit_settings_get_enable_plugins
+webkit_settings_set_enable_plugins
+webkit_settings_get_enable_xss_auditor
+webkit_settings_set_enable_xss_auditor
+webkit_settings_get_javascript_can_open_windows_automatically
+webkit_settings_set_javascript_can_open_windows_automatically
+webkit_settings_get_load_icons_ignoring_image_load_setting
+webkit_settings_set_load_icons_ignoring_image_load_setting
+webkit_settings_get_default_font_family
+webkit_settings_set_default_font_family
+webkit_settings_get_monospace_font_family
+webkit_settings_set_monospace_font_family
+webkit_settings_get_serif_font_family
+webkit_settings_set_serif_font_family
+webkit_settings_get_sans_serif_font_family
+webkit_settings_set_sans_serif_font_family
+webkit_settings_get_cursive_font_family
+webkit_settings_set_cursive_font_family
+webkit_settings_get_fantasy_font_family
+webkit_settings_set_fantasy_font_family
+webkit_settings_get_pictograph_font_family
+webkit_settings_set_pictograph_font_family
+webkit_settings_get_default_font_size
+webkit_settings_set_default_font_size
+webkit_settings_get_default_monospace_font_size
+webkit_settings_set_default_monospace_font_size
+webkit_settings_get_minimum_font_size
+webkit_settings_set_minimum_font_size
+webkit_settings_get_default_charset
+webkit_settings_set_default_charset
+webkit_settings_get_enable_private_browsing
+webkit_settings_set_enable_private_browsing
+webkit_settings_get_enable_developer_extras
+webkit_settings_set_enable_developer_extras
+webkit_settings_get_enable_resizable_text_areas
+webkit_settings_set_enable_resizable_text_areas
+webkit_settings_get_enable_tabs_to_links
+webkit_settings_set_enable_tabs_to_links
+webkit_settings_get_enable_dns_prefetching
+webkit_settings_set_enable_dns_prefetching
+webkit_settings_get_enable_caret_browsing
+webkit_settings_set_enable_caret_browsing
+webkit_settings_get_enable_fullscreen
+webkit_settings_set_enable_fullscreen
+
+<SUBSECTION Standard>
+WebKitSettingsClass
+WEBKIT_TYPE_SETTINGS
+WEBKIT_SETTINGS
+WEBKIT_IS_SETTINGS
+WEBKIT_SETTINGS_CLASS
+WEBKIT_IS_SETTINGS_CLASS
+WEBKIT_SETTINGS_GET_CLASS
+
+<SUBSECTION Private>
+WebKitSettingsPrivate
+webkit_settings_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitURIRequest</FILE>
+WebKitURIRequest
+webkit_uri_request_new
+webkit_uri_request_get_uri
+
+<SUBSECTION Standard>
+WebKitURIRequestClass
+WEBKIT_TYPE_URI_REQUEST
+WEBKIT_URI_REQUEST
+WEBKIT_IS_URI_REQUEST
+WEBKIT_URI_REQUEST_CLASS
+WEBKIT_IS_URI_REQUEST_CLASS
+WEBKIT_URI_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitURIRequestPrivate
+webkit_uri_request_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitURIResponse</FILE>
+WebKitURIResponse
+webkit_uri_response_get_uri
+webkit_uri_response_get_status_code
+webkit_uri_response_get_content_length
+
+<SUBSECTION Standard>
+WebKitURIResponseClass
+WEBKIT_TYPE_URI_RESPONSE
+WEBKIT_URI_RESPONSE
+WEBKIT_IS_URI_RESPONSE
+WEBKIT_URI_RESPONSE_CLASS
+WEBKIT_IS_URI_RESPONSE_CLASS
+WEBKIT_URI_RESPONSE_GET_CLASS
+
+<SUBSECTION Private>
+WebKitURIResponsePrivate
+webkit_uri_response_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitWindowProperties</FILE>
+WebKitWindowProperties
+webkit_window_properties_get_geometry
+webkit_window_properties_get_toolbar_visible
+webkit_window_properties_get_statusbar_visible
+webkit_window_properties_get_scrollbars_visible
+webkit_window_properties_get_menubar_visible
+webkit_window_properties_get_locationbar_visible
+webkit_window_properties_get_resizable
+webkit_window_properties_get_fullscreen
+
+<SUBSECTION Standard>
+WebKitWindowPropertiesClass
+WEBKIT_TYPE_WINDOW_PROPERTIES
+WEBKIT_WINDOW_PROPERTIES
+WEBKIT_IS_WINDOW_PROPERTIES
+WEBKIT_WINDOW_PROPERTIES_CLASS
+WEBKIT_IS_WINDOW_PROPERTIES_CLASS
+WEBKIT_WINDOW_PROPERTIES_GET_CLASS
+
+<SUBSECTION Private>
+WebKitWindowPropertiesPrivate
+webkit_window_properties_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitError</FILE>
+WEBKIT_NETWORK_ERROR
+WEBKIT_PLUGIN_ERROR
+WEBKIT_POLICY_ERROR
+WebKitNetworkError
+WebKitPluginError
+WebKitPolicyError
+webkit_network_error_quark
+webkit_plugin_error_quark
+webkit_policy_error_quark
+</SECTION>
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
new file mode 100644
index 000000000..40a841c89
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
@@ -0,0 +1,10 @@
+#include <webkit2/webkit2.h>
+webkit_web_view_get_type
+webkit_web_view_base_get_type
+webkit_web_context_get_type
+webkit_back_forward_list_get_type
+webkit_back_forward_list_item_get_type
+webkit_settings_get_type
+webkit_uri_response_get_type
+webkit_uri_request_get_type
+webkit_window_properties_get_type
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
new file mode 100644
index 000000000..d912b657e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
@@ -0,0 +1,78 @@
+TEST_PROGS += \
+ Programs/WebKit2APITests/TestWebKitWebContext \
+ Programs/WebKit2APITests/TestWebKitWebView \
+ Programs/WebKit2APITests/TestWebKitWebLoaderClient \
+ Programs/WebKit2APITests/TestWebKitSettings \
+ Programs/WebKit2APITests/TestBackForwardList
+
+noinst_PROGRAMS += $(TEST_PROGS)
+webkit2_tests_cppflags = \
+ -DWEBKIT_EXEC_PATH=\"${shell pwd}/$(top_builddir)/Programs\" \
+ $(javascriptcore_cppflags) \
+ -I$(srcdir)/Source/JavaScriptCore \
+ -I$(srcdir)/Source \
+ -I$(srcdir)/Source/WebKit2 \
+ -I$(top_builddir)/DerivedSources/WebKit2/include \
+ -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk \
+ -I$(top_builddir)/DerivedSources/WebKit2/webkit2gtk/include \
+ -I$(srcdir)/Source/WebKit2/UIProcess/API/gtk \
+ $(global_cppflags) \
+ $(GLIB_CFLAGS) \
+ $(GTK_CFLAGS) \
+ $(LIBSOUP_CFLAGS)
+
+webkit2_tests_ldadd = \
+ Libraries/libWebKit2APITestCore.la \
+ libjavascriptcoregtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+ libwebkit2gtk-@WEBKITGTK_API_MAJOR_VERSION@.@WEBKITGTK_API_MINOR_VERSION@.la \
+ $(GEOCLUE_LIBS) \
+ $(GLIB_LIBS) \
+ $(GTK_LIBS) \
+ $(LIBSOUP_LIBS)
+
+webkit2_tests_ldflags = \
+ -no-install \
+ -no-fast-install
+
+noinst_LTLIBRARIES += Libraries/libWebKit2APITestCore.la
+Libraries_libWebKit2APITestCore_la_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp \
+ Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
+Libraries_libWebKit2APITestCore_la_CPPFLAGS = $(webkit2_tests_cppflags)
+
+Programs_WebKit2APITests_TestWebKitWebContext_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+Programs_WebKit2APITests_TestWebKitWebContext_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitWebContext_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebKitWebContext_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestWebKitWebView_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+Programs_WebKit2APITests_TestWebKitWebView_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitWebView_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebKitWebView_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestWebKitWebLoaderClient_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp
+Programs_WebKit2APITests_TestWebKitWebLoaderClient_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitWebLoaderClient_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebKitWebLoaderClient_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestWebKitSettings_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
+Programs_WebKit2APITests_TestWebKitSettings_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestWebKitSettings_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestWebKitSettings_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestBackForwardList_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp
+Programs_WebKit2APITests_TestBackForwardList_CPPFLAGS = $(webkit2_tests_cppflags)
+Programs_WebKit2APITests_TestBackForwardList_LDADD = $(webkit2_tests_ldadd)
+Programs_WebKit2APITests_TestBackForwardList_LDFLAGS = $(webkit2_tests_ldflags)
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
new file mode 100644
index 000000000..7581f2f6e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "LoadTrackingTest.h"
+
+#include <webkit2/webkit2.h>
+
+static void loadChangedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, LoadTrackingTest* test)
+{
+ switch (loadEvent) {
+ case WEBKIT_LOAD_STARTED:
+ g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+ test->provisionalLoadStarted();
+ break;
+ case WEBKIT_LOAD_REDIRECTED:
+ test->m_activeURI = webkit_web_view_get_uri(webView);
+ if (!test->m_redirectURI.isNull())
+ g_assert_cmpstr(test->m_redirectURI.data(), ==, test->m_activeURI.data());
+ test->provisionalLoadReceivedServerRedirect();
+ break;
+ case WEBKIT_LOAD_COMMITTED:
+ g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+ test->loadCommitted();
+ break;
+ case WEBKIT_LOAD_FINISHED:
+ if (!test->m_loadFailed)
+ g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+ test->loadFinished();
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void loadFailedCallback(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError* error, LoadTrackingTest* test)
+{
+ test->m_loadFailed = true;
+
+ switch (loadEvent) {
+ case WEBKIT_LOAD_STARTED:
+ g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+ g_assert(error);
+ test->provisionalLoadFailed(failingURI, error);
+ break;
+ case WEBKIT_LOAD_COMMITTED:
+ g_assert_cmpstr(test->m_activeURI.data(), ==, webkit_web_view_get_uri(webView));
+ g_assert(error);
+ test->loadFailed(failingURI, error);
+ break;
+ default:
+ g_assert_not_reached();
+ }
+}
+
+static void estimatedProgressChangedCallback(GObject*, GParamSpec*, LoadTrackingTest* test)
+{
+ test->estimatedProgressChanged();
+}
+
+LoadTrackingTest::LoadTrackingTest()
+ : m_runLoadUntilCompletion(false)
+ , m_loadFailed(false)
+{
+ g_signal_connect(m_webView, "load-changed", G_CALLBACK(loadChangedCallback), this);
+ g_signal_connect(m_webView, "load-failed", G_CALLBACK(loadFailedCallback), this);
+ g_signal_connect(m_webView, "notify::estimated-load-progress", G_CALLBACK(estimatedProgressChangedCallback), this);
+
+ g_assert(!webkit_web_view_get_uri(m_webView));
+}
+
+LoadTrackingTest::~LoadTrackingTest()
+{
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+}
+
+void LoadTrackingTest::waitUntilLoadFinished()
+{
+ m_estimatedProgress = 0;
+ m_runLoadUntilCompletion = true;
+ g_main_loop_run(m_mainLoop);
+}
+
+void LoadTrackingTest::provisionalLoadStarted()
+{
+ m_loadEvents.append(ProvisionalLoadStarted);
+}
+
+void LoadTrackingTest::provisionalLoadReceivedServerRedirect()
+{
+ m_loadEvents.append(ProvisionalLoadReceivedServerRedirect);
+}
+
+void LoadTrackingTest::provisionalLoadFailed(const gchar* failingURI, GError* error)
+{
+ m_loadEvents.append(ProvisionalLoadFailed);
+ if (m_runLoadUntilCompletion)
+ g_main_loop_quit(m_mainLoop);
+}
+
+void LoadTrackingTest::loadCommitted()
+{
+ m_loadEvents.append(LoadCommitted);
+}
+
+void LoadTrackingTest::loadFinished()
+{
+ m_loadEvents.append(LoadFinished);
+ if (m_runLoadUntilCompletion)
+ g_main_loop_quit(m_mainLoop);
+}
+
+void LoadTrackingTest::loadFailed(const gchar* failingURI, GError* error)
+{
+ m_loadEvents.append(LoadFailed);
+}
+
+void LoadTrackingTest::estimatedProgressChanged()
+{
+ double progress = webkit_web_view_get_estimated_load_progress(m_webView);
+ g_assert_cmpfloat(m_estimatedProgress, <, progress);
+ m_estimatedProgress = progress;
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
new file mode 100644
index 000000000..308aa9ce1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef LoadTrackingTest_h
+#define LoadTrackingTest_h
+
+#include "TestMain.h"
+#include "WebViewTest.h"
+#include <wtf/Vector.h>
+
+class LoadTrackingTest : public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(LoadTrackingTest);
+ LoadTrackingTest();
+ virtual ~LoadTrackingTest();
+ void waitUntilLoadFinished();
+
+ virtual void provisionalLoadStarted();
+ virtual void provisionalLoadReceivedServerRedirect();
+ virtual void provisionalLoadFailed(const gchar* failingURI, GError*);
+ virtual void loadCommitted();
+ virtual void loadFinished();
+ virtual void loadFailed(const char* failingURI, GError*);
+ virtual void estimatedProgressChanged();
+
+ void setRedirectURI(const char* uri) { m_redirectURI = uri; }
+
+ enum LoadEvents {
+ ProvisionalLoadStarted,
+ ProvisionalLoadReceivedServerRedirect,
+ ProvisionalLoadFailed,
+ LoadCommitted,
+ LoadFinished,
+ LoadFailed
+ };
+ bool m_runLoadUntilCompletion;
+ bool m_loadFailed;
+ Vector<LoadEvents> m_loadEvents;
+ float m_estimatedProgress;
+ CString m_redirectURI;
+};
+
+#endif // LoadTrackingTest_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp
new file mode 100644
index 000000000..ac2a57235
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp
@@ -0,0 +1,275 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <string.h>
+#include <webkit2/webkit2.h>
+
+// Back forward list limit is 100 by default.
+static const size_t kBackForwardListLimit = 100;
+
+static WebKitTestServer* kServer;
+
+static void serverCallback(SoupServer* server, SoupMessage* msg, const char* path, GHashTable* query, SoupClientContext* context, gpointer data)
+{
+ if (msg->method != SOUP_METHOD_GET) {
+ soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(msg, SOUP_STATUS_OK);
+
+ char* body = g_strdup_printf("<html><title>%s</title><body>%s</body></html>", path + 1, path + 1);
+ soup_message_body_append(msg->response_body, SOUP_MEMORY_TAKE, body, strlen(body));
+
+ soup_message_body_complete(msg->response_body);
+}
+
+class BackForwardListTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(BackForwardListTest);
+
+ enum {
+ Backward,
+ Forward
+ };
+
+ enum {
+ CurrentItem = 1 << 0,
+ AddedItem = 1 << 1,
+ RemovedItems = 1 << 2
+ };
+
+ static void checkItem(WebKitBackForwardListItem* item, const char* title, const char* uri, const char* originalURI)
+ {
+ g_assert(item);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_uri(item), ==, uri);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_title(item), == , title);
+ g_assert_cmpstr(webkit_back_forward_list_item_get_original_uri(item), ==, originalURI);
+ }
+
+ static void checkItemIndex(WebKitBackForwardList* list)
+ {
+ g_assert(webkit_back_forward_list_get_nth_item(list, -1) == webkit_back_forward_list_get_back_item(list));
+ g_assert(webkit_back_forward_list_get_nth_item(list, 0) == webkit_back_forward_list_get_current_item(list));
+ g_assert(webkit_back_forward_list_get_nth_item(list, 1) == webkit_back_forward_list_get_forward_item(list));
+ }
+
+ static void checkList(WebKitBackForwardList* list, unsigned type, WebKitBackForwardListItem** items, unsigned nItems)
+ {
+ GList* listItems = type == BackForwardListTest::Backward ? webkit_back_forward_list_get_back_list(list) :
+ webkit_back_forward_list_get_forward_list(list);
+ g_assert(listItems);
+
+ unsigned i = 0;
+ for (GList* listItem = listItems; listItem; listItem = g_list_next(listItem), i++) {
+ g_assert_cmpuint(i, <, nItems);
+ g_assert(listItem->data == items[i]);
+ }
+ g_list_free(listItems);
+ }
+
+ static void backForwardListChanged(WebKitBackForwardList* list, WebKitBackForwardListItem* addedItem, GList* removedItems, BackForwardListTest* test)
+ {
+ test->m_hasChanged = true;
+
+ if (test->m_changedFlags & BackForwardListTest::AddedItem) {
+ g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(addedItem));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(addedItem));
+ } else
+ g_assert(!addedItem);
+
+ if (test->m_changedFlags & BackForwardListTest::RemovedItems) {
+ g_assert(removedItems);
+ for (GList* iter = removedItems; iter; iter = iter->next) {
+ g_assert(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(iter->data));
+ if (test->m_expectedRemovedItems)
+ g_assert(g_list_find(test->m_expectedRemovedItems, iter->data));
+ }
+
+ } else
+ g_assert(!removedItems);
+ }
+
+ BackForwardListTest()
+ : m_list(webkit_web_view_get_back_forward_list(m_webView))
+ , m_changedFlags(0)
+ , m_hasChanged(false)
+ , m_expectedRemovedItems(0)
+ {
+ g_signal_connect(m_list, "changed", G_CALLBACK(backForwardListChanged), this);
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_list));
+ }
+
+ ~BackForwardListTest()
+ {
+ g_signal_handlers_disconnect_matched(m_list, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void waitUntilLoadFinished()
+ {
+ m_hasChanged = false;
+ LoadTrackingTest::waitUntilLoadFinished();
+ g_assert(m_hasChanged);
+ }
+
+ void waitUntilLoadFinishedAndCheckRemovedItems(GList* removedItems)
+ {
+ m_expectedRemovedItems = removedItems;
+ waitUntilLoadFinished();
+ m_expectedRemovedItems = 0;
+ }
+
+ WebKitBackForwardList* m_list;
+ unsigned long m_changedFlags;
+ bool m_hasChanged;
+ GList* m_expectedRemovedItems;
+};
+
+static void testBackForwardListNavigation(BackForwardListTest* test, gconstpointer)
+{
+ WebKitBackForwardListItem* items[1];
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 0);
+ g_assert(!webkit_back_forward_list_get_current_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ CString uriPage1 = kServer->getURIForPath("/Page1");
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(uriPage1.data());
+ test->waitUntilLoadFinished();
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 1);
+ WebKitBackForwardListItem* itemPage1 = webkit_back_forward_list_get_current_item(test->m_list);
+ BackForwardListTest::checkItem(itemPage1, "Page1", uriPage1.data(), uriPage1.data());
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ CString uriPage2 = kServer->getURIForPath("/Page2");
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(uriPage2.data());
+ test->waitUntilLoadFinished();
+
+ g_assert(webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ WebKitBackForwardListItem* itemPage2 = webkit_back_forward_list_get_current_item(test->m_list);
+ BackForwardListTest::checkItem(itemPage2, "Page2", uriPage2.data(), uriPage2.data());
+ g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ items[0] = itemPage1;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goBack();
+ test->waitUntilLoadFinished();
+
+ g_assert(!webkit_web_view_can_go_back(test->m_webView));
+ g_assert(webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list));
+ BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page1", uriPage1.data(), uriPage1.data());
+ g_assert(!webkit_back_forward_list_get_back_item(test->m_list));
+ g_assert(webkit_back_forward_list_get_forward_item(test->m_list) == itemPage2);
+ BackForwardListTest::checkItemIndex(test->m_list);
+ g_assert(!webkit_back_forward_list_get_back_list(test->m_list));
+ items[0] = itemPage2;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Forward, items, 1);
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goForward();
+ test->waitUntilLoadFinished();
+
+ g_assert(webkit_web_view_can_go_back(test->m_webView));
+ g_assert(!webkit_web_view_can_go_forward(test->m_webView));
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, 2);
+ g_assert(itemPage2 == webkit_back_forward_list_get_current_item(test->m_list));
+ BackForwardListTest::checkItem(webkit_back_forward_list_get_current_item(test->m_list), "Page2", uriPage2.data(), uriPage2.data());
+ g_assert(webkit_back_forward_list_get_back_item(test->m_list) == itemPage1);
+ g_assert(!webkit_back_forward_list_get_forward_item(test->m_list));
+ BackForwardListTest::checkItemIndex(test->m_list);
+ items[0] = itemPage1;
+ BackForwardListTest::checkList(test->m_list, BackForwardListTest::Backward, items, 1);
+ g_assert(!webkit_back_forward_list_get_forward_list(test->m_list));
+
+ test->m_changedFlags = BackForwardListTest::CurrentItem;
+ test->goToBackForwardListItem(itemPage1);
+ test->waitUntilLoadFinished();
+
+ g_assert(itemPage1 == webkit_back_forward_list_get_current_item(test->m_list));
+}
+
+static void testBackForwardListLimitAndCache(BackForwardListTest* test, gconstpointer)
+{
+ for (size_t i = 0; i < kBackForwardListLimit; i++) {
+ GOwnPtr<char> path(g_strdup_printf("/Page%d", i));
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem;
+ test->loadURI(kServer->getURIForPath(path.get()).data());
+ test->waitUntilLoadFinished();
+ }
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit);
+ WebKitBackForwardListItem* itemPageFirst = webkit_back_forward_list_get_nth_item(test->m_list, -(kBackForwardListLimit - 1));
+ GOwnPtr<GList> removedItems(g_list_prepend(0, itemPageFirst));
+
+ GOwnPtr<char> path(g_strdup_printf("/Page%d", kBackForwardListLimit));
+ test->m_changedFlags = BackForwardListTest::CurrentItem | BackForwardListTest::AddedItem | BackForwardListTest::RemovedItems;
+ test->loadURI(kServer->getURIForPath(path.get()).data());
+ test->waitUntilLoadFinishedAndCheckRemovedItems(removedItems.get());
+
+ g_assert_cmpuint(webkit_back_forward_list_get_length(test->m_list), ==, kBackForwardListLimit);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ BackForwardListTest::add("BackForwardList", "navigation", testBackForwardListNavigation);
+ BackForwardListTest::add("BackForwardList", "list-limit-and-cache", testBackForwardListLimitAndCache);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp
new file mode 100644
index 000000000..8622af19c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "TestMain.h"
+
+#include <gtk/gtk.h>
+
+void beforeAll();
+void afterAll();
+
+int main(int argc, char** argv)
+{
+ gtk_test_init(&argc, &argv, 0);
+ g_setenv("WEBKIT_EXEC_PATH", WEBKIT_EXEC_PATH, FALSE);
+ g_test_bug_base("https://bugs.webkit.org/");
+
+ beforeAll();
+ int returnValue = g_test_run();
+ afterAll();
+
+ return returnValue;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h
new file mode 100644
index 000000000..631096a76
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef TestMain_h
+#define TestMain_h
+
+#include <glib-object.h>
+#include <JavaScriptCore/GOwnPtr.h>
+#include <JavaScriptCore/HashSet.h>
+
+#define MAKE_GLIB_TEST_FIXTURE(ClassName) \
+ static void setUp(ClassName* fixture, gconstpointer data) \
+ { \
+ new (fixture) ClassName; \
+ } \
+ static void tearDown(ClassName* fixture, gconstpointer data) \
+ { \
+ fixture->~ClassName(); \
+ } \
+ static void add(const char* suiteName, const char* testName, void (*testFunc)(ClassName*, const void*)) \
+ { \
+ GOwnPtr<gchar> testPath(g_strdup_printf("/webkit2/%s/%s", suiteName, testName)); \
+ g_test_add(testPath.get(), ClassName, 0, ClassName::setUp, testFunc, ClassName::tearDown); \
+ }
+
+class Test
+{
+public:
+ MAKE_GLIB_TEST_FIXTURE(Test);
+
+ ~Test()
+ {
+ g_assert(m_watchedObjects.isEmpty());
+ }
+
+ static void objectFinalized(Test* test, GObject* finalizedObject)
+ {
+ test->m_watchedObjects.remove(finalizedObject);
+ }
+
+ void assertObjectIsDeletedWhenTestFinishes(GObject* object)
+ {
+ m_watchedObjects.add(object);
+ g_object_weak_ref(object, reinterpret_cast<GWeakNotify>(objectFinalized), this);
+ }
+
+ HashSet<GObject*> m_watchedObjects;
+};
+
+#endif // TestMain_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
new file mode 100644
index 000000000..93e9c9cd2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
@@ -0,0 +1,211 @@
+/*
+ * Copyright (c) 2011 Motorola Mobility, 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:
+ *
+ * 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 Motorola Mobility, 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 HOLDER 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.
+ */
+
+#include "config.h"
+
+#include "TestMain.h"
+#include <JavaScriptCore/GRefPtr.h>
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static void testWebKitSettings(Test*, gconstpointer)
+{
+ WebKitSettings* settings = webkit_settings_new();
+
+ // JavaScript is enabled by default.
+ g_assert(webkit_settings_get_enable_javascript(settings));
+ webkit_settings_set_enable_javascript(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_javascript(settings));
+
+ // By default auto-load-image is true.
+ g_assert(webkit_settings_get_auto_load_images(settings));
+ webkit_settings_set_auto_load_images(settings, FALSE);
+ g_assert(!webkit_settings_get_auto_load_images(settings));
+
+ // load-icons-ignoring-image-load-setting is false by default.
+ g_assert(!webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
+ webkit_settings_set_load_icons_ignoring_image_load_setting(settings, TRUE);
+ g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings));
+
+ // Offline application cache is true by default.
+ g_assert(webkit_settings_get_enable_offline_web_application_cache(settings));
+ webkit_settings_set_enable_offline_web_application_cache(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_offline_web_application_cache(settings));
+
+ // Local storage is enable by default.
+ g_assert(webkit_settings_get_enable_html5_local_storage(settings));
+ webkit_settings_set_enable_html5_local_storage(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_html5_local_storage(settings));
+
+ // HTML5 database is enabled by default.
+ g_assert(webkit_settings_get_enable_html5_database(settings));
+ webkit_settings_set_enable_html5_database(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_html5_database(settings));
+
+ // XSS Auditor is enabled by default.
+ g_assert(webkit_settings_get_enable_xss_auditor(settings));
+ webkit_settings_set_enable_xss_auditor(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_xss_auditor(settings));
+
+ // Frame flattening is disabled by default.
+ g_assert(!webkit_settings_get_enable_frame_flattening(settings));
+ webkit_settings_set_enable_frame_flattening(settings, TRUE);
+ g_assert(webkit_settings_get_enable_frame_flattening(settings));
+
+ // Plugins are enabled by default.
+ g_assert(webkit_settings_get_enable_plugins(settings));
+ webkit_settings_set_enable_plugins(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_plugins(settings));
+
+ // Java is enabled by default.
+ g_assert(webkit_settings_get_enable_java(settings));
+ webkit_settings_set_enable_java(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_java(settings));
+
+ // By default, JavaScript can open windows automatically is disabled.
+ g_assert(!webkit_settings_get_javascript_can_open_windows_automatically(settings));
+ webkit_settings_set_javascript_can_open_windows_automatically(settings, TRUE);
+ g_assert(webkit_settings_get_javascript_can_open_windows_automatically(settings));
+
+ // By default hyper link auditing is disabled.
+ g_assert(!webkit_settings_get_enable_hyperlink_auditing(settings));
+ webkit_settings_set_enable_hyperlink_auditing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_hyperlink_auditing(settings));
+
+ // Default font family is "sans-serif".
+ g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "sans-serif");
+ webkit_settings_set_default_font_family(settings, "monospace");
+ g_assert_cmpstr(webkit_settings_get_default_font_family(settings), ==, "monospace");
+
+ // Default monospace font family font family is "monospace".
+ g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "monospace");
+ webkit_settings_set_monospace_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_monospace_font_family(settings), ==, "sans-serif");
+
+ // Default serif font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "serif");
+ webkit_settings_set_serif_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_serif_font_family(settings), ==, "sans-serif");
+
+ // Default sans serif font family is "sans-serif".
+ g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "sans-serif");
+ webkit_settings_set_sans_serif_font_family(settings, "serif");
+ g_assert_cmpstr(webkit_settings_get_sans_serif_font_family(settings), ==, "serif");
+
+ // Default cursive font family "serif".
+ g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "serif");
+ webkit_settings_set_cursive_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_cursive_font_family(settings), ==, "sans-serif");
+
+ // Default fantasy font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "serif");
+ webkit_settings_set_fantasy_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_fantasy_font_family(settings), ==, "sans-serif");
+
+ // Default pictograph font family is "serif".
+ g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "serif");
+ webkit_settings_set_pictograph_font_family(settings, "sans-serif");
+ g_assert_cmpstr(webkit_settings_get_pictograph_font_family(settings), ==, "sans-serif");
+
+ // Default font size is 16.
+ g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 16);
+ webkit_settings_set_default_font_size(settings, 14);
+ g_assert_cmpuint(webkit_settings_get_default_font_size(settings), ==, 14);
+
+ // Default monospace font size is 13.
+ g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 13);
+ webkit_settings_set_default_monospace_font_size(settings, 10);
+ g_assert_cmpuint(webkit_settings_get_default_monospace_font_size(settings), ==, 10);
+
+ // Default minimum font size is 0.
+ g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 0);
+ webkit_settings_set_minimum_font_size(settings, 7);
+ g_assert_cmpuint(webkit_settings_get_minimum_font_size(settings), ==, 7);
+
+ // Default charset is "iso-8859-1".
+ g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "iso-8859-1");
+ webkit_settings_set_default_charset(settings, "utf8");
+ g_assert_cmpstr(webkit_settings_get_default_charset(settings), ==, "utf8");
+
+ g_assert(!webkit_settings_get_enable_private_browsing(settings));
+ webkit_settings_set_enable_private_browsing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_private_browsing(settings));
+
+ g_assert(!webkit_settings_get_enable_developer_extras(settings));
+ webkit_settings_set_enable_developer_extras(settings, TRUE);
+ g_assert(webkit_settings_get_enable_developer_extras(settings));
+
+ g_assert(webkit_settings_get_enable_resizable_text_areas(settings));
+ webkit_settings_set_enable_resizable_text_areas(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_resizable_text_areas(settings));
+
+ g_assert(webkit_settings_get_enable_tabs_to_links(settings));
+ webkit_settings_set_enable_tabs_to_links(settings, FALSE);
+ g_assert(!webkit_settings_get_enable_tabs_to_links(settings));
+
+ g_assert(!webkit_settings_get_enable_dns_prefetching(settings));
+ webkit_settings_set_enable_dns_prefetching(settings, TRUE);
+ g_assert(webkit_settings_get_enable_dns_prefetching(settings));
+
+ // Caret browsing is disabled by default.
+ g_assert(!webkit_settings_get_enable_caret_browsing(settings));
+ webkit_settings_set_enable_caret_browsing(settings, TRUE);
+ g_assert(webkit_settings_get_enable_caret_browsing(settings));
+
+ // Fullscreen JavaScript API is disabled by default.
+ g_assert(!webkit_settings_get_enable_fullscreen(settings));
+ webkit_settings_set_enable_fullscreen(settings, TRUE);
+ g_assert(webkit_settings_get_enable_fullscreen(settings));
+
+ g_object_unref(G_OBJECT(settings));
+}
+
+void testWebKitSettingsNewWithSettings(Test* test, gconstpointer)
+{
+ GRefPtr<WebKitSettings> settings = adoptGRef(webkit_settings_new_with_settings("enable-javascript", FALSE,
+ "auto-load-images", FALSE,
+ "load-icons-ignoring-image-load-setting", TRUE,
+ NULL));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(settings.get()));
+ g_assert(!webkit_settings_get_enable_javascript(settings.get()));
+ g_assert(!webkit_settings_get_auto_load_images(settings.get()));
+ g_assert(webkit_settings_get_load_icons_ignoring_image_load_setting(settings.get()));
+}
+
+void beforeAll()
+{
+ Test::add("WebKitSettings", "webkit-settings", testWebKitSettings);
+ Test::add("WebKitSettings", "new-with-settings", testWebKitSettingsNewWithSettings);
+}
+
+void afterAll()
+{
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
new file mode 100644
index 000000000..ad7ce5b8b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "TestMain.h"
+#include <gtk/gtk.h>
+#include <webkit2/webkit2.h>
+
+static void testWebContextDefault(Test* test, gconstpointer)
+{
+ // Check there's a single instance of the default web context.
+ g_assert(webkit_web_context_get_default() == webkit_web_context_get_default());
+}
+
+void beforeAll()
+{
+ Test::add("WebKitWebContext", "default-context", testWebContextDefault);
+}
+
+void afterAll()
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp
new file mode 100644
index 000000000..aaa9ff873
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebLoaderClient.cpp
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2009, 2010 Gustavo Noronha Silva
+ * Copyright (C) 2009, 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "LoadTrackingTest.h"
+#include "WebKitTestServer.h"
+#include <gtk/gtk.h>
+#include <libsoup/soup.h>
+#include <wtf/text/CString.h>
+
+static WebKitTestServer* kServer;
+
+static void testLoadingStatus(LoadTrackingTest* test, gconstpointer data)
+{
+ test->setRedirectURI(kServer->getURIForPath("/normal").data());
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadReceivedServerRedirect);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void testLoadingError(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/error").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::ProvisionalLoadFailed);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void assertNormalLoadHappenedAndClearEvents(Vector<LoadTrackingTest::LoadEvents>& events)
+{
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFinished);
+ events.clear();
+}
+
+static void testLoadHtml(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body>Hello WebKit-GTK+</body></html>", 0);
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
+}
+
+static void testLoadPlainText(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadPlainText("Hello WebKit-GTK+");
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
+}
+
+static void testLoadRequest(LoadTrackingTest* test, gconstpointer)
+{
+ GRefPtr<WebKitURIRequest> request(webkit_uri_request_new(kServer->getURIForPath("/normal").data()));
+ test->loadRequest(request.get());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
+}
+
+class LoadStopTrackingTest : public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(LoadStopTrackingTest);
+
+ virtual void loadCommitted()
+ {
+ LoadTrackingTest::loadCommitted();
+ webkit_web_view_stop_loading(m_webView);
+ }
+ virtual void loadFailed(const gchar* failingURI, GError* error)
+ {
+ g_assert(g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED));
+ LoadTrackingTest::loadFailed(failingURI, error);
+ }
+};
+
+static void testLoadCancelled(LoadStopTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/cancelled").data());
+ test->waitUntilLoadFinished();
+
+ Vector<LoadTrackingTest::LoadEvents>& events = test->m_loadEvents;
+ g_assert_cmpint(events.size(), ==, 4);
+ g_assert_cmpint(events[0], ==, LoadTrackingTest::ProvisionalLoadStarted);
+ g_assert_cmpint(events[1], ==, LoadTrackingTest::LoadCommitted);
+ g_assert_cmpint(events[2], ==, LoadTrackingTest::LoadFailed);
+ g_assert_cmpint(events[3], ==, LoadTrackingTest::LoadFinished);
+}
+
+static void testWebViewTitle(LoadTrackingTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_title(test->m_webView));
+ test->loadHtml("<html><head><title>Welcome to WebKit-GTK+!</title></head></html>", 0);
+ test->waitUntilLoadFinished();
+ g_assert_cmpstr(webkit_web_view_get_title(test->m_webView), ==, "Welcome to WebKit-GTK+!");
+}
+
+static void testWebViewReload(LoadTrackingTest* test, gconstpointer)
+{
+ // Check that nothing happens when there's nothing to reload.
+ webkit_web_view_reload(test->m_webView);
+ test->wait(0.25); // Wait for a quarter of a second.
+
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
+
+ webkit_web_view_reload(test->m_webView);
+ test->waitUntilLoadFinished();
+ assertNormalLoadHappenedAndClearEvents(test->m_loadEvents);
+}
+
+static void testLoadProgress(LoadTrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/normal").data());
+ test->waitUntilLoadFinished();
+ g_assert_cmpfloat(test->m_estimatedProgress, ==, 1);
+}
+
+class ViewURITrackingTest: public LoadTrackingTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(ViewURITrackingTest);
+
+ static void uriChanged(GObject*, GParamSpec*, ViewURITrackingTest* test)
+ {
+ g_assert_cmpstr(test->m_activeURI.data(), !=, webkit_web_view_get_uri(test->m_webView));
+ test->m_activeURI = webkit_web_view_get_uri(test->m_webView);
+ }
+
+ ViewURITrackingTest()
+ : m_activeURI(webkit_web_view_get_uri(m_webView))
+ {
+ g_assert(m_activeURI.isNull());
+ g_signal_connect(m_webView, "notify::uri", G_CALLBACK(uriChanged), this);
+ }
+
+ void provisionalLoadStarted()
+ {
+ checkActiveURI("/redirect");
+ }
+
+ void provisionalLoadReceivedServerRedirect()
+ {
+ checkActiveURI("/normal");
+ }
+
+ void loadCommitted()
+ {
+ checkActiveURI("/normal");
+ }
+
+ void loadFinished()
+ {
+ checkActiveURI("/normal");
+ LoadTrackingTest::loadFinished();
+ }
+
+ CString m_activeURI;
+
+private:
+ void checkActiveURI(const char* uri)
+ {
+ // g_assert_cmpstr is a macro, so we need to cache the temporary string.
+ CString serverURI = kServer->getURIForPath(uri);
+ g_assert_cmpstr(m_activeURI.data(), ==, serverURI.data());
+ }
+};
+
+static void testWebViewActiveURI(ViewURITrackingTest* test, gconstpointer)
+{
+ test->loadURI(kServer->getURIForPath("/redirect").data());
+ test->waitUntilLoadFinished();
+}
+
+static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer)
+{
+ static const char* responseString = "<html><body>Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!"
+ "Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!Testing!</body></html>";
+
+ if (message->method != SOUP_METHOD_GET) {
+ soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED);
+ return;
+ }
+
+ soup_message_set_status(message, SOUP_STATUS_OK);
+
+ if (g_str_equal(path, "/normal"))
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ else if (g_str_equal(path, "/error"))
+ soup_message_set_status(message, SOUP_STATUS_CANT_CONNECT);
+ else if (g_str_equal(path, "/redirect")) {
+ soup_message_set_status(message, SOUP_STATUS_MOVED_PERMANENTLY);
+ soup_message_headers_append(message->response_headers, "Location", "/normal");
+ } else if (g_str_equal(path, "/cancelled")) {
+ soup_message_headers_set_encoding(message->response_headers, SOUP_ENCODING_CHUNKED);
+ soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString));
+ soup_server_unpause_message(server, message);
+ return;
+ }
+
+ soup_message_body_complete(message->response_body);
+}
+
+void beforeAll()
+{
+ kServer = new WebKitTestServer();
+ kServer->run(serverCallback);
+
+ LoadTrackingTest::add("WebKitWebLoaderClient", "loading-status", testLoadingStatus);
+ LoadTrackingTest::add("WebKitWebLoaderClient", "loading-error", testLoadingError);
+ LoadTrackingTest::add("WebKitWebView", "load-html", testLoadHtml);
+ LoadTrackingTest::add("WebKitWebView", "load-plain-text", testLoadPlainText);
+ LoadTrackingTest::add("WebKitWebView", "load-request", testLoadRequest);
+ LoadStopTrackingTest::add("WebKitWebView", "stop-loading", testLoadCancelled);
+ LoadTrackingTest::add("WebKitWebView", "title", testWebViewTitle);
+ LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
+ LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
+
+ // This test checks that web view notify::uri signal is correctly emitted
+ // and the uri is already updated when loader client signals are emitted.
+ ViewURITrackingTest::add("WebKitWebView", "active-uri", testWebViewActiveURI);
+}
+
+void afterAll()
+{
+ delete kServer;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
new file mode 100644
index 000000000..16375ed20
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -0,0 +1,381 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebViewTest.h"
+#include <wtf/HashSet.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/StringHash.h>
+
+static void testWebViewDefaultContext(WebViewTest* test, gconstpointer)
+{
+ g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default());
+}
+
+static void testWebViewCustomCharset(WebViewTest* test, gconstpointer)
+{
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+ webkit_web_view_set_custom_charset(test->m_webView, "utf8");
+ g_assert_cmpstr(webkit_web_view_get_custom_charset(test->m_webView), ==, "utf8");
+ // Go back to the default charset.
+ webkit_web_view_set_custom_charset(test->m_webView, 0);
+ g_assert(!webkit_web_view_get_custom_charset(test->m_webView));
+}
+
+static void testWebViewSettings(WebViewTest* test, gconstpointer)
+{
+ WebKitSettings* defaultSettings = webkit_web_view_get_settings(test->m_webView);
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(defaultSettings));
+ g_assert(defaultSettings);
+ g_assert(webkit_settings_get_enable_javascript(defaultSettings));
+
+ GRefPtr<WebKitSettings> newSettings = adoptGRef(webkit_settings_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings.get()));
+ g_object_set(G_OBJECT(newSettings.get()), "enable-javascript", FALSE, NULL);
+ webkit_web_view_set_settings(test->m_webView, newSettings.get());
+
+ WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
+ g_assert(settings != defaultSettings);
+ g_assert(!webkit_settings_get_enable_javascript(settings));
+
+ GRefPtr<GtkWidget> webView2 = webkit_web_view_new();
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(webView2.get()));
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), settings);
+ g_assert(webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get())) == settings);
+
+ GRefPtr<WebKitSettings> newSettings2 = adoptGRef(webkit_settings_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(newSettings2.get()));
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(webView2.get()), newSettings2.get());
+ settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(webView2.get()));
+ g_assert(settings == newSettings2.get());
+ g_assert(webkit_settings_get_enable_javascript(settings));
+}
+
+static void replaceContentTitleChangedCallback(WebViewTest* test)
+{
+ g_main_loop_quit(test->m_mainLoop);
+}
+
+static void replaceContentLoadCallback()
+{
+ g_assert_not_reached();
+}
+
+static void testWebViewReplaceContent(WebViewTest* test, gconstpointer)
+{
+ g_signal_connect_swapped(test->m_webView, "notify::title", G_CALLBACK(replaceContentTitleChangedCallback), test);
+ g_signal_connect(test->m_webView, "load-changed", G_CALLBACK(replaceContentLoadCallback), test);
+ g_signal_connect(test->m_webView, "load-failed", G_CALLBACK(replaceContentLoadCallback), test);
+ test->replaceContent("<html><head><title>Content Replaced</title></head><body>New Content</body></html>",
+ "http://foo.com/bar", 0);
+ g_main_loop_run(test->m_mainLoop);
+}
+
+static const char* kAlertDialogMessage = "WebKitGTK+ alert dialog message";
+static const char* kConfirmDialogMessage = "WebKitGTK+ confirm dialog message";
+static const char* kPromptDialogMessage = "WebKitGTK+ prompt dialog message";
+static const char* kPromptDialogReturnedText = "WebKitGTK+ prompt dialog returned text";
+
+class UIClientTest: public WebViewTest {
+public:
+ MAKE_GLIB_TEST_FIXTURE(UIClientTest);
+
+ enum WebViewEvents {
+ Create,
+ ReadyToShow,
+ Close
+ };
+
+ enum ScriptType {
+ Alert,
+ Confirm,
+ Prompt
+ };
+
+ class WindowProperties {
+ public:
+ WindowProperties()
+ : m_toolbarVisible(true)
+ , m_statusbarVisible(true)
+ , m_scrollbarsVisible(true)
+ , m_menubarVisible(true)
+ , m_locationbarVisible(true)
+ , m_resizable(true)
+ , m_fullscreen(false)
+ {
+ memset(&m_geometry, 0, sizeof(GdkRectangle));
+ }
+
+ WindowProperties(WebKitWindowProperties* windowProperties)
+ : m_toolbarVisible(webkit_window_properties_get_toolbar_visible(windowProperties))
+ , m_statusbarVisible(webkit_window_properties_get_statusbar_visible(windowProperties))
+ , m_scrollbarsVisible(webkit_window_properties_get_scrollbars_visible(windowProperties))
+ , m_menubarVisible(webkit_window_properties_get_menubar_visible(windowProperties))
+ , m_locationbarVisible(webkit_window_properties_get_locationbar_visible(windowProperties))
+ , m_resizable(webkit_window_properties_get_resizable(windowProperties))
+ , m_fullscreen(webkit_window_properties_get_fullscreen(windowProperties))
+ {
+ webkit_window_properties_get_geometry(windowProperties, &m_geometry);
+ }
+
+ WindowProperties(GdkRectangle* geometry, bool toolbarVisible, bool statusbarVisible, bool scrollbarsVisible, bool menubarVisible,
+ bool locationbarVisible, bool resizable, bool fullscreen)
+ : m_geometry(*geometry)
+ , m_toolbarVisible(toolbarVisible)
+ , m_statusbarVisible(statusbarVisible)
+ , m_scrollbarsVisible(scrollbarsVisible)
+ , m_menubarVisible(menubarVisible)
+ , m_locationbarVisible(locationbarVisible)
+ , m_resizable(resizable)
+ , m_fullscreen(fullscreen)
+ {
+ }
+
+ void assertEqual(const WindowProperties& other) const
+ {
+ // FIXME: We should assert x and y are equal, but we are getting an incorrect
+ // value from WebCore (280 instead of 150).
+ g_assert_cmpint(m_geometry.width, ==, other.m_geometry.width);
+ g_assert_cmpint(m_geometry.height, ==, other.m_geometry.height);
+ g_assert_cmpint(static_cast<int>(m_toolbarVisible), ==, static_cast<int>(other.m_toolbarVisible));
+ g_assert_cmpint(static_cast<int>(m_statusbarVisible), ==, static_cast<int>(other.m_statusbarVisible));
+ g_assert_cmpint(static_cast<int>(m_scrollbarsVisible), ==, static_cast<int>(other.m_scrollbarsVisible));
+ g_assert_cmpint(static_cast<int>(m_menubarVisible), ==, static_cast<int>(other.m_menubarVisible));
+ g_assert_cmpint(static_cast<int>(m_locationbarVisible), ==, static_cast<int>(other.m_locationbarVisible));
+ g_assert_cmpint(static_cast<int>(m_resizable), ==, static_cast<int>(other.m_resizable));
+ g_assert_cmpint(static_cast<int>(m_fullscreen), ==, static_cast<int>(other.m_fullscreen));
+ }
+
+ private:
+ GdkRectangle m_geometry;
+
+ bool m_toolbarVisible;
+ bool m_statusbarVisible;
+ bool m_scrollbarsVisible;
+ bool m_menubarVisible;
+ bool m_locationbarVisible;
+
+ bool m_resizable;
+ bool m_fullscreen;
+ };
+
+ static void windowPropertiesNotifyCallback(GObject*, GParamSpec* paramSpec, UIClientTest* test)
+ {
+ test->m_windowPropertiesChanged.add(g_param_spec_get_name(paramSpec));
+ }
+
+ static void viewClose(WebKitWebView* webView, UIClientTest* test)
+ {
+ g_assert(webView != test->m_webView);
+
+ test->m_webViewEvents.append(Close);
+ g_object_unref(webView);
+
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ static void viewReadyToShow(WebKitWebView* webView, UIClientTest* test)
+ {
+ g_assert(webView != test->m_webView);
+
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(webView);
+ g_assert(windowProperties);
+ WindowProperties(windowProperties).assertEqual(test->m_windowProperties);
+
+ test->m_webViewEvents.append(ReadyToShow);
+ }
+
+ static GtkWidget* viewCreate(WebKitWebView* webView, UIClientTest* test)
+ {
+ g_assert(webView == test->m_webView);
+
+ GtkWidget* newWebView = webkit_web_view_new_with_context(webkit_web_view_get_context(webView));
+ g_object_ref_sink(newWebView);
+
+ test->m_webViewEvents.append(Create);
+
+ WebKitWindowProperties* windowProperties = webkit_web_view_get_window_properties(WEBKIT_WEB_VIEW(newWebView));
+ g_assert(windowProperties);
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(windowProperties));
+ test->m_windowPropertiesChanged.clear();
+ g_signal_connect(windowProperties, "notify", G_CALLBACK(windowPropertiesNotifyCallback), test);
+
+ g_signal_connect(newWebView, "ready-to-show", G_CALLBACK(viewReadyToShow), test);
+ g_signal_connect(newWebView, "close", G_CALLBACK(viewClose), test);
+
+ return newWebView;
+ }
+
+ static gboolean scriptAlert(WebKitWebView*, const char* message, UIClientTest* test)
+ {
+ switch (test->m_scriptType) {
+ case UIClientTest::Alert:
+ g_assert_cmpstr(message, ==, kAlertDialogMessage);
+ break;
+ case UIClientTest::Confirm:
+ g_assert(test->m_scriptDialogConfirmed);
+ g_assert_cmpstr(message, ==, "confirmed");
+
+ break;
+ case UIClientTest::Prompt:
+ g_assert_cmpstr(message, ==, kPromptDialogReturnedText);
+ break;
+ }
+
+ g_main_loop_quit(test->m_mainLoop);
+
+ return TRUE;
+ }
+
+ static gboolean scriptConfirm(WebKitWebView*, const char* message, gboolean* confirmed, UIClientTest* test)
+ {
+ g_assert_cmpstr(message, ==, kConfirmDialogMessage);
+ g_assert(confirmed);
+ test->m_scriptDialogConfirmed = !test->m_scriptDialogConfirmed;
+ *confirmed = test->m_scriptDialogConfirmed;
+
+ return TRUE;
+ }
+
+ static gboolean scriptPrompt(WebKitWebView*, const char* message, const char* defaultText, char **text, UIClientTest* test)
+ {
+ g_assert_cmpstr(message, ==, kPromptDialogMessage);
+ g_assert_cmpstr(defaultText, ==, "default");
+ g_assert(text);
+ *text = g_strdup(kPromptDialogReturnedText);
+
+ return TRUE;
+ }
+
+ UIClientTest()
+ : m_scriptType(Alert)
+ , m_scriptDialogConfirmed(true)
+ {
+ webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
+ g_signal_connect(m_webView, "create", G_CALLBACK(viewCreate), this);
+ g_signal_connect(m_webView, "script-alert", G_CALLBACK(scriptAlert), this);
+ g_signal_connect(m_webView, "script-confirm", G_CALLBACK(scriptConfirm), this);
+ g_signal_connect(m_webView, "script-prompt", G_CALLBACK(scriptPrompt), this);
+ }
+
+ ~UIClientTest()
+ {
+ g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ }
+
+ void waitUntilMainLoopFinishes()
+ {
+ g_main_loop_run(m_mainLoop);
+ }
+
+ void setExpectedWindowProperties(const WindowProperties& windowProperties)
+ {
+ m_windowProperties = windowProperties;
+ }
+
+ Vector<WebViewEvents> m_webViewEvents;
+ ScriptType m_scriptType;
+ bool m_scriptDialogConfirmed;
+ WindowProperties m_windowProperties;
+ HashSet<WTF::String> m_windowPropertiesChanged;
+};
+
+static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
+{
+ test->loadHtml("<html><body onLoad=\"window.open().close();\"></html>", 0);
+ test->waitUntilMainLoopFinishes();
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, UIClientTest::Create);
+ g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+ g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static void testWebViewJavaScriptDialogs(UIClientTest* test, gconstpointer)
+{
+ static const char* htmlOnLoadFormat = "<html><body onLoad=\"%s\"></body></html>";
+ static const char* jsAlertFormat = "alert('%s')";
+ static const char* jsConfirmFormat = "do { confirmed = confirm('%s'); } while (!confirmed); alert('confirmed');";
+ static const char* jsPromptFormat = "alert(prompt('%s', 'default'));";
+
+ test->m_scriptType = UIClientTest::Alert;
+ GOwnPtr<char> alertDialogMessage(g_strdup_printf(jsAlertFormat, kAlertDialogMessage));
+ GOwnPtr<char> alertHTML(g_strdup_printf(htmlOnLoadFormat, alertDialogMessage.get()));
+ test->loadHtml(alertHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ test->m_scriptType = UIClientTest::Confirm;
+ GOwnPtr<char> confirmDialogMessage(g_strdup_printf(jsConfirmFormat, kConfirmDialogMessage));
+ GOwnPtr<char> confirmHTML(g_strdup_printf(htmlOnLoadFormat, confirmDialogMessage.get()));
+ test->loadHtml(confirmHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ test->m_scriptType = UIClientTest::Prompt;
+ GOwnPtr<char> promptDialogMessage(g_strdup_printf(jsPromptFormat, kPromptDialogMessage));
+ GOwnPtr<char> promptHTML(g_strdup_printf(htmlOnLoadFormat, promptDialogMessage.get()));
+ test->loadHtml(promptHTML.get(), 0);
+ test->waitUntilMainLoopFinishes();
+}
+
+static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
+{
+ static const char* windowProrpertiesString = "left=100,top=150,width=400,height=400,location=no,menubar=no,status=no,toolbar=no,scrollbars=no";
+ GdkRectangle geometry = { 100, 150, 400, 400 };
+ test->setExpectedWindowProperties(UIClientTest::WindowProperties(&geometry, false, false, false, false, false, true, false));
+
+ GOwnPtr<char> htmlString(g_strdup_printf("<html><body onLoad=\"window.open('', '', '%s').close();\"></body></html>", windowProrpertiesString));
+ test->loadHtml(htmlString.get(), 0);
+ test->waitUntilMainLoopFinishes();
+
+ static const char* propertiesChanged[] = {
+ "geometry", "locationbar-visible", "menubar-visible", "statusbar-visible", "toolbar-visible", "scrollbars-visible"
+ };
+ for (size_t i = 0; i < G_N_ELEMENTS(propertiesChanged); ++i)
+ g_assert(test->m_windowPropertiesChanged.contains(propertiesChanged[i]));
+
+ Vector<UIClientTest::WebViewEvents>& events = test->m_webViewEvents;
+ g_assert_cmpint(events.size(), ==, 3);
+ g_assert_cmpint(events[0], ==, UIClientTest::Create);
+ g_assert_cmpint(events[1], ==, UIClientTest::ReadyToShow);
+ g_assert_cmpint(events[2], ==, UIClientTest::Close);
+}
+
+static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
+{
+ g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1);
+ webkit_web_view_set_zoom_level(test->m_webView, 2.5);
+ g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 2.5);
+}
+
+void beforeAll()
+{
+ WebViewTest::add("WebKitWebView", "default-context", testWebViewDefaultContext);
+ WebViewTest::add("WebKitWebView", "custom-charset", testWebViewCustomCharset);
+ WebViewTest::add("WebKitWebView", "settings", testWebViewSettings);
+ WebViewTest::add("WebKitWebView", "replace-content", testWebViewReplaceContent);
+ UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
+ UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
+ UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
+ WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
+}
+
+void afterAll()
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp
new file mode 100644
index 000000000..55a93de87
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitTestServer.h"
+
+#include <wtf/gobject/GOwnPtr.h>
+
+WebKitTestServer::WebKitTestServer()
+ : m_soupServer(adoptGRef(soup_server_new(SOUP_SERVER_PORT, 0, NULL)))
+ , m_baseURI(soup_uri_new("http://127.0.0.1/"))
+{
+ soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer.get()));
+}
+
+WebKitTestServer::~WebKitTestServer()
+{
+ soup_uri_free(m_baseURI);
+}
+
+void WebKitTestServer::run(SoupServerCallback serverCallback)
+{
+ soup_server_run_async(m_soupServer.get());
+ soup_server_add_handler(m_soupServer.get(), 0, serverCallback, 0, 0);
+}
+
+CString WebKitTestServer::getURIForPath(const char* path)
+{
+ SoupURI* uri = soup_uri_new_with_base(m_baseURI, path);
+ GOwnPtr<gchar> uriString(soup_uri_to_string(uri, FALSE));
+ soup_uri_free(uri);
+ return uriString.get();
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h
new file mode 100644
index 000000000..9f00349e0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebKitTestServer.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitTestServer_h
+#define WebKitTestServer_h
+
+#include <libsoup/soup.h>
+#include <webkit2/webkit2.h>
+#include <wtf/gobject/GRefPtr.h>
+#include <wtf/text/CString.h>
+
+class WebKitTestServer {
+public:
+ WebKitTestServer();
+ virtual ~WebKitTestServer();
+
+ SoupURI* baseURI() { return m_baseURI; }
+
+ CString getURIForPath(const char* path);
+ void run(SoupServerCallback);
+
+private:
+ GRefPtr<SoupServer> m_soupServer;
+ SoupURI* m_baseURI;
+};
+
+#endif // WebKitTestServer_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
new file mode 100644
index 000000000..dfd9da475
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebViewTest.h"
+
+WebViewTest::WebViewTest()
+ : m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new())))
+ , m_mainLoop(g_main_loop_new(0, TRUE))
+{
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
+}
+
+WebViewTest::~WebViewTest()
+{
+ g_object_unref(m_webView);
+ g_main_loop_unref(m_mainLoop);
+}
+
+static gboolean testLoadTimeoutFinishLoop(GMainLoop* loop)
+{
+ g_main_loop_quit(loop);
+ return FALSE;
+}
+
+void WebViewTest::loadURI(const char* uri)
+{
+ m_activeURI = uri;
+ webkit_web_view_load_uri(m_webView, uri);
+}
+
+void WebViewTest::loadHtml(const char* html, const char* baseURI)
+{
+ m_activeURI = "about:blank";
+ webkit_web_view_load_html(m_webView, html, baseURI);
+}
+
+void WebViewTest::loadPlainText(const char* plainText)
+{
+ m_activeURI = "about:blank";
+ webkit_web_view_load_plain_text(m_webView, plainText);
+}
+
+void WebViewTest::loadRequest(WebKitURIRequest* request)
+{
+ m_activeURI = webkit_uri_request_get_uri(request);
+ webkit_web_view_load_request(m_webView, request);
+}
+
+void WebViewTest::replaceContent(const char* html, const char* contentURI, const char* baseURI)
+{
+ // FIXME: The active uri should be the contentURI,
+ // but WebPageProxy doesn't return the unreachableURL
+ // when the page has been loaded with AlternateHTML()
+ // See https://bugs.webkit.org/show_bug.cgi?id=75465.
+#if 0
+ m_activeURI = contentURI;
+#else
+ m_activeURI = "about:blank";
+#endif
+ webkit_web_view_replace_content(m_webView, html, contentURI, baseURI);
+}
+
+void WebViewTest::goBack()
+{
+ if (webkit_web_view_can_go_back(m_webView)) {
+ WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView);
+ WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, -1);
+ m_activeURI = webkit_back_forward_list_item_get_original_uri(item);
+ }
+
+ // Call go_back even when can_go_back returns FALSE to check nothing happens.
+ webkit_web_view_go_back(m_webView);
+}
+
+void WebViewTest::goForward()
+{
+ if (webkit_web_view_can_go_forward(m_webView)) {
+ WebKitBackForwardList* list = webkit_web_view_get_back_forward_list(m_webView);
+ WebKitBackForwardListItem* item = webkit_back_forward_list_get_nth_item(list, 1);
+ m_activeURI = webkit_back_forward_list_item_get_original_uri(item);
+ }
+
+ // Call go_forward even when can_go_forward returns FALSE to check nothing happens.
+ webkit_web_view_go_forward(m_webView);
+}
+
+void WebViewTest::goToBackForwardListItem(WebKitBackForwardListItem* item)
+{
+ m_activeURI = webkit_back_forward_list_item_get_original_uri(item);
+ webkit_web_view_go_to_back_forward_list_item(m_webView, item);
+}
+
+void WebViewTest::wait(double seconds)
+{
+ g_timeout_add_seconds(seconds, reinterpret_cast<GSourceFunc>(testLoadTimeoutFinishLoop), m_mainLoop);
+ g_main_loop_run(m_mainLoop);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
new file mode 100644
index 000000000..662354032
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebViewTest_h
+#define WebViewTest_h
+
+#include "TestMain.h"
+#include <webkit2/webkit2.h>
+#include <wtf/text/CString.h>
+
+class WebViewTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(WebViewTest);
+ WebViewTest();
+ virtual ~WebViewTest();
+
+ void loadURI(const char* uri);
+ void loadHtml(const char* html, const char* baseURI);
+ void loadPlainText(const char* plainText);
+ void loadRequest(WebKitURIRequest*);
+ void replaceContent(const char* html, const char* contentURI, const char* baseURI);
+ void goBack();
+ void goForward();
+ void goToBackForwardListItem(WebKitBackForwardListItem*);
+
+ void wait(double seconds);
+
+ WebKitWebView* m_webView;
+ GMainLoop* m_mainLoop;
+ CString m_activeURI;
+};
+
+#endif // WebViewTest_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
new file mode 100644
index 000000000..ab0e0a8f1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2011 Igalia S.L.
+ * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __WEBKIT2_H__
+#define __WEBKIT2_H__
+
+#define __WEBKIT2_H_INSIDE__
+
+#include <webkit2/WebKitBackForwardList.h>
+#include <webkit2/WebKitBackForwardListItem.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitEnumTypes.h>
+#include <webkit2/WebKitError.h>
+#include <webkit2/WebKitSettings.h>
+#include <webkit2/WebKitURIRequest.h>
+#include <webkit2/WebKitURIResponse.h>
+#include <webkit2/WebKitWebContext.h>
+#include <webkit2/WebKitWebViewBase.h>
+#include <webkit2/WebKitWebView.h>
+#include <webkit2/WebKitWindowProperties.h>
+
+#undef __WEBKIT2_H_INSIDE__
+
+#endif /* __WEBKIT2_H__ */
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list b/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list
new file mode 100644
index 000000000..89c250e3e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list
@@ -0,0 +1,8 @@
+BOOLEAN:ENUM,STRING,POINTER
+BOOLEAN:STRING
+BOOLEAN:STRING,POINTER
+BOOLEAN:STRING,STRING,POINTER
+OBJECT:VOID
+VOID:ENUM
+VOID:OBJECT,POINTER
+
diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
new file mode 100644
index 000000000..7836a546a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef FindIndicatorWindow_h
+#define FindIndicatorWindow_h
+
+#import <wtf/Noncopyable.h>
+#import <wtf/PassOwnPtr.h>
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+#import "RunLoop.h"
+#import "WebKitSystemInterface.h"
+
+@class WKFindIndicatorWindowAnimation;
+@class WKView;
+
+namespace WebKit {
+
+class FindIndicator;
+
+class FindIndicatorWindow {
+ WTF_MAKE_NONCOPYABLE(FindIndicatorWindow);
+
+public:
+ static PassOwnPtr<FindIndicatorWindow> create(WKView *);
+ ~FindIndicatorWindow();
+
+ void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
+
+private:
+ explicit FindIndicatorWindow(WKView *);
+ void closeWindow();
+
+ void startFadeOutTimerFired();
+
+ void fadeOutAnimationCallback(double);
+ void fadeOutAnimationDidEnd();
+
+ void bounceAnimationCallback(double);
+ void bounceAnimationDidEnd();
+
+ WKView* m_wkView;
+ RefPtr<FindIndicator> m_findIndicator;
+ RetainPtr<NSWindow> m_findIndicatorWindow;
+
+ WKWindowBounceAnimationContextRef m_bounceAnimationContext;
+ RetainPtr<WKFindIndicatorWindowAnimation> m_bounceAnimation;
+
+ RunLoop::Timer<FindIndicatorWindow> m_startFadeOutTimer;
+ RetainPtr<WKFindIndicatorWindowAnimation> m_fadeOutAnimation;
+};
+
+} // namespace WebKit
+
+#endif // FindIndicatorWindow_h
diff --git a/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
new file mode 100644
index 000000000..0e6a6f130
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm
@@ -0,0 +1,249 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#import "config.h"
+#import "FindIndicatorWindow.h"
+
+#import "FindIndicator.h"
+#import "WKView.h"
+#import <WebCore/GraphicsContext.h>
+
+static const double bounceAnimationDuration = 0.12;
+static const double timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
+static const double fadeOutAnimationDuration = 0.3;
+
+using namespace WebCore;
+
+@interface WKFindIndicatorView : NSView {
+ RefPtr<WebKit::FindIndicator> _findIndicator;
+}
+
+- (id)_initWithFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator;
+@end
+
+@implementation WKFindIndicatorView
+
+- (id)_initWithFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator
+{
+ if ((self = [super initWithFrame:NSZeroRect]))
+ _findIndicator = findIndicator;
+
+ return self;
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ GraphicsContext graphicsContext(static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]));
+
+ _findIndicator->draw(graphicsContext, enclosingIntRect(rect));
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+@end
+
+@interface WKFindIndicatorWindowAnimation : NSAnimation<NSAnimationDelegate> {
+ WebKit::FindIndicatorWindow* _findIndicatorWindow;
+ void (WebKit::FindIndicatorWindow::*_animationProgressCallback)(double progress);
+ void (WebKit::FindIndicatorWindow::*_animationDidEndCallback)();
+}
+
+- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow
+ animationDuration:(CFTimeInterval)duration
+ animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
+ animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback;
+@end
+
+@implementation WKFindIndicatorWindowAnimation
+
+- (id)_initWithFindIndicatorWindow:(WebKit::FindIndicatorWindow *)findIndicatorWindow
+ animationDuration:(CFTimeInterval)animationDuration
+ animationProgressCallback:(void (WebKit::FindIndicatorWindow::*)(double progress))animationProgressCallback
+ animationDidEndCallback:(void (WebKit::FindIndicatorWindow::*)())animationDidEndCallback
+{
+ if ((self = [super initWithDuration:animationDuration animationCurve:NSAnimationEaseInOut])) {
+ _findIndicatorWindow = findIndicatorWindow;
+ _animationProgressCallback = animationProgressCallback;
+ _animationDidEndCallback = animationDidEndCallback;
+ [self setDelegate:self];
+ [self setAnimationBlockingMode:NSAnimationNonblocking];
+ }
+ return self;
+}
+
+- (void)setCurrentProgress:(NSAnimationProgress)progress
+{
+ (_findIndicatorWindow->*_animationProgressCallback)(progress);
+}
+
+- (void)animationDidEnd:(NSAnimation *)animation
+{
+ ASSERT(animation == self);
+
+ (_findIndicatorWindow->*_animationDidEndCallback)();
+}
+
+@end
+
+namespace WebKit {
+
+PassOwnPtr<FindIndicatorWindow> FindIndicatorWindow::create(WKView *wkView)
+{
+ return adoptPtr(new FindIndicatorWindow(wkView));
+}
+
+FindIndicatorWindow::FindIndicatorWindow(WKView *wkView)
+ : m_wkView(wkView)
+ , m_bounceAnimationContext(0)
+ , m_startFadeOutTimer(RunLoop::main(), this, &FindIndicatorWindow::startFadeOutTimerFired)
+{
+}
+
+FindIndicatorWindow::~FindIndicatorWindow()
+{
+ closeWindow();
+}
+
+void FindIndicatorWindow::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
+{
+ if (m_findIndicator == findIndicator)
+ return;
+
+ m_findIndicator = findIndicator;
+
+ // Get rid of the old window.
+ closeWindow();
+
+ if (!m_findIndicator)
+ return;
+
+ NSRect contentRect = m_findIndicator->frameRect();
+ NSRect windowFrameRect = NSIntegralRect([m_wkView convertRect:contentRect toView:nil]);
+ windowFrameRect.origin = [[m_wkView window] convertBaseToScreen:windowFrameRect.origin];
+
+ NSRect windowContentRect = [NSWindow contentRectForFrameRect:windowFrameRect styleMask:NSBorderlessWindowMask];
+
+ m_findIndicatorWindow.adoptNS([[NSWindow alloc] initWithContentRect:windowContentRect
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO]);
+
+ [m_findIndicatorWindow.get() setBackgroundColor:[NSColor clearColor]];
+ [m_findIndicatorWindow.get() setOpaque:NO];
+ [m_findIndicatorWindow.get() setIgnoresMouseEvents:YES];
+
+ RetainPtr<WKFindIndicatorView> findIndicatorView(AdoptNS, [[WKFindIndicatorView alloc] _initWithFindIndicator:m_findIndicator]);
+ [m_findIndicatorWindow.get() setContentView:findIndicatorView.get()];
+
+ [[m_wkView window] addChildWindow:m_findIndicatorWindow.get() ordered:NSWindowAbove];
+ [m_findIndicatorWindow.get() setReleasedWhenClosed:NO];
+
+ if (animate) {
+ // Start the bounce animation.
+ m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_findIndicatorWindow.get());
+ m_bounceAnimation.adoptNS([[WKFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
+ animationDuration:bounceAnimationDuration
+ animationProgressCallback:&FindIndicatorWindow::bounceAnimationCallback
+ animationDidEndCallback:&FindIndicatorWindow::bounceAnimationDidEnd]);
+ [m_bounceAnimation.get() startAnimation];
+ }
+
+ if (fadeOut)
+ m_startFadeOutTimer.startOneShot(timeBeforeFadeStarts);
+}
+
+void FindIndicatorWindow::closeWindow()
+{
+ if (!m_findIndicatorWindow)
+ return;
+
+ m_startFadeOutTimer.stop();
+
+ if (m_fadeOutAnimation) {
+ [m_fadeOutAnimation.get() stopAnimation];
+ m_fadeOutAnimation = nullptr;
+ }
+
+ if (m_bounceAnimation) {
+ [m_bounceAnimation.get() stopAnimation];
+ m_bounceAnimation = nullptr;
+ }
+
+ if (m_bounceAnimationContext)
+ WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext);
+
+ [[m_findIndicatorWindow.get() parentWindow] removeChildWindow:m_findIndicatorWindow.get()];
+ [m_findIndicatorWindow.get() close];
+ m_findIndicatorWindow = nullptr;
+}
+
+void FindIndicatorWindow::startFadeOutTimerFired()
+{
+ ASSERT(!m_fadeOutAnimation);
+
+ m_fadeOutAnimation.adoptNS([[WKFindIndicatorWindowAnimation alloc] _initWithFindIndicatorWindow:this
+ animationDuration:fadeOutAnimationDuration
+ animationProgressCallback:&FindIndicatorWindow::fadeOutAnimationCallback
+ animationDidEndCallback:&FindIndicatorWindow::fadeOutAnimationDidEnd]);
+ [m_fadeOutAnimation.get() startAnimation];
+}
+
+void FindIndicatorWindow::fadeOutAnimationCallback(double progress)
+{
+ ASSERT(m_fadeOutAnimation);
+
+ [m_findIndicatorWindow.get() setAlphaValue:1.0 - progress];
+}
+
+void FindIndicatorWindow::fadeOutAnimationDidEnd()
+{
+ ASSERT(m_fadeOutAnimation);
+ ASSERT(m_findIndicatorWindow);
+
+ closeWindow();
+}
+
+void FindIndicatorWindow::bounceAnimationCallback(double progress)
+{
+ ASSERT(m_bounceAnimation);
+ ASSERT(m_bounceAnimationContext);
+
+ WKWindowBounceAnimationSetAnimationProgress(m_bounceAnimationContext, progress);
+}
+
+void FindIndicatorWindow::bounceAnimationDidEnd()
+{
+ ASSERT(m_bounceAnimation);
+ ASSERT(m_bounceAnimationContext);
+ ASSERT(m_findIndicatorWindow);
+
+ WKWindowBounceAnimationContextDestroy(m_bounceAnimationContext);
+ m_bounceAnimationContext = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.h b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
new file mode 100644
index 000000000..3a4f2f600
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#ifndef PDFViewController_h
+#define PDFViewController_h
+
+#include "WebFindOptions.h"
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+@class PDFView;
+@class WKView;
+@class WKPDFView;
+
+namespace CoreIPC {
+ class DataReference;
+}
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class PDFViewController {
+ WTF_MAKE_NONCOPYABLE(PDFViewController);
+
+public:
+ static PassOwnPtr<PDFViewController> create(WKView *);
+ ~PDFViewController();
+
+ WKView* wkView() const { return m_wkView; }
+ WebPageProxy* page() const;
+ NSView* pdfView() const;
+
+ void setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference&);
+
+ double zoomFactor() const;
+ void setZoomFactor(double);
+
+ static Class pdfPreviewViewClass();
+
+ NSPrintOperation *makePrintOperation(NSPrintInfo *);
+ void openPDFInFinder();
+ void savePDFToDownloadsFolder();
+ void linkClicked(const String& url);
+ void print();
+
+ void findString(const String&, FindOptions, unsigned maxMatchCount);
+ void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+
+private:
+ explicit PDFViewController(WKView *wkView);
+
+ static Class pdfDocumentClass();
+ static NSBundle* pdfKitBundle();
+
+ NSString *pathToPDFOnDisk();
+
+ WKView* m_wkView;
+
+ RetainPtr<WKPDFView> m_wkPDFView;
+ PDFView* m_pdfView;
+
+ RetainPtr<NSString> m_suggestedFilename;
+ RetainPtr<CFDataRef> m_pdfData;
+
+ RetainPtr<NSString> m_pathToPDFOnDisk;
+ bool m_hasWrittenPDFToDisk;
+};
+
+} // namespace WebKit
+
+#endif // PDFViewController_h
diff --git a/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
new file mode 100644
index 000000000..c5441a49f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
@@ -0,0 +1,671 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#import "config.h"
+#import "PDFViewController.h"
+
+#import "DataReference.h"
+#import "WKAPICast.h"
+#import "WKViewPrivate.h"
+#import "WebData.h"
+#import "WebEventFactory.h"
+#import "WebPageGroup.h"
+#import "WebPageProxy.h"
+#import "WebPreferences.h"
+#import <PDFKit/PDFKit.h>
+#import <WebCore/LocalizedStrings.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
+
+// Redeclarations of PDFKit notifications. We can't use the API since we use a weak link to the framework.
+#define _webkit_PDFViewDisplayModeChangedNotification @"PDFViewDisplayModeChanged"
+#define _webkit_PDFViewScaleChangedNotification @"PDFViewScaleChanged"
+#define _webkit_PDFViewPageChangedNotification @"PDFViewChangedPage"
+
+using namespace WebKit;
+
+@class PDFDocument;
+@class PDFView;
+
+@interface PDFDocument (PDFDocumentDetails)
+- (NSPrintOperation *)getPrintOperationForPrintInfo:(NSPrintInfo *)printInfo autoRotate:(BOOL)doRotate;
+@end
+
+extern "C" NSString *_NSPathForSystemFramework(NSString *framework);
+
+// MARK: C UTILITY FUNCTIONS
+
+static void _applicationInfoForMIMEType(NSString *type, NSString **name, NSImage **image)
+{
+ ASSERT(name);
+ ASSERT(image);
+
+ CFURLRef appURL = 0;
+
+ OSStatus error = LSCopyApplicationForMIMEType((CFStringRef)type, kLSRolesAll, &appURL);
+ if (error != noErr)
+ return;
+
+ NSString *appPath = [(NSURL *)appURL path];
+ if (appURL)
+ CFRelease(appURL);
+
+ *image = [[NSWorkspace sharedWorkspace] iconForFile:appPath];
+ [*image setSize:NSMakeSize(16, 16)];
+
+ *name = [[NSFileManager defaultManager] displayNameAtPath:appPath];
+}
+
+// FIXME 4182876: We can eliminate this function in favor if -isEqual: if [PDFSelection isEqual:] is overridden
+// to compare contents.
+static BOOL _PDFSelectionsAreEqual(PDFSelection *selectionA, PDFSelection *selectionB)
+{
+ NSArray *aPages = [selectionA pages];
+ NSArray *bPages = [selectionB pages];
+
+ if (![aPages isEqual:bPages])
+ return NO;
+
+ NSUInteger count = [aPages count];
+ for (NSUInteger i = 0; i < count; ++i) {
+ NSRect aBounds = [selectionA boundsForPage:[aPages objectAtIndex:i]];
+ NSRect bBounds = [selectionB boundsForPage:[bPages objectAtIndex:i]];
+ if (!NSEqualRects(aBounds, bBounds))
+ return NO;
+ }
+
+ return YES;
+}
+
+@interface WKPDFView : NSView
+{
+ PDFViewController* _pdfViewController;
+
+ RetainPtr<NSView> _pdfPreviewView;
+ PDFView *_pdfView;
+ BOOL _ignoreScaleAndDisplayModeAndPageNotifications;
+ BOOL _willUpdatePreferencesSoon;
+}
+
+- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController;
+- (void)invalidate;
+- (PDFView *)pdfView;
+- (void)setDocument:(PDFDocument *)pdfDocument;
+
+- (void)_applyPDFPreferences;
+- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection;
+@end
+
+@implementation WKPDFView
+
+- (id)initWithFrame:(NSRect)frame PDFViewController:(PDFViewController*)pdfViewController
+{
+ if ((self = [super initWithFrame:frame])) {
+ _pdfViewController = pdfViewController;
+
+ [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ Class previewViewClass = PDFViewController::pdfPreviewViewClass();
+ ASSERT(previewViewClass);
+
+ _pdfPreviewView.adoptNS([[previewViewClass alloc] initWithFrame:frame]);
+ [_pdfPreviewView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+ [self addSubview:_pdfPreviewView.get()];
+
+ _pdfView = [_pdfPreviewView.get() performSelector:@selector(pdfView)];
+ [_pdfView setDelegate:self];
+ }
+
+ return self;
+}
+
+- (void)invalidate
+{
+ _pdfViewController = 0;
+}
+
+- (PDFView *)pdfView
+{
+ return _pdfView;
+}
+
+- (void)setDocument:(PDFDocument *)pdfDocument
+{
+ _ignoreScaleAndDisplayModeAndPageNotifications = YES;
+ [_pdfView setDocument:pdfDocument];
+ [self _applyPDFPreferences];
+ _ignoreScaleAndDisplayModeAndPageNotifications = NO;
+}
+
+- (void)_applyPDFPreferences
+{
+ if (!_pdfViewController)
+ return;
+
+ WebPreferences *preferences = _pdfViewController->page()->pageGroup()->preferences();
+
+ CGFloat scaleFactor = preferences->pdfScaleFactor();
+ if (!scaleFactor)
+ [_pdfView setAutoScales:YES];
+ else {
+ [_pdfView setAutoScales:NO];
+ [_pdfView setScaleFactor:scaleFactor];
+ }
+ [_pdfView setDisplayMode:preferences->pdfDisplayMode()];
+}
+
+- (void)_updatePreferences:(id)ignored
+{
+ _willUpdatePreferencesSoon = NO;
+
+ if (!_pdfViewController)
+ return;
+
+ WebPreferences* preferences = _pdfViewController->page()->pageGroup()->preferences();
+
+ CGFloat scaleFactor = [_pdfView autoScales] ? 0 : [_pdfView scaleFactor];
+ preferences->setPDFScaleFactor(scaleFactor);
+ preferences->setPDFDisplayMode([_pdfView displayMode]);
+}
+
+- (void)_updatePreferencesSoon
+{
+ if (_willUpdatePreferencesSoon)
+ return;
+
+ [self performSelector:@selector(_updatePreferences:) withObject:nil afterDelay:0];
+ _willUpdatePreferencesSoon = YES;
+}
+
+- (void)_scaleOrDisplayModeOrPageChanged:(NSNotification *)notification
+{
+ ASSERT_ARG(notification, [notification object] == _pdfView);
+ if (!_ignoreScaleAndDisplayModeAndPageNotifications)
+ [self _updatePreferencesSoon];
+}
+
+- (void)_openWithFinder:(id)sender
+{
+ _pdfViewController->openPDFInFinder();
+}
+
+- (PDFSelection *)_nextMatchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag fromSelection:(PDFSelection *)initialSelection startInSelection:(BOOL)startInSelection
+{
+ if (![string length])
+ return nil;
+
+ int options = 0;
+ if (!forward)
+ options |= NSBackwardsSearch;
+
+ if (!caseFlag)
+ options |= NSCaseInsensitiveSearch;
+
+ PDFDocument *document = [_pdfView document];
+
+ PDFSelection *selectionForInitialSearch = [initialSelection copy];
+ if (startInSelection) {
+ // Initially we want to include the selected text in the search. So we must modify the starting search
+ // selection to fit PDFDocument's search requirements: selection must have a length >= 1, begin before
+ // the current selection (if searching forwards) or after (if searching backwards).
+ int initialSelectionLength = [[initialSelection string] length];
+ if (forward) {
+ [selectionForInitialSearch extendSelectionAtStart:1];
+ [selectionForInitialSearch extendSelectionAtEnd:-initialSelectionLength];
+ } else {
+ [selectionForInitialSearch extendSelectionAtEnd:1];
+ [selectionForInitialSearch extendSelectionAtStart:-initialSelectionLength];
+ }
+ }
+ PDFSelection *foundSelection = [document findString:string fromSelection:selectionForInitialSearch withOptions:options];
+ [selectionForInitialSearch release];
+
+ // If we first searched in the selection, and we found the selection, search again from just past the selection
+ if (startInSelection && _PDFSelectionsAreEqual(foundSelection, initialSelection))
+ foundSelection = [document findString:string fromSelection:initialSelection withOptions:options];
+
+ if (!foundSelection && wrapFlag)
+ foundSelection = [document findString:string fromSelection:nil withOptions:options];
+
+ return foundSelection;
+}
+
+- (NSUInteger)_countMatches:(NSString *)string caseSensitive:(BOOL)caseFlag
+{
+ if (![string length])
+ return 0;
+
+ int options = caseFlag ? 0 : NSCaseInsensitiveSearch;
+
+ return [[[_pdfView document] findString:string withOptions:options] count];
+}
+
+// MARK: NSView overrides
+
+- (void)viewDidMoveToWindow
+{
+ if (![self window])
+ return;
+
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewScaleChangedNotification object:_pdfView];
+ [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView];
+ [notificationCenter addObserver:self selector:@selector(_scaleOrDisplayModeOrPageChanged:) name:_webkit_PDFViewPageChangedNotification object:_pdfView];
+}
+
+- (void)viewWillMoveToWindow:(NSWindow *)newWindow
+{
+ if (![self window])
+ return;
+
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+ [notificationCenter removeObserver:self name:_webkit_PDFViewScaleChangedNotification object:_pdfView];
+ [notificationCenter removeObserver:self name:_webkit_PDFViewDisplayModeChangedNotification object:_pdfView];
+ [notificationCenter removeObserver:self name:_webkit_PDFViewPageChangedNotification object:_pdfView];
+}
+
+- (NSView *)hitTest:(NSPoint)point
+{
+ // Override hitTest so we can override menuForEvent.
+ NSEvent *event = [NSApp currentEvent];
+ NSEventType type = [event type];
+ if (type == NSRightMouseDown || (type == NSLeftMouseDown && ([event modifierFlags] & NSControlKeyMask)))
+ return self;
+
+ return [super hitTest:point];
+}
+
+static void insertOpenWithDefaultPDFMenuItem(NSMenu *menu, NSUInteger index)
+{
+ // Add in an "Open with <default PDF viewer>" item
+ NSString *appName = nil;
+ NSImage *appIcon = nil;
+
+ _applicationInfoForMIMEType(@"application/pdf", &appName, &appIcon);
+ if (!appName)
+ appName = WEB_UI_STRING("Finder", "Default application name for Open With context menu");
+
+ // To match the PDFKit style, we'll add Open with Preview even when there's no document yet to view, and
+ // disable it using validateUserInterfaceItem.
+ NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Open with %@", "context menu item for PDF"), appName];
+
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:title action:@selector(_openWithFinder:) keyEquivalent:@""];
+ if (appIcon)
+ [item setImage:appIcon];
+ [menu insertItem:item atIndex:index];
+ [item release];
+}
+
+- (NSMenu *)menuForEvent:(NSEvent *)theEvent
+{
+ NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
+
+ bool insertedOpenWithItem = false;
+
+ NSEnumerator *menuItemEnumerator = [[[_pdfView menuForEvent:theEvent] itemArray] objectEnumerator];
+ while (NSMenuItem *item = [menuItemEnumerator nextObject]) {
+ NSMenuItem *itemCopy = [item copy];
+ [menu addItem:itemCopy];
+ [itemCopy release];
+
+ if (insertedOpenWithItem)
+ continue;
+
+ // If a "Copy" item is present, place the "Open With" item just after it, with an intervening separator.
+ if ([item action] != @selector(copy:))
+ continue;
+
+ [menu addItem:[NSMenuItem separatorItem]];
+ insertOpenWithDefaultPDFMenuItem(menu, [menu numberOfItems]);
+ insertedOpenWithItem = true;
+ }
+
+ if (!insertedOpenWithItem) {
+ // No "Copy" item was found; place the "Open With" item at the top of the menu, with a trailing separator.
+ insertOpenWithDefaultPDFMenuItem(menu, 0);
+ [menu insertItem:[NSMenuItem separatorItem] atIndex:1];
+ }
+
+ return [menu autorelease];
+}
+
+// MARK: NSUserInterfaceValidations PROTOCOL IMPLEMENTATION
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+ SEL action = [item action];
+ if (action == @selector(_openWithFinder:))
+ return [_pdfView document] != nil;
+ return YES;
+}
+
+// MARK: PDFView delegate methods
+
+- (void)PDFViewWillClickOnLink:(PDFView *)sender withURL:(NSURL *)URL
+{
+ _pdfViewController->linkClicked([URL absoluteString]);
+}
+
+- (void)PDFViewOpenPDFInNativeApplication:(PDFView *)sender
+{
+ _pdfViewController->openPDFInFinder();
+}
+
+- (void)PDFViewSavePDFToDownloadFolder:(PDFView *)sender
+{
+ _pdfViewController->savePDFToDownloadsFolder();
+}
+
+- (void)PDFViewPerformPrint:(PDFView *)sender
+{
+ _pdfViewController->print();
+}
+
+@end
+
+namespace WebKit {
+
+PassOwnPtr<PDFViewController> PDFViewController::create(WKView *wkView)
+{
+ return adoptPtr(new PDFViewController(wkView));
+}
+
+PDFViewController::PDFViewController(WKView *wkView)
+ : m_wkView(wkView)
+ , m_wkPDFView(AdoptNS, [[WKPDFView alloc] initWithFrame:[m_wkView bounds] PDFViewController:this])
+ , m_pdfView([m_wkPDFView.get() pdfView])
+ , m_hasWrittenPDFToDisk(false)
+{
+ [m_wkView addSubview:m_wkPDFView.get()];
+}
+
+PDFViewController::~PDFViewController()
+{
+ [m_wkPDFView.get() removeFromSuperview];
+ [m_wkPDFView.get() invalidate];
+ m_wkPDFView = nullptr;
+}
+
+WebPageProxy* PDFViewController::page() const
+{
+ return toImpl([m_wkView pageRef]);
+}
+
+NSView* PDFViewController::pdfView() const
+{
+ return m_wkPDFView.get();
+}
+
+static RetainPtr<CFDataRef> convertPostScriptDataSourceToPDF(const CoreIPC::DataReference& dataReference)
+{
+ // Convert PostScript to PDF using Quartz 2D API
+ // http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_ps_convert/chapter_16_section_1.html
+
+ CGPSConverterCallbacks callbacks = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ RetainPtr<CGPSConverterRef> converter(AdoptCF, CGPSConverterCreate(0, &callbacks, 0));
+ ASSERT(converter);
+
+ RetainPtr<NSData> nsData(AdoptNS, [[NSData alloc] initWithBytesNoCopy:const_cast<uint8_t*>(dataReference.data()) length:dataReference.size() freeWhenDone:NO]);
+
+ RetainPtr<CGDataProviderRef> provider(AdoptCF, CGDataProviderCreateWithCFData((CFDataRef)nsData.get()));
+ ASSERT(provider);
+
+ RetainPtr<CFMutableDataRef> result(AdoptCF, CFDataCreateMutable(kCFAllocatorDefault, 0));
+ ASSERT(result);
+
+ RetainPtr<CGDataConsumerRef> consumer(AdoptCF, CGDataConsumerCreateWithCFData(result.get()));
+ ASSERT(consumer);
+
+ CGPSConverterConvert(converter.get(), provider.get(), consumer.get(), 0);
+
+ if (!result)
+ return 0;
+
+ return result;
+}
+
+void PDFViewController::setPDFDocumentData(const String& mimeType, const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
+{
+ if (equalIgnoringCase(mimeType, "application/postscript")) {
+ m_pdfData = convertPostScriptDataSourceToPDF(dataReference);
+ if (!m_pdfData)
+ return;
+ m_suggestedFilename = String(suggestedFilename + ".pdf");
+ } else {
+ // Make sure to copy the data.
+ m_pdfData.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size()));
+ m_suggestedFilename = suggestedFilename;
+ }
+
+ RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)m_pdfData.get()]);
+ [m_wkPDFView.get() setDocument:pdfDocument.get()];
+}
+
+double PDFViewController::zoomFactor() const
+{
+ return [m_pdfView scaleFactor];
+}
+
+void PDFViewController::setZoomFactor(double zoomFactor)
+{
+ [m_pdfView setScaleFactor:zoomFactor];
+}
+
+Class PDFViewController::pdfDocumentClass()
+{
+ static Class pdfDocumentClass = [pdfKitBundle() classNamed:@"PDFDocument"];
+
+ return pdfDocumentClass;
+}
+
+Class PDFViewController::pdfPreviewViewClass()
+{
+ static Class pdfPreviewViewClass = [pdfKitBundle() classNamed:@"PDFPreviewView"];
+
+ return pdfPreviewViewClass;
+}
+
+NSBundle* PDFViewController::pdfKitBundle()
+{
+ static NSBundle *pdfKitBundle;
+ if (pdfKitBundle)
+ return pdfKitBundle;
+
+ NSString *pdfKitPath = [_NSPathForSystemFramework(@"Quartz.framework") stringByAppendingString:@"/Frameworks/PDFKit.framework"];
+ if (!pdfKitPath) {
+ LOG_ERROR("Couldn't find PDFKit.framework");
+ return nil;
+ }
+
+ pdfKitBundle = [NSBundle bundleWithPath:pdfKitPath];
+ if (![pdfKitBundle load])
+ LOG_ERROR("Couldn't load PDFKit.framework");
+ return pdfKitBundle;
+}
+
+NSPrintOperation *PDFViewController::makePrintOperation(NSPrintInfo *printInfo)
+{
+ return [[m_pdfView document] getPrintOperationForPrintInfo:printInfo autoRotate:YES];
+}
+
+void PDFViewController::openPDFInFinder()
+{
+ // We don't want to open the PDF until we have a document to write. (see 4892525).
+ if (![m_pdfView document]) {
+ NSBeep();
+ return;
+ }
+
+ NSString *path = pathToPDFOnDisk();
+ if (!path)
+ return;
+
+ if (!m_hasWrittenPDFToDisk) {
+ // Create a PDF file with the minimal permissions (only accessible to the current user, see 4145714).
+ RetainPtr<NSNumber> permissions(AdoptNS, [[NSNumber alloc] initWithInt:S_IRUSR]);
+ RetainPtr<NSDictionary> fileAttributes(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:permissions.get(), NSFilePosixPermissions, nil]);
+
+ if (![[NSFileManager defaultManager] createFileAtPath:path contents:(NSData *)m_pdfData.get() attributes:fileAttributes.get()])
+ return;
+
+ m_hasWrittenPDFToDisk = true;
+ }
+
+ [[NSWorkspace sharedWorkspace] openFile:path];
+}
+
+static void releaseCFData(unsigned char*, const void* data)
+{
+ ASSERT(CFGetTypeID(data) == CFDataGetTypeID());
+
+ // Balanced by CFRetain in savePDFToDownloadsFolder.
+ CFRelease(data);
+}
+
+void PDFViewController::savePDFToDownloadsFolder()
+{
+ // We don't want to write the file until we have a document to write. (see 5267607).
+ if (![m_pdfView document]) {
+ NSBeep();
+ return;
+ }
+
+ ASSERT(m_pdfData);
+
+ // Balanced by CFRelease in releaseCFData.
+ CFRetain(m_pdfData.get());
+
+ RefPtr<WebData> data = WebData::createWithoutCopying(CFDataGetBytePtr(m_pdfData.get()), CFDataGetLength(m_pdfData.get()), releaseCFData, m_pdfData.get());
+
+ page()->saveDataToFileInDownloadsFolder(m_suggestedFilename.get(), page()->mainFrame()->mimeType(), page()->mainFrame()->url(), data.get());
+}
+
+static NSString *temporaryPDFDirectoryPath()
+{
+ static NSString *temporaryPDFDirectoryPath;
+
+ if (!temporaryPDFDirectoryPath) {
+ NSString *temporaryDirectoryTemplate = [NSTemporaryDirectory() stringByAppendingPathComponent:@"WebKitPDFs-XXXXXX"];
+ CString templateRepresentation = [temporaryDirectoryTemplate fileSystemRepresentation];
+
+ if (mkdtemp(templateRepresentation.mutableData()))
+ temporaryPDFDirectoryPath = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:templateRepresentation.data() length:templateRepresentation.length()] copy];
+ }
+
+ return temporaryPDFDirectoryPath;
+}
+
+NSString *PDFViewController::pathToPDFOnDisk()
+{
+ if (m_pathToPDFOnDisk)
+ return m_pathToPDFOnDisk.get();
+
+ NSString *pdfDirectoryPath = temporaryPDFDirectoryPath();
+ if (!pdfDirectoryPath)
+ return nil;
+
+ NSString *path = [pdfDirectoryPath stringByAppendingPathComponent:m_suggestedFilename.get()];
+
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ if ([fileManager fileExistsAtPath:path]) {
+ NSString *pathTemplatePrefix = [pdfDirectoryPath stringByAppendingPathComponent:@"XXXXXX-"];
+ NSString *pathTemplate = [pathTemplatePrefix stringByAppendingString:m_suggestedFilename.get()];
+ CString pathTemplateRepresentation = [pathTemplate fileSystemRepresentation];
+
+ int fd = mkstemps(pathTemplateRepresentation.mutableData(), pathTemplateRepresentation.length() - strlen([pathTemplatePrefix fileSystemRepresentation]) + 1);
+ if (fd < 0)
+ return nil;
+
+ close(fd);
+ path = [fileManager stringWithFileSystemRepresentation:pathTemplateRepresentation.data() length:pathTemplateRepresentation.length()];
+ }
+
+ m_pathToPDFOnDisk.adoptNS([path copy]);
+ return path;
+}
+
+void PDFViewController::linkClicked(const String& url)
+{
+ NSEvent* nsEvent = [NSApp currentEvent];
+ WebMouseEvent event;
+ switch ([nsEvent type]) {
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ event = WebEventFactory::createWebMouseEvent(nsEvent, m_pdfView);
+ default:
+ // For non mouse-clicks or for keyboard events, pass an empty WebMouseEvent
+ // through. The event is only used by the WebFrameLoaderClient to determine
+ // the modifier keys and which mouse button is down. These queries will be
+ // valid with an empty event.
+ break;
+ }
+
+ page()->linkClicked(url, event);
+}
+
+void PDFViewController::print()
+{
+ page()->printMainFrame();
+}
+
+void PDFViewController::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ BOOL forward = !(options & FindOptionsBackwards);
+ BOOL caseFlag = !(options & FindOptionsCaseInsensitive);
+ BOOL wrapFlag = options & FindOptionsWrapAround;
+
+ PDFSelection *selection = [m_wkPDFView.get() _nextMatchFor:string direction:forward caseSensitive:caseFlag wrap:wrapFlag fromSelection:[m_pdfView currentSelection] startInSelection:NO];
+ if (!selection) {
+ page()->didFailToFindString(string);
+ return;
+ }
+
+ NSUInteger matchCount;
+ if (!maxMatchCount) {
+ // If the max was zero, any result means we exceeded the max. We can skip computing the actual count.
+ matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);
+ } else {
+ matchCount = [m_wkPDFView.get() _countMatches:string caseSensitive:caseFlag];
+ if (matchCount > maxMatchCount)
+ matchCount = static_cast<unsigned>(kWKMoreThanMaximumMatchCount);
+ }
+
+ [m_pdfView setCurrentSelection:selection];
+ [m_pdfView scrollSelectionToVisible:nil];
+ page()->didFindString(string, matchCount);
+}
+
+void PDFViewController::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ BOOL caseFlag = !(options & FindOptionsCaseInsensitive);
+
+ NSUInteger matchCount = [m_wkPDFView.get() _countMatches:string caseSensitive:caseFlag];
+ if (matchCount > maxMatchCount)
+ matchCount = maxMatchCount;
+ page()->didCountStringMatches(string, matchCount);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
new file mode 100644
index 000000000..8e3c5b7aa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#ifndef PageClientImpl_h
+#define PageClientImpl_h
+
+#include "CorrectionPanel.h"
+#include "PageClient.h"
+#include <wtf/RetainPtr.h>
+
+@class WKEditorUndoTargetObjC;
+@class WKView;
+
+namespace WebKit {
+
+class FindIndicatorWindow;
+
+// NOTE: This does not use String::operator NSString*() since that function
+// expects to be called on the thread running WebCore.
+NSString* nsStringFromWebCoreString(const String&);
+
+class PageClientImpl : public PageClient {
+public:
+ static PassOwnPtr<PageClientImpl> create(WKView*);
+ virtual ~PageClientImpl();
+
+private:
+ PageClientImpl(WKView*);
+
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+
+ virtual void processDidCrash();
+ virtual void pageClosed();
+ virtual void didRelaunchProcess();
+ virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setCursorHiddenUntilMouseMoves(bool);
+ virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual bool canUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual void executeUndoRedo(WebPageProxy::UndoOrRedo);
+ virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&);
+ virtual bool executeSavedCommandBySelector(const String& selector);
+ virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag);
+ virtual void updateTextInputState(bool updateSecureInputState);
+ virtual void resetTextInputState();
+
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&);
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&);
+
+ virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled);
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+
+ void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
+
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+
+ virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&);
+
+ virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus);
+ virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState);
+
+ virtual void makeFirstResponder();
+
+ virtual CGContextRef containingWindowGraphicsContext();
+
+ virtual void didChangeScrollbarsForMainFrame() const;
+
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
+
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+ virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount);
+ virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount);
+
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+
+ virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&);
+ virtual void dismissDictionaryLookupPanel();
+
+ virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
+ virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel);
+ virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel);
+ virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString);
+
+ virtual void recommendedScrollbarStyleDidChange(int32_t newStyle);
+
+ virtual WKView* wkView() const { return m_wkView; }
+
+ WKView* m_wkView;
+ RetainPtr<WKEditorUndoTargetObjC> m_undoTarget;
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ CorrectionPanel m_correctionPanel;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // PageClientImpl_h
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
new file mode 100644
index 000000000..c1ae66643
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -0,0 +1,496 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#import "config.h"
+#import "PageClientImpl.h"
+
+#import "DataReference.h"
+#import "DictionaryPopupInfo.h"
+#import "FindIndicator.h"
+#import "NativeWebKeyboardEvent.h"
+#import "WKAPICast.h"
+#import "WKStringCF.h"
+#import "WKViewInternal.h"
+#import "WebContextMenuProxyMac.h"
+#import "WebEditCommandProxy.h"
+#import "WebPopupMenuProxyMac.h"
+#import <WebCore/Cursor.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/FoundationExtras.h>
+#import <WebCore/GraphicsContext.h>
+#import <WebCore/KeyboardEvent.h>
+#import <WebCore/NotImplemented.h>
+#import <wtf/PassOwnPtr.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
+#import <WebKitSystemInterface.h>
+
+@interface NSApplication (WebNSApplicationDetails)
+- (NSCursor *)_cursorRectCursor;
+@end
+
+using namespace WebCore;
+using namespace WebKit;
+
+@interface WKEditCommandObjC : NSObject
+{
+ RefPtr<WebEditCommandProxy> m_command;
+}
+- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command;
+- (WebEditCommandProxy*)command;
+@end
+
+@interface WKEditorUndoTargetObjC : NSObject
+- (void)undoEditing:(id)sender;
+- (void)redoEditing:(id)sender;
+@end
+
+@implementation WKEditCommandObjC
+
+- (id)initWithWebEditCommandProxy:(PassRefPtr<WebEditCommandProxy>)command
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ m_command = command;
+ return self;
+}
+
+- (WebEditCommandProxy*)command
+{
+ return m_command.get();
+}
+
+@end
+
+@implementation WKEditorUndoTargetObjC
+
+- (void)undoEditing:(id)sender
+{
+ ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
+ [sender command]->unapply();
+}
+
+- (void)redoEditing:(id)sender
+{
+ ASSERT([sender isKindOfClass:[WKEditCommandObjC class]]);
+ [sender command]->reapply();
+}
+
+@end
+
+namespace WebKit {
+
+NSString* nsStringFromWebCoreString(const String& string)
+{
+ return string.impl() ? HardAutorelease(WKStringCopyCFString(0, toAPI(string.impl()))) : @"";
+}
+
+PassOwnPtr<PageClientImpl> PageClientImpl::create(WKView* wkView)
+{
+ return adoptPtr(new PageClientImpl(wkView));
+}
+
+PageClientImpl::PageClientImpl(WKView* wkView)
+ : m_wkView(wkView)
+ , m_undoTarget(AdoptNS, [[WKEditorUndoTargetObjC alloc] init])
+{
+}
+
+PageClientImpl::~PageClientImpl()
+{
+}
+
+PassOwnPtr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
+{
+ return [m_wkView _createDrawingAreaProxy];
+}
+
+void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ [m_wkView setNeedsDisplayInRect:rect];
+}
+
+void PageClientImpl::displayView()
+{
+ [m_wkView displayIfNeeded];
+}
+
+void PageClientImpl::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ NSRect clippedScrollRect = NSIntersectionRect(scrollRect, NSOffsetRect(scrollRect, -scrollOffset.width(), -scrollOffset.height()));
+
+ [m_wkView _cacheWindowBottomCornerRect];
+
+ [m_wkView translateRectsNeedingDisplayInRect:clippedScrollRect by:scrollOffset];
+ [m_wkView scrollRect:clippedScrollRect by:scrollOffset];
+}
+
+IntSize PageClientImpl::viewSize()
+{
+ return IntSize([m_wkView bounds].size);
+}
+
+bool PageClientImpl::isViewWindowActive()
+{
+ return [[m_wkView window] isKeyWindow] || [NSApp keyWindow] == [m_wkView window];
+}
+
+bool PageClientImpl::isViewFocused()
+{
+ return [m_wkView _isFocused];
+}
+
+void PageClientImpl::makeFirstResponder()
+{
+ [[m_wkView window] makeFirstResponder:m_wkView];
+}
+
+bool PageClientImpl::isViewVisible()
+{
+ if (![m_wkView window])
+ return false;
+
+ if (![[m_wkView window] isVisible])
+ return false;
+
+ if ([m_wkView isHiddenOrHasHiddenAncestor])
+ return false;
+
+ return true;
+}
+
+bool PageClientImpl::isViewInWindow()
+{
+ return [m_wkView window];
+}
+
+void PageClientImpl::processDidCrash()
+{
+ [m_wkView _processDidCrash];
+}
+
+void PageClientImpl::pageClosed()
+{
+ [m_wkView _pageClosed];
+}
+
+void PageClientImpl::didRelaunchProcess()
+{
+ [m_wkView _didRelaunchProcess];
+}
+
+void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
+{
+ [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
+}
+
+void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
+{
+ if (![NSApp _cursorRectCursor])
+ [m_wkView _setCursor:cursor.platformCursor()];
+}
+
+void PageClientImpl::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+ [NSCursor setHiddenUntilMouseMoves:hiddenUntilMouseMoves];
+}
+
+void PageClientImpl::didChangeViewportProperties(const WebCore::ViewportArguments&)
+{
+}
+
+void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ RefPtr<WebEditCommandProxy> command = prpCommand;
+
+ RetainPtr<WKEditCommandObjC> commandObjC(AdoptNS, [[WKEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
+ String actionName = WebEditCommandProxy::nameForEditAction(command->editAction());
+
+ NSUndoManager *undoManager = [m_wkView undoManager];
+ [undoManager registerUndoWithTarget:m_undoTarget.get() selector:((undoOrRedo == WebPageProxy::Undo) ? @selector(undoEditing:) : @selector(redoEditing:)) object:commandObjC.get()];
+ if (!actionName.isEmpty())
+ [undoManager setActionName:(NSString *)actionName];
+}
+
+void PageClientImpl::clearAllEditCommands()
+{
+ [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
+}
+
+bool PageClientImpl::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] canUndo] : [[m_wkView undoManager] canRedo];
+}
+
+void PageClientImpl::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return (undoOrRedo == WebPageProxy::Undo) ? [[m_wkView undoManager] undo] : [[m_wkView undoManager] redo];
+}
+
+bool PageClientImpl::interpretKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commands)
+{
+ return [m_wkView _interpretKeyEvent:event.nativeEvent() savingCommandsTo:commands];
+}
+
+void PageClientImpl::setDragImage(const IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag)
+{
+ RetainPtr<CGImageRef> dragCGImage = dragImage->makeCGImage();
+ RetainPtr<NSImage> dragNSImage(AdoptNS, [[NSImage alloc] initWithCGImage:dragCGImage.get() size:dragImage->size()]);
+
+ [m_wkView _setDragImage:dragNSImage.get() at:clientPosition linkDrag:isLinkDrag];
+}
+
+void PageClientImpl::updateTextInputState(bool updateSecureInputState)
+{
+ [m_wkView _updateTextInputStateIncludingSecureInputState:updateSecureInputState];
+}
+
+void PageClientImpl::resetTextInputState()
+{
+ [m_wkView _resetTextInputState];
+}
+
+FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
+{
+ return [m_wkView _convertToDeviceSpace:rect];
+}
+
+FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
+{
+ return [m_wkView _convertToUserSpace:rect];
+}
+
+IntPoint PageClientImpl::screenToWindow(const IntPoint& point)
+{
+ NSPoint windowCoord = [[m_wkView window] convertScreenToBase:point];
+ return IntPoint([m_wkView convertPoint:windowCoord fromView:nil]);
+}
+
+IntRect PageClientImpl::windowToScreen(const IntRect& rect)
+{
+ NSRect tempRect = rect;
+ tempRect = [m_wkView convertRect:tempRect toView:nil];
+ tempRect.origin = [[m_wkView window] convertBaseToScreen:tempRect.origin];
+ return enclosingIntRect(tempRect);
+}
+
+void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
+{
+ [m_wkView _doneWithKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
+}
+
+PassRefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy* page)
+{
+ return WebPopupMenuProxyMac::create(m_wkView, page);
+}
+
+PassRefPtr<WebContextMenuProxy> PageClientImpl::createContextMenuProxy(WebPageProxy* page)
+{
+ return WebContextMenuProxyMac::create(m_wkView, page);
+}
+
+void PageClientImpl::setFindIndicator(PassRefPtr<FindIndicator> findIndicator, bool fadeOut, bool animate)
+{
+ [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut animate:animate];
+}
+
+void PageClientImpl::accessibilityWebProcessTokenReceived(const CoreIPC::DataReference& data)
+{
+ NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
+ [m_wkView _setAccessibilityWebProcessToken:remoteToken];
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void PageClientImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+ [m_wkView _enterAcceleratedCompositingMode:layerTreeContext];
+}
+
+void PageClientImpl::exitAcceleratedCompositingMode()
+{
+ [m_wkView _exitAcceleratedCompositingMode];
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void PageClientImpl::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
+{
+ [m_wkView _pluginFocusOrWindowFocusChanged:pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
+}
+
+void PageClientImpl::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState pluginComplexTextInputState)
+{
+ [m_wkView _setPluginComplexTextInputState:pluginComplexTextInputState pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
+}
+
+CGContextRef PageClientImpl::containingWindowGraphicsContext()
+{
+ NSWindow *window = [m_wkView window];
+
+ // Don't try to get the graphics context if the NSWindow doesn't have a window device.
+ if ([window windowNumber] <= 0)
+ return 0;
+
+ return static_cast<CGContextRef>([[window graphicsContext] graphicsPort]);
+}
+
+void PageClientImpl::didChangeScrollbarsForMainFrame() const
+{
+ [m_wkView _didChangeScrollbarsForMainFrame];
+}
+
+void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+ [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
+}
+
+void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
+{
+ [m_wkView _didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:suggestedFilename dataReference:dataReference];
+}
+
+double PageClientImpl::customRepresentationZoomFactor()
+{
+ return [m_wkView _customRepresentationZoomFactor];
+}
+
+void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor)
+{
+ [m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
+}
+
+void PageClientImpl::findStringInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ [m_wkView _findStringInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
+}
+
+void PageClientImpl::countStringMatchesInCustomRepresentation(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ [m_wkView _countStringMatchesInCustomRepresentation:string withFindOptions:options maxMatchCount:maxMatchCount];
+}
+
+void PageClientImpl::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void PageClientImpl::didPerformDictionaryLookup(const String& text, double scaleFactor, const DictionaryPopupInfo& dictionaryPopupInfo)
+{
+ NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(NSDictionary *)dictionaryPopupInfo.fontInfo.fontAttributeDictionary.get()];
+ NSFont *font = [NSFont fontWithDescriptor:fontDescriptor size:((scaleFactor != 1) ? [fontDescriptor pointSize] * scaleFactor : 0)];
+
+ RetainPtr<NSMutableAttributedString> attributedString(AdoptNS, [[NSMutableAttributedString alloc] initWithString:nsStringFromWebCoreString(text)]);
+ [attributedString.get() addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, [attributedString.get() length])];
+
+ NSPoint textBaselineOrigin = dictionaryPopupInfo.origin;
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // Convert to screen coordinates.
+ textBaselineOrigin = [m_wkView convertPoint:textBaselineOrigin toView:nil];
+ textBaselineOrigin = [m_wkView.window convertRectToScreen:NSMakeRect(textBaselineOrigin.x, textBaselineOrigin.y, 0, 0)].origin;
+
+ WKShowWordDefinitionWindow(attributedString.get(), textBaselineOrigin, (NSDictionary *)dictionaryPopupInfo.options.get());
+#else
+ // If the dictionary lookup is being triggered by a hot key, force the overlay style.
+ NSDictionary *options = (dictionaryPopupInfo.type == DictionaryPopupInfo::HotKey) ? [NSDictionary dictionaryWithObject:NSDefinitionPresentationTypeOverlay forKey:NSDefinitionPresentationTypeKey] : 0;
+ [m_wkView showDefinitionForAttributedString:attributedString.get() range:NSMakeRange(0, [attributedString.get() length]) options:options baselineOriginProvider:^(NSRange adjustedRange) { return (NSPoint)textBaselineOrigin; }];
+#endif
+}
+
+void PageClientImpl::dismissDictionaryLookupPanel()
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ WKHideWordDefinitionWindow();
+#endif
+}
+
+void PageClientImpl::showCorrectionPanel(CorrectionPanelInfo::PanelType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (!isViewVisible() || !isViewInWindow())
+ return;
+ m_correctionPanel.show(m_wkView, type, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
+#endif
+}
+
+void PageClientImpl::dismissCorrectionPanel(ReasonForDismissingCorrectionPanel reason)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ m_correctionPanel.dismiss(reason);
+#endif
+}
+
+String PageClientImpl::dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel reason)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ return m_correctionPanel.dismiss(reason);
+#else
+ return String();
+#endif
+}
+
+void PageClientImpl::recordAutocorrectionResponse(EditorClient::AutocorrectionResponseType responseType, const String& replacedString, const String& replacementString)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSCorrectionResponse response = responseType == EditorClient::AutocorrectionReverted ? NSCorrectionResponseReverted : NSCorrectionResponseEdited;
+ CorrectionPanel::recordAutocorrectionResponse(m_wkView, response, replacedString, replacementString);
+#endif
+}
+
+void PageClientImpl::recommendedScrollbarStyleDidChange(int32_t newStyle)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSArray *trackingAreas = [m_wkView trackingAreas];
+ NSUInteger count = [trackingAreas count];
+ ASSERT(count == 1);
+
+ for (NSUInteger i = 0; i < count; ++i)
+ [m_wkView removeTrackingArea:[trackingAreas objectAtIndex:i]];
+
+ // Now re-create a tracking area with the appropriate options given the new scrollbar style
+ NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
+ if (newStyle == NSScrollerStyleLegacy)
+ options |= NSTrackingActiveAlways;
+ else
+ options |= NSTrackingActiveInKeyWindow;
+
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:[m_wkView frame]
+ options:options
+ owner:m_wkView
+ userInfo:nil];
+ [m_wkView addTrackingArea:trackingArea];
+ [trackingArea release];
+#else
+ UNUSED_PARAM(newStyle);
+#endif
+}
+
+bool PageClientImpl::executeSavedCommandBySelector(const String& selectorString)
+{
+ return [m_wkView _executeSavedCommandBySelector:NSSelectorFromString(selectorString)];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
new file mode 100644
index 000000000..a79fc6afc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextControllerData;
+@protocol WKBrowsingContextLoadDelegate;
+
+WK_EXPORT
+@interface WKBrowsingContextController : NSObject {
+@private
+ WKBrowsingContextControllerData *_data;
+}
+
+#pragma mark Delegates
+
+@property(assign) id<WKBrowsingContextLoadDelegate> loadDelegate;
+
+
+#pragma mark Loading
+
+/* Load a request. This is only valid for requests of non-file: URLs. Passing a
+ file: URL will throw an exception. */
+- (void)loadRequest:(NSURLRequest *)request;
+
+/* Load a file: URL. Opens the sandbox only for files within allowedDirectory.
+ - Passing a non-file: URL to either parameter will yeild an exception.
+ - Passing nil as the allowedDirectory will open the entire file-system for
+ reading.
+*/
+- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory;
+
+/* Stops the load associated with the active URL. */
+- (void)stopLoading;
+
+/* Reload the currently active URL. */
+- (void)reload;
+
+/* Reload the currently active URL, bypassing caches. */
+- (void)reloadFromOrigin;
+
+
+#pragma mark Back/Forward
+
+/* Go to the next page in the back/forward list. */
+- (void)goForward;
+
+/* Whether there is a next page in the back/forward list. */
+@property(readonly) BOOL canGoForward;
+
+/* Go to the previous page in the back/forward list. */
+- (void)goBack;
+
+/* Whether there is a previous page in the back/forward list. */
+@property(readonly) BOOL canGoBack;
+
+
+#pragma mark Active Load Introspection
+
+/* URL for the active load. This is the URL that should be shown in user interface. */
+@property(readonly) NSURL *activeURL;
+
+/* URL for a request that has been sent, but no response has been recieved yet. */
+@property(readonly) NSURL *provisionalURL;
+
+/* URL for a request that has been recieved, and is now being used. */
+@property(readonly) NSURL *committedURL;
+
+
+#pragma mark Active Document Introspection
+
+/* Title of the document associated with the active load. */
+@property(readonly) NSString *title;
+
+
+#pragma mark Zoom
+
+/* Sets the text zoom for the active URL. */
+@property CGFloat textZoom;
+
+/* Sets the text zoom for the active URL. */
+@property CGFloat pageZoom;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
new file mode 100644
index 000000000..955b93045
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextController.mm
@@ -0,0 +1,373 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+#import "WKBrowsingContextController.h"
+#import "WKBrowsingContextControllerPrivate.h"
+#import "WKBrowsingContextControllerInternal.h"
+
+#import "WKErrorCF.h"
+#import "WKFrame.h"
+#import "WKPagePrivate.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
+#import "WKURLCF.h"
+#import "WKURLRequest.h"
+#import "WKURLRequestNS.h"
+#import <wtf/RetainPtr.h>
+
+#import "WKBrowsingContextLoadDelegate.h"
+
+static inline NSString *autoreleased(WKStringRef string)
+{
+ WKRetainPtr<WKStringRef> wkString = adoptWK(string);
+ return [(NSString *)WKStringCopyCFString(kCFAllocatorDefault, wkString.get()) autorelease];
+}
+
+static inline NSURL *autoreleased(WKURLRef url)
+{
+ WKRetainPtr<WKURLRef> wkURL = adoptWK(url);
+ return [(NSURL *)WKURLCopyCFURL(kCFAllocatorDefault, wkURL.get()) autorelease];
+}
+
+
+@interface WKBrowsingContextControllerData : NSObject {
+@public
+ // Underlying WKPageRef.
+ WKRetainPtr<WKPageRef> _pageRef;
+
+ // Delegate for load callbacks.
+ id<WKBrowsingContextLoadDelegate> _loadDelegate;
+}
+@end
+
+@implementation WKBrowsingContextControllerData
+@end
+
+
+@interface WKBrowsingContextController ()
+
+@property(readonly) WKPageRef _pageRef;
+
+@end
+
+
+@implementation WKBrowsingContextController
+
+- (void)dealloc
+{
+ WKPageSetPageLoaderClient(_data->_pageRef.get(), 0);
+
+ [_data release];
+ [super dealloc];
+}
+
+- (WKPageRef)_pageRef
+{
+ return _data->_pageRef.get();
+}
+
+#pragma mark Delegates
+
+- (id<WKBrowsingContextLoadDelegate>)loadDelegate
+{
+ return _data->_loadDelegate;
+}
+
+- (void)setLoadDelegate:(id<WKBrowsingContextLoadDelegate>)loadDelegate
+{
+ _data->_loadDelegate = loadDelegate;
+}
+
+#pragma mark Loading
+
+- (void)loadRequest:(NSURLRequest *)request
+{
+ WKRetainPtr<WKURLRequestRef> wkRequest = adoptWK(WKURLRequestCreateWithNSURLRequest(request));
+ WKPageLoadURLRequest(self._pageRef, wkRequest.get());
+}
+
+- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory
+{
+ if (![URL isFileURL])
+ return;
+
+ /* FIXME: Implement restrictions. */
+
+ WKRetainPtr<WKURLRef> wkURL = adoptWK(WKURLCreateWithCFURL((CFURLRef)URL));
+ WKPageLoadURL(self._pageRef, wkURL.get());
+}
+
+- (void)stopLoading
+{
+ WKPageStopLoading(self._pageRef);
+}
+
+- (void)reload
+{
+ WKPageReload(self._pageRef);
+}
+
+- (void)reloadFromOrigin
+{
+ WKPageReloadFromOrigin(self._pageRef);
+}
+
+#pragma mark Back/Forward
+
+- (void)goForward
+{
+ WKPageGoForward(self._pageRef);
+}
+
+- (BOOL)canGoForward
+{
+ return WKPageCanGoForward(self._pageRef);
+}
+
+- (void)goBack
+{
+ WKPageGoBack(self._pageRef);
+}
+
+- (BOOL)canGoBack
+{
+ return WKPageCanGoBack(self._pageRef);
+}
+
+
+#pragma mark Active Load Introspection
+
+- (NSURL *)activeURL
+{
+ return autoreleased(WKPageCopyActiveURL(self._pageRef));
+}
+
+- (NSURL *)provisionalURL
+{
+ return autoreleased(WKPageCopyProvisionalURL(self._pageRef));
+}
+
+- (NSURL *)committedURL
+{
+ return autoreleased(WKPageCopyCommittedURL(self._pageRef));
+}
+
+#pragma mark Active Document Introspection
+
+- (NSString *)title
+{
+ return autoreleased(WKPageCopyTitle(self._pageRef));
+}
+
+#pragma mark Zoom
+
+- (CGFloat)textZoom
+{
+ return WKPageGetTextZoomFactor(self._pageRef);
+}
+
+- (void)setTextZoom:(CGFloat)textZoom
+{
+ return WKPageSetTextZoomFactor(self._pageRef, textZoom);
+}
+
+- (CGFloat)pageZoom
+{
+ return WKPageGetPageZoomFactor(self._pageRef);
+}
+
+- (void)setPageZoom:(CGFloat)pageZoom
+{
+ return WKPageSetPageZoomFactor(self._pageRef, pageZoom);
+}
+
+@end
+
+@implementation WKBrowsingContextController (Private)
+
+- (void)setPaginationMode:(WKBrowsingContextPaginationMode)paginationMode
+{
+ WKPaginationMode mode;
+ switch (paginationMode) {
+ case WKPaginationModeUnpaginated:
+ mode = kWKPaginationModeUnpaginated;
+ break;
+ case WKPaginationModeHorizontal:
+ mode = kWKPaginationModeHorizontal;
+ break;
+ case WKPaginationModeVertical:
+ mode = kWKPaginationModeVertical;
+ break;
+ default:
+ return;
+ }
+
+ WKPageSetPaginationMode(self._pageRef, mode);
+}
+
+- (WKBrowsingContextPaginationMode)paginationMode
+{
+ switch (WKPageGetPaginationMode(self._pageRef)) {
+ case kWKPaginationModeUnpaginated:
+ return WKPaginationModeUnpaginated;
+ case kWKPaginationModeHorizontal:
+ return WKPaginationModeHorizontal;
+ case kWKPaginationModeVertical:
+ return WKPaginationModeVertical;
+ }
+
+ ASSERT_NOT_REACHED();
+ return WKPaginationModeUnpaginated;
+}
+
+- (void)setPageLength:(CGFloat)pageLength
+{
+ WKPageSetPageLength(self._pageRef, pageLength);
+}
+
+- (CGFloat)pageLength
+{
+ return WKPageGetPageLength(self._pageRef);
+}
+
+- (void)setGapBetweenPages:(CGFloat)gapBetweenPages
+{
+ WKPageSetGapBetweenPages(self._pageRef, gapBetweenPages);
+}
+
+- (CGFloat)gapBetweenPages
+{
+ return WKPageGetGapBetweenPages(self._pageRef);
+}
+
+- (NSUInteger)pageCount
+{
+ return WKPageGetPageCount(self._pageRef);
+}
+
+@end
+
+@implementation WKBrowsingContextController (Internal)
+
+static void didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidStartProvisionalLoad:)])
+ [browsingContext.loadDelegate browsingContextControllerDidStartProvisionalLoad:browsingContext];
+}
+
+static void didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:)])
+ [browsingContext.loadDelegate browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:browsingContext];
+}
+
+static void didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailProvisionalLoad:withError:)]) {
+ RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
+ [browsingContext.loadDelegate browsingContextControllerDidFailProvisionalLoad:browsingContext withError:(NSError *)cfError.get()];
+ }
+}
+
+static void didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidCommitLoad:)])
+ [browsingContext.loadDelegate browsingContextControllerDidCommitLoad:browsingContext];
+}
+
+static void didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFinishLoad:)])
+ [browsingContext.loadDelegate browsingContextControllerDidFinishLoad:browsingContext];
+}
+
+static void didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+
+ WKBrowsingContextController *browsingContext = (WKBrowsingContextController *)clientInfo;
+ if ([browsingContext.loadDelegate respondsToSelector:@selector(browsingContextControllerDidFailLoad:withError:)]) {
+ RetainPtr<CFErrorRef> cfError(AdoptCF, WKErrorCopyCFError(kCFAllocatorDefault, error));
+ [browsingContext.loadDelegate browsingContextControllerDidFailLoad:browsingContext withError:(NSError *)cfError.get()];
+ }
+}
+
+static void setUpPageLoaderClient(WKBrowsingContextController *browsingContext, WKPageRef pageRef)
+{
+ WKPageLoaderClient loaderClient;
+ memset(&loaderClient, 0, sizeof(loaderClient));
+
+ loaderClient.version = kWKPageLoaderClientCurrentVersion;
+ loaderClient.clientInfo = browsingContext;
+ loaderClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+ loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame;
+ loaderClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
+ loaderClient.didCommitLoadForFrame = didCommitLoadForFrame;
+ loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ loaderClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
+
+ WKPageSetPageLoaderClient(pageRef, &loaderClient);
+}
+
+
+/* This should only be called from associate view. */
+
+- (id)_initWithPageRef:(WKPageRef)pageRef
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _data = [[WKBrowsingContextControllerData alloc] init];
+ _data->_pageRef = pageRef;
+
+ setUpPageLoaderClient(self, pageRef);
+
+ return self;
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerInternal.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerInternal.h
new file mode 100644
index 000000000..b9452adfc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerInternal.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKBrowsingContextController.h>
+
+@interface WKBrowsingContextController (Internal)
+
+/* This should only be called from associate view. */
+- (id)_initWithPageRef:(WKPageRef)pageRef;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerPrivate.h
new file mode 100644
index 000000000..3585642d3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextControllerPrivate.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKBrowsingContextController.h>
+
+enum {
+ WKPaginationModeUnpaginated,
+ WKPaginationModeHorizontal,
+ WKPaginationModeVertical,
+};
+typedef NSUInteger WKBrowsingContextPaginationMode;
+
+@interface WKBrowsingContextController (Private)
+
+@property WKBrowsingContextPaginationMode paginationMode;
+// Set to 0 to have the page length equal the view length.
+@property CGFloat pageLength;
+@property CGFloat gapBetweenPages;
+
+@property(readonly) NSUInteger pageCount;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h
new file mode 100644
index 000000000..f3428fc93
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextGroupData;
+
+WK_EXPORT
+@interface WKBrowsingContextGroup : NSObject {
+@private
+ WKBrowsingContextGroupData *_data;
+}
+
+- (id)initWithIdentifier:(NSString *)identifier;
+
+
+/* Settings */
+
+/* Setting to control whether JavaScript referenced by a page is enabled.
+ Default: YES
+*/
+@property BOOL allowsJavaScript;
+
+/* Setting to control whether plug-ins are enabled.
+ Default: YES
+*/
+@property BOOL allowsPlugIns;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm
new file mode 100644
index 000000000..338d390ca
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroup.mm
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+#import "WKBrowsingContextGroup.h"
+#import "WKBrowsingContextGroupInternal.h"
+
+#import "WKPageGroup.h"
+#import "WKPreferences.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
+
+@interface WKBrowsingContextGroupData : NSObject {
+@public
+ WKRetainPtr<WKPageGroupRef> _pageGroupRef;
+}
+@end
+
+@implementation WKBrowsingContextGroupData
+@end
+
+@implementation WKBrowsingContextGroup
+
+- (id)initWithIdentifier:(NSString *)identifier
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _data = [[WKBrowsingContextGroupData alloc] init];
+ _data->_pageGroupRef = adoptWK(WKPageGroupCreateWithIdentifier(adoptWK(WKStringCreateWithCFString((CFStringRef)identifier)).get()));
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [_data release];
+ [super dealloc];
+}
+
+- (BOOL)allowsJavaScript
+{
+ return WKPreferencesGetJavaScriptEnabled(WKPageGroupGetPreferences(self._pageGroupRef));
+}
+
+- (void)setAllowsJavaScript:(BOOL)allowsJavaScript
+{
+ WKPreferencesSetJavaScriptEnabled(WKPageGroupGetPreferences(self._pageGroupRef), allowsJavaScript);
+}
+
+- (BOOL)allowsPlugIns
+{
+ return WKPreferencesGetPluginsEnabled(WKPageGroupGetPreferences(self._pageGroupRef));
+}
+
+- (void)setAllowsPlugIns:(BOOL)allowsPlugIns
+{
+ WKPreferencesSetPluginsEnabled(WKPageGroupGetPreferences(self._pageGroupRef), allowsPlugIns);
+}
+
+@end
+
+@implementation WKBrowsingContextGroup (Internal)
+
+- (WKPageGroupRef)_pageGroupRef
+{
+ return _data->_pageGroupRef.get();
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h
new file mode 100644
index 000000000..957c3b09b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextGroupInternal.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKBrowsingContextGroup.h>
+
+@interface WKBrowsingContextGroup (Internal)
+
+@property(readonly) WKPageGroupRef _pageGroupRef;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h
new file mode 100644
index 000000000..3cd3a51d9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKBrowsingContextLoadDelegate.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextController;
+
+@protocol WKBrowsingContextLoadDelegate <NSObject>
+@optional
+
+/* Sent when the provisional load begins. */
+- (void)browsingContextControllerDidStartProvisionalLoad:(WKBrowsingContextController *)sender;
+
+/* Sent if a server-side redirect was recieved. */
+- (void)browsingContextControllerDidReceiveServerRedirectForProvisionalLoad:(WKBrowsingContextController *)sender;
+
+/* Sent if the provional load fails. */
+- (void)browsingContextControllerDidFailProvisionalLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
+
+/* Sent when the load gets committed. */
+- (void)browsingContextControllerDidCommitLoad:(WKBrowsingContextController *)sender;
+
+/* Sent when the load completes. */
+- (void)browsingContextControllerDidFinishLoad:(WKBrowsingContextController *)sender;
+
+/* Sent if the commited load fails. */
+- (void)browsingContextControllerDidFailLoad:(WKBrowsingContextController *)sender withError:(NSError *)error;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKConnection.h b/Source/WebKit2/UIProcess/API/mac/WKConnection.h
new file mode 100644
index 000000000..bf582b303
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKConnection.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKConnection, WKConnectionData;
+
+@protocol WKConnectionDelegate <NSObject>
+
+- (void)connection:(WKConnection *)connection didReceiveMessageWithName:(NSString *)messageName body:(id)messageBody;
+- (void)connectionDidClose:(WKConnection *)connection;
+
+@end
+
+WK_EXPORT
+@interface WKConnection : NSObject {
+@private
+ WKConnectionData *_data;
+}
+
+#pragma mark Delegates
+
+@property(assign) id<WKConnectionDelegate> delegate;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKConnection.mm b/Source/WebKit2/UIProcess/API/mac/WKConnection.mm
new file mode 100644
index 000000000..626ec85e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKConnection.mm
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+#import "WKConnection.h"
+#import "WKConnectionInternal.h"
+
+#import "WKConnectionRef.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
+#import <wtf/RetainPtr.h>
+
+@interface WKConnectionData : NSObject {
+@public
+ // Underlying connection object.
+ WKRetainPtr<WKConnectionRef> _connectionRef;
+
+ // Delegate for callbacks.
+ id<WKConnectionDelegate> _delegate;
+}
+@end
+
+@implementation WKConnectionData
+@end
+
+@implementation WKConnection
+
+- (void)dealloc
+{
+ WKConnectionSetConnectionClient(_data->_connectionRef.get(), 0);
+
+ [_data release];
+ [super dealloc];
+}
+
+#pragma mark Delegates
+
+- (id<WKConnectionDelegate>)delegate
+{
+ return _data->_delegate;
+}
+
+- (void)setDelegate:(id<WKConnectionDelegate>)delegate
+{
+ _data->_delegate = delegate;
+}
+
+@end
+
+@implementation WKConnection (Internal)
+
+static void didReceiveMessage(WKConnectionRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
+{
+ WKConnection *connection = (WKConnection *)clientInfo;
+ if ([connection.delegate respondsToSelector:@selector(connection:didReceiveMessageWithName:body:)]) {
+ // FIXME: Add messageBody conversion.
+ RetainPtr<CFStringRef> cfMessageName = adoptCF(WKStringCopyCFString(kCFAllocatorDefault, messageName));
+ [connection.delegate connection:connection didReceiveMessageWithName:(NSString *)cfMessageName.get() body:nil];
+ }
+}
+
+static void didClose(WKConnectionRef, const void* clientInfo)
+{
+ WKConnection *connection = (WKConnection *)clientInfo;
+ if ([connection.delegate respondsToSelector:@selector(connectionDidClose:)]) {
+ [connection.delegate connectionDidClose:connection];
+ }
+}
+
+static void setUpClient(WKConnection *connection, WKConnectionRef connectionRef)
+{
+ WKConnectionClient client;
+ memset(&client, 0, sizeof(client));
+
+ client.version = WKConnectionClientCurrentVersion;
+ client.clientInfo = connection;
+ client.didReceiveMessage = didReceiveMessage;
+ client.didClose = didClose;
+
+ WKConnectionSetConnectionClient(connectionRef, &client);
+}
+
+- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _data = [[WKConnectionData alloc] init];
+ _data->_connectionRef = connectionRef;
+
+ setUpClient(self, _data->_connectionRef.get());
+
+ return self;
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKConnectionInternal.h b/Source/WebKit2/UIProcess/API/mac/WKConnectionInternal.h
new file mode 100644
index 000000000..684b7fad9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKConnectionInternal.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKConnection.h>
+
+@interface WKConnection (Internal)
+
+- (id)_initWithConnectionRef:(WKConnectionRef)connectionRef;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h
new file mode 100644
index 000000000..87d81f4d3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebCore/IntRectHash.h>
+#import <wtf/RetainPtr.h>
+
+@class WKPrintingViewData;
+
+namespace WebKit {
+ class WebFrameProxy;
+}
+
+@interface WKPrintingView : NSView {
+@public
+ NSPrintOperation *_printOperation; // WKPrintingView is owned by the operation.
+ RetainPtr<NSView> _wkView;
+
+ RefPtr<WebKit::WebFrameProxy> _webFrame;
+ Vector<WebCore::IntRect> _printingPageRects;
+ double _totalScaleFactorForPrinting;
+ HashMap<WebCore::IntRect, Vector<uint8_t> > _pagePreviews;
+
+ Vector<uint8_t> _printedPagesData;
+ RetainPtr<CGPDFDocumentRef> _printedPagesPDFDocument;
+
+ uint64_t _expectedComputedPagesCallback;
+ HashMap<uint64_t, WebCore::IntRect> _expectedPreviewCallbacks;
+ uint64_t _latestExpectedPreviewCallback;
+ uint64_t _expectedPrintCallback;
+
+ BOOL _isPrintingFromSecondaryThread;
+ Mutex _printingCallbackMutex;
+ ThreadCondition _printingCallbackCondition;
+
+ NSTimer *_autodisplayResumeTimer;
+}
+
+- (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
new file mode 100644
index 000000000..14fe79add
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKPrintingView.mm
@@ -0,0 +1,628 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+#import "WKPrintingView.h"
+
+#import "Logging.h"
+#import "PrintInfo.h"
+#import "WebData.h"
+#import "WebPageProxy.h"
+#import <wtf/MainThread.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+NSString * const WebKitOriginalTopPrintingMarginKey = @"WebKitOriginalTopMargin";
+NSString * const WebKitOriginalBottomPrintingMarginKey = @"WebKitOriginalBottomMargin";
+
+NSString * const NSPrintInfoDidChangeNotification = @"NSPrintInfoDidChange";
+
+static BOOL isForcingPreviewUpdate;
+
+@implementation WKPrintingView
+
+- (id)initWithFrameProxy:(WebKit::WebFrameProxy*)frame view:(NSView *)wkView
+{
+ self = [super init]; // No frame rect to pass to NSView.
+ if (!self)
+ return nil;
+
+ _webFrame = frame;
+ _wkView = wkView;
+
+ return self;
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+- (void)_setAutodisplay:(BOOL)newState
+{
+ if (!newState && [[_wkView.get() window] isAutodisplay])
+ [_wkView.get() displayIfNeeded];
+
+ [[_wkView.get() window] setAutodisplay:newState];
+
+ // For some reason, painting doesn't happen for a long time without this call, <rdar://problem/8975229>.
+ if (newState)
+ [_wkView.get() displayIfNeeded];
+}
+
+
+- (void)_suspendAutodisplay
+{
+ // A drawRect: call on WKView causes a switch to screen mode, which is slow due to relayout, and we want to avoid that.
+ // Disabling autodisplay will prevent random updates from causing this, but resizing the window will still work.
+ if (_autodisplayResumeTimer) {
+ [_autodisplayResumeTimer invalidate];
+ _autodisplayResumeTimer = nil;
+ } else
+ [self _setAutodisplay:NO];
+}
+
+- (void)_delayedResumeAutodisplayTimerFired
+{
+ ASSERT(isMainThread());
+
+ _autodisplayResumeTimer = nil;
+ [self _setAutodisplay:YES];
+
+ // Enabling autodisplay normally implicitly calls endPrinting() via -[WKView drawRect:], but not when content is in accelerated compositing mode.
+ if (_webFrame->page())
+ _webFrame->page()->endPrinting();
+}
+
+- (void)_delayedResumeAutodisplay
+{
+ // AppKit calls endDocument/beginDocument when print option change. We don't want to switch between print and screen mode just for that,
+ // and enabling autodisplay may result in switching into screen mode. So, autodisplay is only resumed on next run loop iteration.
+ if (!_autodisplayResumeTimer) {
+ _autodisplayResumeTimer = [NSTimer timerWithTimeInterval:0 target:self selector:@selector(_delayedResumeAutodisplayTimerFired) userInfo:nil repeats:NO];
+ // The timer must be scheduled on main thread, because printing thread may finish before it fires.
+ [[NSRunLoop mainRunLoop] addTimer:_autodisplayResumeTimer forMode:NSDefaultRunLoopMode];
+ }
+}
+
+- (void)_adjustPrintingMarginsForHeaderAndFooter
+{
+ NSPrintInfo *info = [_printOperation printInfo];
+ NSMutableDictionary *infoDictionary = [info dictionary];
+
+ // We need to modify the top and bottom margins in the NSPrintInfo to account for the space needed by the
+ // header and footer. Because this method can be called more than once on the same NSPrintInfo (see 5038087),
+ // we stash away the unmodified top and bottom margins the first time this method is called, and we read from
+ // those stashed-away values on subsequent calls.
+ double originalTopMargin;
+ double originalBottomMargin;
+ NSNumber *originalTopMarginNumber = [infoDictionary objectForKey:WebKitOriginalTopPrintingMarginKey];
+ if (!originalTopMarginNumber) {
+ ASSERT(![infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey]);
+ originalTopMargin = [info topMargin];
+ originalBottomMargin = [info bottomMargin];
+ [infoDictionary setObject:[NSNumber numberWithDouble:originalTopMargin] forKey:WebKitOriginalTopPrintingMarginKey];
+ [infoDictionary setObject:[NSNumber numberWithDouble:originalBottomMargin] forKey:WebKitOriginalBottomPrintingMarginKey];
+ } else {
+ ASSERT([originalTopMarginNumber isKindOfClass:[NSNumber class]]);
+ ASSERT([[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] isKindOfClass:[NSNumber class]]);
+ originalTopMargin = [originalTopMarginNumber doubleValue];
+ originalBottomMargin = [[infoDictionary objectForKey:WebKitOriginalBottomPrintingMarginKey] doubleValue];
+ }
+
+ CGFloat scale = [info scalingFactor];
+ [info setTopMargin:originalTopMargin + _webFrame->page()->headerHeight(_webFrame.get()) * scale];
+ [info setBottomMargin:originalBottomMargin + _webFrame->page()->footerHeight(_webFrame.get()) * scale];
+}
+
+- (BOOL)_isPrintingPreview
+{
+ // <rdar://problem/8901041> Please add an API returning whether the current print operation is for preview.
+ // Assuming that if NSPrintOperation is allowed to spawn a thread for printing, it will. Print preview doesn't spawn a thread.
+ return !_isPrintingFromSecondaryThread;
+}
+
+- (void)_updatePreview
+{
+ // <rdar://problem/8900923> Please add an API to force print preview update.
+ ASSERT(!isForcingPreviewUpdate);
+ isForcingPreviewUpdate = YES;
+ [[NSNotificationCenter defaultCenter] postNotificationName:NSPrintInfoDidChangeNotification object:nil];
+ isForcingPreviewUpdate = NO;
+}
+
+- (BOOL)_hasPageRects
+{
+ // WebCore always prints at least one page.
+ return !_printingPageRects.isEmpty();
+}
+
+- (NSUInteger)_firstPrintedPageNumber
+{
+ // Need to directly access the dictionary because -[NSPrintOperation pageRange] verifies pagination, potentially causing recursion.
+ return [[[[_printOperation printInfo] dictionary] objectForKey:NSPrintFirstPage] unsignedIntegerValue];
+}
+
+- (NSUInteger)_lastPrintedPageNumber
+{
+ ASSERT([self _hasPageRects]);
+
+ // Need to directly access the dictionary because -[NSPrintOperation pageRange] verifies pagination, potentially causing recursion.
+ NSUInteger firstPage = [[[[_printOperation printInfo] dictionary] objectForKey:NSPrintFirstPage] unsignedIntegerValue];
+ NSUInteger lastPage = [[[[_printOperation printInfo] dictionary] objectForKey:NSPrintLastPage] unsignedIntegerValue];
+ if (lastPage - firstPage >= _printingPageRects.size())
+ return _printingPageRects.size();
+ return lastPage;
+}
+
+- (uint64_t)_expectedPreviewCallbackForRect:(const IntRect&)rect
+{
+ for (HashMap<uint64_t, WebCore::IntRect>::iterator iter = _expectedPreviewCallbacks.begin(); iter != _expectedPreviewCallbacks.end(); ++iter) {
+ if (iter->second == rect)
+ return iter->first;
+ }
+ return 0;
+}
+
+struct IPCCallbackContext {
+ RetainPtr<WKPrintingView> view;
+ uint64_t callbackID;
+};
+
+static void pageDidDrawToPDF(WKDataRef dataRef, WKErrorRef, void* untypedContext)
+{
+ ASSERT(isMainThread());
+
+ OwnPtr<IPCCallbackContext> context = adoptPtr(static_cast<IPCCallbackContext*>(untypedContext));
+ WKPrintingView *view = context->view.get();
+ WebData* data = toImpl(dataRef);
+
+ if (context->callbackID == view->_expectedPrintCallback) {
+ ASSERT(![view _isPrintingPreview]);
+ ASSERT(view->_printedPagesData.isEmpty());
+ ASSERT(!view->_printedPagesPDFDocument);
+ if (data)
+ view->_printedPagesData.append(data->bytes(), data->size());
+ view->_expectedPrintCallback = 0;
+ view->_printingCallbackCondition.signal();
+ } else {
+ // If the user has already changed print setup, then this response is obsolete. And this callback is not in response to the latest request,
+ // then the user has already moved to another page - we'll cache the response, but won't draw it.
+ HashMap<uint64_t, WebCore::IntRect>::iterator iter = view->_expectedPreviewCallbacks.find(context->callbackID);
+ if (iter != view->_expectedPreviewCallbacks.end()) {
+ ASSERT([view _isPrintingPreview]);
+
+ if (data) {
+ pair<HashMap<WebCore::IntRect, Vector<uint8_t> >::iterator, bool> entry = view->_pagePreviews.add(iter->second, Vector<uint8_t>());
+ entry.first->second.append(data->bytes(), data->size());
+ }
+ view->_expectedPreviewCallbacks.remove(context->callbackID);
+ bool receivedResponseToLatestRequest = view->_latestExpectedPreviewCallback == context->callbackID;
+ if (receivedResponseToLatestRequest) {
+ view->_latestExpectedPreviewCallback = 0;
+ [view _updatePreview];
+ }
+ }
+ }
+}
+
+- (void)_preparePDFDataForPrintingOnSecondaryThread
+{
+ ASSERT(isMainThread());
+
+ if (!_webFrame->page()) {
+ _printingCallbackCondition.signal();
+ return;
+ }
+
+ MutexLocker lock(_printingCallbackMutex);
+
+ ASSERT([self _hasPageRects]);
+ ASSERT(_printedPagesData.isEmpty());
+ ASSERT(!_printedPagesPDFDocument);
+ ASSERT(!_expectedPrintCallback);
+
+ NSUInteger firstPage = [self _firstPrintedPageNumber];
+ NSUInteger lastPage = [self _lastPrintedPageNumber];
+
+ ASSERT(firstPage > 0);
+ ASSERT(firstPage <= lastPage);
+ LOG(View, "WKPrintingView requesting PDF data for pages %u...%u", firstPage, lastPage);
+
+ PrintInfo printInfo([_printOperation printInfo]);
+ // Return to printing mode if we're already back to screen (e.g. due to window resizing).
+ _webFrame->page()->beginPrinting(_webFrame.get(), printInfo);
+
+ IPCCallbackContext* context = new IPCCallbackContext;
+ RefPtr<DataCallback> callback = DataCallback::create(context, pageDidDrawToPDF);
+ _expectedPrintCallback = callback->callbackID();
+
+ context->view = self;
+ context->callbackID = callback->callbackID();
+
+ _webFrame->page()->drawPagesToPDF(_webFrame.get(), printInfo, firstPage - 1, lastPage - firstPage + 1, callback.get());
+}
+
+static void pageDidComputePageRects(const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, WKErrorRef, void* untypedContext)
+{
+ ASSERT(isMainThread());
+
+ OwnPtr<IPCCallbackContext> context = adoptPtr(static_cast<IPCCallbackContext*>(untypedContext));
+ WKPrintingView *view = context->view.get();
+
+ // If the user has already changed print setup, then this response is obsolete.
+ if (context->callbackID == view->_expectedComputedPagesCallback) {
+ ASSERT(isMainThread());
+ ASSERT(view->_expectedPreviewCallbacks.isEmpty());
+ ASSERT(!view->_latestExpectedPreviewCallback);
+ ASSERT(!view->_expectedPrintCallback);
+ ASSERT(view->_pagePreviews.isEmpty());
+ view->_expectedComputedPagesCallback = 0;
+
+ view->_printingPageRects = pageRects;
+ view->_totalScaleFactorForPrinting = totalScaleFactorForPrinting;
+
+ // Sanitize a response coming from the Web process.
+ if (view->_printingPageRects.isEmpty())
+ view->_printingPageRects.append(IntRect(0, 0, 1, 1));
+ if (view->_totalScaleFactorForPrinting <= 0)
+ view->_totalScaleFactorForPrinting = 1;
+
+ const IntRect& lastPrintingPageRect = view->_printingPageRects[view->_printingPageRects.size() - 1];
+ NSRect newFrameSize = NSMakeRect(0, 0,
+ ceil(lastPrintingPageRect.maxX() * view->_totalScaleFactorForPrinting),
+ ceil(lastPrintingPageRect.maxY() * view->_totalScaleFactorForPrinting));
+ LOG(View, "WKPrintingView setting frame size to x:%g y:%g width:%g height:%g", newFrameSize.origin.x, newFrameSize.origin.y, newFrameSize.size.width, newFrameSize.size.height);
+ [view setFrame:newFrameSize];
+
+ if ([view _isPrintingPreview]) {
+ // Show page count, and ask for an actual image to replace placeholder.
+ [view _updatePreview];
+ } else {
+ // When printing, request everything we'll need beforehand.
+ [view _preparePDFDataForPrintingOnSecondaryThread];
+ }
+ }
+}
+
+- (BOOL)_askPageToComputePageRects
+{
+ ASSERT(isMainThread());
+
+ if (!_webFrame->page())
+ return NO;
+
+ ASSERT(!_expectedComputedPagesCallback);
+
+ IPCCallbackContext* context = new IPCCallbackContext;
+ RefPtr<ComputedPagesCallback> callback = ComputedPagesCallback::create(context, pageDidComputePageRects);
+ _expectedComputedPagesCallback = callback->callbackID();
+ context->view = self;
+ context->callbackID = _expectedComputedPagesCallback;
+
+ _webFrame->page()->computePagesForPrinting(_webFrame.get(), PrintInfo([_printOperation printInfo]), callback.release());
+ return YES;
+}
+
+static void prepareDataForPrintingOnSecondaryThread(void* untypedContext)
+{
+ ASSERT(isMainThread());
+
+ WKPrintingView *view = static_cast<WKPrintingView *>(untypedContext);
+ MutexLocker lock(view->_printingCallbackMutex);
+
+ // We may have received page rects while a message to call this function traveled from secondary thread to main one.
+ if ([view _hasPageRects]) {
+ [view _preparePDFDataForPrintingOnSecondaryThread];
+ return;
+ }
+
+ // A request for pages has already been made, just wait for it to finish.
+ if (view->_expectedComputedPagesCallback)
+ return;
+
+ [view _askPageToComputePageRects];
+}
+
+- (BOOL)knowsPageRange:(NSRangePointer)range
+{
+ LOG(View, "-[WKPrintingView %p knowsPageRange:], %s, %s", self, [self _hasPageRects] ? "print data is available" : "print data is not available yet", isMainThread() ? "on main thread" : "on secondary thread");
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+
+ // Assuming that once we switch to printing from a secondary thread, we don't go back.
+ ASSERT(!_isPrintingFromSecondaryThread || !isMainThread());
+ if (!isMainThread())
+ _isPrintingFromSecondaryThread = YES;
+
+ if (!_webFrame->page()) {
+ *range = NSMakeRange(1, NSIntegerMax);
+ return YES;
+ }
+
+ [self _suspendAutodisplay];
+
+ [self _adjustPrintingMarginsForHeaderAndFooter];
+
+ if ([self _hasPageRects])
+ *range = NSMakeRange(1, _printingPageRects.size());
+ else if (!isMainThread()) {
+ ASSERT(![self _isPrintingPreview]);
+ MutexLocker lock(_printingCallbackMutex);
+ callOnMainThread(prepareDataForPrintingOnSecondaryThread, self);
+ _printingCallbackCondition.wait(_printingCallbackMutex);
+ *range = NSMakeRange(1, _printingPageRects.size());
+ } else {
+ ASSERT([self _isPrintingPreview]);
+
+ // If a request for pages hasn't already been made, make it now.
+ if (!_expectedComputedPagesCallback)
+ [self _askPageToComputePageRects];
+
+ *range = NSMakeRange(1, NSIntegerMax);
+ }
+ return YES;
+}
+
+- (unsigned)_pageForRect:(NSRect)rect
+{
+ // Assuming that rect exactly matches one of the pages.
+ for (size_t i = 0; i < _printingPageRects.size(); ++i) {
+ IntRect currentRect(_printingPageRects[i]);
+ currentRect.scale(_totalScaleFactorForPrinting);
+ if (rect.origin.y == currentRect.y() && rect.origin.x == currentRect.x())
+ return i + 1;
+ }
+ ASSERT_NOT_REACHED();
+ return 0; // Invalid page number.
+}
+
+- (void)_drawPDFDocument:(CGPDFDocumentRef)pdfDocument page:(unsigned)page atPoint:(NSPoint)point
+{
+ if (!pdfDocument) {
+ LOG_ERROR("Couldn't create a PDF document with data passed for preview");
+ return;
+ }
+
+ CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDocument, page);
+ if (!pdfPage) {
+ LOG_ERROR("Preview data doesn't have page %d", page);
+ return;
+ }
+
+ NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
+ CGContextRef context = static_cast<CGContextRef>([nsGraphicsContext graphicsPort]);
+
+ CGContextSaveGState(context);
+ CGContextTranslateCTM(context, point.x, point.y);
+ CGContextScaleCTM(context, _totalScaleFactorForPrinting, -_totalScaleFactorForPrinting);
+ CGContextTranslateCTM(context, 0, -CGPDFPageGetBoxRect(pdfPage, kCGPDFMediaBox).size.height);
+ CGContextDrawPDFPage(context, pdfPage);
+ CGContextRestoreGState(context);
+}
+
+- (void)_drawPreview:(NSRect)nsRect
+{
+ ASSERT(isMainThread());
+
+ IntRect rect(nsRect);
+ rect.scale(1 / _totalScaleFactorForPrinting);
+ HashMap<WebCore::IntRect, Vector<uint8_t> >::iterator pagePreviewIterator = _pagePreviews.find(rect);
+ if (pagePreviewIterator == _pagePreviews.end()) {
+ // It's too early to ask for page preview if we don't even know page size and scale.
+ if ([self _hasPageRects]) {
+ if (uint64_t existingCallback = [self _expectedPreviewCallbackForRect:rect]) {
+ // We've already asked for a preview of this page, and are waiting for response.
+ // There is no need to ask again.
+ _latestExpectedPreviewCallback = existingCallback;
+ } else {
+ // Preview isn't available yet, request it asynchronously.
+ if (!_webFrame->page())
+ return;
+
+ // Return to printing mode if we're already back to screen (e.g. due to window resizing).
+ _webFrame->page()->beginPrinting(_webFrame.get(), PrintInfo([_printOperation printInfo]));
+
+ IPCCallbackContext* context = new IPCCallbackContext;
+ RefPtr<DataCallback> callback = DataCallback::create(context, pageDidDrawToPDF);
+ _latestExpectedPreviewCallback = callback->callbackID();
+ _expectedPreviewCallbacks.add(_latestExpectedPreviewCallback, rect);
+
+ context->view = self;
+ context->callbackID = callback->callbackID();
+
+ _webFrame->page()->drawRectToPDF(_webFrame.get(), PrintInfo([_printOperation printInfo]), rect, callback.get());
+ return;
+ }
+ }
+
+ // FIXME: Draw a placeholder
+ return;
+ }
+
+ const Vector<uint8_t>& pdfData = pagePreviewIterator->second;
+ RetainPtr<CGDataProviderRef> pdfDataProvider(AdoptCF, CGDataProviderCreateWithData(0, pdfData.data(), pdfData.size(), 0));
+ RetainPtr<CGPDFDocumentRef> pdfDocument(AdoptCF, CGPDFDocumentCreateWithProvider(pdfDataProvider.get()));
+
+ [self _drawPDFDocument:pdfDocument.get() page:1 atPoint:NSMakePoint(nsRect.origin.x, nsRect.origin.y)];
+}
+
+- (void)drawRect:(NSRect)nsRect
+{
+ LOG(View, "WKPrintingView %p printing rect x:%g, y:%g, width:%g, height:%g%s", self, nsRect.origin.x, nsRect.origin.y, nsRect.size.width, nsRect.size.height, [self _isPrintingPreview] ? " for preview" : "");
+
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+
+ if (!_webFrame->page())
+ return;
+
+ if ([self _isPrintingPreview]) {
+ [self _drawPreview:nsRect];
+ return;
+ }
+
+ ASSERT(!isMainThread());
+ ASSERT(!_printedPagesData.isEmpty()); // Prepared by knowsPageRange:
+
+ if (!_printedPagesPDFDocument) {
+ RetainPtr<CGDataProviderRef> pdfDataProvider(AdoptCF, CGDataProviderCreateWithData(0, _printedPagesData.data(), _printedPagesData.size(), 0));
+ _printedPagesPDFDocument.adoptCF(CGPDFDocumentCreateWithProvider(pdfDataProvider.get()));
+ }
+
+ unsigned printedPageNumber = [self _pageForRect:nsRect] - [self _firstPrintedPageNumber] + 1;
+ [self _drawPDFDocument:_printedPagesPDFDocument.get() page:printedPageNumber atPoint:NSMakePoint(nsRect.origin.x, nsRect.origin.y)];
+}
+
+- (void)_drawPageBorderWithSizeOnMainThread:(NSSize)borderSize
+{
+ ASSERT(isMainThread());
+
+ // When printing from a secondary thread, the main thread doesn't have graphics context and printing operation set up.
+ NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+ [NSGraphicsContext setCurrentContext:[_printOperation context]];
+
+ ASSERT(![NSPrintOperation currentOperation]);
+ [NSPrintOperation setCurrentOperation:_printOperation];
+
+ [self drawPageBorderWithSize:borderSize];
+
+ [NSPrintOperation setCurrentOperation:nil];
+ [NSGraphicsContext setCurrentContext:currentContext];
+}
+
+- (void)drawPageBorderWithSize:(NSSize)borderSize
+{
+ ASSERT(NSEqualSizes(borderSize, [[_printOperation printInfo] paperSize]));
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+
+ if (!isMainThread()) {
+ // Don't call the client from a secondary thread.
+ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[WKPrintingView instanceMethodSignatureForSelector:@selector(_drawPageBorderWithSizeOnMainThread:)]];
+ [invocation setSelector:@selector(_drawPageBorderWithSizeOnMainThread:)];
+ [invocation setArgument:&borderSize atIndex:2];
+ [invocation performSelectorOnMainThread:@selector(invokeWithTarget:) withObject:self waitUntilDone:YES];
+ return;
+ }
+
+ if (!_webFrame->page())
+ return;
+
+ // The header and footer rect height scales with the page, but the width is always
+ // all the way across the printed page (inset by printing margins).
+ NSPrintInfo *printInfo = [_printOperation printInfo];
+ CGFloat scale = [printInfo scalingFactor];
+ NSSize paperSize = [printInfo paperSize];
+ CGFloat headerFooterLeft = [printInfo leftMargin] / scale;
+ CGFloat headerFooterWidth = (paperSize.width - ([printInfo leftMargin] + [printInfo rightMargin])) / scale;
+ NSRect footerRect = NSMakeRect(headerFooterLeft, [printInfo bottomMargin] / scale - _webFrame->page()->footerHeight(_webFrame.get()), headerFooterWidth, _webFrame->page()->footerHeight(_webFrame.get()));
+ NSRect headerRect = NSMakeRect(headerFooterLeft, (paperSize.height - [printInfo topMargin]) / scale, headerFooterWidth, _webFrame->page()->headerHeight(_webFrame.get()));
+
+ NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
+ [currentContext saveGraphicsState];
+ NSRectClip(headerRect);
+ _webFrame->page()->drawHeader(_webFrame.get(), headerRect);
+ [currentContext restoreGraphicsState];
+
+ [currentContext saveGraphicsState];
+ NSRectClip(footerRect);
+ _webFrame->page()->drawFooter(_webFrame.get(), footerRect);
+ [currentContext restoreGraphicsState];
+}
+
+- (NSRect)rectForPage:(NSInteger)page
+{
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+ if (![self _hasPageRects]) {
+ LOG(View, "-[WKPrintingView %p rectForPage:%d] - data is not yet available", self, (int)page);
+ if (!_webFrame->page()) {
+ // We may have not told AppKit how many pages there are, so it will try to print until a null rect is returned.
+ return NSMakeRect(0, 0, 0, 0);
+ }
+ // We must be still calculating the page range.
+ ASSERT(_expectedComputedPagesCallback);
+ return NSMakeRect(0, 0, 1, 1);
+ }
+
+ // If Web process crashes while computing page rects, we never tell AppKit how many pages there are.
+ // Returning a null rect prevents selecting non-existent pages in preview dialog.
+ if (static_cast<unsigned>(page) > _printingPageRects.size()) {
+ ASSERT(!_webFrame->page());
+ return NSMakeRect(0, 0, 0, 0);
+ }
+
+ IntRect rect = _printingPageRects[page - 1];
+ rect.scale(_totalScaleFactorForPrinting);
+ LOG(View, "-[WKPrintingView %p rectForPage:%d] -> x %d, y %d, width %d, height %d", self, (int)page, rect.x(), rect.y(), rect.width(), rect.height());
+ return rect;
+}
+
+// Temporary workaround for <rdar://problem/8944535>. Force correct printout positioning.
+- (NSPoint)locationOfPrintRect:(NSRect)aRect
+{
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+ return NSMakePoint([[_printOperation printInfo] leftMargin], [[_printOperation printInfo] bottomMargin]);
+}
+
+- (void)beginDocument
+{
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+
+ // Forcing preview update gets us here, but page setup hasn't actually changed.
+ if (isForcingPreviewUpdate)
+ return;
+
+ LOG(View, "-[WKPrintingView %p beginDocument]", self);
+
+ [super beginDocument];
+
+ [self _suspendAutodisplay];
+}
+
+- (void)endDocument
+{
+ ASSERT(_printOperation == [NSPrintOperation currentOperation]);
+
+ // Forcing preview update gets us here, but page setup hasn't actually changed.
+ if (isForcingPreviewUpdate)
+ return;
+
+ LOG(View, "-[WKPrintingView %p endDocument] - clearing cached data", self);
+
+ // Both existing data and pending responses are now obsolete.
+ _printingPageRects.clear();
+ _totalScaleFactorForPrinting = 1;
+ _pagePreviews.clear();
+ _printedPagesData.clear();
+ _printedPagesPDFDocument = nullptr;
+ _expectedComputedPagesCallback = 0;
+ _expectedPreviewCallbacks.clear();
+ _latestExpectedPreviewCallback = 0;
+ _expectedPrintCallback = 0;
+
+ [self _delayedResumeAutodisplay];
+
+ [super endDocument];
+}
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.h b/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.h
new file mode 100644
index 000000000..d315ad78c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <Foundation/Foundation.h>
+#import <WebKit2/WKBase.h>
+
+@class WKProcessGroup, WKProcessGroupData, WKConnection;
+
+@protocol WKProcessGroupDelegate <NSObject>
+
+- (void)processGroup:(WKProcessGroup *)processGroup didCreateConnectionToWebProcessPlugIn:(WKConnection *)connection;
+
+@end
+
+WK_EXPORT
+@interface WKProcessGroup : NSObject {
+@private
+ WKProcessGroupData *_data;
+}
+
+- (id)initWithInjectedBundleURL:(NSURL *)bundleURL;
+
+
+#pragma mark Delegates
+
+@property(assign) id<WKProcessGroupDelegate> delegate;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.mm b/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.mm
new file mode 100644
index 000000000..f19381891
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKProcessGroup.mm
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import "config.h"
+#import "WKProcessGroup.h"
+#import "WKProcessGroupInternal.h"
+
+#import "WKConnectionInternal.h"
+#import "WKContext.h"
+#import "WKRetainPtr.h"
+#import "WKStringCF.h"
+#import <wtf/RetainPtr.h>
+
+@interface WKProcessGroupData : NSObject {
+@public
+ // Underlying context object.
+ WKRetainPtr<WKContextRef> _contextRef;
+
+ // Delegate for callbacks.
+ id<WKProcessGroupDelegate> _delegate;
+}
+@end
+
+@implementation WKProcessGroupData
+@end
+
+@implementation WKProcessGroup
+
+static void didCreateConnection(WKContextRef, WKConnectionRef connectionRef, const void* clientInfo)
+{
+ WKProcessGroup *processGroup = (WKProcessGroup *)clientInfo;
+ if ([processGroup.delegate respondsToSelector:@selector(processGroup:didCreateConnectionToWebProcessPlugIn:)]) {
+ RetainPtr<WKConnection> connection = adoptNS([[WKConnection alloc] _initWithConnectionRef:connectionRef]);
+ [processGroup.delegate processGroup:processGroup didCreateConnectionToWebProcessPlugIn:connection.get()];
+ }
+}
+
+static void setUpConnectionClient(WKProcessGroup *processGroup, WKContextRef contextRef)
+{
+ WKContextConnectionClient connectionClient;
+ memset(&connectionClient, 0, sizeof(connectionClient));
+
+ connectionClient.version = kWKContextConnectionClientCurrentVersion;
+ connectionClient.clientInfo = processGroup;
+ connectionClient.didCreateConnection = didCreateConnection;
+
+ WKContextSetConnectionClient(contextRef, &connectionClient);
+}
+
+- (id)init
+{
+ return [self initWithInjectedBundleURL:nil];
+}
+
+- (id)initWithInjectedBundleURL:(NSURL *)bundleURL
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _data = [[WKProcessGroupData alloc] init];
+
+ if (bundleURL)
+ _data->_contextRef = adoptWK(WKContextCreateWithInjectedBundlePath(adoptWK(WKStringCreateWithCFString((CFStringRef)[bundleURL absoluteString])).get()));
+ else
+ _data->_contextRef = adoptWK(WKContextCreate());
+
+ setUpConnectionClient(self, _data->_contextRef.get());
+
+ return self;
+}
+
+- (void)dealloc
+{
+ WKContextSetConnectionClient(_data->_contextRef.get(), 0);
+
+ [_data release];
+ [super dealloc];
+}
+
+- (id<WKProcessGroupDelegate>)delegate
+{
+ return _data->_delegate;
+}
+
+- (void)setDelegate:(id<WKProcessGroupDelegate>)delegate
+{
+ _data->_delegate = delegate;
+}
+
+@end
+
+@implementation WKProcessGroup (Internal)
+
+- (WKContextRef)_contextRef
+{
+ return _data->_contextRef.get();
+}
+
+@end
+
+
diff --git a/Source/WebKit2/UIProcess/API/mac/WKProcessGroupInternal.h b/Source/WebKit2/UIProcess/API/mac/WKProcessGroupInternal.h
new file mode 100644
index 000000000..1a8bc2ae2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKProcessGroupInternal.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKProcessGroup.h>
+
+@interface WKProcessGroup (Internal)
+
+@property(readonly) WKContextRef _contextRef;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h
new file mode 100644
index 000000000..91c93e592
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2009, 2010 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. ``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
+ * 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.
+ */
+
+#ifndef WKTextInputWindowController_h
+#define WKTextInputWindowController_h
+
+@class WKTextInputPanel;
+
+@interface WKTextInputWindowController : NSObject {
+ WKTextInputPanel *_panel;
+}
+
++ (WKTextInputWindowController *)sharedTextInputWindowController;
+
+- (NSTextInputContext *)inputContext;
+- (BOOL)interpretKeyEvent:(NSEvent *)event usingLegacyCocoaTextInput:(BOOL)usingLegacyCocoaTextInput string:(NSString **)string;
+
+- (BOOL)hasMarkedText;
+- (void)unmarkText;
+
+@end
+
+#endif // WKTextInputWindowController_h
diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm
new file mode 100644
index 000000000..8c69b08b6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#import "config.h"
+#import "WKTextInputWindowController.h"
+
+#import <WebKitSystemInterface.h>
+
+@interface WKTextInputPanel : NSPanel {
+ NSTextView *_inputTextView;
+}
+
+- (NSTextInputContext *)_inputContext;
+- (BOOL)_interpretKeyEvent:(NSEvent *)event usingLegacyCocoaTextInput:(BOOL)usingLegacyCocoaTextInput string:(NSString **)string;
+
+- (BOOL)_hasMarkedText;
+- (void)_unmarkText;
+
+@end
+
+#define inputWindowHeight 20
+
+@implementation WKTextInputPanel
+
+- (void)dealloc
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ [_inputTextView release];
+
+ [super dealloc];
+}
+
+- (id)init
+{
+ self = [super initWithContentRect:NSZeroRect styleMask:WKGetInputPanelWindowStyle() backing:NSBackingStoreBuffered defer:YES];
+ if (!self)
+ return nil;
+
+ // Set the frame size.
+ NSRect visibleFrame = [[NSScreen mainScreen] visibleFrame];
+ NSRect frame = NSMakeRect(visibleFrame.origin.x, visibleFrame.origin.y, visibleFrame.size.width, inputWindowHeight);
+
+ [self setFrame:frame display:NO];
+
+ _inputTextView = [[NSTextView alloc] initWithFrame:[(NSView *)self.contentView frame]];
+ _inputTextView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable | NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin;
+
+ NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:[(NSView *)self.contentView frame]];
+ scrollView.documentView = _inputTextView;
+ self.contentView = scrollView;
+ [scrollView release];
+
+ [self setFloatingPanel:YES];
+
+ return self;
+}
+
+- (void)_unmarkText
+{
+ [_inputTextView setString:@""];
+ [self orderOut:nil];
+}
+
+- (BOOL)_interpretKeyEvent:(NSEvent *)event usingLegacyCocoaTextInput:(BOOL)usingLegacyCocoaTextInput string:(NSString **)string
+{
+ BOOL hadMarkedText = [_inputTextView hasMarkedText];
+
+ *string = nil;
+
+ // Let TSM know that a bottom input window would be created for marked text.
+ EventRef carbonEvent = static_cast<EventRef>(const_cast<void*>([event eventRef]));
+ if (carbonEvent) {
+ Boolean ignorePAH = true;
+ SetEventParameter(carbonEvent, 'iPAH', typeBoolean, sizeof(ignorePAH), &ignorePAH);
+ }
+
+ if (![[_inputTextView inputContext] handleEvent:event])
+ return NO;
+
+ if ([_inputTextView hasMarkedText]) {
+ // Don't show the input method window for dead keys
+ if ([[event characters] length] > 0)
+ [self orderFront:nil];
+
+ return YES;
+ }
+
+ bool shouldReturnTextString = hadMarkedText;
+
+ // In the updated Cocoa text input model spec, we always want to return the text even if the text view didn't have marked text.
+ if (!usingLegacyCocoaTextInput)
+ shouldReturnTextString = true;
+
+ if (shouldReturnTextString) {
+ [self orderOut:nil];
+
+ NSString *text = [[_inputTextView textStorage] string];
+ if ([text length] > 0)
+ *string = [[text copy] autorelease];
+ }
+
+ [_inputTextView setString:@""];
+ return hadMarkedText;
+}
+
+- (NSTextInputContext *)_inputContext
+{
+ return [_inputTextView inputContext];
+}
+
+- (BOOL)_hasMarkedText
+{
+ return [_inputTextView hasMarkedText];
+}
+
+@end
+
+@implementation WKTextInputWindowController
+
++ (WKTextInputWindowController *)sharedTextInputWindowController
+{
+ static WKTextInputWindowController *textInputWindowController;
+ if (!textInputWindowController)
+ textInputWindowController = [[WKTextInputWindowController alloc] init];
+
+ return textInputWindowController;
+}
+
+- (id)init
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _panel = [[WKTextInputPanel alloc] init];
+
+ return self;
+}
+
+- (NSTextInputContext *)inputContext
+{
+ return [_panel _inputContext];
+}
+
+- (BOOL)hasMarkedText
+{
+ return [_panel _hasMarkedText];
+}
+
+- (BOOL)interpretKeyEvent:(NSEvent *)event usingLegacyCocoaTextInput:(BOOL)usingLegacyCocoaTextInput string:(NSString **)string
+{
+ return [_panel _interpretKeyEvent:event usingLegacyCocoaTextInput:usingLegacyCocoaTextInput string:string];
+}
+
+- (void)unmarkText
+{
+ [_panel _unmarkText];
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.h b/Source/WebKit2/UIProcess/API/mac/WKView.h
new file mode 100644
index 000000000..07105c40b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <WebKit2/WKBase.h>
+
+@class WKBrowsingContextController;
+@class WKBrowsingContextGroup;
+@class WKProcessGroup;
+@class WKViewData;
+
+WK_EXPORT
+@interface WKView : NSView <NSTextInputClient> {
+@private
+ WKViewData *_data;
+ unsigned _unused;
+}
+
+- (id)initWithFrame:(NSRect)frame processGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup;
+
+@property(readonly) WKBrowsingContextController *browsingContextController;
+
+@property BOOL drawsBackground;
+@property BOOL drawsTransparentBackground;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
new file mode 100644
index 000000000..0bb174337
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -0,0 +1,2859 @@
+/*
+ * Copyright (C) 2010, 2011 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.
+ */
+
+#import "config.h"
+#import "WKView.h"
+
+#import "AttributedString.h"
+#import "DataReference.h"
+#import "DrawingAreaProxyImpl.h"
+#import "EditorState.h"
+#import "FindIndicator.h"
+#import "FindIndicatorWindow.h"
+#import "LayerTreeContext.h"
+#import "Logging.h"
+#import "NativeWebKeyboardEvent.h"
+#import "NativeWebMouseEvent.h"
+#import "NativeWebWheelEvent.h"
+#import "PDFViewController.h"
+#import "PageClientImpl.h"
+#import "PasteboardTypes.h"
+#import "RunLoop.h"
+#import "TextChecker.h"
+#import "TextCheckerState.h"
+#import "TiledCoreAnimationDrawingAreaProxy.h"
+#import "WKAPICast.h"
+#import "WKFullScreenWindowController.h"
+#import "WKPrintingView.h"
+#import "WKStringCF.h"
+#import "WKTextInputWindowController.h"
+#import "WKViewInternal.h"
+#import "WKViewPrivate.h"
+#import "WebContext.h"
+#import "WebEventFactory.h"
+#import "WebFullScreenManagerProxy.h"
+#import "WebPage.h"
+#import "WebPageProxy.h"
+#import "WebProcessProxy.h"
+#import "WebSystemInterface.h"
+#import <QuartzCore/QuartzCore.h>
+#import <WebCore/ColorMac.h>
+#import <WebCore/DragController.h>
+#import <WebCore/DragData.h>
+#import <WebCore/DragSession.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/IntRect.h>
+#import <WebCore/KeyboardEvent.h>
+#import <WebCore/LocalizedStrings.h>
+#import <WebCore/PlatformEventFactoryMac.h>
+#import <WebCore/PlatformScreen.h>
+#import <WebCore/Region.h>
+#import <WebKitSystemInterface.h>
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+
+/* API internals. */
+#import "WKBrowsingContextControllerInternal.h"
+#import "WKBrowsingContextGroupInternal.h"
+#import "WKProcessGroupInternal.h"
+
+
+@interface NSApplication (WKNSApplicationDetails)
+- (void)speakString:(NSString *)string;
+- (void)_setCurrentEvent:(NSEvent *)event;
+@end
+
+@interface NSObject (WKNSTextInputContextDetails)
+- (BOOL)wantsToHandleMouseEvents;
+- (BOOL)handleMouseEvent:(NSEvent *)event;
+@end
+
+@interface NSWindow (WKNSWindowDetails)
+- (NSRect)_growBoxRect;
+- (id)_growBoxOwner;
+- (void)_setShowOpaqueGrowBoxForOwner:(id)owner;
+- (BOOL)_updateGrowBoxForWindowFrameChange;
+- (NSRect)_intersectBottomCornersWithRect:(NSRect)viewRect;
+- (void)_maskRoundedBottomCorners:(NSRect)clipRect;
+@end
+
+using namespace WebKit;
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef id <NSValidatedUserInterfaceItem> ValidationItem;
+typedef Vector<RetainPtr<ValidationItem> > ValidationVector;
+typedef HashMap<String, ValidationVector> ValidationMap;
+
+}
+
+struct WKViewInterpretKeyEventsParameters {
+ bool eventInterpretationHadSideEffects;
+ bool consumedByIM;
+ bool executingSavedKeypressCommands;
+ Vector<KeypressCommand>* commands;
+};
+
+@interface WKView ()
+- (void)_accessibilityRegisterUIProcessTokens;
+- (void)_disableComplexTextInputIfNecessary;
+- (float)_intrinsicDeviceScaleFactor;
+- (void)_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent;
+- (void)_setDrawingAreaSize:(NSSize)size;
+- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState;
+- (BOOL)_shouldUseTiledDrawingArea;
+@end
+
+@interface WKViewData : NSObject {
+@public
+ OwnPtr<PageClientImpl> _pageClient;
+ RefPtr<WebPageProxy> _page;
+
+ // Cache of the associated WKBrowsingContextController.
+ RetainPtr<WKBrowsingContextController> _browsingContextController;
+
+ // For ToolTips.
+ NSToolTipTag _lastToolTipTag;
+ id _trackingRectOwner;
+ void* _trackingRectUserData;
+
+ RetainPtr<NSView> _layerHostingView;
+
+ RetainPtr<id> _remoteAccessibilityChild;
+
+ // For asynchronous validation.
+ ValidationMap _validationMap;
+
+ OwnPtr<PDFViewController> _pdfViewController;
+
+ OwnPtr<FindIndicatorWindow> _findIndicatorWindow;
+ // We keep here the event when resending it to
+ // the application to distinguish the case of a new event from one
+ // that has been already sent to WebCore.
+ RetainPtr<NSEvent> _keyDownEventBeingResent;
+ WKViewInterpretKeyEventsParameters* _interpretKeyEventsParameters;
+
+ NSSize _resizeScrollOffset;
+
+ // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
+ uint64_t _pluginComplexTextInputIdentifier;
+
+ // The state of complex text input for the plug-in.
+ PluginComplexTextInputState _pluginComplexTextInputState;
+
+ bool _inBecomeFirstResponder;
+ bool _inResignFirstResponder;
+ NSEvent *_mouseDownEvent;
+ BOOL _ignoringMouseDraggedEvents;
+ BOOL _dragHasStarted;
+
+ id _flagsChangedEventMonitor;
+#if ENABLE(GESTURE_EVENTS)
+ id _endGestureMonitor;
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ RetainPtr<WKFullScreenWindowController> _fullScreenWindowController;
+#endif
+
+ BOOL _hasSpellCheckerDocumentTag;
+ NSInteger _spellCheckerDocumentTag;
+
+ BOOL _inSecureInputState;
+
+ NSRect _windowBottomCornerIntersectionRect;
+
+ unsigned _frameSizeUpdatesDisabledCount;
+}
+@end
+
+@implementation WKViewData
+@end
+
+
+@interface WKResponderChainSink : NSResponder {
+ NSResponder *_lastResponderInChain;
+ bool _didReceiveUnhandledCommand;
+}
+- (id)initWithResponderChain:(NSResponder *)chain;
+- (void)detach;
+- (bool)didReceiveUnhandledCommand;
+@end
+
+@interface WKFlippedView : NSView
+@end
+
+@implementation WKFlippedView
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+@end
+
+@implementation WKView
+
+- (id)initWithFrame:(NSRect)frame processGroup:(WKProcessGroup *)processGroup browsingContextGroup:(WKBrowsingContextGroup *)browsingContextGroup
+{
+ return [self initWithFrame:frame contextRef:processGroup._contextRef pageGroupRef:browsingContextGroup._pageGroupRef];
+}
+
+- (void)dealloc
+{
+ _data->_page->close();
+ [NSEvent removeMonitor:_data->_flagsChangedEventMonitor];
+
+ ASSERT(!_data->_inSecureInputState);
+
+ [_data release];
+ _data = nil;
+
+ WebContext::statistics().wkViewCount--;
+
+ [super dealloc];
+}
+
+- (WKBrowsingContextController *)browsingContextController
+{
+ if (!_data->_browsingContextController)
+ _data->_browsingContextController.adoptNS([[WKBrowsingContextController alloc] _initWithPageRef:[self pageRef]]);
+ return _data->_browsingContextController.get();
+}
+
+- (void)setDrawsBackground:(BOOL)drawsBackground
+{
+ _data->_page->setDrawsBackground(drawsBackground);
+}
+
+- (BOOL)drawsBackground
+{
+ return _data->_page->drawsBackground();
+}
+
+- (void)setDrawsTransparentBackground:(BOOL)drawsTransparentBackground
+{
+ _data->_page->setDrawsTransparentBackground(drawsTransparentBackground);
+}
+
+- (BOOL)drawsTransparentBackground
+{
+ return _data->_page->drawsTransparentBackground();
+}
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+- (BOOL)becomeFirstResponder
+{
+ NSSelectionDirection direction = [[self window] keyViewSelectionDirection];
+
+ _data->_inBecomeFirstResponder = true;
+
+ [self _updateSecureInputState];
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+
+ _data->_inBecomeFirstResponder = false;
+
+ if (direction != NSDirectSelection) {
+ NSEvent *event = [NSApp currentEvent];
+ NSEvent *keyboardEvent = nil;
+ if ([event type] == NSKeyDown || [event type] == NSKeyUp)
+ keyboardEvent = event;
+ _data->_page->setInitialFocus(direction == NSSelectingNext, keyboardEvent != nil, NativeWebKeyboardEvent(keyboardEvent, self));
+ }
+ return YES;
+}
+
+- (BOOL)resignFirstResponder
+{
+ _data->_inResignFirstResponder = true;
+
+ if (_data->_page->editorState().hasComposition && !_data->_page->editorState().shouldIgnoreCompositionSelectionChange)
+ _data->_page->cancelComposition();
+ [self _resetTextInputState];
+
+ if (!_data->_page->maintainsInactiveSelection())
+ _data->_page->clearSelection();
+
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+
+ _data->_inResignFirstResponder = false;
+
+ return YES;
+}
+
+- (void)viewWillStartLiveResize
+{
+ _data->_page->viewWillStartLiveResize();
+}
+
+- (void)viewDidEndLiveResize
+{
+ _data->_page->viewWillEndLiveResize();
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+ [super setFrameSize:size];
+
+ if (![self frameSizeUpdatesDisabled])
+ [self _setDrawingAreaSize:size];
+}
+
+- (void)_updateWindowAndViewFrames
+{
+ NSWindow *window = [self window];
+ ASSERT(window);
+
+ NSRect windowFrameInScreenCoordinates = [window frame];
+ NSRect viewFrameInWindowCoordinates = [self convertRect:[self frame] toView:nil];
+ NSPoint accessibilityPosition = [[self accessibilityAttributeValue:NSAccessibilityPositionAttribute] pointValue];
+
+ _data->_page->windowAndViewFramesChanged(enclosingIntRect(windowFrameInScreenCoordinates), enclosingIntRect(viewFrameInWindowCoordinates), IntPoint(accessibilityPosition));
+}
+
+- (void)renewGState
+{
+ // Hide the find indicator.
+ _data->_findIndicatorWindow = nullptr;
+
+ // Update the view frame.
+ if ([self window])
+ [self _updateWindowAndViewFrames];
+
+ [super renewGState];
+}
+
+- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState
+{
+ _data->_pluginComplexTextInputState = pluginComplexTextInputState;
+
+ if (_data->_pluginComplexTextInputState != PluginComplexTextInputDisabled)
+ return;
+
+ // Send back an empty string to the plug-in. This will disable text input.
+ _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, String());
+}
+
+typedef HashMap<SEL, String> SelectorNameMap;
+
+// Map selectors into Editor command names.
+// This is not needed for any selectors that have the same name as the Editor command.
+static const SelectorNameMap* createSelectorExceptionMap()
+{
+ SelectorNameMap* map = new HashMap<SEL, String>;
+
+ map->add(@selector(insertNewlineIgnoringFieldEditor:), "InsertNewline");
+ map->add(@selector(insertParagraphSeparator:), "InsertNewline");
+ map->add(@selector(insertTabIgnoringFieldEditor:), "InsertTab");
+ map->add(@selector(pageDown:), "MovePageDown");
+ map->add(@selector(pageDownAndModifySelection:), "MovePageDownAndModifySelection");
+ map->add(@selector(pageUp:), "MovePageUp");
+ map->add(@selector(pageUpAndModifySelection:), "MovePageUpAndModifySelection");
+ map->add(@selector(scrollPageDown:), "ScrollPageForward");
+ map->add(@selector(scrollPageUp:), "ScrollPageBackward");
+
+ return map;
+}
+
+static String commandNameForSelector(SEL selector)
+{
+ // Check the exception map first.
+ static const SelectorNameMap* exceptionMap = createSelectorExceptionMap();
+ SelectorNameMap::const_iterator it = exceptionMap->find(selector);
+ if (it != exceptionMap->end())
+ return it->second;
+
+ // Remove the trailing colon.
+ // No need to capitalize the command name since Editor command names are
+ // not case sensitive.
+ const char* selectorName = sel_getName(selector);
+ size_t selectorNameLength = strlen(selectorName);
+ if (selectorNameLength < 2 || selectorName[selectorNameLength - 1] != ':')
+ return String();
+ return String(selectorName, selectorNameLength - 1);
+}
+
+// Editing commands
+
+#define WEBCORE_COMMAND(command) - (void)command:(id)sender { _data->_page->executeEditCommand(commandNameForSelector(_cmd)); }
+
+WEBCORE_COMMAND(alignCenter)
+WEBCORE_COMMAND(alignJustified)
+WEBCORE_COMMAND(alignLeft)
+WEBCORE_COMMAND(alignRight)
+WEBCORE_COMMAND(copy)
+WEBCORE_COMMAND(cut)
+WEBCORE_COMMAND(delete)
+WEBCORE_COMMAND(deleteBackward)
+WEBCORE_COMMAND(deleteBackwardByDecomposingPreviousCharacter)
+WEBCORE_COMMAND(deleteForward)
+WEBCORE_COMMAND(deleteToBeginningOfLine)
+WEBCORE_COMMAND(deleteToBeginningOfParagraph)
+WEBCORE_COMMAND(deleteToEndOfLine)
+WEBCORE_COMMAND(deleteToEndOfParagraph)
+WEBCORE_COMMAND(deleteToMark)
+WEBCORE_COMMAND(deleteWordBackward)
+WEBCORE_COMMAND(deleteWordForward)
+WEBCORE_COMMAND(ignoreSpelling)
+WEBCORE_COMMAND(indent)
+WEBCORE_COMMAND(insertBacktab)
+WEBCORE_COMMAND(insertLineBreak)
+WEBCORE_COMMAND(insertNewline)
+WEBCORE_COMMAND(insertNewlineIgnoringFieldEditor)
+WEBCORE_COMMAND(insertParagraphSeparator)
+WEBCORE_COMMAND(insertTab)
+WEBCORE_COMMAND(insertTabIgnoringFieldEditor)
+WEBCORE_COMMAND(makeTextWritingDirectionLeftToRight)
+WEBCORE_COMMAND(makeTextWritingDirectionNatural)
+WEBCORE_COMMAND(makeTextWritingDirectionRightToLeft)
+WEBCORE_COMMAND(moveBackward)
+WEBCORE_COMMAND(moveBackwardAndModifySelection)
+WEBCORE_COMMAND(moveDown)
+WEBCORE_COMMAND(moveDownAndModifySelection)
+WEBCORE_COMMAND(moveForward)
+WEBCORE_COMMAND(moveForwardAndModifySelection)
+WEBCORE_COMMAND(moveLeft)
+WEBCORE_COMMAND(moveLeftAndModifySelection)
+WEBCORE_COMMAND(moveParagraphBackwardAndModifySelection)
+WEBCORE_COMMAND(moveParagraphForwardAndModifySelection)
+WEBCORE_COMMAND(moveRight)
+WEBCORE_COMMAND(moveRightAndModifySelection)
+WEBCORE_COMMAND(moveToBeginningOfDocument)
+WEBCORE_COMMAND(moveToBeginningOfDocumentAndModifySelection)
+WEBCORE_COMMAND(moveToBeginningOfLine)
+WEBCORE_COMMAND(moveToBeginningOfLineAndModifySelection)
+WEBCORE_COMMAND(moveToBeginningOfParagraph)
+WEBCORE_COMMAND(moveToBeginningOfParagraphAndModifySelection)
+WEBCORE_COMMAND(moveToBeginningOfSentence)
+WEBCORE_COMMAND(moveToBeginningOfSentenceAndModifySelection)
+WEBCORE_COMMAND(moveToEndOfDocument)
+WEBCORE_COMMAND(moveToEndOfDocumentAndModifySelection)
+WEBCORE_COMMAND(moveToEndOfLine)
+WEBCORE_COMMAND(moveToEndOfLineAndModifySelection)
+WEBCORE_COMMAND(moveToEndOfParagraph)
+WEBCORE_COMMAND(moveToEndOfParagraphAndModifySelection)
+WEBCORE_COMMAND(moveToEndOfSentence)
+WEBCORE_COMMAND(moveToEndOfSentenceAndModifySelection)
+WEBCORE_COMMAND(moveToLeftEndOfLine)
+WEBCORE_COMMAND(moveToLeftEndOfLineAndModifySelection)
+WEBCORE_COMMAND(moveToRightEndOfLine)
+WEBCORE_COMMAND(moveToRightEndOfLineAndModifySelection)
+WEBCORE_COMMAND(moveUp)
+WEBCORE_COMMAND(moveUpAndModifySelection)
+WEBCORE_COMMAND(moveWordBackward)
+WEBCORE_COMMAND(moveWordBackwardAndModifySelection)
+WEBCORE_COMMAND(moveWordForward)
+WEBCORE_COMMAND(moveWordForwardAndModifySelection)
+WEBCORE_COMMAND(moveWordLeft)
+WEBCORE_COMMAND(moveWordLeftAndModifySelection)
+WEBCORE_COMMAND(moveWordRight)
+WEBCORE_COMMAND(moveWordRightAndModifySelection)
+WEBCORE_COMMAND(outdent)
+WEBCORE_COMMAND(pageDown)
+WEBCORE_COMMAND(pageDownAndModifySelection)
+WEBCORE_COMMAND(pageUp)
+WEBCORE_COMMAND(pageUpAndModifySelection)
+WEBCORE_COMMAND(paste)
+WEBCORE_COMMAND(pasteAsPlainText)
+WEBCORE_COMMAND(scrollPageDown)
+WEBCORE_COMMAND(scrollPageUp)
+WEBCORE_COMMAND(scrollLineDown)
+WEBCORE_COMMAND(scrollLineUp)
+WEBCORE_COMMAND(scrollToBeginningOfDocument)
+WEBCORE_COMMAND(scrollToEndOfDocument)
+WEBCORE_COMMAND(selectAll)
+WEBCORE_COMMAND(selectLine)
+WEBCORE_COMMAND(selectParagraph)
+WEBCORE_COMMAND(selectSentence)
+WEBCORE_COMMAND(selectToMark)
+WEBCORE_COMMAND(selectWord)
+WEBCORE_COMMAND(setMark)
+WEBCORE_COMMAND(subscript)
+WEBCORE_COMMAND(superscript)
+WEBCORE_COMMAND(swapWithMark)
+WEBCORE_COMMAND(takeFindStringFromSelection)
+WEBCORE_COMMAND(transpose)
+WEBCORE_COMMAND(underline)
+WEBCORE_COMMAND(unscript)
+WEBCORE_COMMAND(yank)
+WEBCORE_COMMAND(yankAndSelect)
+
+#undef WEBCORE_COMMAND
+
+// This method is needed to support Mac OS X services.
+
+- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pasteboard types:(NSArray *)types
+{
+ Vector<String> pasteboardTypes;
+ size_t numTypes = [types count];
+ for (size_t i = 0; i < numTypes; ++i)
+ pasteboardTypes.append([types objectAtIndex:i]);
+ return _data->_page->writeSelectionToPasteboard([pasteboard name], pasteboardTypes);
+}
+
+- (void)centerSelectionInVisibleArea:(id)sender
+{
+ _data->_page->centerSelectionInVisibleArea();
+}
+
+// This method is needed to support Mac OS X services.
+
+- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
+{
+ BOOL isValidSendType = !sendType || ([PasteboardTypes::forSelection() containsObject:sendType] && !_data->_page->editorState().selectionIsNone);
+ BOOL isValidReturnType = NO;
+ if (!returnType)
+ isValidReturnType = YES;
+ else if ([PasteboardTypes::forEditing() containsObject:returnType] && _data->_page->editorState().isContentEditable) {
+ // We can insert strings in any editable context. We can insert other types, like images, only in rich edit contexts.
+ isValidReturnType = _data->_page->editorState().isContentRichlyEditable || [returnType isEqualToString:NSStringPboardType];
+ }
+ if (isValidSendType && isValidReturnType)
+ return self;
+ return [[self nextResponder] validRequestorForSendType:sendType returnType:returnType];
+}
+
+// This method is needed to support Mac OS X services.
+
+- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pasteboard
+{
+ return _data->_page->readSelectionFromPasteboard([pasteboard name]);
+}
+
+/*
+
+When possible, editing-related methods should be implemented in WebCore with the
+EditorCommand mechanism and invoked via WEBCORE_COMMAND, rather than implementing
+individual methods here with Mac-specific code.
+
+Editing-related methods still unimplemented that are implemented in WebKit1:
+
+- (void)capitalizeWord:(id)sender;
+- (void)changeFont:(id)sender;
+- (void)complete:(id)sender;
+- (void)copyFont:(id)sender;
+- (void)lowercaseWord:(id)sender;
+- (void)makeBaseWritingDirectionLeftToRight:(id)sender;
+- (void)makeBaseWritingDirectionNatural:(id)sender;
+- (void)makeBaseWritingDirectionRightToLeft:(id)sender;
+- (void)pasteFont:(id)sender;
+- (void)scrollLineDown:(id)sender;
+- (void)scrollLineUp:(id)sender;
+- (void)showGuessPanel:(id)sender;
+- (void)uppercaseWord:(id)sender;
+
+Some other editing-related methods still unimplemented:
+
+- (void)changeCaseOfLetter:(id)sender;
+- (void)copyRuler:(id)sender;
+- (void)insertContainerBreak:(id)sender;
+- (void)insertDoubleQuoteIgnoringSubstitution:(id)sender;
+- (void)insertSingleQuoteIgnoringSubstitution:(id)sender;
+- (void)pasteRuler:(id)sender;
+- (void)toggleRuler:(id)sender;
+- (void)transposeWords:(id)sender;
+
+*/
+
+// Menu items validation
+
+static NSMenuItem *menuItem(id <NSValidatedUserInterfaceItem> item)
+{
+ if (![(NSObject *)item isKindOfClass:[NSMenuItem class]])
+ return nil;
+ return (NSMenuItem *)item;
+}
+
+static NSToolbarItem *toolbarItem(id <NSValidatedUserInterfaceItem> item)
+{
+ if (![(NSObject *)item isKindOfClass:[NSToolbarItem class]])
+ return nil;
+ return (NSToolbarItem *)item;
+}
+
+static void validateCommandCallback(WKStringRef commandName, bool isEnabled, int32_t state, WKErrorRef error, void* context)
+{
+ // If the process exits before the command can be validated, we'll be called back with an error.
+ if (error)
+ return;
+
+ WKView* wkView = static_cast<WKView*>(context);
+ ASSERT(wkView);
+
+ [wkView _setUserInterfaceItemState:nsStringFromWebCoreString(toImpl(commandName)->string()) enabled:isEnabled state:state];
+}
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+ SEL action = [item action];
+
+ if (action == @selector(showGuessPanel:)) {
+ if (NSMenuItem *menuItem = ::menuItem(item))
+ [menuItem setTitle:contextMenuItemTagShowSpellingPanel(![[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible])];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:))
+ return _data->_page->editorState().isContentEditable;
+
+ if (action == @selector(toggleContinuousSpellChecking:)) {
+ bool enabled = TextChecker::isContinuousSpellCheckingAllowed();
+ bool checked = enabled && TextChecker::state().isContinuousSpellCheckingEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return enabled;
+ }
+
+ if (action == @selector(toggleGrammarChecking:)) {
+ bool checked = TextChecker::state().isGrammarCheckingEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return YES;
+ }
+
+ if (action == @selector(toggleAutomaticSpellingCorrection:)) {
+ bool checked = TextChecker::state().isAutomaticSpellingCorrectionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(orderFrontSubstitutionsPanel:)) {
+ if (NSMenuItem *menuItem = ::menuItem(item))
+ [menuItem setTitle:contextMenuItemTagShowSubstitutions(![[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible])];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleSmartInsertDelete:)) {
+ bool checked = _data->_page->isSmartInsertDeleteEnabled();
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticDashSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticLinkDetection:)) {
+ bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticTextReplacement:)) {
+ bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->editorState().isContentEditable;
+ }
+
+ if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:))
+ return _data->_page->editorState().selectionIsRange && _data->_page->editorState().isContentEditable;
+
+ if (action == @selector(stopSpeaking:))
+ return [NSApp isSpeaking];
+
+ // The centerSelectionInVisibleArea: selector is enabled if there's a selection range or if there's an insertion point in an editable area.
+ if (action == @selector(centerSelectionInVisibleArea:))
+ return _data->_page->editorState().selectionIsRange || (_data->_page->editorState().isContentEditable && !_data->_page->editorState().selectionIsNone);
+
+ // Next, handle editor commands. Start by returning YES for anything that is not an editor command.
+ // Returning YES is the default thing to do in an AppKit validate method for any selector that is not recognized.
+ String commandName = commandNameForSelector([item action]);
+ if (!Editor::commandIsSupportedFromMenuOrKeyBinding(commandName))
+ return YES;
+
+ // Add this item to the vector of items for a given command that are awaiting validation.
+ pair<ValidationMap::iterator, bool> addResult = _data->_validationMap.add(commandName, ValidationVector());
+ addResult.first->second.append(item);
+ if (addResult.second) {
+ // If we are not already awaiting validation for this command, start the asynchronous validation process.
+ // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
+ // we asked for the same command; there is no guarantee the answer is still valid.
+ _data->_page->validateCommand(commandName, ValidateCommandCallback::create(self, validateCommandCallback));
+ }
+
+ // Treat as enabled until we get the result back from the web process and _setUserInterfaceItemState is called.
+ // FIXME <rdar://problem/8803459>: This means disabled items will flash enabled at first for a moment.
+ // But returning NO here would be worse; that would make keyboard commands such as command-C fail.
+ return YES;
+}
+
+static void speakString(WKStringRef string, WKErrorRef error, void*)
+{
+ if (error)
+ return;
+ if (!string)
+ return;
+
+ NSString *convertedString = toImpl(string)->string();
+ [NSApp speakString:convertedString];
+}
+
+- (IBAction)startSpeaking:(id)sender
+{
+ _data->_page->getSelectionOrContentsAsString(StringCallback::create(0, speakString));
+}
+
+- (IBAction)stopSpeaking:(id)sender
+{
+ [NSApp stopSpeaking:sender];
+}
+
+- (IBAction)showGuessPanel:(id)sender
+{
+ NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+ if (!checker) {
+ LOG_ERROR("No NSSpellChecker");
+ return;
+ }
+
+ NSPanel *spellingPanel = [checker spellingPanel];
+ if ([spellingPanel isVisible]) {
+ [spellingPanel orderOut:sender];
+ return;
+ }
+
+ _data->_page->advanceToNextMisspelling(true);
+ [spellingPanel orderFront:sender];
+}
+
+- (IBAction)checkSpelling:(id)sender
+{
+ _data->_page->advanceToNextMisspelling(false);
+}
+
+- (void)changeSpelling:(id)sender
+{
+ NSString *word = [[sender selectedCell] stringValue];
+
+ _data->_page->changeSpellingToWord(word);
+}
+
+- (IBAction)toggleContinuousSpellChecking:(id)sender
+{
+ bool spellCheckingEnabled = !TextChecker::state().isContinuousSpellCheckingEnabled;
+ TextChecker::setContinuousSpellCheckingEnabled(spellCheckingEnabled);
+
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isGrammarCheckingEnabled
+{
+ return TextChecker::state().isGrammarCheckingEnabled;
+}
+
+- (void)setGrammarCheckingEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isGrammarCheckingEnabled)
+ return;
+
+ TextChecker::setGrammarCheckingEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (IBAction)toggleGrammarChecking:(id)sender
+{
+ bool grammarCheckingEnabled = !TextChecker::state().isGrammarCheckingEnabled;
+ TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled);
+
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (IBAction)toggleAutomaticSpellingCorrection:(id)sender
+{
+ TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
+
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)orderFrontSubstitutionsPanel:(id)sender
+{
+ NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+ if (!checker) {
+ LOG_ERROR("No NSSpellChecker");
+ return;
+ }
+
+ NSPanel *substitutionsPanel = [checker substitutionsPanel];
+ if ([substitutionsPanel isVisible]) {
+ [substitutionsPanel orderOut:sender];
+ return;
+ }
+ [substitutionsPanel orderFront:sender];
+}
+
+- (IBAction)toggleSmartInsertDelete:(id)sender
+{
+ _data->_page->setSmartInsertDeleteEnabled(!_data->_page->isSmartInsertDeleteEnabled());
+}
+
+- (BOOL)isAutomaticQuoteSubstitutionEnabled
+{
+ return TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+}
+
+- (void)setAutomaticQuoteSubstitutionEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isAutomaticQuoteSubstitutionEnabled)
+ return;
+
+ TextChecker::setAutomaticQuoteSubstitutionEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticQuoteSubstitution:(id)sender
+{
+ TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticDashSubstitutionEnabled
+{
+ return TextChecker::state().isAutomaticDashSubstitutionEnabled;
+}
+
+- (void)setAutomaticDashSubstitutionEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isAutomaticDashSubstitutionEnabled)
+ return;
+
+ TextChecker::setAutomaticDashSubstitutionEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticDashSubstitution:(id)sender
+{
+ TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticLinkDetectionEnabled
+{
+ return TextChecker::state().isAutomaticLinkDetectionEnabled;
+}
+
+- (void)setAutomaticLinkDetectionEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isAutomaticLinkDetectionEnabled)
+ return;
+
+ TextChecker::setAutomaticLinkDetectionEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticLinkDetection:(id)sender
+{
+ TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (BOOL)isAutomaticTextReplacementEnabled
+{
+ return TextChecker::state().isAutomaticTextReplacementEnabled;
+}
+
+- (void)setAutomaticTextReplacementEnabled:(BOOL)flag
+{
+ if (static_cast<bool>(flag) == TextChecker::state().isAutomaticTextReplacementEnabled)
+ return;
+
+ TextChecker::setAutomaticTextReplacementEnabled(flag);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)toggleAutomaticTextReplacement:(id)sender
+{
+ TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
+ _data->_page->process()->updateTextCheckerState();
+}
+
+- (void)uppercaseWord:(id)sender
+{
+ _data->_page->uppercaseWord();
+}
+
+- (void)lowercaseWord:(id)sender
+{
+ _data->_page->lowercaseWord();
+}
+
+- (void)capitalizeWord:(id)sender
+{
+ _data->_page->capitalizeWord();
+}
+
+- (void)displayIfNeeded
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // FIXME: We should remove this code when <rdar://problem/9362085> is resolved. In the meantime,
+ // it is necessary to disable scren updates so we get a chance to redraw the corners before this
+ // display is visible.
+ NSWindow *window = [self window];
+ BOOL shouldMaskWindow = window && !NSIsEmptyRect(_data->_windowBottomCornerIntersectionRect);
+ if (shouldMaskWindow)
+ NSDisableScreenUpdates();
+#endif
+
+ [super displayIfNeeded];
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (shouldMaskWindow) {
+ [window _maskRoundedBottomCorners:_data->_windowBottomCornerIntersectionRect];
+ NSEnableScreenUpdates();
+ _data->_windowBottomCornerIntersectionRect = NSZeroRect;
+ }
+#endif
+}
+
+// Events
+
+// Override this so that AppKit will send us arrow keys as key down events so we can
+// support them via the key bindings mechanism.
+- (BOOL)_wantsKeyDownForEvent:(NSEvent *)event
+{
+ return YES;
+}
+
+- (void)_setMouseDownEvent:(NSEvent *)event
+{
+ ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown);
+
+ if (event == _data->_mouseDownEvent)
+ return;
+
+ [_data->_mouseDownEvent release];
+ _data->_mouseDownEvent = [event retain];
+}
+
+#define NATIVE_MOUSE_EVENT_HANDLER(Selector) \
+ - (void)Selector:(NSEvent *)theEvent \
+ { \
+ if ([[self inputContext] handleEvent:theEvent]) { \
+ LOG(TextInput, "%s was handled by text input context", String(#Selector).substring(0, String(#Selector).find("Internal")).ascii().data()); \
+ return; \
+ } \
+ NativeWebMouseEvent webEvent(theEvent, self); \
+ _data->_page->handleMouseEvent(webEvent); \
+ }
+
+NATIVE_MOUSE_EVENT_HANDLER(mouseEntered)
+NATIVE_MOUSE_EVENT_HANDLER(mouseExited)
+NATIVE_MOUSE_EVENT_HANDLER(mouseMovedInternal)
+NATIVE_MOUSE_EVENT_HANDLER(mouseDownInternal)
+NATIVE_MOUSE_EVENT_HANDLER(mouseUpInternal)
+NATIVE_MOUSE_EVENT_HANDLER(mouseDraggedInternal)
+NATIVE_MOUSE_EVENT_HANDLER(otherMouseDown)
+NATIVE_MOUSE_EVENT_HANDLER(otherMouseDragged)
+NATIVE_MOUSE_EVENT_HANDLER(otherMouseMoved)
+NATIVE_MOUSE_EVENT_HANDLER(otherMouseUp)
+NATIVE_MOUSE_EVENT_HANDLER(rightMouseDown)
+NATIVE_MOUSE_EVENT_HANDLER(rightMouseDragged)
+NATIVE_MOUSE_EVENT_HANDLER(rightMouseUp)
+
+#undef NATIVE_MOUSE_EVENT_HANDLER
+
+#define NATIVE_EVENT_HANDLER(Selector, Type) \
+ - (void)Selector:(NSEvent *)theEvent \
+ { \
+ NativeWeb##Type##Event webEvent = NativeWeb##Type##Event(theEvent, self); \
+ _data->_page->handle##Type##Event(webEvent); \
+ }
+
+NATIVE_EVENT_HANDLER(scrollWheel, Wheel)
+
+#undef NATIVE_EVENT_HANDLER
+
+- (void)mouseMoved:(NSEvent *)event
+{
+ // When a view is first responder, it gets mouse moved events even when the mouse is outside its visible rect.
+ if (self == [[self window] firstResponder] && !NSPointInRect([self convertPoint:[event locationInWindow] fromView:nil], [self visibleRect]))
+ return;
+
+ [self mouseMovedInternal:event];
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+ [self _setMouseDownEvent:event];
+ _data->_ignoringMouseDraggedEvents = NO;
+ _data->_dragHasStarted = NO;
+ [self mouseDownInternal:event];
+}
+
+- (void)mouseUp:(NSEvent *)event
+{
+ [self _setMouseDownEvent:nil];
+ [self mouseUpInternal:event];
+}
+
+- (void)mouseDragged:(NSEvent *)event
+{
+ if (_data->_ignoringMouseDraggedEvents)
+ return;
+ [self mouseDraggedInternal:event];
+}
+
+- (BOOL)acceptsFirstMouse:(NSEvent *)event
+{
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[event retain] autorelease];
+
+ if (![self hitTest:[event locationInWindow]])
+ return NO;
+
+ [self _setMouseDownEvent:event];
+ bool result = _data->_page->acceptsFirstMouse([event eventNumber], WebEventFactory::createWebMouseEvent(event, self));
+ [self _setMouseDownEvent:nil];
+ return result;
+}
+
+- (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event
+{
+ // If this is the active window or we don't have a range selection, there is no need to perform additional checks
+ // and we can avoid making a synchronous call to the WebProcess.
+ if ([[self window] isKeyWindow] || _data->_page->editorState().selectionIsNone || !_data->_page->editorState().selectionIsRange)
+ return NO;
+
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[event retain] autorelease];
+
+ if (![self hitTest:[event locationInWindow]])
+ return NO;
+
+ [self _setMouseDownEvent:event];
+ bool result = _data->_page->shouldDelayWindowOrderingForEvent(WebEventFactory::createWebMouseEvent(event, self));
+ [self _setMouseDownEvent:nil];
+ return result;
+}
+
+#if ENABLE(GESTURE_EVENTS)
+
+static const short kIOHIDEventTypeScroll = 6;
+
+- (void)shortCircuitedEndGestureWithEvent:(NSEvent *)event
+{
+ if ([event subtype] != kIOHIDEventTypeScroll)
+ return;
+
+ WebGestureEvent webEvent = WebEventFactory::createWebGestureEvent(event, self);
+ _data->_page->handleGestureEvent(webEvent);
+
+ if (_data->_endGestureMonitor) {
+ [NSEvent removeMonitor:_data->_endGestureMonitor];
+ _data->_endGestureMonitor = nil;
+ }
+}
+
+- (void)beginGestureWithEvent:(NSEvent *)event
+{
+ if ([event subtype] != kIOHIDEventTypeScroll)
+ return;
+
+ WebGestureEvent webEvent = WebEventFactory::createWebGestureEvent(event, self);
+ _data->_page->handleGestureEvent(webEvent);
+
+ if (!_data->_endGestureMonitor) {
+ _data->_endGestureMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskEndGesture handler:^(NSEvent *blockEvent) {
+ [self shortCircuitedEndGestureWithEvent:blockEvent];
+ return blockEvent;
+ }];
+ }
+}
+#endif
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ LOG(TextInput, "doCommandBySelector:\"%s\"", sel_getName(selector));
+
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+ if (parameters)
+ parameters->consumedByIM = false;
+
+ // As in insertText:replacementRange:, we assume that the call comes from an input method if there is marked text.
+ bool isFromInputMethod = _data->_page->editorState().hasComposition;
+
+ if (parameters && !isFromInputMethod)
+ parameters->commands->append(KeypressCommand(NSStringFromSelector(selector)));
+ else {
+ // FIXME: Send the command to Editor synchronously and only send it along the
+ // responder chain if it's a selector that does not correspond to an editing command.
+ [super doCommandBySelector:selector];
+ }
+}
+
+- (void)insertText:(id)string
+{
+ // Unlike and NSTextInputClient variant with replacementRange, this NSResponder method is called when there is no input context,
+ // so text input processing isn't performed. We are not going to actually insert any text in that case, but saving an insertText
+ // command ensures that a keypress event is dispatched as appropriate.
+ [self insertText:string replacementRange:NSMakeRange(NSNotFound, 0)];
+}
+
+- (void)insertText:(id)string replacementRange:(NSRange)replacementRange
+{
+ BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
+ ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]);
+
+ if (replacementRange.location != NSNotFound)
+ LOG(TextInput, "insertText:\"%@\" replacementRange:(%u, %u)", isAttributedString ? [string string] : string, replacementRange.location, replacementRange.length);
+ else
+ LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string);
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+ if (parameters)
+ parameters->consumedByIM = false;
+
+ NSString *text;
+ bool isFromInputMethod = _data->_page->editorState().hasComposition;
+
+ if (isAttributedString) {
+ // FIXME: We ignore most attributes from the string, so for example inserting from Character Palette loses font and glyph variation data.
+ text = [string string];
+ } else
+ text = string;
+
+ // insertText can be called for several reasons:
+ // - If it's from normal key event processing (including key bindings), we may need to save the action to perform it later.
+ // - If it's from an input method, then we should go ahead and insert the text now. We assume it's from the input method if we have marked text.
+ // FIXME: In theory, this could be wrong for some input methods, so we should try to find another way to determine if the call is from the input method.
+ // - If it's sent outside of keyboard event processing (e.g. from Character Viewer, or when confirming an inline input area with a mouse),
+ // then we also execute it immediately, as there will be no other chance.
+ if (parameters && !isFromInputMethod) {
+ ASSERT(replacementRange.location == NSNotFound);
+ parameters->commands->append(KeypressCommand("insertText:", text));
+ return;
+ }
+
+ String eventText = text;
+ eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
+ bool eventHandled = _data->_page->insertText(eventText, replacementRange.location, NSMaxRange(replacementRange));
+
+ if (parameters)
+ parameters->eventInterpretationHadSideEffects |= eventHandled;
+}
+
+- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
+{
+ if (!_data->_page->editorState().isContentEditable)
+ return NO;
+
+ if (([event modifierFlags] & NSDeviceIndependentModifierFlagsMask) != NSCommandKeyMask)
+ return NO;
+
+ // Here we special case cmd+b and cmd+i but not cmd+u, for historic reason.
+ // This should not be changed, since it could break some Mac applications that
+ // rely on this inherent behavior.
+ // See https://bugs.webkit.org/show_bug.cgi?id=24943
+
+ NSString *string = [event characters];
+ if ([string caseInsensitiveCompare:@"b"] == NSOrderedSame) {
+ _data->_page->executeEditCommand("ToggleBold");
+ return YES;
+ }
+ if ([string caseInsensitiveCompare:@"i"] == NSOrderedSame) {
+ _data->_page->executeEditCommand("ToggleItalic");
+ return YES;
+ }
+
+ return NO;
+}
+
+- (BOOL)performKeyEquivalent:(NSEvent *)event
+{
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[event retain] autorelease];
+
+ BOOL eventWasSentToWebCore = (_data->_keyDownEventBeingResent == event);
+
+ if (!eventWasSentToWebCore)
+ [self _disableComplexTextInputIfNecessary];
+
+ // Pass key combos through WebCore if there is a key binding available for
+ // this event. This lets web pages have a crack at intercepting key-modified keypresses.
+ // But don't do it if we have already handled the event.
+ // Pressing Esc results in a fake event being sent - don't pass it to WebCore.
+ if (!eventWasSentToWebCore && event == [NSApp currentEvent] && self == [[self window] firstResponder]) {
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(event, self));
+ return YES;
+ }
+
+ return [self _handleStyleKeyEquivalent:event] || [super performKeyEquivalent:event];
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
+- (void)_disableComplexTextInputIfNecessary
+{
+ if (!_data->_pluginComplexTextInputIdentifier)
+ return;
+
+ if (_data->_pluginComplexTextInputState != PluginComplexTextInputEnabled)
+ return;
+
+ // Check if the text input window has been dismissed.
+ if (![[WKTextInputWindowController sharedTextInputWindowController] hasMarkedText])
+ [self _setPluginComplexTextInputState:PluginComplexTextInputDisabled];
+}
+
+- (BOOL)_handlePluginComplexTextInputKeyDown:(NSEvent *)event
+{
+ ASSERT(_data->_pluginComplexTextInputIdentifier);
+ ASSERT(_data->_pluginComplexTextInputState != PluginComplexTextInputDisabled);
+
+ BOOL usingLegacyCocoaTextInput = _data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy;
+
+ NSString *string = nil;
+ BOOL didHandleEvent = [[WKTextInputWindowController sharedTextInputWindowController] interpretKeyEvent:event usingLegacyCocoaTextInput:usingLegacyCocoaTextInput string:&string];
+
+ if (string) {
+ _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, string);
+
+ if (!usingLegacyCocoaTextInput)
+ _data->_pluginComplexTextInputState = PluginComplexTextInputDisabled;
+ }
+
+ return didHandleEvent;
+}
+
+- (BOOL)_tryHandlePluginComplexTextInputKeyDown:(NSEvent *)event
+{
+ if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
+ return NO;
+
+ // Check if the text input window has been dismissed and let the plug-in process know.
+ // This is only valid with the updated Cocoa text input spec.
+ [self _disableComplexTextInputIfNecessary];
+
+ // Try feeding the keyboard event directly to the plug-in.
+ if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
+ return [self _handlePluginComplexTextInputKeyDown:event];
+
+ return NO;
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[theEvent retain] autorelease];
+
+ if ([self _tryHandlePluginComplexTextInputKeyDown:theEvent])
+ return;
+
+ // We could be receiving a key down from AppKit if we have re-sent an event
+ // that maps to an action that is currently unavailable (for example a copy when
+ // there is no range selection).
+ // If this is the case we should ignore the key down.
+ if (_data->_keyDownEventBeingResent == theEvent) {
+ [super keyDown:theEvent];
+ return;
+ }
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+ // There's a chance that responding to this event will run a nested event loop, and
+ // fetching a new event might release the old one. Retaining and then autoreleasing
+ // the current event prevents that from causing a problem inside WebKit or AppKit code.
+ [[theEvent retain] autorelease];
+
+ unsigned short keyCode = [theEvent keyCode];
+
+ // Don't make an event from the num lock and function keys
+ if (!keyCode || keyCode == 10 || keyCode == 63)
+ return;
+
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
+- (void)_executeSavedKeypressCommands
+{
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+ if (!parameters || parameters->commands->isEmpty())
+ return;
+
+ // We could be called again if the execution of one command triggers a call to selectedRange.
+ // In this case, the state is up to date, and we don't need to execute any more saved commands to return a result.
+ if (parameters->executingSavedKeypressCommands)
+ return;
+
+ parameters->executingSavedKeypressCommands = true;
+ parameters->eventInterpretationHadSideEffects |= _data->_page->executeKeypressCommands(*parameters->commands);
+ parameters->commands->clear();
+ parameters->executingSavedKeypressCommands = false;
+}
+
+- (void)_notifyInputContextAboutDiscardedComposition
+{
+ // <rdar://problem/9359055>: -discardMarkedText can only be called for active contexts.
+ // FIXME: We fail to ever notify the input context if something (e.g. a navigation) happens while the window is not key.
+ // This is not a problem when the window is key, because we discard marked text on resigning first responder.
+ if (![[self window] isKeyWindow] || self != [[self window] firstResponder])
+ return;
+
+ [[super inputContext] discardMarkedText]; // Inform the input method that we won't have an inline input area despite having been asked to.
+}
+
+- (NSTextInputContext *)inputContext
+{
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+
+ if (_data->_pluginComplexTextInputIdentifier && !parameters)
+ return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
+
+ // Disable text input machinery when in non-editable content. An invisible inline input area affects performance, and can prevent Expose from working.
+ if (!_data->_page->editorState().isContentEditable)
+ return nil;
+
+ return [super inputContext];
+}
+
+- (NSRange)selectedRange
+{
+ [self _executeSavedKeypressCommands];
+
+ uint64_t selectionStart;
+ uint64_t selectionLength;
+ _data->_page->getSelectedRange(selectionStart, selectionLength);
+
+ NSRange result = NSMakeRange(selectionStart, selectionLength);
+ if (result.location == NSNotFound)
+ LOG(TextInput, "selectedRange -> (NSNotFound, %u)", result.length);
+ else
+ LOG(TextInput, "selectedRange -> (%u, %u)", result.location, result.length);
+
+ return result;
+}
+
+- (BOOL)hasMarkedText
+{
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+
+ BOOL result;
+ if (parameters) {
+ result = _data->_page->editorState().hasComposition;
+ if (result) {
+ // A saved command can confirm a composition, but it cannot start a new one.
+ [self _executeSavedKeypressCommands];
+ result = _data->_page->editorState().hasComposition;
+ }
+ } else {
+ uint64_t location;
+ uint64_t length;
+ _data->_page->getMarkedRange(location, length);
+ result = location != NSNotFound;
+ }
+
+ LOG(TextInput, "hasMarkedText -> %u", result);
+ return result;
+}
+
+- (void)unmarkText
+{
+ [self _executeSavedKeypressCommands];
+
+ LOG(TextInput, "unmarkText");
+
+ // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+
+ if (parameters) {
+ parameters->eventInterpretationHadSideEffects = true;
+ parameters->consumedByIM = false;
+ }
+
+ _data->_page->confirmComposition();
+}
+
+- (NSArray *)validAttributesForMarkedText
+{
+ static NSArray *validAttributes;
+ if (!validAttributes) {
+ validAttributes = [[NSArray alloc] initWithObjects:
+ NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
+ NSMarkedClauseSegmentAttributeName, nil];
+ // NSText also supports the following attributes, but it's
+ // hard to tell which are really required for text input to
+ // work well; I have not seen any input method make use of them yet.
+ // NSFontAttributeName, NSForegroundColorAttributeName,
+ // NSBackgroundColorAttributeName, NSLanguageAttributeName.
+ CFRetain(validAttributes);
+ }
+ LOG(TextInput, "validAttributesForMarkedText -> (...)");
+ return validAttributes;
+}
+
+static void extractUnderlines(NSAttributedString *string, Vector<CompositionUnderline>& result)
+{
+ int length = [[string string] length];
+
+ int i = 0;
+ while (i < length) {
+ NSRange range;
+ NSDictionary *attrs = [string attributesAtIndex:i longestEffectiveRange:&range inRange:NSMakeRange(i, length - i)];
+
+ if (NSNumber *style = [attrs objectForKey:NSUnderlineStyleAttributeName]) {
+ Color color = Color::black;
+ if (NSColor *colorAttr = [attrs objectForKey:NSUnderlineColorAttributeName])
+ color = colorFromNSColor([colorAttr colorUsingColorSpaceName:NSDeviceRGBColorSpace]);
+ result.append(CompositionUnderline(range.location, NSMaxRange(range), color, [style intValue] > 1));
+ }
+
+ i = range.location + range.length;
+ }
+}
+
+- (void)setMarkedText:(id)string selectedRange:(NSRange)newSelRange replacementRange:(NSRange)replacementRange
+{
+ [self _executeSavedKeypressCommands];
+
+ BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]];
+ ASSERT(isAttributedString || [string isKindOfClass:[NSString class]]);
+
+ LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length);
+
+ // Use pointer to get parameters passed to us by the caller of interpretKeyEvents.
+ WKViewInterpretKeyEventsParameters* parameters = _data->_interpretKeyEventsParameters;
+
+ if (parameters) {
+ parameters->eventInterpretationHadSideEffects = true;
+ parameters->consumedByIM = false;
+ }
+
+ Vector<CompositionUnderline> underlines;
+ NSString *text;
+
+ if (isAttributedString) {
+ // FIXME: We ignore most attributes from the string, so an input method cannot specify e.g. a font or a glyph variation.
+ text = [string string];
+ extractUnderlines(string, underlines);
+ } else
+ text = string;
+
+ if (_data->_page->editorState().isInPasswordField) {
+ // In password fields, we only allow ASCII dead keys, and don't allow inline input, matching NSSecureTextInputField.
+ // Allowing ASCII dead keys is necessary to enable full Roman input when using a Vietnamese keyboard.
+ ASSERT(!_data->_page->editorState().hasComposition);
+ [self _notifyInputContextAboutDiscardedComposition];
+ if ([text length] == 1 && [[text decomposedStringWithCanonicalMapping] characterAtIndex:0] < 0x80) {
+ _data->_page->insertText(text, replacementRange.location, NSMaxRange(replacementRange));
+ } else
+ NSBeep();
+ return;
+ }
+
+ _data->_page->setComposition(text, underlines, newSelRange.location, NSMaxRange(newSelRange), replacementRange.location, NSMaxRange(replacementRange));
+}
+
+- (NSRange)markedRange
+{
+ [self _executeSavedKeypressCommands];
+
+ uint64_t location;
+ uint64_t length;
+ _data->_page->getMarkedRange(location, length);
+
+ LOG(TextInput, "markedRange -> (%u, %u)", location, length);
+ return NSMakeRange(location, length);
+}
+
+- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)nsRange actualRange:(NSRangePointer)actualRange
+{
+ [self _executeSavedKeypressCommands];
+
+ if (!_data->_page->editorState().isContentEditable) {
+ LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> nil", nsRange.location, nsRange.length);
+ return nil;
+ }
+
+ if (_data->_page->editorState().isInPasswordField)
+ return nil;
+
+ AttributedString result;
+ _data->_page->getAttributedSubstringFromRange(nsRange.location, NSMaxRange(nsRange), result);
+
+ if (actualRange) {
+ *actualRange = nsRange;
+ actualRange->length = [result.string.get() length];
+ }
+
+ LOG(TextInput, "attributedSubstringFromRange:(%u, %u) -> \"%@\"", nsRange.location, nsRange.length, [result.string.get() string]);
+ return [[result.string.get() retain] autorelease];
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
+{
+ [self _executeSavedKeypressCommands];
+
+ NSWindow *window = [self window];
+
+ if (window)
+ thePoint = [window convertScreenToBase:thePoint];
+ thePoint = [self convertPoint:thePoint fromView:nil]; // the point is relative to the main frame
+
+ uint64_t result = _data->_page->characterIndexForPoint(IntPoint(thePoint));
+ LOG(TextInput, "characterIndexForPoint:(%f, %f) -> %u", thePoint.x, thePoint.y, result);
+ return result;
+}
+
+- (NSRect)firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange
+{
+ [self _executeSavedKeypressCommands];
+
+ // Just to match NSTextView's behavior. Regression tests cannot detect this;
+ // to reproduce, use a test application from http://bugs.webkit.org/show_bug.cgi?id=4682
+ // (type something; try ranges (1, -1) and (2, -1).
+ if ((theRange.location + theRange.length < theRange.location) && (theRange.location + theRange.length != 0))
+ theRange.length = 0;
+
+ NSRect resultRect = _data->_page->firstRectForCharacterRange(theRange.location, theRange.length);
+ resultRect = [self convertRect:resultRect toView:nil];
+
+ NSWindow *window = [self window];
+ if (window)
+ resultRect.origin = [window convertBaseToScreen:resultRect.origin];
+
+ if (actualRange) {
+ // FIXME: Update actualRange to match the range of first rect.
+ *actualRange = theRange;
+ }
+
+ LOG(TextInput, "firstRectForCharacterRange:(%u, %u) -> (%f, %f, %f, %f)", theRange.location, theRange.length, resultRect.origin.x, resultRect.origin.y, resultRect.size.width, resultRect.size.height);
+ return resultRect;
+}
+
+- (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
+{
+ NSPoint windowImageLoc = [[self window] convertScreenToBase:aPoint];
+ NSPoint windowMouseLoc = windowImageLoc;
+
+ // Prevent queued mouseDragged events from coming after the drag and fake mouseUp event.
+ _data->_ignoringMouseDraggedEvents = YES;
+
+ _data->_page->dragEnded(IntPoint(windowMouseLoc), globalPoint(windowMouseLoc, [self window]), operation);
+}
+
+- (DragApplicationFlags)applicationFlags:(id <NSDraggingInfo>)draggingInfo
+{
+ uint32_t flags = 0;
+ if ([NSApp modalWindow])
+ flags = DragApplicationIsModal;
+ if ([[self window] attachedSheet])
+ flags |= DragApplicationHasAttachedSheet;
+ if ([draggingInfo draggingSource] == self)
+ flags |= DragApplicationIsSource;
+ if ([[NSApp currentEvent] modifierFlags] & NSAlternateKeyMask)
+ flags |= DragApplicationIsCopyKeyDown;
+ return static_cast<DragApplicationFlags>(flags);
+}
+
+- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)draggingInfo
+{
+ IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+ IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+ DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+
+ _data->_page->resetDragOperation();
+ _data->_page->dragEntered(&dragData, [[draggingInfo draggingPasteboard] name]);
+ return NSDragOperationCopy;
+}
+
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)draggingInfo
+{
+ IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+ IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+ DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+ _data->_page->dragUpdated(&dragData, [[draggingInfo draggingPasteboard] name]);
+
+ WebCore::DragSession dragSession = _data->_page->dragSession();
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSInteger numberOfValidItemsForDrop = dragSession.numberOfItemsToBeAccepted;
+ NSDraggingFormation draggingFormation = NSDraggingFormationNone;
+ if (dragSession.mouseIsOverFileInput && numberOfValidItemsForDrop > 0)
+ draggingFormation = NSDraggingFormationList;
+
+ if ([draggingInfo numberOfValidItemsForDrop] != numberOfValidItemsForDrop)
+ [draggingInfo setNumberOfValidItemsForDrop:numberOfValidItemsForDrop];
+ if ([draggingInfo draggingFormation] != draggingFormation)
+ [draggingInfo setDraggingFormation:draggingFormation];
+#endif
+ return dragSession.operation;
+}
+
+- (void)draggingExited:(id <NSDraggingInfo>)draggingInfo
+{
+ IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+ IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+ DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+ _data->_page->dragExited(&dragData, [[draggingInfo draggingPasteboard] name]);
+ _data->_page->resetDragOperation();
+}
+
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
+{
+ return YES;
+}
+
+// FIXME: This code is more or less copied from Pasteboard::getBestURL.
+// It would be nice to be able to share the code somehow.
+static bool maybeCreateSandboxExtensionFromPasteboard(NSPasteboard *pasteboard, SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ NSArray *types = [pasteboard types];
+ if (![types containsObject:NSFilenamesPboardType])
+ return false;
+
+ NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
+ if ([files count] != 1)
+ return false;
+
+ NSString *file = [files objectAtIndex:0];
+ BOOL isDirectory;
+ if (![[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory])
+ return false;
+
+ if (isDirectory)
+ return false;
+
+ SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
+ return true;
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo
+{
+ IntPoint client([self convertPoint:[draggingInfo draggingLocation] fromView:nil]);
+ IntPoint global(globalPoint([draggingInfo draggingLocation], [self window]));
+ DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]);
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeCreateSandboxExtensionFromPasteboard([draggingInfo draggingPasteboard], sandboxExtensionHandle);
+ if (createdExtension)
+ _data->_page->process()->willAcquireUniversalFileReadSandboxExtension();
+
+ _data->_page->performDrag(&dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle);
+
+ return YES;
+}
+
+// This code is needed to support drag and drop when the drag types cannot be matched.
+// This is the case for elements that do not place content
+// in the drag pasteboard automatically when the drag start (i.e. dragging a DIV element).
+- (NSView *)_hitTest:(NSPoint *)point dragTypes:(NSSet *)types
+{
+ if ([[self superview] mouse:*point inRect:[self frame]])
+ return self;
+ return nil;
+}
+
+- (BOOL)_windowResizeMouseLocationIsInVisibleScrollerThumb:(NSPoint)loc
+{
+ NSPoint localPoint = [self convertPoint:loc fromView:nil];
+ NSRect visibleThumbRect = NSRect(_data->_page->visibleScrollerThumbRect());
+ return NSMouseInRect(localPoint, visibleThumbRect, [self isFlipped]);
+}
+
+- (void)_updateWindowVisibility
+{
+ _data->_page->updateWindowIsVisible(![[self window] isMiniaturized]);
+}
+
+- (BOOL)_ownsWindowGrowBox
+{
+ NSWindow* window = [self window];
+ if (!window)
+ return NO;
+
+ NSView *superview = [self superview];
+ if (!superview)
+ return NO;
+
+ NSRect growBoxRect = [window _growBoxRect];
+ if (NSIsEmptyRect(growBoxRect))
+ return NO;
+
+ NSRect visibleRect = [self visibleRect];
+ if (NSIsEmptyRect(visibleRect))
+ return NO;
+
+ NSRect visibleRectInWindowCoords = [self convertRect:visibleRect toView:nil];
+ if (!NSIntersectsRect(growBoxRect, visibleRectInWindowCoords))
+ return NO;
+
+ return YES;
+}
+
+- (BOOL)_updateGrowBoxForWindowFrameChange
+{
+ // Temporarily enable the resize indicator to make a the _ownsWindowGrowBox calculation work.
+ BOOL wasShowingIndicator = [[self window] showsResizeIndicator];
+ if (!wasShowingIndicator)
+ [[self window] setShowsResizeIndicator:YES];
+
+ BOOL ownsGrowBox = [self _ownsWindowGrowBox];
+ _data->_page->setWindowResizerSize(ownsGrowBox ? enclosingIntRect([[self window] _growBoxRect]).size() : IntSize());
+
+ if (ownsGrowBox)
+ [[self window] _setShowOpaqueGrowBoxForOwner:(_data->_page->hasHorizontalScrollbar() || _data->_page->hasVerticalScrollbar() ? self : nil)];
+ else
+ [[self window] _setShowOpaqueGrowBoxForOwner:nil];
+
+ // Once WebCore can draw the window resizer, this should read:
+ // if (wasShowingIndicator)
+ // [[self window] setShowsResizeIndicator:!ownsGrowBox];
+ if (!wasShowingIndicator)
+ [[self window] setShowsResizeIndicator:NO];
+
+ return ownsGrowBox;
+}
+
+// FIXME: Use AppKit constants for these when they are available.
+static NSString * const windowDidChangeBackingPropertiesNotification = @"NSWindowDidChangeBackingPropertiesNotification";
+static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOldScaleFactorKey";
+
+- (void)addWindowObserversForWindow:(NSWindow *)window
+{
+ if (window) {
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:)
+ name:NSWindowDidBecomeKeyNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:)
+ name:NSWindowDidResignKeyNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidMiniaturize:)
+ name:NSWindowDidMiniaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidDeminiaturize:)
+ name:NSWindowDidDeminiaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:)
+ name:NSWindowDidMoveNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowFrameDidChange:)
+ name:NSWindowDidResizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:)
+ name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:)
+ name:@"_NSWindowDidBecomeVisible" object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeBackingProperties:)
+ name:windowDidChangeBackingPropertiesNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeScreen:)
+ name:NSWindowDidChangeScreenNotification object:window];
+ }
+}
+
+- (void)removeWindowObservers
+{
+ NSWindow *window = [self window];
+ if (!window)
+ return;
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResignKeyNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMiniaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMoveNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:windowDidChangeBackingPropertiesNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeScreenNotification object:window];
+}
+
+- (void)viewWillMoveToWindow:(NSWindow *)window
+{
+ NSWindow *currentWindow = [self window];
+ if (window == currentWindow)
+ return;
+
+ [self removeWindowObservers];
+ [self addWindowObserversForWindow:window];
+
+ if ([currentWindow _growBoxOwner] == self)
+ [currentWindow _setShowOpaqueGrowBoxForOwner:nil];
+}
+
+- (void)viewDidMoveToWindow
+{
+ // We want to make sure to update the active state while hidden, so if the view is about to become visible, we
+ // update the active state first and then make it visible. If the view is about to be hidden, we hide it first and then
+ // update the active state.
+ if ([self window]) {
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible | WebPageProxy::ViewIsInWindow);
+ [self _updateWindowVisibility];
+ [self _updateWindowAndViewFrames];
+
+ [self _accessibilityRegisterUIProcessTokens];
+ } else {
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow);
+
+#if ENABLE(GESTURE_EVENTS)
+ if (_data->_endGestureMonitor) {
+ [NSEvent removeMonitor:_data->_endGestureMonitor];
+ _data->_endGestureMonitor = nil;
+ }
+#endif
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ WKHideWordDefinitionWindow();
+#endif
+ }
+
+ _data->_page->setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]);
+}
+
+- (void)doWindowDidChangeScreen
+{
+ _data->_page->windowScreenDidChange((PlatformDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]);
+}
+
+- (void)_windowDidBecomeKey:(NSNotification *)notification
+{
+ NSWindow *keyWindow = [notification object];
+ if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet]) {
+ [self _updateSecureInputState];
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ }
+
+ // Send a change screen to make sure the initial displayID is set
+ [self doWindowDidChangeScreen];
+}
+
+- (void)_windowDidChangeScreen:(NSNotification *)notification
+{
+ [self doWindowDidChangeScreen];
+}
+
+- (void)_windowDidResignKey:(NSNotification *)notification
+{
+ NSWindow *formerKeyWindow = [notification object];
+ if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet]) {
+ [self _updateSecureInputState];
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ }
+}
+
+- (void)_windowDidMiniaturize:(NSNotification *)notification
+{
+ [self _updateWindowVisibility];
+}
+
+- (void)_windowDidDeminiaturize:(NSNotification *)notification
+{
+ [self _updateWindowVisibility];
+}
+
+- (void)_windowFrameDidChange:(NSNotification *)notification
+{
+ [self _updateWindowAndViewFrames];
+}
+
+- (void)_windowDidOrderOffScreen:(NSNotification *)notification
+{
+ // We want to make sure to update the active state while hidden, so since the view is about to be hidden,
+ // we hide it first and then update the active state.
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+}
+
+- (void)_windowDidOrderOnScreen:(NSNotification *)notification
+{
+ // We want to make sure to update the active state while hidden, so since the view is about to become visible,
+ // we update the active state first and then make it visible.
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+- (void)_windowDidChangeBackingProperties:(NSNotification *)notification
+{
+ CGFloat oldBackingScaleFactor = [[notification.userInfo objectForKey:backingPropertyOldScaleFactorKey] doubleValue];
+ CGFloat newBackingScaleFactor = [self _intrinsicDeviceScaleFactor];
+ if (oldBackingScaleFactor == newBackingScaleFactor)
+ return;
+
+ _data->_page->setIntrinsicDeviceScaleFactor(newBackingScaleFactor);
+}
+
+static void drawPageBackground(CGContextRef context, WebPageProxy* page, const IntRect& rect)
+{
+ if (!page->drawsBackground())
+ return;
+
+ CGContextSaveGState(context);
+ CGContextSetBlendMode(context, kCGBlendModeCopy);
+
+ CGColorRef backgroundColor;
+ if (page->drawsTransparentBackground())
+ backgroundColor = CGColorGetConstantColor(kCGColorClear);
+ else
+ backgroundColor = CGColorGetConstantColor(kCGColorWhite);
+
+ CGContextSetFillColorWithColor(context, backgroundColor);
+ CGContextFillRect(context, rect);
+
+ CGContextRestoreGState(context);
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ LOG(View, "drawRect: x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+ _data->_page->endPrinting();
+
+ if ([self _shouldUseTiledDrawingArea]) {
+ // Nothing to do here.
+ return;
+ }
+
+ CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+
+ if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
+ const NSRect *rectsBeingDrawn;
+ NSInteger numRectsBeingDrawn;
+ [self getRectsBeingDrawn:&rectsBeingDrawn count:&numRectsBeingDrawn];
+ for (NSInteger i = 0; i < numRectsBeingDrawn; ++i) {
+ Region unpaintedRegion;
+ IntRect rect = enclosingIntRect(rectsBeingDrawn[i]);
+ drawingArea->paint(context, rect, unpaintedRegion);
+
+ Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
+ for (size_t i = 0; i < unpaintedRects.size(); ++i)
+ drawPageBackground(context, _data->_page.get(), unpaintedRects[i]);
+ }
+ } else
+ drawPageBackground(context, _data->_page.get(), enclosingIntRect(rect));
+
+ _data->_page->didDraw();
+}
+
+- (BOOL)isOpaque
+{
+ return _data->_page->drawsBackground();
+}
+
+- (BOOL)mouseDownCanMoveWindow
+{
+ // -[NSView mouseDownCanMoveWindow] returns YES when the NSView is transparent,
+ // but we don't want a drag in the NSView to move the window, even if it's transparent.
+ return NO;
+}
+
+- (void)viewDidHide
+{
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+- (void)viewDidUnhide
+{
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+- (void)_accessibilityRegisterUIProcessTokens
+{
+ // Initialize remote accessibility when the window connection has been established.
+ NSData *remoteElementToken = WKAXRemoteTokenForElement(self);
+ NSData *remoteWindowToken = WKAXRemoteTokenForElement([self accessibilityAttributeValue:NSAccessibilityWindowAttribute]);
+ CoreIPC::DataReference elementToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteElementToken bytes]), [remoteElementToken length]);
+ CoreIPC::DataReference windowToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteWindowToken bytes]), [remoteWindowToken length]);
+ _data->_page->registerUIProcessAccessibilityTokens(elementToken, windowToken);
+}
+
+- (void)_updateRemoteAccessibilityRegistration:(BOOL)registerProcess
+{
+ // When the tree is connected/disconnected, the remote accessibility registration
+ // needs to be updated with the pid of the remote process. If the process is going
+ // away, that information is not present in WebProcess
+ pid_t pid = 0;
+ if (registerProcess && _data->_page->process())
+ pid = _data->_page->process()->processIdentifier();
+ else if (!registerProcess) {
+ pid = WKAXRemoteProcessIdentifier(_data->_remoteAccessibilityChild.get());
+ _data->_remoteAccessibilityChild = nil;
+ }
+ if (pid)
+ WKAXRegisterRemoteProcess(registerProcess, pid);
+}
+
+- (id)accessibilityFocusedUIElement
+{
+ if (_data->_pdfViewController)
+ return NSAccessibilityUnignoredDescendant(_data->_pdfViewController->pdfView());
+
+ return _data->_remoteAccessibilityChild.get();
+}
+
+- (BOOL)accessibilityIsIgnored
+{
+ return NO;
+}
+
+- (id)accessibilityHitTest:(NSPoint)point
+{
+ if (_data->_pdfViewController)
+ return [_data->_pdfViewController->pdfView() accessibilityHitTest:point];
+
+ return _data->_remoteAccessibilityChild.get();
+}
+
+- (id)accessibilityAttributeValue:(NSString*)attribute
+{
+ if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
+
+ id child = nil;
+ if (_data->_pdfViewController)
+ child = NSAccessibilityUnignoredDescendant(_data->_pdfViewController->pdfView());
+ else if (_data->_remoteAccessibilityChild)
+ child = _data->_remoteAccessibilityChild.get();
+
+ if (!child)
+ return nil;
+ return [NSArray arrayWithObject:child];
+ }
+ if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
+ return NSAccessibilityGroupRole;
+ if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute])
+ return NSAccessibilityRoleDescription(NSAccessibilityGroupRole, nil);
+ if ([attribute isEqualToString:NSAccessibilityParentAttribute])
+ return NSAccessibilityUnignoredAncestor([self superview]);
+ if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
+ return [NSNumber numberWithBool:YES];
+
+ return [super accessibilityAttributeValue:attribute];
+}
+
+- (NSView *)hitTest:(NSPoint)point
+{
+ NSView *hitView = [super hitTest:point];
+ if (hitView && _data && hitView == _data->_layerHostingView)
+ hitView = self;
+
+ return hitView;
+}
+
+- (void)_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent
+{
+ NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved location:[[flagsChangedEvent window] convertScreenToBase:[NSEvent mouseLocation]]
+ modifierFlags:[flagsChangedEvent modifierFlags] timestamp:[flagsChangedEvent timestamp] windowNumber:[flagsChangedEvent windowNumber]
+ context:[flagsChangedEvent context] eventNumber:0 clickCount:0 pressure:0];
+ [self mouseMoved:fakeEvent];
+}
+
+- (NSInteger)conversationIdentifier
+{
+ return (NSInteger)self;
+}
+
+- (float)_intrinsicDeviceScaleFactor
+{
+ NSWindow *window = [self window];
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (window)
+ return [window backingScaleFactor];
+ return [[NSScreen mainScreen] backingScaleFactor];
+#else
+ if (window)
+ return [window userSpaceScaleFactor];
+ return [[NSScreen mainScreen] userSpaceScaleFactor];
+#endif
+}
+
+- (void)_setDrawingAreaSize:(NSSize)size
+{
+ if (!_data->_page->drawingArea())
+ return;
+
+ _data->_page->drawingArea()->setSize(IntSize(size), IntSize(_data->_resizeScrollOffset));
+ _data->_resizeScrollOffset = NSZeroSize;
+}
+
+- (BOOL)_shouldUseTiledDrawingArea
+{
+ return NO;
+}
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
+- (void)quickLookPreviewItemsAtWindowLocation:(NSPoint)location
+{
+ NSPoint locationInViewCoordinates = [self convertPoint:location fromView:nil];
+ _data->_page->performDictionaryLookupAtLocation(FloatPoint(locationInViewCoordinates.x, locationInViewCoordinates.y));
+}
+#endif
+
+@end
+
+@implementation WKView (Internal)
+
+- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy
+{
+ if ([self _shouldUseTiledDrawingArea])
+ return TiledCoreAnimationDrawingAreaProxy::create(_data->_page.get());
+
+ return DrawingAreaProxyImpl::create(_data->_page.get());
+}
+
+- (BOOL)_isFocused
+{
+ if (_data->_inBecomeFirstResponder)
+ return YES;
+ if (_data->_inResignFirstResponder)
+ return NO;
+ return [[self window] firstResponder] == self;
+}
+
+- (void)_processDidCrash
+{
+ [self _updateRemoteAccessibilityRegistration:NO];
+}
+
+- (void)_pageClosed
+{
+ [self _updateRemoteAccessibilityRegistration:NO];
+}
+
+- (void)_didRelaunchProcess
+{
+ [self _accessibilityRegisterUIProcessTokens];
+}
+
+- (void)_setCursor:(NSCursor *)cursor
+{
+ if ([NSCursor currentCursor] == cursor)
+ return;
+ [cursor set];
+}
+
+- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState
+{
+ ValidationVector items = _data->_validationMap.take(commandName);
+ size_t size = items.size();
+ for (size_t i = 0; i < size; ++i) {
+ ValidationItem item = items[i].get();
+ [menuItem(item) setState:newState];
+ [menuItem(item) setEnabled:isEnabled];
+ [toolbarItem(item) setEnabled:isEnabled];
+ // FIXME <rdar://problem/8803392>: If the item is neither a menu nor toolbar item, it will be left enabled.
+ }
+}
+
+- (BOOL)_tryPostProcessPluginComplexTextInputKeyDown:(NSEvent *)event
+{
+ if (!_data->_pluginComplexTextInputIdentifier || _data->_pluginComplexTextInputState == PluginComplexTextInputDisabled)
+ return NO;
+
+ // In the legacy text input model, the event has already been sent to the input method.
+ if (_data->_pluginComplexTextInputState == PluginComplexTextInputEnabledLegacy)
+ return NO;
+
+ return [self _handlePluginComplexTextInputKeyDown:event];
+}
+
+- (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled
+{
+ if ([event type] != NSKeyDown)
+ return;
+
+ if ([self _tryPostProcessPluginComplexTextInputKeyDown:event])
+ return;
+
+ if (eventWasHandled) {
+ [NSCursor setHiddenUntilMouseMoves:YES];
+ return;
+ }
+
+ // resending the event may destroy this WKView
+ RetainPtr<WKView> protector(self);
+
+ ASSERT(!_data->_keyDownEventBeingResent);
+ _data->_keyDownEventBeingResent = event;
+ [NSApp _setCurrentEvent:event];
+ [NSApp sendEvent:event];
+
+ _data->_keyDownEventBeingResent = nullptr;
+}
+
+- (BOOL)_interpretKeyEvent:(NSEvent *)event savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands
+{
+ ASSERT(!_data->_interpretKeyEventsParameters);
+ ASSERT(commands.isEmpty());
+
+ if ([event type] == NSFlagsChanged)
+ return NO;
+
+ WKViewInterpretKeyEventsParameters parameters;
+ parameters.eventInterpretationHadSideEffects = false;
+ parameters.executingSavedKeypressCommands = false;
+ // We assume that an input method has consumed the event, and only change this assumption if one of the NSTextInput methods is called.
+ // We assume the IM will *not* consume hotkey sequences.
+ parameters.consumedByIM = !([event modifierFlags] & NSCommandKeyMask);
+ parameters.commands = &commands;
+ _data->_interpretKeyEventsParameters = &parameters;
+
+ [self interpretKeyEvents:[NSArray arrayWithObject:event]];
+
+ _data->_interpretKeyEventsParameters = 0;
+
+ // An input method may consume an event and not tell us (e.g. when displaying a candidate window),
+ // in which case we should not bubble the event up the DOM.
+ if (parameters.consumedByIM)
+ return YES;
+
+ // If we have already executed all or some of the commands, the event is "handled". Note that there are additional checks on web process side.
+ return parameters.eventInterpretationHadSideEffects;
+}
+
+- (NSRect)_convertToDeviceSpace:(NSRect)rect
+{
+ return toDeviceSpace(rect, [self window]);
+}
+
+- (NSRect)_convertToUserSpace:(NSRect)rect
+{
+ return toUserSpace(rect, [self window]);
+}
+
+// Any non-zero value will do, but using something recognizable might help us debug some day.
+#define TRACKING_RECT_TAG 0xBADFACE
+
+- (NSTrackingRectTag)addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside
+{
+ ASSERT(_data->_trackingRectOwner == nil);
+ _data->_trackingRectOwner = owner;
+ _data->_trackingRectUserData = data;
+ return TRACKING_RECT_TAG;
+}
+
+- (NSTrackingRectTag)_addTrackingRect:(NSRect)rect owner:(id)owner userData:(void *)data assumeInside:(BOOL)assumeInside useTrackingNum:(int)tag
+{
+ ASSERT(tag == 0 || tag == TRACKING_RECT_TAG);
+ ASSERT(_data->_trackingRectOwner == nil);
+ _data->_trackingRectOwner = owner;
+ _data->_trackingRectUserData = data;
+ return TRACKING_RECT_TAG;
+}
+
+- (void)_addTrackingRects:(NSRect *)rects owner:(id)owner userDataList:(void **)userDataList assumeInsideList:(BOOL *)assumeInsideList trackingNums:(NSTrackingRectTag *)trackingNums count:(int)count
+{
+ ASSERT(count == 1);
+ ASSERT(trackingNums[0] == 0 || trackingNums[0] == TRACKING_RECT_TAG);
+ ASSERT(_data->_trackingRectOwner == nil);
+ _data->_trackingRectOwner = owner;
+ _data->_trackingRectUserData = userDataList[0];
+ trackingNums[0] = TRACKING_RECT_TAG;
+}
+
+- (void)removeTrackingRect:(NSTrackingRectTag)tag
+{
+ if (!_data)
+ return;
+
+ if (tag == 0)
+ return;
+
+ if (tag == TRACKING_RECT_TAG) {
+ _data->_trackingRectOwner = nil;
+ return;
+ }
+
+ if (tag == _data->_lastToolTipTag) {
+ [super removeTrackingRect:tag];
+ _data->_lastToolTipTag = 0;
+ return;
+ }
+
+ // If any other tracking rect is being removed, we don't know how it was created
+ // and it's possible there's a leak involved (see 3500217)
+ ASSERT_NOT_REACHED();
+}
+
+- (void)_removeTrackingRects:(NSTrackingRectTag *)tags count:(int)count
+{
+ int i;
+ for (i = 0; i < count; ++i) {
+ int tag = tags[i];
+ if (tag == 0)
+ continue;
+ ASSERT(tag == TRACKING_RECT_TAG);
+ if (_data != nil) {
+ _data->_trackingRectOwner = nil;
+ }
+ }
+}
+
+- (void)_sendToolTipMouseExited
+{
+ // Nothing matters except window, trackingNumber, and userData.
+ NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseExited
+ location:NSMakePoint(0, 0)
+ modifierFlags:0
+ timestamp:0
+ windowNumber:[[self window] windowNumber]
+ context:NULL
+ eventNumber:0
+ trackingNumber:TRACKING_RECT_TAG
+ userData:_data->_trackingRectUserData];
+ [_data->_trackingRectOwner mouseExited:fakeEvent];
+}
+
+- (void)_sendToolTipMouseEntered
+{
+ // Nothing matters except window, trackingNumber, and userData.
+ NSEvent *fakeEvent = [NSEvent enterExitEventWithType:NSMouseEntered
+ location:NSMakePoint(0, 0)
+ modifierFlags:0
+ timestamp:0
+ windowNumber:[[self window] windowNumber]
+ context:NULL
+ eventNumber:0
+ trackingNumber:TRACKING_RECT_TAG
+ userData:_data->_trackingRectUserData];
+ [_data->_trackingRectOwner mouseEntered:fakeEvent];
+}
+
+- (NSString *)view:(NSView *)view stringForToolTip:(NSToolTipTag)tag point:(NSPoint)point userData:(void *)data
+{
+ return nsStringFromWebCoreString(_data->_page->toolTip());
+}
+
+- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip
+{
+ if (oldToolTip)
+ [self _sendToolTipMouseExited];
+
+ if (newToolTip && [newToolTip length] > 0) {
+ // See radar 3500217 for why we remove all tooltips rather than just the single one we created.
+ [self removeAllToolTips];
+ NSRect wideOpenRect = NSMakeRect(-100000, -100000, 200000, 200000);
+ _data->_lastToolTipTag = [self addToolTipRect:wideOpenRect owner:self userData:NULL];
+ [self _sendToolTipMouseEntered];
+ }
+}
+
+- (void)_setFindIndicator:(PassRefPtr<FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate
+{
+ if (!findIndicator) {
+ _data->_findIndicatorWindow = nullptr;
+ return;
+ }
+
+ if (!_data->_findIndicatorWindow)
+ _data->_findIndicatorWindow = FindIndicatorWindow::create(self);
+
+ _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut, animate);
+}
+
+- (void)_enterAcceleratedCompositingMode:(const LayerTreeContext&)layerTreeContext
+{
+ ASSERT(!_data->_layerHostingView);
+ ASSERT(!layerTreeContext.isEmpty());
+
+ // Create an NSView that will host our layer tree.
+ _data->_layerHostingView.adoptNS([[WKFlippedView alloc] initWithFrame:[self bounds]]);
+ [_data->_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [self addSubview:_data->_layerHostingView.get()];
+
+ // Create a root layer that will back the NSView.
+ RetainPtr<CALayer> rootLayer(AdoptNS, [[CALayer alloc] init]);
+#ifndef NDEBUG
+ [rootLayer.get() setName:@"Hosting root layer"];
+#endif
+
+ CALayer *renderLayer = WKMakeRenderLayer(layerTreeContext.contextID);
+ [rootLayer.get() addSublayer:renderLayer];
+
+ [_data->_layerHostingView.get() setLayer:rootLayer.get()];
+ [_data->_layerHostingView.get() setWantsLayer:YES];
+
+ [CATransaction commit];
+}
+
+- (void)_exitAcceleratedCompositingMode
+{
+ ASSERT(_data->_layerHostingView);
+
+ [_data->_layerHostingView.get() removeFromSuperview];
+ [_data->_layerHostingView.get() setLayer:nil];
+ [_data->_layerHostingView.get() setWantsLayer:NO];
+
+ _data->_layerHostingView = nullptr;
+}
+
+- (void)_setAccessibilityWebProcessToken:(NSData *)data
+{
+ _data->_remoteAccessibilityChild = WKAXRemoteElementForToken(data);
+ [self _updateRemoteAccessibilityRegistration:YES];
+}
+
+- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
+{
+ BOOL inputSourceChanged = _data->_pluginComplexTextInputIdentifier;
+
+ if (pluginHasFocusAndWindowHasFocus) {
+ // Check if we're already allowing text input for this plug-in.
+ if (pluginComplexTextInputIdentifier == _data->_pluginComplexTextInputIdentifier)
+ return;
+
+ _data->_pluginComplexTextInputIdentifier = pluginComplexTextInputIdentifier;
+
+ } else {
+ // Check if we got a request to unfocus a plug-in that isn't focused.
+ if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier)
+ return;
+
+ _data->_pluginComplexTextInputIdentifier = 0;
+ }
+
+ if (inputSourceChanged) {
+ // The input source changed, go ahead and discard any entered text.
+ [[WKTextInputWindowController sharedTextInputWindowController] unmarkText];
+ }
+
+ // This will force the current input context to be updated to its correct value.
+ [NSApp updateWindows];
+}
+
+- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
+{
+ if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier) {
+ // We're asked to update the state for a plug-in that doesn't have focus.
+ return;
+ }
+
+ [self _setPluginComplexTextInputState:pluginComplexTextInputState];
+}
+
+- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation
+{
+ bool hadPDFView = _data->_pdfViewController;
+ _data->_pdfViewController = nullptr;
+
+ if (pageHasCustomRepresentation)
+ _data->_pdfViewController = PDFViewController::create(self);
+
+ if (pageHasCustomRepresentation != hadPDFView)
+ _data->_page->drawingArea()->pageCustomRepresentationChanged();
+}
+
+- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference
+{
+ ASSERT(_data->_pdfViewController);
+
+ _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), suggestedFilename, dataReference);
+}
+
+- (double)_customRepresentationZoomFactor
+{
+ if (!_data->_pdfViewController)
+ return 1;
+
+ return _data->_pdfViewController->zoomFactor();
+}
+
+- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor
+{
+ if (!_data->_pdfViewController)
+ return;
+
+ _data->_pdfViewController->setZoomFactor(zoomFactor);
+}
+
+- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count
+{
+ if (!_data->_pdfViewController)
+ return;
+
+ _data->_pdfViewController->findString(string, options, count);
+}
+
+- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count
+{
+ if (!_data->_pdfViewController)
+ return;
+
+ _data->_pdfViewController->countStringMatches(string, options, count);
+}
+
+- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag
+{
+ // We need to prevent re-entering this call to avoid crashing in AppKit.
+ // Given the asynchronous nature of WebKit2 this can now happen.
+ if (_data->_dragHasStarted)
+ return;
+
+ _data->_dragHasStarted = YES;
+
+ // The call to super could release this WKView.
+ RetainPtr<WKView> protector(self);
+
+ [super dragImage:image
+ at:clientPoint
+ offset:NSZeroSize
+ event:(linkDrag) ? [NSApp currentEvent] :_data->_mouseDownEvent
+ pasteboard:[NSPasteboard pasteboardWithName:NSDragPboard]
+ source:self
+ slideBack:YES];
+ _data->_dragHasStarted = NO;
+}
+
+- (void)_updateSecureInputState
+{
+ if (![[self window] isKeyWindow] || ![self _isFocused]) {
+ if (_data->_inSecureInputState) {
+ DisableSecureEventInput();
+ _data->_inSecureInputState = NO;
+ }
+ return;
+ }
+ // WKView has a single input context for all editable areas (except for plug-ins).
+ NSTextInputContext *context = [super inputContext];
+ bool isInPasswordField = _data->_page->editorState().isInPasswordField;
+
+ if (isInPasswordField) {
+ if (!_data->_inSecureInputState)
+ EnableSecureEventInput();
+ static NSArray *romanInputSources = [[NSArray alloc] initWithObjects:&NSAllRomanInputSourcesLocaleIdentifier count:1];
+ [context setAllowedInputSourceLocales:romanInputSources];
+ } else {
+ if (_data->_inSecureInputState)
+ DisableSecureEventInput();
+ [context setAllowedInputSourceLocales:nil];
+ }
+ _data->_inSecureInputState = isInPasswordField;
+}
+
+- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState
+{
+ const EditorState& editorState = _data->_page->editorState();
+ if (updateSecureInputState) {
+ // This is a temporary state when editing. Flipping secure input state too quickly can expose race conditions.
+ if (!editorState.selectionIsNone)
+ [self _updateSecureInputState];
+ }
+
+ if (!editorState.hasComposition || editorState.shouldIgnoreCompositionSelectionChange)
+ return;
+
+ _data->_page->cancelComposition();
+
+ [self _notifyInputContextAboutDiscardedComposition];
+}
+
+- (void)_resetTextInputState
+{
+ [self _notifyInputContextAboutDiscardedComposition];
+
+ if (_data->_inSecureInputState) {
+ DisableSecureEventInput();
+ _data->_inSecureInputState = NO;
+ }
+}
+
+- (void)_didChangeScrollbarsForMainFrame
+{
+ [self _updateGrowBoxForWindowFrameChange];
+}
+
+#if ENABLE(FULLSCREEN_API)
+- (WKFullScreenWindowController*)fullScreenWindowController
+{
+ if (!_data->_fullScreenWindowController) {
+ _data->_fullScreenWindowController.adoptNS([[WKFullScreenWindowController alloc] init]);
+ [_data->_fullScreenWindowController.get() setWebView:self];
+ }
+ return _data->_fullScreenWindowController.get();
+}
+
+- (void)closeFullScreenWindowController
+{
+ if (!_data->_fullScreenWindowController)
+ return;
+ [_data->_fullScreenWindowController.get() close];
+ _data->_fullScreenWindowController = nullptr;
+}
+#endif
+
+- (bool)_executeSavedCommandBySelector:(SEL)selector
+{
+ // The sink does two things: 1) Tells us if the responder went unhandled, and
+ // 2) prevents any NSBeep; we don't ever want to beep here.
+ RetainPtr<WKResponderChainSink> sink(AdoptNS, [[WKResponderChainSink alloc] initWithResponderChain:self]);
+ [super doCommandBySelector:selector];
+ [sink.get() detach];
+ return ![sink.get() didReceiveUnhandledCommand];
+}
+
+- (void)_cacheWindowBottomCornerRect
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // FIXME: We should remove this code when <rdar://problem/9362085> is resolved.
+ NSWindow *window = [self window];
+ if (!window)
+ return;
+
+ _data->_windowBottomCornerIntersectionRect = [window _intersectBottomCornersWithRect:[self convertRect:[self visibleRect] toView:nil]];
+ if (!NSIsEmptyRect(_data->_windowBottomCornerIntersectionRect))
+ [self setNeedsDisplayInRect:[self convertRect:_data->_windowBottomCornerIntersectionRect fromView:nil]];
+#endif
+}
+
+- (NSInteger)spellCheckerDocumentTag
+{
+ if (!_data->_hasSpellCheckerDocumentTag) {
+ _data->_spellCheckerDocumentTag = [NSSpellChecker uniqueSpellDocumentTag];
+ _data->_hasSpellCheckerDocumentTag = YES;
+ }
+ return _data->_spellCheckerDocumentTag;
+}
+
+- (void)handleCorrectionPanelResult:(NSString*)result
+{
+ _data->_page->handleCorrectionPanelResult(result);
+}
+
+@end
+
+@implementation WKView (Private)
+
+- (void)_registerDraggedTypes
+{
+ NSMutableSet *types = [[NSMutableSet alloc] initWithArray:PasteboardTypes::forEditing()];
+ [types addObjectsFromArray:PasteboardTypes::forURL()];
+ [self registerForDraggedTypes:[types allObjects]];
+ [types release];
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
+{
+ self = [super initWithFrame:frame];
+ if (!self)
+ return nil;
+
+ [NSApp registerServicesMenuSendTypes:PasteboardTypes::forSelection() returnTypes:PasteboardTypes::forEditing()];
+
+ InitWebCoreSystemInterface();
+ RunLoop::initializeMainRunLoop();
+
+ // Legacy style scrollbars have design details that rely on tracking the mouse all the time.
+ NSTrackingAreaOptions options = NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect;
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (WKRecommendedScrollerStyle() == NSScrollerStyleLegacy)
+ options |= NSTrackingActiveAlways;
+ else
+ options |= NSTrackingActiveInKeyWindow;
+#else
+ options |= NSTrackingActiveInKeyWindow;
+#endif
+
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:frame
+ options:options
+ owner:self
+ userInfo:nil];
+ [self addTrackingArea:trackingArea];
+ [trackingArea release];
+
+ _data = [[WKViewData alloc] init];
+
+ _data->_pageClient = PageClientImpl::create(self);
+ _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef));
+ _data->_page->initializeWebPage();
+#if ENABLE(FULLSCREEN_API)
+ _data->_page->fullScreenManager()->setWebView(self);
+#endif
+ _data->_mouseDownEvent = nil;
+ _data->_ignoringMouseDraggedEvents = NO;
+ _data->_flagsChangedEventMonitor = [NSEvent addLocalMonitorForEventsMatchingMask:NSFlagsChangedMask handler:^(NSEvent *flagsChangedEvent) {
+ [self _postFakeMouseMovedEventForFlagsChangedEvent:flagsChangedEvent];
+ return flagsChangedEvent;
+ }];
+
+ [self _registerDraggedTypes];
+
+ if ([self _shouldUseTiledDrawingArea]) {
+ CALayer *layer = [CALayer layer];
+ layer.backgroundColor = CGColorGetConstantColor(kCGColorWhite);
+ self.layer = layer;
+
+ self.layerContentsRedrawPolicy = NSViewLayerContentsRedrawNever;
+ self.wantsLayer = YES;
+ }
+
+ WebContext::statistics().wkViewCount++;
+
+ return self;
+}
+
+- (WKPageRef)pageRef
+{
+ return toAPI(_data->_page.get());
+}
+
+- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef
+{
+ // PDF documents are already paginated, so we can't change them to add headers and footers.
+ return !toImpl(frameRef)->isDisplayingPDFDocument();
+}
+
+- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef
+{
+ LOG(View, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data());
+
+ // Only the top frame can currently contain a PDF view.
+ if (_data->_pdfViewController) {
+ if (!toImpl(frameRef)->isMainFrame())
+ return 0;
+ return _data->_pdfViewController->makePrintOperation(printInfo);
+ } else {
+ // FIXME: If the frame cannot be printed (e.g. if it contains an encrypted PDF that disallows
+ // printing), this function should return nil.
+ RetainPtr<WKPrintingView> printingView(AdoptNS, [[WKPrintingView alloc] initWithFrameProxy:toImpl(frameRef) view:self]);
+ // NSPrintOperation takes ownership of the view.
+ NSPrintOperation *printOperation = [NSPrintOperation printOperationWithView:printingView.get()];
+ [printOperation setCanSpawnSeparateThread:YES];
+ [printOperation setJobTitle:toImpl(frameRef)->title()];
+ printingView->_printOperation = printOperation;
+ return printOperation;
+ }
+}
+
+- (void)setFrame:(NSRect)rect andScrollBy:(NSSize)offset
+{
+ ASSERT(NSEqualSizes(_data->_resizeScrollOffset, NSZeroSize));
+
+ _data->_resizeScrollOffset = offset;
+ [self setFrame:rect];
+}
+
+- (void)disableFrameSizeUpdates
+{
+ _data->_frameSizeUpdatesDisabledCount++;
+}
+
+- (void)enableFrameSizeUpdates
+{
+ if (!_data->_frameSizeUpdatesDisabledCount)
+ return;
+
+ if (!(--_data->_frameSizeUpdatesDisabledCount))
+ [self _setDrawingAreaSize:[self frame].size];
+}
+
+- (BOOL)frameSizeUpdatesDisabled
+{
+ return _data->_frameSizeUpdatesDisabledCount > 0;
+}
+
+- (void)performDictionaryLookupAtCurrentMouseLocation
+{
+ NSPoint thePoint = [NSEvent mouseLocation];
+ thePoint = [[self window] convertScreenToBase:thePoint];
+ thePoint = [self convertPoint:thePoint fromView:nil];
+
+ _data->_page->performDictionaryLookupAtLocation(FloatPoint(thePoint.x, thePoint.y));
+}
+
++ (void)hideWordDefinitionWindow
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ WKHideWordDefinitionWindow();
+#endif
+}
+
+@end
+
+@implementation WKResponderChainSink
+
+- (id)initWithResponderChain:(NSResponder *)chain
+{
+ self = [super init];
+ if (!self)
+ return nil;
+ _lastResponderInChain = chain;
+ while (NSResponder *next = [_lastResponderInChain nextResponder])
+ _lastResponderInChain = next;
+ [_lastResponderInChain setNextResponder:self];
+ return self;
+}
+
+- (void)detach
+{
+ // This assumes that the responder chain was either unmodified since
+ // -initWithResponderChain: was called, or was modified in such a way
+ // that _lastResponderInChain is still in the chain, and self was not
+ // moved earlier in the chain than _lastResponderInChain.
+ NSResponder *responderBeforeSelf = _lastResponderInChain;
+ NSResponder *next = [responderBeforeSelf nextResponder];
+ for (; next && next != self; next = [next nextResponder])
+ responderBeforeSelf = next;
+
+ // Nothing to be done if we are no longer in the responder chain.
+ if (next != self)
+ return;
+
+ [responderBeforeSelf setNextResponder:[self nextResponder]];
+ _lastResponderInChain = nil;
+}
+
+- (bool)didReceiveUnhandledCommand
+{
+ return _didReceiveUnhandledCommand;
+}
+
+- (void)noResponderFor:(SEL)selector
+{
+ _didReceiveUnhandledCommand = true;
+}
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ _didReceiveUnhandledCommand = true;
+}
+
+- (BOOL)tryToPerform:(SEL)action with:(id)object
+{
+ _didReceiveUnhandledCommand = true;
+ return YES;
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
new file mode 100644
index 000000000..fd3e152e9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#import "PluginComplexTextInputState.h"
+#import "WKView.h"
+#import "WebFindOptions.h"
+#import <wtf/Forward.h>
+#import <wtf/Vector.h>
+
+namespace CoreIPC {
+ class DataReference;
+}
+
+namespace WebCore {
+ struct KeypressCommand;
+}
+
+namespace WebKit {
+ class DrawingAreaProxy;
+ class FindIndicator;
+ class LayerTreeContext;
+ struct EditorState;
+}
+
+@class WKFullScreenWindowController;
+
+@interface WKView (Internal)
+- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy;
+- (BOOL)_isFocused;
+- (void)_processDidCrash;
+- (void)_pageClosed;
+- (void)_didRelaunchProcess;
+- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip;
+- (void)_setCursor:(NSCursor *)cursor;
+- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState;
+- (BOOL)_interpretKeyEvent:(NSEvent *)theEvent savingCommandsTo:(Vector<WebCore::KeypressCommand>&)commands;
+- (void)_doneWithKeyEvent:(NSEvent *)event eventWasHandled:(BOOL)eventWasHandled;
+- (bool)_executeSavedCommandBySelector:(SEL)selector;
+- (NSRect)_convertToDeviceSpace:(NSRect)rect;
+- (NSRect)_convertToUserSpace:(NSRect)rect;
+- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut animate:(BOOL)animate;
+
+- (void)_enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext;
+- (void)_exitAcceleratedCompositingMode;
+
+- (void)_setAccessibilityWebProcessToken:(NSData *)data;
+
+- (void)_pluginFocusOrWindowFocusChanged:(BOOL)pluginHasFocusAndWindowHasFocus pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
+- (void)_setPluginComplexTextInputState:(WebKit::PluginComplexTextInputState)pluginComplexTextInputState pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
+
+- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation;
+- (void)_didFinishLoadingDataForCustomRepresentationWithSuggestedFilename:(const String&)suggestedFilename dataReference:(const CoreIPC::DataReference&)dataReference;
+- (double)_customRepresentationZoomFactor;
+- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor;
+- (void)_findStringInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count;
+- (void)_countStringMatchesInCustomRepresentation:(NSString *)string withFindOptions:(WebKit::FindOptions)options maxMatchCount:(NSUInteger)count;
+- (void)_setDragImage:(NSImage *)image at:(NSPoint)clientPoint linkDrag:(BOOL)linkDrag;
+- (void)_updateSecureInputState;
+- (void)_updateTextInputStateIncludingSecureInputState:(BOOL)updateSecureInputState;
+- (void)_resetTextInputState;
+
+- (void)_didChangeScrollbarsForMainFrame;
+
+#if ENABLE(FULLSCREEN_API)
+- (WKFullScreenWindowController*)fullScreenWindowController;
+- (void)closeFullScreenWindowController;
+#endif
+
+- (void)_cacheWindowBottomCornerRect;
+
+- (NSInteger)spellCheckerDocumentTag;
+- (void)handleCorrectionPanelResult:(NSString*)result;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
new file mode 100644
index 000000000..be3c6303e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#import <WebKit2/WKView.h>
+
+@interface WKView (Private)
+
+/* C SPI support. */
+
+@property(readonly) WKPageRef pageRef;
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
+
+- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef;
+- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef;
+
+- (void)setFrame:(NSRect)rect andScrollBy:(NSSize)offset;
+
+// Stops updating the size of the page as the WKView frame size updates.
+// This should always be followed by enableFrameSizeUpdates. Calls can be nested.
+- (void)disableFrameSizeUpdates;
+// Immediately updates the size of the page to match WKView's frame size
+// and allows subsequent updates as the frame size is set. Calls can be nested.
+- (void)enableFrameSizeUpdates;
+- (BOOL)frameSizeUpdatesDisabled;
+
+- (void)performDictionaryLookupAtCurrentMouseLocation;
++ (void)hideWordDefinitionWindow;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply.cpp b/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply.cpp
new file mode 100644
index 000000000..4e8810302
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply.cpp
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquicknetworkreply_p.h"
+
+#include "QtNetworkReplyData.h"
+#include "QtNetworkRequestData.h"
+#include "qquickwebview_p.h"
+#include <QDateTime>
+
+using namespace WebKit;
+
+QQuickNetworkReply::QQuickNetworkReply(QObject* parent)
+ : QObject(parent)
+ , m_networkReplyData(adoptRef(new WebKit::QtNetworkReplyData))
+{
+ Q_ASSERT(parent);
+}
+
+QString QQuickNetworkReply::contentType() const
+{
+ return m_networkReplyData->m_contentType;
+}
+
+void QQuickNetworkReply::setContentType(const QString& contentType)
+{
+ m_networkReplyData->m_contentType = contentType;
+}
+
+QNetworkAccessManager::Operation QQuickNetworkReply::operation() const
+{
+ return m_networkReplyData->m_operation;
+}
+
+void QQuickNetworkReply::setOperation(QNetworkAccessManager::Operation operation)
+{
+ m_networkReplyData->m_operation = operation;
+}
+
+QString QQuickNetworkReply::contentDisposition() const
+{
+ return m_networkReplyData->m_contentDisposition;
+}
+
+void QQuickNetworkReply::setContentDisposition(const QString& disposition)
+{
+ m_networkReplyData->m_contentDisposition = disposition;
+}
+
+QString QQuickNetworkReply::location() const
+{
+ return m_networkReplyData->m_location;
+}
+
+void QQuickNetworkReply::setLocation(const QString& location)
+{
+ m_networkReplyData->m_location = location;
+}
+
+QString QQuickNetworkReply::lastModified() const
+{
+ return QDateTime::fromMSecsSinceEpoch(m_networkReplyData->m_lastModified).toString(Qt::ISODate);
+}
+
+void QQuickNetworkReply::setLastModified(const QString& lastModified)
+{
+ m_networkReplyData->m_lastModified = QDateTime::fromString(lastModified, Qt::ISODate).toMSecsSinceEpoch();
+}
+
+QString QQuickNetworkReply::cookie() const
+{
+ return m_networkReplyData->m_cookie;
+}
+
+void QQuickNetworkReply::setCookie(const QString& cookie)
+{
+ m_networkReplyData->m_cookie = cookie;
+}
+
+QString QQuickNetworkReply::userAgent() const
+{
+ return m_networkReplyData->m_userAgent;
+}
+
+void QQuickNetworkReply::setUserAgent(const QString& userAgent)
+{
+ m_networkReplyData->m_userAgent = userAgent;
+}
+
+QString QQuickNetworkReply::server() const
+{
+ return m_networkReplyData->m_server;
+}
+
+void QQuickNetworkReply::setServer(const QString& server)
+{
+ m_networkReplyData->m_server = server;
+}
+
+QString QQuickNetworkReply::data() const
+{
+ if (m_networkReplyData->m_dataHandle.isNull())
+ return QString();
+ RefPtr<SharedMemory> sm = SharedMemory::create(m_networkReplyData->m_dataHandle, SharedMemory::ReadOnly);
+ if (!sm)
+ return QString();
+
+ uint64_t stringLength = m_networkReplyData->m_contentLength / sizeof(UChar);
+ return QString(reinterpret_cast<const QChar*>(sm->data()), stringLength);
+}
+
+void QQuickNetworkReply::setData(const QString& data)
+{
+ // This function can be called several times. In this case the previous SharedMemory handles
+ // will be overwritten and the previously allocated SharedMemory will die with the last handle.
+ m_networkReplyData->m_contentLength = 0;
+
+ if (data.isNull())
+ return;
+ const UChar* ucharData = reinterpret_cast<const UChar*>(data.constData());
+ uint64_t smLength = sizeof(UChar) * data.length();
+
+ RefPtr<SharedMemory> sm = SharedMemory::create(smLength);
+ if (!sm)
+ return;
+ // The size of the allocated shared memory can be bigger than requested.
+ // Usually the size will be rounded up to the next multiple of a page size.
+ memcpy(sm->data(), ucharData, smLength);
+
+ if (!sm->createHandle(m_networkReplyData->m_dataHandle, SharedMemory::ReadOnly))
+ return;
+ m_networkReplyData->m_contentLength = smLength;
+}
+
+void QQuickNetworkReply::send()
+{
+ QObject* schemeParent = parent()->parent();
+ if (!schemeParent)
+ return;
+ QQuickWebViewExperimental* webViewExperimental = qobject_cast<QQuickWebViewExperimental*>(schemeParent->parent());
+ if (!webViewExperimental)
+ return;
+ webViewExperimental->sendApplicationSchemeReply(this);
+}
+
+WTF::RefPtr<WebKit::QtNetworkRequestData> QQuickNetworkReply::networkRequestData() const
+{
+ return m_networkRequestData;
+}
+
+void QQuickNetworkReply::setNetworkRequestData(WTF::RefPtr<WebKit::QtNetworkRequestData> data)
+{
+ m_networkRequestData = data;
+ m_networkReplyData->m_replyUuid = data->m_replyUuid;
+}
+
+WTF::RefPtr<WebKit::QtNetworkReplyData> QQuickNetworkReply::networkReplyData() const
+{
+ return m_networkReplyData;
+}
+
+#include "moc_qquicknetworkreply_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply_p.h b/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply_p.h
new file mode 100644
index 000000000..ffe45f3c9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquicknetworkreply_p.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquicknetworkreply_p_h
+#define qquicknetworkreply_p_h
+
+#include "QtNetworkReplyData.h"
+#include "QtNetworkRequestData.h"
+#include "qwebkitglobal.h"
+#include <QNetworkAccessManager>
+#include <QObject>
+#include <QtDeclarative/qdeclarativelist.h>
+#include <QtQuick/qquickitem.h>
+
+class QWEBKIT_EXPORT QQuickNetworkReply : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString contentType READ contentType WRITE setContentType)
+ Q_PROPERTY(QString data READ data WRITE setData)
+ Q_ENUMS(QNetworkAccessManager::Operation)
+
+public:
+ QQuickNetworkReply(QObject* parent);
+ QString contentType() const;
+ void setContentType(const QString&);
+ QNetworkAccessManager::Operation operation() const;
+ void setOperation(QNetworkAccessManager::Operation);
+ QString contentDisposition() const;
+ void setContentDisposition(const QString&);
+ QString location() const;
+ void setLocation(const QString&);
+ QString lastModified() const;
+ void setLastModified(const QString&);
+ QString cookie() const;
+ void setCookie(const QString&);
+ QString userAgent() const;
+ void setUserAgent(const QString&);
+ QString server() const;
+ void setServer(const QString&);
+
+ QString data() const;
+ void setData(const QString& data);
+
+ WTF::RefPtr<WebKit::QtNetworkRequestData> networkRequestData() const;
+ void setNetworkRequestData(WTF::RefPtr<WebKit::QtNetworkRequestData> data);
+ WTF::RefPtr<WebKit::QtNetworkReplyData> networkReplyData() const;
+
+public Q_SLOTS:
+ void send();
+
+private:
+ WTF::RefPtr<WebKit::QtNetworkRequestData> m_networkRequestData;
+ WTF::RefPtr<WebKit::QtNetworkReplyData> m_networkReplyData;
+};
+
+QML_DECLARE_TYPE(QQuickNetworkReply)
+
+#endif // qquicknetworkreply_p_h
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qquicknetworkrequest_p.h b/Source/WebKit2/UIProcess/API/qt/qquicknetworkrequest_p.h
new file mode 100644
index 000000000..113114c87
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquicknetworkrequest_p.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquicknetworkrequest_p_h
+#define qquicknetworkrequest_p_h
+
+#include "qwebkitglobal.h"
+#include <QObject>
+#include <QtDeclarative/qdeclarativelist.h>
+#include <QtQuick/qquickitem.h>
+
+class QWEBKIT_EXPORT QQuickNetworkRequest : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString url READ url)
+
+public:
+ QQuickNetworkRequest(QObject* parent)
+ : QObject(parent)
+ {
+ Q_ASSERT(parent);
+ }
+
+ QString url() const { return m_url; }
+ void setUrl(const QString& url) { m_url = url; }
+
+private:
+ QString m_url;
+};
+
+QML_DECLARE_TYPE(QQuickNetworkRequest)
+
+#endif // qquicknetworkrequest_p_h
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp
new file mode 100644
index 000000000..e5d63043b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate.cpp
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquickurlschemedelegate_p.h"
+
+#include "qquicknetworkreply_p.h"
+#include "qquicknetworkrequest_p.h"
+
+QQuickUrlSchemeDelegate::QQuickUrlSchemeDelegate(QObject* parent)
+ : QObject(parent)
+ , m_request(new QQuickNetworkRequest(this))
+ , m_reply(new QQuickNetworkReply(this))
+{ }
+
+QString QQuickUrlSchemeDelegate::scheme() const
+{
+ return m_scheme;
+}
+
+void QQuickUrlSchemeDelegate::setScheme(const QString& scheme)
+{
+ m_scheme = scheme;
+ emit schemeChanged();
+}
+
+QQuickNetworkRequest* QQuickUrlSchemeDelegate::request() const
+{
+ return m_request;
+}
+
+QQuickNetworkReply* QQuickUrlSchemeDelegate::reply() const
+{
+ return m_reply;
+}
+
+#include "moc_qquickurlschemedelegate_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h
new file mode 100644
index 000000000..6ee602754
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickurlschemedelegate_p.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 Zeno Albisser <zeno@webkit.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickurlschemedelegate_p_h
+#define qquickurlschemedelegate_p_h
+
+#include "qwebkitglobal.h"
+#include <QObject>
+#include <QtQuick/qquickitem.h>
+
+class QQuickNetworkRequest;
+class QQuickNetworkReply;
+
+class QWEBKIT_EXPORT QQuickUrlSchemeDelegate : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString scheme READ scheme WRITE setScheme NOTIFY schemeChanged)
+ Q_PROPERTY(QQuickNetworkRequest* request READ request)
+ Q_PROPERTY(QQuickNetworkReply* reply READ reply)
+
+public:
+ QQuickUrlSchemeDelegate(QObject* parent = 0);
+ QString scheme() const;
+ void setScheme(const QString& scheme);
+ QQuickNetworkRequest* request() const;
+ QQuickNetworkReply* reply() const;
+
+Q_SIGNALS:
+ void schemeChanged();
+ void receivedRequest();
+
+private:
+ QString m_scheme;
+ QQuickNetworkRequest* m_request;
+ QQuickNetworkReply* m_reply;
+};
+
+QML_DECLARE_TYPE(QQuickUrlSchemeDelegate)
+
+#endif // qquickurlschemedelegate_p_h
+
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
new file mode 100644
index 000000000..7d3b2d6a6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquickwebpage_p.h"
+
+#include "LayerTreeHostProxy.h"
+#include "QtWebPageEventHandler.h"
+#include "TransformationMatrix.h"
+#include "qquickwebpage_p_p.h"
+#include <QtQuick/QQuickCanvas>
+#include <QtQuick/QSGGeometryNode>
+#include <QtQuick/QSGMaterial>
+
+QQuickWebPage::QQuickWebPage(QQuickItem* parent)
+ : QQuickItem(parent)
+ , d(new QQuickWebPagePrivate(this))
+{
+ setFlag(ItemHasContents);
+
+ // We do the transform from the top left so the viewport can assume the position 0, 0
+ // is always where rendering starts.
+ setTransformOrigin(TopLeft);
+}
+
+QQuickWebPage::~QQuickWebPage()
+{
+ delete d;
+}
+
+QtSGUpdateQueue *QQuickWebPage::sceneGraphUpdateQueue() const
+{
+ return &d->sgUpdateQueue;
+}
+
+void QQuickWebPage::keyPressEvent(QKeyEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::keyReleaseEvent(QKeyEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::inputMethodEvent(QInputMethodEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::focusInEvent(QFocusEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::focusOutEvent(QFocusEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::mousePressEvent(QMouseEvent* event)
+{
+ forceActiveFocus();
+ this->event(event);
+}
+
+void QQuickWebPage::mouseMoveEvent(QMouseEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::mouseReleaseEvent(QMouseEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::mouseDoubleClickEvent(QMouseEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::wheelEvent(QWheelEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::hoverEnterEvent(QHoverEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::hoverMoveEvent(QHoverEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::hoverLeaveEvent(QHoverEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::dragMoveEvent(QDragMoveEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::dragEnterEvent(QDragEnterEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::dragLeaveEvent(QDragLeaveEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::dropEvent(QDropEvent* event)
+{
+ this->event(event);
+}
+
+void QQuickWebPage::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
+{
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ if (newGeometry.size() != oldGeometry.size())
+ d->setDrawingAreaSize(newGeometry.size().toSize());
+}
+
+bool QQuickWebPage::event(QEvent* ev)
+{
+ if (d->eventHandler.data()->handleEvent(ev))
+ return true;
+ if (ev->type() == QEvent::InputMethod)
+ return false; // This is necessary to avoid an endless loop in connection with QQuickItem::event().
+ return QQuickItem::event(ev);
+}
+
+void QQuickWebPage::touchEvent(QTouchEvent* event)
+{
+ forceActiveFocus();
+ this->event(event);
+}
+
+QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* q)
+ : q(q)
+ , webPageProxy(0)
+ , sgUpdateQueue(q)
+ , paintingIsInitialized(false)
+ , m_paintNode(0)
+{
+}
+
+void QQuickWebPagePrivate::initialize(WebKit::WebPageProxy* webPageProxy)
+{
+ this->webPageProxy = webPageProxy;
+ eventHandler.reset(new QtWebPageEventHandler(toAPI(webPageProxy), q));
+}
+
+static float computeEffectiveOpacity(const QQuickItem* item)
+{
+ if (!item)
+ return 1;
+
+ float opacity = item->opacity();
+ if (opacity < 0.01)
+ return 0;
+
+ return opacity * computeEffectiveOpacity(item->parentItem());
+}
+
+void QQuickWebPagePrivate::setDrawingAreaSize(const QSize& size)
+{
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (!drawingArea)
+ return;
+ drawingArea->setSize(WebCore::IntSize(size), WebCore::IntSize());
+}
+
+void QQuickWebPagePrivate::paintToCurrentGLContext()
+{
+ if (!q->isVisible())
+ return;
+
+ QTransform transform = q->itemTransform(0, 0);
+
+ float opacity = computeEffectiveOpacity(q);
+ QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect());
+
+ if (!clipRect.isValid())
+ return;
+
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (!drawingArea)
+ return;
+
+ // Make sure that no GL error code stays from previous QT operations.
+ glGetError();
+
+ glEnable(GL_SCISSOR_TEST);
+ ASSERT(!glGetError());
+ const int left = clipRect.left();
+ const int width = clipRect.width();
+ const int bottom = q->canvas()->height() - (clipRect.bottom() + 1);
+ const int height = clipRect.height();
+
+ glScissor(left, bottom, width, height);
+ ASSERT(!glGetError());
+
+ drawingArea->paintToCurrentGLContext(transform, opacity);
+
+ glDisable(GL_SCISSOR_TEST);
+ ASSERT(!glGetError());
+}
+
+struct PageProxyMaterial;
+struct PageProxyNode;
+
+// FIXME: temporary until Qt Scenegraph will support custom painting.
+struct PageProxyMaterialShader : public QSGMaterialShader {
+ virtual void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial);
+ virtual char const* const* attributeNames() const
+ {
+ static char const* const attr[] = { "vertex", 0 };
+ return attr;
+ }
+
+ // vertexShader and fragmentShader are no-op shaders.
+ // All real painting is gone by TextureMapper through LayerTreeHostProxy.
+ virtual const char* vertexShader() const
+ {
+ return "attribute highp vec4 vertex; \n"
+ "void main() { gl_Position = vertex; }";
+ }
+
+ virtual const char* fragmentShader() const
+ {
+ return "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }";
+ }
+};
+
+struct PageProxyMaterial : public QSGMaterial {
+ PageProxyMaterial(PageProxyNode* node) : m_node(node) { }
+
+ QSGMaterialType* type() const
+ {
+ static QSGMaterialType type;
+ return &type;
+ }
+
+ QSGMaterialShader* createShader() const
+ {
+ return new PageProxyMaterialShader;
+ }
+
+ PageProxyNode* m_node;
+};
+
+struct PageProxyNode : public QSGGeometryNode {
+ PageProxyNode(QQuickWebPagePrivate* page) :
+ m_pagePrivate(page)
+ , m_material(this)
+ , m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
+ {
+ setGeometry(&m_geometry);
+ setMaterial(&m_material);
+ }
+
+ ~PageProxyNode()
+ {
+ if (m_pagePrivate)
+ m_pagePrivate->resetPaintNode();
+ }
+
+ QQuickWebPagePrivate* m_pagePrivate;
+ PageProxyMaterial m_material;
+ QSGGeometry m_geometry;
+};
+
+void PageProxyMaterialShader::updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial)
+{
+ if (!newMaterial)
+ return;
+
+ PageProxyNode* node = static_cast<PageProxyMaterial*>(newMaterial)->m_node;
+ // FIXME: Normally we wouldn't paint inside QSGMaterialShader::updateState,
+ // but this is a temporary hack until custom paint nodes are available.
+ if (node->m_pagePrivate)
+ node->m_pagePrivate->paintToCurrentGLContext();
+}
+
+QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
+{
+ if (!(flags() & ItemHasContents)) {
+ if (oldNode)
+ delete oldNode;
+ return 0;
+ }
+
+ PageProxyNode* proxyNode = static_cast<PageProxyNode*>(oldNode);
+ if (!proxyNode) {
+ proxyNode = new PageProxyNode(d);
+ d->m_paintNode = proxyNode;
+ }
+
+ return proxyNode;
+}
+
+void QQuickWebPagePrivate::resetPaintNode()
+{
+ m_paintNode = 0;
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (drawingArea && drawingArea->layerTreeHostProxy())
+ drawingArea->layerTreeHostProxy()->purgeGLResources();
+}
+
+QQuickWebPagePrivate::~QQuickWebPagePrivate()
+{
+ if (m_paintNode)
+ static_cast<PageProxyNode*>(m_paintNode)->m_pagePrivate = 0;
+}
+
+#include "moc_qquickwebpage_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h
new file mode 100644
index 000000000..f7c35064e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebpage_p_h
+#define qquickwebpage_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QSharedPointer>
+#include <QtQuick/QQuickItem>
+
+class QQuickWebPagePrivate;
+class QWebPreferences;
+
+namespace WebKit {
+class QtSGUpdateQueue;
+}
+
+class QWEBKIT_EXPORT QQuickWebPage : public QQuickItem {
+ Q_OBJECT
+public:
+ QQuickWebPage(QQuickItem* parent = 0);
+ virtual ~QQuickWebPage();
+
+ // Internal. To be removed soon.
+ WebKit::QtSGUpdateQueue* sceneGraphUpdateQueue() const;
+
+protected:
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void keyReleaseEvent(QKeyEvent*);
+ virtual void inputMethodEvent(QInputMethodEvent*);
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
+ virtual void mousePressEvent(QMouseEvent*);
+ virtual void mouseMoveEvent(QMouseEvent*);
+ virtual void mouseReleaseEvent(QMouseEvent *);
+ virtual void mouseDoubleClickEvent(QMouseEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+ virtual void hoverEnterEvent(QHoverEvent*);
+ virtual void hoverMoveEvent(QHoverEvent*);
+ virtual void hoverLeaveEvent(QHoverEvent*);
+ virtual void dragMoveEvent(QDragMoveEvent*);
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dragLeaveEvent(QDragLeaveEvent*);
+ virtual void dropEvent(QDropEvent*);
+ virtual void touchEvent(QTouchEvent*);
+ virtual bool event(QEvent*);
+ virtual void geometryChanged(const QRectF&, const QRectF&);
+ virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*);
+
+private:
+ QQuickWebPagePrivate* d;
+ friend class QQuickWebView;
+ friend class QQuickWebViewPrivate;
+};
+
+QML_DECLARE_TYPE(QQuickWebPage)
+
+#endif // qquickwebpage_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
new file mode 100644
index 000000000..7224f3975
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebpage_p_p_h
+#define qquickwebpage_p_p_h
+
+#include "QtSGUpdateQueue.h"
+#include "qquickwebpage_p.h"
+
+namespace WebKit {
+class WebPageProxy;
+class QtViewportInteractionEngine;
+}
+
+class QtWebPageEventHandler;
+
+class QQuickWebPagePrivate {
+public:
+ QQuickWebPagePrivate(QQuickWebPage* q);
+ ~QQuickWebPagePrivate();
+
+ void initialize(WebKit::WebPageProxy*);
+ void setDrawingAreaSize(const QSize&);
+
+ void paintToCurrentGLContext();
+ void resetPaintNode();
+
+ QScopedPointer<QtWebPageEventHandler> eventHandler;
+ QQuickWebPage* const q;
+ WebKit::WebPageProxy* webPageProxy;
+ WebKit::QtSGUpdateQueue sgUpdateQueue;
+ bool paintingIsInitialized;
+ QSGNode* m_paintNode;
+};
+
+#endif // qquickwebpage_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
new file mode 100644
index 000000000..7bbef9182
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -0,0 +1,988 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qquickwebview_p.h"
+
+#include "DownloadProxy.h"
+#include "DrawingAreaProxyImpl.h"
+#include "QtDialogRunner.h"
+#include "QtDownloadManager.h"
+#include "QtWebContext.h"
+#include "QtWebIconDatabaseClient.h"
+#include "QtWebPageEventHandler.h"
+#include "UtilsQt.h"
+#include "WebBackForwardList.h"
+#include "WebPageGroup.h"
+#include "WebPreferences.h"
+
+#include "qquicknetworkreply_p.h"
+#include "qquickwebpage_p_p.h"
+#include "qquickwebview_p_p.h"
+#include "qwebdownloaditem_p_p.h"
+#include "qwebnavigationhistory_p.h"
+#include "qwebnavigationhistory_p_p.h"
+#include "qwebpreferences_p.h"
+#include "qwebpreferences_p_p.h"
+#include "qwebviewportinfo_p.h"
+
+#include <JavaScriptCore/InitializeThreading.h>
+#include <QDeclarativeEngine>
+#include <QFileDialog>
+#include <QtQuick/QQuickCanvas>
+#include <WKOpenPanelResultListener.h>
+#include <wtf/text/WTFString.h>
+
+QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport)
+ : q_ptr(viewport)
+ , alertDialog(0)
+ , confirmDialog(0)
+ , promptDialog(0)
+ , itemSelector(0)
+ , postTransitionState(adoptPtr(new PostTransitionState(this)))
+ , isTransitioningToNewPage(false)
+ , pageIsSuspended(false)
+ , m_navigatorQtObjectEnabled(false)
+{
+ viewport->setFlags(QQuickItem::ItemClipsChildrenToShape);
+ QObject::connect(viewport, SIGNAL(visibleChanged()), viewport, SLOT(_q_onVisibleChanged()));
+ pageView.reset(new QQuickWebPage(viewport));
+}
+
+QQuickWebViewPrivate::~QQuickWebViewPrivate()
+{
+ if (interactionEngine)
+ interactionEngine->disconnect();
+ webPageProxy->close();
+}
+
+// Note: we delay this initialization to make sure that QQuickWebView has its d-ptr in-place.
+void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
+{
+ RefPtr<WebPageGroup> pageGroup;
+ if (pageGroupRef)
+ pageGroup = toImpl(pageGroupRef);
+ else
+ pageGroup = WebPageGroup::create();
+
+ context = contextRef ? QtWebContext::create(toImpl(contextRef)) : QtWebContext::defaultContext();
+ webPageProxy = context->createWebPage(&pageClient, pageGroup.get());
+
+ QQuickWebPagePrivate* const pageViewPrivate = pageView.data()->d;
+ pageViewPrivate->initialize(webPageProxy.get());
+
+ pageLoadClient.reset(new QtWebPageLoadClient(toAPI(webPageProxy.get()), q_ptr));
+ pagePolicyClient.reset(new QtWebPagePolicyClient(toAPI(webPageProxy.get()), q_ptr));
+ pageUIClient.reset(new QtWebPageUIClient(toAPI(webPageProxy.get()), q_ptr));
+ navigationHistory = adoptPtr(QWebNavigationHistoryPrivate::createHistory(toAPI(webPageProxy.get())));
+
+ QtWebIconDatabaseClient* iconDatabase = context->iconDatabase();
+ QObject::connect(iconDatabase, SIGNAL(iconChangedForPageURL(QUrl, QUrl)), q_ptr, SLOT(_q_onIconChangedForPageURL(QUrl, QUrl)));
+ QObject::connect(q_ptr, SIGNAL(urlChanged(QUrl)), iconDatabase, SLOT(requestIconForPageURL(QUrl)));
+
+ // Any page setting should preferrable be set before creating the page.
+ setUseTraditionalDesktopBehaviour(false);
+ webPageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
+
+ pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController);
+ webPageProxy->initializeWebPage();
+
+ // Trigger setting of correct visibility flags after everything was allocated and initialized.
+ _q_onVisibleChanged();
+}
+
+void QQuickWebViewPrivate::enableMouseEvents()
+{
+ Q_Q(QQuickWebView);
+ q->setAcceptedMouseButtons(Qt::MouseButtonMask);
+ q->setAcceptHoverEvents(true);
+ pageView->setAcceptedMouseButtons(Qt::MouseButtonMask);
+ pageView->setAcceptHoverEvents(true);
+}
+
+void QQuickWebViewPrivate::disableMouseEvents()
+{
+ Q_Q(QQuickWebView);
+ q->setAcceptedMouseButtons(Qt::NoButton);
+ q->setAcceptHoverEvents(false);
+ pageView->setAcceptedMouseButtons(Qt::NoButton);
+ pageView->setAcceptHoverEvents(false);
+}
+
+void QQuickWebViewPrivate::initializeDesktop(QQuickWebView* viewport)
+{
+ if (interactionEngine) {
+ QObject::disconnect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), viewport, SLOT(_q_suspend()));
+ QObject::disconnect(interactionEngine.data(), SIGNAL(contentResumeRequested()), viewport, SLOT(_q_resume()));
+ QObject::disconnect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
+ }
+ interactionEngine.reset(0);
+ pageView->d->eventHandler->setViewportInteractionEngine(0);
+ enableMouseEvents();
+}
+
+void QQuickWebViewPrivate::initializeTouch(QQuickWebView* viewport)
+{
+ interactionEngine.reset(new QtViewportInteractionEngine(viewport, pageView.data()));
+ pageView->d->eventHandler->setViewportInteractionEngine(interactionEngine.data());
+ disableMouseEvents();
+ QObject::connect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), viewport, SLOT(_q_suspend()));
+ QObject::connect(interactionEngine.data(), SIGNAL(contentResumeRequested()), viewport, SLOT(_q_resume()));
+ QObject::connect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
+ updateViewportSize();
+}
+
+void QQuickWebViewPrivate::loadDidCommit()
+{
+ // Due to entering provisional load before committing, we
+ // might actually be suspended here.
+
+ if (useTraditionalDesktopBehaviour)
+ return;
+
+ isTransitioningToNewPage = true;
+}
+
+void QQuickWebViewPrivate::didFinishFirstNonEmptyLayout()
+{
+ if (useTraditionalDesktopBehaviour)
+ return;
+
+ if (!pageIsSuspended) {
+ isTransitioningToNewPage = false;
+ postTransitionState->apply();
+ }
+}
+
+void QQuickWebViewPrivate::_q_onIconChangedForPageURL(const QUrl& pageURL, const QUrl& iconURL)
+{
+ Q_Q(QQuickWebView);
+ if (q->url() != pageURL)
+ return;
+
+ setIcon(iconURL);
+}
+
+void QQuickWebViewPrivate::_q_suspend()
+{
+ pageIsSuspended = true;
+}
+
+void QQuickWebViewPrivate::_q_resume()
+{
+ pageIsSuspended = false;
+
+ if (isTransitioningToNewPage) {
+ isTransitioningToNewPage = false;
+ postTransitionState->apply();
+ }
+
+ updateVisibleContentRectAndScale();
+}
+
+void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize)
+{
+ Q_Q(QQuickWebView);
+ if (useTraditionalDesktopBehaviour)
+ return;
+
+ // FIXME: We probably want to handle suspend here as well
+ if (isTransitioningToNewPage) {
+ postTransitionState->contentsSize = newSize;
+ return;
+ }
+
+ pageView->setWidth(newSize.width());
+ pageView->setHeight(newSize.height());
+
+ q->m_experimental->viewportInfo()->didUpdateContentsSize();
+}
+
+void QQuickWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+{
+ if (useTraditionalDesktopBehaviour)
+ return;
+
+ viewportArguments = args;
+
+ if (isTransitioningToNewPage)
+ return;
+
+ interactionEngine->applyConstraints(computeViewportConstraints());
+}
+
+void QQuickWebViewPrivate::didChangeBackForwardList()
+{
+ navigationHistory->d->reset();
+}
+
+void QQuickWebViewPrivate::pageDidRequestScroll(const QPoint& pos)
+{
+ if (useTraditionalDesktopBehaviour)
+ return;
+
+ if (isTransitioningToNewPage) {
+ postTransitionState->position = pos;
+ return;
+ }
+
+ interactionEngine->pagePositionRequest(pos);
+}
+
+void QQuickWebViewPrivate::processDidCrash()
+{
+ emit q_ptr->navigationStateChanged();
+ pageView->d->eventHandler->resetGestureRecognizers();
+ WebCore::KURL url(WebCore::ParsedURLString, webPageProxy->urlAtProcessExit());
+ qWarning("WARNING: The web process experienced a crash on '%s'.", qPrintable(QUrl(url).toString(QUrl::RemoveUserInfo)));
+}
+
+void QQuickWebViewPrivate::didRelaunchProcess()
+{
+ emit q_ptr->navigationStateChanged();
+ qWarning("WARNING: The web process has been successfully restarted.");
+ pageView->d->setDrawingAreaSize(viewSize());
+}
+
+PassOwnPtr<DrawingAreaProxy> QQuickWebViewPrivate::createDrawingAreaProxy()
+{
+ return DrawingAreaProxyImpl::create(webPageProxy.get());
+}
+
+void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
+{
+ Q_Q(QQuickWebView);
+ // This function is responsible for hooking up a DownloadProxy to our API layer
+ // by creating a QWebDownloadItem. It will then wait for the QWebDownloadItem to be
+ // ready (filled with the ResourceResponse information) so we can pass it through to
+ // our WebViews.
+ QWebDownloadItem* downloadItem = new QWebDownloadItem();
+ downloadItem->d->downloadProxy = download;
+
+ q->connect(downloadItem->d, SIGNAL(receivedResponse(QWebDownloadItem*)), q, SLOT(_q_onReceivedResponseFromDownload(QWebDownloadItem*)));
+ context->downloadManager()->addDownload(download, downloadItem);
+}
+
+void QQuickWebViewPrivate::updateVisibleContentRectAndScale()
+{
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (!drawingArea)
+ return;
+
+ Q_Q(QQuickWebView);
+ const QRectF visibleRectInPageViewCoordinates = q->mapRectToItem(pageView.data(), q->boundingRect()).intersected(pageView->boundingRect());
+ float scale = pageView->scale();
+
+ QRect alignedVisibleContentRect = visibleRectInPageViewCoordinates.toAlignedRect();
+ drawingArea->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale);
+
+ // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
+ webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
+ q->m_experimental->viewportInfo()->didUpdateCurrentScale();
+}
+
+void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
+{
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (!drawingArea)
+ return;
+ drawingArea->setVisibleContentRectTrajectoryVector(trajectoryVector);
+}
+
+void QQuickWebViewPrivate::_q_onVisibleChanged()
+{
+ webPageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+void QQuickWebViewPrivate::_q_onReceivedResponseFromDownload(QWebDownloadItem* downloadItem)
+{
+ // Now that our downloadItem has everything we need we can emit downloadRequested.
+ if (!downloadItem)
+ return;
+
+ Q_Q(QQuickWebView);
+ QDeclarativeEngine::setObjectOwnership(downloadItem, QDeclarativeEngine::JavaScriptOwnership);
+ emit q->experimental()->downloadRequested(downloadItem);
+}
+
+void QQuickWebViewPrivate::updateViewportSize()
+{
+ Q_Q(QQuickWebView);
+ QSize viewportSize = q->boundingRect().size().toSize();
+
+ if (viewportSize.isEmpty())
+ return;
+
+ // Let the WebProcess know about the new viewport size, so that
+ // it can resize the content accordingly.
+ webPageProxy->setViewportSize(viewportSize);
+
+ interactionEngine->applyConstraints(computeViewportConstraints());
+ updateVisibleContentRectAndScale();
+}
+
+void QQuickWebViewPrivate::PostTransitionState::apply()
+{
+ p->interactionEngine->reset();
+ p->interactionEngine->applyConstraints(p->computeViewportConstraints());
+ p->interactionEngine->pagePositionRequest(position);
+
+ if (contentsSize.isValid()) {
+ p->pageView->setWidth(contentsSize.width());
+ p->pageView->setHeight(contentsSize.height());
+ p->q_ptr->experimental()->viewportInfo()->didUpdateContentsSize();
+ }
+
+ position = QPoint();
+ contentsSize = QSize();
+}
+
+QtViewportInteractionEngine::Constraints QQuickWebViewPrivate::computeViewportConstraints()
+{
+ Q_Q(QQuickWebView);
+
+ QtViewportInteractionEngine::Constraints newConstraints;
+ QSize availableSize = q->boundingRect().size().toSize();
+
+ // Return default values for zero sized viewport.
+ if (availableSize.isEmpty())
+ return newConstraints;
+
+ WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences();
+
+ // FIXME: Remove later; Hardcode some values for now to make sure the DPI adjustment is being tested.
+ wkPrefs->setDeviceDPI(240);
+ wkPrefs->setDeviceWidth(480);
+ wkPrefs->setDeviceHeight(720);
+
+ int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width());
+
+ WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize);
+ WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize);
+ WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr);
+
+ newConstraints.initialScale = attr.initialScale;
+ newConstraints.minimumScale = attr.minimumScale;
+ newConstraints.maximumScale = attr.maximumScale;
+ newConstraints.devicePixelRatio = attr.devicePixelRatio;
+ newConstraints.isUserScalable = !!attr.userScalable;
+ newConstraints.layoutSize = attr.layoutSize;
+
+ q->m_experimental->viewportInfo()->didUpdateViewportConstraints();
+
+ return newConstraints;
+}
+
+void QQuickWebViewPrivate::runJavaScriptAlert(const QString& alertText)
+{
+ if (!alertDialog)
+ return;
+
+ Q_Q(QQuickWebView);
+ QtDialogRunner dialogRunner;
+ if (!dialogRunner.initForAlert(alertDialog, q, alertText))
+ return;
+ setViewInAttachedProperties(dialogRunner.dialog());
+
+ disableMouseEvents();
+ dialogRunner.exec();
+ enableMouseEvents();
+}
+
+bool QQuickWebViewPrivate::runJavaScriptConfirm(const QString& message)
+{
+ if (!confirmDialog)
+ return true;
+
+ Q_Q(QQuickWebView);
+ QtDialogRunner dialogRunner;
+ if (!dialogRunner.initForConfirm(confirmDialog, q, message))
+ return true;
+ setViewInAttachedProperties(dialogRunner.dialog());
+
+ disableMouseEvents();
+ dialogRunner.exec();
+ enableMouseEvents();
+
+ return dialogRunner.wasAccepted();
+}
+
+QString QQuickWebViewPrivate::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+ if (!promptDialog) {
+ ok = true;
+ return defaultValue;
+ }
+
+ Q_Q(QQuickWebView);
+ QtDialogRunner dialogRunner;
+ if (!dialogRunner.initForPrompt(promptDialog, q, message, defaultValue)) {
+ ok = true;
+ return defaultValue;
+ }
+ setViewInAttachedProperties(dialogRunner.dialog());
+
+ disableMouseEvents();
+ dialogRunner.exec();
+ enableMouseEvents();
+
+ ok = dialogRunner.wasAccepted();
+ return dialogRunner.result();
+}
+
+void QQuickWebViewPrivate::chooseFiles(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType type)
+{
+#ifndef QT_NO_FILEDIALOG
+ Q_Q(QQuickWebView);
+ openPanelResultListener = listenerRef;
+
+ // Qt does not support multiple files suggestion, so we get just the first suggestion.
+ QString selectedFileName;
+ if (!selectedFileNames.isEmpty())
+ selectedFileName = selectedFileNames.at(0);
+
+ Q_ASSERT(!fileDialog);
+
+ QWindow* window = q->canvas();
+ if (!window)
+ return;
+
+ fileDialog = new QFileDialog(0, QString(), selectedFileName);
+ fileDialog->window()->winId(); // Ensure that the dialog has a window
+ Q_ASSERT(fileDialog->window()->windowHandle());
+ fileDialog->window()->windowHandle()->setTransientParent(window);
+
+ fileDialog->open(q, SLOT(_q_onOpenPanelFilesSelected()));
+
+ q->connect(fileDialog, SIGNAL(finished(int)), SLOT(_q_onOpenPanelFinished(int)));
+#endif
+}
+
+void QQuickWebViewPrivate::_q_onOpenPanelFilesSelected()
+{
+ const QStringList fileList = fileDialog->selectedFiles();
+ Vector<RefPtr<APIObject> > wkFiles(fileList.size());
+
+ for (unsigned i = 0; i < fileList.size(); ++i)
+ wkFiles[i] = WebURL::create(QUrl::fromLocalFile(fileList.at(i)).toString());
+
+ WKOpenPanelResultListenerChooseFiles(openPanelResultListener, toAPI(ImmutableArray::adopt(wkFiles).leakRef()));
+}
+
+void QQuickWebViewPrivate::_q_onOpenPanelFinished(int result)
+{
+ if (result == QDialog::Rejected)
+ WKOpenPanelResultListenerCancel(openPanelResultListener);
+
+ fileDialog->deleteLater();
+ fileDialog = 0;
+}
+
+void QQuickWebViewPrivate::setUseTraditionalDesktopBehaviour(bool enable)
+{
+ Q_Q(QQuickWebView);
+
+ // Do not guard, testing for the same value, as we call this from the constructor.
+
+ webPageProxy->setUseFixedLayout(!enable);
+
+ useTraditionalDesktopBehaviour = enable;
+ if (useTraditionalDesktopBehaviour)
+ initializeDesktop(q);
+ else
+ initializeTouch(q);
+}
+
+void QQuickWebViewPrivate::setViewInAttachedProperties(QObject* object)
+{
+ Q_Q(QQuickWebView);
+ QQuickWebViewAttached* attached = static_cast<QQuickWebViewAttached*>(qmlAttachedPropertiesObject<QQuickWebView>(object));
+ attached->setView(q);
+}
+
+void QQuickWebViewPrivate::setIcon(const QUrl& iconURL)
+{
+ Q_Q(QQuickWebView);
+ if (m_iconURL == iconURL)
+ return;
+
+ String oldPageURL = QUrl::fromPercentEncoding(m_iconURL.encodedFragment());
+ String newPageURL = webPageProxy->mainFrame()->url();
+
+ if (oldPageURL != newPageURL) {
+ QtWebIconDatabaseClient* iconDatabase = context->iconDatabase();
+ if (!oldPageURL.isEmpty())
+ iconDatabase->releaseIconForPageURL(oldPageURL);
+
+ if (!newPageURL.isEmpty())
+ iconDatabase->retainIconForPageURL(newPageURL);
+ }
+
+ m_iconURL = iconURL;
+ emit q->iconChanged(m_iconURL);
+}
+
+bool QQuickWebViewPrivate::navigatorQtObjectEnabled() const
+{
+ return m_navigatorQtObjectEnabled;
+}
+
+void QQuickWebViewPrivate::setNavigatorQtObjectEnabled(bool enabled)
+{
+ ASSERT(enabled != m_navigatorQtObjectEnabled);
+ // FIXME: Currently we have to keep this information in both processes and the setting is asynchronous.
+ m_navigatorQtObjectEnabled = enabled;
+ context->setNavigatorQtObjectEnabled(webPageProxy.get(), enabled);
+}
+
+WebCore::IntSize QQuickWebViewPrivate::viewSize() const
+{
+ return WebCore::IntSize(pageView->width(), pageView->height());
+}
+
+void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& message)
+{
+ QVariantMap variantMap;
+ variantMap.insert(QLatin1String("data"), QString(message));
+ variantMap.insert(QLatin1String("origin"), q_ptr->url());
+ emit q_ptr->experimental()->messageReceived(variantMap);
+}
+
+/*!
+ \qmlsignal WebView::onNavigationRequested(request)
+
+ This signal is emitted for every navigation request. The request object contains url, button and modifiers properties
+ describing the navigation action, e.g. "a middle click with shift key pressed to 'http://qt-project.org'".
+
+ The navigation will be accepted by default. To change that, one can set the action property to WebView.IgnoreRequest to reject
+ the request or WebView.DownloadRequest to trigger a download instead of navigating to the url.
+
+ The request object cannot be used after the signal handler function ends.
+*/
+
+QQuickWebViewAttached::QQuickWebViewAttached(QObject* object)
+ : QObject(object)
+ , m_view(0)
+{
+
+}
+
+void QQuickWebViewAttached::setView(QQuickWebView* view)
+{
+ if (m_view == view)
+ return;
+ m_view = view;
+ emit viewChanged();
+}
+
+QQuickWebViewExperimental::QQuickWebViewExperimental(QQuickWebView *webView)
+ : QObject(webView)
+ , q_ptr(webView)
+ , d_ptr(webView->d_ptr.data())
+ , schemeParent(new QObject(this))
+ , m_viewportInfo(new QWebViewportInfo(webView->d_ptr.data(), this))
+{
+}
+
+QQuickWebViewExperimental::~QQuickWebViewExperimental()
+{
+}
+
+void QQuickWebViewExperimental::setUseTraditionalDesktopBehaviour(bool enable)
+{
+ Q_D(QQuickWebView);
+
+ if (enable == d->useTraditionalDesktopBehaviour)
+ return;
+
+ d->setUseTraditionalDesktopBehaviour(enable);
+}
+
+void QQuickWebViewExperimental::postMessage(const QString& message)
+{
+ Q_D(QQuickWebView);
+ d->context->postMessageToNavigatorQtObject(d->webPageProxy.get(), message);
+}
+
+QDeclarativeComponent* QQuickWebViewExperimental::alertDialog() const
+{
+ Q_D(const QQuickWebView);
+ return d->alertDialog;
+}
+
+void QQuickWebViewExperimental::setAlertDialog(QDeclarativeComponent* alertDialog)
+{
+ Q_D(QQuickWebView);
+ if (d->alertDialog == alertDialog)
+ return;
+ d->alertDialog = alertDialog;
+ emit alertDialogChanged();
+}
+
+QDeclarativeComponent* QQuickWebViewExperimental::confirmDialog() const
+{
+ Q_D(const QQuickWebView);
+ return d->confirmDialog;
+}
+
+void QQuickWebViewExperimental::setConfirmDialog(QDeclarativeComponent* confirmDialog)
+{
+ Q_D(QQuickWebView);
+ if (d->confirmDialog == confirmDialog)
+ return;
+ d->confirmDialog = confirmDialog;
+ emit confirmDialogChanged();
+}
+
+QWebNavigationHistory* QQuickWebViewExperimental::navigationHistory() const
+{
+ return d_ptr->navigationHistory.get();
+}
+
+QDeclarativeComponent* QQuickWebViewExperimental::promptDialog() const
+{
+ Q_D(const QQuickWebView);
+ return d->promptDialog;
+}
+
+QWebPreferences* QQuickWebViewExperimental::preferences() const
+{
+ QQuickWebViewPrivate* const d = d_ptr;
+ if (!d->preferences)
+ d->preferences = adoptPtr(QWebPreferencesPrivate::createPreferences(d));
+ return d->preferences.get();
+}
+
+void QQuickWebViewExperimental::setPromptDialog(QDeclarativeComponent* promptDialog)
+{
+ Q_D(QQuickWebView);
+ if (d->promptDialog == promptDialog)
+ return;
+ d->promptDialog = promptDialog;
+ emit promptDialogChanged();
+}
+
+QDeclarativeComponent* QQuickWebViewExperimental::itemSelector() const
+{
+ Q_D(const QQuickWebView);
+ return d->itemSelector;
+}
+
+void QQuickWebViewExperimental::setItemSelector(QDeclarativeComponent* itemSelector)
+{
+ Q_D(QQuickWebView);
+ if (d->itemSelector == itemSelector)
+ return;
+ d->itemSelector = itemSelector;
+ emit itemSelectorChanged();
+}
+
+bool QQuickWebViewExperimental::useTraditionalDesktopBehaviour() const
+{
+ Q_D(const QQuickWebView);
+ return d->useTraditionalDesktopBehaviour;
+}
+
+QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property, int index)
+{
+ const QObjectList children = property->object->children();
+ if (index < children.count())
+ return static_cast<QQuickUrlSchemeDelegate*>(children.at(index));
+ return 0;
+}
+
+void QQuickWebViewExperimental::schemeDelegates_Append(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property, QQuickUrlSchemeDelegate *scheme)
+{
+ QObject* schemeParent = property->object;
+ scheme->setParent(schemeParent);
+ QQuickWebViewExperimental* webViewExperimental = qobject_cast<QQuickWebViewExperimental*>(property->object->parent());
+ if (!webViewExperimental)
+ return;
+ QQuickWebViewPrivate* d = webViewExperimental->d_func();
+ d->webPageProxy->registerApplicationScheme(scheme->scheme());
+}
+
+int QQuickWebViewExperimental::schemeDelegates_Count(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property)
+{
+ return property->object->children().count();
+}
+
+void QQuickWebViewExperimental::schemeDelegates_Clear(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property)
+{
+ const QObjectList children = property->object->children();
+ for (int index = 0; index < children.count(); index++) {
+ QObject* child = children.at(index);
+ child->setParent(0);
+ delete child;
+ }
+}
+
+QDeclarativeListProperty<QQuickUrlSchemeDelegate> QQuickWebViewExperimental::schemeDelegates()
+{
+ return QDeclarativeListProperty<QQuickUrlSchemeDelegate>(schemeParent, 0,
+ QQuickWebViewExperimental::schemeDelegates_Append,
+ QQuickWebViewExperimental::schemeDelegates_Count,
+ QQuickWebViewExperimental::schemeDelegates_At,
+ QQuickWebViewExperimental::schemeDelegates_Clear);
+}
+
+void QQuickWebViewExperimental::invokeApplicationSchemeHandler(PassRefPtr<QtNetworkRequestData> request)
+{
+ const QObjectList children = schemeParent->children();
+ for (int index = 0; index < children.count(); index++) {
+ QQuickUrlSchemeDelegate* delegate = qobject_cast<QQuickUrlSchemeDelegate*>(children.at(index));
+ if (!delegate)
+ continue;
+ if (!delegate->scheme().compare(QString(request->m_scheme), Qt::CaseInsensitive)) {
+ delegate->reply()->setNetworkRequestData(request);
+ emit delegate->receivedRequest();
+ return;
+ }
+ }
+}
+
+void QQuickWebViewExperimental::sendApplicationSchemeReply(QQuickNetworkReply* reply)
+{
+ d_ptr->webPageProxy->sendApplicationSchemeReply(reply);
+}
+
+void QQuickWebViewExperimental::goForwardTo(int index)
+{
+ d_ptr->navigationHistory->d->goForwardTo(index);
+}
+
+void QQuickWebViewExperimental::goBackTo(int index)
+{
+ d_ptr->navigationHistory->d->goBackTo(index);
+}
+
+QWebViewportInfo* QQuickWebViewExperimental::viewportInfo()
+{
+ return m_viewportInfo;
+}
+
+QQuickWebPage* QQuickWebViewExperimental::page()
+{
+ return q_ptr->page();
+}
+
+QQuickWebView::QQuickWebView(QQuickItem* parent)
+ : QQuickItem(parent)
+ , d_ptr(new QQuickWebViewPrivate(this))
+ , m_experimental(new QQuickWebViewExperimental(this))
+{
+ Q_D(QQuickWebView);
+ d->initialize();
+ d->initializeTouch(this);
+}
+
+QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent)
+ : QQuickItem(parent)
+ , d_ptr(new QQuickWebViewPrivate(this))
+ , m_experimental(new QQuickWebViewExperimental(this))
+{
+ Q_D(QQuickWebView);
+ d->initialize(contextRef, pageGroupRef);
+}
+
+QQuickWebView::~QQuickWebView()
+{
+}
+
+QQuickWebPage* QQuickWebView::page()
+{
+ Q_D(QQuickWebView);
+ return d->pageView.data();
+}
+
+void QQuickWebView::load(const QUrl& url)
+{
+ Q_D(QQuickWebView);
+ d->webPageProxy->loadURL(url.toString());
+}
+
+void QQuickWebView::goBack()
+{
+ Q_D(QQuickWebView);
+ d->webPageProxy->goBack();
+}
+
+void QQuickWebView::goForward()
+{
+ Q_D(QQuickWebView);
+ d->webPageProxy->goForward();
+}
+
+void QQuickWebView::stop()
+{
+ Q_D(QQuickWebView);
+ d->webPageProxy->stopLoading();
+}
+
+void QQuickWebView::reload()
+{
+ Q_D(QQuickWebView);
+ const bool reloadFromOrigin = true;
+ d->webPageProxy->reload(reloadFromOrigin);
+}
+
+QUrl QQuickWebView::url() const
+{
+ Q_D(const QQuickWebView);
+ RefPtr<WebFrameProxy> mainFrame = d->webPageProxy->mainFrame();
+ if (!mainFrame)
+ return QUrl();
+ return QUrl(QString(mainFrame->url()));
+}
+
+QUrl QQuickWebView::icon() const
+{
+ Q_D(const QQuickWebView);
+ return d->m_iconURL;
+}
+
+int QQuickWebView::loadProgress() const
+{
+ Q_D(const QQuickWebView);
+ return d->pageLoadClient->loadProgress();
+}
+
+bool QQuickWebView::canGoBack() const
+{
+ Q_D(const QQuickWebView);
+ return d->webPageProxy->canGoBack();
+}
+
+bool QQuickWebView::canGoForward() const
+{
+ Q_D(const QQuickWebView);
+ return d->webPageProxy->canGoForward();
+}
+
+bool QQuickWebView::loading() const
+{
+ Q_D(const QQuickWebView);
+ RefPtr<WebKit::WebFrameProxy> mainFrame = d->webPageProxy->mainFrame();
+ return mainFrame && !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
+}
+
+bool QQuickWebView::canReload() const
+{
+ Q_D(const QQuickWebView);
+ RefPtr<WebKit::WebFrameProxy> mainFrame = d->webPageProxy->mainFrame();
+ if (mainFrame)
+ return (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
+ return d->webPageProxy->backForwardList()->currentItem();
+}
+
+QString QQuickWebView::title() const
+{
+ Q_D(const QQuickWebView);
+ return d->webPageProxy->pageTitle();
+}
+
+QVariant QQuickWebView::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ Q_D(const QQuickWebView);
+ const EditorState& state = d->webPageProxy->editorState();
+
+ switch(property) {
+ case Qt::ImCursorRectangle:
+ return QRectF(state.microFocus);
+ case Qt::ImFont:
+ return QVariant();
+ case Qt::ImCursorPosition:
+ return QVariant(static_cast<int>(state.cursorPosition));
+ case Qt::ImAnchorPosition:
+ return QVariant(static_cast<int>(state.anchorPosition));
+ case Qt::ImSurroundingText:
+ return QString(state.surroundingText);
+ case Qt::ImCurrentSelection:
+ return QString(state.selectedText);
+ case Qt::ImMaximumTextLength:
+ return QVariant(); // No limit.
+ default:
+ // Rely on the base implementation for ImEnabled, ImHints and ImPreferredLanguage.
+ return QQuickItem::inputMethodQuery(property);
+ }
+}
+
+QQuickWebViewExperimental* QQuickWebView::experimental() const
+{
+ return m_experimental;
+}
+
+QQuickWebViewAttached* QQuickWebView::qmlAttachedProperties(QObject* object)
+{
+ return new QQuickWebViewAttached(object);
+}
+
+void QQuickWebView::platformInitialize()
+{
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+}
+
+void QQuickWebView::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
+{
+ Q_D(QQuickWebView);
+ QQuickItem::geometryChanged(newGeometry, oldGeometry);
+ if (newGeometry.size() != oldGeometry.size()) {
+ if (d->useTraditionalDesktopBehaviour) {
+ d->pageView->setWidth(newGeometry.width());
+ d->pageView->setHeight(newGeometry.height());
+ } else
+ d->updateViewportSize();
+ }
+}
+
+void QQuickWebView::focusInEvent(QFocusEvent* event)
+{
+ Q_D(QQuickWebView);
+ d->pageView->event(event);
+}
+
+void QQuickWebView::focusOutEvent(QFocusEvent* event)
+{
+ Q_D(QQuickWebView);
+ d->pageView->event(event);
+}
+
+WKPageRef QQuickWebView::pageRef() const
+{
+ Q_D(const QQuickWebView);
+ return toAPI(d->webPageProxy.get());
+}
+
+/*!
+ Loads the specified \a html as the content of the web view.
+
+ External objects such as stylesheets or images referenced in the HTML
+ document are located relative to \a baseUrl.
+
+ \sa load()
+*/
+void QQuickWebView::loadHtml(const QString& html, const QUrl& baseUrl)
+{
+ Q_D(QQuickWebView);
+ d->webPageProxy->loadHTMLString(html, baseUrl.toString());
+}
+
+#include "moc_qquickwebview_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
new file mode 100644
index 000000000..e5d3f1e5a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebview_p_h
+#define qquickwebview_p_h
+
+#include "qquickurlschemedelegate_p.h"
+#include "qwebkitglobal.h"
+#include <QtDeclarative/qdeclarativelist.h>
+#include <QtQuick/qquickitem.h>
+
+class QWebNavigationRequest;
+class QDeclarativeComponent;
+class QQuickWebPage;
+class QQuickWebViewAttached;
+class QQuickWebViewPrivate;
+class QQuickWebViewExperimental;
+class QWebDownloadItem;
+class QWebNavigationHistory;
+class QWebPreferences;
+class QWebPermissionRequest;
+class QWebViewportInfo;
+class QQuickNetworkReply;
+
+namespace WTR {
+class PlatformWebView;
+}
+
+namespace WebKit {
+class QtNetworkRequestData;
+}
+
+namespace WTF {
+template<class T> class PassRefPtr;
+}
+
+typedef const struct OpaqueWKContext* WKContextRef;
+typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
+typedef const struct OpaqueWKPage* WKPageRef;
+
+QT_BEGIN_NAMESPACE
+class QPainter;
+class QUrl;
+QT_END_NAMESPACE
+
+class QWEBKIT_EXPORT QQuickWebView : public QQuickItem {
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title NOTIFY titleChanged)
+ Q_PROPERTY(QUrl url READ url NOTIFY urlChanged)
+ Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged FINAL)
+ Q_PROPERTY(int loadProgress READ loadProgress NOTIFY loadProgressChanged)
+ Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY navigationStateChanged FINAL)
+ Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY navigationStateChanged FINAL)
+ Q_PROPERTY(bool loading READ loading NOTIFY navigationStateChanged FINAL)
+ Q_PROPERTY(bool canReload READ canReload NOTIFY navigationStateChanged FINAL)
+ Q_ENUMS(NavigationRequestAction)
+ Q_ENUMS(ErrorDomain)
+
+public:
+ enum NavigationRequestAction {
+ AcceptRequest,
+ IgnoreRequest
+ };
+
+ enum ErrorDomain {
+ InternalErrorDomain,
+ NetworkErrorDomain,
+ HttpErrorDomain,
+ DownloadErrorDomain
+ };
+ QQuickWebView(QQuickItem* parent = 0);
+ virtual ~QQuickWebView();
+
+ QUrl url() const;
+ QUrl icon() const;
+ QString title() const;
+ int loadProgress() const;
+
+ bool canGoBack() const;
+ bool canGoForward() const;
+ bool loading() const;
+ bool canReload() const;
+
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+ QQuickWebPage* page();
+
+ QQuickWebViewExperimental* experimental() const;
+ static QQuickWebViewAttached* qmlAttachedProperties(QObject*);
+
+ static void platformInitialize(); // Only needed by WTR.
+
+public Q_SLOTS:
+ void load(const QUrl&);
+ void loadHtml(const QString& html, const QUrl& baseUrl = QUrl());
+
+ void goBack();
+ void goForward();
+ void stop();
+ void reload();
+
+Q_SIGNALS:
+ void titleChanged(const QString& title);
+ void loadStarted();
+ void loadSucceeded();
+ void loadFailed(QQuickWebView::ErrorDomain errorDomain, int errorCode, const QUrl& url, const QString& description);
+ void loadProgressChanged(int progress);
+ void urlChanged(const QUrl& url);
+ void iconChanged(const QUrl& iconURL);
+ void linkHovered(const QUrl& url, const QString& title);
+ void navigationStateChanged();
+ void navigationRequested(QWebNavigationRequest* request);
+
+protected:
+ virtual void geometryChanged(const QRectF&, const QRectF&);
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
+
+private:
+ Q_DECLARE_PRIVATE(QQuickWebView)
+
+ QQuickWebView(WKContextRef, WKPageGroupRef, QQuickItem* parent = 0);
+ WKPageRef pageRef() const;
+
+ Q_PRIVATE_SLOT(d_func(), void _q_suspend());
+ Q_PRIVATE_SLOT(d_func(), void _q_resume());
+ Q_PRIVATE_SLOT(d_func(), void _q_viewportTrajectoryVectorChanged(const QPointF&));
+ Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFilesSelected());
+ Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
+ Q_PRIVATE_SLOT(d_func(), void _q_onVisibleChanged());
+ Q_PRIVATE_SLOT(d_func(), void _q_onReceivedResponseFromDownload(QWebDownloadItem*));
+ Q_PRIVATE_SLOT(d_func(), void _q_onIconChangedForPageURL(const QUrl&, const QUrl&));
+ // Hides QObject::d_ptr allowing us to use the convenience macros.
+ QScopedPointer<QQuickWebViewPrivate> d_ptr;
+ QQuickWebViewExperimental* m_experimental;
+
+ friend class QtWebPageLoadClient;
+ friend class QtWebPagePolicyClient;
+ friend class QtWebPageUIClient;
+ friend class WTR::PlatformWebView;
+ friend class QQuickWebViewExperimental;
+};
+
+QML_DECLARE_TYPE(QQuickWebView)
+
+class QWEBKIT_EXPORT QQuickWebViewAttached : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QQuickWebView* view READ view NOTIFY viewChanged FINAL)
+
+public:
+ QQuickWebViewAttached(QObject* object);
+ QQuickWebView* view() const { return m_view; }
+ void setView(QQuickWebView*);
+
+Q_SIGNALS:
+ void viewChanged();
+
+private:
+ QQuickWebView* m_view;
+};
+
+QML_DECLARE_TYPEINFO(QQuickWebView, QML_HAS_ATTACHED_PROPERTIES)
+
+class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QQuickWebPage* page READ page CONSTANT FINAL)
+ Q_PROPERTY(QWebNavigationHistory* navigationHistory READ navigationHistory CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeComponent* alertDialog READ alertDialog WRITE setAlertDialog NOTIFY alertDialogChanged)
+ Q_PROPERTY(QDeclarativeComponent* confirmDialog READ confirmDialog WRITE setConfirmDialog NOTIFY confirmDialogChanged)
+ Q_PROPERTY(QDeclarativeComponent* promptDialog READ promptDialog WRITE setPromptDialog NOTIFY promptDialogChanged)
+ Q_PROPERTY(QDeclarativeComponent* itemSelector READ itemSelector WRITE setItemSelector NOTIFY itemSelectorChanged)
+ Q_PROPERTY(QWebPreferences* preferences READ preferences CONSTANT FINAL)
+ Q_PROPERTY(bool useTraditionalDesktopBehaviour READ useTraditionalDesktopBehaviour WRITE setUseTraditionalDesktopBehaviour)
+ Q_PROPERTY(QWebViewportInfo* viewportInfo READ viewportInfo CONSTANT FINAL)
+ Q_PROPERTY(QDeclarativeListProperty<QQuickUrlSchemeDelegate> urlSchemeDelegates READ schemeDelegates)
+ Q_ENUMS(NavigationRequestAction)
+
+public:
+ enum NavigationRequestAction {
+ DownloadRequest = 2
+ };
+
+ QQuickWebViewExperimental(QQuickWebView* webView);
+ virtual ~QQuickWebViewExperimental();
+
+ QDeclarativeComponent* alertDialog() const;
+ void setAlertDialog(QDeclarativeComponent*);
+ QDeclarativeComponent* confirmDialog() const;
+ void setConfirmDialog(QDeclarativeComponent*);
+ QDeclarativeComponent* promptDialog() const;
+ void setPromptDialog(QDeclarativeComponent*);
+ QDeclarativeComponent* itemSelector() const;
+ void setItemSelector(QDeclarativeComponent*);
+
+ QWebViewportInfo* viewportInfo();
+
+ QWebPreferences* preferences() const;
+ bool useTraditionalDesktopBehaviour() const;
+ QWebNavigationHistory* navigationHistory() const;
+ QQuickWebPage* page();
+
+ static QQuickUrlSchemeDelegate* schemeDelegates_At(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*, int index);
+ static void schemeDelegates_Append(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*, QQuickUrlSchemeDelegate*);
+ static int schemeDelegates_Count(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*);
+ static void schemeDelegates_Clear(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*);
+ QDeclarativeListProperty<QQuickUrlSchemeDelegate> schemeDelegates();
+ void invokeApplicationSchemeHandler(WTF::PassRefPtr<WebKit::QtNetworkRequestData>);
+ void sendApplicationSchemeReply(QQuickNetworkReply*);
+
+public Q_SLOTS:
+ void setUseTraditionalDesktopBehaviour(bool enable);
+ void goBackTo(int index);
+ void goForwardTo(int index);
+ void postMessage(const QString&);
+
+Q_SIGNALS:
+ void alertDialogChanged();
+ void confirmDialogChanged();
+ void promptDialogChanged();
+ void itemSelectorChanged();
+ void downloadRequested(QWebDownloadItem* downloadItem);
+ void permissionRequested(QWebPermissionRequest* permission);
+ void messageReceived(const QVariantMap& message);
+
+private:
+ QQuickWebView* q_ptr;
+ QQuickWebViewPrivate* d_ptr;
+ QObject* schemeParent;
+ QWebViewportInfo* m_viewportInfo;
+
+ friend class QtWebPageUIClient;
+
+ Q_DECLARE_PRIVATE(QQuickWebView)
+ Q_DECLARE_PUBLIC(QQuickWebView)
+};
+
+#endif // qquickwebview_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
new file mode 100644
index 000000000..3b999282b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qquickwebview_p_p_h
+#define qquickwebview_p_p_h
+
+#include "DrawingAreaProxy.h"
+#include "QtPageClient.h"
+#include "QtViewportInteractionEngine.h"
+#include "QtWebPageLoadClient.h"
+#include "QtWebPagePolicyClient.h"
+#include "QtWebPageUIClient.h"
+#include "QtWebUndoController.h"
+#include "WebPageProxy.h"
+
+#include "qquickwebview_p.h"
+#include "qquickwebpage_p.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QScopedPointer>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+class DownloadProxy;
+class QtWebContext;
+class WebPageProxy;
+}
+class QWebNavigationHistory;
+class QWebViewportInfo;
+
+QT_BEGIN_NAMESPACE
+class QDeclarativeComponent;
+class QFileDialog;
+QT_END_NAMESPACE
+
+class QQuickWebViewPrivate {
+ Q_DECLARE_PUBLIC(QQuickWebView)
+ friend class QQuickWebViewExperimental;
+ friend class QQuickWebPage;
+ friend class QWebPreferencesPrivate;
+ friend class QWebViewportInfo;
+
+public:
+ static QQuickWebViewPrivate* get(QQuickWebView* q) { return q->d_ptr.data(); }
+
+ QQuickWebViewPrivate(QQuickWebView* viewport);
+ virtual ~QQuickWebViewPrivate();
+
+ void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
+
+ void initializeTouch(QQuickWebView* viewport);
+ void initializeDesktop(QQuickWebView* viewport);
+ void enableMouseEvents();
+ void disableMouseEvents();
+
+ void loadDidCommit();
+
+ void didFinishFirstNonEmptyLayout();
+ void didChangeViewportProperties(const WebCore::ViewportArguments& args);
+ void didChangeBackForwardList();
+
+ void updateViewportSize();
+ QtViewportInteractionEngine::Constraints computeViewportConstraints();
+
+ void updateVisibleContentRectAndScale();
+
+ void _q_suspend();
+ void _q_resume();
+ void _q_viewportTrajectoryVectorChanged(const QPointF&);
+ void _q_onOpenPanelFilesSelected();
+ void _q_onOpenPanelFinished(int result);
+ void _q_onVisibleChanged();
+ void _q_onReceivedResponseFromDownload(QWebDownloadItem*);
+ void _q_onIconChangedForPageURL(const QUrl& pageURL, const QUrl& iconURLString);
+
+ void chooseFiles(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, QtWebPageUIClient::FileChooserType);
+ void runJavaScriptAlert(const QString&);
+ bool runJavaScriptConfirm(const QString&);
+ QString runJavaScriptPrompt(const QString&, const QString& defaultValue, bool& ok);
+
+ void setUseTraditionalDesktopBehaviour(bool enable);
+ void setViewInAttachedProperties(QObject*);
+ void setIcon(const QUrl&);
+
+ bool navigatorQtObjectEnabled() const;
+ void setNavigatorQtObjectEnabled(bool);
+
+ // PageClient.
+ WebCore::IntSize viewSize() const;
+ void didReceiveMessageFromNavigatorQtObject(const String& message);
+ void pageDidRequestScroll(const QPoint& pos);
+ void didChangeContentsSize(const QSize& newSize);
+ void processDidCrash();
+ void didRelaunchProcess();
+ PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ void handleDownloadRequest(DownloadProxy*);
+
+private:
+ // This class is responsible for collecting and applying all properties
+ // on the viewport item, when transitioning from page A to page B is finished.
+ // See more at https://trac.webkit.org/wiki/QtWebKitLayoutInteraction
+ class PostTransitionState {
+ public:
+ PostTransitionState(QQuickWebViewPrivate* parent)
+ : p(parent)
+ { }
+
+ void apply();
+
+ QQuickWebViewPrivate* p;
+ QSize contentsSize;
+ QPoint position;
+ };
+
+ RefPtr<QtWebContext> context;
+ RefPtr<WebKit::WebPageProxy> webPageProxy;
+
+ QtPageClient pageClient;
+ QtWebUndoController undoController;
+ OwnPtr<QWebNavigationHistory> navigationHistory;
+ OwnPtr<QWebPreferences> preferences;
+
+ QScopedPointer<QtWebPageLoadClient> pageLoadClient;
+ QScopedPointer<QtWebPagePolicyClient> pagePolicyClient;
+ QScopedPointer<QtWebPageUIClient> pageUIClient;
+
+ QScopedPointer<QQuickWebPage> pageView;
+ QScopedPointer<QtViewportInteractionEngine> interactionEngine;
+
+ QQuickWebView* q_ptr;
+
+ QDeclarativeComponent* alertDialog;
+ QDeclarativeComponent* confirmDialog;
+ QDeclarativeComponent* promptDialog;
+ QDeclarativeComponent* itemSelector;
+
+ WebCore::ViewportArguments viewportArguments;
+ OwnPtr<PostTransitionState> postTransitionState;
+ QFileDialog* fileDialog;
+ WKOpenPanelResultListenerRef openPanelResultListener;
+
+ bool isTransitioningToNewPage;
+ bool pageIsSuspended;
+
+ bool useTraditionalDesktopBehaviour;
+ bool m_navigatorQtObjectEnabled;
+ QUrl m_iconURL;
+};
+
+#endif // qquickwebview_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem.cpp b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem.cpp
new file mode 100644
index 000000000..85476431f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qwebdownloaditem_p.h"
+
+#include "DownloadProxy.h"
+#include "qwebdownloaditem_p_p.h"
+
+QWebDownloadItemPrivate::QWebDownloadItemPrivate(QWebDownloadItem* qq)
+ : q(qq)
+ , downloadProxy(0)
+ , expectedContentLength(0)
+ , totalBytesReceived(0)
+{
+}
+
+QWebDownloadItem::QWebDownloadItem(QObject* parent)
+ : QObject(parent)
+ , d(new QWebDownloadItemPrivate(this))
+{
+}
+
+QWebDownloadItem::~QWebDownloadItem()
+{
+ delete d;
+}
+
+QUrl QWebDownloadItem::url() const
+{
+ return d->sourceUrl;
+}
+
+QString QWebDownloadItem::destinationPath() const
+{
+ return d->destinationPath;
+}
+
+void QWebDownloadItem::setDestinationPath(const QString& destination)
+{
+ d->destinationPath = destination;
+}
+
+QString QWebDownloadItem::suggestedFilename() const
+{
+ return d->suggestedFilename;
+}
+
+QString QWebDownloadItem::mimeType() const
+{
+ return d->mimeType;
+}
+
+quint64 QWebDownloadItem::expectedContentLength() const
+{
+ return d->expectedContentLength;
+}
+
+quint64 QWebDownloadItem::totalBytesReceived() const
+{
+ return d->totalBytesReceived;
+}
+
+void QWebDownloadItem::cancel()
+{
+ ASSERT(d->downloadProxy);
+ d->downloadProxy->cancel();
+}
+
+void QWebDownloadItem::start()
+{
+ ASSERT(!d->suggestedFilename.isEmpty());
+
+ if (d->destinationPath.isEmpty())
+ d->destinationPath = d->suggestedFilename;
+
+ d->downloadProxy->startTransfer(d->destinationPath);
+}
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h
new file mode 100644
index 000000000..79659753b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qwebdownloaditem_p_h
+#define qwebdownloaditem_p_h
+
+#include "qwebkitglobal.h"
+#include <QObject>
+#include <QUrl>
+
+class QWebDownloadItemPrivate;
+class QtWebError;
+
+QT_BEGIN_NAMESPACE
+class QString;
+QT_END_NAMESPACE
+
+namespace WebKit {
+class QtDownloadManager;
+}
+
+class QWEBKIT_EXPORT QWebDownloadItem : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(quint64 expectedContentLength READ expectedContentLength CONSTANT FINAL)
+ Q_PROPERTY(QString destinationPath READ destinationPath WRITE setDestinationPath)
+ Q_PROPERTY(QString suggestedFilename READ suggestedFilename CONSTANT FINAL)
+ Q_PROPERTY(quint64 totalBytesReceived READ totalBytesReceived NOTIFY totalBytesReceivedChanged FINAL)
+ Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
+ Q_ENUMS(DownloadError)
+public:
+ virtual ~QWebDownloadItem();
+
+ enum DownloadError {
+ Aborted = 0,
+ CannotWriteToFile,
+ CannotOpenFile,
+ DestinationAlreadyExists,
+ Cancelled,
+ CannotDetermineFilename,
+ NetworkFailure
+ };
+
+ QUrl url() const;
+ QString destinationPath() const;
+ QString suggestedFilename() const;
+ QString mimeType() const;
+ quint64 expectedContentLength() const;
+ quint64 totalBytesReceived() const;
+ void setDestinationPath(const QString& destination);
+
+public Q_SLOTS:
+ void start();
+ void cancel();
+
+Q_SIGNALS:
+ void destinationFileCreated(const QString& destinationPath);
+ void totalBytesReceivedChanged(quint64 bytesReceived);
+ void succeeded();
+ void failed(QWebDownloadItem::DownloadError error, const QUrl& url, const QString& description);
+
+private:
+ QWebDownloadItem(QObject* parent = 0);
+ QWebDownloadItemPrivate* d;
+
+ friend class WebKit::QtDownloadManager;
+ friend class QQuickWebViewPrivate;
+};
+
+#endif // qwebdownloaditem_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p_p.h
new file mode 100644
index 000000000..780848be6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebdownloaditem_p_p.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+
+#ifndef qwebdownloaditem_p_p_h
+#define qwebdownloaditem_p_p_h
+
+#include "qwebdownloaditem_p.h"
+#include <QUrl>
+
+namespace WebKit {
+class DownloadProxy;
+}
+
+class QWebDownloadItemPrivate : public QObject {
+ Q_OBJECT
+public:
+ QWebDownloadItemPrivate(QWebDownloadItem*);
+
+ void didReceiveResponse(QWebDownloadItem* download) { emit receivedResponse(download); }
+
+ QWebDownloadItem* q;
+
+ WebKit::DownloadProxy* downloadProxy;
+
+ QUrl sourceUrl;
+ QString suggestedFilename;
+ QString destinationPath;
+ QString mimeType;
+ quint64 expectedContentLength;
+ quint64 totalBytesReceived;
+
+Q_SIGNALS:
+ void receivedResponse(QWebDownloadItem*);
+};
+
+#endif // qwebdownloaditem_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp
new file mode 100644
index 000000000..dce6ee9df
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp
@@ -0,0 +1,66 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "qwebiconimageprovider_p.h"
+
+#include "QtWebContext.h"
+#include "QtWebIconDatabaseClient.h"
+#include <QtCore/QUrl>
+#include <QtGui/QImage>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+
+QWebIconImageProvider::QWebIconImageProvider()
+ : QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
+{
+}
+
+QWebIconImageProvider::~QWebIconImageProvider()
+{
+}
+
+QImage QWebIconImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
+{
+ QString decodedIconUrl = id;
+ decodedIconUrl.remove(0, decodedIconUrl.indexOf('#') + 1);
+ String pageURL = QString::fromUtf8(QUrl(decodedIconUrl).toEncoded());
+
+ // The string identifier has the leading image://webicon/ already stripped, so we just
+ // need to truncate from the first slash to get the context id.
+ QString contextIDAsString = id;
+ contextIDAsString.truncate(contextIDAsString.indexOf(QLatin1Char('/')));
+ bool ok = false;
+ uint64_t contextId = contextIDAsString.toUInt(&ok);
+ if (!ok)
+ return QImage();
+ QtWebContext* context = QtWebContext::contextByID(contextId);
+ if (!context)
+ return QImage();
+
+ QtWebIconDatabaseClient* iconDatabase = context->iconDatabase();
+ QImage icon = requestedSize.isValid() ? iconDatabase->iconImageForPageURL(pageURL, requestedSize) : iconDatabase->iconImageForPageURL(pageURL);
+ ASSERT(!icon.isNull());
+
+ if (size)
+ *size = icon.size();
+
+ return icon;
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h
new file mode 100644
index 000000000..8815d7b76
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider_p.h
@@ -0,0 +1,33 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef qwebiconimageprovider_p_h
+#define qwebiconimageprovider_p_h
+
+#include "qwebkitglobal.h"
+#include <QtDeclarative/QDeclarativeImageProvider>
+
+class QWEBKIT_EXPORT QWebIconImageProvider : public QDeclarativeImageProvider {
+public:
+ QWebIconImageProvider();
+ ~QWebIconImageProvider();
+ QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize);
+};
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory.cpp b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory.cpp
new file mode 100644
index 000000000..ff77dae6b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory.cpp
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+*/
+
+#include "config.h"
+#include "qwebnavigationhistory_p.h"
+
+#include "WKBackForwardList.h"
+#include "WKStringQt.h"
+#include "WKURL.h"
+#include "WKURLQt.h"
+#include "WebBackForwardList.h"
+
+#include "qwebnavigationhistory_p_p.h"
+#include <QDeclarativeEngine>
+#include <QString>
+#include <QUrl>
+#include <WebKit2/WKArray.h>
+#include <WebKit2/WKBackForwardListItem.h>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+
+using namespace WebKit;
+
+QWebNavigationListModelPrivate::QWebNavigationListModelPrivate(WKBackForwardListRef list)
+ : m_backForwardList(list)
+ , indexSign(0)
+{
+}
+
+QWebNavigationListModel* QWebNavigationListModelPrivate::createWebNavigationModel(WKBackForwardListRef list)
+{
+ QWebNavigationListModel* model = new QWebNavigationListModel();
+ model->d = new QWebNavigationListModelPrivate(list);
+ return model;
+}
+
+
+QWebNavigationHistoryPrivate::QWebNavigationHistoryPrivate(WKPageRef page)
+ : m_page(page)
+ , m_backForwardList(WKPageGetBackForwardList(page))
+ , m_backNavigationModel(adoptPtr(QWebNavigationListModelPrivate::createWebNavigationModel(m_backForwardList.get())))
+ , m_forwardNavigationModel(adoptPtr(QWebNavigationListModelPrivate::createWebNavigationModel(m_backForwardList.get())))
+{
+ m_backNavigationModel->d->count = &WKBackForwardListGetBackListCount;
+ m_backNavigationModel->d->indexSign = -1;
+ m_forwardNavigationModel->d->count = &WKBackForwardListGetForwardListCount;
+ m_forwardNavigationModel->d->indexSign = 1;
+}
+
+QWebNavigationHistory* QWebNavigationHistoryPrivate::createHistory(WKPageRef page)
+{
+ QWebNavigationHistory* history = new QWebNavigationHistory();
+ history->d = new QWebNavigationHistoryPrivate(page);
+ return history;
+}
+
+void QWebNavigationHistoryPrivate::reset()
+{
+ m_backNavigationModel->reset();
+ m_forwardNavigationModel->reset();
+}
+
+void QWebNavigationHistoryPrivate::goBackTo(int index)
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(m_backForwardList.get(), -(index + 1));
+ if (itemRef && m_page)
+ WKPageGoToBackForwardListItem(m_page.get(), itemRef.get());
+}
+
+void QWebNavigationHistoryPrivate::goForwardTo(int index)
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(m_backForwardList.get(), index + 1);
+ if (itemRef && m_page)
+ WKPageGoToBackForwardListItem(m_page.get(), itemRef.get());
+}
+
+QWebNavigationListModel::QWebNavigationListModel()
+ : QAbstractListModel()
+{
+ QHash<int, QByteArray> roles;
+ roles[QWebNavigationHistory::UrlRole] = "url";
+ roles[QWebNavigationHistory::TitleRole] = "title";
+ setRoleNames(roles);
+}
+
+QWebNavigationListModel::~QWebNavigationListModel()
+{
+ delete d;
+}
+
+int QWebNavigationListModel::rowCount(const QModelIndex&) const
+{
+ return d->count(d->m_backForwardList.get());
+}
+
+QVariant QWebNavigationListModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (role < QWebNavigationHistory::UrlRole || role > QWebNavigationHistory::TitleRole)
+ return QVariant();
+
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(d->m_backForwardList.get(), (index.row() + 1) * d->indexSign);
+ if (role == QWebNavigationHistory::UrlRole) {
+ WKRetainPtr<WKURLRef> url(AdoptWK, WKBackForwardListItemCopyURL(itemRef.get()));
+ return WKURLCopyQUrl(url.get());
+ }
+
+ if (role == QWebNavigationHistory::TitleRole) {
+ WKRetainPtr<WKStringRef> title(AdoptWK, WKBackForwardListItemCopyTitle(itemRef.get()));
+ return WKStringCopyQString(title.get());
+ }
+
+ return QVariant();
+}
+
+QWebNavigationHistory::QWebNavigationHistory()
+ : QObject()
+{
+}
+
+QWebNavigationHistory::~QWebNavigationHistory()
+{
+ delete d;
+}
+
+QWebNavigationListModel* QWebNavigationHistory::backItems() const
+{
+ return d->m_backNavigationModel.get();
+}
+
+QWebNavigationListModel* QWebNavigationHistory::forwardItems() const
+{
+ return d->m_forwardNavigationModel.get();
+}
+
+#include "moc_qwebnavigationhistory_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h
new file mode 100644
index 000000000..929114472
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+*/
+
+#ifndef qwebnavigationhistory_p_h
+#define qwebnavigationhistory_p_h
+
+#include "qwebkitglobal.h"
+#include <QAbstractListModel>
+#include <QObject>
+#include <QUrl>
+#include <QVariant>
+#include <qdeclarative.h>
+
+class QAbstractListModel;
+class QWebNavigationHistoryPrivate;
+class QWebNavigationListModelPrivate;
+class QUrl;
+class QString;
+
+class QWEBKIT_EXPORT QWebNavigationListModel : public QAbstractListModel {
+ Q_OBJECT
+public:
+ virtual ~QWebNavigationListModel();
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ QVariant data(const QModelIndex& index, int role) const;
+
+private:
+ QWebNavigationListModel();
+ QWebNavigationListModelPrivate* d;
+ friend class QWebNavigationListModelPrivate;
+ friend class QWebNavigationHistory;
+ friend class QWebNavigationHistoryPrivate;
+};
+
+QML_DECLARE_TYPE(QWebNavigationListModel)
+
+class QWEBKIT_EXPORT QWebNavigationHistory : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QWebNavigationListModel* backItems READ backItems CONSTANT FINAL)
+ Q_PROPERTY(QWebNavigationListModel* forwardItems READ forwardItems CONSTANT FINAL)
+public:
+ enum NavigationHistoryRoles {
+ UrlRole = Qt::UserRole + 1,
+ TitleRole = Qt::UserRole + 2
+ };
+
+ QWebNavigationListModel* backItems() const;
+ QWebNavigationListModel* forwardItems() const;
+
+ virtual ~QWebNavigationHistory();
+
+private:
+ QWebNavigationHistory();
+
+ QWebNavigationHistoryPrivate* d;
+ friend class QWebNavigationHistoryPrivate;
+ friend class QQuickWebViewPrivate;
+ friend class QQuickWebViewExperimental;
+};
+
+QML_DECLARE_TYPE(QWebNavigationHistory)
+
+#endif /* qwebnavigationhistory_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p_p.h
new file mode 100644
index 000000000..c8cc5ab32
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationhistory_p_p.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * 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.
+*/
+
+#ifndef qwebnavigationhistory_p_p_h
+#define qwebnavigationhistory_p_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QObject>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+class WebBackForwardList;
+}
+
+class QWebNavigationHistory;
+class QWebNavigationListModel;
+
+class QWebNavigationListModelPrivate {
+public:
+ QWebNavigationListModelPrivate(WKBackForwardListRef);
+
+ static QWebNavigationListModel* createWebNavigationModel(WKBackForwardListRef);
+
+ unsigned (*count)(WKBackForwardListRef);
+ WKRetainPtr<WKBackForwardListRef> m_backForwardList;
+ int indexSign;
+};
+
+class QWebNavigationHistoryPrivate {
+public:
+ static QWebNavigationHistory* createHistory(WKPageRef);
+
+ QWebNavigationHistoryPrivate(WKPageRef);
+ void reset();
+ void goBackTo(int index);
+ void goForwardTo(int index);
+
+ WKRetainPtr<WKPageRef> m_page;
+ WKRetainPtr<WKBackForwardListRef> m_backForwardList;
+ OwnPtr<QWebNavigationListModel> m_backNavigationModel;
+ OwnPtr<QWebNavigationListModel> m_forwardNavigationModel;
+};
+
+#endif /* qwebnavigationhistory_p_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
new file mode 100644
index 000000000..5208a061c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
@@ -0,0 +1,92 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#include "qwebnavigationrequest_p.h"
+
+#include "qquickwebview_p.h"
+
+class QWebNavigationRequestPrivate {
+public:
+ QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+ : url(url)
+ , originatingUrl(originatingUrl)
+ , button(button)
+ , modifiers(modifiers)
+ , action(QQuickWebView::AcceptRequest)
+ {
+ }
+
+ ~QWebNavigationRequestPrivate()
+ {
+ }
+
+ QUrl url;
+ QUrl originatingUrl;
+ Qt::MouseButton button;
+ Qt::KeyboardModifiers modifiers;
+ int action;
+};
+
+QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent)
+ : QObject(parent)
+ , d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers))
+{
+}
+
+QWebNavigationRequest::~QWebNavigationRequest()
+{
+ delete d;
+}
+
+void QWebNavigationRequest::setAction(int action)
+{
+ if (d->action == action)
+ return;
+
+ d->action = action;
+ emit actionChanged();
+}
+
+QUrl QWebNavigationRequest::url() const
+{
+ return d->url;
+}
+
+QUrl QWebNavigationRequest::originatingUrl() const
+{
+ return d->originatingUrl;
+}
+
+int QWebNavigationRequest::button() const
+{
+ return int(d->button);
+}
+
+int QWebNavigationRequest::modifiers() const
+{
+ return int(d->modifiers);
+}
+
+int QWebNavigationRequest::action() const
+{
+ return int(d->action);
+}
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
new file mode 100644
index 000000000..986b1c12d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef qwebnavigationrequest_p_h
+#define qwebnavigationrequest_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
+
+class QWebNavigationRequestPrivate;
+
+class QWEBKIT_EXPORT QWebNavigationRequest : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QUrl url READ url CONSTANT FINAL)
+ Q_PROPERTY(QUrl originatingUrl READ originatingUrl CONSTANT FINAL)
+ Q_PROPERTY(int button READ button CONSTANT FINAL)
+ Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
+ Q_PROPERTY(int action READ action WRITE setAction NOTIFY actionChanged FINAL)
+
+public:
+ QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent = 0);
+ ~QWebNavigationRequest();
+
+ QUrl url() const;
+ QUrl originatingUrl() const;
+ int button() const;
+ int modifiers() const;
+ int action() const;
+
+ void setAction(int action);
+
+Q_SIGNALS:
+ void actionChanged();
+
+private:
+ QWebNavigationRequestPrivate* d;
+};
+
+#endif // qwebnavigationrequest_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp
new file mode 100644
index 000000000..16a438560
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp
@@ -0,0 +1,106 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+
+#include "qwebpermissionrequest_p.h"
+
+#include "WKStringQt.h"
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+
+
+class QWebPermissionRequestPrivate : public QSharedData {
+public:
+ QWebPermissionRequestPrivate(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest)
+ : origin(securityOrigin)
+ , type(QWebPermissionRequest::Geolocation)
+ , request(permissionRequest)
+ , allow(false)
+ {
+ }
+ ~QWebPermissionRequestPrivate()
+ {
+ }
+
+ WKRetainPtr<WKSecurityOriginRef> origin;
+ QWebPermissionRequest::RequestType type;
+ WKRetainPtr<WKGeolocationPermissionRequestRef> request;
+ bool allow;
+};
+
+QWebPermissionRequest* QWebPermissionRequest::create(WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef request)
+{
+ return new QWebPermissionRequest(origin, request);
+}
+
+QWebPermissionRequest::QWebPermissionRequest(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest, QObject* parent)
+ : QObject(parent)
+ , d(new QWebPermissionRequestPrivate(securityOrigin, permissionRequest))
+{
+}
+
+QWebPermissionRequest::~QWebPermissionRequest()
+{
+}
+
+QWebPermissionRequest::RequestType QWebPermissionRequest::type() const
+{
+ return d->type;
+}
+
+void QWebPermissionRequest::setAllow(bool accepted)
+{
+ d->allow = accepted;
+ switch (type()) {
+ case Geolocation: {
+ if (accepted)
+ WKGeolocationPermissionRequestAllow(d->request.get());
+ else
+ WKGeolocationPermissionRequestDeny(d->request.get());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ deleteLater();
+}
+
+bool QWebPermissionRequest::allow() const
+{
+ return d->allow;
+}
+
+QString QWebPermissionRequest::scheme() const
+{
+ WKRetainPtr<WKStringRef> url = adoptWK(WKSecurityOriginCopyProtocol(d->origin.get()));
+ return WKStringCopyQString(url.get());
+}
+
+QString QWebPermissionRequest::host() const
+{
+ WKRetainPtr<WKStringRef> origin = adoptWK(WKSecurityOriginCopyHost(d->origin.get()));
+ return WKStringCopyQString(origin.get());
+}
+
+int QWebPermissionRequest::port() const
+{
+ return static_cast<int>(WKSecurityOriginGetPort(d->origin.get()));
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h
new file mode 100644
index 000000000..5824c4ccd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef qwebpermissionrequest_p_h
+#define qwebpermissionrequest_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+#include <QtCore/qshareddata.h>
+#include <WebKit2/WKGeolocationPermissionRequest.h>
+#include <WebKit2/WKSecurityOrigin.h>
+
+class QWebPermissionRequestPrivate;
+
+class QWEBKIT_EXPORT QWebPermissionRequest : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(bool allow READ allow WRITE setAllow)
+ Q_PROPERTY(RequestType type READ type)
+ Q_PROPERTY(QString scheme READ scheme)
+ Q_PROPERTY(QString host READ host)
+ Q_PROPERTY(int port READ port)
+ Q_ENUMS(RequestType)
+
+public:
+ enum RequestType {
+ Geolocation
+ };
+
+ static QWebPermissionRequest* create(WKSecurityOriginRef, WKGeolocationPermissionRequestRef);
+ virtual ~QWebPermissionRequest();
+
+ RequestType type() const;
+ bool allow() const;
+ QString scheme() const;
+ QString host() const;
+ int port() const;
+
+public Q_SLOTS:
+ void setAllow(bool);
+
+private:
+ friend class QWebPermissionRequestPrivate;
+ QWebPermissionRequest(WKSecurityOriginRef securityOrigin, WKGeolocationPermissionRequestRef permissionRequest, QObject* parent = 0);
+
+private:
+ QExplicitlySharedDataPointer<QWebPermissionRequestPrivate> d;
+};
+
+
+#endif // qwebpermissionrequest_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
new file mode 100644
index 000000000..71c11afe5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -0,0 +1,404 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "config.h"
+#include "qwebpreferences_p.h"
+
+#include "WKPageGroup.h"
+#include "WKPreferences.h"
+#include "WKPreferencesPrivate.h"
+#include "WKRetainPtr.h"
+#include "WKStringQt.h"
+#include "qquickwebview_p_p.h"
+#include "qwebpreferences_p_p.h"
+
+QWebPreferences* QWebPreferencesPrivate::createPreferences(QQuickWebViewPrivate* webViewPrivate)
+{
+ QWebPreferences* prefs = new QWebPreferences;
+ prefs->d->webViewPrivate = webViewPrivate;
+ return prefs;
+}
+
+bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute attr) const
+{
+ switch (attr) {
+ case AutoLoadImages:
+ return WKPreferencesGetLoadsImagesAutomatically(preferencesRef());
+ case JavascriptEnabled:
+ return WKPreferencesGetJavaScriptEnabled(preferencesRef());
+ case PluginsEnabled:
+ return WKPreferencesGetPluginsEnabled(preferencesRef());
+ case OfflineWebApplicationCacheEnabled:
+ return WKPreferencesGetOfflineWebApplicationCacheEnabled(preferencesRef());
+ case LocalStorageEnabled:
+ return WKPreferencesGetLocalStorageEnabled(preferencesRef());
+ case XSSAuditingEnabled:
+ return WKPreferencesGetXSSAuditorEnabled(preferencesRef());
+ case PrivateBrowsingEnabled:
+ return WKPreferencesGetPrivateBrowsingEnabled(preferencesRef());
+ case DnsPrefetchEnabled:
+ return WKPreferencesGetDNSPrefetchingEnabled(preferencesRef());
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+}
+
+void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute attr, bool enable)
+{
+ switch (attr) {
+ case AutoLoadImages:
+ WKPreferencesSetLoadsImagesAutomatically(preferencesRef(), enable);
+ break;
+ case JavascriptEnabled:
+ WKPreferencesSetJavaScriptEnabled(preferencesRef(), enable);
+ break;
+ case PluginsEnabled:
+ WKPreferencesSetPluginsEnabled(preferencesRef(), enable);
+ break;
+ case OfflineWebApplicationCacheEnabled:
+ WKPreferencesSetOfflineWebApplicationCacheEnabled(preferencesRef(), enable);
+ break;
+ case LocalStorageEnabled:
+ WKPreferencesSetLocalStorageEnabled(preferencesRef(), enable);
+ break;
+ case XSSAuditingEnabled:
+ WKPreferencesSetXSSAuditorEnabled(preferencesRef(), enable);
+ break;
+ case PrivateBrowsingEnabled:
+ WKPreferencesSetPrivateBrowsingEnabled(preferencesRef(), enable);
+ break;
+ case DnsPrefetchEnabled:
+ WKPreferencesSetDNSPrefetchingEnabled(preferencesRef(), enable);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void QWebPreferencesPrivate::setFontFamily(QWebPreferencesPrivate::FontFamily which, const QString& family)
+{
+ switch (which) {
+ case StandardFont:
+ WKPreferencesSetStandardFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ case FixedFont:
+ WKPreferencesSetFixedFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ case SerifFont:
+ WKPreferencesSetSerifFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ case SansSerifFont:
+ WKPreferencesSetSansSerifFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ case CursiveFont:
+ WKPreferencesSetCursiveFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ case FantasyFont:
+ WKPreferencesSetFantasyFontFamily(preferencesRef(), WKStringCreateWithQString(family));
+ break;
+ default:
+ break;
+ }
+}
+
+QString QWebPreferencesPrivate::fontFamily(QWebPreferencesPrivate::FontFamily which) const
+{
+ switch (which) {
+ case StandardFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case FixedFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case SerifFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case SansSerifFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case CursiveFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case FantasyFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(preferencesRef()));
+ return WKStringCopyQString(stringRef.get());
+ }
+ default:
+ return QString();
+ }
+}
+
+void QWebPreferencesPrivate::setFontSize(QWebPreferencesPrivate::FontSizeType type, unsigned size)
+{
+ switch (type) {
+ case MinimumFontSize:
+ WKPreferencesSetMinimumFontSize(preferencesRef(), size);
+ break;
+ case DefaultFontSize:
+ WKPreferencesSetDefaultFontSize(preferencesRef(), size);
+ break;
+ case DefaultFixedFontSize:
+ WKPreferencesSetDefaultFixedFontSize(preferencesRef(), size);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+unsigned QWebPreferencesPrivate::fontSize(QWebPreferencesPrivate::FontSizeType type) const
+{
+ switch (type) {
+ case MinimumFontSize:
+ return WKPreferencesGetMinimumFontSize(preferencesRef());
+ case DefaultFontSize:
+ return WKPreferencesGetDefaultFontSize(preferencesRef());
+ case DefaultFixedFontSize:
+ return WKPreferencesGetDefaultFixedFontSize(preferencesRef());
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+}
+
+QWebPreferences::QWebPreferences()
+ : d(new QWebPreferencesPrivate)
+{
+}
+
+QWebPreferences::~QWebPreferences()
+{
+ delete d;
+}
+
+bool QWebPreferences::autoLoadImages() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::AutoLoadImages);
+}
+
+void QWebPreferences::setAutoLoadImages(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::AutoLoadImages, enable);
+ emit autoLoadImagesChanged();
+}
+
+bool QWebPreferences::javascriptEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::JavascriptEnabled);
+}
+
+void QWebPreferences::setJavascriptEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::JavascriptEnabled, enable);
+ emit javascriptEnabledChanged();
+}
+
+bool QWebPreferences::pluginsEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::PluginsEnabled);
+}
+
+void QWebPreferences::setPluginsEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::PluginsEnabled, enable);
+ emit pluginsEnabledChanged();
+}
+
+bool QWebPreferences::offlineWebApplicationCacheEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::OfflineWebApplicationCacheEnabled);
+}
+
+void QWebPreferences::setOfflineWebApplicationCacheEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::OfflineWebApplicationCacheEnabled, enable);
+ emit offlineWebApplicationCacheEnabledChanged();
+}
+
+bool QWebPreferences::localStorageEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::LocalStorageEnabled);
+}
+
+void QWebPreferences::setLocalStorageEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::LocalStorageEnabled, enable);
+ emit localStorageEnabledChanged();
+}
+
+bool QWebPreferences::xssAuditingEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::XSSAuditingEnabled);
+}
+
+void QWebPreferences::setXssAuditingEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::XSSAuditingEnabled, enable);
+ emit xssAuditingEnabledChanged();
+}
+
+bool QWebPreferences::privateBrowsingEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::PrivateBrowsingEnabled);
+}
+
+void QWebPreferences::setPrivateBrowsingEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::PrivateBrowsingEnabled, enable);
+ emit privateBrowsingEnabledChanged();
+}
+
+bool QWebPreferences::dnsPrefetchEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::DnsPrefetchEnabled);
+}
+
+void QWebPreferences::setDnsPrefetchEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::DnsPrefetchEnabled, enable);
+ emit dnsPrefetchEnabledChanged();
+}
+
+bool QWebPreferences::navigatorQtObjectEnabled() const
+{
+ return d->webViewPrivate->navigatorQtObjectEnabled();
+}
+
+void QWebPreferences::setNavigatorQtObjectEnabled(bool enable)
+{
+ if (enable == navigatorQtObjectEnabled())
+ return;
+ d->webViewPrivate->setNavigatorQtObjectEnabled(enable);
+ emit navigatorQtObjectEnabledChanged();
+}
+
+QString QWebPreferences::standardFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::StandardFont);
+}
+
+void QWebPreferences::setStandardFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::StandardFont, family);
+ emit standardFontFamilyChanged();
+}
+
+QString QWebPreferences::fixedFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::FixedFont);
+}
+
+void QWebPreferences::setFixedFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::FixedFont, family);
+ emit fixedFontFamilyChanged();
+}
+
+QString QWebPreferences::serifFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::SerifFont);
+}
+
+void QWebPreferences::setSerifFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::SerifFont, family);
+ emit serifFontFamilyChanged();
+}
+
+QString QWebPreferences::sansSerifFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::SansSerifFont);
+}
+
+void QWebPreferences::setSansSerifFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::SansSerifFont, family);
+ emit sansSerifFontFamilyChanged();
+}
+
+QString QWebPreferences::cursiveFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::CursiveFont);
+}
+
+void QWebPreferences::setCursiveFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::CursiveFont, family);
+ emit cursiveFontFamilyChanged();
+}
+
+QString QWebPreferences::fantasyFontFamily() const
+{
+ return d->fontFamily(QWebPreferencesPrivate::FantasyFont);
+}
+
+void QWebPreferences::setFantasyFontFamily(const QString& family)
+{
+ d->setFontFamily(QWebPreferencesPrivate::FantasyFont, family);
+ emit fantasyFontFamilyChanged();
+}
+
+unsigned QWebPreferences::minimumFontSize() const
+{
+ return d->fontSize(QWebPreferencesPrivate::MinimumFontSize);
+}
+
+void QWebPreferences::setMinimumFontSize(unsigned size)
+{
+ d->setFontSize(QWebPreferencesPrivate::MinimumFontSize, size);
+ emit minimumFontSizeChanged();
+}
+
+unsigned QWebPreferences::defaultFontSize() const
+{
+ return d->fontSize(QWebPreferencesPrivate::DefaultFontSize);
+}
+
+void QWebPreferences::setDefaultFontSize(unsigned size)
+{
+ d->setFontSize(QWebPreferencesPrivate::DefaultFontSize, size);
+ emit defaultFontSizeChanged();
+}
+
+unsigned QWebPreferences::defaultFixedFontSize() const
+{
+ return d->fontSize(QWebPreferencesPrivate::DefaultFixedFontSize);
+}
+
+void QWebPreferences::setDefaultFixedFontSize(unsigned size)
+{
+ d->setFontSize(QWebPreferencesPrivate::DefaultFixedFontSize, size);
+ emit defaultFixedFontSizeChanged();
+}
+
+WKPreferencesRef QWebPreferencesPrivate::preferencesRef() const
+{
+ WKPageGroupRef pageGroupRef = toAPI(webViewPrivate->webPageProxy->pageGroup());
+ return WKPageGroupGetPreferences(pageGroupRef);
+}
+
+QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences)
+{
+ return preferences->d;
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
new file mode 100644
index 000000000..29df04cea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
@@ -0,0 +1,141 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef qwebpreferences_p_h
+#define qwebpreferences_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+
+class QWebPreferencesPrivate;
+
+class QWEBKIT_EXPORT QWebPreferences : public QObject {
+ Q_OBJECT
+public:
+ ~QWebPreferences();
+
+ Q_PROPERTY(bool autoLoadImages READ autoLoadImages WRITE setAutoLoadImages NOTIFY autoLoadImagesChanged FINAL)
+ Q_PROPERTY(bool javascriptEnabled READ javascriptEnabled WRITE setJavascriptEnabled NOTIFY javascriptEnabledChanged FINAL)
+ Q_PROPERTY(bool pluginsEnabled READ pluginsEnabled WRITE setPluginsEnabled NOTIFY pluginsEnabledChanged FINAL)
+ Q_PROPERTY(bool offlineWebApplicationCacheEnabled READ offlineWebApplicationCacheEnabled WRITE setOfflineWebApplicationCacheEnabled NOTIFY offlineWebApplicationCacheEnabledChanged FINAL)
+ Q_PROPERTY(bool localStorageEnabled READ localStorageEnabled WRITE setLocalStorageEnabled NOTIFY localStorageEnabledChanged FINAL)
+ Q_PROPERTY(bool xssAuditingEnabled READ xssAuditingEnabled WRITE setXssAuditingEnabled NOTIFY xssAuditingEnabledChanged FINAL)
+ Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled NOTIFY privateBrowsingEnabledChanged FINAL)
+ Q_PROPERTY(bool dnsPrefetchEnabled READ dnsPrefetchEnabled WRITE setDnsPrefetchEnabled NOTIFY dnsPrefetchEnabledChanged FINAL)
+ Q_PROPERTY(bool navigatorQtObjectEnabled READ navigatorQtObjectEnabled WRITE setNavigatorQtObjectEnabled NOTIFY navigatorQtObjectEnabledChanged FINAL)
+
+ Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL)
+ Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL)
+ Q_PROPERTY(QString serifFontFamily READ serifFontFamily WRITE setSerifFontFamily NOTIFY serifFontFamilyChanged FINAL)
+ Q_PROPERTY(QString sansSerifFontFamily READ sansSerifFontFamily WRITE setSansSerifFontFamily NOTIFY sansSerifFontFamilyChanged FINAL)
+ Q_PROPERTY(QString cursiveFontFamily READ cursiveFontFamily WRITE setCursiveFontFamily NOTIFY cursiveFontFamilyChanged FINAL)
+ Q_PROPERTY(QString fantasyFontFamily READ fantasyFontFamily WRITE setFantasyFontFamily NOTIFY fantasyFontFamilyChanged FINAL)
+
+ Q_PROPERTY(unsigned minimumFontSize READ minimumFontSize WRITE setMinimumFontSize NOTIFY minimumFontSizeChanged FINAL)
+ Q_PROPERTY(unsigned defaultFontSize READ defaultFontSize WRITE setDefaultFontSize NOTIFY defaultFontSizeChanged FINAL)
+ Q_PROPERTY(unsigned defaultFixedFontSize READ defaultFixedFontSize WRITE setDefaultFixedFontSize NOTIFY defaultFixedFontSizeChanged FINAL)
+
+ bool autoLoadImages() const;
+ void setAutoLoadImages(bool enable);
+
+ bool javascriptEnabled() const;
+ void setJavascriptEnabled(bool enable);
+
+ bool pluginsEnabled() const;
+ void setPluginsEnabled(bool enable);
+
+ bool offlineWebApplicationCacheEnabled() const;
+ void setOfflineWebApplicationCacheEnabled(bool enable);
+
+ bool localStorageEnabled() const;
+ void setLocalStorageEnabled(bool enable);
+
+ bool xssAuditingEnabled() const;
+ void setXssAuditingEnabled(bool enable);
+
+ bool privateBrowsingEnabled() const;
+ void setPrivateBrowsingEnabled(bool enable);
+
+ bool dnsPrefetchEnabled() const;
+ void setDnsPrefetchEnabled(bool enable);
+
+ bool navigatorQtObjectEnabled() const;
+ void setNavigatorQtObjectEnabled(bool);
+
+ QString standardFontFamily() const;
+ void setStandardFontFamily(const QString& family);
+
+ QString fixedFontFamily() const;
+ void setFixedFontFamily(const QString& family);
+
+ QString serifFontFamily() const;
+ void setSerifFontFamily(const QString& family);
+
+ QString sansSerifFontFamily() const;
+ void setSansSerifFontFamily(const QString& family);
+
+ QString cursiveFontFamily() const;
+ void setCursiveFontFamily(const QString& family);
+
+ QString fantasyFontFamily() const;
+ void setFantasyFontFamily(const QString& family);
+
+ unsigned minimumFontSize() const;
+ void setMinimumFontSize(unsigned size);
+
+ unsigned defaultFontSize() const;
+ void setDefaultFontSize(unsigned size);
+
+ unsigned defaultFixedFontSize() const;
+ void setDefaultFixedFontSize(unsigned size);
+
+Q_SIGNALS:
+ void autoLoadImagesChanged();
+ void pluginsEnabledChanged();
+ void javascriptEnabledChanged();
+ void offlineWebApplicationCacheEnabledChanged();
+ void localStorageEnabledChanged();
+ void xssAuditingEnabledChanged();
+ void privateBrowsingEnabledChanged();
+ void dnsPrefetchEnabledChanged();
+ void navigatorQtObjectEnabledChanged();
+
+ void standardFontFamilyChanged();
+ void fixedFontFamilyChanged();
+ void serifFontFamilyChanged();
+ void sansSerifFontFamilyChanged();
+ void cursiveFontFamilyChanged();
+ void fantasyFontFamilyChanged();
+
+ void minimumFontSizeChanged();
+ void defaultFontSizeChanged();
+ void defaultFixedFontSizeChanged();
+
+private:
+ Q_DISABLE_COPY(QWebPreferences)
+
+ QWebPreferences();
+
+ QWebPreferencesPrivate *d;
+
+ friend class QWebPreferencesPrivate;
+};
+
+#endif // qwebpreferences_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
new file mode 100644
index 000000000..f4ef13c21
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p_p.h
@@ -0,0 +1,75 @@
+/*
+ Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef qwebpreferences_p_p_h
+#define qwebpreferences_p_p_h
+
+#include "WKPreferences.h"
+
+class QQuickWebViewPrivate;
+
+class QWebPreferencesPrivate {
+public:
+
+ enum WebAttribute {
+ AutoLoadImages,
+ JavascriptEnabled,
+ PluginsEnabled,
+ OfflineWebApplicationCacheEnabled,
+ LocalStorageEnabled,
+ XSSAuditingEnabled,
+ FrameFlatteningEnabled,
+ PrivateBrowsingEnabled,
+ DnsPrefetchEnabled
+ };
+
+ enum FontFamily {
+ StandardFont,
+ FixedFont,
+ SerifFont,
+ SansSerifFont,
+ CursiveFont,
+ FantasyFont
+ };
+
+ enum FontSizeType {
+ MinimumFontSize,
+ DefaultFontSize,
+ DefaultFixedFontSize
+ };
+
+ static QWebPreferences* createPreferences(QQuickWebViewPrivate*);
+
+ void setAttribute(WebAttribute attr, bool enable);
+ bool testAttribute(WebAttribute attr) const;
+
+ void setFontFamily(FontFamily which, const QString& family);
+ QString fontFamily(FontFamily which) const;
+
+ void setFontSize(FontSizeType type, unsigned size);
+ unsigned fontSize(FontSizeType type) const;
+
+ WKPreferencesRef preferencesRef() const;
+
+ QQuickWebViewPrivate* webViewPrivate;
+
+ static QWebPreferencesPrivate* get(QWebPreferences*);
+};
+
+#endif // qwebpreferences_p_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp
new file mode 100644
index 000000000..8b6fb418b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "qwebviewportinfo_p.h"
+
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+
+QWebViewportInfo::QWebViewportInfo(QQuickWebViewPrivate* webViewPrivate, QObject* parent)
+ : QObject(parent)
+ , m_webViewPrivate(webViewPrivate)
+{
+
+}
+
+QWebViewportInfo::~QWebViewportInfo()
+{
+
+}
+
+QSize QWebViewportInfo::contentsSize() const
+{
+ return QSize(m_webViewPrivate->pageView->width(), m_webViewPrivate->pageView->height());
+}
+
+QVariant QWebViewportInfo::currentScale() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->currentCSSScale();
+}
+
+QVariant QWebViewportInfo::devicePixelRatio() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().devicePixelRatio;
+}
+
+QVariant QWebViewportInfo::initialScale() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().initialScale;
+}
+
+QVariant QWebViewportInfo::minimumScale() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().minimumScale;
+}
+
+QVariant QWebViewportInfo::maximumScale() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().maximumScale;
+}
+
+QVariant QWebViewportInfo::isScalable() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().isUserScalable;
+}
+
+QVariant QWebViewportInfo::layoutSize() const
+{
+ if (!m_webViewPrivate->interactionEngine)
+ return QVariant();
+
+ return m_webViewPrivate->interactionEngine->constraints().layoutSize;
+}
+
+void QWebViewportInfo::didUpdateContentsSize()
+{
+ emit contentsSizeUpdated();
+}
+
+void QWebViewportInfo::didUpdateCurrentScale()
+{
+ emit currentScaleUpdated();
+}
+
+void QWebViewportInfo::didUpdateViewportConstraints()
+{
+ emit viewportConstraintsUpdated();
+ emit currentScaleUpdated();
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h
new file mode 100644
index 000000000..e1dea6575
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef qwebviewportinfp_p_h
+#define qwebviewportinfo_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QObject>
+#include <QtCore/QPointer>
+#include <QtCore/QSize>
+#include <QtCore/QVariant>
+#include <QtDeclarative/QtDeclarative>
+
+namespace WebCore {
+class ViewportAttributes;
+}
+class QQuickWebViewPrivate;
+
+class QWEBKIT_EXPORT QWebViewportInfo : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QSize contentsSize READ contentsSize NOTIFY contentsSizeUpdated)
+ Q_PROPERTY(QVariant currentScale READ currentScale NOTIFY currentScaleUpdated)
+ Q_PROPERTY(QVariant devicePixelRatio READ devicePixelRatio NOTIFY viewportConstraintsUpdated)
+ Q_PROPERTY(QVariant initialScale READ initialScale NOTIFY viewportConstraintsUpdated)
+ Q_PROPERTY(QVariant isScalable READ isScalable NOTIFY viewportConstraintsUpdated)
+ Q_PROPERTY(QVariant maximumScale READ maximumScale NOTIFY viewportConstraintsUpdated)
+ Q_PROPERTY(QVariant minimumScale READ minimumScale NOTIFY viewportConstraintsUpdated)
+ Q_PROPERTY(QVariant layoutSize READ layoutSize NOTIFY viewportConstraintsUpdated)
+
+signals:
+ void contentsSizeUpdated();
+ void currentScaleUpdated();
+ void viewportConstraintsUpdated();
+
+public:
+ QWebViewportInfo(QQuickWebViewPrivate* webviewPrivate, QObject* parent = 0);
+ virtual ~QWebViewportInfo();
+
+ QSize contentsSize() const;
+ QVariant currentScale() const;
+ QVariant devicePixelRatio() const;
+ QVariant initialScale() const;
+ QVariant isScalable() const;
+ QVariant layoutSize() const;
+ QVariant maximumScale() const;
+ QVariant minimumScale() const;
+
+ void didUpdateContentsSize();
+ void didUpdateCurrentScale();
+ void didUpdateViewportConstraints();
+
+private:
+ QQuickWebViewPrivate* m_webViewPrivate;
+};
+
+#endif // qwebviewportinfo_p
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html
new file mode 100644
index 000000000..b4eea41bd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page.html
@@ -0,0 +1 @@
+<h1>Basic page</h1>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html
new file mode 100644
index 000000000..f8cff2969
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/html/basic_page2.html
@@ -0,0 +1 @@
+<h1>Basic page 2</h1>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html b/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html
new file mode 100644
index 000000000..2fd91418a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/html/direct-image-compositing.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>Testing direct image layer optimisation</title>
+ <style type="text/css" media="screen">
+ img {
+ float: left;
+ width: 150px;
+ height: 150px;
+ }
+ img {
+ -webkit-transform: rotate3d(0, 0, 1, 0);
+ }
+ .test {
+ float: left;
+ height: 200px;
+ width: 260px;
+ }
+ </style>
+</head>
+<body>
+
+ <h1>Image optimisation in layers</h1>
+
+ <p>
+ This test exercises direct compositing of images with hardware acceleration. The visual results
+ using ACCELERATED_COMPOSITING and regular TOT should be identical. Running this test manually with
+ the correct debug options will show which elements are directly composited. See
+ <a href="https://bugs.webkit.org/show_bug.cgi?id=23361">https://bugs.webkit.org/show_bug.cgi?id=23361</a>
+ </p>
+
+ <div class="test">
+ <img src="resources/simple_image.png">
+ Basic image - no style - can be directly composited
+ </div>
+
+ <div class="test">
+ <img src="resources/simple_image.png" style="border: 5px solid blue;">
+ 5px blue border - can NOT be directly composited
+ </div>
+
+ <div class="test">
+ <img src="resources/simple_image.png" style="margin: 5px 5px;">
+ margin - can NOT be directly composited
+ </div>
+
+ <div class="test">
+ <img src="resources/simple_image.png" style="background-color: grey;">
+ solid background - can be directly composited
+ </div>
+
+ <div class="test">
+ <img src="resources/simple_image.png" style="background: orange url(resources/simple_image.png) -50px -50px;">
+ background image - can NOT be directly composited
+ </div>
+
+ <div class="test">
+ <img src="resources/simple_image.png" style="-webkit-transform: rotate3d(0, 0, 1, 10deg);">
+ rotated but otherwise no style - can be directly composited
+ </div>
+
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png
new file mode 100644
index 000000000..4685399ca
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/html/resources/simple_image.png
Binary files differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html b/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html
new file mode 100644
index 000000000..6b9b2d652
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/html/scroll.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<meta name="viewport" content="width=200, height=500, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
+<script type="text/javascript">
+function pageScroll() {
+ window.scrollBy(0,50); // horizontal and vertical scroll increments
+}
+</script>
+<style>
+ body {
+ background-color: blue;
+ margin: 50 50 50 50;
+ }
+ div {
+ font-color: white;
+ background-color: green;
+ width: 300px;
+ height: 1000px;
+ }
+</style>
+
+<head>
+<title>Scroll test </title>
+</head>
+<body onload="pageScroll()">
+<div>
+</div>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml
new file mode 100644
index 000000000..4dce0918b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: component
+ experimental.useTraditionalDesktopBehaviour: true
+}
+
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml
new file mode 100644
index 000000000..c98958319
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml
@@ -0,0 +1,85 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+DesktopWebView {
+ id: webView
+ width: 200
+ height: 400
+ focus: true
+
+ property string lastUrl
+ property string lastTitle
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "linkHovered"
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ onLinkHovered: {
+ webView.lastUrl = url
+ webView.lastTitle = title
+ }
+
+ TestCase {
+ name: "DesktopWebViewLinkHovered"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ webView.lastUrl = ""
+ webView.lastTitle = ""
+ spy.clear()
+ }
+
+ function test_linkHovered() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/test2.html"))
+ loadSpy.wait()
+ mouseMove(webView, 100, 100)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html"))
+ compare(webView.lastTitle, "A title")
+ mouseMove(webView, 100, 300)
+ spy.wait()
+ compare(spy.count, 2)
+ compare(webView.lastUrl, "")
+ compare(webView.lastTitle, "")
+ }
+
+ function test_linkHoveredDoesntEmitRepeated() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/test2.html"))
+ loadSpy.wait()
+
+ for (var i = 0; i < 100; i += 10)
+ mouseMove(webView, 100, 100 + i)
+
+ spy.wait()
+ compare(spy.count, 1)
+ compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html"))
+
+ for (var i = 0; i < 100; i += 10)
+ mouseMove(webView, 100, 300 + i)
+
+ spy.wait()
+ compare(spy.count, 2)
+ compare(webView.lastUrl, "")
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml
new file mode 100644
index 000000000..b45b01ac8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml
@@ -0,0 +1,60 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+DesktopWebView {
+ id: webView
+ width: 200
+ height: 400
+ focus: true
+
+ property string lastUrl
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: linkHoveredSpy
+ target: webView
+ signalName: "linkHovered"
+ }
+
+ onLinkHovered: {
+ webView.lastUrl = url
+ }
+
+ TestCase {
+ name: "DesktopWebViewLoadHtml"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ webView.lastUrl = ""
+ linkHoveredSpy.clear()
+ loadSpy.clear()
+ }
+
+ function test_baseUrlAfterLoadHtml() {
+ loadSpy.clear()
+ linkHoveredSpy.clear()
+ compare(linkHoveredSpy.count, 0)
+ webView.loadHtml("<html><head><title>Test page with huge link area</title></head><body><a title=\"A title\" href=\"test1.html\"><img width=200 height=200></a></body></html>", "http://www.example.foo.com")
+ loadSpy.wait()
+ compare("http://www.example.foo.com/", webView.url)
+ mouseMove(webView, 100, 100)
+ linkHoveredSpy.wait()
+ compare(linkHoveredSpy.count, 1)
+ compare(webView.lastUrl, "http://www.example.foo.com/test1.html")
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml
new file mode 100644
index 000000000..7fcc91a64
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml
@@ -0,0 +1,108 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+Item {
+ DesktopWebView {
+ id: webView
+ property variant lastMessage
+ experimental.preferences.navigatorQtObjectEnabled: true
+ experimental.onMessageReceived: {
+ lastMessage = message
+ }
+ }
+
+ DesktopWebView {
+ id: otherWebView
+ property variant lastMessage
+ experimental.preferences.navigatorQtObjectEnabled: true
+ experimental.onMessageReceived: {
+ lastMessage = message
+ }
+ }
+
+ DesktopWebView {
+ id: disabledWebView
+ property bool receivedMessage
+ experimental.preferences.navigatorQtObjectEnabled: false
+ experimental.onMessageReceived: {
+ receivedMessage = true
+ }
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: messageSpy
+ target: webView.experimental
+ signalName: "messageReceived"
+ }
+
+ SignalSpy {
+ id: otherLoadSpy
+ target: otherWebView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: otherMessageSpy
+ target: otherWebView.experimental
+ signalName: "messageReceived"
+ }
+
+ SignalSpy {
+ id: disabledWebViewLoadSpy
+ target: disabledWebView
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ name: "DesktopWebViewMessaging"
+ property url testUrl: Qt.resolvedUrl("../common/messaging.html")
+
+ function init() {
+ loadSpy.clear()
+ messageSpy.clear()
+ webView.lastMessage = null
+ otherLoadSpy.clear()
+ otherMessageSpy.clear()
+ otherWebView.lastMessage = null
+ }
+
+ function test_basic() {
+ webView.load(testUrl)
+ loadSpy.wait()
+ webView.experimental.postMessage("HELLO")
+ messageSpy.wait()
+ compare(webView.lastMessage.data, "OLLEH")
+ compare(webView.lastMessage.origin.toString(), testUrl.toString())
+ }
+
+ function test_twoWebViews() {
+ webView.load(testUrl)
+ otherWebView.load(testUrl)
+ loadSpy.wait()
+ otherLoadSpy.wait()
+ webView.experimental.postMessage("FIRST")
+ otherWebView.experimental.postMessage("SECOND")
+ messageSpy.wait()
+ otherMessageSpy.wait()
+ compare(webView.lastMessage.data, "TSRIF")
+ compare(otherWebView.lastMessage.data, "DNOCES")
+ }
+
+ function test_disabled() {
+ disabledWebView.load(testUrl)
+ verify(!disabledWebView.experimental.preferences.navigatorQtObjectEnabled)
+ disabledWebViewLoadSpy.wait()
+ disabledWebView.experimental.postMessage("HI")
+ wait(1000)
+ verify(!disabledWebView.receivedMessage)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml
new file mode 100644
index 000000000..3ef7d5516
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml
@@ -0,0 +1,151 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+Item {
+ property int expectedLength: 0
+ property int totalBytes: 0
+ property bool shouldDownload: false
+ property string originatingUrl: ""
+ property url beginUrl: Qt.resolvedUrl("../common/test2.html")
+ property url endUrl: Qt.resolvedUrl("../common/test1.html")
+
+ DesktopWebView {
+ id: webView
+ width: 200
+ height: 200
+
+ signal downloadFinished()
+
+ onNavigationRequested: {
+ if (shouldDownload)
+ request.action = WebViewExperimental.DownloadRequest
+ else if (request.button == Qt.MiddleButton && request.modifiers & Qt.ControlModifier) {
+ otherWebView.load(request.url)
+ request.action = WebView.IgnoreRequest
+ }
+ originatingUrl = request.originatingUrl
+ }
+
+ experimental.onDownloadRequested: {
+ download.target = downloadItem
+ expectedLength = downloadItem.expectedContentLength
+ downloadItem.destinationPath = downloadItem.suggestedFilename
+ downloadItem.start()
+ }
+
+ Connections {
+ id: download
+ ignoreUnknownSignals: true
+ onSucceeded: {
+ totalBytes = download.target.totalBytesReceived
+ webView.downloadFinished()
+ }
+ }
+ }
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ DesktopWebView {
+ id: otherWebView
+ }
+
+ SignalSpy {
+ id: otherSpy
+ target: otherWebView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: downloadSpy
+ target: webView.experimental
+ signalName: "downloadRequested"
+ }
+
+ SignalSpy {
+ id: downloadFinishedSpy
+ target: webView
+ signalName: "downloadFinished"
+ }
+
+ TestCase {
+ name: "DesktopWebViewNavigationRequested"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ spy.clear()
+ otherSpy.clear()
+ downloadSpy.clear()
+ downloadFinishedSpy.clear()
+ shouldDownload = false
+ originatingUrl = ""
+ }
+
+ function test_usePolicy() {
+ webView.load(beginUrl)
+ spy.wait()
+ spy.clear()
+ mouseClick(webView, 100, 100, Qt.LeftButton)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(webView.title, "Test page 1")
+ compare(webView.url, endUrl)
+ }
+
+ function test_ignorePolicy() {
+ webView.load(beginUrl)
+ spy.wait()
+ spy.clear()
+ compare(spy.count, 0)
+ compare(otherSpy.count, 0)
+ mouseClick(webView, 100, 100, Qt.MiddleButton, Qt.ControlModifier)
+ otherSpy.wait()
+ compare(spy.count, 0)
+ compare(otherSpy.count, 1)
+ compare(webView.url, beginUrl)
+ compare(otherWebView.title, "Test page 1")
+ compare(otherWebView.url, endUrl)
+ }
+
+ function test_downloadPolicy() {
+ webView.load(beginUrl)
+ spy.wait()
+ spy.clear()
+ compare(spy.count, 0)
+ downloadSpy.clear()
+ downloadFinishedSpy.clear()
+ expectedLength = 0
+ shouldDownload = true
+ mouseClick(webView, 100, 100, Qt.LeftButton)
+ downloadSpy.wait()
+ compare(downloadSpy.count, 1)
+ downloadFinishedSpy.wait()
+ compare(downloadFinishedSpy.count, 1)
+ compare(totalBytes, expectedLength)
+ }
+
+ function test_originatingUrl() {
+ webView.load(beginUrl)
+ spy.wait()
+ spy.clear()
+ mouseClick(webView, 100, 100, Qt.LeftButton)
+ spy.wait()
+ compare(webView.title, "Test page 1")
+ compare(webView.url, endUrl)
+ compare(originatingUrl, beginUrl)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
new file mode 100644
index 000000000..29774e117
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml
@@ -0,0 +1,41 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ experimental {
+ urlSchemeDelegates: [
+ UrlSchemeDelegate {
+ scheme: "applicationScheme"
+ onReceivedRequest: {
+ reply.data = "<html><head><title>Test Application Scheme</title></head><body>A test page.</body></html>"
+ reply.send()
+ }
+ }
+ ]
+ }
+
+ SignalSpy {
+ id: spyTitle
+ target: webView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ name: "WebViewApplicationSchemes"
+
+ function test_applicationScheme() {
+ compare(spyTitle.count, 0)
+ var testUrl = "applicationScheme://something"
+ webView.load(testUrl)
+ spyTitle.wait()
+ compare(webView.title, "Test Application Scheme")
+ }
+ }
+
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml
new file mode 100644
index 000000000..6c25af3bc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml
@@ -0,0 +1,86 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+ width: 200
+ height: 200
+
+ property int expectedLength: 0
+ property int totalBytes: 0
+
+ signal downloadFinished()
+
+ SignalSpy {
+ id: spy
+ target: experimental
+ signalName: "downloadRequested"
+ }
+
+ SignalSpy {
+ id: downloadFinishedSpy
+ target: webView
+ signalName: "downloadFinished"
+ }
+
+ experimental.onDownloadRequested: {
+ download.target = downloadItem
+ expectedLength = downloadItem.expectedContentLength
+ downloadItem.destinationPath = downloadItem.suggestedFilename
+ downloadItem.start()
+ }
+
+ Connections {
+ id: download
+ ignoreUnknownSignals: true
+ onSucceeded: {
+ totalBytes = download.target.totalBytesReceived
+ webView.downloadFinished()
+ }
+ }
+
+ TestCase {
+ name: "WebViewDownload"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ spy.clear()
+ downloadFinishedSpy.clear()
+ expectedLength = 0
+ }
+
+ function test_downloadRequest() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/download.zip"))
+ spy.wait()
+ compare(spy.count, 1)
+ }
+
+ function test_expectedLength() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/download.zip"))
+ spy.wait()
+ compare(spy.count, 1)
+ compare(expectedLength, 325)
+ }
+
+ function test_succeeded() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/download.zip"))
+ spy.wait()
+ compare(spy.count, 1)
+ downloadFinishedSpy.wait()
+ compare(totalBytes, expectedLength)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml
new file mode 100644
index 000000000..121809316
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml
@@ -0,0 +1,60 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "iconChanged"
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ Image {
+ id: favicon
+ source: webView.icon
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewLoadFavIcon"
+
+ function init() {
+ if (webView.icon != '') {
+ // If this is not the first test, then load a blank page without favicon, restoring the initial state.
+ webView.load('about:blank')
+ spy.wait()
+ loadSpy.wait()
+ }
+ loadSpy.clear()
+ spy.clear()
+ }
+
+ function test_favIconLoad() {
+ compare(spy.count, 0)
+ var url = Qt.resolvedUrl("../common/favicon.html")
+ webView.load(url)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(favicon.width, 48)
+ compare(favicon.height, 48)
+ }
+
+ function test_favIconLoadEncodedUrl() {
+ compare(spy.count, 0)
+ var url = Qt.resolvedUrl("../common/favicon2.html?favicon=load should work with#whitespace!")
+ webView.load(url)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(favicon.width, 16)
+ compare(favicon.height, 16)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml
new file mode 100644
index 000000000..697ab085a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml
@@ -0,0 +1,54 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+ width: 200
+ height: 200
+
+ property bool expectedPermission: false
+
+ SignalSpy {
+ id: spy
+ target: experimental
+ signalName: "permissionRequested"
+ }
+
+ experimental.onPermissionRequested: {
+ //Must be false by default
+ if (!permission.allow) {
+ permission.allow = true
+ } else
+ console.log("Fail: permission must be set to false")
+
+ if (permission.type == PermissionRequest.Geolocation) {
+ console.log("Permission is geotype")
+ }
+ }
+
+ TestCase {
+ name: "WebViewGeopermission"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ spy.clear()
+ }
+
+ function test_permissionRequest() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/geolocation.html"))
+ spy.wait()
+ compare(spy.count, 1)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml
new file mode 100644
index 000000000..03d68be5b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml
@@ -0,0 +1,119 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+// FIXME: used because we want to have mouseClick() to open the <select> tag. We can remove this
+// when TestCase starts supporting touch events, see https://bugreports.qt.nokia.com/browse/QTBUG-23083.
+import "../DesktopBehavior"
+
+DesktopWebView {
+ id: webView
+
+ width: 400
+ height: 400
+
+ property int initialSelection
+ property int finalSelection
+ property bool useAcceptDirectly
+ property bool selectorLoaded
+
+ experimental.itemSelector: Item {
+ Component.onCompleted: {
+ if (WebView.view.initialSelection != -1)
+ model.items.select(WebView.view.initialSelection)
+
+ if (WebView.view.finalSelection == -1)
+ model.reject()
+ else {
+ if (useAcceptDirectly) {
+ model.accept(WebView.view.finalSelection)
+ } else {
+ model.items.select(WebView.view.finalSelection)
+ model.accept()
+ }
+ }
+
+ WebView.view.selectorLoaded = true
+ }
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: titleSpy
+ target: webView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewItemSelector"
+ when: windowShown
+
+ function init() {
+ webView.initialSelection = -1
+ webView.finalSelection = -1
+ webView.useAcceptDirectly = false
+ webView.selectorLoaded = false
+ loadSpy.clear()
+ webView.load(Qt.resolvedUrl("../common/select.html"))
+ loadSpy.wait()
+ titleSpy.clear()
+ }
+
+ function openItemSelector() {
+ mouseClick(webView, 15, 15, Qt.LeftButton)
+ }
+
+ function test_accept() {
+ webView.finalSelection = 1
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "__closed__")
+ }
+
+ function test_acceptDirectly() {
+ webView.finalSelection = 1
+ webView.useAcceptDirectly = true
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "__closed__")
+ }
+
+ function test_selectFirstThenAccept() {
+ webView.initialSelection = 1
+ webView.finalSelection = 2
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "__all__")
+ }
+
+ function test_selectFirstThenAcceptDirectly() {
+ webView.initialSelection = 1
+ webView.finalSelection = 2
+ webView.useAcceptDirectly = true
+ openItemSelector()
+ titleSpy.wait()
+ compare(webView.title, "__all__")
+ }
+
+ function test_reject() {
+ openItemSelector()
+ tryCompare(webView, "selectorLoaded", true)
+ compare(webView.title, "No new selection was made")
+ }
+
+ function test_selectFirstThenReject() {
+ webView.initialSelection = 1
+ webView.finalSelection = -1
+ openItemSelector()
+ tryCompare(webView, "selectorLoaded", true)
+ compare(webView.title, "No new selection was made")
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml
new file mode 100644
index 000000000..56c34abcd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml
@@ -0,0 +1,125 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+
+ property bool modelMessageEqualsMessage: false
+ property string messageFromAlertDialog: ""
+ property int confirmCount: 0
+ property int promptCount: 0
+
+ experimental.alertDialog: Item {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ // Testing both attached property and id defined in the Component context.
+ parent.WebView.view.messageFromAlertDialog = message
+ webView.modelMessageEqualsMessage = Boolean(model.message == message)
+ model.dismiss()
+ }
+ }
+ }
+
+ experimental.confirmDialog: Item {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ parent.WebView.view.confirmCount += 1
+ if (message == "ACCEPT")
+ model.accept()
+ else
+ model.reject()
+ }
+ }
+ }
+
+ experimental.promptDialog: Item {
+ Timer {
+ running: true
+ interval: 1
+ onTriggered: {
+ parent.WebView.view.promptCount += 1
+ if (message == "REJECT")
+ model.reject()
+ else {
+ var reversedDefaultValue = defaultValue.split("").reverse().join("")
+ model.accept(reversedDefaultValue)
+ }
+ }
+ }
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewJavaScriptDialogs"
+
+ function init() {
+ webView.modelMessageEqualsMessage = false
+ webView.messageFromAlertDialog = ""
+ webView.confirmCount = 0
+ webView.promptCount = 0
+ loadSpy.clear()
+ }
+
+ function test_alert() {
+ webView.load(Qt.resolvedUrl("../common/alert.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.messageFromAlertDialog, "Hello Qt")
+ verify(webView.modelMessageEqualsMessage)
+ }
+
+ function test_alertWithoutDialog() {
+ webView.experimental.alertDialog = null
+ webView.load(Qt.resolvedUrl("../common/alert.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.messageFromAlertDialog, "")
+ }
+
+ function test_confirm() {
+ webView.load(Qt.resolvedUrl("../common/confirm.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.confirmCount, 2)
+ compare(webView.title, "ACCEPTED REJECTED")
+ }
+
+ function test_confirmWithoutDialog() {
+ webView.experimental.confirmDialog = null
+ webView.load(Qt.resolvedUrl("../common/confirm.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.confirmCount, 0)
+ compare(webView.title, "ACCEPTED ACCEPTED")
+ }
+
+ function test_prompt() {
+ webView.load(Qt.resolvedUrl("../common/prompt.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.promptCount, 2)
+ compare(webView.title, "tQ olleH")
+ }
+
+ function test_promptWithoutDialog() {
+ webView.experimental.promptDialog = null
+ webView.load(Qt.resolvedUrl("../common/prompt.html"))
+ loadSpy.wait()
+ compare(loadSpy.count, 1)
+ compare(webView.promptCount, 0)
+ compare(webView.title, "FAIL")
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml
new file mode 100644
index 000000000..26a42c0b7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadFail.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ property variant testUrl
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadFailed"
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewLoadFail"
+ function test_fail() {
+ compare(spy.count, 0)
+ testUrl = Qt.resolvedUrl("file_that_does_not_exist.html")
+ webView.load(testUrl)
+ spy.wait()
+ compare(spy.count, 1)
+ }
+ }
+
+ onLoadFailed: {
+ test.compare(url, testUrl)
+ test.compare(errorCode, NetworkReply.ContentNotFoundError)
+ test.compare(errorDomain, WebView.NetworkErrorDomain)
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml
new file mode 100644
index 000000000..b57df66a6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadHtml.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 200
+ height: 400
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ name: "WebViewLoadHtml"
+
+ function test_loadProgressAfterLoadHtml() {
+ loadSpy.clear()
+ compare(loadSpy.count, 0)
+ compare(webView.loadProgress, 0)
+ webView.loadHtml("<html><head><title>Test page 1</title></head><body>Hello.</body></html>")
+ loadSpy.wait()
+ compare(webView.loadProgress, 100)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml
new file mode 100644
index 000000000..a51d6f69f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgress.qml
@@ -0,0 +1,28 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ name: "WebViewLoadProgress"
+
+ function test_loadProgress() {
+ compare(spy.count, 0)
+ compare(webView.loadProgress, 0)
+ webView.load(Qt.resolvedUrl("../common/test1.html"))
+ compare(webView.loadProgress, 0)
+ spy.wait()
+ compare(webView.loadProgress, 100)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml
new file mode 100644
index 000000000..10ac879a8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_loadProgressSignal.qml
@@ -0,0 +1,38 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: spyProgress
+ target: webView
+ signalName: "loadProgressChanged"
+ }
+
+ TestCase {
+ name: "WebViewLoadProgressSignal"
+
+ function test_loadProgressSignal() {
+ compare(spyProgress.count, 0)
+ compare(webView.loadProgress, 0)
+ webView.load(Qt.resolvedUrl("../common/test1.html"))
+ spyProgress.wait()
+ compare(true, webView.loadProgress > -1 && webView.loadProgress < 101)
+ if (webView.loadProgress > 0 && webView.loadProgress < 100) {
+ spy.wait()
+ spyProgress.wait()
+ compare(webView.loadProgress, 100)
+ }
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml
new file mode 100644
index 000000000..68aeeb556
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml
@@ -0,0 +1,108 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ ListView {
+ id: backItemsList
+ anchors.fill: parent
+ model: webView.experimental.navigationHistory.backItems
+ delegate:
+ Text {
+ color:"black"
+ text: "title : " + title
+ }
+ }
+
+ ListView {
+ id: forwardItemsList
+ anchors.fill: parent
+ model: webView.experimental.navigationHistory.forwardItems
+ delegate:
+ Text {
+ color:"black"
+ text: "title : " + title
+ }
+ }
+
+ TestCase {
+ name: "WebViewNavigationHistory"
+
+ function test_navigationHistory() {
+ compare(spy.count, 0)
+ compare(webView.loadProgress, 0)
+ webView.load(Qt.resolvedUrl("../common/test1.html"))
+ spy.wait()
+ compare(webView.canGoBack, false)
+ compare(webView.canGoForward, false)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 0)
+ spy.clear()
+ webView.load(Qt.resolvedUrl("../common/test2.html"))
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/test2.html"))
+ compare(webView.canGoBack, true)
+ compare(webView.canGoForward, false)
+ compare(backItemsList.count, 1)
+ spy.clear()
+ webView.experimental.goBackTo(0)
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/test1.html"))
+ compare(webView.canGoBack, false)
+ compare(webView.canGoForward, true)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 1)
+ spy.clear()
+ webView.goForward()
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/test2.html"))
+ compare(webView.canGoBack, true)
+ compare(webView.canGoForward, false)
+ compare(backItemsList.count, 1)
+ compare(forwardItemsList.count, 0)
+ spy.clear()
+ webView.load(Qt.resolvedUrl("../common/javascript.html"))
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/javascript.html"))
+ compare(webView.canGoBack, true)
+ compare(webView.canGoForward, false)
+ compare(backItemsList.count, 2)
+ compare(forwardItemsList.count, 0)
+ spy.clear()
+ webView.experimental.goBackTo(1)
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/test1.html"))
+ compare(webView.canGoBack, false)
+ compare(webView.canGoForward, true)
+ compare(backItemsList.count, 0)
+ compare(forwardItemsList.count, 2)
+ spy.clear()
+ webView.experimental.goForwardTo(1)
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/javascript.html"))
+ compare(webView.canGoBack, true)
+ compare(webView.canGoForward, false)
+ compare(backItemsList.count, 2)
+ compare(forwardItemsList.count, 0)
+ spy.clear()
+ webView.goBack()
+ spy.wait()
+ compare(webView.url, Qt.resolvedUrl("../common/test2.html"))
+ compare(webView.canGoBack, true)
+ compare(webView.canGoForward, true)
+ compare(backItemsList.count, 1)
+ compare(forwardItemsList.count, 1)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml
new file mode 100644
index 000000000..0554abb2d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml
@@ -0,0 +1,101 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 3.0
+
+Item {
+ WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ experimental.preferences.javascriptEnabled: true
+ experimental.preferences.localStorageEnabled: true
+ experimental.preferences.pluginsEnabled: true
+
+ WebView {
+ id: webView2
+ width: 400
+ height: 300
+ }
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: otherSpy
+ target: webView2
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ name: "WebViewPreferences"
+
+ function init() {
+ webView.experimental.preferences.javascriptEnabled = true
+ webView.experimental.preferences.localStorageEnabled = true
+ webView.experimental.preferences.pluginsEnabled = true
+ spy.clear()
+ }
+
+ function test_javascriptEnabled() {
+ webView.experimental.preferences.javascriptEnabled = true
+ var testUrl = Qt.resolvedUrl("../common/javascript.html")
+ webView.load(testUrl)
+ spy.wait()
+ compare(webView.title, "New Title")
+ }
+
+ function test_javascriptDisabled() {
+ webView.experimental.preferences.javascriptEnabled = false
+ var testUrl = Qt.resolvedUrl("../common/javascript.html")
+ webView.load(testUrl)
+ spy.wait()
+ compare(webView.title, "Original Title")
+ }
+
+ function test_localStorageDisabled() {
+ webView.experimental.preferences.localStorageEnabled = false
+ var testUrl = Qt.resolvedUrl("../common/localStorage.html")
+ webView.load(testUrl)
+ spy.wait()
+ compare(webView.title, "Original Title")
+ }
+
+ function test_localStorageEnabled() {
+ webView.experimental.preferences.localStorageEnabled = true
+ var testUrl = Qt.resolvedUrl("../common/localStorage.html")
+ webView.load(testUrl)
+ spy.wait()
+ spy.clear()
+ webView.load(testUrl)
+ spy.wait()
+ compare(webView.title, "New Title")
+ }
+
+ function test_preferencesAffectCurrentViewOnly() {
+ webView.experimental.preferences.javascriptEnabled = true
+ webView2.experimental.preferences.javascriptEnabled = true
+ var testUrl = Qt.resolvedUrl("../common/javascript.html")
+ webView.load(testUrl)
+ spy.wait()
+ webView2.load(testUrl)
+ otherSpy.wait()
+ compare(webView.title, "New Title")
+ compare(webView2.title, "New Title")
+ spy.clear()
+ otherSpy.clear()
+ webView.experimental.preferences.javascriptEnabled = false
+ webView.load(testUrl)
+ spy.wait()
+ webView2.load(testUrl)
+ otherSpy.wait()
+ compare(webView.title, "Original Title")
+ compare(webView2.title, "New Title")
+ }
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml
new file mode 100644
index 000000000..4761cd322
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_properties.qml
@@ -0,0 +1,34 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ TestCase {
+ name: "WebViewProperties"
+
+ function test_title() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/test1.html"))
+ spy.wait()
+ compare(webView.title, "Test page 1")
+ }
+
+ function test_url() {
+ compare(spy.count, 1)
+ var testUrl = Qt.resolvedUrl("../common/test1.html")
+ webView.load(testUrl)
+ spy.wait()
+ compare(webView.url, testUrl)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml
new file mode 100644
index 000000000..f36ea8579
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_titleChanged.qml
@@ -0,0 +1,35 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+ width: 400
+ height: 300
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ SignalSpy {
+ id: spyTitle
+ target: webView
+ signalName: "titleChanged"
+ }
+
+ TestCase {
+ name: "WebViewTitleChangedSignal"
+
+ function test_titleFirstLoad() {
+ compare(spyTitle.count, 0)
+ var testUrl = Qt.resolvedUrl("../common/test3.html")
+ webView.load(testUrl)
+ spyTitle.wait()
+ compare(webView.title, "Test page 3")
+ spyTitle.wait()
+ compare(webView.title, "New Title")
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html
new file mode 100644
index 000000000..a75b9a60f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/alert.html
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<head>
+<script>alert("Hello Qt");</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html
new file mode 100644
index 000000000..5dd6081d4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/confirm.html
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+<head>
+<script>
+document.title = "";
+function updateTitle(accepted) {
+ if (accepted)
+ document.title += " ACCEPTED";
+ else
+ document.title += " REJECTED";
+}
+
+updateTitle(confirm("ACCEPT"));
+updateTitle(confirm("REJECT"));
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip
new file mode 100644
index 000000000..b5456351a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/download.zip
Binary files differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html
new file mode 100644
index 000000000..c9f225c52
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+</head>
+<link type="image/png" href="favicon.png" sizes="48x48" rel="icon" />
+<body>
+<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
+<p>The favicon looks like this:</p>
+<img src="favicon.png"/>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png
new file mode 100644
index 000000000..35717cca5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png
Binary files differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html
new file mode 100644
index 000000000..5548b867f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon2.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+</head>
+<link type="image/png" href="small-favicon.png" sizes="16x16" rel="icon" />
+<body>
+<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
+<p>The favicon looks like this:</p>
+<img src="small-favicon.png"/>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html
new file mode 100644
index 000000000..2d41cab3e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/geolocation.html
@@ -0,0 +1,29 @@
+<head>
+<title>Geolocation Permission API Test</title>
+<meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/>
+<script>
+var watchId = 0;
+
+function successHandler(location) {
+ var message = document.getElementById("message"), html = [];
+ html.push("<img width='256' height='256' src='http://maps.google.com/maps/api/staticmap?center=", location.coords.latitude, ",", location.coords.longitude, "&markers=size:small|color:blue|", location.coords.latitude, ",", location.coords.longitude, "&zoom=14&size=256x256&sensor=false' />");
+ html.push("<p>Longitude: ", location.coords.longitude, "</p>");
+ html.push("<p>Latitude: ", location.coords.latitude, "</p>");
+ html.push("<p>Accuracy: ", location.coords.accuracy, " meters</p>");
+ message.innerHTML = html.join("");
+}
+
+function errorHandler(error) {
+ alert('Attempt to get location failed: ' + error.message);
+}
+
+<!-- One shot example -->
+navigator.geolocation.getCurrentPosition(successHandler, errorHandler);
+
+</script>
+</head>
+<body>
+<div id="message">Location unknown</div>
+</body>
+</html>
+
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html
new file mode 100644
index 000000000..7a3dc0a1c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/javascript.html
@@ -0,0 +1,8 @@
+<html>
+<head><title>Original Title</title></head>
+<body>
+<script type="text/javascript">
+document.title = "New Title";
+</script>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html
new file mode 100644
index 000000000..a4e395f48
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/localStorage.html
@@ -0,0 +1,9 @@
+<html>
+<head><title>Original Title</title></head>
+<body>
+<script type="text/javascript">
+document.title = localStorage.getItem('title');
+localStorage.setItem('title', 'New Title');
+</script>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html
new file mode 100644
index 000000000..7e3dd7230
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/messaging.html
@@ -0,0 +1,15 @@
+<!doctype html>
+<html>
+<head>
+<script>
+ function initialize() {
+ navigator.qt.onmessage = function(ev) {
+ var reversed = ev.data.split("").reverse().join("");
+ navigator.qt.postMessage(reversed);
+ }
+ }
+</script>
+</head>
+<body onload="initialize();">
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html
new file mode 100644
index 000000000..f35e30204
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/prompt.html
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+<head>
+<script>
+document.title = prompt("Please, reverse the default value", "Hello Qt");
+if (prompt("REJECT") !== null) {
+ document.title = "FAIL";
+}
+</script>
+</head>
+<body>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html
new file mode 100644
index 000000000..46080f6e4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/select.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>No new selection was made</title>
+<script>
+function updateTitle(selectElement) {
+ var index = selectElement.selectedIndex;
+ document.title = selectElement.options[index].value;
+}
+</script>
+</head>
+<body>
+<select onchange="updateTitle(this)">
+<option value="__open__" >Open</option>
+<option value="__closed__" >Closed</option>
+<option value="__all__" >All</option>
+</select>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png
new file mode 100644
index 000000000..4462752a5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/small-favicon.png
Binary files differ
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html
new file mode 100644
index 000000000..5c09f06ed
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test1.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page 1</title></head>
+<body>
+Hello.
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html
new file mode 100644
index 000000000..629c2a063
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test2.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Test page with huge link area</title></head>
+<body>
+<a title="A title" href="test1.html"><img width=200 height=200></a>
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html
new file mode 100644
index 000000000..0c0e4eebf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/test3.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>Test page 3</title>
+</head>
+<script type="text/javascript">
+function kickOffTitleChange()
+{
+ var t = setTimeout("changeTitle('New Title')",3000);
+}
+function changeTitle(title)
+{
+ document.title = title;
+}
+</script>
+<body onload="kickOffTitleChange()">
+Hello.
+</body>
+</html>
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro
new file mode 100644
index 000000000..7e449a224
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro
@@ -0,0 +1,31 @@
+include(../tests.pri)
+
+CONFIG += qtwebkit-private
+CONFIG += warn_on testcase
+
+QT -= testlib
+QT += qmltest
+
+# QML files tested are the ones in WebKit source repository.
+DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\"
+DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\"
+
+OTHER_FILES += \
+ DesktopBehavior/DesktopWebView.qml \
+ DesktopBehavior/tst_linkHovered.qml \
+ DesktopBehavior/tst_loadHtml.qml \
+ DesktopBehavior/tst_messaging.qml \
+ DesktopBehavior/tst_navigationRequested.qml \
+ WebView/tst_favIconLoad.qml \
+ WebView/tst_download.qml \
+ WebView/tst_geopermission.qml \
+ WebView/tst_itemSelector.qml \
+ WebView/tst_javaScriptDialogs.qml \
+ WebView/tst_loadFail.qml \
+ WebView/tst_loadHtml.qml \
+ WebView/tst_loadProgress.qml \
+ WebView/tst_loadProgressSignal.qml \
+ WebView/tst_preferences.qml \
+ WebView/tst_properties.qml \
+ WebView/tst_titleChanged.qml \
+ WebView/tst_applicationScheme.qml
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
new file mode 100644
index 000000000..e8d9aab0e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
@@ -0,0 +1,45 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "../util.h"
+
+#include <QVarLengthArray>
+#include <QtQuickTest/quicktest.h>
+#include <QtWidgets/QApplication>
+
+int main(int argc, char** argv)
+{
+ QVarLengthArray<char*, 8> arguments;
+ for (int i = 0; i < argc; ++i)
+ arguments.append(argv[i]);
+
+ arguments.append(const_cast<char*>("-import"));
+ arguments.append(const_cast<char*>(IMPORT_DIR));
+
+ argc = arguments.count();
+ argv = arguments.data();
+
+ suppressDebugOutput();
+ addQtWebProcessToPath();
+
+ // Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication.
+ // This can be removed as soon as we do not use QtWidgets any more.
+ QApplication app(argc, argv);
+ return quick_test_main(argc, argv, "qmltests", 0, QUICK_TEST_SOURCE_DIR);
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro
new file mode 100644
index 000000000..728521f8a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro
@@ -0,0 +1,2 @@
+include(../tests.pri)
+CONFIG += qtwebkit-private
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
new file mode 100644
index 000000000..57b7ec14a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
@@ -0,0 +1,290 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "../testwindow.h"
+#include "../util.h"
+
+#include <QScopedPointer>
+#include <QtTest/QtTest>
+#include <qquickwebpage_p.h>
+#include <qquickwebview_p.h>
+
+class tst_QQuickWebView : public QObject {
+ Q_OBJECT
+public:
+ tst_QQuickWebView();
+
+private slots:
+ void init();
+ void cleanup();
+
+ void accessPage();
+ void navigationStatusAtStartup();
+ void stopEnabledAfterLoadStarted();
+ void baseUrl();
+ void loadEmptyUrl();
+ void loadEmptyPageViewVisible();
+ void loadEmptyPageViewHidden();
+ void loadNonexistentFileUrl();
+ void backAndForward();
+ void reload();
+ void stop();
+ void loadProgress();
+ void scrollRequest();
+
+ void show();
+ void showWebView();
+ void removeFromCanvas();
+
+private:
+ inline QQuickWebView* webView() const;
+ QScopedPointer<TestWindow> m_window;
+};
+
+tst_QQuickWebView::tst_QQuickWebView()
+{
+ addQtWebProcessToPath();
+ qRegisterMetaType<QQuickWebPage*>("QQuickWebPage*");
+}
+
+void tst_QQuickWebView::init()
+{
+ m_window.reset(new TestWindow(new QQuickWebView()));
+}
+
+void tst_QQuickWebView::cleanup()
+{
+ m_window.reset();
+}
+
+inline QQuickWebView* tst_QQuickWebView::webView() const
+{
+ return static_cast<QQuickWebView*>(m_window->webView.data());
+}
+
+void tst_QQuickWebView::accessPage()
+{
+ QQuickWebPage* const pageDirectAccess = webView()->page();
+
+ QVariant pagePropertyValue = webView()->experimental()->property("page");
+ QQuickWebPage* const pagePropertyAccess = pagePropertyValue.value<QQuickWebPage*>();
+ QCOMPARE(pagePropertyAccess, pageDirectAccess);
+}
+
+void tst_QQuickWebView::navigationStatusAtStartup()
+{
+ QCOMPARE(webView()->canGoBack(), false);
+
+ QCOMPARE(webView()->canGoForward(), false);
+
+ QCOMPARE(webView()->loading(), false);
+
+ QCOMPARE(webView()->canReload(), false);
+}
+
+class LoadStartedCatcher : public QObject {
+ Q_OBJECT
+public:
+ LoadStartedCatcher(QQuickWebView* webView)
+ : m_webView(webView)
+ {
+ connect(m_webView, SIGNAL(loadStarted()), this, SLOT(onLoadStarted()));
+ }
+
+public slots:
+ void onLoadStarted()
+ {
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+
+ QCOMPARE(m_webView->loading(), true);
+ }
+
+signals:
+ void finished();
+
+private:
+ QQuickWebView* m_webView;
+};
+
+void tst_QQuickWebView::stopEnabledAfterLoadStarted()
+{
+ QCOMPARE(webView()->loading(), false);
+
+ LoadStartedCatcher catcher(webView());
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ waitForSignal(&catcher, SIGNAL(finished()));
+
+ QCOMPARE(webView()->loading(), true);
+
+ waitForSignal(webView(), SIGNAL(loadSucceeded()));
+}
+
+void tst_QQuickWebView::baseUrl()
+{
+ // Test the url is in a well defined state when instanciating the view, but before loading anything.
+ QVERIFY(webView()->url().isEmpty());
+}
+
+void tst_QQuickWebView::loadEmptyUrl()
+{
+ webView()->load(QUrl());
+ webView()->load(QUrl(QLatin1String("")));
+}
+
+void tst_QQuickWebView::loadEmptyPageViewVisible()
+{
+ m_window->show();
+ loadEmptyPageViewHidden();
+}
+
+void tst_QQuickWebView::loadEmptyPageViewHidden()
+{
+ QSignalSpy loadStartedSpy(webView(), SIGNAL(loadStarted()));
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(loadStartedSpy.size(), 1);
+}
+
+void tst_QQuickWebView::loadNonexistentFileUrl()
+{
+ QSignalSpy loadFailedSpy(webView(), SIGNAL(loadStarted()));
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/file_that_does_not_exist.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadFailed(QQuickWebView::ErrorDomain, int, QUrl, QString))));
+
+ QCOMPARE(loadFailedSpy.size(), 1);
+}
+
+void tst_QQuickWebView::backAndForward()
+{
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
+
+ webView()->goBack();
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+ webView()->goForward();
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page2.html"));
+}
+
+void tst_QQuickWebView::reload()
+{
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+ webView()->reload();
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+}
+
+void tst_QQuickWebView::stop()
+{
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QCOMPARE(webView()->url().path(), QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html"));
+
+ // FIXME: This test should be fleshed out. Right now it's just here to make sure we don't crash.
+ webView()->stop();
+}
+
+void tst_QQuickWebView::loadProgress()
+{
+ QCOMPARE(webView()->loadProgress(), 0);
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/basic_page.html")));
+ QSignalSpy loadProgressChangedSpy(webView(), SIGNAL(loadProgressChanged(int)));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ QVERIFY(loadProgressChangedSpy.count() >= 1);
+
+ QCOMPARE(webView()->loadProgress(), 100);
+}
+
+void tst_QQuickWebView::show()
+{
+ // This should not crash.
+ m_window->show();
+ QTest::qWait(200);
+ m_window->hide();
+}
+
+void tst_QQuickWebView::showWebView()
+{
+ webView()->setSize(QSizeF(300, 400));
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/direct-image-compositing.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ m_window->show();
+ // This should not crash.
+ webView()->setVisible(true);
+ QTest::qWait(200);
+ webView()->setVisible(false);
+ QTest::qWait(200);
+}
+
+void tst_QQuickWebView::removeFromCanvas()
+{
+ showWebView();
+
+ // This should not crash.
+ QQuickItem* parent = webView()->parentItem();
+ QQuickItem noCanvasItem;
+ webView()->setParentItem(&noCanvasItem);
+ QTest::qWait(200);
+ webView()->setParentItem(parent);
+ webView()->setVisible(true);
+ QTest::qWait(200);
+}
+
+void tst_QQuickWebView::scrollRequest()
+{
+ webView()->setSize(QSizeF(300, 400));
+
+ webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html")));
+ QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
+
+ // COMPARE with the position requested in the html
+ // Use qRound as that is also used when calculating the position
+ // in WebKit.
+ int y = -qRound(50 * webView()->page()->scale());
+ QVERIFY(webView()->page()->pos().y() == y);
+}
+
+QTWEBKIT_API_TEST_MAIN(tst_QQuickWebView)
+
+#include "tst_qquickwebview.moc"
+
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
new file mode 100644
index 000000000..297bcec92
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
@@ -0,0 +1,15 @@
+TEMPLATE = app
+
+VPATH += $$_PRO_FILE_PWD_
+TARGET = tst_$$TARGET
+
+SOURCES += $${TARGET}.cpp \
+ ../util.cpp
+INCLUDEPATH += $$PWD
+
+QT += testlib declarative widgets
+
+CONFIG += qtwebkit
+
+DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\" \
+ QWP_PATH=\\\"$${ROOT_BUILD_DIR}/bin\\\"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h
new file mode 100644
index 000000000..1eaa43772
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/testwindow.h
@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef testwindow_h
+#define testwindow_h
+
+#include <QResizeEvent>
+#include <QScopedPointer>
+#include <QtQuick/qquickitem.h>
+#include <QtQuick/qquickview.h>
+
+// TestWindow: Utility class to ignore QQuickView details.
+class TestWindow : public QQuickView {
+public:
+ inline TestWindow(QQuickItem* webView);
+ QScopedPointer<QQuickItem> webView;
+
+protected:
+ inline void resizeEvent(QResizeEvent*);
+};
+
+inline TestWindow::TestWindow(QQuickItem* webView)
+ : webView(webView)
+{
+ Q_ASSERT(webView);
+ webView->setParentItem(rootItem());
+}
+
+inline void TestWindow::resizeEvent(QResizeEvent* event)
+{
+ QQuickView::resizeEvent(event);
+ webView->setX(0);
+ webView->setY(0);
+ webView->setWidth(event->size().width());
+ webView->setHeight(event->size().height());
+}
+
+#endif /* testwindow_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.cpp b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp
new file mode 100644
index 000000000..e230221e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/util.cpp
@@ -0,0 +1,67 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "util.h"
+#include <stdio.h>
+
+void addQtWebProcessToPath()
+{
+ // Since tests won't find ./QtWebProcess, add it to PATH (at the end to prevent surprises).
+ // QWP_PATH should be defined by qmake.
+ qputenv("PATH", qgetenv("PATH") + ":" + QWP_PATH);
+}
+
+/**
+ * Starts an event loop that runs until the given signal is received.
+ * Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ * \p false on timeout
+ */
+bool waitForSignal(QObject* obj, const char* signal, int timeout)
+{
+ QEventLoop loop;
+ QObject::connect(obj, signal, &loop, SLOT(quit()));
+ QTimer timer;
+ QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+ if (timeout > 0) {
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ timer.setSingleShot(true);
+ timer.start(timeout);
+ }
+ loop.exec();
+ return timeoutSpy.isEmpty();
+}
+
+static void messageHandler(QtMsgType type, const char* message)
+{
+ if (type == QtCriticalMsg) {
+ fprintf(stderr, "%s\n", message);
+ return;
+ }
+ // Do nothing
+}
+
+void suppressDebugOutput()
+{
+ qInstallMsgHandler(messageHandler); \
+ if (qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT").isEmpty()) \
+ qputenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT", "1");
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h
new file mode 100644
index 000000000..007964fe5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+// Functions and macros that really need to be in QTestLib
+
+#include <QEventLoop>
+#include <QSignalSpy>
+#include <QTimer>
+
+#if !defined(TESTS_SOURCE_DIR)
+#define TESTS_SOURCE_DIR ""
+#endif
+
+void addQtWebProcessToPath();
+bool waitForSignal(QObject*, const char* signal, int timeout = 10000);
+void suppressDebugOutput();
+
+#define QTWEBKIT_API_TEST_MAIN(TestObject) \
+int main(int argc, char** argv) \
+{ \
+ suppressDebugOutput(); \
+ QApplication app(argc, argv); \
+ QTEST_DISABLE_KEYPAD_NAVIGATION \
+ TestObject tc; \
+ return QTest::qExec(&tc, argc, argv); \
+}