summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess
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
Imported WebKit commit 2ea9d364d0f6efa8fa64acf19f451504c59be0e4 (http://svn.webkit.org/repository/webkit/trunk@104285)
Diffstat (limited to 'Source/WebKit2/UIProcess')
-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
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp102
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h80
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp60
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h62
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebCredential.cpp58
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebCredential.h77
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp73
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h63
-rw-r--r--Source/WebKit2/UIProcess/BackingStore.cpp70
-rw-r--r--Source/WebKit2/UIProcess/BackingStore.h108
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp202
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.h97
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in35
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.cpp77
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.h143
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in43
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp395
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h124
-rw-r--r--Source/WebKit2/UIProcess/FindIndicator.cpp212
-rw-r--r--Source/WebKit2/UIProcess/FindIndicator.h64
-rw-r--r--Source/WebKit2/UIProcess/GenericCallback.h210
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp70
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.h56
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp62
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.h61
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp97
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h95
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp66
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h71
-rw-r--r--Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp151
-rw-r--r--Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp40
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.h66
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.mm204
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.cpp153
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.h68
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm234
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm74
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp196
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp77
-rw-r--r--Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp125
-rw-r--r--Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp71
-rw-r--r--Source/WebKit2/UIProcess/LayerTreeHostProxy.h141
-rw-r--r--Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in32
-rw-r--r--Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.cpp67
-rw-r--r--Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.h58
-rw-r--r--Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp70
-rw-r--r--Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.h59
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotification.cpp44
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotification.h79
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp151
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h90
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in28
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp84
-rw-r--r--Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h53
-rw-r--r--Source/WebKit2/UIProcess/PageClient.h197
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp226
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h91
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp108
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h74
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp264
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h164
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in37
-rw-r--r--Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp299
-rw-r--r--Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.h88
-rw-r--r--Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp43
-rw-r--r--Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm102
-rw-r--r--Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm245
-rw-r--r--Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp43
-rw-r--r--Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp107
-rw-r--r--Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp408
-rw-r--r--Source/WebKit2/UIProcess/ProcessModel.h39
-rw-r--r--Source/WebKit2/UIProcess/ResponsivenessTimer.cpp83
-rw-r--r--Source/WebKit2/UIProcess/ResponsivenessTimer.h64
-rw-r--r--Source/WebKit2/UIProcess/TextChecker.h79
-rw-r--r--Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp96
-rw-r--r--Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h113
-rw-r--r--Source/WebKit2/UIProcess/VisitedLinkProvider.cpp182
-rw-r--r--Source/WebKit2/UIProcess/VisitedLinkProvider.h66
-rw-r--r--Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp99
-rw-r--r--Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h85
-rw-r--r--Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.messages.in25
-rw-r--r--Source/WebKit2/UIProcess/WebBackForwardList.cpp245
-rw-r--r--Source/WebKit2/UIProcess/WebBackForwardList.h102
-rw-r--r--Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp138
-rw-r--r--Source/WebKit2/UIProcess/WebConnectionToWebProcess.h66
-rw-r--r--Source/WebKit2/UIProcess/WebContext.cpp902
-rw-r--r--Source/WebKit2/UIProcess/WebContext.h329
-rw-r--r--Source/WebKit2/UIProcess/WebContext.messages.in45
-rw-r--r--Source/WebKit2/UIProcess/WebContextConnectionClient.cpp41
-rw-r--r--Source/WebKit2/UIProcess/WebContextConnectionClient.h44
-rw-r--r--Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp54
-rw-r--r--Source/WebKit2/UIProcess/WebContextInjectedBundleClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebContextMenuProxy.cpp39
-rw-r--r--Source/WebKit2/UIProcess/WebContextMenuProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebContextUserMessageCoders.h141
-rw-r--r--Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp163
-rw-r--r--Source/WebKit2/UIProcess/WebCookieManagerProxy.h102
-rw-r--r--Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in28
-rw-r--r--Source/WebKit2/UIProcess/WebCookieManagerProxyClient.cpp41
-rw-r--r--Source/WebKit2/UIProcess/WebCookieManagerProxyClient.h44
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp233
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h102
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in28
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.cpp49
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebDownloadClient.cpp126
-rw-r--r--Source/WebKit2/UIProcess/WebDownloadClient.h61
-rw-r--r--Source/WebKit2/UIProcess/WebEditCommandProxy.cpp152
-rw-r--r--Source/WebKit2/UIProcess/WebEditCommandProxy.h69
-rw-r--r--Source/WebKit2/UIProcess/WebFindClient.cpp59
-rw-r--r--Source/WebKit2/UIProcess/WebFindClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebFormClient.cpp50
-rw-r--r--Source/WebKit2/UIProcess/WebFormClient.h49
-rw-r--r--Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.cpp41
-rw-r--r--Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebFrameListenerProxy.cpp57
-rw-r--r--Source/WebKit2/UIProcess/WebFrameListenerProxy.h57
-rw-r--r--Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.cpp53
-rw-r--r--Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebFrameProxy.cpp340
-rw-r--r--Source/WebKit2/UIProcess/WebFrameProxy.h164
-rw-r--r--Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp112
-rw-r--r--Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h112
-rw-r--r--Source/WebKit2/UIProcess/WebFullScreenManagerProxy.messages.in38
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp98
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h79
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.messages.in26
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationProvider.cpp50
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationProvider.h45
-rw-r--r--Source/WebKit2/UIProcess/WebGrammarDetail.cpp72
-rw-r--r--Source/WebKit2/UIProcess/WebGrammarDetail.h62
-rw-r--r--Source/WebKit2/UIProcess/WebHistoryClient.cpp78
-rw-r--r--Source/WebKit2/UIProcess/WebHistoryClient.h53
-rw-r--r--Source/WebKit2/UIProcess/WebIconDatabase.cpp278
-rw-r--r--Source/WebKit2/UIProcess/WebIconDatabase.h119
-rw-r--r--Source/WebKit2/UIProcess/WebIconDatabase.messages.in35
-rw-r--r--Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp50
-rw-r--r--Source/WebKit2/UIProcess/WebIconDatabaseClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.cpp272
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.h191
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.messages.in37
-rw-r--r--Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp98
-rw-r--r--Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h85
-rw-r--r--Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.messages.in25
-rw-r--r--Source/WebKit2/UIProcess/WebLoaderClient.cpp250
-rw-r--r--Source/WebKit2/UIProcess/WebLoaderClient.h88
-rw-r--r--Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp102
-rw-r--r--Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h83
-rw-r--r--Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.messages.in25
-rw-r--r--Source/WebKit2/UIProcess/WebNavigationData.cpp40
-rw-r--r--Source/WebKit2/UIProcess/WebNavigationData.h60
-rw-r--r--Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp81
-rw-r--r--Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h64
-rw-r--r--Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp85
-rw-r--r--Source/WebKit2/UIProcess/WebPageContextMenuClient.h48
-rw-r--r--Source/WebKit2/UIProcess/WebPageGroup.cpp131
-rw-r--r--Source/WebKit2/UIProcess/WebPageGroup.h72
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.cpp3546
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.h1007
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.messages.in279
-rw-r--r--Source/WebKit2/UIProcess/WebPolicyClient.cpp79
-rw-r--r--Source/WebKit2/UIProcess/WebPolicyClient.h58
-rw-r--r--Source/WebKit2/UIProcess/WebPopupMenuProxy.h81
-rw-r--r--Source/WebKit2/UIProcess/WebPreferences.cpp106
-rw-r--r--Source/WebKit2/UIProcess/WebPreferences.h98
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.cpp491
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.h227
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.messages.in46
-rw-r--r--Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp96
-rw-r--r--Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h83
-rw-r--r--Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.messages.in25
-rw-r--r--Source/WebKit2/UIProcess/WebResourceLoadClient.cpp91
-rw-r--r--Source/WebKit2/UIProcess/WebResourceLoadClient.h56
-rw-r--r--Source/WebKit2/UIProcess/WebTextChecker.cpp84
-rw-r--r--Source/WebKit2/UIProcess/WebTextChecker.h63
-rw-r--r--Source/WebKit2/UIProcess/WebTextCheckerClient.cpp175
-rw-r--r--Source/WebKit2/UIProcess/WebTextCheckerClient.h61
-rw-r--r--Source/WebKit2/UIProcess/WebUIClient.cpp414
-rw-r--r--Source/WebKit2/UIProcess/WebUIClient.h122
-rw-r--r--Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp78
-rw-r--r--Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp171
-rw-r--r--Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp229
-rw-r--r--Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp146
-rw-r--r--Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp127
-rw-r--r--Source/WebKit2/UIProcess/efl/WebContextEfl.cpp67
-rw-r--r--Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp97
-rw-r--r--Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp79
-rw-r--r--Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp58
-rw-r--r--Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp140
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp66
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp126
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h63
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebFullScreenManagerProxyGtk.cpp86
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp155
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp62
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp138
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h62
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp59
-rw-r--r--Source/WebKit2/UIProcess/mac/BackingStoreMac.mm143
-rw-r--r--Source/WebKit2/UIProcess/mac/CorrectionPanel.h61
-rw-r--r--Source/WebKit2/UIProcess/mac/CorrectionPanel.mm149
-rw-r--r--Source/WebKit2/UIProcess/mac/TextCheckerMac.mm402
-rw-r--r--Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h62
-rw-r--r--Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm111
-rw-r--r--Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.h40
-rw-r--r--Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.mm86
-rw-r--r--Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h72
-rw-r--r--Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm644
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMac.mm151
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h64
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm234
-rw-r--r--Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm39
-rw-r--r--Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm112
-rw-r--r--Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm283
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm404
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h61
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm177
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm128
-rw-r--r--Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm116
-rw-r--r--Source/WebKit2/UIProcess/qt/BackingStoreQt.cpp75
-rw-r--r--Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp635
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp136
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDialogRunner.h63
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp145
-rw-r--r--Source/WebKit2/UIProcess/qt/QtDownloadManager.h64
-rw-r--r--Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp49
-rw-r--r--Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h55
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPageClient.cpp256
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPageClient.h107
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp104
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h54
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp157
-rw-r--r--Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h83
-rw-r--r--Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp73
-rw-r--r--Source/WebKit2/UIProcess/qt/QtSGTileNode.h54
-rw-r--r--Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp170
-rw-r--r--Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h82
-rw-r--r--Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp161
-rw-r--r--Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h76
-rw-r--r--Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp589
-rw-r--r--Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h171
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebContext.cpp157
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebContext.h82
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebError.cpp67
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebError.h60
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp122
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h67
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp500
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h97
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp197
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h67
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp136
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h43
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp147
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h64
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp63
-rw-r--r--Source/WebKit2/UIProcess/qt/QtWebUndoController.h41
-rw-r--r--Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp129
-rw-r--r--Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp83
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp53
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h51
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextQt.cpp107
-rw-r--r--Source/WebKit2/UIProcess/qt/WebFullScreenManagerProxyQt.cpp86
-rw-r--r--Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp119
-rw-r--r--Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h56
-rw-r--r--Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp97
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp105
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp316
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h76
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp51
-rw-r--r--Source/WebKit2/UIProcess/win/BackingStoreWin.cpp110
-rw-r--r--Source/WebKit2/UIProcess/win/TextCheckerWin.cpp140
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp107
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.h61
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextWin.cpp101
-rw-r--r--Source/WebKit2/UIProcess/win/WebFullScreenManagerProxyWin.cpp111
-rw-r--r--Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp340
-rw-r--r--Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp201
-rw-r--r--Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp961
-rw-r--r--Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h144
-rw-r--r--Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp36
-rw-r--r--Source/WebKit2/UIProcess/win/WebUndoClient.cpp69
-rw-r--r--Source/WebKit2/UIProcess/win/WebUndoClient.h48
-rw-r--r--Source/WebKit2/UIProcess/win/WebView.cpp1782
-rw-r--r--Source/WebKit2/UIProcess/win/WebView.h292
547 files changed, 72812 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); \
+}
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp
new file mode 100644
index 000000000..7f4e958ed
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp
@@ -0,0 +1,102 @@
+/*
+ * 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 "AuthenticationChallengeProxy.h"
+
+#include "AuthenticationDecisionListener.h"
+#include "AuthenticationManagerMessages.h"
+#include "WebCertificateInfo.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebCredential.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include "WebProtectionSpace.h"
+
+namespace WebKit {
+
+AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
+ : m_coreAuthenticationChallenge(authenticationChallenge)
+ , m_challengeID(challengeID)
+ , m_process(process)
+{
+ ASSERT(m_challengeID);
+ m_listener = AuthenticationDecisionListener::create(this);
+}
+
+AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
+{
+ // If an outstanding AuthenticationChallengeProxy is being destroyed even though it hasn't been responded to yet,
+ // we cancel it here so the WebProcess isn't waiting for an answer forever.
+ if (m_challengeID)
+ m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
+
+ if (m_listener)
+ m_listener->detachChallenge();
+}
+
+void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
+{
+ if (!m_challengeID)
+ return;
+
+ if (!credential)
+ m_process->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
+ else {
+ WebCertificateInfo* certificateInfo = credential->certificateInfo();
+ PlatformCertificateInfo platformInfo = certificateInfo ? certificateInfo->platformCertificateInfo() : PlatformCertificateInfo();
+ m_process->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
+ }
+
+ m_challengeID = 0;
+}
+
+void AuthenticationChallengeProxy::cancel()
+{
+ if (!m_challengeID)
+ return;
+
+ m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
+
+ m_challengeID = 0;
+}
+
+WebCredential* AuthenticationChallengeProxy::proposedCredential() const
+{
+ if (!m_webCredential)
+ m_webCredential = WebCredential::create(m_coreAuthenticationChallenge.proposedCredential());
+
+ return m_webCredential.get();
+}
+
+WebProtectionSpace* AuthenticationChallengeProxy::protectionSpace() const
+{
+ if (!m_webProtectionSpace)
+ m_webProtectionSpace = WebProtectionSpace::create(m_coreAuthenticationChallenge.protectionSpace());
+
+ return m_webProtectionSpace.get();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h
new file mode 100644
index 000000000..a429ac510
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h
@@ -0,0 +1,80 @@
+/*
+ * 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 AuthenticationChallengeProxy_h
+#define AuthenticationChallengeProxy_h
+
+#include "APIObject.h"
+#include <WebCore/AuthenticationChallenge.h>
+#include <wtf/PassRefPtr.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+class AuthenticationDecisionListener;
+class WebCredential;
+class WebProcessProxy;
+class WebProtectionSpace;
+
+class AuthenticationChallengeProxy : public APIObject {
+public:
+ static const Type APIType = TypeAuthenticationChallenge;
+
+ static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
+ {
+ return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, process));
+ }
+
+ ~AuthenticationChallengeProxy();
+
+ void useCredential(WebCredential*);
+ void cancel();
+
+ AuthenticationDecisionListener* listener() const { return m_listener.get(); }
+ WebCredential* proposedCredential() const;
+ WebProtectionSpace* protectionSpace() const;
+ int previousFailureCount() const { return m_coreAuthenticationChallenge.previousFailureCount(); }
+
+private:
+ AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, WebProcessProxy*);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
+ uint64_t m_challengeID;
+ RefPtr<WebProcessProxy> m_process;
+ RefPtr<AuthenticationDecisionListener> m_listener;
+ mutable RefPtr<WebCredential> m_webCredential;
+ mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
+};
+
+} // namespace WebKit
+
+#endif // WebAuthenticationChallengeProxy_h
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp
new file mode 100644
index 000000000..00cd8748c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.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 "AuthenticationDecisionListener.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "AuthenticationManagerMessages.h"
+#include "WebCertificateInfo.h"
+#include "WebCredential.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+AuthenticationDecisionListener::AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge)
+ : m_challengeProxy(authenticationChallenge)
+{
+}
+
+void AuthenticationDecisionListener::useCredential(WebCredential* credential)
+{
+ if (m_challengeProxy)
+ m_challengeProxy->useCredential(credential);
+}
+
+void AuthenticationDecisionListener::cancel()
+{
+ if (m_challengeProxy)
+ m_challengeProxy->cancel();
+}
+
+void AuthenticationDecisionListener::detachChallenge()
+{
+ m_challengeProxy = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h
new file mode 100644
index 000000000..00af84965
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h
@@ -0,0 +1,62 @@
+/*
+ * 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 AuthenticationDecisionListener_h
+#define AuthenticationDecisionListener_h
+
+#include "APIObject.h"
+
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class AuthenticationChallengeProxy;
+class WebCredential;
+
+class AuthenticationDecisionListener : public APIObject {
+public:
+ static const Type APIType = TypeAuthenticationDecisionListener;
+
+ static PassRefPtr<AuthenticationDecisionListener> create(AuthenticationChallengeProxy* authenticationChallenge)
+ {
+ return adoptRef(new AuthenticationDecisionListener(authenticationChallenge));
+ }
+
+ void useCredential(WebCredential*);
+ void cancel();
+
+ void detachChallenge();
+
+private:
+ AuthenticationDecisionListener(AuthenticationChallengeProxy* authenticationChallenge);
+
+ virtual Type type() const { return APIType; }
+
+ AuthenticationChallengeProxy* m_challengeProxy;
+};
+
+} // namespace WebKit
+
+#endif // WebAuthenticationDecisionListener_h
diff --git a/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp b/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp
new file mode 100644
index 000000000..6d70c5fbc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "WebCredential.h"
+
+#include "WebCertificateInfo.h"
+
+namespace WebKit {
+
+WebCredential::WebCredential(const WebCore::Credential& credential)
+ : m_coreCredential(credential)
+{
+}
+
+WebCredential::WebCredential(WebCertificateInfo* certificateInfo)
+ : m_certificateInfo(certificateInfo)
+{
+}
+
+WebCertificateInfo* WebCredential::certificateInfo()
+{
+ return m_certificateInfo.get();
+}
+
+const WebCore::Credential& WebCredential::core()
+{
+ return m_coreCredential;
+}
+
+const String& WebCredential::user() const
+{
+ return m_coreCredential.user();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Authentication/WebCredential.h b/Source/WebKit2/UIProcess/Authentication/WebCredential.h
new file mode 100644
index 000000000..b07a8a6ec
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.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 WebCredential_h
+#define WebCredential_h
+
+#include "APIObject.h"
+#include "WebString.h"
+
+#include <WebCore/Credential.h>
+#include <wtf/PassRefPtr.h>
+
+
+namespace WebKit {
+
+class WebCertificateInfo;
+
+class WebCredential : public APIObject {
+public:
+ static const Type APIType = TypeCredential;
+
+ static PassRefPtr<WebCredential> create(const WebCore::Credential& credential)
+ {
+ return adoptRef(new WebCredential(credential));
+ }
+
+ static PassRefPtr<WebCredential> create(WebString* username, WebString* password, WebCore::CredentialPersistence persistence)
+ {
+ return adoptRef(new WebCredential(WebCore::Credential(username->string(), password->string(), persistence)));
+ }
+
+ static PassRefPtr<WebCredential> create(WebCertificateInfo* certificateInfo)
+ {
+ return adoptRef(new WebCredential(certificateInfo));
+ }
+
+ WebCertificateInfo* certificateInfo();
+
+ const WebCore::Credential& core();
+
+ const String& user() const;
+
+private:
+ WebCredential(const WebCore::Credential&);
+ WebCredential(WebCertificateInfo*);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::Credential m_coreCredential;
+ RefPtr<WebCertificateInfo> m_certificateInfo;
+};
+
+} // namespace WebKit
+
+#endif // WebCredential_h
diff --git a/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp
new file mode 100644
index 000000000..3d38e2242
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "WebProtectionSpace.h"
+
+#include <WebCore/SharedBuffer.h>
+
+namespace WebKit {
+
+WebProtectionSpace::WebProtectionSpace(const WebCore::ProtectionSpace& coreProtectionSpace)
+ : m_coreProtectionSpace(coreProtectionSpace)
+{
+}
+
+const String& WebProtectionSpace::host() const
+{
+ return m_coreProtectionSpace.host();
+}
+
+int WebProtectionSpace::port() const
+{
+ return m_coreProtectionSpace.port();
+}
+
+const String& WebProtectionSpace::realm() const
+{
+ return m_coreProtectionSpace.realm();
+}
+
+bool WebProtectionSpace::isProxy() const
+{
+ return m_coreProtectionSpace.isProxy();
+}
+
+WebCore::ProtectionSpaceServerType WebProtectionSpace::serverType() const
+{
+ return m_coreProtectionSpace.serverType();
+}
+
+bool WebProtectionSpace::receivesCredentialSecurely() const
+{
+ return m_coreProtectionSpace.receivesCredentialSecurely();
+}
+
+WebCore::ProtectionSpaceAuthenticationScheme WebProtectionSpace::authenticationScheme() const
+{
+ return m_coreProtectionSpace.authenticationScheme();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h
new file mode 100644
index 000000000..604236a62
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h
@@ -0,0 +1,63 @@
+/*
+ * 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 WebProtectionSpace_h
+#define WebProtectionSpace_h
+
+#include "APIObject.h"
+#include <WebCore/ProtectionSpace.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebProtectionSpace : public APIObject {
+public:
+ static const Type APIType = TypeProtectionSpace;
+
+ static PassRefPtr<WebProtectionSpace> create(const WebCore::ProtectionSpace& protectionSpace)
+ {
+ return adoptRef(new WebProtectionSpace(protectionSpace));
+ }
+
+ const String& protocol() const;
+ const String& host() const;
+ int port() const;
+ const String& realm() const;
+ bool isProxy() const;
+ WebCore::ProtectionSpaceServerType serverType() const;
+ bool receivesCredentialSecurely() const;
+ WebCore::ProtectionSpaceAuthenticationScheme authenticationScheme() const;
+
+private:
+ WebProtectionSpace(const WebCore::ProtectionSpace&);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::ProtectionSpace m_coreProtectionSpace;
+};
+
+} // namespace WebKit
+
+#endif // WebProtectionSpace_h
diff --git a/Source/WebKit2/UIProcess/BackingStore.cpp b/Source/WebKit2/UIProcess/BackingStore.cpp
new file mode 100644
index 000000000..30ec8e629
--- /dev/null
+++ b/Source/WebKit2/UIProcess/BackingStore.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "BackingStore.h"
+
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size, float deviceScaleFactor, WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new BackingStore(size, deviceScaleFactor, webPageProxy));
+}
+
+BackingStore::BackingStore(const IntSize& size, float deviceScaleFactor, WebPageProxy* webPageProxy)
+ : m_size(size)
+ , m_deviceScaleFactor(deviceScaleFactor)
+ , m_webPageProxy(webPageProxy)
+{
+ ASSERT(!m_size.isEmpty());
+}
+
+BackingStore::~BackingStore()
+{
+}
+
+void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo)
+{
+ ASSERT(m_size == updateInfo.viewSize);
+
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
+ if (!bitmap)
+ return;
+
+#if !ASSERT_DISABLED
+ IntSize updateSize = updateInfo.updateRectBounds.size();
+ updateSize.scale(m_deviceScaleFactor);
+ ASSERT(bitmap->size() == updateSize);
+#endif
+
+ incorporateUpdate(bitmap.get(), updateInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/BackingStore.h b/Source/WebKit2/UIProcess/BackingStore.h
new file mode 100644
index 000000000..e83ae88d2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/BackingStore.h
@@ -0,0 +1,108 @@
+/*
+ * 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 BackingStore_h
+#define BackingStore_h
+
+#include <WebCore/IntSize.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/PassOwnPtr.h>
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#elif PLATFORM(WIN) || PLATFORM(WIN_CAIRO)
+#include <wtf/OwnPtr.h>
+#endif
+
+#if PLATFORM(QT)
+#include <QtGui/QPainter>
+#include <QtGui/QPixmap>
+#endif
+
+#if USE(CAIRO) && !PLATFORM(WIN_CAIRO)
+#include <RefPtrCairo.h>
+#include <WebCore/WidgetBackingStore.h>
+#endif
+
+namespace WebCore {
+ class IntRect;
+}
+
+namespace WebKit {
+
+class ShareableBitmap;
+class UpdateInfo;
+class WebPageProxy;
+
+class BackingStore {
+ WTF_MAKE_NONCOPYABLE(BackingStore);
+
+public:
+ static PassOwnPtr<BackingStore> create(const WebCore::IntSize&, float deviceScaleFactor, WebPageProxy*);
+ ~BackingStore();
+
+ const WebCore::IntSize& size() const { return m_size; }
+ float deviceScaleFactor() const { return m_deviceScaleFactor; }
+
+#if PLATFORM(MAC)
+ typedef CGContextRef PlatformGraphicsContext;
+#elif PLATFORM(WIN)
+ typedef HDC PlatformGraphicsContext;
+#elif PLATFORM(QT)
+ typedef QPainter* PlatformGraphicsContext;
+#elif USE(CAIRO)
+ typedef cairo_t* PlatformGraphicsContext;
+#endif
+
+ void paint(PlatformGraphicsContext, const WebCore::IntRect&);
+ void incorporateUpdate(const UpdateInfo&);
+
+private:
+ BackingStore(const WebCore::IntSize&, float deviceScaleFactor, WebPageProxy*);
+
+ void incorporateUpdate(ShareableBitmap*, const UpdateInfo&);
+ void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+
+ WebCore::IntSize m_size;
+ float m_deviceScaleFactor;
+ WebPageProxy* m_webPageProxy;
+
+#if PLATFORM(MAC)
+ CGContextRef backingStoreContext();
+
+ RetainPtr<CGLayerRef> m_cgLayer;
+ RetainPtr<CGContextRef> m_bitmapContext;
+#elif PLATFORM(WIN) || PLATFORM(WIN_CAIRO)
+ OwnPtr<HBITMAP> m_bitmap;
+#elif PLATFORM(QT)
+ QPixmap m_pixmap;
+#elif USE(CAIRO)
+ OwnPtr<WebCore::WidgetBackingStore> m_backingStore;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // BackingStore_h
diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
new file mode 100644
index 000000000..26a521f39
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
@@ -0,0 +1,202 @@
+/*
+ * 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 "DownloadProxy.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "DataReference.h"
+#include "WebContext.h"
+#include "WebData.h"
+#include "WebProcessMessages.h"
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t generateDownloadID()
+{
+ static uint64_t uniqueDownloadID = 0;
+ return ++uniqueDownloadID;
+}
+
+PassRefPtr<DownloadProxy> DownloadProxy::create(WebContext* webContext)
+{
+ return adoptRef(new DownloadProxy(webContext));
+}
+
+DownloadProxy::DownloadProxy(WebContext* webContext)
+ : m_webContext(webContext)
+ , m_downloadID(generateDownloadID())
+{
+}
+
+DownloadProxy::~DownloadProxy()
+{
+ ASSERT(!m_webContext);
+}
+
+void DownloadProxy::cancel()
+{
+ if (!m_webContext)
+ return;
+
+ // FIXME (Multi-WebProcess): Downloads shouldn't be handled in the web process.
+ m_webContext->sendToAllProcesses(Messages::WebProcess::CancelDownload(m_downloadID));
+}
+
+void DownloadProxy::invalidate()
+{
+ ASSERT(m_webContext);
+ m_webContext = 0;
+}
+
+void DownloadProxy::processDidClose()
+{
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().processDidCrash(m_webContext, this);
+}
+
+void DownloadProxy::didStart(const ResourceRequest& request)
+{
+ m_request = request;
+
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().didStart(m_webContext, this);
+}
+
+void DownloadProxy::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge, uint64_t challengeID)
+{
+ if (!m_webContext)
+ return;
+
+ RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->process());
+ m_webContext->downloadClient().didReceiveAuthenticationChallenge(m_webContext, this, authenticationChallengeProxy.get());
+}
+
+void DownloadProxy::didReceiveResponse(const ResourceResponse& response)
+{
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().didReceiveResponse(m_webContext, this, response);
+}
+
+void DownloadProxy::didReceiveData(uint64_t length)
+{
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().didReceiveData(m_webContext, this, length);
+}
+
+void DownloadProxy::shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result)
+{
+ if (!m_webContext)
+ return;
+
+ result = m_webContext->downloadClient().shouldDecodeSourceDataOfMIMEType(m_webContext, this, mimeType);
+}
+
+void DownloadProxy::decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ if (!m_webContext)
+ return;
+
+ destination = m_webContext->downloadClient().decideDestinationWithSuggestedFilename(m_webContext, this, filename, allowOverwrite);
+
+ if (!destination.isNull())
+ SandboxExtension::createHandle(destination, SandboxExtension::WriteOnly, sandboxExtensionHandle);
+}
+
+void DownloadProxy::didCreateDestination(const String& path)
+{
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().didCreateDestination(m_webContext, this, path);
+}
+
+void DownloadProxy::didFinish()
+{
+ if (!m_webContext)
+ return;
+
+ m_webContext->downloadClient().didFinish(m_webContext, this);
+
+ // This can cause the DownloadProxy object to be deleted.
+ m_webContext->downloadFinished(this);
+}
+
+static PassRefPtr<WebData> createWebData(const CoreIPC::DataReference& data)
+{
+ if (data.isEmpty())
+ return 0;
+
+ return WebData::create(data.data(), data.size());
+}
+
+void DownloadProxy::didFail(const ResourceError& error, const CoreIPC::DataReference& resumeData)
+{
+ if (!m_webContext)
+ return;
+
+ m_resumeData = createWebData(resumeData);
+
+ m_webContext->downloadClient().didFail(m_webContext, this, error);
+
+ // This can cause the DownloadProxy object to be deleted.
+ m_webContext->downloadFinished(this);
+}
+
+void DownloadProxy::didCancel(const CoreIPC::DataReference& resumeData)
+{
+ m_resumeData = createWebData(resumeData);
+
+ m_webContext->downloadClient().didCancel(m_webContext, this);
+
+ // This can cause the DownloadProxy object to be deleted.
+ m_webContext->downloadFinished(this);
+}
+
+#if PLATFORM(QT)
+void DownloadProxy::startTransfer(const String& filename)
+{
+ if (!m_webContext)
+ return;
+
+ // FIXME (Multi-WebProcess): Downloads shouldn't be handled in the web process.
+ m_webContext->sendToAllProcesses(Messages::WebProcess::StartTransfer(m_downloadID, filename));
+}
+#endif
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
new file mode 100644
index 000000000..c1eda1fd1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
@@ -0,0 +1,97 @@
+/*
+ * 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 DownloadProxy_h
+#define DownloadProxy_h
+
+#include "APIObject.h"
+#include "Connection.h"
+#include "SandboxExtension.h"
+#include <WebCore/ResourceRequest.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+ class AuthenticationChallenge;
+ class ResourceError;
+ class ResourceResponse;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebData;
+class WebPageProxy;
+
+class DownloadProxy : public APIObject {
+public:
+ static const Type APIType = TypeDownload;
+
+ static PassRefPtr<DownloadProxy> create(WebContext*);
+ ~DownloadProxy();
+
+ uint64_t downloadID() const { return m_downloadID; }
+ const WebCore::ResourceRequest& request() const { return m_request; }
+ WebData* resumeData() const { return m_resumeData.get(); }
+
+ void cancel();
+
+ void invalidate();
+ void processDidClose();
+
+ void didReceiveDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+#if PLATFORM(QT)
+ void startTransfer(const String& filename);
+#endif
+
+private:
+ explicit DownloadProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ // Message handlers.
+ void didStart(const WebCore::ResourceRequest&);
+ void didReceiveAuthenticationChallenge(const WebCore::AuthenticationChallenge&, uint64_t challengeID);
+ void didReceiveResponse(const WebCore::ResourceResponse&);
+ void didReceiveData(uint64_t length);
+ void shouldDecodeSourceDataOfMIMEType(const String& mimeType, bool& result);
+ void decideDestinationWithSuggestedFilename(const String& filename, String& destination, bool& allowOverwrite, SandboxExtension::Handle& sandboxExtensionHandle);
+ void didCreateDestination(const String& path);
+ void didFinish();
+ void didFail(const WebCore::ResourceError&, const CoreIPC::DataReference& resumeData);
+ void didCancel(const CoreIPC::DataReference& resumeData);
+
+ WebContext* m_webContext;
+ uint64_t m_downloadID;
+
+ RefPtr<WebData> m_resumeData;
+ WebCore::ResourceRequest m_request;
+};
+
+} // namespace WebKit
+
+#endif // DownloadProxy_h
diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in
new file mode 100644
index 000000000..d72559988
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in
@@ -0,0 +1,35 @@
+# 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.
+
+messages -> DownloadProxy {
+ DidStart(WebCore::ResourceRequest request)
+ DidReceiveAuthenticationChallenge(WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
+
+ DidReceiveResponse(WebCore::ResourceResponse response)
+ DidReceiveData(uint64_t length)
+ ShouldDecodeSourceDataOfMIMEType(String mimeType) -> (bool result)
+ DecideDestinationWithSuggestedFilename(String filename) -> (String destination, bool allowOverwrite, WebKit::SandboxExtension::Handle sandboxExtensionHandle)
+ DidCreateDestination(WTF::String path)
+ DidFinish()
+ DidFail(WebCore::ResourceError error, CoreIPC::DataReference resumeData)
+ DidCancel(CoreIPC::DataReference resumeData)
+}
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp
new file mode 100644
index 000000000..aa25dd1fd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.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 "DrawingAreaProxy.h"
+
+#include "WebPageProxy.h"
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "LayerTreeHostProxy.h"
+#include <CoreIPC/MessageID.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DrawingAreaProxy::DrawingAreaProxy(DrawingAreaType type, WebPageProxy* webPageProxy)
+ : m_type(type)
+ , m_webPageProxy(webPageProxy)
+ , m_size(webPageProxy->viewSize())
+{
+}
+
+DrawingAreaProxy::~DrawingAreaProxy()
+{
+}
+
+void DrawingAreaProxy::setSize(const IntSize& size, const IntSize& scrollOffset)
+{
+ if (m_size == size && scrollOffset.isZero())
+ return;
+
+ m_size = size;
+ m_scrollOffset += scrollOffset;
+ sizeDidChange();
+}
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+void DrawingAreaProxy::updateViewport()
+{
+ m_webPageProxy->setViewNeedsDisplay(viewportVisibleRect());
+}
+
+WebCore::IntRect DrawingAreaProxy::contentsRect() const
+{
+ return IntRect(IntPoint::zero(), m_webPageProxy->viewSize());
+}
+
+void DrawingAreaProxy::didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+}
+#endif
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h
new file mode 100644
index 000000000..2f5832287
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h
@@ -0,0 +1,143 @@
+/*
+ * 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 DrawingAreaProxy_h
+#define DrawingAreaProxy_h
+
+#include "DrawingAreaInfo.h"
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <stdint.h>
+#include <wtf/Noncopyable.h>
+
+#if PLATFORM(QT)
+class QPainter;
+#elif PLATFORM(GTK)
+typedef struct _cairo cairo_t;
+#endif
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebCore {
+ class FloatPoint;
+ class TransformationMatrix;
+}
+
+namespace WebKit {
+
+class LayerTreeContext;
+class LayerTreeHostProxy;
+class UpdateInfo;
+class WebLayerTreeInfo;
+class WebLayerUpdateInfo;
+class WebPageProxy;
+
+class DrawingAreaProxy {
+ WTF_MAKE_NONCOPYABLE(DrawingAreaProxy);
+
+public:
+ virtual ~DrawingAreaProxy();
+
+ DrawingAreaType type() const { return m_type; }
+
+ void didReceiveDrawingAreaProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ virtual void deviceScaleFactorDidChange() = 0;
+
+ // FIXME: These should be pure virtual.
+ virtual void visibilityDidChange() { }
+ virtual void setBackingStoreIsDiscardable(bool) { }
+
+ virtual void waitForBackingStoreUpdateOnNextPaint() { }
+
+ const WebCore::IntSize& size() const { return m_size; }
+ void setSize(const WebCore::IntSize&, const WebCore::IntSize& scrollOffset);
+
+ virtual void pageCustomRepresentationChanged() { }
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+ virtual void updateViewport();
+ virtual WebCore::IntRect viewportVisibleRect() const { return contentsRect(); }
+ virtual WebCore::IntRect contentsRect() const;
+ virtual bool isBackingStoreReady() const { return true; }
+ virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity) { }
+ LayerTreeHostProxy* layerTreeHostProxy() const { return m_layerTreeHostProxy.get(); }
+
+#if USE(TILED_BACKING_STORE)
+ virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale) { }
+ virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&) { }
+ virtual void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
+ virtual void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&) { }
+ virtual void removeTileForLayer(int layerID, int tileID) { }
+ virtual void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ WebPageProxy* page() { return m_webPageProxy; }
+#endif
+#endif
+protected:
+ explicit DrawingAreaProxy(DrawingAreaType, WebPageProxy*);
+
+ DrawingAreaType m_type;
+ WebPageProxy* m_webPageProxy;
+
+ WebCore::IntSize m_size;
+ WebCore::IntSize m_scrollOffset;
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+ OwnPtr<LayerTreeHostProxy> m_layerTreeHostProxy;
+#endif
+
+private:
+ virtual void sizeDidChange() = 0;
+
+ // CoreIPC message handlers.
+ // FIXME: These should be pure virtual.
+ virtual void update(uint64_t backingStoreStateID, const UpdateInfo&) { }
+ virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&) { }
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) { }
+ virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) { }
+#endif
+#if PLATFORM(MAC)
+ virtual void didUpdateGeometry() { }
+#endif
+#if USE(TILED_BACKING_STORE)
+ virtual void snapshotTaken(const UpdateInfo&) { }
+ virtual void createTile(int tileID, const UpdateInfo& updateInfo) { }
+ virtual void updateTile(int tileID, const UpdateInfo& updateInfo) { }
+ virtual void didRenderFrame() { }
+ virtual void removeTile(int tileID) { }
+ virtual void allTileUpdatesProcessed() { }
+#endif
+};
+
+} // namespace WebKit
+
+#endif // DrawingAreaProxy_h
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in
new file mode 100644
index 000000000..89f7328a3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in
@@ -0,0 +1,43 @@
+# 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.
+
+messages -> DrawingAreaProxy {
+ Update(uint64_t stateID, WebKit::UpdateInfo updateInfo)
+ DidUpdateBackingStoreState(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo, WebKit::LayerTreeContext context)
+#if USE(ACCELERATED_COMPOSITING)
+ EnterAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::LayerTreeContext context)
+ ExitAcceleratedCompositingMode(uint64_t backingStoreStateID, WebKit::UpdateInfo updateInfo)
+#endif
+
+#if PLATFORM(MAC)
+ // Used by TiledCoreAnimationDrawingAreaProxy.
+ DidUpdateGeometry()
+#endif
+
+#if USE(TILED_BACKING_STORE)
+ CreateTile(int tileID, WebKit::UpdateInfo updateInfo)
+ UpdateTile(int tileID, WebKit::UpdateInfo updateInfo)
+ DidRenderFrame()
+ RemoveTile(int tileID)
+ SnapshotTaken(WebKit::UpdateInfo updateInfo)
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
new file mode 100644
index 000000000..7b153848d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
@@ -0,0 +1,395 @@
+/*
+ * 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 "DrawingAreaProxyImpl.h"
+
+#include "DrawingAreaMessages.h"
+#include "DrawingAreaProxyMessages.h"
+#include "LayerTreeContext.h"
+#include "UpdateInfo.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include <WebCore/Region.h>
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "LayerTreeHostProxy.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new DrawingAreaProxyImpl(webPageProxy));
+}
+
+DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaTypeImpl, webPageProxy)
+ , m_currentBackingStoreStateID(0)
+ , m_nextBackingStoreStateID(0)
+ , m_isWaitingForDidUpdateBackingStoreState(false)
+ , m_hasReceivedFirstUpdate(false)
+ , m_isBackingStoreDiscardable(true)
+ , m_discardBackingStoreTimer(RunLoop::current(), this, &DrawingAreaProxyImpl::discardBackingStore)
+{
+}
+
+DrawingAreaProxyImpl::~DrawingAreaProxyImpl()
+{
+#if USE(ACCELERATED_COMPOSITING)
+ // Make sure to exit accelerated compositing mode.
+ if (isInAcceleratedCompositingMode())
+ exitAcceleratedCompositingMode();
+#endif
+}
+
+void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect, Region& unpaintedRegion)
+{
+ unpaintedRegion = rect;
+
+ if (isInAcceleratedCompositingMode())
+ return;
+
+ ASSERT(m_currentBackingStoreStateID <= m_nextBackingStoreStateID);
+ if (m_currentBackingStoreStateID < m_nextBackingStoreStateID) {
+ // Tell the web process to do a full backing store update now, in case we previously told
+ // it about our next state but didn't request an immediate update.
+ sendUpdateBackingStoreState(RespondImmediately);
+
+ // If we haven't yet received our first bits from the WebProcess then don't paint anything.
+ if (!m_hasReceivedFirstUpdate)
+ return;
+
+ if (m_isWaitingForDidUpdateBackingStoreState) {
+ // Wait for a DidUpdateBackingStoreState message that contains the new bits before we paint
+ // what's currently in the backing store.
+ waitForAndDispatchDidUpdateBackingStoreState();
+ }
+
+ // Dispatching DidUpdateBackingStoreState (either beneath sendUpdateBackingStoreState or
+ // beneath waitForAndDispatchDidUpdateBackingStoreState) could destroy our backing store or
+ // change the compositing mode.
+ if (!m_backingStore || isInAcceleratedCompositingMode())
+ return;
+ } else {
+ ASSERT(!m_isWaitingForDidUpdateBackingStoreState);
+ if (!m_backingStore) {
+ // The view has asked us to paint before the web process has painted anything. There's
+ // nothing we can do.
+ return;
+ }
+ }
+
+ m_backingStore->paint(context, rect);
+ unpaintedRegion.subtract(IntRect(IntPoint(), m_backingStore->size()));
+
+ discardBackingStoreSoon();
+}
+
+void DrawingAreaProxyImpl::sizeDidChange()
+{
+ backingStoreStateDidChange(RespondImmediately);
+}
+
+void DrawingAreaProxyImpl::deviceScaleFactorDidChange()
+{
+ backingStoreStateDidChange(RespondImmediately);
+}
+
+void DrawingAreaProxyImpl::visibilityDidChange()
+{
+ if (!m_webPageProxy->isViewVisible()) {
+ // Suspend painting.
+ m_webPageProxy->process()->send(Messages::DrawingArea::SuspendPainting(), m_webPageProxy->pageID());
+ return;
+ }
+
+ // Resume painting.
+ m_webPageProxy->process()->send(Messages::DrawingArea::ResumePainting(), m_webPageProxy->pageID());
+
+#if USE(ACCELERATED_COMPOSITING)
+ // If we don't have a backing store, go ahead and mark the backing store as being changed so
+ // that when paint we'll actually wait for something to paint and not flash white.
+ if (!m_backingStore && m_layerTreeContext.isEmpty())
+ backingStoreStateDidChange(DoNotRespondImmediately);
+#endif
+}
+
+void DrawingAreaProxyImpl::setBackingStoreIsDiscardable(bool isBackingStoreDiscardable)
+{
+ if (m_isBackingStoreDiscardable == isBackingStoreDiscardable)
+ return;
+
+ m_isBackingStoreDiscardable = isBackingStoreDiscardable;
+ if (m_isBackingStoreDiscardable)
+ discardBackingStoreSoon();
+ else
+ m_discardBackingStoreTimer.stop();
+}
+
+void DrawingAreaProxyImpl::waitForBackingStoreUpdateOnNextPaint()
+{
+ m_hasReceivedFirstUpdate = true;
+}
+
+void DrawingAreaProxyImpl::update(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
+{
+ ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
+ if (backingStoreStateID < m_currentBackingStoreStateID)
+ return;
+
+ // FIXME: Handle the case where the view is hidden.
+
+ incorporateUpdate(updateInfo);
+ m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID());
+}
+
+void DrawingAreaProxyImpl::didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo& updateInfo, const LayerTreeContext& layerTreeContext)
+{
+ ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_nextBackingStoreStateID);
+ ASSERT_ARG(backingStoreStateID, backingStoreStateID > m_currentBackingStoreStateID);
+ m_currentBackingStoreStateID = backingStoreStateID;
+
+ m_isWaitingForDidUpdateBackingStoreState = false;
+
+ // Stop the responsiveness timer that was started in sendUpdateBackingStoreState.
+ m_webPageProxy->process()->responsivenessTimer()->stop();
+
+ if (m_nextBackingStoreStateID != m_currentBackingStoreStateID)
+ sendUpdateBackingStoreState(RespondImmediately);
+ else
+ m_hasReceivedFirstUpdate = true;
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (layerTreeContext != m_layerTreeContext) {
+ if (!m_layerTreeContext.isEmpty()) {
+ exitAcceleratedCompositingMode();
+ ASSERT(m_layerTreeContext.isEmpty());
+ }
+
+ if (!layerTreeContext.isEmpty()) {
+ enterAcceleratedCompositingMode(layerTreeContext);
+ ASSERT(layerTreeContext == m_layerTreeContext);
+ }
+ }
+
+ if (isInAcceleratedCompositingMode()) {
+ ASSERT(!m_backingStore);
+ return;
+ }
+#endif
+
+ // If we have a backing store the right size, reuse it.
+ if (m_backingStore && (m_backingStore->size() != updateInfo.viewSize || m_backingStore->deviceScaleFactor() != updateInfo.deviceScaleFactor))
+ m_backingStore = nullptr;
+ incorporateUpdate(updateInfo);
+}
+
+void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+{
+ ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
+ if (backingStoreStateID < m_currentBackingStoreStateID)
+ return;
+
+#if USE(ACCELERATED_COMPOSITING)
+ enterAcceleratedCompositingMode(layerTreeContext);
+#endif
+}
+
+void DrawingAreaProxyImpl::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo& updateInfo)
+{
+ ASSERT_ARG(backingStoreStateID, backingStoreStateID <= m_currentBackingStoreStateID);
+ if (backingStoreStateID < m_currentBackingStoreStateID)
+ return;
+
+#if USE(ACCELERATED_COMPOSITING)
+ exitAcceleratedCompositingMode();
+#endif
+
+ incorporateUpdate(updateInfo);
+}
+
+void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
+{
+ ASSERT(!isInAcceleratedCompositingMode());
+
+ if (updateInfo.updateRectBounds.isEmpty())
+ return;
+
+ if (!m_backingStore)
+ m_backingStore = BackingStore::create(updateInfo.viewSize, updateInfo.deviceScaleFactor, m_webPageProxy);
+
+ m_backingStore->incorporateUpdate(updateInfo);
+
+ bool shouldScroll = !updateInfo.scrollRect.isEmpty();
+
+ if (shouldScroll)
+ m_webPageProxy->scrollView(updateInfo.scrollRect, updateInfo.scrollOffset);
+
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i)
+ m_webPageProxy->setViewNeedsDisplay(updateInfo.updateRects[i]);
+
+ if (WebPageProxy::debugPaintFlags() & kWKDebugFlashBackingStoreUpdates)
+ m_webPageProxy->flashBackingStoreUpdates(updateInfo.updateRects);
+
+ if (shouldScroll)
+ m_webPageProxy->displayView();
+}
+
+void DrawingAreaProxyImpl::backingStoreStateDidChange(RespondImmediatelyOrNot respondImmediatelyOrNot)
+{
+ ++m_nextBackingStoreStateID;
+ sendUpdateBackingStoreState(respondImmediatelyOrNot);
+}
+
+void DrawingAreaProxyImpl::sendUpdateBackingStoreState(RespondImmediatelyOrNot respondImmediatelyOrNot)
+{
+ ASSERT(m_currentBackingStoreStateID < m_nextBackingStoreStateID);
+
+ if (!m_webPageProxy->isValid())
+ return;
+
+ if (m_isWaitingForDidUpdateBackingStoreState)
+ return;
+
+ if (m_webPageProxy->viewSize().isEmpty())
+ return;
+
+ m_isWaitingForDidUpdateBackingStoreState = respondImmediatelyOrNot == RespondImmediately;
+
+ m_webPageProxy->process()->send(Messages::DrawingArea::UpdateBackingStoreState(m_nextBackingStoreStateID, respondImmediatelyOrNot == RespondImmediately, m_webPageProxy->deviceScaleFactor(), m_size, m_scrollOffset), m_webPageProxy->pageID());
+ m_scrollOffset = IntSize();
+
+ if (m_isWaitingForDidUpdateBackingStoreState) {
+ // Start the responsiveness timer. We will stop it when we hear back from the WebProcess
+ // in didUpdateBackingStoreState.
+ m_webPageProxy->process()->responsivenessTimer()->start();
+ }
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_isWaitingForDidUpdateBackingStoreState && !m_layerTreeContext.isEmpty()) {
+ // Wait for the DidUpdateBackingStoreState message. Normally we do this in DrawingAreaProxyImpl::paint, but that
+ // function is never called when in accelerated compositing mode.
+ waitForAndDispatchDidUpdateBackingStoreState();
+ }
+#endif
+}
+
+void DrawingAreaProxyImpl::waitForAndDispatchDidUpdateBackingStoreState()
+{
+ ASSERT(m_isWaitingForDidUpdateBackingStoreState);
+
+ if (!m_webPageProxy->isValid())
+ return;
+ if (m_webPageProxy->process()->isLaunching())
+ return;
+
+#if USE(ACCELERATED_COMPOSITING)
+ // FIXME: waitForAndDispatchImmediately will always return the oldest DidUpdateBackingStoreState message that
+ // hasn't yet been processed. But it might be better to skip ahead to some other DidUpdateBackingStoreState
+ // message, if multiple DidUpdateBackingStoreState messages are waiting to be processed. For instance, we could
+ // choose the most recent one, or the one that is closest to our current size.
+
+ // The timeout, in seconds, we use when waiting for a DidUpdateBackingStoreState message when we're asked to paint.
+ static const double didUpdateBackingStoreStateTimeout = 0.5;
+ m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateBackingStoreState>(m_webPageProxy->pageID(), didUpdateBackingStoreStateTimeout);
+#endif
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void DrawingAreaProxyImpl::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+ ASSERT(!isInAcceleratedCompositingMode());
+
+ m_backingStore = nullptr;
+ m_layerTreeContext = layerTreeContext;
+ m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext);
+#if USE(TEXTURE_MAPPER)
+ if (!m_layerTreeHostProxy)
+ m_layerTreeHostProxy = adoptPtr(new LayerTreeHostProxy(this));
+#endif
+}
+
+#if USE(TILED_BACKING_STORE)
+void DrawingAreaProxyImpl::didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ if (m_layerTreeHostProxy)
+ m_layerTreeHostProxy->didReceiveLayerTreeHostProxyMessage(connection, messageID, arguments);
+}
+
+void DrawingAreaProxyImpl::setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale)
+{
+ if (m_layerTreeHostProxy)
+ m_layerTreeHostProxy->setVisibleContentsRectAndScale(visibleContentsRect, scale);
+}
+
+void DrawingAreaProxyImpl::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
+{
+ if (m_layerTreeHostProxy)
+ m_layerTreeHostProxy->setVisibleContentRectTrajectoryVector(trajectoryVector);
+}
+
+void DrawingAreaProxyImpl::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity)
+{
+ if (m_layerTreeHostProxy)
+ m_layerTreeHostProxy->paintToCurrentGLContext(matrix, opacity);
+}
+#endif
+
+void DrawingAreaProxyImpl::exitAcceleratedCompositingMode()
+{
+ ASSERT(isInAcceleratedCompositingMode());
+
+ m_layerTreeContext = LayerTreeContext();
+ m_webPageProxy->exitAcceleratedCompositingMode();
+}
+#endif
+
+void DrawingAreaProxyImpl::pageCustomRepresentationChanged()
+{
+ m_webPageProxy->process()->send(Messages::DrawingArea::PageCustomRepresentationChanged(), m_webPageProxy->pageID());
+}
+
+void DrawingAreaProxyImpl::discardBackingStoreSoon()
+{
+ if (!m_isBackingStoreDiscardable || m_discardBackingStoreTimer.isActive())
+ return;
+
+ // We'll wait this many seconds after the last paint before throwing away our backing store to save memory.
+ // FIXME: It would be smarter to make this delay based on how expensive painting is. See <http://webkit.org/b/55733>.
+ static const double discardBackingStoreDelay = 2;
+
+ m_discardBackingStoreTimer.startOneShot(discardBackingStoreDelay);
+}
+
+void DrawingAreaProxyImpl::discardBackingStore()
+{
+ m_backingStore = nullptr;
+ backingStoreStateDidChange(DoNotRespondImmediately);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
new file mode 100644
index 000000000..05d735423
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
@@ -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.
+ */
+
+#ifndef DrawingAreaProxyImpl_h
+#define DrawingAreaProxyImpl_h
+
+#include "BackingStore.h"
+#include "DrawingAreaProxy.h"
+#include "LayerTreeContext.h"
+#include "RunLoop.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+
+namespace WebCore {
+class Region;
+}
+
+namespace WebKit {
+
+class LayerTreeHostProxy;
+
+class DrawingAreaProxyImpl : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*);
+ virtual ~DrawingAreaProxyImpl();
+
+ void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&, WebCore::Region& unpaintedRegion);
+
+private:
+ explicit DrawingAreaProxyImpl(WebPageProxy*);
+
+ // DrawingAreaProxy
+ virtual void sizeDidChange();
+ virtual void deviceScaleFactorDidChange();
+ virtual void visibilityDidChange();
+ virtual void setBackingStoreIsDiscardable(bool);
+ virtual void waitForBackingStoreUpdateOnNextPaint();
+
+ // CoreIPC message handlers
+ virtual void update(uint64_t backingStoreStateID, const UpdateInfo&);
+ virtual void didUpdateBackingStoreState(uint64_t backingStoreStateID, const UpdateInfo&, const LayerTreeContext&);
+ virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&);
+
+ void incorporateUpdate(const UpdateInfo&);
+
+ enum RespondImmediatelyOrNot { DoNotRespondImmediately, RespondImmediately };
+ void backingStoreStateDidChange(RespondImmediatelyOrNot);
+ void sendUpdateBackingStoreState(RespondImmediatelyOrNot);
+ void waitForAndDispatchDidUpdateBackingStoreState();
+
+#if USE(ACCELERATED_COMPOSITING)
+ void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ void exitAcceleratedCompositingMode();
+
+ bool isInAcceleratedCompositingMode() const { return !m_layerTreeContext.isEmpty(); }
+
+#if USE(TILED_BACKING_STORE)
+ virtual void setVisibleContentsRectAndScale(const WebCore::IntRect& visibleContentsRect, float scale);
+ virtual void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
+ virtual void paintToCurrentGLContext(const WebCore::TransformationMatrix&, float opacity);
+ void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+#endif
+#else
+ bool isInAcceleratedCompositingMode() const { return false; }
+#endif
+
+ virtual void pageCustomRepresentationChanged();
+
+ void discardBackingStoreSoon();
+ void discardBackingStore();
+
+ // The state ID corresponding to our current backing store. Updated whenever we allocate
+ // a new backing store. Any messages received that correspond to an earlier state are ignored,
+ // as they don't apply to our current backing store.
+ uint64_t m_currentBackingStoreStateID;
+
+ // The next backing store state ID we will request the web process update to. Incremented
+ // whenever our state changes in a way that will require a new backing store to be allocated.
+ uint64_t m_nextBackingStoreStateID;
+
+#if USE(ACCELERATED_COMPOSITING)
+ // The current layer tree context.
+ LayerTreeContext m_layerTreeContext;
+#endif
+
+ // Whether we've sent a UpdateBackingStoreState message and are now waiting for a DidUpdateBackingStoreState message.
+ // Used to throttle UpdateBackingStoreState messages so we don't send them faster than the Web process can handle.
+ bool m_isWaitingForDidUpdateBackingStoreState;
+
+ // For a new Drawing Area don't draw anything until the WebProcess has sent over the first content.
+ bool m_hasReceivedFirstUpdate;
+
+ bool m_isBackingStoreDiscardable;
+ OwnPtr<BackingStore> m_backingStore;
+
+ RunLoop::Timer<DrawingAreaProxyImpl> m_discardBackingStoreTimer;
+};
+
+} // namespace WebKit
+
+#endif // DrawingAreaProxyImpl_h
diff --git a/Source/WebKit2/UIProcess/FindIndicator.cpp b/Source/WebKit2/UIProcess/FindIndicator.cpp
new file mode 100644
index 000000000..e3dfe6f4d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/FindIndicator.cpp
@@ -0,0 +1,212 @@
+/*
+ * 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 "FindIndicator.h"
+
+#include "ShareableBitmap.h"
+#include <WebCore/Gradient.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/Path.h>
+
+using namespace WebCore;
+
+static const float cornerRadius = 3.0;
+
+static const float shadowOffsetX = 0.0;
+static const float shadowOffsetY = 1.0;
+static const float shadowBlurRadius = 3.0;
+
+static const int shadowRed = 0;
+static const int shadowGreen = 0;
+static const int shadowBlue = 0;
+static const int shadowAlpha = 204;
+
+static const float lightBorderThickness = 1.0;
+static const float horizontalPaddingInsideLightBorder = 3.0;
+static const float verticalPaddingInsideLightBorder = 1.0;
+
+static const float horizontalBorderInsideShadow = lightBorderThickness + horizontalPaddingInsideLightBorder;
+static const float verticalBorderInsideShadow = lightBorderThickness + verticalPaddingInsideLightBorder;
+
+static const float leftBorderThickness = horizontalBorderInsideShadow + shadowOffsetX + shadowBlurRadius / 2.0;
+static const float topBorderThickness = verticalBorderInsideShadow - shadowOffsetY + shadowBlurRadius / 2.0;
+static const float rightBorderThickness = horizontalBorderInsideShadow - shadowOffsetX + shadowBlurRadius / 2.0;
+static const float bottomBorderThickness = verticalBorderInsideShadow + shadowOffsetY + shadowBlurRadius / 2.0;
+
+static const float horizontalOutsetToCenterOfLightBorder = horizontalBorderInsideShadow - lightBorderThickness / 2.0;
+static const float verticalOutsetToCenterOfLightBorder = verticalBorderInsideShadow - lightBorderThickness / 2.0;
+
+static const int lightBorderRed = 245;
+static const int lightBorderGreen = 230;
+static const int lightBorderBlue = 0;
+static const int lightBorderAlpha = 255;
+
+static const int gradientDarkRed = 237;
+static const int gradientDarkGreen = 204;
+static const int gradientDarkBlue = 0;
+static const int gradientDarkAlpha = 255;
+
+static const int gradientLightRed = 242;
+static const int gradientLightGreen = 239;
+static const int gradientLightBlue = 0;
+static const int gradientLightAlpha = 255;
+
+namespace WebKit {
+
+PassRefPtr<FindIndicator> FindIndicator::create(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle)
+{
+ RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(contentImageHandle);
+ if (!contentImage)
+ return 0;
+ ASSERT(contentImageScaleFactor != 1 || contentImage->size() == enclosingIntRect(selectionRectInWindowCoordinates).size());
+
+ return adoptRef(new FindIndicator(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImage.release()));
+}
+
+static bool findIndicatorsForTextRectsOverlap(const Vector<FloatRect>& textRects)
+{
+ size_t count = textRects.size();
+ if (count <= 1)
+ return false;
+
+ Vector<FloatRect> indicatorRects;
+ indicatorRects.reserveInitialCapacity(count);
+
+ for (size_t i = 0; i < count; ++i) {
+ FloatRect indicatorRect = textRects[i];
+ indicatorRect.move(-leftBorderThickness, -topBorderThickness);
+ indicatorRect.expand(leftBorderThickness + rightBorderThickness, topBorderThickness + bottomBorderThickness);
+
+ for (size_t j = indicatorRects.size(); j; ) {
+ --j;
+ if (indicatorRect.intersects(indicatorRects[j]))
+ return true;
+ }
+
+ indicatorRects.uncheckedAppend(indicatorRect);
+ }
+
+ return false;
+}
+
+FindIndicator::FindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage)
+ : m_selectionRectInWindowCoordinates(selectionRectInWindowCoordinates)
+ , m_textRectsInSelectionRectCoordinates(textRectsInSelectionRectCoordinates)
+ , m_contentImageScaleFactor(contentImageScaleFactor)
+ , m_contentImage(contentImage)
+{
+ if (findIndicatorsForTextRectsOverlap(m_textRectsInSelectionRectCoordinates)) {
+ m_textRectsInSelectionRectCoordinates[0] = unionRect(m_textRectsInSelectionRectCoordinates);
+ m_textRectsInSelectionRectCoordinates.shrink(1);
+ }
+}
+
+FindIndicator::~FindIndicator()
+{
+}
+
+static FloatRect inflateRect(const FloatRect& rect, float inflateX, float inflateY)
+{
+ FloatRect inflatedRect = rect;
+ inflatedRect.inflateX(inflateX);
+ inflatedRect.inflateY(inflateY);
+
+ return inflatedRect;
+}
+
+FloatRect FindIndicator::frameRect() const
+{
+ return FloatRect(m_selectionRectInWindowCoordinates.x() - leftBorderThickness, m_selectionRectInWindowCoordinates.y() - topBorderThickness,
+ m_selectionRectInWindowCoordinates.width() + rightBorderThickness + leftBorderThickness,
+ m_selectionRectInWindowCoordinates.height() + topBorderThickness + bottomBorderThickness);
+}
+
+static Color lightBorderColor()
+{
+ return Color(lightBorderRed, lightBorderGreen, lightBorderBlue, lightBorderAlpha);
+}
+
+static Color shadowColor()
+{
+ return Color(shadowRed, shadowGreen, shadowBlue, shadowAlpha);
+}
+
+static Color gradientLightColor()
+{
+ return Color(gradientLightRed, gradientLightGreen, gradientLightBlue, gradientLightAlpha);
+}
+
+static Color gradientDarkColor()
+{
+ return Color(gradientDarkRed, gradientDarkGreen, gradientDarkBlue, gradientDarkAlpha);
+}
+
+static Path pathWithRoundedRect(const FloatRect& pathRect, float radius)
+{
+ Path path;
+ path.addRoundedRect(pathRect, FloatSize(radius, radius));
+
+ return path;
+}
+
+void FindIndicator::draw(GraphicsContext& graphicsContext, const IntRect& dirtyRect)
+{
+ for (size_t i = 0; i < m_textRectsInSelectionRectCoordinates.size(); ++i) {
+ FloatRect textRect = m_textRectsInSelectionRectCoordinates[i];
+ textRect.move(leftBorderThickness, topBorderThickness);
+
+ FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
+ FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
+ graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
+ graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
+ }
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
+ RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.maxY()));
+ gradient->addColorStop(0, gradientLightColor());
+ gradient->addColorStop(1, gradientDarkColor());
+ graphicsContext.setFillGradient(gradient);
+ graphicsContext.fillRect(outerPathRect);
+ }
+
+ {
+ GraphicsContextStateSaver stateSaver(graphicsContext);
+ graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness)));
+
+ IntRect contentImageRect = enclosingIntRect(m_textRectsInSelectionRectCoordinates[i]);
+ m_contentImage->paint(graphicsContext, m_contentImageScaleFactor, contentImageRect.location(), contentImageRect);
+ }
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/FindIndicator.h b/Source/WebKit2/UIProcess/FindIndicator.h
new file mode 100644
index 000000000..a34973b84
--- /dev/null
+++ b/Source/WebKit2/UIProcess/FindIndicator.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 FindIndicator_h
+#define FindIndicator_h
+
+#include "ShareableBitmap.h"
+#include <WebCore/FloatRect.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+ class GraphicsContext;
+}
+
+namespace WebKit {
+
+class FindIndicator : public RefCounted<FindIndicator> {
+public:
+ static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle);
+ ~FindIndicator();
+
+ WebCore::FloatRect selectionRectInWindowCoordinates() const { return m_selectionRectInWindowCoordinates; }
+ WebCore::FloatRect frameRect() const;
+
+ ShareableBitmap* contentImage() const { return m_contentImage.get(); }
+
+ void draw(WebCore::GraphicsContext&, const WebCore::IntRect& dirtyRect);
+
+private:
+ FindIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, float contentImageScaleFactor, PassRefPtr<ShareableBitmap> contentImage);
+
+ WebCore::FloatRect m_selectionRectInWindowCoordinates;
+ Vector<WebCore::FloatRect> m_textRectsInSelectionRectCoordinates;
+ float m_contentImageScaleFactor;
+ RefPtr<ShareableBitmap> m_contentImage;
+};
+
+} // namespace WebKit
+
+#endif // FindIndicator_h
diff --git a/Source/WebKit2/UIProcess/GenericCallback.h b/Source/WebKit2/UIProcess/GenericCallback.h
new file mode 100644
index 000000000..b0d7b9b1c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GenericCallback.h
@@ -0,0 +1,210 @@
+/*
+ * 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 GenericCallback_h
+#define GenericCallback_h
+
+#include "WKAPICast.h"
+
+#include "WebError.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class CallbackBase : public RefCounted<CallbackBase> {
+public:
+ virtual ~CallbackBase()
+ {
+ }
+
+ uint64_t callbackID() const { return m_callbackID; }
+
+protected:
+ CallbackBase(void* context)
+ : m_context(context)
+ , m_callbackID(generateCallbackID())
+ {
+ }
+
+ void* context() const { return m_context; }
+
+private:
+ static uint64_t generateCallbackID()
+ {
+ static uint64_t uniqueCallbackID = 1;
+ return uniqueCallbackID++;
+ }
+
+ void* m_context;
+ uint64_t m_callbackID;
+};
+
+class VoidCallback : public CallbackBase {
+public:
+ typedef void (*CallbackFunction)(WKErrorRef, void*);
+
+ static PassRefPtr<VoidCallback> create(void* context, CallbackFunction callback)
+ {
+ return adoptRef(new VoidCallback(context, callback));
+ }
+
+ virtual ~VoidCallback()
+ {
+ ASSERT(!m_callback);
+ }
+
+ void performCallback()
+ {
+ ASSERT(m_callback);
+
+ m_callback(0, context());
+
+ m_callback = 0;
+ }
+
+ void invalidate()
+ {
+ ASSERT(m_callback);
+
+ RefPtr<WebError> error = WebError::create();
+ m_callback(toAPI(error.get()), context());
+
+ m_callback = 0;
+ }
+
+private:
+ VoidCallback(void* context, CallbackFunction callback)
+ : CallbackBase(context)
+ , m_callback(callback)
+ {
+ }
+
+ CallbackFunction m_callback;
+};
+
+template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType>
+class GenericCallback : public CallbackBase {
+public:
+ typedef void (*CallbackFunction)(APIReturnValueType, WKErrorRef, void*);
+
+ static PassRefPtr<GenericCallback> create(void* context, CallbackFunction callback)
+ {
+ return adoptRef(new GenericCallback(context, callback));
+ }
+
+ virtual ~GenericCallback()
+ {
+ ASSERT(!m_callback);
+ }
+
+ void performCallbackWithReturnValue(InternalReturnValueType returnValue)
+ {
+ ASSERT(m_callback);
+
+ m_callback(toAPI(returnValue), 0, context());
+
+ m_callback = 0;
+ }
+
+ void invalidate()
+ {
+ ASSERT(m_callback);
+
+ RefPtr<WebError> error = WebError::create();
+ m_callback(0, toAPI(error.get()), context());
+
+ m_callback = 0;
+ }
+
+private:
+ GenericCallback(void* context, CallbackFunction callback)
+ : CallbackBase(context)
+ , m_callback(callback)
+ {
+ }
+
+ CallbackFunction m_callback;
+};
+
+// FIXME: Make a version of CallbackBase with two arguments, and define ComputedPagesCallback as a specialization.
+class ComputedPagesCallback : public CallbackBase {
+public:
+ typedef void (*CallbackFunction)(const Vector<WebCore::IntRect>&, double, WKErrorRef, void*);
+
+ static PassRefPtr<ComputedPagesCallback> create(void* context, CallbackFunction callback)
+ {
+ return adoptRef(new ComputedPagesCallback(context, callback));
+ }
+
+ virtual ~ComputedPagesCallback()
+ {
+ ASSERT(!m_callback);
+ }
+
+ void performCallbackWithReturnValue(const Vector<WebCore::IntRect>& returnValue1, double returnValue2)
+ {
+ ASSERT(m_callback);
+
+ m_callback(returnValue1, returnValue2, 0, context());
+
+ m_callback = 0;
+ }
+
+ void invalidate()
+ {
+ ASSERT(m_callback);
+
+ RefPtr<WebError> error = WebError::create();
+ m_callback(Vector<WebCore::IntRect>(), 0, toAPI(error.get()), context());
+
+ m_callback = 0;
+ }
+
+private:
+
+ ComputedPagesCallback(void* context, CallbackFunction callback)
+ : CallbackBase(context)
+ , m_callback(callback)
+ {
+ }
+
+ CallbackFunction m_callback;
+};
+
+template<typename T>
+void invalidateCallbackMap(HashMap<uint64_t, T>& map)
+{
+ Vector<T> callbacksVector;
+ copyValuesToVector(map, callbacksVector);
+ for (size_t i = 0, size = callbacksVector.size(); i < size; ++i)
+ callbacksVector[i]->invalidate();
+ map.clear();
+}
+
+} // namespace WebKit
+
+#endif // GenericCallback_h
diff --git a/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp
new file mode 100644
index 000000000..38bbd6a16
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "GeolocationPermissionRequestManagerProxy.h"
+
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+GeolocationPermissionRequestManagerProxy::GeolocationPermissionRequestManagerProxy(WebPageProxy* page)
+ : m_page(page)
+{
+}
+
+void GeolocationPermissionRequestManagerProxy::invalidateRequests()
+{
+ PendingRequestMap::const_iterator it = m_pendingRequests.begin();
+ PendingRequestMap::const_iterator end = m_pendingRequests.end();
+ for (; it != end; ++it)
+ it->second->invalidate();
+
+ m_pendingRequests.clear();
+}
+
+PassRefPtr<GeolocationPermissionRequestProxy> GeolocationPermissionRequestManagerProxy::createRequest(uint64_t geolocationID)
+{
+ RefPtr<GeolocationPermissionRequestProxy> request = GeolocationPermissionRequestProxy::create(this, geolocationID);
+ m_pendingRequests.add(geolocationID, request.get());
+ return request.release();
+}
+
+void GeolocationPermissionRequestManagerProxy::didReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed)
+{
+ if (!m_page->isValid())
+ return;
+
+ PendingRequestMap::iterator it = m_pendingRequests.find(geolocationID);
+ if (it == m_pendingRequests.end())
+ return;
+
+ m_page->process()->send(Messages::WebPage::DidReceiveGeolocationPermissionDecision(geolocationID, allowed), m_page->pageID());
+ m_pendingRequests.remove(it);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.h b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.h
new file mode 100644
index 000000000..98885bf07
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.h
@@ -0,0 +1,56 @@
+/*
+ * 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 GeolocationPermissionRequestManagerProxy_h
+#define GeolocationPermissionRequestManagerProxy_h
+
+#include "GeolocationPermissionRequestProxy.h"
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class GeolocationPermissionRequestManagerProxy {
+public:
+ explicit GeolocationPermissionRequestManagerProxy(WebPageProxy*);
+
+ void invalidateRequests();
+
+ // Create a request to be presented to the user.
+ PassRefPtr<GeolocationPermissionRequestProxy> createRequest(uint64_t geolocationID);
+
+ // Called by GeolocationPermissionRequestProxy when a decision is made by the user.
+ void didReceiveGeolocationPermissionDecision(uint64_t, bool allow);
+
+private:
+ typedef HashMap<uint64_t, RefPtr<GeolocationPermissionRequestProxy> > PendingRequestMap;
+ PendingRequestMap m_pendingRequests;
+ WebPageProxy* m_page;
+};
+
+} // namespace WebKit
+
+#endif // GeolocationPermissionRequestManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp b/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp
new file mode 100644
index 000000000..4cd173678
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "GeolocationPermissionRequestProxy.h"
+
+#include "GeolocationPermissionRequestManagerProxy.h"
+
+namespace WebKit {
+
+GeolocationPermissionRequestProxy::GeolocationPermissionRequestProxy(GeolocationPermissionRequestManagerProxy* manager, uint64_t geolocationID)
+ : m_manager(manager)
+ , m_geolocationID(geolocationID)
+{
+}
+
+void GeolocationPermissionRequestProxy::allow()
+{
+ if (!m_manager)
+ return;
+
+ m_manager->didReceiveGeolocationPermissionDecision(m_geolocationID, true);
+ m_manager = 0;
+}
+
+void GeolocationPermissionRequestProxy::deny()
+{
+ if (!m_manager)
+ return;
+
+ m_manager->didReceiveGeolocationPermissionDecision(m_geolocationID, false);
+ m_manager = 0;
+}
+
+void GeolocationPermissionRequestProxy::invalidate()
+{
+ m_manager = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.h b/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.h
new file mode 100644
index 000000000..c34c3fd3c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.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 GeolocationPermissionRequestProxy_h
+#define GeolocationPermissionRequestProxy_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class GeolocationPermissionRequestManagerProxy;
+
+class GeolocationPermissionRequestProxy : public APIObject {
+public:
+ static const Type APIType = TypeGeolocationPermissionRequest;
+
+ static PassRefPtr<GeolocationPermissionRequestProxy> create(GeolocationPermissionRequestManagerProxy* manager, uint64_t geolocationID)
+ {
+ return adoptRef(new GeolocationPermissionRequestProxy(manager, geolocationID));
+ }
+
+ void allow();
+ void deny();
+
+ void invalidate();
+
+private:
+ GeolocationPermissionRequestProxy(GeolocationPermissionRequestManagerProxy*, uint64_t geolocationID);
+
+ virtual Type type() const { return APIType; }
+
+ GeolocationPermissionRequestManagerProxy* m_manager;
+ uint64_t m_geolocationID;
+};
+
+} // namespace WebKit
+
+#endif // GeolocationPermissionRequestProxy_h
diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
new file mode 100644
index 000000000..e53d4156b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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 "ProcessLauncher.h"
+
+#include "WorkQueue.h"
+#include <wtf/StdLibExtras.h>
+
+namespace WebKit {
+
+static WorkQueue& processLauncherWorkQueue()
+{
+ DEFINE_STATIC_LOCAL(WorkQueue, processLauncherWorkQueue, ("com.apple.WebKit.ProcessLauncher"));
+ return processLauncherWorkQueue;
+}
+
+ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOptions)
+ : m_client(client)
+ , m_launchOptions(launchOptions)
+ , m_processIdentifier(0)
+{
+ // Launch the process.
+ m_isLaunching = true;
+ processLauncherWorkQueue().dispatch(bind(&ProcessLauncher::launchProcess, this));
+}
+
+void ProcessLauncher::didFinishLaunchingProcess(PlatformProcessIdentifier processIdentifier, CoreIPC::Connection::Identifier identifier)
+{
+ m_processIdentifier = processIdentifier;
+ m_isLaunching = false;
+
+ if (!m_client) {
+ // FIXME: Dispose of the connection identifier.
+ return;
+ }
+
+ m_client->didFinishLaunching(this, identifier);
+}
+
+void ProcessLauncher::invalidate()
+{
+ m_client = 0;
+ platformInvalidate();
+}
+
+const char* ProcessLauncher::processTypeAsString(ProcessType processType)
+{
+ switch (processType) {
+ case WebProcess:
+ return "webprocess";
+ case PluginProcess:
+ return "pluginprocess";
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+bool ProcessLauncher::getProcessTypeFromString(const char* string, ProcessType& processType)
+{
+ if (!strcmp(string, "webprocess")) {
+ processType = WebProcess;
+ return true;
+ }
+
+ if (!strcmp(string, "pluginprocess")) {
+ processType = PluginProcess;
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h
new file mode 100644
index 000000000..8dbfb1101
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.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 WebProcessLauncher_h
+#define WebProcessLauncher_h
+
+#include "Connection.h"
+#include "PlatformProcessIdentifier.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
+
+#if PLATFORM(QT)
+class QLocalSocket;
+#endif
+
+namespace WebKit {
+
+class ProcessLauncher : public ThreadSafeRefCounted<ProcessLauncher> {
+public:
+ class Client {
+ public:
+ virtual ~Client() { }
+
+ virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier) = 0;
+ };
+
+ enum ProcessType {
+ WebProcess,
+ PluginProcess
+ };
+
+ struct LaunchOptions {
+ ProcessType processType;
+#if PLATFORM(MAC)
+ static const cpu_type_t MatchCurrentArchitecture = 0;
+ cpu_type_t architecture;
+ bool executableHeap;
+#endif
+ };
+
+ static PassRefPtr<ProcessLauncher> create(Client* client, const LaunchOptions& launchOptions)
+ {
+ return adoptRef(new ProcessLauncher(client, launchOptions));
+ }
+
+ bool isLaunching() const { return m_isLaunching; }
+ PlatformProcessIdentifier processIdentifier() const { return m_processIdentifier; }
+
+ void terminateProcess();
+ void invalidate();
+
+ static bool getProcessTypeFromString(const char*, ProcessType&);
+
+private:
+ ProcessLauncher(Client*, const LaunchOptions& launchOptions);
+
+ static const char* processTypeAsString(ProcessType);
+
+ void launchProcess();
+ void didFinishLaunchingProcess(PlatformProcessIdentifier, CoreIPC::Connection::Identifier);
+
+ void platformInvalidate();
+
+ Client* m_client;
+
+ const LaunchOptions m_launchOptions;
+ bool m_isLaunching;
+ PlatformProcessIdentifier m_processIdentifier;
+};
+
+} // namespace WebKit
+
+#endif // WebProcessLauncher_h
diff --git a/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp
new file mode 100644
index 000000000..3c0fbf160
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+
+namespace WebKit {
+
+ThreadLauncher::ThreadLauncher(Client* client)
+ : m_client(client)
+{
+ launchThread();
+}
+
+void ThreadLauncher::launchThread()
+{
+ m_isLaunching = true;
+
+ CoreIPC::Connection::Identifier connectionIdentifier = createWebThread();
+
+ // We've finished launching the thread, message back to the main run loop.
+ RunLoop::main()->dispatch(bind(&ThreadLauncher::didFinishLaunchingThread, this, connectionIdentifier));
+}
+
+void ThreadLauncher::didFinishLaunchingThread(CoreIPC::Connection::Identifier identifier)
+{
+ m_isLaunching = false;
+
+ if (!m_client) {
+ // FIXME: Dispose of the connection identifier.
+ return;
+ }
+
+ m_client->didFinishLaunching(this, identifier);
+}
+
+void ThreadLauncher::invalidate()
+{
+ m_client = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h
new file mode 100644
index 000000000..f3a5312a2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h
@@ -0,0 +1,71 @@
+/*
+ * 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 ThreadLauncher_h
+#define ThreadLauncher_h
+
+#include "Connection.h"
+#include "PlatformProcessIdentifier.h"
+#include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
+
+#if PLATFORM(QT)
+class QLocalSocket;
+#endif
+
+namespace WebKit {
+
+class ThreadLauncher : public ThreadSafeRefCounted<ThreadLauncher> {
+public:
+ class Client {
+ public:
+ virtual ~Client() { }
+ virtual void didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier) = 0;
+ };
+
+ static PassRefPtr<ThreadLauncher> create(Client* client)
+ {
+ return adoptRef(new ThreadLauncher(client));
+ }
+
+ bool isLaunching() const { return m_isLaunching; }
+
+ void invalidate();
+
+private:
+ explicit ThreadLauncher(Client*);
+
+ void launchThread();
+ void didFinishLaunchingThread(CoreIPC::Connection::Identifier);
+
+ static CoreIPC::Connection::Identifier createWebThread();
+
+ bool m_isLaunching;
+ Client* m_client;
+};
+
+} // namespace WebKit
+
+#endif // ThreadLauncher_h
diff --git a/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp b/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
new file mode 100644
index 000000000..d7a50829d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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 MOTOROLA 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 MOTOROLA 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 "ProcessLauncher.h"
+
+#include "Connection.h"
+#include "RunLoop.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/ResourceHandle.h>
+#include <errno.h>
+#if OS(LINUX)
+#include <sys/prctl.h>
+#endif
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/gobject/GlibUtilities.h>
+
+#ifdef SOCK_SEQPACKET
+#define SOCKET_TYPE SOCK_SEQPACKET
+#else
+#define SOCKET_TYPE SOCK_STREAM
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const char* gWebKitWebProcessName = "WebKitWebProcess";
+const char* gWebKitPluginProcessName = "WebKitPluginProcess";
+
+static void childSetupFunction(gpointer userData)
+{
+ int socket = GPOINTER_TO_INT(userData);
+ close(socket);
+
+#if OS(LINUX)
+ // Kill child process when parent dies.
+ prctl(PR_SET_PDEATHSIG, SIGKILL);
+#endif
+}
+
+static void childFinishedFunction(GPid, gint status, gpointer userData)
+{
+ if (WIFEXITED(status) && !WEXITSTATUS(status))
+ return;
+
+ close(GPOINTER_TO_INT(userData));
+}
+
+static CString findWebKitProcess(const char* processName)
+{
+ const char* execDirectory = g_getenv("WEBKIT_EXEC_PATH");
+ if (execDirectory) {
+ String processPath = pathByAppendingComponent(filenameToString(execDirectory), processName);
+ if (fileExists(processPath))
+ return fileSystemRepresentation(processPath);
+ }
+
+ static bool gotExecutablePath = false;
+ static String executablePath;
+ if (!gotExecutablePath) {
+ gotExecutablePath = true;
+
+ CString executableFile = getCurrentExecutablePath();
+ if (!executableFile.isNull())
+ executablePath = directoryName(filenameToString(executableFile.data()));
+ }
+
+ if (!executablePath.isNull()) {
+ String processPath = pathByAppendingComponent(executablePath, processName);
+ if (fileExists(processPath))
+ return fileSystemRepresentation(processPath);
+ }
+
+ return fileSystemRepresentation(pathByAppendingComponent(filenameToString(LIBEXECDIR), processName));
+}
+
+void ProcessLauncher::launchProcess()
+{
+ GPid pid = 0;
+
+ int sockets[2];
+ if (socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) < 0) {
+ g_printerr("Creation of socket failed: %s.\n", g_strerror(errno));
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ CString binaryPath = findWebKitProcess(m_launchOptions.processType == ProcessLauncher::WebProcess ? gWebKitWebProcessName : gWebKitPluginProcessName);
+ GOwnPtr<gchar> socket(g_strdup_printf("%d", sockets[0]));
+ char* argv[3];
+ argv[0] = const_cast<char*>(binaryPath.data());
+ argv[1] = socket.get();
+ argv[2] = 0;
+
+ GOwnPtr<GError> error;
+ int spawnFlags = G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_DO_NOT_REAP_CHILD;
+ if (!g_spawn_async(0, argv, 0, static_cast<GSpawnFlags>(spawnFlags), childSetupFunction, GINT_TO_POINTER(sockets[1]), &pid, &error.outPtr())) {
+ g_printerr("Unable to fork a new WebProcess: %s.\n", error->message);
+ ASSERT_NOT_REACHED();
+ }
+
+ close(sockets[0]);
+ m_processIdentifier = pid;
+
+ // Monitor the child process, it calls waitpid to prevent the child process from becomming a zombie,
+ // and it allows us to close the socket when the child process crashes.
+ g_child_watch_add(m_processIdentifier, childFinishedFunction, GINT_TO_POINTER(sockets[1]));
+
+ // We've finished launching the process, message back to the main run loop.
+ RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, m_processIdentifier, sockets[1]));
+}
+
+void ProcessLauncher::terminateProcess()
+{
+ if (!m_processIdentifier)
+ return;
+
+ kill(m_processIdentifier, SIGKILL);
+}
+
+void ProcessLauncher::platformInvalidate()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp b/Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp
new file mode 100644
index 000000000..84f72b54d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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 "ThreadLauncher.h"
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+ notImplemented();
+ return -1;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.h b/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.h
new file mode 100644
index 000000000..311e59087
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.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 DynamicLinkerEnvironmentExtractor_h
+#define DynamicLinkerEnvironmentExtractor_h
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+
+#include <mach/machine.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+
+namespace WebKit {
+
+class EnvironmentVariables;
+
+class DynamicLinkerEnvironmentExtractor {
+ WTF_MAKE_NONCOPYABLE(DynamicLinkerEnvironmentExtractor);
+
+public:
+ DynamicLinkerEnvironmentExtractor(NSString *executablePath, cpu_type_t architecture);
+
+ void getExtractedEnvironmentVariables(EnvironmentVariables&) const;
+
+private:
+ void processSingleArchitecture(const void* data, size_t length);
+ void processFatFile(const void* data, size_t length);
+ void processLoadCommands(const void* data, size_t length, int32_t numberOfCommands, bool shouldByteSwap);
+ size_t processLoadCommand(const void* data, size_t length, bool shouldByteSwap);
+ void processEnvironmentVariable(const char* environmentString);
+
+ RetainPtr<NSString> m_executablePath;
+ cpu_type_t m_architecture;
+
+ Vector<std::pair<CString, CString> > m_extractedVariables;
+};
+
+} // namespace WebKit
+
+#endif // BUILDING_ON_SNOW_LEOPARD
+
+#endif // DynamicLinkerEnvironmentExtractor_h
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.mm b/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.mm
new file mode 100644
index 000000000..70dccc58a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/DynamicLinkerEnvironmentExtractor.mm
@@ -0,0 +1,204 @@
+/*
+ * 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 "DynamicLinkerEnvironmentExtractor.h"
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+
+#include "EnvironmentVariables.h"
+#include <mach-o/loader.h>
+#include <mach-o/swap.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+DynamicLinkerEnvironmentExtractor::DynamicLinkerEnvironmentExtractor(NSString *executablePath, cpu_type_t architecture)
+ : m_executablePath(executablePath)
+ , m_architecture(architecture)
+{
+ NSData *mainExecutableData = [NSData dataWithContentsOfFile:m_executablePath.get() options:NSDataReadingMappedIfSafe error:0];
+ if (!mainExecutableData)
+ return;
+
+ const void* mainExecutableBytes = [mainExecutableData bytes];
+ size_t length = [mainExecutableData length];
+ if (length < sizeof(uint32_t))
+ return;
+
+ uint32_t magicValue = *static_cast<const uint32_t*>(mainExecutableBytes);
+ if (magicValue == FAT_MAGIC || magicValue == FAT_CIGAM) {
+ processFatFile(mainExecutableBytes, length);
+ return;
+ }
+
+ processSingleArchitecture(mainExecutableBytes, length);
+}
+
+#define DEFINE_BYTE_SWAPPER(type) inline type byteSwapIfNeeded(const type& data, bool shouldByteSwap) \
+{ \
+ type swapped = data; \
+ if (shouldByteSwap) \
+ swap_##type(&swapped, NX_UnknownByteOrder); \
+ return swapped; \
+}
+
+DEFINE_BYTE_SWAPPER(load_command)
+DEFINE_BYTE_SWAPPER(dylinker_command)
+DEFINE_BYTE_SWAPPER(mach_header)
+DEFINE_BYTE_SWAPPER(mach_header_64)
+
+#undef DEFINE_BYTE_SWAPPER
+
+void DynamicLinkerEnvironmentExtractor::processEnvironmentVariable(const char* environmentString)
+{
+ const char* equalsLocation = strchr(environmentString, '=');
+ if (!equalsLocation)
+ return;
+
+ size_t nameLength = equalsLocation - environmentString;
+ String name(environmentString, nameLength);
+
+ // LC_DYLD_ENVIRONMENT only respects DYLD_*_PATH variables.
+ if (!name.startsWith("DYLD_") || !name.endsWith("_PATH"))
+ return;
+
+ CString value(equalsLocation + 1);
+ m_extractedVariables.append(make_pair(name.latin1(), value));
+}
+
+size_t DynamicLinkerEnvironmentExtractor::processLoadCommand(const void* data, size_t length, bool shouldByteSwap)
+{
+ if (length < sizeof(load_command))
+ return 0;
+
+ const load_command* rawLoadCommand = static_cast<const load_command*>(data);
+ load_command loadCommand = byteSwapIfNeeded(*rawLoadCommand, shouldByteSwap);
+
+ if (length < loadCommand.cmdsize)
+ return 0;
+
+ if (loadCommand.cmd == LC_DYLD_ENVIRONMENT) {
+ if (length < sizeof(dylinker_command))
+ return 0;
+
+ dylinker_command environmentCommand = byteSwapIfNeeded(*reinterpret_cast<const dylinker_command*>(rawLoadCommand), shouldByteSwap);
+ if (loadCommand.cmdsize < environmentCommand.name.offset)
+ return 0;
+
+ size_t environmentStringLength = loadCommand.cmdsize - environmentCommand.name.offset;
+ Vector<char, 256> environmentString;
+ environmentString.reserveCapacity(environmentStringLength + 1);
+ environmentString.append(reinterpret_cast<const char*>(rawLoadCommand) + environmentCommand.name.offset, environmentStringLength);
+ environmentString.append(0);
+
+ processEnvironmentVariable(environmentString.data());
+ }
+
+ return loadCommand.cmdsize;
+}
+
+void DynamicLinkerEnvironmentExtractor::processLoadCommands(const void* data, size_t length, int32_t numberOfCommands, bool shouldByteSwap)
+{
+ const void* dataRemaining = data;
+ size_t lengthRemaining = length;
+ for (int i = 0; i < numberOfCommands; i++) {
+ size_t commandLength = processLoadCommand(dataRemaining, lengthRemaining, shouldByteSwap);
+ if (!commandLength || lengthRemaining < commandLength)
+ return;
+
+ dataRemaining = static_cast<const char*>(dataRemaining) + commandLength;
+ lengthRemaining -= commandLength;
+ }
+}
+
+void DynamicLinkerEnvironmentExtractor::processSingleArchitecture(const void* data, size_t length)
+{
+ if (length < sizeof(mach_header))
+ return;
+
+ const mach_header* header = static_cast<const mach_header*>(data);
+ if (header->magic == MH_MAGIC || header->magic == MH_CIGAM) {
+ bool shouldByteSwap = header->magic == MH_CIGAM;
+ mach_header swappedHeader = byteSwapIfNeeded(*header, shouldByteSwap);
+ if (swappedHeader.cputype == m_architecture)
+ processLoadCommands(static_cast<const char*>(data) + sizeof(*header), length - sizeof(*header), swappedHeader.ncmds, shouldByteSwap);
+ return;
+ }
+
+ if (length < sizeof(mach_header_64))
+ return;
+
+ const mach_header_64* header64 = static_cast<const mach_header_64*>(data);
+ bool shouldByteSwap = header->magic == MH_CIGAM_64;
+ mach_header_64 swappedHeader64 = byteSwapIfNeeded(*header64, shouldByteSwap);
+ if (swappedHeader64.cputype == m_architecture)
+ processLoadCommands(static_cast<const char*>(data) + sizeof(*header64), length - sizeof(*header64), swappedHeader64.ncmds, shouldByteSwap);
+}
+
+void DynamicLinkerEnvironmentExtractor::processFatFile(const void* data, size_t length)
+{
+ if (length < sizeof(fat_header))
+ return;
+
+ const fat_header* header = static_cast<const fat_header*>(data);
+
+ size_t numberOfArchitectures = OSSwapBigToHostInt32(header->nfat_arch);
+
+ // Ensure that we have enough data remaining for numberOfArchitectures fat_arch structs.
+ if ((length - sizeof(fat_header)) / sizeof(fat_arch) < numberOfArchitectures)
+ return;
+
+ const fat_arch* archs = reinterpret_cast<const fat_arch*>(reinterpret_cast<const char*>(data) + sizeof(*header));
+ for (uint32_t i = 0; i < numberOfArchitectures; i++) {
+ uint32_t architectureOffset = OSSwapBigToHostInt32(archs[i].offset);
+ uint32_t architectureSize = OSSwapBigToHostInt32(archs[i].size);
+ if (length < architectureOffset + architectureSize)
+ return;
+
+ processSingleArchitecture(static_cast<const char*>(data) + architectureOffset, architectureSize);
+ }
+}
+
+void DynamicLinkerEnvironmentExtractor::getExtractedEnvironmentVariables(EnvironmentVariables& environmentVariables) const
+{
+ size_t extractedVariableCount = m_extractedVariables.size();
+ for (size_t i = 0; i < extractedVariableCount; ++i) {
+ const CString& name = m_extractedVariables[i].first;
+
+ // Preserve any existing environment variable by this name so that it will take
+ // precedence over what we extracted from the executable file.
+ if (environmentVariables.get(name.data()))
+ continue;
+
+ environmentVariables.set(name.data(), m_extractedVariables[i].second.data());
+ }
+}
+
+} // namespace WebKit
+
+#endif // BUILDING_ON_SNOW_LEOPARD
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.cpp b/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.cpp
new file mode 100644
index 000000000..72979f8f7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.cpp
@@ -0,0 +1,153 @@
+/*
+ * 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 "EnvironmentVariables.h"
+
+#include <crt_externs.h>
+
+namespace WebKit {
+
+EnvironmentVariables::EnvironmentVariables()
+ : m_environmentPointer(*_NSGetEnviron())
+{
+}
+
+EnvironmentVariables::~EnvironmentVariables()
+{
+ size_t size = m_allocatedStrings.size();
+ for (size_t i = 0; i < size; ++i)
+ fastFree(m_allocatedStrings[i]);
+}
+
+void EnvironmentVariables::set(const char* name, const char* value)
+{
+ // Check if we need to copy the environment.
+ if (m_environmentPointer == *_NSGetEnviron())
+ copyEnvironmentVariables();
+
+ // Allocate a string for the name and value.
+ const char* nameAndValue = createStringForVariable(name, value);
+
+ for (size_t i = 0; i < m_environmentVariables.size() - 1; ++i) {
+ if (valueIfVariableHasName(m_environmentVariables[i], name)) {
+ // Just replace the environment variable.
+ m_environmentVariables[i] = const_cast<char*>(nameAndValue);
+ return;
+ }
+ }
+
+ // Append the new string.
+ ASSERT(!m_environmentVariables.last());
+ m_environmentVariables.last() = const_cast<char*>(nameAndValue);
+ m_environmentVariables.append(static_cast<char*>(0));
+
+ m_environmentPointer = m_environmentVariables.data();
+}
+
+const char* EnvironmentVariables::get(const char* name) const
+{
+ for (size_t i = 0; m_environmentPointer[i]; ++i) {
+ if (const char* value = valueIfVariableHasName(m_environmentPointer[i], name))
+ return value;
+ }
+ return 0;
+}
+
+void EnvironmentVariables::appendValue(const char* name, const char* value, char separator)
+{
+ const char* existingValue = get(name);
+ if (!existingValue) {
+ set(name, value);
+ return;
+ }
+
+ Vector<char, 128> newValue;
+ newValue.append(existingValue, strlen(existingValue));
+ newValue.append(separator);
+ newValue.append(value, strlen(value) + 1);
+
+ set(name, newValue.data());
+}
+
+const char* EnvironmentVariables::valueIfVariableHasName(const char* environmentVariable, const char* name) const
+{
+ // Find the environment variable name.
+ const char* equalsLocation = strchr(environmentVariable, '=');
+ ASSERT(equalsLocation);
+
+ size_t nameLength = equalsLocation - environmentVariable;
+ if (strlen(name) != nameLength)
+ return 0;
+ if (memcmp(environmentVariable, name, nameLength))
+ return 0;
+
+ return equalsLocation + 1;
+}
+
+const char* EnvironmentVariables::createStringForVariable(const char* name, const char* value)
+{
+ int nameLength = strlen(name);
+ int valueLength = strlen(value);
+
+ // Allocate enough room to hold 'name=value' and the null character.
+ char* string = static_cast<char*>(fastMalloc(nameLength + 1 + valueLength + 1));
+ memcpy(string, name, nameLength);
+ string[nameLength] = '=';
+ memcpy(string + nameLength + 1, value, valueLength);
+ string[nameLength + 1 + valueLength] = '\0';
+
+ m_allocatedStrings.append(string);
+
+ return string;
+}
+
+void EnvironmentVariables::copyEnvironmentVariables()
+{
+ for (size_t i = 0; (*_NSGetEnviron())[i]; i++)
+ m_environmentVariables.append((*_NSGetEnviron())[i]);
+
+ // Null-terminate the array.
+ m_environmentVariables.append(static_cast<char*>(0));
+
+ // Update the environment pointer.
+ m_environmentPointer = m_environmentVariables.data();
+}
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+
+const char* EnvironmentVariables::preexistingProcessServiceNameKey()
+{
+ return "WEBKIT_PREEXISTING_PROCESS_SERVICE_NAME";
+}
+
+const char* EnvironmentVariables::preexistingProcessTypeKey()
+{
+ return "WEBKIT_PREEXISTING_PROCESS_TYPE";
+}
+
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD)
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.h b/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.h
new file mode 100644
index 000000000..33829398d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/EnvironmentVariables.h
@@ -0,0 +1,68 @@
+/*
+ * 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 EnvironmentVariables_h
+#define EnvironmentVariables_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class EnvironmentVariables {
+ WTF_MAKE_NONCOPYABLE(EnvironmentVariables);
+
+public:
+ EnvironmentVariables();
+ ~EnvironmentVariables();
+
+ void set(const char* name, const char* value);
+ const char* get(const char* name) const;
+
+ // Will append the value with the given separator if the environment variable already exists.
+ void appendValue(const char* name, const char* value, char separator);
+
+ char** environmentPointer() const { return m_environmentPointer; }
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ static const char* preexistingProcessServiceNameKey();
+ static const char* preexistingProcessTypeKey();
+#endif
+
+private:
+ const char* valueIfVariableHasName(const char* environmentVariable, const char* name) const;
+ const char* createStringForVariable(const char* name, const char* value);
+ void copyEnvironmentVariables();
+
+ char** m_environmentPointer;
+ Vector<char*> m_environmentVariables;
+
+ // These allocated strings will be freed in the destructor.
+ Vector<char*> m_allocatedStrings;
+};
+
+} // namespace WebKit
+
+#endif // EnvironmentVariables_h
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
new file mode 100644
index 000000000..c70f62edf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2010, 2011, 2012 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 "ProcessLauncher.h"
+
+#import "DynamicLinkerEnvironmentExtractor.h"
+#import "EnvironmentVariables.h"
+#import "RunLoop.h"
+#import "WebProcess.h"
+#import "WebKitSystemInterface.h"
+#import <crt_externs.h>
+#import <mach-o/dyld.h>
+#import <mach/machine.h>
+#import <runtime/InitializeThreading.h>
+#import <servers/bootstrap.h>
+#import <spawn.h>
+#import <sys/param.h>
+#import <sys/stat.h>
+#import <wtf/PassRefPtr.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/Threading.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+// FIXME: We should be doing this another way.
+extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, uint64_t);
+
+namespace WebKit {
+
+static void setUpTerminationNotificationHandler(pid_t pid)
+{
+#if HAVE(DISPATCH_H)
+ dispatch_source_t processDiedSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_PROC, pid, DISPATCH_PROC_EXIT, dispatch_get_current_queue());
+ dispatch_source_set_event_handler(processDiedSource, ^{
+ int status;
+ waitpid(dispatch_source_get_handle(processDiedSource), &status, 0);
+ dispatch_source_cancel(processDiedSource);
+ });
+ dispatch_source_set_cancel_handler(processDiedSource, ^{
+ dispatch_release(processDiedSource);
+ });
+ dispatch_resume(processDiedSource);
+#endif
+}
+
+void ProcessLauncher::launchProcess()
+{
+ // Create the listening port.
+ mach_port_t listeningPort;
+ mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+
+ // Insert a send right so we can send to it.
+ mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+
+ pid_t processIdentifier = 0;
+
+ EnvironmentVariables environmentVariables;
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ static const char* preexistingProcessServiceName = environmentVariables.get(EnvironmentVariables::preexistingProcessServiceNameKey());
+ ProcessType preexistingProcessType;
+ if (preexistingProcessServiceName)
+ getProcessTypeFromString(environmentVariables.get(EnvironmentVariables::preexistingProcessTypeKey()), preexistingProcessType);
+
+ bool usePreexistingProcess = preexistingProcessServiceName && preexistingProcessType == m_launchOptions.processType;
+
+ if (usePreexistingProcess) {
+ mach_port_t lookupPort;
+ bootstrap_look_up(bootstrap_port, preexistingProcessServiceName, &lookupPort);
+
+ mach_msg_header_t header;
+ header.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND);
+ header.msgh_id = 0;
+ header.msgh_local_port = listeningPort;
+ header.msgh_remote_port = lookupPort;
+ header.msgh_size = sizeof(header);
+ kern_return_t kr = mach_msg(&header, MACH_SEND_MSG, sizeof(header), 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+
+ if (kr) {
+ LOG_ERROR("Failed to pick up preexisting process at %s (%x). Launching a new process of type %s instead.", preexistingProcessServiceName, kr, processTypeAsString(m_launchOptions.processType));
+ usePreexistingProcess = false;
+ }
+
+ mach_port_deallocate(mach_task_self(), lookupPort);
+
+ preexistingProcessServiceName = 0;
+ }
+
+ if (!usePreexistingProcess) {
+#endif
+ NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"];
+ NSString *frameworksPath = [[webKit2Bundle bundlePath] stringByDeletingLastPathComponent];
+ const char* frameworkExecutablePath = [[webKit2Bundle executablePath] fileSystemRepresentation];
+
+ NSString *processPath;
+ if (m_launchOptions.processType == ProcessLauncher::PluginProcess)
+ processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"PluginProcess.app"];
+ else
+ processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"WebProcess.app"];
+
+ NSString *processAppExecutablePath = [[NSBundle bundleWithPath:processPath] executablePath];
+
+ RetainPtr<CFStringRef> cfLocalization(AdoptCF, WKCopyCFLocalizationPreferredName(NULL));
+ CString localization = String(cfLocalization.get()).utf8();
+
+ // Make a unique, per pid, per process launcher web process service name.
+ CString serviceName = String::format("com.apple.WebKit.WebProcess-%d-%p", getpid(), this).utf8();
+
+ const char* args[] = { [processAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-localization", localization.data(), 0 };
+
+ // Register ourselves.
+ kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.data()), listeningPort, 0);
+ ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+
+ posix_spawnattr_t attr;
+ posix_spawnattr_init(&attr);
+
+ short flags = 0;
+
+ // We want our process to receive all signals.
+ sigset_t signalMaskSet;
+ sigemptyset(&signalMaskSet);
+
+ posix_spawnattr_setsigmask(&attr, &signalMaskSet);
+ flags |= POSIX_SPAWN_SETSIGMASK;
+
+ // Determine the architecture to use.
+ cpu_type_t architecture = m_launchOptions.architecture;
+ if (architecture == LaunchOptions::MatchCurrentArchitecture)
+ architecture = _NSGetMachExecuteHeader()->cputype;
+
+ cpu_type_t cpuTypes[] = { architecture };
+ size_t outCount = 0;
+ posix_spawnattr_setbinpref_np(&attr, 1, cpuTypes, &outCount);
+
+ // Start suspended so we can set up the termination notification handler.
+ flags |= POSIX_SPAWN_START_SUSPENDED;
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+ static const int allowExecutableHeapFlag = 0x2000;
+ if (m_launchOptions.executableHeap)
+ flags |= allowExecutableHeapFlag;
+#endif
+
+ posix_spawnattr_setflags(&attr, flags);
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+ DynamicLinkerEnvironmentExtractor environmentExtractor([[NSBundle mainBundle] executablePath], architecture);
+ environmentExtractor.getExtractedEnvironmentVariables(environmentVariables);
+#endif
+
+ // To make engineering builds work, if the path is outside of /System set up
+ // DYLD_FRAMEWORK_PATH to pick up other frameworks, but don't do it for the
+ // production configuration because it involves extra file system access.
+ if (![frameworksPath hasPrefix:@"/System/"])
+ environmentVariables.appendValue("DYLD_FRAMEWORK_PATH", [frameworksPath fileSystemRepresentation], ':');
+
+ NSString *processShimPathNSString = nil;
+ if (m_launchOptions.processType == ProcessLauncher::PluginProcess)
+ processShimPathNSString = [[processAppExecutablePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"PluginProcessShim.dylib"];
+ else if (m_launchOptions.processType == ProcessLauncher::WebProcess)
+ processShimPathNSString = [[processAppExecutablePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"WebProcessShim.dylib"];
+
+ // Make sure that the shim library file exists and insert it.
+ if (processShimPathNSString) {
+ const char* processShimPath = [processShimPathNSString fileSystemRepresentation];
+ struct stat statBuf;
+ if (stat(processShimPath, &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG)
+ environmentVariables.appendValue("DYLD_INSERT_LIBRARIES", processShimPath, ':');
+ }
+
+ int result = posix_spawn(&processIdentifier, args[0], 0, &attr, const_cast<char**>(args), environmentVariables.environmentPointer());
+
+ posix_spawnattr_destroy(&attr);
+
+ if (!result) {
+ // Set up the termination notification handler and then ask the child process to continue.
+ setUpTerminationNotificationHandler(processIdentifier);
+ kill(processIdentifier, SIGCONT);
+ } else {
+ // We failed to launch. Release the send right.
+ mach_port_deallocate(mach_task_self(), listeningPort);
+
+ // And the receive right.
+ mach_port_mod_refs(mach_task_self(), listeningPort, MACH_PORT_RIGHT_RECEIVE, -1);
+
+ listeningPort = MACH_PORT_NULL;
+ processIdentifier = 0;
+ }
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ }
+#endif
+
+ // We've finished launching the process, message back to the main run loop.
+ RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, processIdentifier, listeningPort));
+}
+
+void ProcessLauncher::terminateProcess()
+{
+ if (!m_processIdentifier)
+ return;
+
+ kill(m_processIdentifier, SIGKILL);
+}
+
+void ProcessLauncher::platformInvalidate()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
new file mode 100644
index 000000000..1c74b7d28
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
@@ -0,0 +1,74 @@
+/*
+ * 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 "ThreadLauncher.h"
+
+#import "RunLoop.h"
+#import "WebProcess.h"
+#import "WebSystemInterface.h"
+#import <runtime/InitializeThreading.h>
+#import <wtf/MainThread.h>
+#import <wtf/Threading.h>
+
+namespace WebKit {
+
+static void* webThreadBody(void* context)
+{
+ mach_port_t serverPort = static_cast<mach_port_t>(reinterpret_cast<uintptr_t>(context));
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ InitWebCoreSystemInterface();
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+
+ WebProcess::shared().initialize(serverPort, RunLoop::current());
+
+ [pool drain];
+
+ RunLoop::current()->run();
+
+ return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+ // Create the service port.
+ mach_port_t listeningPort;
+ mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
+
+ // Insert a send right so we can send to it.
+ mach_port_insert_right(mach_task_self(), listeningPort, listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+
+ if (!createThread(webThreadBody, reinterpret_cast<void*>(listeningPort), "WebKit2: WebThread")) {
+ mach_port_destroy(mach_task_self(), listeningPort);
+ return MACH_PORT_NULL;
+ }
+
+ return listeningPort;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
new file mode 100644
index 000000000..837f59baf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -0,0 +1,196 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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.
+ */
+
+#include "config.h"
+#include "ProcessLauncher.h"
+
+#include "Connection.h"
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <QCoreApplication>
+#include <QDebug>
+#include <QFile>
+#include <QLocalServer>
+#include <QMetaType>
+#include <QProcess>
+#include <QString>
+#include <QtCore/qglobal.h>
+#include <WebCore/NotImplemented.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <runtime/InitializeThreading.h>
+#include <string>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <unistd.h>
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/text/WTFString.h>
+#if defined(Q_OS_LINUX)
+#include <sys/prctl.h>
+#include <signal.h>
+#endif
+
+#if OS(DARWIN)
+#include <mach/mach_init.h>
+#include <servers/bootstrap.h>
+
+extern "C" kern_return_t bootstrap_register2(mach_port_t, name_t, mach_port_t, uint64_t);
+#endif
+
+#if defined(SOCK_SEQPACKET) && !defined(Q_OS_MACX)
+#define SOCKET_TYPE SOCK_SEQPACKET
+#else
+#define SOCKET_TYPE SOCK_DGRAM
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class QtWebProcess : public QProcess
+{
+ Q_OBJECT
+public:
+ QtWebProcess(QObject* parent = 0)
+ : QProcess(parent)
+ {
+ }
+
+protected:
+ virtual void setupChildProcess();
+};
+
+void QtWebProcess::setupChildProcess()
+{
+#if defined(Q_OS_LINUX)
+#ifndef NDEBUG
+ if (qgetenv("QT_WEBKIT2_DEBUG") == "1")
+ return;
+#endif
+ prctl(PR_SET_PDEATHSIG, SIGKILL);
+#endif
+#if defined(Q_OS_MACX)
+ qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", QByteArray("1"));
+#endif
+}
+
+void ProcessLauncher::launchProcess()
+{
+ QString applicationPath = QLatin1String("%1 %2");
+
+ if (QFile::exists(QCoreApplication::applicationDirPath() + QLatin1String("/QtWebProcess"))) {
+ applicationPath = applicationPath.arg(QCoreApplication::applicationDirPath() + QLatin1String("/QtWebProcess"));
+ } else {
+ applicationPath = applicationPath.arg(QLatin1String("QtWebProcess"));
+ }
+
+#if OS(DARWIN)
+ // Create the listening port.
+ mach_port_t connector;
+ mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &connector);
+
+ // Insert a send right so we can send to it.
+ mach_port_insert_right(mach_task_self(), connector, connector, MACH_MSG_TYPE_MAKE_SEND);
+
+ // Register port with a service name to the system.
+ QString serviceName = QString("com.nokia.Qt.WebKit.QtWebProcess-%1-%2");
+ serviceName = serviceName.arg(QString().setNum(getpid()), QString().setNum((size_t)this));
+ kern_return_t kr = bootstrap_register2(bootstrap_port, const_cast<char*>(serviceName.toUtf8().data()), connector, 0);
+ ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+
+ QString program(applicationPath.arg(serviceName));
+#else
+ int sockets[2];
+ if (socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) == -1) {
+ qDebug() << "Creation of socket failed with errno:" << errno;
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ // Don't expose the ui socket to the web process
+ while (fcntl(sockets[1], F_SETFD, FD_CLOEXEC) == -1) {
+ if (errno != EINTR) {
+ ASSERT_NOT_REACHED();
+ while (close(sockets[0]) == -1 && errno == EINTR) { }
+ while (close(sockets[1]) == -1 && errno == EINTR) { }
+ return;
+ }
+ }
+
+ int connector = sockets[1];
+ QString program(applicationPath.arg(sockets[0]));
+#endif
+
+ QProcess* webProcess = new QtWebProcess();
+ webProcess->setProcessChannelMode(QProcess::ForwardedChannels);
+ webProcess->start(program);
+
+#if !OS(DARWIN)
+ // Don't expose the web socket to possible future web processes
+ while (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1) {
+ if (errno != EINTR) {
+ ASSERT_NOT_REACHED();
+ delete webProcess;
+ return;
+ }
+ }
+#endif
+
+ if (!webProcess->waitForStarted()) {
+ qDebug() << "Failed to start" << program;
+ ASSERT_NOT_REACHED();
+#if OS(DARWIN)
+ mach_port_deallocate(mach_task_self(), connector);
+ mach_port_mod_refs(mach_task_self(), connector, MACH_PORT_RIGHT_RECEIVE, -1);
+#endif
+ delete webProcess;
+ return;
+ }
+
+ setpriority(PRIO_PROCESS, webProcess->pid(), 10);
+
+ RunLoop::main()->dispatch(bind(&WebKit::ProcessLauncher::didFinishLaunchingProcess, this, webProcess, connector));
+}
+
+void ProcessLauncher::terminateProcess()
+{
+ if (!m_processIdentifier)
+ return;
+
+ QObject::connect(m_processIdentifier, SIGNAL(finished(int)), m_processIdentifier, SLOT(deleteLater()), Qt::QueuedConnection);
+ m_processIdentifier->terminate();
+}
+
+void ProcessLauncher::platformInvalidate()
+{
+
+}
+
+} // namespace WebKit
+
+#include "ProcessLauncherQt.moc"
diff --git a/Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp b/Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp
new file mode 100644
index 000000000..7b95ca049
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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.
+ */
+
+#include "config.h"
+#include "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/MainThread.h>
+#include <wtf/Threading.h>
+
+#include <QDebug>
+#include <QFile>
+#include <QLocalServer>
+#include <QProcess>
+
+#include <QtCore/qglobal.h>
+
+#include <sys/resource.h>
+#include <unistd.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void* webThreadBody(void* /* context */)
+{
+ // Initialization
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+
+ // FIXME: We do not support threaded mode for now.
+
+ WebProcess::shared().initialize(-1, RunLoop::current());
+ RunLoop::run();
+
+ return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+ srandom(time(0));
+ int connectionIdentifier = random();
+
+ if (!createThread(webThreadBody, reinterpret_cast<void*>(connectionIdentifier), "WebKit2: WebThread")) {
+ qWarning() << "failed starting thread";
+ return 0;
+ }
+
+ return connectionIdentifier;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp b/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
new file mode 100644
index 000000000..d526c0307
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
@@ -0,0 +1,125 @@
+/*
+ * 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 "ProcessLauncher.h"
+
+#include "Connection.h"
+#include "RunLoop.h"
+#include <shlwapi.h>
+#include <wtf/text/WTFString.h>
+
+#ifdef DEBUG_ALL
+const LPCWSTR webProcessName = L"WebKit2WebProcess_debug.exe";
+#else
+const LPCWSTR webProcessName = L"WebKit2WebProcess.exe";
+#endif
+
+#ifdef DEBUG_ALL
+const LPCWSTR webKitDLLName = L"WebKit_debug.dll";
+#else
+const LPCWSTR webKitDLLName = L"WebKit.dll";
+#endif
+
+namespace WebKit {
+
+void ProcessLauncher::launchProcess()
+{
+ // First, create the server and client identifiers.
+ HANDLE serverIdentifier, clientIdentifier;
+ if (!CoreIPC::Connection::createServerAndClientIdentifiers(serverIdentifier, clientIdentifier)) {
+ // FIXME: What should we do here?
+ ASSERT_NOT_REACHED();
+ }
+
+ // Ensure that the child process inherits the client identifier.
+ ::SetHandleInformation(clientIdentifier, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT);
+
+ // To get the full file path to WebKit2WebProcess.exe, we fild the location of WebKit.dll,
+ // remove the last path component, and then append WebKit2WebProcess(_debug).exe.
+ HMODULE webKitModule = ::GetModuleHandleW(webKitDLLName);
+ ASSERT(webKitModule);
+ if (!webKitModule)
+ return;
+
+ WCHAR pathStr[MAX_PATH];
+ if (!::GetModuleFileNameW(webKitModule, pathStr, WTF_ARRAY_LENGTH(pathStr)))
+ return;
+
+ ::PathRemoveFileSpecW(pathStr);
+ if (!::PathAppendW(pathStr, webProcessName))
+ return;
+
+ String commandLine(pathStr);
+
+ // FIXME: It would be nice if we could just create a CommandLine object and output a command line vector from it.
+ Vector<UChar> commandLineVector;
+ append(commandLineVector, "\"");
+ append(commandLineVector, commandLine);
+ append(commandLineVector, "\"");
+ append(commandLineVector, " -type webprocess");
+ append(commandLineVector, " -clientIdentifier ");
+ append(commandLineVector, String::number(reinterpret_cast<uintptr_t>(clientIdentifier)));
+ commandLineVector.append('\0');
+
+ STARTUPINFO startupInfo = { 0 };
+ startupInfo.cb = sizeof(startupInfo);
+ PROCESS_INFORMATION processInformation = { 0 };
+ BOOL result = ::CreateProcessW(0, commandLineVector.data(), 0, 0, true, 0, 0, 0, &startupInfo, &processInformation);
+
+ // We can now close the client identifier handle.
+ ::CloseHandle(clientIdentifier);
+
+ if (!result) {
+ // FIXME: What should we do here?
+ DWORD error = ::GetLastError();
+ ASSERT_NOT_REACHED();
+ }
+
+ // Don't leak the thread handle.
+ ::CloseHandle(processInformation.hThread);
+
+ // We've finished launching the process, message back to the run loop.
+ RunLoop::main()->dispatch(bind(&ProcessLauncher::didFinishLaunchingProcess, this, processInformation.hProcess, serverIdentifier));
+}
+
+void ProcessLauncher::terminateProcess()
+{
+ if (!m_processIdentifier)
+ return;
+
+ ::TerminateProcess(m_processIdentifier, 0);
+}
+
+void ProcessLauncher::platformInvalidate()
+{
+ if (!m_processIdentifier)
+ return;
+
+ ::CloseHandle(m_processIdentifier);
+ m_processIdentifier = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp b/Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
new file mode 100644
index 000000000..2596998ea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/MainThread.h>
+#include <wtf/Threading.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void* webThreadBody(void* context)
+{
+ HANDLE clientIdentifier = reinterpret_cast<HANDLE>(context);
+
+ // Initialization
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+
+ WebProcess::shared().initialize(clientIdentifier, RunLoop::current());
+ RunLoop::run();
+
+ return 0;
+}
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+ // First, create the server and client identifiers.
+ HANDLE serverIdentifier, clientIdentifier;
+ if (!CoreIPC::Connection::createServerAndClientIdentifiers(serverIdentifier, clientIdentifier)) {
+ // FIXME: What should we do here?
+ ASSERT_NOT_REACHED();
+ }
+
+ if (!createThread(webThreadBody, reinterpret_cast<void*>(clientIdentifier), "WebKit2: WebThread")) {
+ ::CloseHandle(serverIdentifier);
+ ::CloseHandle(clientIdentifier);
+ return 0;
+ }
+
+ return serverIdentifier;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/LayerTreeHostProxy.h b/Source/WebKit2/UIProcess/LayerTreeHostProxy.h
new file mode 100644
index 000000000..871e3bf09
--- /dev/null
+++ b/Source/WebKit2/UIProcess/LayerTreeHostProxy.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 LayerTreeHostProxy_h
+#define LayerTreeHostProxy_h
+
+#include "BackingStore.h"
+#include "DrawingAreaProxy.h"
+#include "MessageQueue.h"
+#include "Region.h"
+#include "RunLoop.h"
+#include "WebLayerTreeInfo.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/GraphicsLayer.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/IntSize.h>
+#include <wtf/HashSet.h>
+
+#if USE(TEXTURE_MAPPER)
+#include "TextureMapper.h"
+#include "TextureMapperNode.h"
+#endif
+
+namespace WebKit {
+
+class WebLayerInfo;
+class WebLayerUpdateInfo;
+
+using namespace WebCore;
+
+class LayerTreeMessageToRenderer;
+
+class LayerTreeHostProxy : public GraphicsLayerClient {
+public:
+ LayerTreeHostProxy(DrawingAreaProxy*);
+ virtual ~LayerTreeHostProxy();
+ void syncCompositingLayerState(const WebLayerInfo&);
+ void deleteCompositingLayer(WebLayerID);
+ void setRootCompositingLayer(WebLayerID);
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void paintToCurrentGLContext(const TransformationMatrix&, float);
+ void purgeGLResources();
+ void setVisibleContentsRectAndScale(const IntRect&, float);
+ void setVisibleContentRectTrajectoryVector(const FloatPoint&);
+#if USE(TILED_BACKING_STORE)
+ void syncRemoteContent();
+ void swapContentBuffers();
+ void didRenderFrame();
+ void createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&);
+ void updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo&);
+ void removeTileForLayer(int layerID, int tileID);
+ void createDirectlyCompositedImage(int64_t, const WebKit::ShareableBitmap::Handle&);
+ void destroyDirectlyCompositedImage(int64_t);
+ void didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void setVisibleContentsRectForLayer(WebLayerID, const IntRect&);
+ void updateViewport();
+#endif
+
+protected:
+ PassOwnPtr<GraphicsLayer> createLayer(WebLayerID);
+
+ GraphicsLayer* layerByID(WebLayerID id) { return (id == InvalidWebLayerID) ? 0 : m_layers.get(id); }
+ GraphicsLayer* rootLayer() { return m_rootLayer.get(); }
+
+ // Reimplementations from WebCore::GraphicsLayerClient.
+ virtual void notifyAnimationStarted(const GraphicsLayer*, double) { }
+ virtual void notifySyncRequired(const GraphicsLayer*) { }
+ virtual bool showDebugBorders() const { return false; }
+ virtual bool showRepaintCounter() const { return false; }
+ void paintContents(const WebCore::GraphicsLayer*, WebCore::GraphicsContext&, WebCore::GraphicsLayerPaintingPhase, const WebCore::IntRect&) { }
+
+ RunLoop::Timer<LayerTreeHostProxy> m_animationTimer;
+ DrawingAreaProxy* m_drawingAreaProxy;
+
+ typedef HashMap<WebLayerID, WebCore::GraphicsLayer*> LayerMap;
+ IntRect m_visibleContentsRect;
+ float m_contentsScale;
+
+ MessageQueue<LayerTreeMessageToRenderer> m_messagesToRenderer;
+ void pushUpdateToQueue(PassOwnPtr<LayerTreeMessageToRenderer>);
+
+#if USE(TEXTURE_MAPPER)
+ OwnPtr<TextureMapper> m_textureMapper;
+#endif
+
+#if PLATFORM(QT)
+ typedef HashMap<IntPoint, RefPtr<BitmapTexture> > TiledImage;
+ TextureMapperNode::NodeRectMap m_nodeVisualContentsRectMap;
+ HashMap<int, int> m_tileToNodeTile;
+ int remoteTileIDToNodeTileID(int tileID) const;
+ HashMap<int64_t, TiledImage> m_directlyCompositedImages;
+
+ void scheduleWebViewUpdate();
+ void synchronizeViewport();
+ void deleteLayer(WebLayerID);
+ void setRootLayerID(WebLayerID);
+ void syncLayerParameters(const WebLayerInfo&);
+ void createTile(WebLayerID, int, float scale);
+ void removeTile(WebLayerID, int);
+ void updateTile(WebLayerID, int, const IntRect&, const IntRect&, const QImage&);
+ void createImage(int64_t, const QImage&);
+ void destroyImage(int64_t);
+ void assignImageToLayer(WebCore::GraphicsLayer*, int64_t imageID);
+ void flushLayerChanges();
+ void ensureRootLayer();
+ void ensureLayer(WebLayerID);
+
+#endif
+
+ OwnPtr<GraphicsLayer> m_rootLayer;
+ Vector<WebLayerID> m_layersToDelete;
+
+#if PLATFORM(QT)
+ void didFireViewportUpdateTimer(Timer<LayerTreeHostProxy>*);
+ Timer<LayerTreeHostProxy> m_viewportUpdateTimer;
+#endif
+
+ LayerMap m_layers;
+ WebLayerID m_rootLayerID;
+ int m_id;
+};
+
+}
+
+#endif // LayerTreeHostProxy_h
diff --git a/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in b/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in
new file mode 100644
index 000000000..70465b350
--- /dev/null
+++ b/Source/WebKit2/UIProcess/LayerTreeHostProxy.messages.in
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TILED_BACKING_STORE)
+messages -> LayerTreeHostProxy {
+ SyncCompositingLayerState(WebKit::WebLayerInfo layerInfo)
+ SetRootCompositingLayer(uint32_t id)
+ DeleteCompositingLayer(uint32_t id)
+ CreateTileForLayer(uint32_t layerID, int tileID, WebKit::UpdateInfo updateInfo)
+ UpdateTileForLayer(uint32_t layerID, int tileID, WebKit::UpdateInfo updateInfo)
+ RemoveTileForLayer(uint32_t layerID, int tileID)
+ CreateDirectlyCompositedImage(int64_t key, WebKit::ShareableBitmap::Handle handle)
+ DestroyDirectlyCompositedImage(int64_t key)
+ DidRenderFrame()
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.cpp b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.cpp
new file mode 100644
index 000000000..25d37da4b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "NotificationPermissionRequest.h"
+
+#include "NotificationPermissionRequestManagerProxy.h"
+
+namespace WebKit {
+
+PassRefPtr<NotificationPermissionRequest> NotificationPermissionRequest::create(WebKit::NotificationPermissionRequestManagerProxy *manager, uint64_t notificationID)
+{
+ return adoptRef(new NotificationPermissionRequest(manager, notificationID));
+}
+
+NotificationPermissionRequest::NotificationPermissionRequest(NotificationPermissionRequestManagerProxy* manager, uint64_t notificationID)
+ : m_manager(manager)
+ , m_notificationID(notificationID)
+{
+}
+
+void NotificationPermissionRequest::allow()
+{
+ if (!m_manager)
+ return;
+
+ m_manager->didReceiveNotificationPermissionDecision(m_notificationID, true);
+ m_manager = 0;
+}
+
+void NotificationPermissionRequest::deny()
+{
+ if (!m_manager)
+ return;
+
+ m_manager->didReceiveNotificationPermissionDecision(m_notificationID, false);
+ m_manager = 0;
+}
+
+void NotificationPermissionRequest::invalidate()
+{
+ m_manager = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.h b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.h
new file mode 100644
index 000000000..24db98b0c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequest.h
@@ -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.
+ */
+
+#ifndef NotificationPermissionRequest_h
+#define NotificationPermissionRequest_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class NotificationPermissionRequestManagerProxy;
+
+class NotificationPermissionRequest : public APIObject {
+public:
+ static const Type APIType = TypeNotificationPermissionRequest;
+
+ static PassRefPtr<NotificationPermissionRequest> create(NotificationPermissionRequestManagerProxy*, uint64_t notificationID);
+
+ void allow();
+ void deny();
+
+ void invalidate();
+
+private:
+ NotificationPermissionRequest(NotificationPermissionRequestManagerProxy*, uint64_t notificationID);
+
+ virtual Type type() const { return APIType; }
+
+ NotificationPermissionRequestManagerProxy* m_manager;
+ uint64_t m_notificationID;
+};
+
+} // namespace WebKit
+
+#endif // NotificationPermissionRequestProxy_h
diff --git a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp
new file mode 100644
index 000000000..07922985e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.cpp
@@ -0,0 +1,70 @@
+/*
+ * 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 "NotificationPermissionRequestManagerProxy.h"
+
+#include "NotificationPermissionRequest.h"
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+NotificationPermissionRequestManagerProxy::NotificationPermissionRequestManagerProxy(WebPageProxy* page)
+ : m_page(page)
+{
+}
+
+void NotificationPermissionRequestManagerProxy::invalidateRequests()
+{
+ PendingRequestMap::const_iterator it = m_pendingRequests.begin();
+ PendingRequestMap::const_iterator end = m_pendingRequests.end();
+ for (; it != end; ++it)
+ it->second->invalidate();
+
+ m_pendingRequests.clear();
+}
+
+PassRefPtr<NotificationPermissionRequest> NotificationPermissionRequestManagerProxy::createRequest(uint64_t notificationID)
+{
+ RefPtr<NotificationPermissionRequest> request = NotificationPermissionRequest::create(this, notificationID);
+ m_pendingRequests.add(notificationID, request.get());
+ return request.release();
+}
+
+void NotificationPermissionRequestManagerProxy::didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allow)
+{
+ if (!m_page->isValid())
+ return;
+
+ RefPtr<NotificationPermissionRequest> request = m_pendingRequests.take(notificationID);
+ if (!request)
+ return;
+
+ m_page->process()->send(Messages::WebPage::DidReceiveNotificationPermissionDecision(notificationID, allow), m_page->pageID());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.h b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.h
new file mode 100644
index 000000000..f6228e72a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/NotificationPermissionRequestManagerProxy.h
@@ -0,0 +1,59 @@
+/*
+ * 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 NotificationPermissionRequestManagerProxy_h
+#define NotificationPermissionRequestManagerProxy_h
+
+#include "NotificationPermissionRequest.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class GeolocationPermissionRequestProxy;
+class WebPageProxy;
+
+class NotificationPermissionRequestManagerProxy {
+public:
+ explicit NotificationPermissionRequestManagerProxy(WebPageProxy*);
+
+ void invalidateRequests();
+
+ // Create a request to be presented to the user.
+ PassRefPtr<NotificationPermissionRequest> createRequest(uint64_t notificationID);
+
+ // Called by NotificationPermissionRequest when a decision is made by the user.
+ void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allow);
+
+private:
+ typedef HashMap<uint64_t, RefPtr<NotificationPermissionRequest> > PendingRequestMap;
+ PendingRequestMap m_pendingRequests;
+ WebPageProxy* m_page;
+};
+
+} // namespace WebKit
+
+
+#endif // NotificationPermissionRequestManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp
new file mode 100644
index 000000000..7bb74432c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebNotification.h"
+
+#include "ArgumentCoders.h"
+#include "ArgumentDecoder.h"
+#include "ArgumentEncoder.h"
+#include "Arguments.h"
+
+namespace WebKit {
+
+WebNotification::WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
+ : m_title(title)
+ , m_body(body)
+ , m_origin(WebSecurityOrigin::create(originIdentifier))
+ , m_notificationID(notificationID)
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.h b/Source/WebKit2/UIProcess/Notifications/WebNotification.h
new file mode 100644
index 000000000..0b89a0aab
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.h
@@ -0,0 +1,79 @@
+/*
+ * 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 WebNotification_h
+#define WebNotification_h
+
+#include "APIObject.h"
+#include "WebSecurityOrigin.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace CoreIPC {
+
+class ArgumentDecoder;
+class ArgumentEncoder;
+
+} // namespace CoreIPC
+
+namespace WebKit {
+
+class WebNotification : public APIObject {
+public:
+ static const Type APIType = TypeNotification;
+
+ static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
+ {
+ return adoptRef(new WebNotification(title, body, originIdentifier, notificationID));
+ }
+
+ const String& title() const { return m_title; }
+ const String& body() const { return m_body; }
+ WebSecurityOrigin* origin() const { return m_origin.get(); }
+
+ uint64_t notificationID() const { return m_notificationID; }
+
+private:
+ WebNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID);
+
+ virtual Type type() const { return APIType; }
+
+ String m_title;
+ String m_body;
+ RefPtr<WebSecurityOrigin> m_origin;
+ uint64_t m_notificationID;
+};
+
+inline bool isNotificationIDValid(uint64_t id)
+{
+ // This check makes sure that the ID is not equal to values needed by
+ // HashMap for bucketing.
+ return id && id != static_cast<uint64_t>(-1);
+}
+
+} // namespace WebKit
+
+#endif // WebNotification_h
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp
new file mode 100644
index 000000000..7d7c045db
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp
@@ -0,0 +1,151 @@
+/*
+ * 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 "WebNotificationManagerProxy.h"
+
+#include "ImmutableArray.h"
+#include "WebContext.h"
+#include "WebNotification.h"
+#include "WebNotificationManagerMessages.h"
+#include "WebPageProxy.h"
+#include "WebSecurityOrigin.h"
+#include <WebCore/NotificationContents.h>
+
+using namespace WTF;
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebNotificationManagerProxy> WebNotificationManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebNotificationManagerProxy(context));
+}
+
+WebNotificationManagerProxy::WebNotificationManagerProxy(WebContext* context)
+ : m_context(context)
+{
+}
+
+void WebNotificationManagerProxy::invalidate()
+{
+ m_provider.removeNotificationManager(this);
+}
+
+void WebNotificationManagerProxy::initializeProvider(const WKNotificationProvider *provider)
+{
+ m_provider.initialize(provider);
+}
+
+void WebNotificationManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebNotificationManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebNotificationManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ didReceiveSyncWebNotificationManagerProxyMessage(connection, messageID, arguments, reply);
+}
+
+void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
+{
+ if (!isNotificationIDValid(notificationID))
+ return;
+
+ m_provider.addNotificationManager(this);
+
+ RefPtr<WebNotification> notification = WebNotification::create(title, body, originIdentifier, notificationID);
+ m_notifications.set(notificationID, notification);
+ m_provider.show(page, notification.get());
+}
+
+void WebNotificationManagerProxy::cancel(uint64_t notificationID)
+{
+ if (!isNotificationIDValid(notificationID))
+ return;
+
+ RefPtr<WebNotification> notification = m_notifications.get(notificationID);
+ if (!notification)
+ return;
+
+ m_provider.addNotificationManager(this);
+ m_provider.cancel(notification.get());
+}
+
+void WebNotificationManagerProxy::didDestroyNotification(uint64_t notificationID)
+{
+ if (!isNotificationIDValid(notificationID))
+ return;
+
+ RefPtr<WebNotification> notification = m_notifications.take(notificationID);
+ if (!notification)
+ return;
+
+ m_provider.didDestroyNotification(notification.get());
+}
+
+void WebNotificationManagerProxy::notificationPermissionLevel(const String& originIdentifier, uint64_t& permissionLevel)
+{
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+ permissionLevel = m_provider.policyForNotificationPermissionAtOrigin(origin.get());
+}
+
+void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID)
+{
+ if (!m_context)
+ return;
+
+ m_context->sendToAllProcesses(Messages::WebNotificationManager::DidShowNotification(notificationID));
+}
+
+void WebNotificationManagerProxy::providerDidClickNotification(uint64_t notificationID)
+{
+ if (!m_context)
+ return;
+
+ m_context->sendToAllProcesses(Messages::WebNotificationManager::DidClickNotification(notificationID));
+}
+
+
+void WebNotificationManagerProxy::providerDidCloseNotifications(ImmutableArray* notificationIDs)
+{
+ if (!m_context)
+ return;
+
+ size_t size = notificationIDs->size();
+
+ Vector<uint64_t> vectorNotificationIDs;
+ vectorNotificationIDs.reserveInitialCapacity(size);
+
+ for (size_t i = 0; i < size; ++i) {
+ uint64_t notificationID = notificationIDs->at<WebUInt64>(i)->value();
+ vectorNotificationIDs.append(notificationID);
+ }
+
+ if (vectorNotificationIDs.size())
+ m_context->sendToAllProcesses(Messages::WebNotificationManager::DidCloseNotifications(vectorNotificationIDs));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
new file mode 100644
index 000000000..1705abcf4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
@@ -0,0 +1,90 @@
+/*
+ * 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 WebNotificationManagerProxy_h
+#define WebNotificationManagerProxy_h
+
+#include "APIObject.h"
+#include "MessageID.h"
+#include "WebNotificationProvider.h"
+#include <wtf/HashMap.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class ArgumentEncoder;
+class Connection;
+}
+
+namespace WebKit {
+
+class ImmutableArray;
+class WebContext;
+class WebPageProxy;
+
+class WebNotificationManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeNotificationManager;
+
+ static PassRefPtr<WebNotificationManagerProxy> create(WebContext*);
+
+ void invalidate();
+ void clearContext() { m_context = 0; }
+
+ void initializeProvider(const WKNotificationProvider*);
+
+ void show(WebPageProxy*, const WTF::String& title, const WTF::String& body, const WTF::String& originIdentifier, uint64_t notificationID);
+
+ void providerDidShowNotification(uint64_t notificationID);
+ void providerDidClickNotification(uint64_t notificationID);
+ void providerDidCloseNotifications(ImmutableArray* notificationIDs);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+private:
+ explicit WebNotificationManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didReceiveWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebNotificationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ // Message handlers
+ void cancel(uint64_t notificationID);
+ void didDestroyNotification(uint64_t notificationID);
+ void notificationPermissionLevel(const WTF::String& originIdentifier, uint64_t& permissionLevel);
+
+ typedef HashMap<uint64_t, RefPtr<WebNotification> > WebNotificationMap;
+
+ WebContext* m_context;
+ WebNotificationProvider m_provider;
+ WebNotificationMap m_notifications;
+};
+
+} // namespace WebKit
+
+#endif // WebNotificationManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in
new file mode 100644
index 000000000..04d1a01b1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in
@@ -0,0 +1,28 @@
+# 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.
+
+messages -> WebNotificationManagerProxy {
+ Cancel(uint64_t notificationID);
+ DidDestroyNotification(uint64_t notificationID);
+
+ NotificationPermissionLevel(WTF::String originIdentifier) -> (uint64_t policy)
+}
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp
new file mode 100644
index 000000000..080aea666
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "WebNotificationProvider.h"
+
+#include "WKAPICast.h"
+#include "WebNotification.h"
+#include "WebNotificationManagerProxy.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+void WebNotificationProvider::show(WebPageProxy* page, WebNotification* notification)
+{
+ if (!m_client.show)
+ return;
+
+ m_client.show(toAPI(page), toAPI(notification), m_client.clientInfo);
+}
+
+void WebNotificationProvider::cancel(WebNotification* notification)
+{
+ if (!m_client.cancel)
+ return;
+
+ m_client.cancel(toAPI(notification), m_client.clientInfo);
+}
+
+void WebNotificationProvider::didDestroyNotification(WebNotification* notification)
+{
+ if (!m_client.didDestroyNotification)
+ return;
+
+ m_client.didDestroyNotification(toAPI(notification), m_client.clientInfo);
+}
+
+int WebNotificationProvider::policyForNotificationPermissionAtOrigin(WebSecurityOrigin* origin)
+{
+ if (!m_client.policyForNotificationPermissionAtOrigin)
+ return INT_MIN;
+
+ return m_client.policyForNotificationPermissionAtOrigin(toAPI(origin), m_client.clientInfo);
+}
+
+void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager)
+{
+ if (!m_client.addNotificationManager)
+ return;
+
+ m_client.addNotificationManager(toAPI(manager), m_client.clientInfo);
+}
+
+void WebNotificationProvider::removeNotificationManager(WebNotificationManagerProxy* manager)
+{
+ if (!m_client.removeNotificationManager)
+ return;
+
+ m_client.removeNotificationManager(toAPI(manager), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h
new file mode 100644
index 000000000..43d963919
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.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 WebNotificationProvider_h
+#define WebNotificationProvider_h
+
+#include "APIClient.h"
+#include "WKNotificationProvider.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebNotification;
+class WebNotificationManagerProxy;
+class WebPageProxy;
+class WebSecurityOrigin;
+
+class WebNotificationProvider : public APIClient<WKNotificationProvider, kWKNotificationProviderCurrentVersion> {
+public:
+ void show(WebPageProxy*, WebNotification*);
+ void cancel(WebNotification*);
+ void didDestroyNotification(WebNotification*);
+ int policyForNotificationPermissionAtOrigin(WebSecurityOrigin*);
+
+ void addNotificationManager(WebNotificationManagerProxy*);
+ void removeNotificationManager(WebNotificationManagerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebNotificationProvider_h
diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h
new file mode 100644
index 000000000..1db4eaa9b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/PageClient.h
@@ -0,0 +1,197 @@
+/*
+ * 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 PageClient_h
+#define PageClient_h
+
+#include "ShareableBitmap.h"
+#include "WebPageProxy.h"
+#include "WebPopupMenuProxy.h"
+#include <WebCore/EditorClient.h>
+#include <WebCore/SpellingCorrectionController.h>
+#include <wtf/Forward.h>
+
+#if PLATFORM(MAC)
+#include "PluginComplexTextInputState.h"
+
+OBJC_CLASS WKView;
+#endif
+
+namespace WebCore {
+ class Cursor;
+ struct ViewportArguments;
+}
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+class FindIndicator;
+class NativeWebKeyboardEvent;
+#if ENABLE(TOUCH_EVENTS)
+class NativeWebTouchEvent;
+#endif
+class WebContextMenuProxy;
+class WebEditCommandProxy;
+class WebPopupMenuProxy;
+
+#if PLATFORM(WIN)
+struct WindowGeometry;
+#endif
+
+class PageClient {
+public:
+ virtual ~PageClient() { }
+
+ // Create a new drawing area proxy for the given page.
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy() = 0;
+
+ // Tell the view to invalidate the given rect. The rect is in view coordinates.
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&) = 0;
+
+ // Tell the view to immediately display its invalid rect.
+ virtual void displayView() = 0;
+
+ // Tell the view to scroll scrollRect by scrollOffset.
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset) = 0;
+
+ // Return the size of the view the page is associated with.
+ virtual WebCore::IntSize viewSize() = 0;
+
+ // Return whether the view's containing window is active.
+ virtual bool isViewWindowActive() = 0;
+
+ // Return whether the view is focused.
+ virtual bool isViewFocused() = 0;
+
+ // Return whether the view is visible.
+ virtual bool isViewVisible() = 0;
+
+ // Return whether the view is in a window.
+ virtual bool isViewInWindow() = 0;
+
+ virtual void processDidCrash() = 0;
+ virtual void didRelaunchProcess() = 0;
+ virtual void pageClosed() = 0;
+
+ virtual void toolTipChanged(const String&, const String&) = 0;
+
+#if USE(TILED_BACKING_STORE)
+ virtual void pageDidRequestScroll(const WebCore::IntPoint&) = 0;
+#endif
+#if PLATFORM(QT)
+ virtual void didChangeContentsSize(const WebCore::IntSize&) = 0;
+ virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&) = 0;
+ virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&) = 0;
+ virtual void didReceiveMessageFromNavigatorQtObject(const String&) = 0;
+ virtual void handleDownloadRequest(DownloadProxy*) = 0;
+#endif
+
+#if PLATFORM(QT) || PLATFORM(GTK)
+ virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage) = 0;
+#endif
+
+ virtual void setCursor(const WebCore::Cursor&) = 0;
+ virtual void setCursorHiddenUntilMouseMoves(bool) = 0;
+ virtual void didChangeViewportProperties(const WebCore::ViewportArguments&) = 0;
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) = 0;
+ virtual void clearAllEditCommands() = 0;
+ virtual bool canUndoRedo(WebPageProxy::UndoOrRedo) = 0;
+ virtual void executeUndoRedo(WebPageProxy::UndoOrRedo) = 0;
+#if PLATFORM(MAC)
+ virtual void accessibilityWebProcessTokenReceived(const CoreIPC::DataReference&) = 0;
+ virtual bool interpretKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&) = 0;
+ virtual bool executeSavedCommandBySelector(const String& selector) = 0;
+ virtual void setDragImage(const WebCore::IntPoint& clientPosition, PassRefPtr<ShareableBitmap> dragImage, bool isLinkDrag) = 0;
+ virtual void updateTextInputState(bool updateSecureInputState) = 0;
+ virtual void resetTextInputState() = 0;
+ virtual void makeFirstResponder() = 0;
+#endif
+#if PLATFORM(WIN)
+ virtual void compositionSelectionChanged(bool) = 0;
+#endif
+#if PLATFORM(GTK)
+ virtual void getEditorCommandsForKeyEvent(const NativeWebKeyboardEvent&, const AtomicString&, Vector<WTF::String>&) = 0;
+#endif
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
+ virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) = 0;
+ virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) = 0;
+
+ virtual void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) = 0;
+#if ENABLE(TOUCH_EVENTS)
+ virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled) = 0;
+#endif
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*) = 0;
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) = 0;
+
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate) = 0;
+#if PLATFORM(WIN)
+ virtual void didInstallOrUninstallPageOverlay(bool) = 0;
+#endif
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&) = 0;
+ virtual void exitAcceleratedCompositingMode() = 0;
+#endif
+
+#if PLATFORM(WIN)
+ virtual HWND nativeWindow() = 0;
+ virtual void setGestureReachedScrollingLimit(bool) = 0;
+ virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&) = 0;
+#endif
+
+#if PLATFORM(MAC)
+ virtual void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus) = 0;
+ virtual void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, PluginComplexTextInputState) = 0;
+ virtual CGContextRef containingWindowGraphicsContext() = 0;
+ virtual void didPerformDictionaryLookup(const String&, double scaleFactor, const DictionaryPopupInfo&) = 0;
+ virtual void dismissDictionaryLookupPanel() = 0;
+ virtual void showCorrectionPanel(WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings) = 0;
+ virtual void dismissCorrectionPanel(WebCore::ReasonForDismissingCorrectionPanel) = 0;
+ virtual String dismissCorrectionPanelSoon(WebCore::ReasonForDismissingCorrectionPanel) = 0;
+ virtual void recordAutocorrectionResponse(WebCore::EditorClient::AutocorrectionResponseType, const String& replacedString, const String& replacementString) = 0;
+ virtual void recommendedScrollbarStyleDidChange(int32_t newStyle) = 0;
+
+ virtual WKView* wkView() const = 0;
+#endif
+
+ virtual void didChangeScrollbarsForMainFrame() const = 0;
+
+ // Custom representations.
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation) = 0;
+ virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) = 0;
+ virtual double customRepresentationZoomFactor() = 0;
+ virtual void setCustomRepresentationZoomFactor(double) = 0;
+
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects) = 0;
+ virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
+ virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount) = 0;
+};
+
+} // namespace WebKit
+
+#endif // PageClient_h
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
new file mode 100644
index 000000000..f37099f2c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
@@ -0,0 +1,226 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#include "PluginModuleInfo.h"
+#include <WebCore/KURL.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <algorithm>
+#include <wtf/ListHashSet.h>
+#include <wtf/StdLibExtras.h>
+
+using namespace std;
+using namespace WebCore;
+
+namespace WebKit {
+
+PluginInfoStore::PluginInfoStore()
+ : m_pluginListIsUpToDate(false)
+{
+}
+
+void PluginInfoStore::setAdditionalPluginsDirectories(const Vector<String>& directories)
+{
+ m_additionalPluginsDirectories = directories;
+ refresh();
+}
+
+void PluginInfoStore::refresh()
+{
+ m_pluginListIsUpToDate = false;
+}
+
+template <typename T, typename U>
+static void addFromVector(T& hashSet, const U& vector)
+{
+ for (size_t i = 0; i < vector.size(); ++i)
+ hashSet.add(vector[i]);
+}
+
+// We use a ListHashSet so that plugins will be loaded from the additional plugins directories first
+// (which in turn means those plugins will be preferred if two plugins claim the same MIME type).
+#if OS(WINDOWS)
+typedef ListHashSet<String, 32, CaseFoldingHash> PathHashSet;
+#else
+typedef ListHashSet<String, 32> PathHashSet;
+#endif
+
+void PluginInfoStore::loadPluginsIfNecessary()
+{
+ if (m_pluginListIsUpToDate)
+ return;
+
+ PathHashSet uniquePluginPaths;
+
+ // First, load plug-ins from the additional plug-ins directories specified.
+ for (size_t i = 0; i < m_additionalPluginsDirectories.size(); ++i)
+ addFromVector(uniquePluginPaths, pluginPathsInDirectory(m_additionalPluginsDirectories[i]));
+
+ // Then load plug-ins from the standard plug-ins directories.
+ Vector<String> directories = pluginsDirectories();
+ for (size_t i = 0; i < directories.size(); ++i)
+ addFromVector(uniquePluginPaths, pluginPathsInDirectory(directories[i]));
+
+ // Then load plug-ins that are not in the standard plug-ins directories.
+ addFromVector(uniquePluginPaths, individualPluginPaths());
+
+ Vector<PluginModuleInfo> plugins;
+
+ PathHashSet::const_iterator end = uniquePluginPaths.end();
+ for (PathHashSet::const_iterator it = uniquePluginPaths.begin(); it != end; ++it)
+ loadPlugin(plugins, *it);
+
+ m_plugins.swap(plugins);
+ m_pluginListIsUpToDate = true;
+}
+
+void PluginInfoStore::loadPlugin(Vector<PluginModuleInfo>& plugins, const String& pluginPath)
+{
+ PluginModuleInfo plugin;
+
+ if (!getPluginInfo(pluginPath, plugin))
+ return;
+
+ if (!shouldUsePlugin(plugins, plugin))
+ return;
+
+ plugins.append(plugin);
+}
+
+Vector<PluginModuleInfo> PluginInfoStore::plugins()
+{
+ loadPluginsIfNecessary();
+
+ Vector<PluginModuleInfo> plugins(m_plugins);
+
+ return plugins;
+}
+
+PluginModuleInfo PluginInfoStore::findPluginForMIMEType(const String& mimeType) const
+{
+ ASSERT(!mimeType.isNull());
+
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ const PluginModuleInfo& plugin = m_plugins[i];
+
+ for (size_t j = 0; j < plugin.info.mimes.size(); ++j) {
+ const MimeClassInfo& mimeClassInfo = plugin.info.mimes[j];
+ if (mimeClassInfo.type == mimeType)
+ return plugin;
+ }
+ }
+
+ return PluginModuleInfo();
+}
+
+PluginModuleInfo PluginInfoStore::findPluginForExtension(const String& extension, String& mimeType) const
+{
+ ASSERT(!extension.isNull());
+
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ const PluginModuleInfo& plugin = m_plugins[i];
+
+ for (size_t j = 0; j < plugin.info.mimes.size(); ++j) {
+ const MimeClassInfo& mimeClassInfo = plugin.info.mimes[j];
+
+ const Vector<String>& extensions = mimeClassInfo.extensions;
+
+ if (find(extensions.begin(), extensions.end(), extension) != extensions.end()) {
+ // We found a supported extension, set the correct MIME type.
+ mimeType = mimeClassInfo.type;
+ return plugin;
+ }
+ }
+ }
+
+ return PluginModuleInfo();
+}
+
+static inline String pathExtension(const KURL& url)
+{
+ String extension;
+ String filename = url.lastPathComponent();
+ if (!filename.endsWith("/")) {
+ int extensionPos = filename.reverseFind('.');
+ if (extensionPos != -1)
+ extension = filename.substring(extensionPos + 1);
+ }
+
+ return extension;
+}
+
+#if !PLATFORM(MAC)
+String PluginInfoStore::getMIMETypeForExtension(const String& extension)
+{
+ return MIMETypeRegistry::getMIMETypeForExtension(extension);
+}
+#endif
+
+PluginModuleInfo PluginInfoStore::findPlugin(String& mimeType, const KURL& url)
+{
+ loadPluginsIfNecessary();
+
+ // First, check if we can get the plug-in based on its MIME type.
+ if (!mimeType.isNull()) {
+ PluginModuleInfo plugin = findPluginForMIMEType(mimeType);
+ if (!plugin.path.isNull())
+ return plugin;
+ }
+
+ // Next, check if any plug-ins claim to support the URL extension.
+ String extension = pathExtension(url).lower();
+ if (!extension.isNull() && mimeType.isEmpty()) {
+ PluginModuleInfo plugin = findPluginForExtension(extension, mimeType);
+ if (!plugin.path.isNull())
+ return plugin;
+
+ // Finally, try to get the MIME type from the extension in a platform specific manner and use that.
+ String extensionMimeType = getMIMETypeForExtension(extension);
+ if (!extensionMimeType.isNull()) {
+ PluginModuleInfo plugin = findPluginForMIMEType(extensionMimeType);
+ if (!plugin.path.isNull()) {
+ mimeType = extensionMimeType;
+ return plugin;
+ }
+ }
+ }
+
+ return PluginModuleInfo();
+}
+
+PluginModuleInfo PluginInfoStore::infoForPluginWithPath(const String& pluginPath) const
+{
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ if (m_plugins[i].path == pluginPath)
+ return m_plugins[i];
+ }
+
+ ASSERT_NOT_REACHED();
+ return PluginModuleInfo();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
new file mode 100644
index 000000000..4bfecb424
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
@@ -0,0 +1,91 @@
+/*
+ * 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 PluginInfoStore_h
+#define PluginInfoStore_h
+
+#include "PluginModuleInfo.h"
+
+namespace WebCore {
+ class KURL;
+}
+
+namespace WebKit {
+
+class PluginInfoStore {
+ WTF_MAKE_NONCOPYABLE(PluginInfoStore);
+
+public:
+ PluginInfoStore();
+
+ void setAdditionalPluginsDirectories(const Vector<String>&);
+
+ void refresh();
+ Vector<PluginModuleInfo> plugins();
+
+ // Returns the info for a plug-in that can handle the given MIME type.
+ // If the MIME type is null, the file extension of the given url will be used to infer the
+ // plug-in type. In that case, mimeType will be filled in with the right MIME type.
+ PluginModuleInfo findPlugin(String& mimeType, const WebCore::KURL&);
+
+ // Returns the info for the plug-in with the given path.
+ PluginModuleInfo infoForPluginWithPath(const String& pluginPath) const;
+
+private:
+
+ PluginModuleInfo findPluginForMIMEType(const String& mimeType) const;
+ PluginModuleInfo findPluginForExtension(const String& extension, String& mimeType) const;
+
+ void loadPluginsIfNecessary();
+ static void loadPlugin(Vector<PluginModuleInfo>& plugins, const String& pluginPath);
+
+ // Platform-specific member functions:
+
+ // Returns paths to directories that should be searched for plug-ins (via pluginPathsInDirectory).
+ static Vector<String> pluginsDirectories();
+
+ // Returns paths to all plug-ins in the specified directory.
+ static Vector<String> pluginPathsInDirectory(const String& directory);
+
+ // Returns paths to individual plug-ins that won't be found via pluginsDirectories/pluginPathsInDirectory.
+ static Vector<String> individualPluginPaths();
+
+ // Load plug-in info for the plug-in with the specified path.
+ static bool getPluginInfo(const String& pluginPath, PluginModuleInfo&);
+
+ // Return whether this plug-in should be used (added to the list of plug-ins) or not.
+ static bool shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo&);
+
+ // Get the MIME type for the given extension.
+ static String getMIMETypeForExtension(const String& extension);
+
+ Vector<String> m_additionalPluginsDirectories;
+ Vector<PluginModuleInfo> m_plugins;
+ bool m_pluginListIsUpToDate;
+};
+
+} // namespace WebKit
+
+#endif // PluginInfoStore_h
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp
new file mode 100644
index 000000000..35da365d7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "PluginProcessManager.h"
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessProxy.h"
+#include "WebContext.h"
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+PluginProcessManager& PluginProcessManager::shared()
+{
+ DEFINE_STATIC_LOCAL(PluginProcessManager, pluginProcessManager, ());
+ return pluginProcessManager;
+}
+
+PluginProcessManager::PluginProcessManager()
+{
+}
+
+void PluginProcessManager::getPluginProcessConnection(const PluginInfoStore& pluginInfoStore, const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply)
+{
+ ASSERT(!pluginPath.isNull());
+
+ PluginModuleInfo plugin = pluginInfoStore.infoForPluginWithPath(pluginPath);
+ PluginProcessProxy* pluginProcess = getOrCreatePluginProcess(plugin);
+ pluginProcess->getPluginProcessConnection(reply);
+}
+
+void PluginProcessManager::removePluginProcessProxy(PluginProcessProxy* pluginProcessProxy)
+{
+ size_t vectorIndex = m_pluginProcesses.find(pluginProcessProxy);
+ ASSERT(vectorIndex != notFound);
+
+ m_pluginProcesses.remove(vectorIndex);
+}
+
+void PluginProcessManager::getSitesWithData(const PluginModuleInfo& plugin, WebPluginSiteDataManager* webPluginSiteDataManager, uint64_t callbackID)
+{
+ PluginProcessProxy* pluginProcess = getOrCreatePluginProcess(plugin);
+ pluginProcess->getSitesWithData(webPluginSiteDataManager, callbackID);
+}
+
+void PluginProcessManager::clearSiteData(const PluginModuleInfo& plugin, WebPluginSiteDataManager* webPluginSiteDataManager, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
+{
+ PluginProcessProxy* pluginProcess = getOrCreatePluginProcess(plugin);
+ pluginProcess->clearSiteData(webPluginSiteDataManager, sites, flags, maxAgeInSeconds, callbackID);
+}
+
+void PluginProcessManager::pluginSyncMessageSendTimedOut(const String& pluginPath)
+{
+ PluginProcessProxy* pluginProcess = pluginProcessWithPath(pluginPath);
+ if (!pluginProcess)
+ return;
+
+ pluginProcess->terminate();
+}
+
+PluginProcessProxy* PluginProcessManager::pluginProcessWithPath(const String& pluginPath)
+{
+ for (size_t i = 0; i < m_pluginProcesses.size(); ++i) {
+ if (m_pluginProcesses[i]->pluginInfo().path == pluginPath)
+ return m_pluginProcesses[i];
+ }
+ return 0;
+}
+
+PluginProcessProxy* PluginProcessManager::getOrCreatePluginProcess(const PluginModuleInfo& plugin)
+{
+ if (PluginProcessProxy* pluginProcess = pluginProcessWithPath(plugin.path))
+ return pluginProcess;
+
+ PluginProcessProxy* pluginProcess = PluginProcessProxy::create(this, plugin).leakPtr();
+ m_pluginProcesses.append(pluginProcess);
+
+ return pluginProcess;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h
new file mode 100644
index 000000000..935967bdd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h
@@ -0,0 +1,74 @@
+/*
+ * 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 PluginProcessManager_h
+#define PluginProcessManager_h
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginModuleInfo.h"
+#include "WebProcessProxyMessages.h"
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class PluginInfoStore;
+class PluginProcessProxy;
+class WebProcessProxy;
+class WebPluginSiteDataManager;
+
+class PluginProcessManager {
+ WTF_MAKE_NONCOPYABLE(PluginProcessManager);
+public:
+ static PluginProcessManager& shared();
+
+ void getPluginProcessConnection(const PluginInfoStore&, const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>);
+ void removePluginProcessProxy(PluginProcessProxy*);
+
+ void getSitesWithData(const PluginModuleInfo&, WebPluginSiteDataManager*, uint64_t callbackID);
+ void clearSiteData(const PluginModuleInfo&, WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
+
+ void pluginSyncMessageSendTimedOut(const String& pluginPath);
+
+private:
+ PluginProcessManager();
+
+ PluginProcessProxy* getOrCreatePluginProcess(const PluginModuleInfo&);
+ PluginProcessProxy* pluginProcessWithPath(const String& pluginPath);
+
+ Vector<PluginProcessProxy*> m_pluginProcesses;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
+
+#endif // PluginProcessManager_h
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp
new file mode 100644
index 000000000..41c7a47cb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp
@@ -0,0 +1,264 @@
+/*
+ * 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 "PluginProcessProxy.h"
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessCreationParameters.h"
+#include "PluginProcessManager.h"
+#include "PluginProcessMessages.h"
+#include "RunLoop.h"
+#include "WebContext.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebPluginSiteDataManager.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include <WebCore/NotImplemented.h>
+
+#if PLATFORM(MAC)
+#include "MachPort.h"
+#endif
+
+namespace WebKit {
+
+PassOwnPtr<PluginProcessProxy> PluginProcessProxy::create(PluginProcessManager* PluginProcessManager, const PluginModuleInfo& pluginInfo)
+{
+ return adoptPtr(new PluginProcessProxy(PluginProcessManager, pluginInfo));
+}
+
+PluginProcessProxy::PluginProcessProxy(PluginProcessManager* PluginProcessManager, const PluginModuleInfo& pluginInfo)
+ : m_pluginProcessManager(PluginProcessManager)
+ , m_pluginInfo(pluginInfo)
+ , m_numPendingConnectionRequests(0)
+#if PLATFORM(MAC)
+ , m_modalWindowIsShowing(false)
+ , m_fullscreenWindowIsShowing(false)
+ , m_preFullscreenAppPresentationOptions(0)
+#endif
+{
+ ProcessLauncher::LaunchOptions launchOptions;
+ launchOptions.processType = ProcessLauncher::PluginProcess;
+#if PLATFORM(MAC)
+ launchOptions.architecture = pluginInfo.pluginArchitecture;
+ launchOptions.executableHeap = PluginProcessProxy::pluginNeedsExecutableHeap(pluginInfo);
+#endif
+
+ m_processLauncher = ProcessLauncher::create(this, launchOptions);
+}
+
+PluginProcessProxy::~PluginProcessProxy()
+{
+}
+
+// Asks the plug-in process to create a new connection to a web process. The connection identifier will be
+// encoded in the given argument encoder and sent back to the connection of the given web process.
+void PluginProcessProxy::getPluginProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply)
+{
+ m_pendingConnectionReplies.append(reply);
+
+ if (m_processLauncher->isLaunching()) {
+ m_numPendingConnectionRequests++;
+ return;
+ }
+
+ // Ask the plug-in process to create a connection. Since the plug-in can be waiting for a synchronous reply
+ // we need to make sure that this message is always processed, even when the plug-in is waiting for a synchronus reply.
+ m_connection->send(Messages::PluginProcess::CreateWebProcessConnection(), 0, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+}
+
+void PluginProcessProxy::getSitesWithData(WebPluginSiteDataManager* webPluginSiteDataManager, uint64_t callbackID)
+{
+ ASSERT(!m_pendingGetSitesReplies.contains(callbackID));
+ m_pendingGetSitesReplies.set(callbackID, webPluginSiteDataManager);
+
+ if (m_processLauncher->isLaunching()) {
+ m_pendingGetSitesRequests.append(callbackID);
+ return;
+ }
+
+ // Ask the plug-in process for the sites with data.
+ m_connection->send(Messages::PluginProcess::GetSitesWithData(callbackID), 0);
+}
+
+void PluginProcessProxy::clearSiteData(WebPluginSiteDataManager* webPluginSiteDataManager, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
+{
+ ASSERT(!m_pendingClearSiteDataReplies.contains(callbackID));
+ m_pendingClearSiteDataReplies.set(callbackID, webPluginSiteDataManager);
+
+ if (m_processLauncher->isLaunching()) {
+ ClearSiteDataRequest request;
+ request.sites = sites;
+ request.flags = flags;
+ request.maxAgeInSeconds = maxAgeInSeconds;
+ request.callbackID = callbackID;
+ m_pendingClearSiteDataRequests.append(request);
+ return;
+ }
+
+ // Ask the plug-in process to clear the site data.
+ m_connection->send(Messages::PluginProcess::ClearSiteData(sites, flags, maxAgeInSeconds, callbackID), 0);
+}
+
+void PluginProcessProxy::terminate()
+{
+ m_processLauncher->terminateProcess();
+}
+
+void PluginProcessProxy::pluginProcessCrashedOrFailedToLaunch()
+{
+ // The plug-in process must have crashed or exited, send any pending sync replies we might have.
+ while (!m_pendingConnectionReplies.isEmpty()) {
+ RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
+
+#if PLATFORM(MAC)
+ reply->send(CoreIPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
+#elif USE(UNIX_DOMAIN_SOCKETS)
+ reply->send(CoreIPC::Attachment());
+#else
+ notImplemented();
+#endif
+ }
+
+ while (!m_pendingGetSitesReplies.isEmpty())
+ didGetSitesWithData(Vector<String>(), m_pendingGetSitesReplies.begin()->first);
+
+ while (!m_pendingClearSiteDataReplies.isEmpty())
+ didClearSiteData(m_pendingClearSiteDataReplies.begin()->first);
+
+ // Tell the plug-in process manager to forget about this plug-in process proxy.
+ m_pluginProcessManager->removePluginProcessProxy(this);
+ delete this;
+}
+
+void PluginProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceivePluginProcessProxyMessage(connection, messageID, arguments);
+}
+
+void PluginProcessProxy::didClose(CoreIPC::Connection*)
+{
+#if PLATFORM(MAC)
+ if (m_modalWindowIsShowing)
+ endModal();
+
+ if (m_fullscreenWindowIsShowing)
+ exitFullscreen();
+#endif
+
+ const Vector<WebContext*>& contexts = WebContext::allContexts();
+ for (size_t i = 0; i < contexts.size(); ++i)
+ contexts[i]->sendToAllProcesses(Messages::WebProcess::PluginProcessCrashed(m_pluginInfo.path));
+
+ // This will cause us to be deleted.
+ pluginProcessCrashedOrFailedToLaunch();
+}
+
+void PluginProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID)
+{
+}
+
+void PluginProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*)
+{
+}
+
+void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ ASSERT(!m_connection);
+
+ if (!connectionIdentifier) {
+ pluginProcessCrashedOrFailedToLaunch();
+ return;
+ }
+
+ m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
+#if PLATFORM(MAC)
+ m_connection->setShouldCloseConnectionOnMachExceptions();
+#endif
+
+ m_connection->open();
+
+ PluginProcessCreationParameters parameters;
+
+ parameters.pluginPath = m_pluginInfo.path;
+
+ platformInitializePluginProcess(parameters);
+
+ // Initialize the plug-in host process.
+ m_connection->send(Messages::PluginProcess::InitializePluginProcess(parameters), 0);
+
+ // Send all our pending requests.
+ for (size_t i = 0; i < m_pendingGetSitesRequests.size(); ++i)
+ m_connection->send(Messages::PluginProcess::GetSitesWithData(m_pendingGetSitesRequests[i]), 0);
+ m_pendingGetSitesRequests.clear();
+
+ for (size_t i = 0; i < m_pendingClearSiteDataRequests.size(); ++i) {
+ const ClearSiteDataRequest& request = m_pendingClearSiteDataRequests[i];
+ m_connection->send(Messages::PluginProcess::ClearSiteData(request.sites, request.flags, request.maxAgeInSeconds, request.callbackID), 0);
+ }
+ m_pendingClearSiteDataRequests.clear();
+
+ for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i)
+ m_connection->send(Messages::PluginProcess::CreateWebProcessConnection(), 0);
+
+ m_numPendingConnectionRequests = 0;
+}
+
+void PluginProcessProxy::didCreateWebProcessConnection(const CoreIPC::Attachment& connectionIdentifier)
+{
+ ASSERT(!m_pendingConnectionReplies.isEmpty());
+
+ // Grab the first pending connection reply.
+ RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
+
+#if PLATFORM(MAC)
+ reply->send(CoreIPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
+#elif USE(UNIX_DOMAIN_SOCKETS)
+ reply->send(connectionIdentifier);
+#else
+ notImplemented();
+#endif
+}
+
+void PluginProcessProxy::didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID)
+{
+ RefPtr<WebPluginSiteDataManager> webPluginSiteDataManager = m_pendingGetSitesReplies.take(callbackID);
+ ASSERT(webPluginSiteDataManager);
+
+ webPluginSiteDataManager->didGetSitesWithDataForSinglePlugin(sites, callbackID);
+}
+
+void PluginProcessProxy::didClearSiteData(uint64_t callbackID)
+{
+ RefPtr<WebPluginSiteDataManager> webPluginSiteDataManager = m_pendingClearSiteDataReplies.take(callbackID);
+ ASSERT(webPluginSiteDataManager);
+
+ webPluginSiteDataManager->didClearSiteDataForSinglePlugin(callbackID);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h
new file mode 100644
index 000000000..a75d5b138
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h
@@ -0,0 +1,164 @@
+/*
+ * 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 PluginProcessProxy_h
+#define PluginProcessProxy_h
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "Connection.h"
+#include "PluginModuleInfo.h"
+#include "ProcessLauncher.h"
+#include "WebProcessProxyMessages.h"
+#include <wtf/Deque.h>
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+OBJC_CLASS NSObject;
+OBJC_CLASS WKPlaceholderModalWindow;
+#endif
+
+// FIXME: This is platform specific.
+namespace CoreIPC {
+ class MachPort;
+}
+
+namespace WebKit {
+
+class PluginProcessManager;
+class WebPluginSiteDataManager;
+class WebProcessProxy;
+struct PluginProcessCreationParameters;
+
+class PluginProcessProxy : CoreIPC::Connection::Client, ProcessLauncher::Client {
+public:
+ static PassOwnPtr<PluginProcessProxy> create(PluginProcessManager*, const PluginModuleInfo&);
+ ~PluginProcessProxy();
+
+ const PluginModuleInfo& pluginInfo() const { return m_pluginInfo; }
+
+ // Asks the plug-in process to create a new connection to a web process. The connection identifier will be
+ // encoded in the given argument encoder and sent back to the connection of the given web process.
+ void getPluginProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>);
+
+ // Asks the plug-in process to get a list of domains for which the plug-in has data stored.
+ void getSitesWithData(WebPluginSiteDataManager*, uint64_t callbackID);
+
+ // Asks the plug-in process to clear the data for the given sites.
+ void clearSiteData(WebPluginSiteDataManager*, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
+
+ // Terminates the plug-in process.
+ void terminate();
+
+#if PLATFORM(MAC)
+ // Returns whether the plug-in needs the heap to be marked executable.
+ static bool pluginNeedsExecutableHeap(const PluginModuleInfo&);
+
+ // Creates a property list in ~/Library/Preferences that contains all the MIME types supported by the plug-in.
+ static bool createPropertyListFile(const PluginModuleInfo&);
+#endif
+
+private:
+ PluginProcessProxy(PluginProcessManager*, const PluginModuleInfo&);
+
+ void pluginProcessCrashedOrFailedToLaunch();
+
+ // CoreIPC::Connection::Client
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didClose(CoreIPC::Connection*);
+ virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
+ virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
+
+ // ProcessLauncher::Client
+ virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
+
+ // Message handlers
+ void didReceivePluginProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didCreateWebProcessConnection(const CoreIPC::Attachment&);
+ void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID);
+ void didClearSiteData(uint64_t callbackID);
+
+#if PLATFORM(MAC)
+ bool getPluginProcessSerialNumber(ProcessSerialNumber&);
+ void makePluginProcessTheFrontProcess();
+ void makeUIProcessTheFrontProcess();
+
+ void setFullscreenWindowIsShowing(bool);
+ void enterFullscreen();
+ void exitFullscreen();
+
+ void setModalWindowIsShowing(bool);
+ void beginModal();
+ void endModal();
+
+ void applicationDidBecomeActive();
+#endif
+
+ void platformInitializePluginProcess(PluginProcessCreationParameters& parameters);
+
+ // The plug-in host process manager.
+ PluginProcessManager* m_pluginProcessManager;
+
+ // Information about the plug-in.
+ PluginModuleInfo m_pluginInfo;
+
+ // The connection to the plug-in host process.
+ RefPtr<CoreIPC::Connection> m_connection;
+
+ // The process launcher for the plug-in host process.
+ RefPtr<ProcessLauncher> m_processLauncher;
+
+ Deque<RefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> > m_pendingConnectionReplies;
+
+ Vector<uint64_t> m_pendingGetSitesRequests;
+ HashMap<uint64_t, RefPtr<WebPluginSiteDataManager> > m_pendingGetSitesReplies;
+
+ struct ClearSiteDataRequest {
+ Vector<String> sites;
+ uint64_t flags;
+ uint64_t maxAgeInSeconds;
+ uint64_t callbackID;
+ };
+ Vector<ClearSiteDataRequest> m_pendingClearSiteDataRequests;
+ HashMap<uint64_t, RefPtr<WebPluginSiteDataManager> > m_pendingClearSiteDataReplies;
+
+ // If createPluginConnection is called while the process is still launching we'll keep count of it and send a bunch of requests
+ // when the process finishes launching.
+ unsigned m_numPendingConnectionRequests;
+
+#if PLATFORM(MAC)
+ RetainPtr<NSObject> m_activationObserver;
+ RetainPtr<WKPlaceholderModalWindow *> m_placeholderWindow;
+ bool m_modalWindowIsShowing;
+ bool m_fullscreenWindowIsShowing;
+ unsigned m_preFullscreenAppPresentationOptions;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
+
+#endif // PluginProcessProxy_h
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in
new file mode 100644
index 000000000..7b59aefec
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in
@@ -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.
+
+#if ENABLE(PLUGIN_PROCESS)
+
+messages -> PluginProcessProxy {
+ DidCreateWebProcessConnection(CoreIPC::Attachment connectionIdentifier)
+
+ DidGetSitesWithData(Vector<WTF::String> sites, uint64_t callbackID)
+ DidClearSiteData(uint64_t callbackID)
+
+#if PLATFORM(MAC)
+ SetModalWindowIsShowing(bool modalWindowIsShowing)
+ SetFullscreenWindowIsShowing(bool fullscreenWindowIsShowing)
+#endif
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp
new file mode 100644
index 000000000..553ea727b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.cpp
@@ -0,0 +1,299 @@
+/*
+ * 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 "WebPluginSiteDataManager.h"
+
+#include "ImmutableArray.h"
+#include "PluginProcessManager.h"
+#include "WebContext.h"
+#include "WebProcessMessages.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if ENABLE(PLUGIN_PROCESS)
+class WebPluginSiteDataManager::GetSitesWithDataState {
+public:
+ explicit GetSitesWithDataState(WebPluginSiteDataManager* webPluginSiteDataManager, uint64_t callbackID)
+ : m_webPluginSiteDataManager(webPluginSiteDataManager)
+ , m_callbackID(callbackID)
+ , m_plugins(webPluginSiteDataManager->m_webContext->pluginInfoStore().plugins())
+ {
+ }
+
+ void getSitesWithDataForNextPlugin()
+ {
+ if (m_plugins.isEmpty()) {
+ Vector<String> sites;
+ copyToVector(m_sites, sites);
+
+ m_webPluginSiteDataManager->didGetSitesWithDataForAllPlugins(sites, m_callbackID);
+ return;
+ }
+
+ PluginProcessManager::shared().getSitesWithData(m_plugins.last(), m_webPluginSiteDataManager, m_callbackID);
+ m_plugins.removeLast();
+ }
+
+ void didGetSitesWithDataForSinglePlugin(const Vector<String>& sites)
+ {
+ for (size_t i = 0; i < sites.size(); ++i)
+ m_sites.add(sites[i]);
+
+ getSitesWithDataForNextPlugin();
+ }
+
+private:
+ WebPluginSiteDataManager* m_webPluginSiteDataManager;
+ uint64_t m_callbackID;
+ Vector<PluginModuleInfo> m_plugins;
+ HashSet<String> m_sites;
+};
+
+class WebPluginSiteDataManager::ClearSiteDataState {
+public:
+ explicit ClearSiteDataState(WebPluginSiteDataManager* webPluginSiteDataManager, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
+ : m_webPluginSiteDataManager(webPluginSiteDataManager)
+ , m_sites(sites)
+ , m_flags(flags)
+ , m_maxAgeInSeconds(maxAgeInSeconds)
+ , m_callbackID(callbackID)
+ , m_plugins(webPluginSiteDataManager->m_webContext->pluginInfoStore().plugins())
+ {
+ }
+
+ void clearSiteDataForNextPlugin()
+ {
+ if (m_plugins.isEmpty()) {
+ m_webPluginSiteDataManager->didClearSiteDataForAllPlugins(m_callbackID);
+ return;
+ }
+
+ PluginProcessManager::shared().clearSiteData(m_plugins.last(), m_webPluginSiteDataManager, m_sites, m_flags, m_maxAgeInSeconds, m_callbackID);
+ m_plugins.removeLast();
+ }
+
+ void didClearSiteDataForSinglePlugin()
+ {
+ clearSiteDataForNextPlugin();
+ }
+
+private:
+ WebPluginSiteDataManager* m_webPluginSiteDataManager;
+ Vector<String> m_sites;
+ uint64_t m_flags;
+ uint64_t m_maxAgeInSeconds;
+ uint64_t m_callbackID;
+ Vector<PluginModuleInfo> m_plugins;
+};
+#endif // ENABLE(PLUGIN_PROCESS)
+
+PassRefPtr<WebPluginSiteDataManager> WebPluginSiteDataManager::create(WebContext* webContext)
+{
+ return adoptRef(new WebPluginSiteDataManager(webContext));
+}
+
+WebPluginSiteDataManager::WebPluginSiteDataManager(WebContext* webContext)
+ : m_webContext(webContext)
+{
+}
+
+WebPluginSiteDataManager::~WebPluginSiteDataManager()
+{
+ ASSERT(m_arrayCallbacks.isEmpty());
+ ASSERT(m_voidCallbacks.isEmpty());
+#if ENABLE(PLUGIN_PROCESS)
+ ASSERT(m_pendingGetSitesWithData.isEmpty());
+ ASSERT(m_pendingClearSiteData.isEmpty());
+#endif
+}
+
+void WebPluginSiteDataManager::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+
+#if ENABLE(PLUGIN_PROCESS)
+ deleteAllValues(m_pendingGetSitesWithData);
+ m_pendingGetSitesWithData.clear();
+ deleteAllValues(m_pendingClearSiteData);
+ m_pendingClearSiteData.clear();
+#endif
+}
+
+void WebPluginSiteDataManager::getSitesWithData(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+
+ if (!m_webContext) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+#if ENABLE(PLUGIN_PROCESS)
+ ASSERT(!m_pendingGetSitesWithData.contains(callbackID));
+
+ GetSitesWithDataState* state = new GetSitesWithDataState(this, callbackID);
+ m_pendingGetSitesWithData.set(callbackID, state);
+ state->getSitesWithDataForNextPlugin();
+#else
+ m_webContext->relaunchProcessIfNecessary();
+
+ Vector<PluginModuleInfo> plugins = m_webContext->pluginInfoStore().plugins();
+ Vector<String> pluginPaths;
+ for (size_t i = 0; i < plugins.size(); ++i)
+ pluginPaths.append(plugins[i].path);
+
+ // FIXME (Multi-WebProcess): When multi-process is enabled, we must always use a plug-in process for this,
+ // so this code should just be removed.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebProcess::GetSitesWithPluginData(pluginPaths, callbackID));
+#endif
+}
+
+void WebPluginSiteDataManager::didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ Vector<RefPtr<APIObject> > sitesWK(sites.size());
+
+ for (size_t i = 0; i < sites.size(); ++i)
+ sitesWK[i] = WebString::create(sites[i]);
+
+ RefPtr<ImmutableArray> resultArray = ImmutableArray::adopt(sitesWK);
+ callback->performCallbackWithReturnValue(resultArray.get());
+}
+
+void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback> prpCallback)
+{
+ RefPtr<VoidCallback> callback = prpCallback;
+ if (!m_webContext) {
+ callback->invalidate();
+ return;
+ }
+
+ Vector<String> sitesVector;
+
+ // If the array is empty, don't do anything.
+ if (sites) {
+ if (!sites->size()) {
+ callback->performCallback();
+ return;
+ }
+
+ for (size_t i = 0; i < sites->size(); ++i) {
+ if (WebString* site = sites->at<WebString>(i))
+ sitesVector.append(site->string());
+ }
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, callback.release());
+
+#if ENABLE(PLUGIN_PROCESS)
+ ASSERT(!m_pendingClearSiteData.contains(callbackID));
+
+ ClearSiteDataState* state = new ClearSiteDataState(this, sitesVector, flags, maxAgeInSeconds, callbackID);
+ m_pendingClearSiteData.set(callbackID, state);
+ state->clearSiteDataForNextPlugin();
+#else
+ m_webContext->relaunchProcessIfNecessary();
+
+ Vector<PluginModuleInfo> plugins = m_webContext->pluginInfoStore().plugins();
+ Vector<String> pluginPaths;
+ for (size_t i = 0; i < plugins.size(); ++i)
+ pluginPaths.append(plugins[i].path);
+
+ // FIXME (Multi-WebProcess): When multi-process is enabled, we must always use a plug-in process for this,
+ // so this code should just be removed.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebProcess::ClearPluginSiteData(pluginPaths, sitesVector, flags, maxAgeInSeconds, callbackID));
+#endif
+}
+
+void WebPluginSiteDataManager::didClearSiteData(uint64_t callbackID)
+{
+ RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallback();
+}
+
+bool WebPluginSiteDataManager::shouldTerminate(WebProcessProxy*) const
+{
+#if ENABLE(PLUGIN_PROCESS)
+ // When out of process plug-ins are enabled, the web process is not involved in fetching site data.
+ return true;
+#else
+ return m_arrayCallbacks.isEmpty() && m_voidCallbacks.isEmpty();
+#endif
+}
+
+#if ENABLE(PLUGIN_PROCESS)
+void WebPluginSiteDataManager::didGetSitesWithDataForSinglePlugin(const Vector<String>& sites, uint64_t callbackID)
+{
+ GetSitesWithDataState* state = m_pendingGetSitesWithData.get(callbackID);
+ ASSERT(state);
+
+ state->didGetSitesWithDataForSinglePlugin(sites);
+}
+
+void WebPluginSiteDataManager::didGetSitesWithDataForAllPlugins(const Vector<String>& sites, uint64_t callbackID)
+{
+ OwnPtr<GetSitesWithDataState> state = adoptPtr(m_pendingGetSitesWithData.take(callbackID));
+ ASSERT(state);
+
+ didGetSitesWithData(sites, callbackID);
+}
+
+void WebPluginSiteDataManager::didClearSiteDataForSinglePlugin(uint64_t callbackID)
+{
+ ClearSiteDataState* state = m_pendingClearSiteData.get(callbackID);
+ ASSERT(state);
+
+ state->didClearSiteDataForSinglePlugin();
+}
+
+void WebPluginSiteDataManager::didClearSiteDataForAllPlugins(uint64_t callbackID)
+{
+ OwnPtr<ClearSiteDataState> state = adoptPtr(m_pendingClearSiteData.take(callbackID));
+ ASSERT(state);
+
+ didClearSiteData(callbackID);
+}
+
+#endif
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.h b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.h
new file mode 100644
index 000000000..9efa17513
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/WebPluginSiteDataManager.h
@@ -0,0 +1,88 @@
+/*
+ * 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 WebPluginSiteDataManagerh
+#define WebPluginSiteDataManager_h
+
+#include "APIObject.h"
+#include "Arguments.h"
+#include "GenericCallback.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebContext;
+class WebProcessProxy;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebPluginSiteDataManager : public APIObject {
+public:
+ static const Type APIType = TypePluginSiteDataManager;
+
+ static PassRefPtr<WebPluginSiteDataManager> create(WebContext*);
+ virtual ~WebPluginSiteDataManager();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void getSitesWithData(PassRefPtr<ArrayCallback>);
+ void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID);
+
+ void clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback>);
+ void didClearSiteData(uint64_t callbackID);
+
+#if ENABLE(PLUGIN_PROCESS)
+ void didGetSitesWithDataForSinglePlugin(const Vector<String>& sites, uint64_t callbackID);
+ void didClearSiteDataForSinglePlugin(uint64_t callbackID);
+#endif
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ explicit WebPluginSiteDataManager(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+ HashMap<uint64_t, RefPtr<VoidCallback> > m_voidCallbacks;
+
+#if ENABLE(PLUGIN_PROCESS)
+ void didGetSitesWithDataForAllPlugins(const Vector<String>& sites, uint64_t callbackID);
+ void didClearSiteDataForAllPlugins(uint64_t callbackID);
+
+ class GetSitesWithDataState;
+ HashMap<uint64_t, GetSitesWithDataState*> m_pendingGetSitesWithData;
+
+ class ClearSiteDataState;
+ HashMap<uint64_t, ClearSiteDataState*> m_pendingClearSiteData;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // WebPluginSiteDataManager_h
diff --git a/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp b/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp
new file mode 100644
index 000000000..4c85772a2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/gtk/PluginProcessProxyGtk.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "PluginProcessProxy.h"
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessCreationParameters.h"
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
new file mode 100644
index 000000000..6c6040781
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
@@ -0,0 +1,102 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#import "NetscapePluginModule.h"
+#import "WebKitSystemInterface.h"
+#import <WebCore/WebCoreNSStringExtras.h>
+#import <wtf/HashSet.h>
+#import <wtf/RetainPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Vector<String> PluginInfoStore::pluginsDirectories()
+{
+ Vector<String> pluginsDirectories;
+
+ pluginsDirectories.append([NSHomeDirectory() stringByAppendingPathComponent:@"Library/Internet Plug-Ins"]);
+ pluginsDirectories.append("/Library/Internet Plug-Ins");
+
+ return pluginsDirectories;
+}
+
+// FIXME: Once the UI process knows the difference between the main thread and the web thread we can drop this and just use
+// String::createCFString.
+static CFStringRef safeCreateCFString(const String& string)
+{
+ return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length());
+}
+
+Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
+{
+ Vector<String> pluginPaths;
+
+ RetainPtr<CFStringRef> directoryCFString(AdoptCF, safeCreateCFString(directory));
+
+ NSArray *filenames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:(NSString *)directoryCFString.get() error:nil];
+ for (NSString *filename in filenames)
+ pluginPaths.append([(NSString *)directoryCFString.get() stringByAppendingPathComponent:filename]);
+
+ return pluginPaths;
+}
+
+Vector<String> PluginInfoStore::individualPluginPaths()
+{
+ return Vector<String>();
+}
+
+bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
+{
+ for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
+ const PluginModuleInfo& loadedPlugin = alreadyLoadedPlugins[i];
+
+ // If a plug-in with the same bundle identifier already exists, we don't want to load it.
+ if (loadedPlugin.bundleIdentifier == plugin.bundleIdentifier)
+ return false;
+ }
+
+ return true;
+}
+
+String PluginInfoStore::getMIMETypeForExtension(const String& extension)
+{
+ // FIXME: This should just call MIMETypeRegistry::getMIMETypeForExtension and be
+ // strength reduced into the callsite once we can safely convert String
+ // to CFStringRef off the main thread.
+
+ RetainPtr<CFStringRef> extensionCFString(AdoptCF, safeCreateCFString(extension));
+ return WKGetMIMETypeForExtension((NSString *)extensionCFString.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
new file mode 100644
index 000000000..b072417fe
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
@@ -0,0 +1,245 @@
+/*
+ * 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 "PluginProcessProxy.h"
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#import "EnvironmentVariables.h"
+#import "PluginProcessCreationParameters.h"
+#import "WebKitSystemInterface.h"
+#import <WebCore/FileSystem.h>
+#import <spawn.h>
+#import <wtf/text/CString.h>
+
+@interface WKPlaceholderModalWindow : NSWindow
+@end
+
+@implementation WKPlaceholderModalWindow
+
+// Prevent NSApp from calling requestUserAttention: when the window is shown
+// modally, even if the app is inactive. See 6823049.
+- (BOOL)_wantsUserAttention
+{
+ return NO;
+}
+
+@end
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool PluginProcessProxy::pluginNeedsExecutableHeap(const PluginModuleInfo& pluginInfo)
+{
+ static bool forceNonexecutableHeapForPlugins = [[NSUserDefaults standardUserDefaults] boolForKey:@"ForceNonexecutableHeapForPlugins"];
+ if (forceNonexecutableHeapForPlugins)
+ return false;
+
+ if (pluginInfo.bundleIdentifier == "com.apple.QuickTime Plugin.plugin")
+ return false;
+
+ return true;
+}
+
+bool PluginProcessProxy::createPropertyListFile(const PluginModuleInfo& plugin)
+{
+ NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"];
+ NSString *frameworksPath = [[webKit2Bundle bundlePath] stringByDeletingLastPathComponent];
+ const char* frameworkExecutablePath = [[webKit2Bundle executablePath] fileSystemRepresentation];
+
+ NSString *processPath = [webKit2Bundle pathForAuxiliaryExecutable:@"PluginProcess.app"];
+ NSString *processAppExecutablePath = [[NSBundle bundleWithPath:processPath] executablePath];
+
+ CString pluginPathString = fileSystemRepresentation(plugin.path);
+
+ posix_spawnattr_t attr;
+ posix_spawnattr_init(&attr);
+
+ cpu_type_t cpuTypes[] = { plugin.pluginArchitecture };
+ size_t outCount = 0;
+ posix_spawnattr_setbinpref_np(&attr, 1, cpuTypes, &outCount);
+
+ EnvironmentVariables environmentVariables;
+
+ // To make engineering builds work, if the path is outside of /System set up
+ // DYLD_FRAMEWORK_PATH to pick up other frameworks, but don't do it for the
+ // production configuration because it involves extra file system access.
+ if (![frameworksPath hasPrefix:@"/System/"])
+ environmentVariables.appendValue("DYLD_FRAMEWORK_PATH", [frameworksPath fileSystemRepresentation], ':');
+
+ const char* args[] = { [processAppExecutablePath fileSystemRepresentation], frameworkExecutablePath, "-type", "pluginprocess", "-createPluginMIMETypesPreferences", pluginPathString.data(), 0 };
+
+ pid_t pid;
+ int result = posix_spawn(&pid, args[0], 0, &attr, const_cast<char* const*>(args), environmentVariables.environmentPointer());
+ posix_spawnattr_destroy(&attr);
+
+ if (result)
+ return false;
+ int status;
+ if (waitpid(pid, &status, 0) < 0)
+ return false;
+
+ if (!WIFEXITED(status))
+ return false;
+
+ if (WEXITSTATUS(status) != EXIT_SUCCESS)
+ return false;
+
+ return true;
+}
+
+void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
+{
+#if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
+ parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
+ mach_port_t renderServerPort = WKInitializeRenderServer();
+ if (renderServerPort != MACH_PORT_NULL)
+ parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
+#endif
+}
+
+bool PluginProcessProxy::getPluginProcessSerialNumber(ProcessSerialNumber& pluginProcessSerialNumber)
+{
+ pid_t pluginProcessPID = m_processLauncher->processIdentifier();
+ return GetProcessForPID(pluginProcessPID, &pluginProcessSerialNumber) == noErr;
+}
+
+void PluginProcessProxy::makePluginProcessTheFrontProcess()
+{
+ ProcessSerialNumber pluginProcessSerialNumber;
+ if (!getPluginProcessSerialNumber(pluginProcessSerialNumber))
+ return;
+
+ SetFrontProcess(&pluginProcessSerialNumber);
+}
+
+void PluginProcessProxy::makeUIProcessTheFrontProcess()
+{
+ ProcessSerialNumber processSerialNumber;
+ GetCurrentProcess(&processSerialNumber);
+ SetFrontProcess(&processSerialNumber);
+}
+
+void PluginProcessProxy::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing)
+{
+ if (m_fullscreenWindowIsShowing == fullscreenWindowIsShowing)
+ return;
+
+ m_fullscreenWindowIsShowing = fullscreenWindowIsShowing;
+ if (m_fullscreenWindowIsShowing)
+ enterFullscreen();
+ else
+ exitFullscreen();
+}
+
+void PluginProcessProxy::enterFullscreen()
+{
+ // Get the current presentation options.
+ m_preFullscreenAppPresentationOptions = [NSApp presentationOptions];
+
+ // Figure out which presentation options to use.
+ unsigned presentationOptions = m_preFullscreenAppPresentationOptions & ~(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar);
+ presentationOptions |= NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar;
+
+ [NSApp setPresentationOptions:presentationOptions];
+ makePluginProcessTheFrontProcess();
+}
+
+void PluginProcessProxy::exitFullscreen()
+{
+ // If the plug-in host is the current application then we should bring ourselves to the front when it exits full-screen mode.
+ ProcessSerialNumber frontProcessSerialNumber;
+ GetFrontProcess(&frontProcessSerialNumber);
+
+ // The UI process must be the front process in order to change the presentation mode.
+ makeUIProcessTheFrontProcess();
+ [NSApp setPresentationOptions:m_preFullscreenAppPresentationOptions];
+
+ ProcessSerialNumber pluginProcessSerialNumber;
+ if (!getPluginProcessSerialNumber(pluginProcessSerialNumber))
+ return;
+
+ // If the plug-in process was not the front process, switch back to the previous front process.
+ // (Otherwise we'll keep the UI process as the front process).
+ Boolean isPluginProcessFrontProcess;
+ SameProcess(&frontProcessSerialNumber, &pluginProcessSerialNumber, &isPluginProcessFrontProcess);
+ if (!isPluginProcessFrontProcess)
+ SetFrontProcess(&frontProcessSerialNumber);
+}
+
+void PluginProcessProxy::setModalWindowIsShowing(bool modalWindowIsShowing)
+{
+ if (modalWindowIsShowing == m_modalWindowIsShowing)
+ return;
+
+ m_modalWindowIsShowing = modalWindowIsShowing;
+
+ if (m_modalWindowIsShowing)
+ beginModal();
+ else
+ endModal();
+}
+
+void PluginProcessProxy::beginModal()
+{
+ ASSERT(!m_placeholderWindow);
+ ASSERT(!m_activationObserver);
+
+ m_placeholderWindow.adoptNS([[WKPlaceholderModalWindow alloc] initWithContentRect:NSMakeRect(0, 0, 1, 1) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+ [m_placeholderWindow.get() setReleasedWhenClosed:NO];
+
+ m_activationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:NSApplicationWillBecomeActiveNotification object:NSApp queue:nil
+ usingBlock:^(NSNotification *){ applicationDidBecomeActive(); }];
+
+ [NSApp runModalForWindow:m_placeholderWindow.get()];
+
+ [m_placeholderWindow.get() orderOut:nil];
+ m_placeholderWindow = nullptr;
+}
+
+void PluginProcessProxy::endModal()
+{
+ ASSERT(m_placeholderWindow);
+ ASSERT(m_activationObserver);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:m_activationObserver.get()];
+ m_activationObserver = nullptr;
+
+ [NSApp stopModal];
+
+ makeUIProcessTheFrontProcess();
+}
+
+void PluginProcessProxy::applicationDidBecomeActive()
+{
+ makePluginProcessTheFrontProcess();
+}
+
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp b/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp
new file mode 100644
index 000000000..cc521e0af
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/qt/PluginProcessProxyQt.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 Nokia 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 "PluginProcessProxy.h"
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessCreationParameters.h"
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp b/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
new file mode 100644
index 000000000..caecf7942
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/unix/PluginInfoStoreUnix.cpp
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+// Note: this file is only for UNIX. On other platforms we can reuse the native implementation.
+
+#include "config.h"
+#include "PluginInfoStore.h"
+
+#include "NetscapePluginModule.h"
+#include "PluginDatabase.h"
+#include <WebCore/FileSystem.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Vector<String> PluginInfoStore::pluginsDirectories()
+{
+ Vector<String> result;
+
+ result.append(homeDirectoryPath() + "/.mozilla/plugins");
+ result.append(homeDirectoryPath() + "/.netscape/plugins");
+ result.append("/usr/lib/browser/plugins");
+ result.append("/usr/local/lib/mozilla/plugins");
+ result.append("/usr/lib/firefox/plugins");
+ result.append("/usr/lib64/browser-plugins");
+ result.append("/usr/lib/browser-plugins");
+ result.append("/usr/lib/mozilla/plugins");
+ result.append("/usr/local/netscape/plugins");
+ result.append("/opt/mozilla/plugins");
+ result.append("/opt/mozilla/lib/plugins");
+ result.append("/opt/netscape/plugins");
+ result.append("/opt/netscape/communicator/plugins");
+ result.append("/usr/lib/netscape/plugins");
+ result.append("/usr/lib/netscape/plugins-libc5");
+ result.append("/usr/lib/netscape/plugins-libc6");
+ result.append("/usr/lib64/netscape/plugins");
+ result.append("/usr/lib64/mozilla/plugins");
+ result.append("/usr/lib/nsbrowser/plugins");
+ result.append("/usr/lib64/nsbrowser/plugins");
+
+ String mozillaHome(getenv("MOZILLA_HOME"));
+ if (!mozillaHome.isEmpty())
+ result.append(mozillaHome + "/plugins");
+
+ String mozillaPaths(getenv("MOZ_PLUGIN_PATH"));
+ if (!mozillaPaths.isEmpty()) {
+ Vector<String> paths;
+ mozillaPaths.split(UChar(':'), /* allowEmptyEntries */ false, paths);
+ result.append(paths);
+ }
+
+ return result;
+}
+
+Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
+{
+ Vector<String> result;
+ Vector<String> pluginPaths = listDirectory(directory, String("*.so"));
+ Vector<String>::const_iterator end = pluginPaths.end();
+ for (Vector<String>::const_iterator it = pluginPaths.begin(); it != end; ++it) {
+ if (fileExists(*it))
+ result.append(*it);
+ }
+
+ return result;
+}
+
+Vector<String> PluginInfoStore::individualPluginPaths()
+{
+ return Vector<String>();
+}
+
+bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
+{
+ // We do not do any black-listing presently.
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
new file mode 100644
index 000000000..78d0562d9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
@@ -0,0 +1,408 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#include "NetscapePluginModule.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/PathWalker.h>
+#include <shlwapi.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static inline Vector<int> parseVersionString(const String& versionString)
+{
+ Vector<int> version;
+
+ unsigned startPos = 0;
+ unsigned endPos;
+
+ while (startPos < versionString.length()) {
+ for (endPos = startPos; endPos < versionString.length(); ++endPos)
+ if (versionString[endPos] == '.' || versionString[endPos] == '_')
+ break;
+
+ int versionComponent = versionString.substring(startPos, endPos - startPos).toInt();
+ version.append(versionComponent);
+
+ startPos = endPos + 1;
+ }
+
+ return version;
+}
+
+// This returns whether versionA is higher than versionB
+static inline bool compareVersions(const Vector<int>& versionA, const Vector<int>& versionB)
+{
+ for (unsigned i = 0; i < versionA.size(); i++) {
+ if (i >= versionB.size())
+ return true;
+
+ if (versionA[i] > versionB[i])
+ return true;
+ else if (versionA[i] < versionB[i])
+ return false;
+ }
+
+ // If we come here, the versions are either the same or versionB has an extra component, just return false
+ return false;
+}
+
+static inline String safariPluginsDirectory()
+{
+ static String pluginsDirectory;
+ static bool cachedPluginDirectory = false;
+
+ if (!cachedPluginDirectory) {
+ cachedPluginDirectory = true;
+
+ WCHAR moduleFileNameStr[MAX_PATH];
+ int moduleFileNameLen = ::GetModuleFileNameW(0, moduleFileNameStr, WTF_ARRAY_LENGTH(moduleFileNameStr));
+
+ if (!moduleFileNameLen || moduleFileNameLen == WTF_ARRAY_LENGTH(moduleFileNameStr))
+ return pluginsDirectory;
+
+ if (!::PathRemoveFileSpecW(moduleFileNameStr))
+ return pluginsDirectory;
+
+ pluginsDirectory = String(moduleFileNameStr) + "\\Plugins";
+ }
+
+ return pluginsDirectory;
+}
+
+static inline void addMozillaPluginDirectories(Vector<String>& directories)
+{
+ // Enumerate all Mozilla plugin directories in the registry
+ HKEY key;
+ LONG result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Mozilla", 0, KEY_READ, &key);
+ if (result != ERROR_SUCCESS)
+ return;
+
+ WCHAR name[128];
+ FILETIME lastModified;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = WTF_ARRAY_LENGTH(name);
+ result = ::RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ String extensionsPath = String(name, nameLen) + "\\Extensions";
+ HKEY extensionsKey;
+
+ // Try opening the key
+ result = ::RegOpenKeyExW(key, extensionsPath.charactersWithNullTermination(), 0, KEY_READ, &extensionsKey);
+
+ if (result == ERROR_SUCCESS) {
+ // Now get the plugins directory
+ WCHAR pluginsDirectoryStr[MAX_PATH];
+ DWORD pluginsDirectorySize = sizeof(pluginsDirectoryStr);
+ DWORD type;
+
+ result = ::RegQueryValueExW(extensionsKey, L"Plugins", 0, &type, reinterpret_cast<LPBYTE>(&pluginsDirectoryStr), &pluginsDirectorySize);
+
+ if (result == ERROR_SUCCESS && type == REG_SZ)
+ directories.append(String(pluginsDirectoryStr, pluginsDirectorySize / sizeof(WCHAR) - 1));
+
+ ::RegCloseKey(extensionsKey);
+ }
+ }
+
+ ::RegCloseKey(key);
+}
+
+static inline void addWindowsMediaPlayerPluginDirectory(Vector<String>& directories)
+{
+ // The new WMP Firefox plugin is installed in \PFiles\Plugins if it can't find any Firefox installs
+ WCHAR pluginDirectoryStr[MAX_PATH + 1];
+ DWORD pluginDirectorySize = ::ExpandEnvironmentStringsW(L"%SYSTEMDRIVE%\\PFiles\\Plugins", pluginDirectoryStr, WTF_ARRAY_LENGTH(pluginDirectoryStr));
+
+ if (pluginDirectorySize > 0 && pluginDirectorySize <= WTF_ARRAY_LENGTH(pluginDirectoryStr))
+ directories.append(String(pluginDirectoryStr, pluginDirectorySize - 1));
+
+ DWORD type;
+ WCHAR installationDirectoryStr[MAX_PATH];
+ DWORD installationDirectorySize = sizeof(installationDirectoryStr);
+
+ HRESULT result = ::SHGetValueW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\MediaPlayer", L"Installation Directory", &type, reinterpret_cast<LPBYTE>(&installationDirectoryStr), &installationDirectorySize);
+
+ if (result == ERROR_SUCCESS && type == REG_SZ)
+ directories.append(String(installationDirectoryStr, installationDirectorySize / sizeof(WCHAR) - 1));
+}
+
+static inline void addQuickTimePluginDirectory(Vector<String>& directories)
+{
+ DWORD type;
+ WCHAR installationDirectoryStr[MAX_PATH];
+ DWORD installationDirectorySize = sizeof(installationDirectoryStr);
+
+ HRESULT result = ::SHGetValueW(HKEY_LOCAL_MACHINE, L"Software\\Apple Computer, Inc.\\QuickTime", L"InstallDir", &type, reinterpret_cast<LPBYTE>(&installationDirectoryStr), &installationDirectorySize);
+
+ if (result == ERROR_SUCCESS && type == REG_SZ) {
+ String pluginDir = String(installationDirectoryStr, installationDirectorySize / sizeof(WCHAR) - 1) + "\\plugins";
+ directories.append(pluginDir);
+ }
+}
+
+static inline void addAdobeAcrobatPluginDirectory(Vector<String>& directories)
+{
+ HKEY key;
+ HRESULT result = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Adobe\\Acrobat Reader", 0, KEY_READ, &key);
+ if (result != ERROR_SUCCESS)
+ return;
+
+ WCHAR name[128];
+ FILETIME lastModified;
+
+ Vector<int> latestAcrobatVersion;
+ String latestAcrobatVersionString;
+
+ // Enumerate subkeys
+ for (int i = 0;; i++) {
+ DWORD nameLen = WTF_ARRAY_LENGTH(name);
+ result = ::RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, &lastModified);
+
+ if (result != ERROR_SUCCESS)
+ break;
+
+ Vector<int> acrobatVersion = parseVersionString(String(name, nameLen));
+ if (compareVersions(acrobatVersion, latestAcrobatVersion)) {
+ latestAcrobatVersion = acrobatVersion;
+ latestAcrobatVersionString = String(name, nameLen);
+ }
+ }
+
+ if (!latestAcrobatVersionString.isNull()) {
+ DWORD type;
+ WCHAR acrobatInstallPathStr[MAX_PATH];
+ DWORD acrobatInstallPathSize = sizeof(acrobatInstallPathStr);
+
+ String acrobatPluginKeyPath = "Software\\Adobe\\Acrobat Reader\\" + latestAcrobatVersionString + "\\InstallPath";
+ result = ::SHGetValueW(HKEY_LOCAL_MACHINE, acrobatPluginKeyPath.charactersWithNullTermination(), 0, &type, reinterpret_cast<LPBYTE>(acrobatInstallPathStr), &acrobatInstallPathSize);
+
+ if (result == ERROR_SUCCESS) {
+ String acrobatPluginDirectory = String(acrobatInstallPathStr, acrobatInstallPathSize / sizeof(WCHAR) - 1) + "\\browser";
+ directories.append(acrobatPluginDirectory);
+ }
+ }
+
+ ::RegCloseKey(key);
+}
+
+static inline void addMacromediaPluginDirectories(Vector<String>& directories)
+{
+#if !OS(WINCE)
+ WCHAR systemDirectoryStr[MAX_PATH];
+
+ if (!::GetSystemDirectoryW(systemDirectoryStr, WTF_ARRAY_LENGTH(systemDirectoryStr)))
+ return;
+
+ WCHAR macromediaDirectoryStr[MAX_PATH];
+
+ if (!::PathCombineW(macromediaDirectoryStr, systemDirectoryStr, L"macromed\\Flash"))
+ return;
+
+ directories.append(macromediaDirectoryStr);
+
+ if (!::PathCombineW(macromediaDirectoryStr, systemDirectoryStr, L"macromed\\Shockwave 10"))
+ return;
+
+ directories.append(macromediaDirectoryStr);
+#endif
+}
+
+Vector<String> PluginInfoStore::pluginsDirectories()
+{
+ Vector<String> directories;
+
+ String ourDirectory = safariPluginsDirectory();
+ if (!ourDirectory.isNull())
+ directories.append(ourDirectory);
+
+ addQuickTimePluginDirectory(directories);
+ addAdobeAcrobatPluginDirectory(directories);
+ addMozillaPluginDirectories(directories);
+ addWindowsMediaPlayerPluginDirectory(directories);
+ addMacromediaPluginDirectories(directories);
+
+ return directories;
+}
+
+Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
+{
+ Vector<String> paths;
+
+ PathWalker walker(directory, "*");
+ if (!walker.isValid())
+ return paths;
+
+ do {
+ if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ continue;
+
+ String filename = walker.data().cFileName;
+ if ((!filename.startsWith("np", false) || !filename.endsWith("dll", false)) && (!equalIgnoringCase(filename, "Plugin.dll") || !directory.endsWith("Shockwave 10", false)))
+ continue;
+
+ paths.append(directory + "\\" + filename);
+ } while (walker.step());
+
+ return paths;
+}
+
+static void addPluginPathsFromRegistry(HKEY rootKey, Vector<String>& paths)
+{
+ HKEY key;
+ if (::RegOpenKeyExW(rootKey, L"Software\\MozillaPlugins", 0, KEY_ENUMERATE_SUB_KEYS, &key) != ERROR_SUCCESS)
+ return;
+
+ for (size_t i = 0; ; ++i) {
+ // MSDN says that key names have a maximum length of 255 characters.
+ wchar_t name[256];
+ DWORD nameLen = WTF_ARRAY_LENGTH(name);
+ if (::RegEnumKeyExW(key, i, name, &nameLen, 0, 0, 0, 0) != ERROR_SUCCESS)
+ break;
+
+ wchar_t path[MAX_PATH];
+ DWORD pathSizeInBytes = sizeof(path);
+ DWORD type;
+ if (::SHGetValueW(key, name, L"Path", &type, path, &pathSizeInBytes) != ERROR_SUCCESS)
+ continue;
+ if (type != REG_SZ)
+ continue;
+
+ paths.append(path);
+ }
+
+ ::RegCloseKey(key);
+}
+
+Vector<String> PluginInfoStore::individualPluginPaths()
+{
+ Vector<String> paths;
+
+ addPluginPathsFromRegistry(HKEY_LOCAL_MACHINE, paths);
+ addPluginPathsFromRegistry(HKEY_CURRENT_USER, paths);
+
+ return paths;
+}
+
+static uint64_t fileVersion(DWORD leastSignificant, DWORD mostSignificant)
+{
+ ULARGE_INTEGER version;
+ version.LowPart = leastSignificant;
+ version.HighPart = mostSignificant;
+ return version.QuadPart;
+}
+
+bool PluginInfoStore::getPluginInfo(const String& pluginPath, PluginModuleInfo& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+static bool isOldWindowsMediaPlayerPlugin(const PluginModuleInfo& plugin)
+{
+ return equalIgnoringCase(plugin.info.file, "npdsplay.dll");
+}
+
+static bool isNewWindowsMediaPlayerPlugin(const PluginModuleInfo& plugin)
+{
+ return equalIgnoringCase(plugin.info.file, "np-mswmp.dll");
+}
+
+bool PluginInfoStore::shouldUsePlugin(Vector<PluginModuleInfo>& alreadyLoadedPlugins, const PluginModuleInfo& plugin)
+{
+ if (plugin.info.name == "Citrix ICA Client") {
+ // The Citrix ICA Client plug-in requires a Mozilla-based browser; see <rdar://6418681>.
+ return false;
+ }
+
+ if (plugin.info.name == "Silverlight Plug-In") {
+ // workaround for <rdar://5557379> Crash in Silverlight when opening microsoft.com.
+ // the latest 1.0 version of Silverlight does not reproduce this crash, so allow it
+ // and any newer versions
+ static const uint64_t minimumRequiredVersion = fileVersion(0x51BE0000, 0x00010000);
+ return plugin.fileVersion >= minimumRequiredVersion;
+ }
+
+ if (equalIgnoringCase(plugin.info.file, "npmozax.dll")) {
+ // Bug 15217: Mozilla ActiveX control complains about missing xpcom_core.dll
+ return false;
+ }
+
+ if (equalIgnoringCase(plugin.info.file, "npwpf.dll")) {
+ // Bug 57119: Microsoft Windows Presentation Foundation (WPF) plug-in complains about missing xpcom.dll
+ return false;
+ }
+
+ if (plugin.info.name == "Yahoo Application State Plugin") {
+ // https://bugs.webkit.org/show_bug.cgi?id=26860
+ // Bug in Yahoo Application State plug-in earlier than 1.0.0.6 leads to heap corruption.
+ static const uint64_t minimumRequiredVersion = fileVersion(0x00000006, 0x00010000);
+ return plugin.fileVersion >= minimumRequiredVersion;
+ }
+
+ if (isOldWindowsMediaPlayerPlugin(plugin)) {
+ // Don't load the old Windows Media Player plugin if we've already loaded the new Windows
+ // Media Player plugin.
+ for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
+ if (!isNewWindowsMediaPlayerPlugin(alreadyLoadedPlugins[i]))
+ continue;
+ return false;
+ }
+ return true;
+ }
+
+ if (isNewWindowsMediaPlayerPlugin(plugin)) {
+ // Remove the old Windows Media Player plugin if we've already added it.
+ for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
+ if (!isOldWindowsMediaPlayerPlugin(alreadyLoadedPlugins[i]))
+ continue;
+ alreadyLoadedPlugins.remove(i);
+ }
+ return true;
+ }
+
+ // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading
+ // only the first. <http://webkit.org/b/58469>
+ String pluginFileName = pathGetFileName(plugin.path);
+ for (size_t i = 0; i < alreadyLoadedPlugins.size(); ++i) {
+ const PluginModuleInfo& loadedPlugin = alreadyLoadedPlugins[i];
+
+ // If a plug-in with the same filename already exists, we don't want to load it.
+ if (equalIgnoringCase(pluginFileName, pathGetFileName(loadedPlugin.path)))
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/ProcessModel.h b/Source/WebKit2/UIProcess/ProcessModel.h
new file mode 100644
index 000000000..0e89c65c9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ProcessModel.h
@@ -0,0 +1,39 @@
+/*
+ * 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 ProcessModel_h
+#define ProcessModel_h
+
+namespace WebKit {
+
+enum ProcessModel {
+ ProcessModelSharedSecondaryProcess,
+ ProcessModelSharedSecondaryThread,
+ ProcessModelSecondaryProcess
+};
+
+} // namespace WebKit
+
+#endif // ProcessModel_h
diff --git a/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp b/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp
new file mode 100644
index 000000000..057cc7435
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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 "ResponsivenessTimer.h"
+
+namespace WebKit {
+
+static const double kResponsivenessTimeout = 3;
+
+ResponsivenessTimer::ResponsivenessTimer(ResponsivenessTimer::Client* client)
+ : m_client(client)
+ , m_isResponsive(true)
+ , m_timer(RunLoop::main(), this, &ResponsivenessTimer::timerFired)
+{
+}
+
+ResponsivenessTimer::~ResponsivenessTimer()
+{
+ m_timer.stop();
+}
+
+void ResponsivenessTimer::invalidate()
+{
+ m_timer.stop();
+}
+
+void ResponsivenessTimer::timerFired()
+{
+ // We'll never schedule the timer unless we're responsive.
+ ASSERT(m_isResponsive);
+
+ m_isResponsive = false;
+ m_client->didBecomeUnresponsive(this);
+
+ m_timer.stop();
+}
+
+void ResponsivenessTimer::start()
+{
+ if (m_timer.isActive())
+ return;
+
+ if (!m_isResponsive)
+ return;
+
+ m_timer.startOneShot(kResponsivenessTimeout);
+}
+
+void ResponsivenessTimer::stop()
+{
+ if (!m_isResponsive) {
+ // We got a life sign from the web process!
+ m_client->didBecomeResponsive(this);
+ m_isResponsive = true;
+ }
+
+ m_timer.stop();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/ResponsivenessTimer.h b/Source/WebKit2/UIProcess/ResponsivenessTimer.h
new file mode 100644
index 000000000..659191612
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ResponsivenessTimer.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 ResponsivenessTimer_h
+#define ResponsivenessTimer_h
+
+#include "RunLoop.h"
+
+namespace WebKit {
+
+class ResponsivenessTimer {
+public:
+ class Client {
+ public:
+ virtual ~Client() { }
+ virtual void didBecomeUnresponsive(ResponsivenessTimer*) = 0;
+ virtual void didBecomeResponsive(ResponsivenessTimer*) = 0;
+ };
+
+ ResponsivenessTimer(ResponsivenessTimer::Client*);
+ ~ResponsivenessTimer();
+
+ void start();
+ void stop();
+
+ void invalidate();
+
+ bool isResponsive() { return m_isResponsive; }
+
+private:
+ void timerFired();
+
+ ResponsivenessTimer::Client* m_client;
+ bool m_isResponsive;
+
+ RunLoop::Timer<ResponsivenessTimer> m_timer;
+};
+
+} // namespace WebKit
+
+#endif // ResponsivenessTimer_h
+
diff --git a/Source/WebKit2/UIProcess/TextChecker.h b/Source/WebKit2/UIProcess/TextChecker.h
new file mode 100644
index 000000000..49b5a48c3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TextChecker.h
@@ -0,0 +1,79 @@
+/*
+ * 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 TextChecker_h
+#define TextChecker_h
+
+#include <WebCore/EditorClient.h>
+#include <WebCore/TextCheckerClient.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+struct TextCheckerState;
+
+class TextChecker {
+public:
+ static const TextCheckerState& state();
+ static bool isContinuousSpellCheckingAllowed();
+
+ static void setContinuousSpellCheckingEnabled(bool);
+ static void setGrammarCheckingEnabled(bool);
+
+#if PLATFORM(MAC)
+ static void setAutomaticSpellingCorrectionEnabled(bool);
+ static void setAutomaticQuoteSubstitutionEnabled(bool);
+ static void setAutomaticDashSubstitutionEnabled(bool);
+ static void setAutomaticLinkDetectionEnabled(bool);
+ static void setAutomaticTextReplacementEnabled(bool);
+
+ static bool isSmartInsertDeleteEnabled();
+ static void setSmartInsertDeleteEnabled(bool);
+
+ static bool substitutionsPanelIsShowing();
+ static void toggleSubstitutionsPanelIsShowing();
+#endif
+
+ static void continuousSpellCheckingEnabledStateChanged(bool);
+ static void grammarCheckingEnabledStateChanged(bool);
+ static int64_t uniqueSpellDocumentTag(WebPageProxy*);
+ static void closeSpellDocumentWithTag(int64_t);
+#if USE(UNIFIED_TEXT_CHECKING)
+ static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
+#endif
+ static void checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength);
+ static void checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
+ static bool spellingUIIsShowing();
+ static void toggleSpellingUIIsShowing();
+ static void updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord);
+ static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const WebCore::GrammarDetail&);
+ static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
+ static void learnWord(int64_t spellDocumentTag, const String& word);
+ static void ignoreWord(int64_t spellDocumentTag, const String& word);
+};
+
+} // namespace WebKit
+
+#endif // TextChecker_h
diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp
new file mode 100644
index 000000000..6f544407e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp
@@ -0,0 +1,96 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "TiledDrawingAreaProxy.h"
+
+#if USE(TILED_BACKING_STORE)
+#include "DrawingAreaMessages.h"
+#include "DrawingAreaProxyMessages.h"
+#include "MessageID.h"
+#include "NotImplemented.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<TiledDrawingAreaProxy> TiledDrawingAreaProxy::create(PlatformWebView* webView, WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new TiledDrawingAreaProxy(webView, webPageProxy));
+}
+
+TiledDrawingAreaProxy::TiledDrawingAreaProxy(PlatformWebView* webView, WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaTypeTiled, webPageProxy)
+ , m_isWaitingForDidSetFrameNotification(false)
+ , m_webView(webView)
+{
+}
+
+TiledDrawingAreaProxy::~TiledDrawingAreaProxy()
+{
+}
+
+void TiledDrawingAreaProxy::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentRect, float scale)
+{
+ page()->process()->send(Messages::DrawingArea::SetVisibleContentRectAndScale(visibleContentRect, scale), page()->pageID());
+}
+
+void TiledDrawingAreaProxy::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector)
+{
+ page()->process()->send(Messages::DrawingArea::SetVisibleContentRectTrajectoryVector(trajectoryVector), page()->pageID());
+}
+
+void TiledDrawingAreaProxy::renderNextFrame()
+{
+}
+
+void TiledDrawingAreaProxy::sizeDidChange()
+{
+ WebPageProxy* page = this->page();
+ if (!page || !page->isValid())
+ return;
+
+ if (m_size.isEmpty())
+ return;
+
+ if (m_isWaitingForDidSetFrameNotification)
+ return;
+ m_isWaitingForDidSetFrameNotification = true;
+
+ page->process()->responsivenessTimer()->start();
+ page->process()->send(Messages::DrawingArea::SetSize(m_size), page->pageID());
+}
+
+void TiledDrawingAreaProxy::deviceScaleFactorDidChange()
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h
new file mode 100644
index 000000000..855977de9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h
@@ -0,0 +1,113 @@
+/*
+ * 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 TiledDrawingAreaProxy_h
+#define TiledDrawingAreaProxy_h
+
+#if USE(TILED_BACKING_STORE)
+
+#include "DrawingAreaProxy.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntRect.h>
+#include <wtf/HashSet.h>
+
+#include "RunLoop.h"
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#ifdef __OBJC__
+@class WKView;
+#else
+class WKView;
+#endif
+#endif
+
+namespace WebCore {
+class GraphicsContext;
+}
+
+#if PLATFORM(QT)
+class QQuickWebPage;
+typedef QQuickWebPage PlatformWebView;
+#endif
+
+namespace WebKit {
+
+class ShareableBitmap;
+class TiledDrawingAreaTileSet;
+class WebPageProxy;
+
+#if PLATFORM(MAC)
+typedef WKView PlatformWebView;
+#elif PLATFORM(WIN)
+class WebView;
+typedef WebView PlatformWebView;
+#endif
+
+class TiledDrawingAreaProxy : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<TiledDrawingAreaProxy> create(PlatformWebView* webView, WebPageProxy*);
+
+ TiledDrawingAreaProxy(PlatformWebView*, WebPageProxy*);
+ virtual ~TiledDrawingAreaProxy();
+
+ void setVisibleContentRectAndScale(const WebCore::IntRect&, float);
+ void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&);
+ void renderNextFrame();
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void attachCompositingContext(uint32_t /* contextID */) { }
+ virtual void detachCompositingContext() { }
+#endif
+
+private:
+ WebPageProxy* page();
+ void updateWebView(const Vector<WebCore::IntRect>& paintedArea);
+
+ // DrawingAreaProxy
+ virtual void sizeDidChange();
+ virtual void deviceScaleFactorDidChange();
+
+ virtual void createTile(int tileID, const UpdateInfo&);
+ virtual void updateTile(int tileID, const UpdateInfo&);
+ virtual void didRenderFrame();
+ virtual void removeTile(int tileID);
+
+
+private:
+ bool m_isWaitingForDidSetFrameNotification;
+
+ PlatformWebView* m_webView;
+#if PLATFORM(QT)
+ // Maps tile IDs to node IDs.
+ HashMap<int, int> m_tileNodeMap;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // USE(TILED_BACKING_STORE)
+
+#endif // TiledDrawingAreaProxy_h
diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp
new file mode 100644
index 000000000..912d05fd7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp
@@ -0,0 +1,182 @@
+/*
+ * 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 "VisitedLinkProvider.h"
+
+#include "SharedMemory.h"
+#include "VisitedLinkTable.h"
+#include "WebContext.h"
+#include "WebProcessMessages.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const int VisitedLinkTableMaxLoad = 2;
+
+VisitedLinkProvider::VisitedLinkProvider(WebContext* context)
+ : m_context(context)
+ , m_visitedLinksPopulated(false)
+ , m_webProcessHasVisitedLinkState(false)
+ , m_keyCount(0)
+ , m_tableSize(0)
+ , m_pendingVisitedLinksTimer(RunLoop::main(), this, &VisitedLinkProvider::pendingVisitedLinksTimerFired)
+{
+}
+
+void VisitedLinkProvider::processDidFinishLaunching()
+{
+ m_webProcessHasVisitedLinkState = false;
+
+ if (m_keyCount)
+ m_pendingVisitedLinksTimer.startOneShot(0);
+
+ if (m_visitedLinksPopulated)
+ return;
+
+ m_context->populateVisitedLinks();
+
+ m_visitedLinksPopulated = true;
+}
+
+void VisitedLinkProvider::addVisitedLink(LinkHash linkHash)
+{
+ m_pendingVisitedLinks.add(linkHash);
+
+ if (!m_pendingVisitedLinksTimer.isActive())
+ m_pendingVisitedLinksTimer.startOneShot(0);
+}
+
+void VisitedLinkProvider::processDidClose()
+{
+ m_pendingVisitedLinksTimer.stop();
+}
+
+static unsigned nextPowerOf2(unsigned v)
+{
+ // Taken from http://www.cs.utk.edu/~vose/c-stuff/bithacks.html
+ // Devised by Sean Anderson, Sepember 14, 2001
+
+ v--;
+ v |= v >> 1;
+ v |= v >> 2;
+ v |= v >> 4;
+ v |= v >> 8;
+ v |= v >> 16;
+ v++;
+
+ return v;
+}
+
+static unsigned tableSizeForKeyCount(unsigned keyCount)
+{
+ // We want the table to be at least half empty.
+ unsigned tableSize = nextPowerOf2(keyCount * VisitedLinkTableMaxLoad);
+
+ // Ensure that the table size is at least the size of a page.
+ size_t minimumTableSize = SharedMemory::systemPageSize() / sizeof(LinkHash);
+ if (tableSize < minimumTableSize)
+ return minimumTableSize;
+
+ return tableSize;
+}
+
+void VisitedLinkProvider::pendingVisitedLinksTimerFired()
+{
+ Vector<WebCore::LinkHash> pendingVisitedLinks;
+ copyToVector(m_pendingVisitedLinks, pendingVisitedLinks);
+ m_pendingVisitedLinks.clear();
+
+ unsigned currentTableSize = m_tableSize;
+ unsigned newTableSize = tableSizeForKeyCount(m_keyCount + pendingVisitedLinks.size());
+
+ // Links that were added.
+ Vector<WebCore::LinkHash> addedVisitedLinks;
+
+ if (currentTableSize != newTableSize) {
+ // Create a new table.
+ RefPtr<SharedMemory> newTableMemory = SharedMemory::create(newTableSize * sizeof(LinkHash));
+
+ // We failed to create the shared memory.
+ if (!newTableMemory)
+ return;
+
+ memset(newTableMemory->data(), 0, newTableMemory->size());
+
+ RefPtr<SharedMemory> currentTableMemory = m_table.sharedMemory();
+
+ m_table.setSharedMemory(newTableMemory);
+ m_tableSize = newTableSize;
+
+ if (currentTableMemory) {
+ ASSERT(currentTableMemory->size() == currentTableSize * sizeof(LinkHash));
+
+ // Go through the current hash table and re-add all entries to the new hash table.
+ const LinkHash* currentLinkHashes = static_cast<const LinkHash*>(currentTableMemory->data());
+ for (unsigned i = 0; i < currentTableSize; ++i) {
+ LinkHash linkHash = currentLinkHashes[i];
+
+ if (!linkHash)
+ continue;
+
+ // It should always be possible to add the link hash to a new table.
+ if (!m_table.addLinkHash(linkHash))
+ ASSERT_NOT_REACHED();
+ }
+ }
+ }
+
+ for (size_t i = 0; i < pendingVisitedLinks.size(); ++i) {
+ if (m_table.addLinkHash(pendingVisitedLinks[i]))
+ addedVisitedLinks.append(pendingVisitedLinks[i]);
+ }
+
+ m_keyCount += pendingVisitedLinks.size();
+
+ if (!m_webProcessHasVisitedLinkState || currentTableSize != newTableSize) {
+ // Send the new visited link table.
+
+ SharedMemory::Handle handle;
+ if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::ReadOnly))
+ return;
+
+ // FIXME (Multi-WebProcess): Encoding a handle will null it out so we need to create a new
+ // handle for every process. Maybe the ArgumentEncoder should handle this.
+ m_context->sendToAllProcesses(Messages::WebProcess::SetVisitedLinkTable(handle));
+ }
+
+ // We now need to let the web process know that we've added links.
+ if (m_webProcessHasVisitedLinkState && addedVisitedLinks.size() <= 20) {
+ m_context->sendToAllProcesses(Messages::WebProcess::VisitedLinkStateChanged(addedVisitedLinks));
+ return;
+ }
+
+ // Just recalculate all the visited links.
+ m_context->sendToAllProcesses(Messages::WebProcess::AllVisitedLinkStateChanged());
+ m_webProcessHasVisitedLinkState = true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.h b/Source/WebKit2/UIProcess/VisitedLinkProvider.h
new file mode 100644
index 000000000..a428d5b83
--- /dev/null
+++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.h
@@ -0,0 +1,66 @@
+/*
+ * 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 VisitedLinkProvider_h
+#define VisitedLinkProvider_h
+
+#include "RunLoop.h"
+#include "VisitedLinkTable.h"
+#include <WebCore/LinkHash.h>
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WebContext;
+
+class VisitedLinkProvider {
+ WTF_MAKE_NONCOPYABLE(VisitedLinkProvider);
+public:
+ explicit VisitedLinkProvider(WebContext*);
+
+ void addVisitedLink(WebCore::LinkHash);
+
+ void processDidFinishLaunching();
+ void processDidClose();
+
+private:
+ void pendingVisitedLinksTimerFired();
+
+ WebContext* m_context;
+ bool m_visitedLinksPopulated;
+ bool m_webProcessHasVisitedLinkState;
+
+ unsigned m_keyCount;
+ unsigned m_tableSize;
+ VisitedLinkTable m_table;
+
+ HashSet<WebCore::LinkHash, WebCore::LinkHashHash> m_pendingVisitedLinks;
+ RunLoop::Timer<VisitedLinkProvider> m_pendingVisitedLinksTimer;
+};
+
+} // namespace WebKit
+
+#endif // VisitedLinkProvider_h
diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp
new file mode 100644
index 000000000..5ea62cdc3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.cpp
@@ -0,0 +1,99 @@
+/*
+ * 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 "WebApplicationCacheManagerProxy.h"
+
+#include "SecurityOriginData.h"
+#include "WebApplicationCacheManagerMessages.h"
+#include "WebContext.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+PassRefPtr<WebApplicationCacheManagerProxy> WebApplicationCacheManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebApplicationCacheManagerProxy(context));
+}
+
+WebApplicationCacheManagerProxy::WebApplicationCacheManagerProxy(WebContext* context)
+ : m_webContext(context)
+{
+}
+
+WebApplicationCacheManagerProxy::~WebApplicationCacheManagerProxy()
+{
+}
+
+void WebApplicationCacheManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+}
+
+bool WebApplicationCacheManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty();
+}
+
+void WebApplicationCacheManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebApplicationCacheManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebApplicationCacheManagerProxy::getApplicationCacheOrigins(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::GetApplicationCacheOrigins(callbackID));
+}
+
+void WebApplicationCacheManagerProxy::didGetApplicationCacheOrigins(const Vector<SecurityOriginData>& originDatas, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ performAPICallbackWithSecurityOriginDataVector(originDatas, callback.get());
+}
+
+void WebApplicationCacheManagerProxy::deleteEntriesForOrigin(WebSecurityOrigin* origin)
+{
+ SecurityOriginData securityOriginData;
+ securityOriginData.protocol = origin->protocol();
+ securityOriginData.host = origin->host();
+ securityOriginData.port = origin->port();
+
+ // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::DeleteEntriesForOrigin(securityOriginData));
+}
+
+void WebApplicationCacheManagerProxy::deleteAllEntries()
+{
+ // FIXME (Multi-WebProcess): The application cache shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebApplicationCacheManager::DeleteAllEntries());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h
new file mode 100644
index 000000000..b3dca15b6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.h
@@ -0,0 +1,85 @@
+/*
+ * 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 WebApplicationCacheManagerProxy_h
+#define WebApplicationCacheManagerProxy_h
+
+#include "APIObject.h"
+#include "GenericCallback.h"
+#include "ImmutableArray.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+struct SecurityOriginData;
+class WebContext;
+class WebProcessProxy;
+class WebSecurityOrigin;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebApplicationCacheManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeApplicationCacheManager;
+
+ static PassRefPtr<WebApplicationCacheManagerProxy> create(WebContext*);
+ virtual ~WebApplicationCacheManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void getApplicationCacheOrigins(PassRefPtr<ArrayCallback>);
+ void deleteEntriesForOrigin(WebSecurityOrigin*);
+ void deleteAllEntries();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ WebApplicationCacheManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didGetApplicationCacheOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID);
+
+ void didReceiveWebApplicationCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+};
+
+} // namespace WebKit
+
+#endif // WebApplicationCacheManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.messages.in
new file mode 100644
index 000000000..2aa0f670e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebApplicationCacheManagerProxy.messages.in
@@ -0,0 +1,25 @@
+# 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.
+
+messages -> WebApplicationCacheManagerProxy {
+ DidGetApplicationCacheOrigins(Vector<WebKit::SecurityOriginData> originIdentifiers, uint64_t callbackID);
+}
diff --git a/Source/WebKit2/UIProcess/WebBackForwardList.cpp b/Source/WebKit2/UIProcess/WebBackForwardList.cpp
new file mode 100644
index 000000000..5c567b550
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebBackForwardList.cpp
@@ -0,0 +1,245 @@
+/*
+ * 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 "WebBackForwardList.h"
+
+#include "WebPageProxy.h"
+
+namespace WebKit {
+
+static const unsigned DefaultCapacity = 100;
+
+WebBackForwardList::WebBackForwardList(WebPageProxy* page)
+ : m_page(page)
+ , m_current(NoCurrentItemIndex)
+ , m_capacity(DefaultCapacity)
+ , m_closed(true)
+ , m_enabled(true)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+}
+
+WebBackForwardList::~WebBackForwardList()
+{
+}
+
+void WebBackForwardList::pageClosed()
+{
+ if (m_page) {
+ size_t size = m_entries.size();
+ for (size_t i = 0; i < size; ++i)
+ m_page->backForwardRemovedItem(m_entries[i]->itemID());
+ }
+
+ m_page = 0;
+}
+
+void WebBackForwardList::addItem(WebBackForwardListItem* newItem)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ if (m_capacity == 0 || !m_enabled)
+ return;
+
+ Vector<RefPtr<APIObject> > removedItems;
+
+ // Toss anything in the forward list
+ if (m_current != NoCurrentItemIndex) {
+ unsigned targetSize = m_current + 1;
+ removedItems.reserveCapacity(m_entries.size() - targetSize);
+ while (m_entries.size() > targetSize) {
+ if (m_page)
+ m_page->backForwardRemovedItem(m_entries.last()->itemID());
+ removedItems.append(m_entries.last().release());
+ m_entries.removeLast();
+ }
+ }
+
+ // Toss the first item if the list is getting too big, as long as we're not using it
+ // (or even if we are, if we only want 1 entry).
+ if (m_entries.size() == m_capacity && (m_current != 0 || m_capacity == 1)) {
+ if (m_page)
+ m_page->backForwardRemovedItem(m_entries[0]->itemID());
+ removedItems.append(m_entries[0].release());
+ m_entries.remove(0);
+ m_current--;
+ }
+
+ m_entries.insert(m_current + 1, newItem);
+ m_current++;
+
+ if (m_page)
+ m_page->didChangeBackForwardList(newItem, &removedItems);
+
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+}
+
+void WebBackForwardList::goToItem(WebBackForwardListItem* item)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ if (!m_entries.size() || !item)
+ return;
+
+ unsigned index = 0;
+ for (; index < m_entries.size(); ++index) {
+ if (m_entries[index] == item)
+ break;
+ }
+ if (index < m_entries.size()) {
+ m_current = index;
+ if (m_page)
+ m_page->didChangeBackForwardList(0, 0);
+ }
+}
+
+WebBackForwardListItem* WebBackForwardList::currentItem()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ if (m_current != NoCurrentItemIndex)
+ return m_entries[m_current].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::backItem()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ if (m_current && m_current != NoCurrentItemIndex)
+ return m_entries[m_current - 1].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::forwardItem()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ if (m_entries.size() && m_current < m_entries.size() - 1)
+ return m_entries[m_current + 1].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ // Do range checks without doing math on index to avoid overflow.
+ if (index < -static_cast<int>(m_current))
+ return 0;
+
+ if (index > forwardListCount())
+ return 0;
+
+ return m_entries[index + m_current].get();
+}
+
+int WebBackForwardList::backListCount()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ return m_current == NoCurrentItemIndex ? 0 : m_current;
+}
+
+int WebBackForwardList::forwardListCount()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
+}
+
+PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ unsigned backListSize = static_cast<unsigned>(backListCount());
+ unsigned size = std::min(backListSize, limit);
+ if (!size)
+ return ImmutableArray::create();
+
+ Vector<RefPtr<APIObject> > vector;
+ vector.reserveInitialCapacity(size);
+
+ ASSERT(backListSize >= size);
+ for (unsigned i = backListSize - size; i < backListSize; ++i)
+ vector.uncheckedAppend(m_entries[i].get());
+
+ return ImmutableArray::adopt(vector);
+}
+
+PassRefPtr<ImmutableArray> WebBackForwardList::forwardListAsImmutableArrayWithLimit(unsigned limit)
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ unsigned size = std::min(static_cast<unsigned>(forwardListCount()), limit);
+ if (!size)
+ return ImmutableArray::create();
+
+ Vector<RefPtr<APIObject> > vector;
+ vector.reserveInitialCapacity(size);
+
+ unsigned last = m_current + size;
+ ASSERT(last < m_entries.size());
+ for (unsigned i = m_current + 1; i <= last; ++i)
+ vector.uncheckedAppend(m_entries[i].get());
+
+ return ImmutableArray::adopt(vector);
+}
+
+void WebBackForwardList::clear()
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ size_t size = m_entries.size();
+ if (size <= 1)
+ return;
+
+ RefPtr<WebBackForwardListItem> currentItem = this->currentItem();
+
+ if (m_page) {
+ for (size_t i = 0; i < size; ++i) {
+ if (m_entries[i] != currentItem)
+ m_page->backForwardRemovedItem(m_entries[i]->itemID());
+ }
+ }
+
+ Vector<RefPtr<APIObject> > removedItems;
+ removedItems.reserveCapacity(m_entries.size() - 1);
+ for (size_t i = 0; i < m_entries.size(); ++i) {
+ if (i != m_current)
+ removedItems.append(m_entries[i].release());
+ }
+
+ m_entries.shrink(1);
+ m_entries[0] = currentItem.release();
+
+ m_current = 0;
+
+ if (m_page)
+ m_page->didChangeBackForwardList(0, &removedItems);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebBackForwardList.h b/Source/WebKit2/UIProcess/WebBackForwardList.h
new file mode 100644
index 000000000..ead0fca06
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebBackForwardList.h
@@ -0,0 +1,102 @@
+/*
+ * 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 WebBackForwardList_h
+#define WebBackForwardList_h
+
+#include "APIObject.h"
+#include "ImmutableArray.h"
+#include "WebBackForwardListItem.h"
+#include "WebPageProxy.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#if USE(CF)
+#include <CoreFoundation/CFDictionary.h>
+#endif
+
+namespace WebKit {
+
+typedef Vector<RefPtr<WebBackForwardListItem> > BackForwardListItemVector;
+
+/*
+ * Current
+ * |---------*--------------| Entries
+ * Back Forward
+ */
+
+class WebBackForwardList : public APIObject {
+public:
+ static const Type APIType = TypeBackForwardList;
+
+ static PassRefPtr<WebBackForwardList> create(WebPageProxy* page)
+ {
+ return adoptRef(new WebBackForwardList(page));
+ }
+ void pageClosed();
+
+ virtual ~WebBackForwardList();
+
+ void addItem(WebBackForwardListItem*);
+ void goToItem(WebBackForwardListItem*);
+ void clear();
+
+ WebBackForwardListItem* currentItem();
+ WebBackForwardListItem* backItem();
+ WebBackForwardListItem* forwardItem();
+ WebBackForwardListItem* itemAtIndex(int);
+
+ const BackForwardListItemVector& entries() const { return m_entries; }
+
+ uint32_t currentIndex() { return m_current; }
+ int backListCount();
+ int forwardListCount();
+
+ PassRefPtr<ImmutableArray> backListAsImmutableArrayWithLimit(unsigned limit);
+ PassRefPtr<ImmutableArray> forwardListAsImmutableArrayWithLimit(unsigned limit);
+
+#if USE(CF)
+ CFDictionaryRef createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback, void* context) const;
+ bool restoreFromCFDictionaryRepresentation(CFDictionaryRef);
+#endif
+
+private:
+ static const unsigned NoCurrentItemIndex = UINT_MAX;
+
+ WebBackForwardList(WebPageProxy*);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageProxy* m_page;
+ BackForwardListItemVector m_entries;
+ uint32_t m_current;
+ uint32_t m_capacity;
+ bool m_closed;
+ bool m_enabled;
+};
+
+} // namespace WebKit
+
+#endif // WebBackForwardList_h
diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp
new file mode 100644
index 000000000..18f74a99f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp
@@ -0,0 +1,138 @@
+/*
+ * 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 "WebConnectionToWebProcess.h"
+
+#include "WebConnectionMessageKinds.h"
+#include "WebContextUserMessageCoders.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+PassRefPtr<WebConnectionToWebProcess> WebConnectionToWebProcess::create(WebProcessProxy* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop)
+{
+ return adoptRef(new WebConnectionToWebProcess(process, connectionIdentifier, runLoop));
+}
+
+WebConnectionToWebProcess::WebConnectionToWebProcess(WebProcessProxy* process, CoreIPC::Connection::Identifier connectionIdentifier, RunLoop* runLoop)
+ : m_process(process)
+ , m_connection(CoreIPC::Connection::createServerConnection(connectionIdentifier, this, runLoop))
+{
+#if OS(DARWIN)
+ m_connection->setShouldCloseConnectionOnMachExceptions();
+#elif PLATFORM(QT)
+ m_connection->setShouldCloseConnectionOnProcessTermination(process->processIdentifier());
+#endif
+
+ m_connection->open();
+}
+
+void WebConnectionToWebProcess::invalidate()
+{
+ m_connection->invalidate();
+ m_connection = nullptr;
+ m_process = 0;
+}
+
+// WebConnection
+
+void WebConnectionToWebProcess::postMessage(const String& messageName, APIObject* messageBody)
+{
+ // We need to check if we have an underlying process here since a user of the API can hold
+ // onto us and call postMessage even after the process has been invalidated.
+ if (!m_process)
+ return;
+
+ m_process->deprecatedSend(WebConnectionLegacyMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody)));
+}
+
+// CoreIPC::Connection::Client
+
+void WebConnectionToWebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ if (messageID.is<CoreIPC::MessageClassWebConnectionLegacy>()) {
+ switch (messageID.get<WebConnectionLegacyMessage::Kind>()) {
+ case WebConnectionLegacyMessage::PostMessage: {
+ String messageName;
+ RefPtr<APIObject> messageBody;
+ WebContextUserMessageDecoder messageDecoder(messageBody, m_process->context());
+ if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder)))
+ return;
+
+ forwardDidReceiveMessageToClient(messageName, messageBody.get());
+ return;
+ }
+ }
+ return;
+ }
+
+ m_process->didReceiveMessage(connection, messageID, arguments);
+}
+
+void WebConnectionToWebProcess::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ m_process->didReceiveSyncMessage(connection, messageID, arguments, reply);
+}
+
+void WebConnectionToWebProcess::didClose(CoreIPC::Connection* connection)
+{
+ RefPtr<WebConnectionToWebProcess> protector(this);
+
+ m_process->didClose(connection);
+
+ // Tell the API client that the connection closed.
+ m_client.didClose(this);
+}
+
+void WebConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID)
+{
+ RefPtr<WebProcessProxy> process = m_process;
+
+ // This will invalidate the CoreIPC::Connection and the WebProcessProxy member
+ // variables, so we should be careful not to use them after this call.
+ process->didReceiveInvalidMessage(connection, messageID);
+
+ // Since we've invalidated the connection we'll never get a CoreIPC::Connection::Client::didClose
+ // callback so we'll explicitly call it here instead.
+ process->didClose(connection);
+
+ // Tell the API client that the connection closed.
+ m_client.didClose(this);
+}
+
+void WebConnectionToWebProcess::syncMessageSendTimedOut(CoreIPC::Connection* connection)
+{
+ m_process->syncMessageSendTimedOut(connection);
+}
+
+#if PLATFORM(WIN)
+Vector<HWND> WebConnectionToWebProcess::windowsToReceiveSentMessagesWhileWaitingForSyncReply()
+{
+ return m_process->windowsToReceiveSentMessagesWhileWaitingForSyncReply();
+}
+#endif
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.h
new file mode 100644
index 000000000..b9d58f2c7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.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 WebConnectionToWebProcess_h
+#define WebConnectionToWebProcess_h
+
+#include "Connection.h"
+#include "WebConnection.h"
+
+namespace WebKit {
+
+class WebProcessProxy;
+
+class WebConnectionToWebProcess : public WebConnection, CoreIPC::Connection::Client {
+public:
+ static PassRefPtr<WebConnectionToWebProcess> create(WebProcessProxy*, CoreIPC::Connection::Identifier, RunLoop*);
+
+ CoreIPC::Connection* connection() { return m_connection.get(); }
+
+ void invalidate();
+
+private:
+ WebConnectionToWebProcess(WebProcessProxy*, CoreIPC::Connection::Identifier, RunLoop*);
+
+ // WebConnection
+ virtual void postMessage(const String&, APIObject*);
+
+ // CoreIPC::Connection::Client
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+ virtual void didClose(CoreIPC::Connection*);
+ virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
+ virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
+#if PLATFORM(WIN)
+ virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
+#endif
+
+ WebProcessProxy* m_process;
+ RefPtr<CoreIPC::Connection> m_connection;
+};
+
+} // namespace WebKit
+
+#endif // WebConnectionToWebProcess_h
diff --git a/Source/WebKit2/UIProcess/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp
new file mode 100644
index 000000000..18bca116a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.cpp
@@ -0,0 +1,902 @@
+/*
+ * 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 "WebContext.h"
+
+#include "DownloadProxy.h"
+#include "ImmutableArray.h"
+#include "InjectedBundleMessageKinds.h"
+#include "Logging.h"
+#include "MutableDictionary.h"
+#include "RunLoop.h"
+#include "SandboxExtension.h"
+#include "StatisticsData.h"
+#include "TextChecker.h"
+#include "WKContextPrivate.h"
+#include "WebApplicationCacheManagerProxy.h"
+#include "WebContextMessageKinds.h"
+#include "WebContextUserMessageCoders.h"
+#include "WebCookieManagerProxy.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebDatabaseManagerProxy.h"
+#include "WebGeolocationManagerProxy.h"
+#include "WebIconDatabase.h"
+#include "WebKeyValueStorageManagerProxy.h"
+#include "WebMediaCacheManagerProxy.h"
+#include "WebNotificationManagerProxy.h"
+#include "WebPluginSiteDataManager.h"
+#include "WebPageGroup.h"
+#include "WebMemorySampler.h"
+#include "WebProcessCreationParameters.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include "WebResourceCacheManagerProxy.h"
+#include <WebCore/Language.h>
+#include <WebCore/LinkHash.h>
+#include <WebCore/Logging.h>
+#include <WebCore/ResourceRequest.h>
+#include <runtime/InitializeThreading.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/MainThread.h>
+
+#if PLATFORM(MAC)
+#include "BuiltInPDFView.h"
+#endif
+
+#ifndef NDEBUG
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
+#define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webContextCounter, ("WebContext"));
+
+WebContext* WebContext::sharedProcessContext()
+{
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+ RunLoop::initializeMainRunLoop();
+ static WebContext* context = adoptRef(new WebContext(ProcessModelSharedSecondaryProcess, String())).leakRef();
+ return context;
+}
+
+WebContext* WebContext::sharedThreadContext()
+{
+ RunLoop::initializeMainRunLoop();
+ static WebContext* context = adoptRef(new WebContext(ProcessModelSharedSecondaryThread, String())).leakRef();
+ return context;
+}
+
+PassRefPtr<WebContext> WebContext::create(const String& injectedBundlePath)
+{
+ JSC::initializeThreading();
+ WTF::initializeMainThread();
+ RunLoop::initializeMainRunLoop();
+ return adoptRef(new WebContext(ProcessModelSecondaryProcess, injectedBundlePath));
+}
+
+static Vector<WebContext*>& contexts()
+{
+ DEFINE_STATIC_LOCAL(Vector<WebContext*>, contexts, ());
+
+ return contexts;
+}
+
+const Vector<WebContext*>& WebContext::allContexts()
+{
+ return contexts();
+}
+
+WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePath)
+ : m_processModel(processModel)
+ , m_defaultPageGroup(WebPageGroup::create())
+ , m_injectedBundlePath(injectedBundlePath)
+ , m_visitedLinkProvider(this)
+ , m_alwaysUsesComplexTextCodePath(false)
+ , m_shouldUseFontSmoothing(true)
+ , m_cacheModel(CacheModelDocumentViewer)
+ , m_memorySamplerEnabled(false)
+ , m_memorySamplerInterval(1400.0)
+ , m_applicationCacheManagerProxy(WebApplicationCacheManagerProxy::create(this))
+ , m_cookieManagerProxy(WebCookieManagerProxy::create(this))
+ , m_databaseManagerProxy(WebDatabaseManagerProxy::create(this))
+ , m_geolocationManagerProxy(WebGeolocationManagerProxy::create(this))
+ , m_iconDatabase(WebIconDatabase::create(this))
+ , m_keyValueStorageManagerProxy(WebKeyValueStorageManagerProxy::create(this))
+ , m_mediaCacheManagerProxy(WebMediaCacheManagerProxy::create(this))
+ , m_notificationManagerProxy(WebNotificationManagerProxy::create(this))
+ , m_pluginSiteDataManager(WebPluginSiteDataManager::create(this))
+ , m_resourceCacheManagerProxy(WebResourceCacheManagerProxy::create(this))
+#if PLATFORM(WIN)
+ , m_shouldPaintNativeControls(true)
+ , m_initialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicyAlways)
+#endif
+ , m_processTerminationEnabled(true)
+{
+#if !LOG_DISABLED
+ WebKit::initializeLogChannelsIfNecessary();
+#endif
+
+ contexts().append(this);
+
+ addLanguageChangeObserver(this, languageChanged);
+
+ WebCore::initializeLoggingChannelsIfNecessary();
+
+#ifndef NDEBUG
+ webContextCounter.increment();
+#endif
+}
+
+WebContext::~WebContext()
+{
+ ASSERT(contexts().find(this) != notFound);
+ contexts().remove(contexts().find(this));
+
+ removeLanguageChangeObserver(this);
+
+ m_applicationCacheManagerProxy->invalidate();
+ m_applicationCacheManagerProxy->clearContext();
+
+ m_cookieManagerProxy->invalidate();
+ m_cookieManagerProxy->clearContext();
+
+ m_databaseManagerProxy->invalidate();
+ m_databaseManagerProxy->clearContext();
+
+ m_geolocationManagerProxy->invalidate();
+ m_geolocationManagerProxy->clearContext();
+
+ m_iconDatabase->invalidate();
+ m_iconDatabase->clearContext();
+
+ m_keyValueStorageManagerProxy->invalidate();
+ m_keyValueStorageManagerProxy->clearContext();
+
+ m_mediaCacheManagerProxy->invalidate();
+ m_mediaCacheManagerProxy->clearContext();
+
+ m_notificationManagerProxy->invalidate();
+ m_notificationManagerProxy->clearContext();
+
+ m_pluginSiteDataManager->invalidate();
+ m_pluginSiteDataManager->clearContext();
+
+ m_resourceCacheManagerProxy->invalidate();
+ m_resourceCacheManagerProxy->clearContext();
+
+ invalidateCallbackMap(m_dictionaryCallbacks);
+
+ platformInvalidateContext();
+
+#ifndef NDEBUG
+ webContextCounter.decrement();
+#endif
+}
+
+void WebContext::initializeInjectedBundleClient(const WKContextInjectedBundleClient* client)
+{
+ m_injectedBundleClient.initialize(client);
+}
+
+void WebContext::initializeConnectionClient(const WKContextConnectionClient* client)
+{
+ m_connectionClient.initialize(client);
+}
+
+void WebContext::initializeHistoryClient(const WKContextHistoryClient* client)
+{
+ m_historyClient.initialize(client);
+
+ sendToAllProcesses(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()));
+}
+
+void WebContext::initializeDownloadClient(const WKContextDownloadClient* client)
+{
+ m_downloadClient.initialize(client);
+}
+
+void WebContext::languageChanged(void* context)
+{
+ static_cast<WebContext*>(context)->languageChanged();
+}
+
+void WebContext::languageChanged()
+{
+ sendToAllProcesses(Messages::WebProcess::LanguageChanged(defaultLanguage()));
+}
+
+void WebContext::fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled)
+{
+ sendToAllProcesses(Messages::WebProcess::FullKeyboardAccessModeChanged(fullKeyboardAccessEnabled));
+}
+
+void WebContext::ensureWebProcess()
+{
+ if (m_process)
+ return;
+
+ m_process = WebProcessProxy::create(this);
+
+ WebProcessCreationParameters parameters;
+
+ if (!injectedBundlePath().isEmpty()) {
+ parameters.injectedBundlePath = injectedBundlePath();
+ SandboxExtension::createHandle(parameters.injectedBundlePath, SandboxExtension::ReadOnly, parameters.injectedBundlePathExtensionHandle);
+ }
+
+ parameters.shouldTrackVisitedLinks = m_historyClient.shouldTrackVisitedLinks();
+ parameters.cacheModel = m_cacheModel;
+ parameters.languageCode = defaultLanguage();
+ parameters.applicationCacheDirectory = applicationCacheDirectory();
+ parameters.databaseDirectory = databaseDirectory();
+ parameters.localStorageDirectory = localStorageDirectory();
+ parameters.webInspectorLocalizedStringsPath = m_overrideWebInspectorLocalizedStringsPath;
+
+#if PLATFORM(MAC)
+ parameters.webInspectorBaseDirectory = m_overrideWebInspectorBaseDirectory;
+ parameters.presenterApplicationPid = getpid();
+#endif
+
+ copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument);
+ copyToVector(m_schemesToRegisterAsSecure, parameters.urlSchemesRegisteredAsSecure);
+ copyToVector(m_schemesToSetDomainRelaxationForbiddenFor, parameters.urlSchemesForWhichDomainRelaxationIsForbidden);
+
+ parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
+ parameters.shouldUseFontSmoothing = m_shouldUseFontSmoothing;
+
+ parameters.iconDatabaseEnabled = !iconDatabasePath().isEmpty();
+
+ parameters.textCheckerState = TextChecker::state();
+
+ parameters.fullKeyboardAccessEnabled = WebProcessProxy::fullKeyboardAccessEnabled();
+
+ parameters.defaultRequestTimeoutInterval = WebURLRequest::defaultTimeoutInterval();
+
+ // Add any platform specific parameters
+ platformInitializeWebProcess(parameters);
+
+ m_process->send(Messages::WebProcess::InitializeWebProcess(parameters, WebContextUserMessageEncoder(m_injectedBundleInitializationUserData.get())), 0);
+
+ for (size_t i = 0; i != m_pendingMessagesToPostToInjectedBundle.size(); ++i) {
+ pair<String, RefPtr<APIObject> >& message = m_pendingMessagesToPostToInjectedBundle[i];
+ m_process->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message.first, WebContextUserMessageEncoder(message.second.get())));
+ }
+ m_pendingMessagesToPostToInjectedBundle.clear();
+}
+
+void WebContext::warmInitialProcess()
+{
+ ensureWebProcess();
+}
+
+void WebContext::enableProcessTermination()
+{
+ m_processTerminationEnabled = true;
+ if (shouldTerminate(m_process.get()))
+ m_process->terminate();
+}
+
+bool WebContext::shouldTerminate(WebProcessProxy* process)
+{
+ // FIXME: Once we support multiple processes per context, this assertion won't hold.
+ ASSERT(process == m_process);
+
+ if (!m_processTerminationEnabled)
+ return false;
+
+ if (!m_downloads.isEmpty())
+ return false;
+
+ if (!m_applicationCacheManagerProxy->shouldTerminate(process))
+ return false;
+ if (!m_cookieManagerProxy->shouldTerminate(process))
+ return false;
+ if (!m_databaseManagerProxy->shouldTerminate(process))
+ return false;
+ if (!m_keyValueStorageManagerProxy->shouldTerminate(process))
+ return false;
+ if (!m_mediaCacheManagerProxy->shouldTerminate(process))
+ return false;
+ if (!m_pluginSiteDataManager->shouldTerminate(process))
+ return false;
+ if (!m_resourceCacheManagerProxy->shouldTerminate(process))
+ return false;
+
+ return true;
+}
+
+void WebContext::processDidFinishLaunching(WebProcessProxy* process)
+{
+ // FIXME: Once we support multiple processes per context, this assertion won't hold.
+ ASSERT_UNUSED(process, process == m_process);
+
+ m_visitedLinkProvider.processDidFinishLaunching();
+
+ // Sometimes the memorySampler gets initialized after process initialization has happened but before the process has finished launching
+ // so check if it needs to be started here
+ if (m_memorySamplerEnabled) {
+ SandboxExtension::Handle sampleLogSandboxHandle;
+ double now = WTF::currentTime();
+ String sampleLogFilePath = String::format("WebProcess%llu", static_cast<unsigned long long>(now));
+ sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
+
+ m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, m_memorySamplerInterval), 0);
+ }
+
+ m_connectionClient.didCreateConnection(this, process->webConnection());
+}
+
+void WebContext::disconnectProcess(WebProcessProxy* process)
+{
+ // FIXME: Once we support multiple processes per context, this assertion won't hold.
+ ASSERT_UNUSED(process, process == m_process);
+
+ m_visitedLinkProvider.processDidClose();
+
+ // Invalidate all outstanding downloads.
+ for (HashMap<uint64_t, RefPtr<DownloadProxy> >::iterator::Values it = m_downloads.begin().values(), end = m_downloads.end().values(); it != end; ++it) {
+ (*it)->processDidClose();
+ (*it)->invalidate();
+ }
+
+ m_downloads.clear();
+
+ m_applicationCacheManagerProxy->invalidate();
+ m_cookieManagerProxy->invalidate();
+ m_databaseManagerProxy->invalidate();
+ m_geolocationManagerProxy->invalidate();
+ m_keyValueStorageManagerProxy->invalidate();
+ m_mediaCacheManagerProxy->invalidate();
+ m_notificationManagerProxy->invalidate();
+ m_resourceCacheManagerProxy->invalidate();
+
+ // When out of process plug-ins are enabled, we don't want to invalidate the plug-in site data
+ // manager just because the web process crashes since it's not involved.
+#if !ENABLE(PLUGIN_PROCESS)
+ m_pluginSiteDataManager->invalidate();
+#endif
+
+ // This can cause the web context to be destroyed.
+ m_process = 0;
+}
+
+PassRefPtr<WebPageProxy> WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pageGroup)
+{
+ ensureWebProcess();
+
+ if (!pageGroup)
+ pageGroup = m_defaultPageGroup.get();
+
+ return m_process->createWebPage(pageClient, this, pageGroup);
+}
+
+WebProcessProxy* WebContext::relaunchProcessIfNecessary()
+{
+ ensureWebProcess();
+
+ ASSERT(m_process);
+ return m_process.get();
+}
+
+DownloadProxy* WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
+{
+ ensureWebProcess();
+
+ DownloadProxy* download = createDownloadProxy();
+ uint64_t initiatingPageID = initiatingPage ? initiatingPage->pageID() : 0;
+
+#if PLATFORM(QT)
+ ASSERT(initiatingPage); // Our design does not suppport downloads without a WebPage.
+ initiatingPage->handleDownloadRequest(download);
+#endif
+
+ process()->send(Messages::WebProcess::DownloadRequest(download->downloadID(), initiatingPageID, request), 0);
+ return download;
+}
+
+void WebContext::postMessageToInjectedBundle(const String& messageName, APIObject* messageBody)
+{
+ if (!m_process || !m_process->canSendMessage()) {
+ m_pendingMessagesToPostToInjectedBundle.append(make_pair(messageName, messageBody));
+ return;
+ }
+
+ // FIXME: We should consider returning false from this function if the messageBody cannot
+ // be encoded.
+ m_process->deprecatedSend(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(messageName, WebContextUserMessageEncoder(messageBody)));
+}
+
+// InjectedBundle client
+
+void WebContext::didReceiveMessageFromInjectedBundle(const String& messageName, APIObject* messageBody)
+{
+ m_injectedBundleClient.didReceiveMessageFromInjectedBundle(this, messageName, messageBody);
+}
+
+void WebContext::didReceiveSynchronousMessageFromInjectedBundle(const String& messageName, APIObject* messageBody, RefPtr<APIObject>& returnData)
+{
+ m_injectedBundleClient.didReceiveSynchronousMessageFromInjectedBundle(this, messageName, messageBody, returnData);
+}
+
+// HistoryClient
+
+void WebContext::didNavigateWithNavigationData(uint64_t pageID, const WebNavigationDataStore& store, uint64_t frameID)
+{
+ WebPageProxy* page = m_process->webPage(pageID);
+ if (!page)
+ return;
+
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK(frame->page() == page);
+
+ m_historyClient.didNavigateWithNavigationData(this, page, store, frame);
+}
+
+void WebContext::didPerformClientRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+ WebPageProxy* page = m_process->webPage(pageID);
+ if (!page)
+ return;
+
+ if (sourceURLString.isEmpty() || destinationURLString.isEmpty())
+ return;
+
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK(frame->page() == page);
+ MESSAGE_CHECK_URL(sourceURLString);
+ MESSAGE_CHECK_URL(destinationURLString);
+
+ m_historyClient.didPerformClientRedirect(this, page, sourceURLString, destinationURLString, frame);
+}
+
+void WebContext::didPerformServerRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+ WebPageProxy* page = m_process->webPage(pageID);
+ if (!page)
+ return;
+
+ if (sourceURLString.isEmpty() || destinationURLString.isEmpty())
+ return;
+
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK(frame->page() == page);
+ MESSAGE_CHECK_URL(sourceURLString);
+ MESSAGE_CHECK_URL(destinationURLString);
+
+ m_historyClient.didPerformServerRedirect(this, page, sourceURLString, destinationURLString, frame);
+}
+
+void WebContext::didUpdateHistoryTitle(uint64_t pageID, const String& title, const String& url, uint64_t frameID)
+{
+ WebPageProxy* page = m_process->webPage(pageID);
+ if (!page)
+ return;
+
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK(frame->page() == page);
+ MESSAGE_CHECK_URL(url);
+
+ m_historyClient.didUpdateHistoryTitle(this, page, title, url, frame);
+}
+
+void WebContext::populateVisitedLinks()
+{
+ m_historyClient.populateVisitedLinks(this);
+}
+
+WebContext::Statistics& WebContext::statistics()
+{
+ static Statistics statistics = Statistics();
+
+ return statistics;
+}
+
+void WebContext::setAdditionalPluginsDirectory(const String& directory)
+{
+ Vector<String> directories;
+ directories.append(directory);
+
+ m_pluginInfoStore.setAdditionalPluginsDirectories(directories);
+}
+
+void WebContext::setAlwaysUsesComplexTextCodePath(bool alwaysUseComplexText)
+{
+ m_alwaysUsesComplexTextCodePath = alwaysUseComplexText;
+ sendToAllProcesses(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText));
+}
+
+void WebContext::setShouldUseFontSmoothing(bool useFontSmoothing)
+{
+ m_shouldUseFontSmoothing = useFontSmoothing;
+ sendToAllProcesses(Messages::WebProcess::SetShouldUseFontSmoothing(useFontSmoothing));
+}
+
+void WebContext::registerURLSchemeAsEmptyDocument(const String& urlScheme)
+{
+ m_schemesToRegisterAsEmptyDocument.add(urlScheme);
+ sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme));
+}
+
+void WebContext::registerURLSchemeAsSecure(const String& urlScheme)
+{
+ m_schemesToRegisterAsSecure.add(urlScheme);
+ sendToAllProcesses(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme));
+}
+
+void WebContext::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme)
+{
+ m_schemesToSetDomainRelaxationForbiddenFor.add(urlScheme);
+ sendToAllProcesses(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme));
+}
+
+void WebContext::setCacheModel(CacheModel cacheModel)
+{
+ m_cacheModel = cacheModel;
+ sendToAllProcesses(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)));
+}
+
+void WebContext::setDefaultRequestTimeoutInterval(double timeoutInterval)
+{
+ sendToAllProcesses(Messages::WebProcess::SetDefaultRequestTimeoutInterval(timeoutInterval));
+}
+
+void WebContext::addVisitedLink(const String& visitedURL)
+{
+ if (visitedURL.isEmpty())
+ return;
+
+ LinkHash linkHash = visitedLinkHash(visitedURL.characters(), visitedURL.length());
+ addVisitedLinkHash(linkHash);
+}
+
+void WebContext::addVisitedLinkHash(LinkHash linkHash)
+{
+ m_visitedLinkProvider.addVisitedLink(linkHash);
+}
+
+void WebContext::getPlugins(bool refresh, Vector<PluginInfo>& pluginInfos)
+{
+ if (refresh)
+ m_pluginInfoStore.refresh();
+
+ Vector<PluginModuleInfo> plugins = m_pluginInfoStore.plugins();
+ for (size_t i = 0; i < plugins.size(); ++i)
+ pluginInfos.append(plugins[i].info);
+
+#if PLATFORM(MAC)
+ // Add built-in PDF last, so that it's not used when a real plug-in is installed.
+ if (!omitPDFSupport())
+ pluginInfos.append(BuiltInPDFView::pluginInfo());
+#endif
+}
+
+void WebContext::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath)
+{
+ MESSAGE_CHECK_URL(urlString);
+
+ String newMimeType = mimeType.lower();
+
+ PluginModuleInfo plugin = pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString));
+ if (!plugin.path)
+ return;
+
+ pluginPath = plugin.path;
+}
+
+#if !ENABLE(PLUGIN_PROCESS)
+void WebContext::didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID)
+{
+ m_pluginSiteDataManager->didGetSitesWithData(sites, callbackID);
+}
+
+void WebContext::didClearPluginSiteData(uint64_t callbackID)
+{
+ m_pluginSiteDataManager->didClearSiteData(callbackID);
+}
+#endif
+
+DownloadProxy* WebContext::createDownloadProxy()
+{
+ RefPtr<DownloadProxy> downloadProxy = DownloadProxy::create(this);
+ m_downloads.set(downloadProxy->downloadID(), downloadProxy);
+ return downloadProxy.get();
+}
+
+void WebContext::downloadFinished(DownloadProxy* downloadProxy)
+{
+ ASSERT(m_downloads.contains(downloadProxy->downloadID()));
+
+ downloadProxy->invalidate();
+ m_downloads.remove(downloadProxy->downloadID());
+}
+
+// FIXME: This is not the ideal place for this function.
+HashSet<String, CaseFoldingHash> WebContext::pdfAndPostScriptMIMETypes()
+{
+ HashSet<String, CaseFoldingHash> mimeTypes;
+
+ mimeTypes.add("application/pdf");
+ mimeTypes.add("application/postscript");
+ mimeTypes.add("text/pdf");
+
+ return mimeTypes;
+}
+
+void WebContext::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ if (messageID.is<CoreIPC::MessageClassWebContext>()) {
+ didReceiveWebContextMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
+ if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get())
+ downloadProxy->didReceiveDownloadProxyMessage(connection, messageID, arguments);
+
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebApplicationCacheManagerProxy>()) {
+ m_applicationCacheManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>()) {
+ m_cookieManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>()) {
+ m_databaseManagerProxy->didReceiveWebDatabaseManagerProxyMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()) {
+ m_geolocationManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebIconDatabase>()) {
+ m_iconDatabase->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebKeyValueStorageManagerProxy>()) {
+ m_keyValueStorageManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebMediaCacheManagerProxy>()) {
+ m_mediaCacheManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebNotificationManagerProxy>()) {
+ m_notificationManagerProxy->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebResourceCacheManagerProxy>()) {
+ m_resourceCacheManagerProxy->didReceiveWebResourceCacheManagerProxyMessage(connection, messageID, arguments);
+ return;
+ }
+
+ switch (messageID.get<WebContextLegacyMessage::Kind>()) {
+ case WebContextLegacyMessage::PostMessage: {
+ String messageName;
+ RefPtr<APIObject> messageBody;
+ WebContextUserMessageDecoder messageDecoder(messageBody, this);
+ if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder)))
+ return;
+
+ didReceiveMessageFromInjectedBundle(messageName, messageBody.get());
+ return;
+ }
+ case WebContextLegacyMessage::PostSynchronousMessage:
+ ASSERT_NOT_REACHED();
+ }
+
+ ASSERT_NOT_REACHED();
+}
+
+void WebContext::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ if (messageID.is<CoreIPC::MessageClassWebContext>()) {
+ didReceiveSyncWebContextMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
+ if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get())
+ downloadProxy->didReceiveSyncDownloadProxyMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebIconDatabase>()) {
+ m_iconDatabase->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ switch (messageID.get<WebContextLegacyMessage::Kind>()) {
+ case WebContextLegacyMessage::PostSynchronousMessage: {
+ // FIXME: We should probably encode something in the case that the arguments do not decode correctly.
+
+ String messageName;
+ RefPtr<APIObject> messageBody;
+ WebContextUserMessageDecoder messageDecoder(messageBody, this);
+ if (!arguments->decode(CoreIPC::Out(messageName, messageDecoder)))
+ return;
+
+ RefPtr<APIObject> returnData;
+ didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody.get(), returnData);
+ reply->encode(CoreIPC::In(WebContextUserMessageEncoder(returnData.get())));
+ return;
+ }
+ case WebContextLegacyMessage::PostMessage:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void WebContext::setEnhancedAccessibility(bool flag)
+{
+ sendToAllProcesses(Messages::WebProcess::SetEnhancedAccessibility(flag));
+}
+
+void WebContext::startMemorySampler(const double interval)
+{
+ // For new WebProcesses we will also want to start the Memory Sampler
+ m_memorySamplerEnabled = true;
+ m_memorySamplerInterval = interval;
+
+ // For UIProcess
+#if ENABLE(MEMORY_SAMPLER)
+ WebMemorySampler::shared()->start(interval);
+#endif
+
+ // For WebProcess
+ SandboxExtension::Handle sampleLogSandboxHandle;
+ double now = WTF::currentTime();
+ String sampleLogFilePath = String::format("WebProcess%llu", static_cast<unsigned long long>(now));
+ sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
+
+ sendToAllProcesses(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval));
+}
+
+void WebContext::stopMemorySampler()
+{
+ // For WebProcess
+ m_memorySamplerEnabled = false;
+
+ // For UIProcess
+#if ENABLE(MEMORY_SAMPLER)
+ WebMemorySampler::shared()->stop();
+#endif
+
+ sendToAllProcesses(Messages::WebProcess::StopMemorySampler());
+}
+
+String WebContext::databaseDirectory() const
+{
+ if (!m_overrideDatabaseDirectory.isEmpty())
+ return m_overrideDatabaseDirectory;
+
+ return platformDefaultDatabaseDirectory();
+}
+
+void WebContext::setIconDatabasePath(const String& path)
+{
+ m_overrideIconDatabasePath = path;
+ m_iconDatabase->setDatabasePath(path);
+}
+
+String WebContext::iconDatabasePath() const
+{
+ if (!m_overrideIconDatabasePath.isEmpty())
+ return m_overrideIconDatabasePath;
+
+ return platformDefaultIconDatabasePath();
+}
+
+String WebContext::localStorageDirectory() const
+{
+ if (!m_overrideLocalStorageDirectory.isEmpty())
+ return m_overrideLocalStorageDirectory;
+
+ return platformDefaultLocalStorageDirectory();
+}
+
+void WebContext::setHTTPPipeliningEnabled(bool enabled)
+{
+#if PLATFORM(MAC)
+ ResourceRequest::setHTTPPipeliningEnabled(enabled);
+#endif
+}
+
+bool WebContext::httpPipeliningEnabled() const
+{
+#if PLATFORM(MAC)
+ return ResourceRequest::httpPipeliningEnabled();
+#else
+ return false;
+#endif
+}
+
+void WebContext::getWebCoreStatistics(PassRefPtr<DictionaryCallback> prpCallback)
+{
+ RefPtr<DictionaryCallback> callback = prpCallback;
+
+ uint64_t callbackID = callback->callbackID();
+ m_dictionaryCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebProcess::GetWebCoreStatistics(callbackID), 0);
+}
+
+static PassRefPtr<MutableDictionary> createDictionaryFromHashMap(const HashMap<String, uint64_t>& map)
+{
+ RefPtr<MutableDictionary> result = MutableDictionary::create();
+ HashMap<String, uint64_t>::const_iterator end = map.end();
+ for (HashMap<String, uint64_t>::const_iterator it = map.begin(); it != end; ++it)
+ result->set(it->first, RefPtr<WebUInt64>(WebUInt64::create(it->second)).get());
+
+ return result;
+}
+
+void WebContext::didGetWebCoreStatistics(const StatisticsData& statisticsData, uint64_t callbackID)
+{
+ RefPtr<DictionaryCallback> callback = m_dictionaryCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ RefPtr<MutableDictionary> statistics = createDictionaryFromHashMap(statisticsData.statisticsNumbers);
+ statistics->set("JavaScriptProtectedObjectTypeCounts", createDictionaryFromHashMap(statisticsData.javaScriptProtectedObjectTypeCounts).get());
+ statistics->set("JavaScriptObjectTypeCounts", createDictionaryFromHashMap(statisticsData.javaScriptObjectTypeCounts).get());
+
+ size_t cacheStatisticsCount = statisticsData.webCoreCacheStatistics.size();
+ Vector<RefPtr<APIObject> > cacheStatisticsVector(cacheStatisticsCount);
+ for (size_t i = 0; i < cacheStatisticsCount; ++i)
+ cacheStatisticsVector[i] = createDictionaryFromHashMap(statisticsData.webCoreCacheStatistics[i]);
+ statistics->set("WebCoreCacheStatistics", ImmutableArray::adopt(cacheStatisticsVector).get());
+
+ callback->performCallbackWithReturnValue(statistics.get());
+}
+
+void WebContext::garbageCollectJavaScriptObjects()
+{
+ sendToAllProcesses(Messages::WebProcess::GarbageCollectJavaScriptObjects());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h
new file mode 100644
index 000000000..21f219149
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.h
@@ -0,0 +1,329 @@
+/*
+ * 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 WebContext_h
+#define WebContext_h
+
+#include "APIObject.h"
+#include "GenericCallback.h"
+#include "PluginInfoStore.h"
+#include "ProcessModel.h"
+#include "VisitedLinkProvider.h"
+#include "WebContextInjectedBundleClient.h"
+#include "WebContextConnectionClient.h"
+#include "WebDownloadClient.h"
+#include "WebHistoryClient.h"
+#include "WebProcessProxy.h"
+#include <WebCore/LinkHash.h>
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class DownloadProxy;
+class WebApplicationCacheManagerProxy;
+class WebCookieManagerProxy;
+class WebDatabaseManagerProxy;
+class WebGeolocationManagerProxy;
+class WebIconDatabase;
+class WebKeyValueStorageManagerProxy;
+class WebMediaCacheManagerProxy;
+class WebNotificationManagerProxy;
+class WebPageGroup;
+class WebPageProxy;
+class WebResourceCacheManagerProxy;
+struct StatisticsData;
+struct WebProcessCreationParameters;
+
+typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
+
+class WebContext : public APIObject {
+public:
+ static const Type APIType = TypeContext;
+
+ static WebContext* sharedProcessContext();
+ static WebContext* sharedThreadContext();
+
+ static PassRefPtr<WebContext> create(const String& injectedBundlePath);
+ virtual ~WebContext();
+
+ static const Vector<WebContext*>& allContexts();
+
+ void initializeInjectedBundleClient(const WKContextInjectedBundleClient*);
+ void initializeConnectionClient(const WKContextConnectionClient*);
+ void initializeHistoryClient(const WKContextHistoryClient*);
+ void initializeDownloadClient(const WKContextDownloadClient*);
+
+ ProcessModel processModel() const { return m_processModel; }
+ WebProcessProxy* process() const { return m_process.get(); }
+
+ template<typename U> bool sendToAllProcesses(const U& message);
+ template<typename U> bool sendToAllProcessesRelaunchingThemIfNecessary(const U& message);
+
+ void processDidFinishLaunching(WebProcessProxy*);
+
+ // Disconnect the process from the context.
+ void disconnectProcess(WebProcessProxy*);
+
+ PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebPageGroup*);
+
+ WebProcessProxy* relaunchProcessIfNecessary();
+
+ const String& injectedBundlePath() const { return m_injectedBundlePath; }
+
+ DownloadProxy* download(WebPageProxy* initiatingPage, const WebCore::ResourceRequest&);
+
+ void setInjectedBundleInitializationUserData(PassRefPtr<APIObject> userData) { m_injectedBundleInitializationUserData = userData; }
+ APIObject* injectedBundleInitializationUserData() const { return m_injectedBundleInitializationUserData.get(); }
+
+ void postMessageToInjectedBundle(const String&, APIObject*);
+
+ // InjectedBundle client
+ void didReceiveMessageFromInjectedBundle(const String&, APIObject*);
+ void didReceiveSynchronousMessageFromInjectedBundle(const String&, APIObject*, RefPtr<APIObject>& returnData);
+
+ void populateVisitedLinks();
+
+ void setAdditionalPluginsDirectory(const String&);
+
+ PluginInfoStore& pluginInfoStore() { return m_pluginInfoStore; }
+ String applicationCacheDirectory();
+
+ void setAlwaysUsesComplexTextCodePath(bool);
+ void setShouldUseFontSmoothing(bool);
+
+ void registerURLSchemeAsEmptyDocument(const String&);
+ void registerURLSchemeAsSecure(const String&);
+ void setDomainRelaxationForbiddenForURLScheme(const String&);
+
+ void addVisitedLink(const String&);
+ void addVisitedLinkHash(WebCore::LinkHash);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ void setCacheModel(CacheModel);
+ CacheModel cacheModel() const { return m_cacheModel; }
+
+ void setDefaultRequestTimeoutInterval(double);
+
+ void startMemorySampler(const double interval);
+ void stopMemorySampler();
+
+#if PLATFORM(WIN)
+ void setShouldPaintNativeControls(bool);
+
+ void setInitialHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy) { m_initialHTTPCookieAcceptPolicy = policy; }
+#endif
+
+ void setEnhancedAccessibility(bool);
+
+ // Downloads.
+ DownloadProxy* createDownloadProxy();
+ WebDownloadClient& downloadClient() { return m_downloadClient; }
+ void downloadFinished(DownloadProxy*);
+
+ static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
+
+ WebApplicationCacheManagerProxy* applicationCacheManagerProxy() const { return m_applicationCacheManagerProxy.get(); }
+ WebCookieManagerProxy* cookieManagerProxy() const { return m_cookieManagerProxy.get(); }
+ WebDatabaseManagerProxy* databaseManagerProxy() const { return m_databaseManagerProxy.get(); }
+ WebGeolocationManagerProxy* geolocationManagerProxy() const { return m_geolocationManagerProxy.get(); }
+ WebIconDatabase* iconDatabase() const { return m_iconDatabase.get(); }
+ WebKeyValueStorageManagerProxy* keyValueStorageManagerProxy() const { return m_keyValueStorageManagerProxy.get(); }
+ WebMediaCacheManagerProxy* mediaCacheManagerProxy() const { return m_mediaCacheManagerProxy.get(); }
+ WebNotificationManagerProxy* notificationManagerProxy() const { return m_notificationManagerProxy.get(); }
+ WebPluginSiteDataManager* pluginSiteDataManager() const { return m_pluginSiteDataManager.get(); }
+ WebResourceCacheManagerProxy* resourceCacheManagerProxy() const { return m_resourceCacheManagerProxy.get(); }
+
+ struct Statistics {
+ unsigned wkViewCount;
+ unsigned wkPageCount;
+ unsigned wkFrameCount;
+ };
+ static Statistics& statistics();
+
+ void setDatabaseDirectory(const String& dir) { m_overrideDatabaseDirectory = dir; }
+ void setIconDatabasePath(const String&);
+ String iconDatabasePath() const;
+ void setLocalStorageDirectory(const String& dir) { m_overrideLocalStorageDirectory = dir; }
+
+ String overrideWebInspectorBaseDirectory() const { return m_overrideWebInspectorBaseDirectory; }
+ void setOverrideWebInspectorBaseDirectory(const String& path) { m_overrideWebInspectorBaseDirectory = path; }
+
+ String overrideWebInspectorPagePath() const { return m_overrideWebInspectorPagePath; }
+ void setOverrideWebInspectorPagePath(const String& path) { m_overrideWebInspectorPagePath = path; }
+
+ void setOverrideWebInspectorLocalizedStringsPath(const String& path) { m_overrideWebInspectorLocalizedStringsPath = path; }
+
+ void ensureWebProcess();
+ void warmInitialProcess();
+
+ bool shouldTerminate(WebProcessProxy*);
+
+ void disableProcessTermination() { m_processTerminationEnabled = false; }
+ void enableProcessTermination();
+
+ // Defaults to false.
+ void setHTTPPipeliningEnabled(bool);
+ bool httpPipeliningEnabled() const;
+
+ void getWebCoreStatistics(PassRefPtr<DictionaryCallback>);
+ void garbageCollectJavaScriptObjects();
+
+#if PLATFORM(MAC)
+ static bool omitPDFSupport();
+#endif
+
+ void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled);
+
+private:
+ WebContext(ProcessModel, const String& injectedBundlePath);
+
+ virtual Type type() const { return APIType; }
+
+ void platformInitializeWebProcess(WebProcessCreationParameters&);
+ void platformInvalidateContext();
+
+ // History client
+ void didNavigateWithNavigationData(uint64_t pageID, const WebNavigationDataStore& store, uint64_t frameID);
+ void didPerformClientRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
+ void didPerformServerRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID);
+ void didUpdateHistoryTitle(uint64_t pageID, const String& title, const String& url, uint64_t frameID);
+
+ // Plugins
+ void getPlugins(bool refresh, Vector<WebCore::PluginInfo>&);
+ void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath);
+#if !ENABLE(PLUGIN_PROCESS)
+ void didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID);
+ void didClearPluginSiteData(uint64_t callbackID);
+#endif
+
+ void didGetWebCoreStatistics(const StatisticsData&, uint64_t callbackID);
+
+ // Implemented in generated WebContextMessageReceiver.cpp
+ void didReceiveWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ static void languageChanged(void* context);
+ void languageChanged();
+
+ String databaseDirectory() const;
+ String platformDefaultDatabaseDirectory() const;
+
+ String platformDefaultIconDatabasePath() const;
+
+ String localStorageDirectory() const;
+ String platformDefaultLocalStorageDirectory() const;
+
+ ProcessModel m_processModel;
+
+ // FIXME: In the future, this should be one or more WebProcessProxies.
+ RefPtr<WebProcessProxy> m_process;
+
+ RefPtr<WebPageGroup> m_defaultPageGroup;
+
+ RefPtr<APIObject> m_injectedBundleInitializationUserData;
+ String m_injectedBundlePath;
+ WebContextInjectedBundleClient m_injectedBundleClient;
+
+ WebContextConnectionClient m_connectionClient;
+
+ WebHistoryClient m_historyClient;
+
+ PluginInfoStore m_pluginInfoStore;
+ VisitedLinkProvider m_visitedLinkProvider;
+
+ HashSet<String> m_schemesToRegisterAsEmptyDocument;
+ HashSet<String> m_schemesToRegisterAsSecure;
+ HashSet<String> m_schemesToSetDomainRelaxationForbiddenFor;
+
+ bool m_alwaysUsesComplexTextCodePath;
+ bool m_shouldUseFontSmoothing;
+
+ Vector<pair<String, RefPtr<APIObject> > > m_pendingMessagesToPostToInjectedBundle;
+
+ CacheModel m_cacheModel;
+
+ WebDownloadClient m_downloadClient;
+ HashMap<uint64_t, RefPtr<DownloadProxy> > m_downloads;
+
+ bool m_memorySamplerEnabled;
+ double m_memorySamplerInterval;
+
+ RefPtr<WebApplicationCacheManagerProxy> m_applicationCacheManagerProxy;
+ RefPtr<WebCookieManagerProxy> m_cookieManagerProxy;
+ RefPtr<WebDatabaseManagerProxy> m_databaseManagerProxy;
+ RefPtr<WebGeolocationManagerProxy> m_geolocationManagerProxy;
+ RefPtr<WebIconDatabase> m_iconDatabase;
+ RefPtr<WebKeyValueStorageManagerProxy> m_keyValueStorageManagerProxy;
+ RefPtr<WebMediaCacheManagerProxy> m_mediaCacheManagerProxy;
+ RefPtr<WebNotificationManagerProxy> m_notificationManagerProxy;
+ RefPtr<WebPluginSiteDataManager> m_pluginSiteDataManager;
+ RefPtr<WebResourceCacheManagerProxy> m_resourceCacheManagerProxy;
+
+#if PLATFORM(WIN)
+ bool m_shouldPaintNativeControls;
+ HTTPCookieAcceptPolicy m_initialHTTPCookieAcceptPolicy;
+#endif
+
+#if PLATFORM(MAC)
+ RetainPtr<CFTypeRef> m_enhancedAccessibilityObserver;
+#endif
+
+ String m_overrideDatabaseDirectory;
+ String m_overrideIconDatabasePath;
+ String m_overrideLocalStorageDirectory;
+ String m_overrideWebInspectorBaseDirectory;
+ String m_overrideWebInspectorPagePath;
+ String m_overrideWebInspectorLocalizedStringsPath;
+
+ bool m_processTerminationEnabled;
+
+ HashMap<uint64_t, RefPtr<DictionaryCallback> > m_dictionaryCallbacks;
+};
+
+template<typename U> inline bool WebContext::sendToAllProcesses(const U& message)
+{
+ if (!m_process || !m_process->canSendMessage())
+ return false;
+
+ return m_process->send(message, 0);
+}
+
+template<typename U> bool WebContext::sendToAllProcessesRelaunchingThemIfNecessary(const U& message)
+{
+ relaunchProcessIfNecessary();
+
+ return m_process->send(message, 0);
+}
+
+} // namespace WebKit
+
+#endif // WebContext_h
diff --git a/Source/WebKit2/UIProcess/WebContext.messages.in b/Source/WebKit2/UIProcess/WebContext.messages.in
new file mode 100644
index 000000000..954894f1e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.messages.in
@@ -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.
+
+messages -> WebContext {
+
+ # History client messages.
+ DidNavigateWithNavigationData(uint64_t pageID, WebKit::WebNavigationDataStore store, uint64_t frameID)
+ DidPerformClientRedirect(uint64_t pageID, WTF::String sourceURLString, WTF::String destinationURLString, uint64_t frameID)
+ DidPerformServerRedirect(uint64_t pageID, WTF::String sourceURLString, WTF::String destinationURLString, uint64_t frameID)
+ DidUpdateHistoryTitle(uint64_t pageID, WTF::String title, WTF::String url, uint64_t frameID)
+
+ # Visited link provider messages.
+ AddVisitedLinkHash(uint64_t linkHash)
+
+ # Plugin messages.
+ GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins)
+ GetPluginPath(WTF::String mimeType, WTF::String urlString) -> (WTF::String pluginPath)
+
+#if !ENABLE(PLUGIN_PROCESS)
+ void DidGetSitesWithPluginData(Vector<WTF::String> sites, uint64_t callbackID)
+ void DidClearPluginSiteData(uint64_t callbackID)
+#endif
+
+ DidGetWebCoreStatistics(WebKit::StatisticsData statisticsData, uint64_t callbackID)
+
+}
diff --git a/Source/WebKit2/UIProcess/WebContextConnectionClient.cpp b/Source/WebKit2/UIProcess/WebContextConnectionClient.cpp
new file mode 100644
index 000000000..c5873ab52
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextConnectionClient.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebContextConnectionClient.h"
+
+#include "WKAPICast.h"
+
+namespace WebKit {
+
+void WebContextConnectionClient::didCreateConnection(WebContext* context, WebConnection* connection)
+{
+ if (!m_client.didCreateConnection)
+ return;
+
+ m_client.didCreateConnection(toAPI(context), toAPI(connection), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContextConnectionClient.h b/Source/WebKit2/UIProcess/WebContextConnectionClient.h
new file mode 100644
index 000000000..148bd1bdb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextConnectionClient.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 WebContextConnectionClient_h
+#define WebContextConnectionClient_h
+
+#include "APIClient.h"
+#include "WKContext.h"
+
+namespace WebKit {
+
+class WebConnection;
+class WebContext;
+
+class WebContextConnectionClient : public APIClient<WKContextConnectionClient, kWKContextConnectionClientCurrentVersion> {
+public:
+ void didCreateConnection(WebContext*, WebConnection*);
+};
+
+} // namespace WebKit
+
+#endif // WebContextConnectionClient_h
diff --git a/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
new file mode 100644
index 000000000..24e62714f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
@@ -0,0 +1,54 @@
+/*
+ * 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 "WebContextInjectedBundleClient.h"
+
+#include "WKAPICast.h"
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebContextInjectedBundleClient::didReceiveMessageFromInjectedBundle(WebContext* context, const String& messageName, APIObject* messageBody)
+{
+ if (!m_client.didReceiveMessageFromInjectedBundle)
+ return;
+
+ m_client.didReceiveMessageFromInjectedBundle(toAPI(context), toAPI(messageName.impl()), toAPI(messageBody), m_client.clientInfo);
+}
+
+void WebContextInjectedBundleClient::didReceiveSynchronousMessageFromInjectedBundle(WebContext* context, const String& messageName, APIObject* messageBody, RefPtr<APIObject>& returnData)
+{
+ if (!m_client.didReceiveSynchronousMessageFromInjectedBundle)
+ return;
+
+ WKTypeRef returnDataRef = 0;
+ m_client.didReceiveSynchronousMessageFromInjectedBundle(toAPI(context), toAPI(messageName.impl()), toAPI(messageBody), &returnDataRef, m_client.clientInfo);
+ returnData = adoptRef(toImpl(returnDataRef));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.h b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.h
new file mode 100644
index 000000000..2b6ce8d86
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.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 WebContextInjectedBundleClient_h
+#define WebContextInjectedBundleClient_h
+
+#include "APIClient.h"
+#include "WKContext.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class APIObject;
+class WebContext;
+
+class WebContextInjectedBundleClient : public APIClient<WKContextInjectedBundleClient, kWKContextInjectedBundleClientCurrentVersion> {
+public:
+ void didReceiveMessageFromInjectedBundle(WebContext*, const String&, APIObject*);
+ void didReceiveSynchronousMessageFromInjectedBundle(WebContext*, const String&, APIObject*, RefPtr<APIObject>& returnData);
+};
+
+} // namespace WebKit
+
+#endif // WebContextInjectedBundleClient_h
diff --git a/Source/WebKit2/UIProcess/WebContextMenuProxy.cpp b/Source/WebKit2/UIProcess/WebContextMenuProxy.cpp
new file mode 100644
index 000000000..4c4cb26c0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextMenuProxy.cpp
@@ -0,0 +1,39 @@
+/*
+ * 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 "WebContextMenuProxy.h"
+
+namespace WebKit {
+
+WebContextMenuProxy::WebContextMenuProxy()
+{
+}
+
+WebContextMenuProxy::~WebContextMenuProxy()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContextMenuProxy.h b/Source/WebKit2/UIProcess/WebContextMenuProxy.h
new file mode 100644
index 000000000..098552d3a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextMenuProxy.h
@@ -0,0 +1,54 @@
+/*
+ * 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 WebContextMenuProxy_h
+#define WebContextMenuProxy_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+ class IntPoint;
+}
+
+namespace WebKit {
+
+class WebContextMenuItemData;
+
+class WebContextMenuProxy : public RefCounted<WebContextMenuProxy> {
+public:
+ virtual ~WebContextMenuProxy();
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>& items) = 0;
+ virtual void hideContextMenu() = 0;
+
+protected:
+ WebContextMenuProxy();
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxy_h
diff --git a/Source/WebKit2/UIProcess/WebContextUserMessageCoders.h b/Source/WebKit2/UIProcess/WebContextUserMessageCoders.h
new file mode 100644
index 000000000..bb2ba39a1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextUserMessageCoders.h
@@ -0,0 +1,141 @@
+/*
+ * 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 "UserMessageCoders.h"
+#include "WebContext.h"
+#include "WebFrameProxy.h"
+#include "WebPageGroup.h"
+#include "WebPageGroupData.h"
+#include "WebPageProxy.h"
+
+namespace WebKit {
+
+// Adds
+// - Page -> BundlePage
+// - Frame -> BundleFrame
+// - PageGroup -> BundlePageGroup
+
+class WebContextUserMessageEncoder : public UserMessageEncoder<WebContextUserMessageEncoder> {
+public:
+ typedef UserMessageEncoder<WebContextUserMessageEncoder> Base;
+
+ WebContextUserMessageEncoder(APIObject* root)
+ : Base(root)
+ {
+ }
+
+ void encode(CoreIPC::ArgumentEncoder* encoder) const
+ {
+ APIObject::Type type = APIObject::TypeNull;
+ if (baseEncode(encoder, type))
+ return;
+
+ switch (type) {
+ case APIObject::TypePage: {
+ WebPageProxy* page = static_cast<WebPageProxy*>(m_root);
+ encoder->encode(page->pageID());
+ break;
+ }
+ case APIObject::TypeFrame: {
+ WebFrameProxy* frame = static_cast<WebFrameProxy*>(m_root);
+ encoder->encode(frame->frameID());
+ break;
+ }
+ case APIObject::TypePageGroup: {
+ WebPageGroup* pageGroup = static_cast<WebPageGroup*>(m_root);
+ encoder->encode(pageGroup->data());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+};
+
+// Adds
+// - Page -> BundlePage
+// - Frame -> BundleFrame
+// - PageGroup -> BundlePageGroup
+
+class WebContextUserMessageDecoder : public UserMessageDecoder<WebContextUserMessageDecoder> {
+public:
+ typedef UserMessageDecoder<WebContextUserMessageDecoder> Base;
+
+ WebContextUserMessageDecoder(RefPtr<APIObject>& root, WebContext* context)
+ : Base(root)
+ , m_context(context)
+ {
+ }
+
+ WebContextUserMessageDecoder(WebContextUserMessageDecoder& userMessageDecoder, RefPtr<APIObject>& root)
+ : Base(root)
+ , m_context(userMessageDecoder.m_context)
+ {
+ }
+
+ static bool decode(CoreIPC::ArgumentDecoder* decoder, WebContextUserMessageDecoder& coder)
+ {
+ APIObject::Type type = APIObject::TypeNull;
+ if (!Base::baseDecode(decoder, coder, type))
+ return false;
+
+ if (coder.m_root || type == APIObject::TypeNull)
+ return true;
+
+ switch (type) {
+ case APIObject::TypeBundlePage: {
+ uint64_t pageID;
+ if (!decoder->decode(pageID))
+ return false;
+ coder.m_root = coder.m_context->process()->webPage(pageID);
+ break;
+ }
+ case APIObject::TypeBundleFrame: {
+ uint64_t frameID;
+ if (!decoder->decode(frameID))
+ return false;
+ coder.m_root = coder.m_context->process()->webFrame(frameID);
+ break;
+ }
+ case APIObject::TypeBundlePageGroup: {
+ uint64_t pageGroupID;
+ if (!decoder->decode(pageGroupID))
+ return false;
+ coder.m_root = WebPageGroup::get(pageGroupID);
+ break;
+ }
+ default:
+ return false;
+ }
+
+ return true;
+ }
+
+private:
+ WebContext* m_context;
+};
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
new file mode 100644
index 000000000..e7b4a6a8e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.cpp
@@ -0,0 +1,163 @@
+/*
+ * 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 "WebCookieManagerProxy.h"
+
+#include "SecurityOriginData.h"
+#include "WebCookieManagerMessages.h"
+#include "WebContext.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+PassRefPtr<WebCookieManagerProxy> WebCookieManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebCookieManagerProxy(context));
+}
+
+WebCookieManagerProxy::WebCookieManagerProxy(WebContext* context)
+ : m_webContext(context)
+{
+}
+
+WebCookieManagerProxy::~WebCookieManagerProxy()
+{
+}
+
+void WebCookieManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+ invalidateCallbackMap(m_httpCookieAcceptPolicyCallbacks);
+}
+
+bool WebCookieManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty() && m_httpCookieAcceptPolicyCallbacks.isEmpty();
+}
+
+void WebCookieManagerProxy::initializeClient(const WKCookieManagerClient* client)
+{
+ m_client.initialize(client);
+}
+
+void WebCookieManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebCookieManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebCookieManagerProxy::getHostnamesWithCookies(PassRefPtr<ArrayCallback> prpCallback)
+{
+ ASSERT(m_webContext);
+
+ RefPtr<ArrayCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): Cookies shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::GetHostnamesWithCookies(callbackID));
+}
+
+void WebCookieManagerProxy::didGetHostnamesWithCookies(const Vector<String>& hostnameList, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ size_t hostnameCount = hostnameList.size();
+ Vector<RefPtr<APIObject> > hostnames(hostnameCount);
+
+ for (size_t i = 0; i < hostnameCount; ++i)
+ hostnames[i] = WebString::create(hostnameList[i]);
+
+ callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
+}
+
+void WebCookieManagerProxy::deleteCookiesForHostname(const String& hostname)
+{
+ ASSERT(m_webContext);
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteCookiesForHostname(hostname));
+}
+
+void WebCookieManagerProxy::deleteAllCookies()
+{
+ ASSERT(m_webContext);
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::DeleteAllCookies());
+}
+
+void WebCookieManagerProxy::startObservingCookieChanges()
+{
+ ASSERT(m_webContext);
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::StartObservingCookieChanges());
+}
+
+void WebCookieManagerProxy::stopObservingCookieChanges()
+{
+ ASSERT(m_webContext);
+ m_webContext->sendToAllProcesses(Messages::WebCookieManager::StopObservingCookieChanges());
+}
+
+void WebCookieManagerProxy::cookiesDidChange()
+{
+ m_client.cookiesDidChange(this);
+}
+
+void WebCookieManagerProxy::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+{
+ ASSERT(m_webContext);
+#if PLATFORM(MAC)
+ persistHTTPCookieAcceptPolicy(policy);
+#endif
+
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::SetHTTPCookieAcceptPolicy(policy));
+}
+
+void WebCookieManagerProxy::getHTTPCookieAcceptPolicy(PassRefPtr<HTTPCookieAcceptPolicyCallback> prpCallback)
+{
+ ASSERT(m_webContext);
+
+ RefPtr<HTTPCookieAcceptPolicyCallback> callback = prpCallback;
+
+ uint64_t callbackID = callback->callbackID();
+ m_httpCookieAcceptPolicyCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): Cookies shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebCookieManager::GetHTTPCookieAcceptPolicy(callbackID));
+}
+
+void WebCookieManagerProxy::didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID)
+{
+ RefPtr<HTTPCookieAcceptPolicyCallback> callback = m_httpCookieAcceptPolicyCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(policy);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.h b/Source/WebKit2/UIProcess/WebCookieManagerProxy.h
new file mode 100644
index 000000000..7dc20d52e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.h
@@ -0,0 +1,102 @@
+/*
+ * 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 WebCookieManagerProxy_h
+#define WebCookieManagerProxy_h
+
+#include "APIObject.h"
+#include "GenericCallback.h"
+#include "ImmutableArray.h"
+#include "WebCookieManagerProxyClient.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebProcessProxy;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+typedef GenericCallback<WKHTTPCookieAcceptPolicy, HTTPCookieAcceptPolicy> HTTPCookieAcceptPolicyCallback;
+
+class WebCookieManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeCookieManager;
+
+ static PassRefPtr<WebCookieManagerProxy> create(WebContext*);
+ virtual ~WebCookieManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void initializeClient(const WKCookieManagerClient*);
+
+ void getHostnamesWithCookies(PassRefPtr<ArrayCallback>);
+ void deleteCookiesForHostname(const String& hostname);
+ void deleteAllCookies();
+
+ void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
+ void getHTTPCookieAcceptPolicy(PassRefPtr<HTTPCookieAcceptPolicyCallback>);
+
+ void startObservingCookieChanges();
+ void stopObservingCookieChanges();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ WebCookieManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didGetHostnamesWithCookies(const Vector<String>&, uint64_t callbackID);
+ void didGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
+
+ void cookiesDidChange();
+
+ void didReceiveWebCookieManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+#if PLATFORM(MAC)
+ void persistHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
+#endif
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+ HashMap<uint64_t, RefPtr<HTTPCookieAcceptPolicyCallback> > m_httpCookieAcceptPolicyCallbacks;
+
+ WebCookieManagerProxyClient m_client;
+};
+
+} // namespace WebKit
+
+#endif // WebCookieManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in
new file mode 100644
index 000000000..2ae0545c3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebCookieManagerProxy.messages.in
@@ -0,0 +1,28 @@
+# 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.
+
+messages -> WebCookieManagerProxy {
+ DidGetHostnamesWithCookies(Vector<WTF::String> hostnames, uint64_t callbackID);
+ DidGetHTTPCookieAcceptPolicy(uint32_t policy, uint64_t callbackID);
+
+ CookiesDidChange()
+}
diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.cpp b/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.cpp
new file mode 100644
index 000000000..da5512df7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebCookieManagerProxyClient.h"
+
+#include "WKAPICast.h"
+
+namespace WebKit {
+
+void WebCookieManagerProxyClient::cookiesDidChange(WebCookieManagerProxy* cookieManager)
+{
+ if (!m_client.cookiesDidChange)
+ return;
+
+ m_client.cookiesDidChange(toAPI(cookieManager), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.h b/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.h
new file mode 100644
index 000000000..2faa167c0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebCookieManagerProxyClient.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 WebCookieManagerProxyClient_h
+#define WebCookieManagerProxyClient_h
+
+#include "APIClient.h"
+#include "WKCookieManager.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebCookieManagerProxy;
+
+class WebCookieManagerProxyClient : public APIClient<WKCookieManagerClient, kWKCookieManagerClientCurrentVersion> {
+public:
+ void cookiesDidChange(WebCookieManagerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebCookieManagerProxyClient_h
diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp
new file mode 100644
index 000000000..26c518fd8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp
@@ -0,0 +1,233 @@
+/*
+ * 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 "WebDatabaseManagerProxy.h"
+
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "WebDatabaseManagerMessages.h"
+#include "WebContext.h"
+#include "WebSecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+String WebDatabaseManagerProxy::originKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerOriginKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::originQuotaKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerOriginQuotaKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::originUsageKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerOriginUsageKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::databaseDetailsKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerDatabaseDetailsKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::databaseDetailsNameKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerDatabaseDetailsNameKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerDatabaseDetailsDisplayNameKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerDatabaseDetailsExpectedUsageKey"));
+ return key;
+}
+
+String WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()
+{
+ DEFINE_STATIC_LOCAL(String, key, ("WebDatabaseManagerDatabaseDetailsCurrentUsageKey"));
+ return key;
+}
+
+PassRefPtr<WebDatabaseManagerProxy> WebDatabaseManagerProxy::create(WebContext* webContext)
+{
+ return adoptRef(new WebDatabaseManagerProxy(webContext));
+}
+
+WebDatabaseManagerProxy::WebDatabaseManagerProxy(WebContext* webContext)
+ : m_webContext(webContext)
+{
+}
+
+WebDatabaseManagerProxy::~WebDatabaseManagerProxy()
+{
+}
+
+void WebDatabaseManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+}
+
+bool WebDatabaseManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty();
+}
+
+void WebDatabaseManagerProxy::initializeClient(const WKDatabaseManagerClient* client)
+{
+ m_client.initialize(client);
+}
+
+void WebDatabaseManagerProxy::getDatabasesByOrigin(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID));
+}
+
+void WebDatabaseManagerProxy::didGetDatabasesByOrigin(const Vector<OriginAndDatabases>& originAndDatabasesVector, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ size_t originAndDatabasesCount = originAndDatabasesVector.size();
+ Vector<RefPtr<APIObject> > result(originAndDatabasesCount);
+
+ for (size_t i = 0; i < originAndDatabasesCount; ++i) {
+ const OriginAndDatabases& originAndDatabases = originAndDatabasesVector[i];
+
+ RefPtr<APIObject> origin = WebSecurityOrigin::create(originAndDatabases.originIdentifier);
+
+ size_t databasesCount = originAndDatabases.databases.size();
+ Vector<RefPtr<APIObject> > databases(databasesCount);
+
+ for (size_t j = 0; j < databasesCount; ++j) {
+ const DatabaseDetails& details = originAndDatabases.databases[i];
+ HashMap<String, RefPtr<APIObject> > detailsMap;
+
+ detailsMap.set(databaseDetailsNameKey(), WebString::create(details.name()));
+ detailsMap.set(databaseDetailsDisplayNameKey(), WebString::create(details.displayName()));
+ detailsMap.set(databaseDetailsExpectedUsageKey(), WebUInt64::create(details.expectedUsage()));
+ detailsMap.set(databaseDetailsCurrentUsageKey(), WebUInt64::create(details.currentUsage()));
+ databases.append(ImmutableDictionary::adopt(detailsMap));
+ }
+
+ HashMap<String, RefPtr<APIObject> > originAndDatabasesMap;
+ originAndDatabasesMap.set(originKey(), origin);
+ originAndDatabasesMap.set(originQuotaKey(), WebUInt64::create(originAndDatabases.originQuota));
+ originAndDatabasesMap.set(originUsageKey(), WebUInt64::create(originAndDatabases.originUsage));
+ originAndDatabasesMap.set(databaseDetailsKey(), ImmutableArray::adopt(databases));
+
+ result.append(ImmutableDictionary::adopt(originAndDatabasesMap));
+ }
+
+ RefPtr<ImmutableArray> resultArray = ImmutableArray::adopt(result);
+ callback->performCallbackWithReturnValue(resultArray.get());
+}
+
+void WebDatabaseManagerProxy::getDatabaseOrigins(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID));
+}
+
+void WebDatabaseManagerProxy::didGetDatabaseOrigins(const Vector<String>& originIdentifiers, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ size_t originIdentifiersCount = originIdentifiers.size();
+ Vector<RefPtr<APIObject> > securityOrigins(originIdentifiersCount);
+
+ for (size_t i = 0; i < originIdentifiersCount; ++i)
+ securityOrigins[i] = WebSecurityOrigin::create(originIdentifiers[i]);
+
+ callback->performCallbackWithReturnValue(ImmutableArray::adopt(securityOrigins).get());
+}
+
+void WebDatabaseManagerProxy::deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin* origin)
+{
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier()));
+}
+
+void WebDatabaseManagerProxy::deleteDatabasesForOrigin(WebSecurityOrigin* origin)
+{
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier()));
+}
+
+void WebDatabaseManagerProxy::deleteAllDatabases()
+{
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::DeleteAllDatabases());
+}
+
+void WebDatabaseManagerProxy::setQuotaForOrigin(WebSecurityOrigin* origin, uint64_t quota)
+{
+ // FIXME (Multi-WebProcess): Databases shouldn't be stored in the web process.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota));
+}
+
+void WebDatabaseManagerProxy::didModifyOrigin(const String& originIdentifier)
+{
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+ m_client.didModifyOrigin(this, origin.get());
+}
+
+void WebDatabaseManagerProxy::didModifyDatabase(const String& originIdentifier, const String& databaseIdentifier)
+{
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+ m_client.didModifyDatabase(this, origin.get(), databaseIdentifier);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h
new file mode 100644
index 000000000..d70011c38
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h
@@ -0,0 +1,102 @@
+/*
+ * 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 WebDatabaseManagerProxy_h
+#define WebDatabaseManagerProxy_h
+
+#include "APIObject.h"
+#include "Arguments.h"
+#include "GenericCallback.h"
+#include "OriginAndDatabases.h"
+#include "WebDatabaseManagerProxyClient.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+class MessageID;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebProcessProxy;
+class WebSecurityOrigin;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebDatabaseManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeDatabaseManager;
+
+ static PassRefPtr<WebDatabaseManagerProxy> create(WebContext*);
+ virtual ~WebDatabaseManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void initializeClient(const WKDatabaseManagerClient*);
+
+ void getDatabasesByOrigin(PassRefPtr<ArrayCallback>);
+ void getDatabaseOrigins(PassRefPtr<ArrayCallback>);
+ void deleteDatabaseWithNameForOrigin(const String& databaseIdentifier, WebSecurityOrigin*);
+ void deleteDatabasesForOrigin(WebSecurityOrigin*);
+ void deleteAllDatabases();
+ void setQuotaForOrigin(WebSecurityOrigin*, uint64_t quota);
+
+ static String originKey();
+ static String originQuotaKey();
+ static String originUsageKey();
+ static String databaseDetailsKey();
+ static String databaseDetailsNameKey();
+ static String databaseDetailsDisplayNameKey();
+ static String databaseDetailsExpectedUsageKey();
+ static String databaseDetailsCurrentUsageKey();
+
+ void didReceiveWebDatabaseManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ explicit WebDatabaseManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ // Message handlers.
+ void didGetDatabasesByOrigin(const Vector<OriginAndDatabases>& originAndDatabases, uint64_t callbackID);
+ void didGetDatabaseOrigins(const Vector<String>& originIdentifiers, uint64_t callbackID);
+ void didModifyOrigin(const String& originIdentifier);
+ void didModifyDatabase(const String& originIdentifier, const String& databaseIdentifier);
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+
+ WebDatabaseManagerProxyClient m_client;
+};
+
+} // namespace WebKit
+
+#endif // DatabaseManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in
new file mode 100644
index 000000000..37a9b89ec
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in
@@ -0,0 +1,28 @@
+# 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.
+
+messages -> WebDatabaseManagerProxy {
+ DidGetDatabasesByOrigin(Vector<WebKit::OriginAndDatabases> originAndDatabases, uint64_t callbackID);
+ DidGetDatabaseOrigins(Vector<WTF::String> originIdentifiers, uint64_t callbackID)
+ DidModifyOrigin(WTF::String originIdentifier)
+ DidModifyDatabase(WTF::String originIdentifier, WTF::String databaseIdentifier)
+}
diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.cpp
new file mode 100644
index 000000000..2f3c767e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebDatabaseManagerProxyClient.h"
+
+#include "WKAPICast.h"
+
+namespace WebKit {
+
+void WebDatabaseManagerProxyClient::didModifyOrigin(WebDatabaseManagerProxy* databaseManager, WebSecurityOrigin* origin)
+{
+ if (!m_client.didModifyOrigin)
+ return;
+
+ m_client.didModifyOrigin(toAPI(databaseManager), toAPI(origin), m_client.clientInfo);
+}
+
+void WebDatabaseManagerProxyClient::didModifyDatabase(WebDatabaseManagerProxy* databaseManager, WebSecurityOrigin* origin, const String& databaseIdentifier)
+{
+ if (!m_client.didModifyDatabase)
+ return;
+
+ m_client.didModifyDatabase(toAPI(databaseManager), toAPI(origin), toAPI(databaseIdentifier.impl()), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.h b/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.h
new file mode 100644
index 000000000..31646d2c8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.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 WebDatabaseManagerProxyClient_h
+#define WebDatabaseManagerProxyClient_h
+
+#include "APIClient.h"
+#include "WKDatabaseManager.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebDatabaseManagerProxy;
+class WebSecurityOrigin;
+
+class WebDatabaseManagerProxyClient : public APIClient<WKDatabaseManagerClient, kWKDatabaseManagerClientCurrentVersion> {
+public:
+ void didModifyOrigin(WebDatabaseManagerProxy*, WebSecurityOrigin*);
+ void didModifyDatabase(WebDatabaseManagerProxy*, WebSecurityOrigin*, const String& databaseIdentifier);
+};
+
+} // namespace WebKit
+
+#endif // WebDatabaseManagerProxyClient_h
diff --git a/Source/WebKit2/UIProcess/WebDownloadClient.cpp b/Source/WebKit2/UIProcess/WebDownloadClient.cpp
new file mode 100644
index 000000000..612a056c2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDownloadClient.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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 "WebDownloadClient.h"
+
+#include "WKAPICast.h"
+#include "WebURLResponse.h"
+#include "WKRetainPtr.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebDownloadClient::didStart(WebContext* webContext, DownloadProxy* downloadProxy)
+{
+ if (!m_client.didStart)
+ return;
+
+ m_client.didStart(toAPI(webContext), toAPI(downloadProxy), m_client.clientInfo);
+}
+
+void WebDownloadClient::didReceiveAuthenticationChallenge(WebContext* webContext, DownloadProxy* downloadProxy, AuthenticationChallengeProxy* authenticationChallengeProxy)
+{
+ if (!m_client.didReceiveAuthenticationChallenge)
+ return;
+
+ m_client.didReceiveAuthenticationChallenge(toAPI(webContext), toAPI(downloadProxy), toAPI(authenticationChallengeProxy), m_client.clientInfo);
+}
+
+void WebDownloadClient::didReceiveResponse(WebContext* webContext, DownloadProxy* downloadProxy, const ResourceResponse& response)
+{
+ if (!m_client.didReceiveResponse)
+ return;
+
+ m_client.didReceiveResponse(toAPI(webContext), toAPI(downloadProxy), toAPI(WebURLResponse::create(response).get()), m_client.clientInfo);
+}
+
+void WebDownloadClient::didReceiveData(WebContext* webContext, DownloadProxy* downloadProxy, uint64_t length)
+{
+ if (!m_client.didReceiveData)
+ return;
+
+ m_client.didReceiveData(toAPI(webContext), toAPI(downloadProxy), length, m_client.clientInfo);
+}
+
+bool WebDownloadClient::shouldDecodeSourceDataOfMIMEType(WebContext* webContext, DownloadProxy* downloadProxy, const String& mimeType)
+{
+ if (!m_client.shouldDecodeSourceDataOfMIMEType)
+ return true;
+
+ return m_client.shouldDecodeSourceDataOfMIMEType(toAPI(webContext), toAPI(downloadProxy), toAPI(mimeType.impl()), m_client.clientInfo);
+}
+
+String WebDownloadClient::decideDestinationWithSuggestedFilename(WebContext* webContext, DownloadProxy* downloadProxy, const String& filename, bool& allowOverwrite)
+{
+ if (!m_client.decideDestinationWithSuggestedFilename)
+ return String();
+
+ WKRetainPtr<WKStringRef> destination(AdoptWK, m_client.decideDestinationWithSuggestedFilename(toAPI(webContext), toAPI(downloadProxy), toAPI(filename.impl()), &allowOverwrite, m_client.clientInfo));
+ return toWTFString(destination.get());
+}
+
+void WebDownloadClient::didCreateDestination(WebContext* webContext, DownloadProxy* downloadProxy, const String& path)
+{
+ if (!m_client.didCreateDestination)
+ return;
+
+ m_client.didCreateDestination(toAPI(webContext), toAPI(downloadProxy), toAPI(path.impl()), m_client.clientInfo);
+}
+
+void WebDownloadClient::didFinish(WebContext* webContext, DownloadProxy* downloadProxy)
+{
+ if (!m_client.didFinish)
+ return;
+
+ m_client.didFinish(toAPI(webContext), toAPI(downloadProxy), m_client.clientInfo);
+}
+
+void WebDownloadClient::didFail(WebContext* webContext, DownloadProxy* downloadProxy, const ResourceError& error)
+{
+ if (!m_client.didFail)
+ return;
+
+ m_client.didFail(toAPI(webContext), toAPI(downloadProxy), toAPI(error), m_client.clientInfo);
+}
+
+void WebDownloadClient::didCancel(WebContext* webContext, DownloadProxy* downloadProxy)
+{
+ if (!m_client.didCancel)
+ return;
+
+ m_client.didCancel(toAPI(webContext), toAPI(downloadProxy), m_client.clientInfo);
+}
+
+void WebDownloadClient::processDidCrash(WebContext* webContext, DownloadProxy* downloadProxy)
+{
+ if (!m_client.processDidCrash)
+ return;
+
+ m_client.processDidCrash(toAPI(webContext), toAPI(downloadProxy), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebDownloadClient.h b/Source/WebKit2/UIProcess/WebDownloadClient.h
new file mode 100644
index 000000000..20950e569
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDownloadClient.h
@@ -0,0 +1,61 @@
+/*
+ * 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 WebDownloadClient_h
+#define WebDownloadClient_h
+
+#include "APIClient.h"
+#include "WKContext.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+ class ResourceError;
+ class ResourceResponse;
+}
+
+namespace WebKit {
+
+class AuthenticationChallengeProxy;
+class DownloadProxy;
+class WebContext;
+
+class WebDownloadClient : public APIClient<WKContextDownloadClient, kWKContextDownloadClientCurrentVersion> {
+public:
+ void didStart(WebContext*, DownloadProxy*);
+ void didReceiveAuthenticationChallenge(WebContext*, DownloadProxy*, AuthenticationChallengeProxy*);
+ void didReceiveResponse(WebContext*, DownloadProxy*, const WebCore::ResourceResponse&);
+ void didReceiveData(WebContext*, DownloadProxy*, uint64_t length);
+ bool shouldDecodeSourceDataOfMIMEType(WebContext*, DownloadProxy*, const String& mimeType);
+ String decideDestinationWithSuggestedFilename(WebContext*, DownloadProxy*, const String& filename, bool& allowOverwrite);
+ void didCreateDestination(WebContext*, DownloadProxy*, const String& path);
+ void didFinish(WebContext*, DownloadProxy*);
+ void didFail(WebContext*, DownloadProxy*, const WebCore::ResourceError&);
+ void didCancel(WebContext*, DownloadProxy*);
+ void processDidCrash(WebContext*, DownloadProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebDownloadClient_h
diff --git a/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp b/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp
new file mode 100644
index 000000000..25ffe2302
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp
@@ -0,0 +1,152 @@
+/*
+ * 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 "WebEditCommandProxy.h"
+
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include <WebCore/LocalizedStrings.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebEditCommandProxy::WebEditCommandProxy(uint64_t commandID, WebCore::EditAction editAction, WebPageProxy* page)
+ : m_commandID(commandID)
+ , m_editAction(editAction)
+ , m_page(page)
+{
+ m_page->addEditCommand(this);
+}
+
+WebEditCommandProxy::~WebEditCommandProxy()
+{
+ if (m_page)
+ m_page->removeEditCommand(this);
+}
+
+void WebEditCommandProxy::unapply()
+{
+ if (!m_page || !m_page->isValid())
+ return;
+
+ m_page->process()->send(Messages::WebPage::UnapplyEditCommand(m_commandID), m_page->pageID(), CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_page->registerEditCommand(this, WebPageProxy::Redo);
+}
+
+void WebEditCommandProxy::reapply()
+{
+ if (!m_page || !m_page->isValid())
+ return;
+
+ m_page->process()->send(Messages::WebPage::ReapplyEditCommand(m_commandID), m_page->pageID(), CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+ m_page->registerEditCommand(this, WebPageProxy::Undo);
+}
+
+String WebEditCommandProxy::nameForEditAction(EditAction editAction)
+{
+ switch (editAction) {
+ case EditActionUnspecified:
+ return String();
+ case EditActionSetColor:
+ return WEB_UI_STRING_KEY("Set Color", "Set Color (Undo action name)", "Undo action name");
+ case EditActionSetBackgroundColor:
+ return WEB_UI_STRING_KEY("Set Background Color", "Set Background Color (Undo action name)", "Undo action name");
+ case EditActionTurnOffKerning:
+ return WEB_UI_STRING_KEY("Turn Off Kerning", "Turn Off Kerning (Undo action name)", "Undo action name");
+ case EditActionTightenKerning:
+ return WEB_UI_STRING_KEY("Tighten Kerning", "Tighten Kerning (Undo action name)", "Undo action name");
+ case EditActionLoosenKerning:
+ return WEB_UI_STRING_KEY("Loosen Kerning", "Loosen Kerning (Undo action name)", "Undo action name");
+ case EditActionUseStandardKerning:
+ return WEB_UI_STRING_KEY("Use Standard Kerning", "Use Standard Kerning (Undo action name)", "Undo action name");
+ case EditActionTurnOffLigatures:
+ return WEB_UI_STRING_KEY("Turn Off Ligatures", "Turn Off Ligatures (Undo action name)", "Undo action name");
+ case EditActionUseStandardLigatures:
+ return WEB_UI_STRING_KEY("Use Standard Ligatures", "Use Standard Ligatures (Undo action name)", "Undo action name");
+ case EditActionUseAllLigatures:
+ return WEB_UI_STRING_KEY("Use All Ligatures", "Use All Ligatures (Undo action name)", "Undo action name");
+ case EditActionRaiseBaseline:
+ return WEB_UI_STRING_KEY("Raise Baseline", "Raise Baseline (Undo action name)", "Undo action name");
+ case EditActionLowerBaseline:
+ return WEB_UI_STRING_KEY("Lower Baseline", "Lower Baseline (Undo action name)", "Undo action name");
+ case EditActionSetTraditionalCharacterShape:
+ return WEB_UI_STRING_KEY("Set Traditional Character Shape", "Set Traditional Character Shape (Undo action name)", "Undo action name");
+ case EditActionSetFont:
+ return WEB_UI_STRING_KEY("Set Font", "Set Font (Undo action name)", "Undo action name");
+ case EditActionChangeAttributes:
+ return WEB_UI_STRING_KEY("Change Attributes", "Change Attributes (Undo action name)", "Undo action name");
+ case EditActionAlignLeft:
+ return WEB_UI_STRING_KEY("Align Left", "Align Left (Undo action name)", "Undo action name");
+ case EditActionAlignRight:
+ return WEB_UI_STRING_KEY("Align Right", "Align Right (Undo action name)", "Undo action name");
+ case EditActionCenter:
+ return WEB_UI_STRING_KEY("Center", "Center (Undo action name)", "Undo action name");
+ case EditActionJustify:
+ return WEB_UI_STRING_KEY("Justify", "Justify (Undo action name)", "Undo action name");
+ case EditActionSetWritingDirection:
+ return WEB_UI_STRING_KEY("Set Writing Direction", "Set Writing Direction (Undo action name)", "Undo action name");
+ case EditActionSubscript:
+ return WEB_UI_STRING_KEY("Subscript", "Subscript (Undo action name)", "Undo action name");
+ case EditActionSuperscript:
+ return WEB_UI_STRING_KEY("Superscript", "Superscript (Undo action name)", "Undo action name");
+ case EditActionUnderline:
+ return WEB_UI_STRING_KEY("Underline", "Underline (Undo action name)", "Undo action name");
+ case EditActionOutline:
+ return WEB_UI_STRING_KEY("Outline", "Outline (Undo action name)", "Undo action name");
+ case EditActionUnscript:
+ return WEB_UI_STRING_KEY("Unscript", "Unscript (Undo action name)", "Undo action name");
+ case EditActionDrag:
+ return WEB_UI_STRING_KEY("Drag", "Drag (Undo action name)", "Undo action name");
+ case EditActionCut:
+ return WEB_UI_STRING_KEY("Cut", "Cut (Undo action name)", "Undo action name");
+ case EditActionPaste:
+ return WEB_UI_STRING_KEY("Paste", "Paste (Undo action name)", "Undo action name");
+ case EditActionPasteFont:
+ return WEB_UI_STRING_KEY("Paste Font", "Paste Font (Undo action name)", "Undo action name");
+ case EditActionPasteRuler:
+ return WEB_UI_STRING_KEY("Paste Ruler", "Paste Ruler (Undo action name)", "Undo action name");
+ case EditActionTyping:
+ return WEB_UI_STRING_KEY("Typing", "Typing (Undo action name)", "Undo action name");
+ case EditActionCreateLink:
+ return WEB_UI_STRING_KEY("Create Link", "Create Link (Undo action name)", "Undo action name");
+ case EditActionUnlink:
+ return WEB_UI_STRING_KEY("Unlink", "Unlink (Undo action name)", "Undo action name");
+ case EditActionInsertList:
+ return WEB_UI_STRING_KEY("Insert List", "Insert List (Undo action name)", "Undo action name");
+ case EditActionFormatBlock:
+ return WEB_UI_STRING_KEY("Formatting", "Format Block (Undo action name)", "Undo action name");
+ case EditActionIndent:
+ return WEB_UI_STRING_KEY("Indent", "Indent (Undo action name)", "Undo action name");
+ case EditActionOutdent:
+ return WEB_UI_STRING_KEY("Outdent", "Outdent (Undo action name)", "Undo action name");
+ }
+ return String();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebEditCommandProxy.h b/Source/WebKit2/UIProcess/WebEditCommandProxy.h
new file mode 100644
index 000000000..67d1430f1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.h
@@ -0,0 +1,69 @@
+/*
+ * 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 WebEditCommandProxy_h
+#define WebEditCommandProxy_h
+
+#include "APIObject.h"
+#include <WebCore/EditAction.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebEditCommandProxy : public APIObject {
+public:
+ static PassRefPtr<WebEditCommandProxy> create(uint64_t commandID, WebCore::EditAction editAction, WebPageProxy* page)
+ {
+ return adoptRef(new WebEditCommandProxy(commandID, editAction, page));
+ }
+ ~WebEditCommandProxy();
+
+ uint64_t commandID() const { return m_commandID; }
+ WebCore::EditAction editAction() const { return m_editAction; }
+
+ void invalidate() { m_page = 0; }
+
+ void unapply();
+ void reapply();
+
+ static String nameForEditAction(WebCore::EditAction);
+
+private:
+ WebEditCommandProxy(uint64_t commandID, WebCore::EditAction, WebPageProxy*);
+
+ virtual Type type() const { return TypeEditCommandProxy; }
+
+ uint64_t m_commandID;
+ WebCore::EditAction m_editAction;
+ WebPageProxy* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebEditCommandProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFindClient.cpp b/Source/WebKit2/UIProcess/WebFindClient.cpp
new file mode 100644
index 000000000..c8df91dbd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFindClient.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 "WebFindClient.h"
+#include "WKAPICast.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+void WebFindClient::didFindString(WebPageProxy* page, const String& string, uint32_t matchCount)
+{
+ if (!m_client.didFindString)
+ return;
+
+ m_client.didFindString(toAPI(page), toAPI(string.impl()), matchCount, m_client.clientInfo);
+
+}
+
+void WebFindClient::didFailToFindString(WebPageProxy* page, const String& string)
+{
+ if (!m_client.didFailToFindString)
+ return;
+
+ m_client.didFailToFindString(toAPI(page), toAPI(string.impl()), m_client.clientInfo);
+}
+
+void WebFindClient::didCountStringMatches(WebPageProxy* page, const String& string, uint32_t matchCount)
+{
+ if (!m_client.didCountStringMatches)
+ return;
+
+ m_client.didCountStringMatches(toAPI(page), toAPI(string.impl()), matchCount, m_client.clientInfo);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/WebFindClient.h b/Source/WebKit2/UIProcess/WebFindClient.h
new file mode 100644
index 000000000..82380ab78
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFindClient.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 WebFindClient_h
+#define WebFindClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebFindClient : public APIClient<WKPageFindClient, kWKPageFindClientCurrentVersion> {
+public:
+ void didFindString(WebPageProxy*, const String&, uint32_t matchCount);
+ void didFailToFindString(WebPageProxy*, const String&);
+ void didCountStringMatches(WebPageProxy*, const String&, uint32_t matchCount);
+};
+
+} // namespace WebKit
+
+#endif // WebFindClient_h
diff --git a/Source/WebKit2/UIProcess/WebFormClient.cpp b/Source/WebKit2/UIProcess/WebFormClient.cpp
new file mode 100644
index 000000000..ecddbcc42
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormClient.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebFormClient.h"
+
+#include "ImmutableDictionary.h"
+#include "WKAPICast.h"
+#include "WebString.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+bool WebFormClient::willSubmitForm(WebPageProxy* page, WebFrameProxy* frame, WebFrameProxy* sourceFrame, const Vector<std::pair<String, String> >& textFieldValues, APIObject* userData, WebFormSubmissionListenerProxy* listener)
+{
+ if (!m_client.willSubmitForm)
+ return false;
+
+ ImmutableDictionary::MapType map;
+ for (size_t i = 0; i < textFieldValues.size(); ++i)
+ map.set(textFieldValues[i].first, WebString::create(textFieldValues[i].second));
+ RefPtr<ImmutableDictionary> textFieldsMap = ImmutableDictionary::adopt(map);
+
+ m_client.willSubmitForm(toAPI(page), toAPI(frame), toAPI(sourceFrame), toAPI(textFieldsMap.get()), toAPI(userData), toAPI(listener), m_client.clientInfo);
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFormClient.h b/Source/WebKit2/UIProcess/WebFormClient.h
new file mode 100644
index 000000000..05925239f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormClient.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 WebFormClient_h
+#define WebFormClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include <utility>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class APIObject;
+class WebPageProxy;
+class WebFrameProxy;
+class WebFormSubmissionListenerProxy;
+
+class WebFormClient : public APIClient<WKPageFormClient, kWKPageFormClientCurrentVersion> {
+public:
+ bool willSubmitForm(WebPageProxy*, WebFrameProxy*, WebFrameProxy*, const Vector<std::pair<String, String> >& textFieldValues, APIObject* userData, WebFormSubmissionListenerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebFormClient_h
diff --git a/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.cpp b/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.cpp
new file mode 100644
index 000000000..dcc864afe
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.cpp
@@ -0,0 +1,41 @@
+/*
+ * 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 "WebFormSubmissionListenerProxy.h"
+
+namespace WebKit {
+
+WebFormSubmissionListenerProxy::WebFormSubmissionListenerProxy(WebFrameProxy* frame, uint64_t listenerID)
+ : WebFrameListenerProxy(frame, listenerID)
+{
+}
+
+void WebFormSubmissionListenerProxy::continueSubmission()
+{
+ receivedPolicyDecision(WebCore::PolicyUse);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.h b/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.h
new file mode 100644
index 000000000..53ba3b980
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.h
@@ -0,0 +1,54 @@
+/*
+ * 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 WebFormSubmissionListenerProxy_h
+#define WebFormSubmissionListenerProxy_h
+
+#include "WebFrameListenerProxy.h"
+
+namespace WebKit {
+
+class WebFrameProxy;
+
+class WebFormSubmissionListenerProxy : public WebFrameListenerProxy {
+public:
+ static const Type APIType = TypeFormSubmissionListener;
+
+ static PassRefPtr<WebFormSubmissionListenerProxy> create(WebFrameProxy* frame, uint64_t listenerID)
+ {
+ return adoptRef(new WebFormSubmissionListenerProxy(frame, listenerID));
+ }
+
+ void continueSubmission();
+
+private:
+ WebFormSubmissionListenerProxy(WebFrameProxy*, uint64_t listenerID);
+
+ virtual Type type() const { return APIType; }
+};
+
+} // namespace WebKit
+
+#endif // WebFramePolicyListenerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFrameListenerProxy.cpp b/Source/WebKit2/UIProcess/WebFrameListenerProxy.cpp
new file mode 100644
index 000000000..b998f5836
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameListenerProxy.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 "WebFrameListenerProxy.h"
+
+#include "WebFrameProxy.h"
+
+namespace WebKit {
+
+WebFrameListenerProxy::WebFrameListenerProxy(WebFrameProxy* frame, uint64_t listenerID)
+ : m_frame(frame)
+ , m_listenerID(listenerID)
+{
+}
+
+WebFrameListenerProxy::~WebFrameListenerProxy()
+{
+}
+
+void WebFrameListenerProxy::invalidate()
+{
+ m_frame = 0;
+}
+
+void WebFrameListenerProxy::receivedPolicyDecision(WebCore::PolicyAction action)
+{
+ if (!m_frame)
+ return;
+
+ m_frame->receivedPolicyDecision(action, m_listenerID);
+ m_frame = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFrameListenerProxy.h b/Source/WebKit2/UIProcess/WebFrameListenerProxy.h
new file mode 100644
index 000000000..fd9ad7194
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameListenerProxy.h
@@ -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.
+ */
+
+#ifndef WebFrameListenerProxy_h
+#define WebFrameListenerProxy_h
+
+#include "APIObject.h"
+#include <WebCore/FrameLoaderTypes.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class WebFrameProxy;
+
+class WebFrameListenerProxy : public APIObject {
+public:
+ virtual ~WebFrameListenerProxy();
+
+ void invalidate();
+ uint64_t listenerID() const { return m_listenerID; }
+
+protected:
+ WebFrameListenerProxy(WebFrameProxy*, uint64_t listenerID);
+
+ void receivedPolicyDecision(WebCore::PolicyAction);
+
+private:
+ RefPtr<WebFrameProxy> m_frame;
+ uint64_t m_listenerID;
+};
+
+} // namespace WebKit
+
+#endif // WebFrameListenerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.cpp b/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.cpp
new file mode 100644
index 000000000..576453343
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.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 "WebFramePolicyListenerProxy.h"
+
+#include "WebFrameProxy.h"
+
+namespace WebKit {
+
+WebFramePolicyListenerProxy::WebFramePolicyListenerProxy(WebFrameProxy* frame, uint64_t listenerID)
+ : WebFrameListenerProxy(frame, listenerID)
+{
+}
+
+void WebFramePolicyListenerProxy::use()
+{
+ receivedPolicyDecision(WebCore::PolicyUse);
+}
+
+void WebFramePolicyListenerProxy::download()
+{
+ receivedPolicyDecision(WebCore::PolicyDownload);
+}
+
+void WebFramePolicyListenerProxy::ignore()
+{
+ receivedPolicyDecision(WebCore::PolicyIgnore);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.h b/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.h
new file mode 100644
index 000000000..779d2a56c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.h
@@ -0,0 +1,54 @@
+/*
+ * 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 WebFramePolicyListenerProxy_h
+#define WebFramePolicyListenerProxy_h
+
+#include "WebFrameListenerProxy.h"
+
+namespace WebKit {
+
+class WebFramePolicyListenerProxy : public WebFrameListenerProxy {
+public:
+ static const Type APIType = TypeFramePolicyListener;
+
+ static PassRefPtr<WebFramePolicyListenerProxy> create(WebFrameProxy* frame, uint64_t listenerID)
+ {
+ return adoptRef(new WebFramePolicyListenerProxy(frame, listenerID));
+ }
+
+ void use();
+ void download();
+ void ignore();
+
+private:
+ WebFramePolicyListenerProxy(WebFrameProxy*, uint64_t listenerID);
+
+ virtual Type type() const { return APIType; }
+};
+
+} // namespace WebKit
+
+#endif // WebFramePolicyListenerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.cpp b/Source/WebKit2/UIProcess/WebFrameProxy.cpp
new file mode 100644
index 000000000..f60fab040
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameProxy.cpp
@@ -0,0 +1,340 @@
+/*
+ * 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 "WebFrameProxy.h"
+
+#include "WebCertificateInfo.h"
+#include "WebContext.h"
+#include "WebFormSubmissionListenerProxy.h"
+#include "WebFramePolicyListenerProxy.h"
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include <WebCore/DOMImplementation.h>
+#include <WebCore/Image.h>
+#include <stdio.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebKit {
+
+WebFrameProxy::WebFrameProxy(WebPageProxy* page, uint64_t frameID)
+ : m_page(page)
+ , m_parentFrame(0)
+ , m_nextSibling(0)
+ , m_previousSibling(0)
+ , m_firstChild(0)
+ , m_lastChild(0)
+ , m_loadState(LoadStateFinished)
+ , m_isFrameSet(false)
+ , m_frameID(frameID)
+{
+ WebContext::statistics().wkFrameCount++;
+}
+
+WebFrameProxy::~WebFrameProxy()
+{
+ WebContext::statistics().wkFrameCount--;
+}
+
+void WebFrameProxy::disconnect()
+{
+ m_page = 0;
+ m_parentFrame = 0;
+ m_nextSibling = 0;
+ m_previousSibling = 0;
+ m_firstChild = 0;
+ m_lastChild = 0;
+
+ if (m_activeListener) {
+ m_activeListener->invalidate();
+ m_activeListener = 0;
+ }
+}
+
+bool WebFrameProxy::isMainFrame() const
+{
+ if (!m_page)
+ return false;
+
+ return this == m_page->mainFrame();
+}
+
+void WebFrameProxy::stopLoading() const
+{
+ if (!m_page)
+ return;
+
+ if (!m_page->isValid())
+ return;
+
+ m_page->process()->send(Messages::WebPage::StopLoadingFrame(m_frameID), m_page->pageID());
+}
+
+bool WebFrameProxy::canProvideSource() const
+{
+ return isDisplayingMarkupDocument();
+}
+
+bool WebFrameProxy::canShowMIMEType(const String& mimeType) const
+{
+ if (!m_page)
+ return false;
+
+ if (m_page->canShowMIMEType(mimeType))
+ return true;
+
+#if PLATFORM(MAC)
+ // On Mac, we can show PDFs.
+ if (!mimeType.isEmpty())
+ return WebContext::pdfAndPostScriptMIMETypes().contains(mimeType) && !WebContext::omitPDFSupport();
+#endif
+
+ return false;
+}
+
+bool WebFrameProxy::isDisplayingStandaloneImageDocument() const
+{
+ return Image::supportsType(m_MIMEType);
+}
+
+bool WebFrameProxy::isDisplayingMarkupDocument() const
+{
+ // FIXME: This check should be moved to somewhere in WebCore.
+ // FIXME: This returns false when displaying a web archive.
+ return m_MIMEType == "text/html" || m_MIMEType == "image/svg+xml" || DOMImplementation::isXMLMIMEType(m_MIMEType);
+}
+
+bool WebFrameProxy::isDisplayingPDFDocument() const
+{
+ if (m_MIMEType.isEmpty())
+ return false;
+
+ return WebContext::pdfAndPostScriptMIMETypes().contains(m_MIMEType);
+}
+
+void WebFrameProxy::didStartProvisionalLoad(const String& url)
+{
+ ASSERT(m_loadState == LoadStateFinished);
+ ASSERT(m_provisionalURL.isEmpty());
+ m_loadState = LoadStateProvisional;
+ m_provisionalURL = url;
+}
+
+void WebFrameProxy::didReceiveServerRedirectForProvisionalLoad(const String& url)
+{
+ ASSERT(m_loadState == LoadStateProvisional);
+ m_provisionalURL = url;
+}
+
+void WebFrameProxy::didFailProvisionalLoad()
+{
+ ASSERT(m_loadState == LoadStateProvisional);
+ m_loadState = LoadStateFinished;
+ m_provisionalURL = String();
+ m_unreachableURL = m_lastUnreachableURL;
+}
+
+void WebFrameProxy::didCommitLoad(const String& contentType, const PlatformCertificateInfo& certificateInfo)
+{
+ ASSERT(m_loadState == LoadStateProvisional);
+ m_loadState = LoadStateCommitted;
+ m_url = m_provisionalURL;
+ m_provisionalURL = String();
+ m_title = String();
+ m_MIMEType = contentType;
+ m_isFrameSet = false;
+ m_certificateInfo = WebCertificateInfo::create(certificateInfo);
+}
+
+void WebFrameProxy::didFinishLoad()
+{
+ ASSERT(m_loadState == LoadStateCommitted);
+ ASSERT(m_provisionalURL.isEmpty());
+ m_loadState = LoadStateFinished;
+}
+
+void WebFrameProxy::didFailLoad()
+{
+ ASSERT(m_loadState == LoadStateCommitted);
+ ASSERT(m_provisionalURL.isEmpty());
+ m_loadState = LoadStateFinished;
+ m_title = String();
+}
+
+void WebFrameProxy::didSameDocumentNavigation(const String& url)
+{
+ m_url = url;
+}
+
+void WebFrameProxy::didChangeTitle(const String& title)
+{
+ m_title = title;
+}
+
+void WebFrameProxy::appendChild(WebFrameProxy* child)
+{
+ ASSERT(child->page() == page());
+ ASSERT(!child->m_parentFrame);
+ ASSERT(!child->m_nextSibling);
+ ASSERT(!child->m_previousSibling);
+
+ child->m_parentFrame = this;
+
+ WebFrameProxy* oldLast = m_lastChild;
+ m_lastChild = child;
+
+ if (oldLast) {
+ ASSERT(!oldLast->m_nextSibling);
+ child->m_previousSibling = oldLast;
+ oldLast->m_nextSibling = child;
+ } else
+ m_firstChild = child;
+}
+
+void WebFrameProxy::removeChild(WebFrameProxy* child)
+{
+ child->m_parentFrame = 0;
+
+ WebFrameProxy*& newLocationForNext = m_firstChild == child ? m_firstChild : child->m_previousSibling->m_nextSibling;
+ WebFrameProxy*& newLocationForPrevious = m_lastChild == child ? m_lastChild : child->m_nextSibling->m_previousSibling;
+ swap(newLocationForNext, child->m_nextSibling);
+ swap(newLocationForPrevious, child->m_previousSibling);
+ child->m_previousSibling = 0;
+ child->m_nextSibling = 0;
+}
+
+bool WebFrameProxy::isDescendantOf(const WebFrameProxy* ancestor) const
+{
+ if (!ancestor)
+ return false;
+
+ if (m_page != ancestor->m_page)
+ return false;
+
+ for (const WebFrameProxy* frame = this; frame; frame = frame->m_parentFrame) {
+ if (frame == ancestor)
+ return true;
+ }
+
+ return false;
+}
+
+void WebFrameProxy::dumpFrameTreeToSTDOUT(unsigned indent)
+{
+ if (!indent && m_parentFrame)
+ printf("NOTE: Printing subtree.\n");
+
+ for (unsigned i = 0; i < indent; ++i)
+ printf(" ");
+ printf("| FRAME %d %s\n", (int)m_frameID, m_url.utf8().data());
+
+ for (WebFrameProxy* child = m_firstChild; child; child = child->m_nextSibling)
+ child->dumpFrameTreeToSTDOUT(indent + 4);
+}
+
+void WebFrameProxy::didRemoveFromHierarchy()
+{
+ if (m_parentFrame)
+ m_parentFrame->removeChild(this);
+}
+
+PassRefPtr<ImmutableArray> WebFrameProxy::childFrames()
+{
+ if (!m_firstChild)
+ return ImmutableArray::create();
+
+ Vector<RefPtr<APIObject> > vector;
+ for (WebFrameProxy* child = m_firstChild; child; child = child->m_nextSibling)
+ vector.append(child);
+
+ return ImmutableArray::adopt(vector);
+}
+
+void WebFrameProxy::receivedPolicyDecision(WebCore::PolicyAction action, uint64_t listenerID)
+{
+ if (!m_page)
+ return;
+
+ ASSERT(m_activeListener);
+ ASSERT(m_activeListener->listenerID() == listenerID);
+ m_page->receivedPolicyDecision(action, this, listenerID);
+}
+
+WebFramePolicyListenerProxy* WebFrameProxy::setUpPolicyListenerProxy(uint64_t listenerID)
+{
+ if (m_activeListener)
+ m_activeListener->invalidate();
+ m_activeListener = WebFramePolicyListenerProxy::create(this, listenerID);
+ return static_cast<WebFramePolicyListenerProxy*>(m_activeListener.get());
+}
+
+WebFormSubmissionListenerProxy* WebFrameProxy::setUpFormSubmissionListenerProxy(uint64_t listenerID)
+{
+ if (m_activeListener)
+ m_activeListener->invalidate();
+ m_activeListener = WebFormSubmissionListenerProxy::create(this, listenerID);
+ return static_cast<WebFormSubmissionListenerProxy*>(m_activeListener.get());
+}
+
+void WebFrameProxy::getWebArchive(PassRefPtr<DataCallback> callback)
+{
+ if (!m_page) {
+ callback->invalidate();
+ return;
+ }
+
+ m_page->getWebArchiveOfFrame(this, callback);
+}
+
+void WebFrameProxy::getMainResourceData(PassRefPtr<DataCallback> callback)
+{
+ if (!m_page) {
+ callback->invalidate();
+ return;
+ }
+
+ m_page->getMainResourceDataOfFrame(this, callback);
+}
+
+void WebFrameProxy::getResourceData(WebURL* resourceURL, PassRefPtr<DataCallback> callback)
+{
+ if (!m_page) {
+ callback->invalidate();
+ return;
+ }
+
+ m_page->getResourceDataFromFrame(this, resourceURL, callback);
+}
+
+void WebFrameProxy::setUnreachableURL(const String& unreachableURL)
+{
+ m_lastUnreachableURL = m_unreachableURL;
+ m_unreachableURL = unreachableURL;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.h b/Source/WebKit2/UIProcess/WebFrameProxy.h
new file mode 100644
index 000000000..de5a58cb7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameProxy.h
@@ -0,0 +1,164 @@
+/*
+ * 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 WebFrameProxy_h
+#define WebFrameProxy_h
+
+#include "APIObject.h"
+#include "ImmutableArray.h"
+#include "GenericCallback.h"
+#include "WebFrameListenerProxy.h"
+#include <WebCore/FrameLoaderTypes.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+class ImmutableArray;
+class PlatformCertificateInfo;
+class WebCertificateInfo;
+class WebFormSubmissionListenerProxy;
+class WebFramePolicyListenerProxy;
+class WebPageProxy;
+
+typedef GenericCallback<WKDataRef> DataCallback;
+
+class WebFrameProxy : public APIObject {
+public:
+ static const Type APIType = TypeFrame;
+
+ static PassRefPtr<WebFrameProxy> create(WebPageProxy* page, uint64_t frameID)
+ {
+ return adoptRef(new WebFrameProxy(page, frameID));
+ }
+
+ virtual ~WebFrameProxy();
+
+ enum LoadState {
+ LoadStateProvisional,
+ LoadStateCommitted,
+ LoadStateFinished
+ };
+
+ uint64_t frameID() const { return m_frameID; }
+ WebPageProxy* page() const { return m_page; }
+
+ WebFrameProxy* parentFrame() { return m_parentFrame; }
+ WebFrameProxy* nextSibling() { return m_nextSibling; }
+ WebFrameProxy* previousSibling() { return m_previousSibling; }
+ WebFrameProxy* firstChild() { return m_firstChild; }
+ WebFrameProxy* lastChild() { return m_lastChild; }
+
+ void disconnect();
+
+ bool isMainFrame() const;
+
+ void setIsFrameSet(bool value) { m_isFrameSet = value; }
+ bool isFrameSet() const { return m_isFrameSet; }
+
+ LoadState loadState() const { return m_loadState; }
+
+ void stopLoading() const;
+
+ const String& url() const { return m_url; }
+ const String& provisionalURL() const { return m_provisionalURL; }
+
+ void setUnreachableURL(const String&);
+ const String& unreachableURL() const { return m_unreachableURL; }
+
+ const String& mimeType() const { return m_MIMEType; }
+
+ const String& title() const { return m_title; }
+
+ WebCertificateInfo* certificateInfo() const { return m_certificateInfo.get(); }
+
+ bool canProvideSource() const;
+ bool canShowMIMEType(const String& mimeType) const;
+
+ bool isDisplayingStandaloneImageDocument() const;
+ bool isDisplayingMarkupDocument() const;
+ bool isDisplayingPDFDocument() const;
+
+ void getWebArchive(PassRefPtr<DataCallback>);
+ void getMainResourceData(PassRefPtr<DataCallback>);
+ void getResourceData(WebURL*, PassRefPtr<DataCallback>);
+
+ void didStartProvisionalLoad(const String& url);
+ void didReceiveServerRedirectForProvisionalLoad(const String& url);
+ void didFailProvisionalLoad();
+ void didCommitLoad(const String& contentType, const PlatformCertificateInfo&);
+ void didFinishLoad();
+ void didFailLoad();
+ void didSameDocumentNavigation(const String&); // eg. anchor navigation, session state change.
+ void didChangeTitle(const String&);
+
+ // Frame tree operations.
+ void appendChild(WebFrameProxy*);
+ void removeChild(WebFrameProxy*);
+ void didRemoveFromHierarchy();
+ PassRefPtr<ImmutableArray> childFrames();
+ bool isDescendantOf(const WebFrameProxy* ancestor) const;
+ void dumpFrameTreeToSTDOUT(unsigned indent = 0);
+
+ // Policy operations.
+ void receivedPolicyDecision(WebCore::PolicyAction, uint64_t listenerID);
+ WebFramePolicyListenerProxy* setUpPolicyListenerProxy(uint64_t listenerID);
+ WebFormSubmissionListenerProxy* setUpFormSubmissionListenerProxy(uint64_t listenerID);
+
+private:
+ WebFrameProxy(WebPageProxy* page, uint64_t frameID);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageProxy* m_page;
+ WebFrameProxy* m_parentFrame;
+ WebFrameProxy* m_nextSibling;
+ WebFrameProxy* m_previousSibling;
+ WebFrameProxy* m_firstChild;
+ WebFrameProxy* m_lastChild;
+
+ LoadState m_loadState;
+ String m_url;
+ String m_provisionalURL;
+ String m_unreachableURL;
+ String m_lastUnreachableURL;
+ String m_MIMEType;
+ String m_title;
+ bool m_isFrameSet;
+ RefPtr<WebCertificateInfo> m_certificateInfo;
+ RefPtr<WebFrameListenerProxy> m_activeListener;
+ uint64_t m_frameID;
+};
+
+} // namespace WebKit
+
+#endif // WebFrameProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp
new file mode 100644
index 000000000..729b62e9d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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 "WebFullScreenManagerProxy.h"
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "WebContext.h"
+#include "WebFullScreenManagerMessages.h"
+#include "WebFullScreenManagerProxyMessages.h"
+
+namespace WebKit {
+
+PassRefPtr<WebFullScreenManagerProxy> WebFullScreenManagerProxy::create(WebPageProxy* page)
+{
+ return adoptRef(new WebFullScreenManagerProxy(page));
+}
+
+WebFullScreenManagerProxy::WebFullScreenManagerProxy(WebPageProxy* page)
+ : m_page(page)
+ , m_webView(0)
+{
+}
+
+WebFullScreenManagerProxy::~WebFullScreenManagerProxy()
+{
+}
+
+void WebFullScreenManagerProxy::setWebView(PlatformWebView* webView)
+{
+ m_webView = webView;
+}
+
+void WebFullScreenManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebFullScreenManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebFullScreenManagerProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ didReceiveSyncWebFullScreenManagerProxyMessage(connection, messageID, arguments, reply);
+}
+
+void WebFullScreenManagerProxy::willEnterFullScreen()
+{
+ m_page->process()->send(Messages::WebFullScreenManager::WillEnterFullScreen(), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::didEnterFullScreen()
+{
+ m_page->process()->send(Messages::WebFullScreenManager::DidEnterFullScreen(), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::willExitFullScreen()
+{
+ m_page->process()->send(Messages::WebFullScreenManager::WillExitFullScreen(), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::didExitFullScreen()
+{
+ m_page->process()->send(Messages::WebFullScreenManager::DidExitFullScreen(), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::beginEnterFullScreenAnimation(float duration)
+{
+ m_page->process()->send(Messages::WebFullScreenManager::BeginEnterFullScreenAnimation(duration), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::beginExitFullScreenAnimation(float duration)
+{
+ m_page->process()->send(Messages::WebFullScreenManager::BeginExitFullScreenAnimation(duration), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::disposeOfLayerClient()
+{
+ m_page->process()->send(Messages::WebFullScreenManager::DisposeOfLayerClient(), m_page->pageID());
+}
+
+void WebFullScreenManagerProxy::supportsFullScreen(bool withKeyboard, bool& supports)
+{
+ if (withKeyboard)
+ supports = false;
+ else
+ supports = true;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(FULLSCREEN_API)
diff --git a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h
new file mode 100644
index 000000000..1a1c94c93
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.h
@@ -0,0 +1,112 @@
+/*
+ * 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 WebFullScreenManagerProxy_h
+#define WebFullScreenManagerProxy_h
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "Connection.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+class MessageID;
+}
+
+namespace WebCore {
+class IntRect;
+}
+
+#if PLATFORM(MAC)
+OBJC_CLASS WKView;
+#endif
+
+namespace WebKit {
+
+#if PLATFORM(MAC)
+typedef WKView PlatformWebView;
+#elif PLATFORM(WIN)
+class WebView;
+typedef WebView PlatformWebView;
+#elif PLATFORM(QT)
+// FIXME: We need to investigate how to abstract QDesktopWebView/QTouchWebView here.
+typedef QObject PlatformWebView;
+#elif PLATFORM(GTK)
+class WebView;
+typedef WebView PlatformWebView;
+#endif
+
+class WebPageProxy;
+class LayerTreeContext;
+
+class WebFullScreenManagerProxy : public RefCounted<WebFullScreenManagerProxy> {
+public:
+ static PassRefPtr<WebFullScreenManagerProxy> create(WebPageProxy*);
+ virtual ~WebFullScreenManagerProxy();
+
+ void invalidate();
+
+ void setWebView(PlatformWebView*);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply);
+
+ void willEnterFullScreen();
+ void didEnterFullScreen();
+ void willExitFullScreen();
+ void didExitFullScreen();
+ void beginEnterFullScreenAnimation(float duration);
+ void beginExitFullScreenAnimation(float duration);
+ void disposeOfLayerClient();
+
+private:
+ WebFullScreenManagerProxy(WebPageProxy*);
+
+ void supportsFullScreen(bool withKeyboard, bool&);
+ void enterFullScreen();
+ void exitFullScreen();
+ void beganEnterFullScreenAnimation();
+ void finishedEnterFullScreenAnimation(bool completed);
+ void beganExitFullScreenAnimation();
+ void finishedExitFullScreenAnimation(bool completed);
+ void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ void exitAcceleratedCompositingMode();
+ void getFullScreenRect(WebCore::IntRect&);
+
+ WebPageProxy* m_page;
+ PlatformWebView* m_webView;
+
+ void didReceiveWebFullScreenManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebFullScreenManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply);
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(FULLSCREEN_API)
+
+#endif // WebFullScreenManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.messages.in
new file mode 100644
index 000000000..007e30916
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFullScreenManagerProxy.messages.in
@@ -0,0 +1,38 @@
+# 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.
+
+#if ENABLE(FULLSCREEN_API)
+messages -> WebFullScreenManagerProxy {
+ SupportsFullScreen(bool withKeyboard) -> (bool supportsFullScreen)
+ EnterFullScreen()
+ ExitFullScreen()
+ BeganEnterFullScreenAnimation()
+ FinishedEnterFullScreenAnimation(bool completed)
+ BeganExitFullScreenAnimation()
+ FinishedExitFullScreenAnimation(bool completed)
+ GetFullScreenRect() -> (WebCore::IntRect rect)
+#if USE(ACCELERATED_COMPOSITING)
+ EnterAcceleratedCompositingMode(WebKit::LayerTreeContext context)
+ ExitAcceleratedCompositingMode()
+#endif
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp
new file mode 100644
index 000000000..14ab88aed
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp
@@ -0,0 +1,98 @@
+/*
+ * 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 "WebGeolocationManagerProxy.h"
+
+#include "WebContext.h"
+#include "WebGeolocationManagerMessages.h"
+
+namespace WebKit {
+
+PassRefPtr<WebGeolocationManagerProxy> WebGeolocationManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebGeolocationManagerProxy(context));
+}
+
+WebGeolocationManagerProxy::WebGeolocationManagerProxy(WebContext* context)
+ : m_isUpdating(false)
+ , m_context(context)
+{
+}
+
+WebGeolocationManagerProxy::~WebGeolocationManagerProxy()
+{
+}
+
+void WebGeolocationManagerProxy::invalidate()
+{
+ stopUpdating();
+}
+
+void WebGeolocationManagerProxy::initializeProvider(const WKGeolocationProvider* provider)
+{
+ m_provider.initialize(provider);
+}
+
+void WebGeolocationManagerProxy::providerDidChangePosition(WebGeolocationPosition* position)
+{
+ if (!m_context)
+ return;
+
+ m_context->sendToAllProcesses(Messages::WebGeolocationManager::DidChangePosition(position->data()));
+}
+
+void WebGeolocationManagerProxy::providerDidFailToDeterminePosition()
+{
+ if (!m_context)
+ return;
+
+ m_context->sendToAllProcesses(Messages::WebGeolocationManager::DidFailToDeterminePosition());
+}
+
+void WebGeolocationManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebGeolocationManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebGeolocationManagerProxy::startUpdating()
+{
+ if (m_isUpdating)
+ return;
+
+ m_provider.startUpdating(this);
+ m_isUpdating = true;
+}
+
+void WebGeolocationManagerProxy::stopUpdating()
+{
+ if (!m_isUpdating)
+ return;
+
+ m_provider.stopUpdating(this);
+ m_isUpdating = false;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h
new file mode 100644
index 000000000..509169318
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h
@@ -0,0 +1,79 @@
+/*
+ * 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 WebGeolocationManagerProxy_h
+#define WebGeolocationManagerProxy_h
+
+#include "APIObject.h"
+#include "MessageID.h"
+#include "WebGeolocationProvider.h"
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebGeolocationPosition;
+
+class WebGeolocationManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeGeolocationManager;
+
+ static PassRefPtr<WebGeolocationManagerProxy> create(WebContext*);
+ virtual ~WebGeolocationManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_context = 0; }
+
+ void initializeProvider(const WKGeolocationProvider*);
+
+ void providerDidChangePosition(WebGeolocationPosition*);
+ void providerDidFailToDeterminePosition();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+private:
+ explicit WebGeolocationManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ // Implemented in generated WebGeolocationManagerProxyMessageReceiver.cpp
+ void didReceiveWebGeolocationManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ void startUpdating();
+ void stopUpdating();
+
+ bool m_isUpdating;
+
+ WebContext* m_context;
+ WebGeolocationProvider m_provider;
+};
+
+} // namespace WebKit
+
+#endif // WebGeolocationManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.messages.in
new file mode 100644
index 000000000..fe5a27300
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.messages.in
@@ -0,0 +1,26 @@
+# 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.
+
+messages -> WebGeolocationManagerProxy {
+ StartUpdating();
+ StopUpdating();
+}
diff --git a/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp b/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp
new file mode 100644
index 000000000..c382235c7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebGeolocationProvider.h"
+
+#include "WKAPICast.h"
+#include "WebGeolocationManagerProxy.h"
+
+namespace WebKit {
+
+void WebGeolocationProvider::startUpdating(WebGeolocationManagerProxy* geolocationManager)
+{
+ if (!m_client.startUpdating)
+ return;
+
+ m_client.startUpdating(toAPI(geolocationManager), m_client.clientInfo);
+}
+
+void WebGeolocationProvider::stopUpdating(WebGeolocationManagerProxy* geolocationManager)
+{
+ if (!m_client.stopUpdating)
+ return;
+
+ m_client.stopUpdating(toAPI(geolocationManager), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebGeolocationProvider.h b/Source/WebKit2/UIProcess/WebGeolocationProvider.h
new file mode 100644
index 000000000..1776879d5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationProvider.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 WebGeolocationProvider_h
+#define WebGeolocationProvider_h
+
+#include "APIClient.h"
+#include "WKGeolocationManager.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebGeolocationManagerProxy;
+
+class WebGeolocationProvider : public APIClient<WKGeolocationProvider, kWKGeolocationProviderCurrentVersion> {
+public:
+ void startUpdating(WebGeolocationManagerProxy*);
+ void stopUpdating(WebGeolocationManagerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebGeolocationProvider_h
diff --git a/Source/WebKit2/UIProcess/WebGrammarDetail.cpp b/Source/WebKit2/UIProcess/WebGrammarDetail.cpp
new file mode 100644
index 000000000..8df528cd9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGrammarDetail.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 "WebGrammarDetail.h"
+
+#include "ImmutableArray.h"
+#include "WKGrammarDetail.h"
+#include "WebString.h"
+
+namespace WebKit {
+
+PassRefPtr<WebGrammarDetail> WebGrammarDetail::create(int location, int length, ImmutableArray* guesses, const String& userDescription)
+{
+ return adoptRef(new WebGrammarDetail(location, length, guesses, userDescription));
+}
+
+PassRefPtr<WebGrammarDetail> WebGrammarDetail::create(const WebCore::GrammarDetail& grammarDetail)
+{
+ return adoptRef(new WebGrammarDetail(grammarDetail));
+}
+
+WebGrammarDetail::WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription)
+{
+ m_grammarDetail.location = location;
+ m_grammarDetail.length = length;
+
+ size_t numGuesses = guesses->size();
+ m_grammarDetail.guesses.reserveCapacity(numGuesses);
+ for (size_t i = 0; i < numGuesses; ++i)
+ m_grammarDetail.guesses.uncheckedAppend(guesses->at<WebString>(i)->string());
+
+ m_grammarDetail.userDescription = userDescription;
+}
+
+PassRefPtr<ImmutableArray> WebGrammarDetail::guesses() const
+{
+ size_t numGuesses = m_grammarDetail.guesses.size();
+ Vector<RefPtr<APIObject> > wkGuesses(numGuesses);
+ for (unsigned i = 0; i < numGuesses; ++i)
+ wkGuesses[i] = WebString::create(m_grammarDetail.guesses[i]);
+ return ImmutableArray::adopt(wkGuesses);
+}
+
+WebGrammarDetail::WebGrammarDetail(const WebCore::GrammarDetail& grammarDetail)
+ : m_grammarDetail(grammarDetail)
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebGrammarDetail.h b/Source/WebKit2/UIProcess/WebGrammarDetail.h
new file mode 100644
index 000000000..ff79b5cce
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGrammarDetail.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.
+ */
+
+#ifndef WebGrammarDetail_h
+#define WebGrammarDetail_h
+
+#include "APIObject.h"
+#include <WebCore/TextCheckerClient.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class ImmutableArray;
+
+class WebGrammarDetail : public APIObject {
+public:
+ static const Type APIType = TypeGrammarDetail;
+ static PassRefPtr<WebGrammarDetail> create(int location, int length, ImmutableArray* guesses, const String& userDescription);
+ static PassRefPtr<WebGrammarDetail> create(const WebCore::GrammarDetail&);
+
+ int location() const { return m_grammarDetail.location; }
+ int length() const { return m_grammarDetail.length; }
+ PassRefPtr<ImmutableArray> guesses() const;
+ const String& userDescription() const { return m_grammarDetail.userDescription; }
+
+ const WebCore::GrammarDetail& grammarDetail() { return m_grammarDetail; }
+
+private:
+ WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription);
+ WebGrammarDetail(const WebCore::GrammarDetail&);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::GrammarDetail m_grammarDetail;
+};
+
+} // namespace WebKit
+
+#endif // WebGrammarDetail_h
diff --git a/Source/WebKit2/UIProcess/WebHistoryClient.cpp b/Source/WebKit2/UIProcess/WebHistoryClient.cpp
new file mode 100644
index 000000000..ca6cf9446
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebHistoryClient.cpp
@@ -0,0 +1,78 @@
+/*
+ * 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 "WebHistoryClient.h"
+
+#include "WKAPICast.h"
+#include "WebNavigationData.h"
+#include <wtf/RefPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebHistoryClient::didNavigateWithNavigationData(WebContext* context, WebPageProxy* page, const WebNavigationDataStore& navigationDataStore, WebFrameProxy* frame)
+{
+ if (!m_client.didNavigateWithNavigationData)
+ return;
+
+ RefPtr<WebNavigationData> navigationData = WebNavigationData::create(navigationDataStore);
+ m_client.didNavigateWithNavigationData(toAPI(context), toAPI(page), toAPI(navigationData.get()), toAPI(frame), m_client.clientInfo);
+}
+
+void WebHistoryClient::didPerformClientRedirect(WebContext* context, WebPageProxy* page, const String& sourceURL, const String& destinationURL, WebFrameProxy* frame)
+{
+ if (!m_client.didPerformClientRedirect)
+ return;
+
+ m_client.didPerformClientRedirect(toAPI(context), toAPI(page), toURLRef(sourceURL.impl()), toURLRef(destinationURL.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+void WebHistoryClient::didPerformServerRedirect(WebContext* context, WebPageProxy* page, const String& sourceURL, const String& destinationURL, WebFrameProxy* frame)
+{
+ if (!m_client.didPerformServerRedirect)
+ return;
+
+ m_client.didPerformServerRedirect(toAPI(context), toAPI(page), toURLRef(sourceURL.impl()), toURLRef(destinationURL.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+void WebHistoryClient::didUpdateHistoryTitle(WebContext* context, WebPageProxy* page, const String& title, const String& url, WebFrameProxy* frame)
+{
+ if (!m_client.didUpdateHistoryTitle)
+ return;
+
+ m_client.didUpdateHistoryTitle(toAPI(context), toAPI(page), toAPI(title.impl()), toURLRef(url.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+void WebHistoryClient::populateVisitedLinks(WebContext* context)
+{
+ if (!m_client.populateVisitedLinks)
+ return;
+
+ m_client.populateVisitedLinks(toAPI(context), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebHistoryClient.h b/Source/WebKit2/UIProcess/WebHistoryClient.h
new file mode 100644
index 000000000..daaea4f4e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebHistoryClient.h
@@ -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.
+ */
+
+#ifndef WebHistoryClient_h
+#define WebHistoryClient_h
+
+#include "APIClient.h"
+#include "WKContext.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebContext;
+class WebFrameProxy;
+class WebPageProxy;
+struct WebNavigationDataStore;
+
+class WebHistoryClient : public APIClient<WKContextHistoryClient, kWKContextHistoryClientCurrentVersion> {
+public:
+ void didNavigateWithNavigationData(WebContext*, WebPageProxy*, const WebNavigationDataStore&, WebFrameProxy*);
+ void didPerformClientRedirect(WebContext*, WebPageProxy*, const String& sourceURL, const String& destinationURL, WebFrameProxy*);
+ void didPerformServerRedirect(WebContext*, WebPageProxy*, const String& sourceURL, const String& destinationURL, WebFrameProxy*);
+ void didUpdateHistoryTitle(WebContext*, WebPageProxy*, const String& title, const String& url, WebFrameProxy*);
+ void populateVisitedLinks(WebContext*);
+
+ bool shouldTrackVisitedLinks() const { return m_client.populateVisitedLinks; }
+};
+
+} // namespace WebKit
+
+#endif // WebHistoryClient_h
diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.cpp b/Source/WebKit2/UIProcess/WebIconDatabase.cpp
new file mode 100644
index 000000000..8016cfbd6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebIconDatabase.cpp
@@ -0,0 +1,278 @@
+/*
+ * 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 "WebIconDatabase.h"
+
+#include "DataReference.h"
+#include "Logging.h"
+#include "WebContext.h"
+#include "WebIconDatabaseProxyMessages.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/IconDatabase.h>
+#include <WebCore/IconDatabaseBase.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebIconDatabase> WebIconDatabase::create(WebContext* context)
+{
+ return adoptRef(new WebIconDatabase(context));
+}
+
+WebIconDatabase::~WebIconDatabase()
+{
+}
+
+WebIconDatabase::WebIconDatabase(WebContext* context)
+ : m_webContext(context)
+ , m_urlImportCompleted(false)
+ , m_databaseCleanupDisabled(false)
+{
+}
+
+void WebIconDatabase::invalidate()
+{
+}
+
+void WebIconDatabase::setDatabasePath(const String& path)
+{
+ if (m_iconDatabaseImpl && m_iconDatabaseImpl->isOpen()) {
+ LOG_ERROR("Icon database already has a path and is already open. We don't currently support changing its path and reopening.");
+ return;
+ }
+
+ m_iconDatabaseImpl = IconDatabase::create();
+ m_iconDatabaseImpl->setClient(this);
+ IconDatabase::delayDatabaseCleanup();
+ m_databaseCleanupDisabled = true;
+ m_iconDatabaseImpl->setEnabled(true);
+ if (!m_iconDatabaseImpl->open(directoryName(path), pathGetFileName(path))) {
+ LOG_ERROR("Unable to open WebKit2 icon database on disk");
+ m_iconDatabaseImpl.clear();
+ setGlobalIconDatabase(0);
+ IconDatabase::allowDatabaseCleanup();
+ m_databaseCleanupDisabled = false;
+ }
+ setGlobalIconDatabase(m_iconDatabaseImpl.get());
+}
+
+void WebIconDatabase::enableDatabaseCleanup()
+{
+ if (!m_iconDatabaseImpl) {
+ LOG_ERROR("Cannot enabled Icon Database cleanup - it hasn't been opened yet.");
+ return;
+ }
+
+ if (!m_databaseCleanupDisabled) {
+ LOG_ERROR("Attempt to enable database cleanup, but it's already enabled.");
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ IconDatabase::allowDatabaseCleanup();
+ m_databaseCleanupDisabled = false;
+}
+
+void WebIconDatabase::retainIconForPageURL(const String& pageURL)
+{
+ if (m_iconDatabaseImpl)
+ m_iconDatabaseImpl->retainIconForPageURL(pageURL);
+}
+
+void WebIconDatabase::releaseIconForPageURL(const String& pageURL)
+{
+ if (m_iconDatabaseImpl)
+ m_iconDatabaseImpl->releaseIconForPageURL(pageURL);
+}
+
+void WebIconDatabase::setIconURLForPageURL(const String& iconURL, const String& pageURL)
+{
+ LOG(IconDatabase, "WK2 UIProcess setting icon URL %s for page URL %s", iconURL.ascii().data(), pageURL.ascii().data());
+ if (m_iconDatabaseImpl)
+ m_iconDatabaseImpl->setIconURLForPageURL(iconURL, pageURL);
+}
+
+void WebIconDatabase::setIconDataForIconURL(const CoreIPC::DataReference& iconData, const String& iconURL)
+{
+ LOG(IconDatabase, "WK2 UIProcess setting icon data (%i bytes) for page URL %s", (int)iconData.size(), iconURL.ascii().data());
+ if (!m_iconDatabaseImpl)
+ return;
+
+ RefPtr<SharedBuffer> buffer = SharedBuffer::create(iconData.data(), iconData.size());
+ m_iconDatabaseImpl->setIconDataForIconURL(buffer.release(), iconURL);
+}
+
+void WebIconDatabase::synchronousIconDataForPageURL(const String&, CoreIPC::DataReference& iconData)
+{
+ iconData = CoreIPC::DataReference();
+}
+
+void WebIconDatabase::synchronousIconURLForPageURL(const String& pageURL, String& iconURL)
+{
+ if (!m_iconDatabaseImpl) {
+ iconURL = String();
+ return;
+ }
+
+ iconURL = m_iconDatabaseImpl->synchronousIconURLForPageURL(pageURL);
+}
+
+void WebIconDatabase::synchronousIconDataKnownForIconURL(const String&, bool& iconDataKnown) const
+{
+ iconDataKnown = false;
+}
+
+void WebIconDatabase::synchronousLoadDecisionForIconURL(const String&, int& loadDecision) const
+{
+ loadDecision = static_cast<int>(IconLoadNo);
+}
+
+void WebIconDatabase::getLoadDecisionForIconURL(const String& iconURL, uint64_t callbackID)
+{
+ LOG(IconDatabase, "WK2 UIProcess getting load decision for icon URL %s with callback ID %lli", iconURL.ascii().data(), static_cast<long long>(callbackID));
+
+ if (!m_webContext)
+ return;
+
+ if (!m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || iconURL.isEmpty()) {
+ // FIXME (Multi-WebProcess): We need to know which connection to send this message to.
+ m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(IconLoadNo), callbackID));
+ return;
+ }
+
+ // If the decision hasn't been read from disk yet, set this url and callback ID aside to be notifed later
+ IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(iconURL, 0);
+ if (decision == IconLoadUnknown) {
+ // We should never get an unknown load decision after the URL import has completed.
+ ASSERT(!m_urlImportCompleted);
+
+ m_pendingLoadDecisionURLMap.set(callbackID, iconURL);
+ return;
+ }
+
+ // FIXME (Multi-WebProcess): We need to know which connection to send this message to.
+ m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision((int)decision, callbackID));
+}
+
+Image* WebIconDatabase::imageForPageURL(const String& pageURL, const WebCore::IntSize& iconSize)
+{
+ if (!m_webContext || !m_iconDatabaseImpl || !m_iconDatabaseImpl->isOpen() || pageURL.isEmpty())
+ return 0;
+
+ // The WebCore IconDatabase ignores the passed in size parameter.
+ // If that changes we'll need to rethink how this API is exposed.
+ return m_iconDatabaseImpl->synchronousIconForPageURL(pageURL, iconSize);
+}
+
+void WebIconDatabase::removeAllIcons()
+{
+ m_iconDatabaseImpl->removeAllIcons();
+}
+
+void WebIconDatabase::checkIntegrityBeforeOpening()
+{
+ IconDatabase::checkIntegrityBeforeOpening();
+}
+
+void WebIconDatabase::close()
+{
+ m_iconDatabaseImpl->close();
+}
+
+void WebIconDatabase::initializeIconDatabaseClient(const WKIconDatabaseClient* client)
+{
+ m_iconDatabaseClient.initialize(client);
+}
+
+// WebCore::IconDatabaseClient
+bool WebIconDatabase::performImport()
+{
+ // WebKit2 icon database doesn't currently support importing any old icon database formats.
+ return true;
+}
+
+void WebIconDatabase::didImportIconURLForPageURL(const String& pageURL)
+{
+ didChangeIconForPageURL(pageURL);
+}
+
+void WebIconDatabase::didImportIconDataForPageURL(const String& pageURL)
+{
+ didChangeIconForPageURL(pageURL);
+}
+
+void WebIconDatabase::didChangeIconForPageURL(const String& pageURL)
+{
+ m_iconDatabaseClient.didChangeIconForPageURL(this, WebURL::create(pageURL).get());
+}
+
+void WebIconDatabase::didRemoveAllIcons()
+{
+ m_iconDatabaseClient.didRemoveAllIcons(this);
+}
+
+void WebIconDatabase::didFinishURLImport()
+{
+ if (!m_webContext)
+ return;
+
+ ASSERT(!m_urlImportCompleted);
+
+ LOG(IconDatabase, "WK2 UIProcess URL import complete, notifying all %i pending page URL load decisions", m_pendingLoadDecisionURLMap.size());
+
+ HashMap<uint64_t, String>::iterator i = m_pendingLoadDecisionURLMap.begin();
+ HashMap<uint64_t, String>::iterator end = m_pendingLoadDecisionURLMap.end();
+
+ for (; i != end; ++i) {
+ LOG(IconDatabase, "WK2 UIProcess performing delayed callback on callback ID %i for page url %s", (int)i->first, i->second.ascii().data());
+ IconLoadDecision decision = m_iconDatabaseImpl->synchronousLoadDecisionForIconURL(i->second, 0);
+
+ // Decisions should never be unknown after the inital import is complete
+ ASSERT(decision != IconLoadUnknown);
+
+ // FIXME (Multi-WebProcess): We need to know which connection to send this message to.
+ m_webContext->sendToAllProcesses(Messages::WebIconDatabaseProxy::ReceivedIconLoadDecision(static_cast<int>(decision), i->first));
+ }
+
+ m_pendingLoadDecisionURLMap.clear();
+
+ m_urlImportCompleted = true;
+}
+
+void WebIconDatabase::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* decoder)
+{
+ didReceiveWebIconDatabaseMessage(connection, messageID, decoder);
+}
+
+void WebIconDatabase::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* decoder, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ didReceiveSyncWebIconDatabaseMessage(connection, messageID, decoder, reply);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.h b/Source/WebKit2/UIProcess/WebIconDatabase.h
new file mode 100644
index 000000000..b74c21086
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebIconDatabase.h
@@ -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.
+ */
+
+#ifndef WebIconDatabase_h
+#define WebIconDatabase_h
+
+#include "APIObject.h"
+
+#include "Connection.h"
+#include "WebIconDatabaseClient.h"
+#include <WebCore/IconDatabaseClient.h>
+#include <WebCore/IntSize.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/StringHash.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class DataReference;
+class MessageID;
+}
+
+namespace WebCore {
+class IconDatabase;
+class Image;
+}
+
+namespace WebKit {
+
+class WebContext;
+
+class WebIconDatabase : public APIObject, public WebCore::IconDatabaseClient {
+public:
+ static const Type APIType = TypeIconDatabase;
+
+ static PassRefPtr<WebIconDatabase> create(WebContext*);
+ virtual ~WebIconDatabase();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+ void setDatabasePath(const String&);
+ void enableDatabaseCleanup();
+
+ void retainIconForPageURL(const String&);
+ void releaseIconForPageURL(const String&);
+ void setIconURLForPageURL(const String&, const String&);
+ void setIconDataForIconURL(const CoreIPC::DataReference&, const String&);
+
+ void synchronousIconDataForPageURL(const String&, CoreIPC::DataReference&);
+ void synchronousIconURLForPageURL(const String&, String&);
+ void synchronousIconDataKnownForIconURL(const String&, bool&) const;
+ void synchronousLoadDecisionForIconURL(const String&, int&) const;
+
+ void getLoadDecisionForIconURL(const String&, uint64_t callbackID);
+
+ WebCore::Image* imageForPageURL(const String&, const WebCore::IntSize& iconSize = WebCore::IntSize(32, 32));
+
+ void removeAllIcons();
+ void checkIntegrityBeforeOpening();
+ void close();
+
+ void initializeIconDatabaseClient(const WKIconDatabaseClient*);
+
+ // WebCore::IconDatabaseClient
+ virtual bool performImport();
+ virtual void didImportIconURLForPageURL(const String&);
+ virtual void didImportIconDataForPageURL(const String&);
+ virtual void didChangeIconForPageURL(const String&);
+ virtual void didRemoveAllIcons();
+ virtual void didFinishURLImport();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+private:
+ WebIconDatabase(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didReceiveWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebIconDatabaseMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ WebContext* m_webContext;
+
+ OwnPtr<WebCore::IconDatabase> m_iconDatabaseImpl;
+ bool m_urlImportCompleted;
+ bool m_databaseCleanupDisabled;
+ HashMap<uint64_t, String> m_pendingLoadDecisionURLMap;
+
+ WebIconDatabaseClient m_iconDatabaseClient;
+};
+
+} // namespace WebKit
+
+#endif // WebIconDatabase_h
diff --git a/Source/WebKit2/UIProcess/WebIconDatabase.messages.in b/Source/WebKit2/UIProcess/WebIconDatabase.messages.in
new file mode 100644
index 000000000..b68a0a742
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebIconDatabase.messages.in
@@ -0,0 +1,35 @@
+# 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.
+
+messages -> WebIconDatabase {
+ RetainIconForPageURL(WTF::String pageURL)
+ ReleaseIconForPageURL(WTF::String pageURL)
+ SetIconURLForPageURL(WTF::String iconURL, WTF::String pageURL)
+ SetIconDataForIconURL(CoreIPC::DataReference iconData, WTF::String iconURL)
+
+ SynchronousIconDataForPageURL(WTF::String pageURL) -> (CoreIPC::DataReference iconData)
+ SynchronousIconURLForPageURL(WTF::String pageURL) -> (WTF::String iconURL)
+ SynchronousIconDataKnownForIconURL(WTF::String iconURL) -> (bool dataKnown)
+ SynchronousLoadDecisionForIconURL(WTF::String iconURL) -> (int loadDecision)
+
+ GetLoadDecisionForIconURL(WTF::String iconURL, uint64_t callbackID)
+}
diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp
new file mode 100644
index 000000000..e0de3664e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebIconDatabaseClient.h"
+
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+
+namespace WebKit {
+
+void WebIconDatabaseClient::didChangeIconForPageURL(WebIconDatabase* iconDatabase, WebURL* url)
+{
+ if (!m_client.didChangeIconForPageURL)
+ return;
+
+ m_client.didChangeIconForPageURL(toAPI(iconDatabase), toAPI(url), m_client.clientInfo);
+}
+
+void WebIconDatabaseClient::didRemoveAllIcons(WebIconDatabase* iconDatabase)
+{
+ if (!m_client.didRemoveAllIcons)
+ return;
+
+ m_client.didRemoveAllIcons(toAPI(iconDatabase), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebIconDatabaseClient.h b/Source/WebKit2/UIProcess/WebIconDatabaseClient.h
new file mode 100644
index 000000000..801ec12a8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebIconDatabaseClient.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 WebIconDatabaseClient_h
+#define WebIconDatabaseClient_h
+
+#include "APIClient.h"
+#include "WKIconDatabase.h"
+
+namespace WebKit {
+
+class APIObject;
+class WebIconDatabase;
+class WebURL;
+
+class WebIconDatabaseClient : public APIClient<WKIconDatabaseClient, kWKIconDatabaseClientCurrentVersion> {
+public:
+ void didChangeIconForPageURL(WebIconDatabase*, WebURL*);
+ void didRemoveAllIcons(WebIconDatabase*);
+};
+
+} // namespace WebKit
+
+#endif // WebIconDatabaseClient_h
diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
new file mode 100644
index 000000000..a7057e083
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
@@ -0,0 +1,272 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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.
+ */
+
+#include "config.h"
+#include "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebInspectorMessages.h"
+#include "WebPageCreationParameters.h"
+#include "WebPageGroup.h"
+#include "WebPageProxy.h"
+#include "WebPreferences.h"
+#include "WebProcessProxy.h"
+
+#if PLATFORM(WIN)
+#include "WebView.h"
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static PassRefPtr<WebPageGroup> createInspectorPageGroup()
+{
+ RefPtr<WebPageGroup> pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false, false);
+
+#ifndef NDEBUG
+ // Allow developers to inspect the Web Inspector in debug builds.
+ pageGroup->preferences()->setDeveloperExtrasEnabled(true);
+#endif
+
+ pageGroup->preferences()->setApplicationChromeModeEnabled(true);
+ pageGroup->preferences()->setSuppressIncrementalRendering(true);
+
+ return pageGroup.release();
+}
+
+WebPageGroup* WebInspectorProxy::inspectorPageGroup()
+{
+ static WebPageGroup* pageGroup = createInspectorPageGroup().leakRef();
+ return pageGroup;
+}
+
+WebInspectorProxy::WebInspectorProxy(WebPageProxy* page)
+ : m_page(page)
+ , m_isVisible(false)
+ , m_isAttached(false)
+ , m_isDebuggingJavaScript(false)
+ , m_isProfilingJavaScript(false)
+ , m_isProfilingPage(false)
+#if PLATFORM(WIN)
+ , m_inspectorWindow(0)
+#elif PLATFORM(GTK)
+ , m_inspectorView(0)
+ , m_inspectorWindow(0)
+#endif
+{
+}
+
+WebInspectorProxy::~WebInspectorProxy()
+{
+}
+
+void WebInspectorProxy::invalidate()
+{
+ m_page->close();
+ didClose();
+
+ m_page = 0;
+
+ m_isVisible = false;
+ m_isDebuggingJavaScript = false;
+ m_isProfilingJavaScript = false;
+ m_isProfilingPage = false;
+}
+
+// Public APIs
+void WebInspectorProxy::show()
+{
+ if (!m_page)
+ return;
+
+ m_page->process()->send(Messages::WebInspector::Show(), m_page->pageID());
+}
+
+void WebInspectorProxy::close()
+{
+ if (!m_page)
+ return;
+
+ m_page->process()->send(Messages::WebInspector::Close(), m_page->pageID());
+}
+
+void WebInspectorProxy::showConsole()
+{
+ if (!m_page)
+ return;
+
+ m_page->process()->send(Messages::WebInspector::ShowConsole(), m_page->pageID());
+}
+
+void WebInspectorProxy::attach()
+{
+ if (!canAttach())
+ return;
+
+ m_isAttached = true;
+
+ if (m_isVisible)
+ inspectorPageGroup()->preferences()->setInspectorStartsAttached(true);
+
+ platformAttach();
+}
+
+void WebInspectorProxy::detach()
+{
+ m_isAttached = false;
+
+ if (m_isVisible)
+ inspectorPageGroup()->preferences()->setInspectorStartsAttached(false);
+
+ platformDetach();
+}
+
+void WebInspectorProxy::setAttachedWindowHeight(unsigned height)
+{
+ platformSetAttachedWindowHeight(height);
+}
+
+void WebInspectorProxy::toggleJavaScriptDebugging()
+{
+ if (!m_page)
+ return;
+
+ if (m_isDebuggingJavaScript)
+ m_page->process()->send(Messages::WebInspector::StopJavaScriptDebugging(), m_page->pageID());
+ else
+ m_page->process()->send(Messages::WebInspector::StartJavaScriptDebugging(), m_page->pageID());
+
+ // FIXME: have the WebProcess notify us on state changes.
+ m_isDebuggingJavaScript = !m_isDebuggingJavaScript;
+}
+
+void WebInspectorProxy::toggleJavaScriptProfiling()
+{
+ if (!m_page)
+ return;
+
+ if (m_isProfilingJavaScript)
+ m_page->process()->send(Messages::WebInspector::StopJavaScriptProfiling(), m_page->pageID());
+ else
+ m_page->process()->send(Messages::WebInspector::StartJavaScriptProfiling(), m_page->pageID());
+
+ // FIXME: have the WebProcess notify us on state changes.
+ m_isProfilingJavaScript = !m_isProfilingJavaScript;
+}
+
+void WebInspectorProxy::togglePageProfiling()
+{
+ if (!m_page)
+ return;
+
+ if (m_isProfilingPage)
+ m_page->process()->send(Messages::WebInspector::StopPageProfiling(), m_page->pageID());
+ else
+ m_page->process()->send(Messages::WebInspector::StartPageProfiling(), m_page->pageID());
+
+ // FIXME: have the WebProcess notify us on state changes.
+ m_isProfilingPage = !m_isProfilingPage;
+}
+
+bool WebInspectorProxy::isInspectorPage(WebPageProxy* page)
+{
+ return page->pageGroup() == inspectorPageGroup();
+}
+
+// Called by WebInspectorProxy messages
+void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters& inspectorPageParameters)
+{
+ inspectorPageID = 0;
+
+ if (!m_page)
+ return;
+
+ WebPageProxy* inspectorPage = platformCreateInspectorPage();
+ ASSERT(inspectorPage);
+ if (!inspectorPage)
+ return;
+
+ inspectorPageID = inspectorPage->pageID();
+ inspectorPageParameters = inspectorPage->creationParameters();
+
+ String url = inspectorPageURL();
+ if (shouldOpenAttached())
+ url += "?docked=true";
+ m_page->process()->assumeReadAccessToBaseURL(inspectorBaseURL());
+ inspectorPage->loadURL(url);
+}
+
+void WebInspectorProxy::didLoadInspectorPage()
+{
+ m_isVisible = true;
+ m_isAttached = shouldOpenAttached();
+
+ // platformOpen is responsible for rendering attached mode depending on m_isAttached.
+ platformOpen();
+}
+
+void WebInspectorProxy::didClose()
+{
+ m_isVisible = false;
+ m_isDebuggingJavaScript = false;
+ m_isProfilingJavaScript = false;
+ m_isProfilingPage = false;
+
+ if (m_isAttached) {
+ // Detach here so we only need to have one code path that is responsible for cleaning up the inspector
+ // state.
+ detach();
+ }
+
+ platformDidClose();
+}
+
+void WebInspectorProxy::bringToFront()
+{
+ platformBringToFront();
+}
+
+void WebInspectorProxy::inspectedURLChanged(const String& urlString)
+{
+ platformInspectedURLChanged(urlString);
+}
+
+bool WebInspectorProxy::canAttach()
+{
+ unsigned inspectedWindowHeight = platformInspectedWindowHeight();
+ return inspectedWindowHeight && minimumAttachedHeight <= (inspectedWindowHeight * 3 / 4);
+}
+
+bool WebInspectorProxy::shouldOpenAttached()
+{
+ return inspectorPageGroup()->preferences()->inspectorStartsAttached() && canAttach();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.h b/Source/WebKit2/UIProcess/WebInspectorProxy.h
new file mode 100644
index 000000000..a70ac700c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.h
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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 WebInspectorProxy_h
+#define WebInspectorProxy_h
+
+#if ENABLE(INSPECTOR)
+
+#include "APIObject.h"
+#include "Connection.h"
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS NSWindow;
+OBJC_CLASS WKWebInspectorProxyObjCAdapter;
+OBJC_CLASS WKWebInspectorWKView;
+#endif
+
+#if PLATFORM(WIN)
+#include <WebCore/WindowMessageListener.h>
+#endif
+
+namespace WebKit {
+
+class WebPageGroup;
+class WebPageProxy;
+struct WebPageCreationParameters;
+
+#if PLATFORM(WIN)
+class WebView;
+#endif
+
+class WebInspectorProxy : public APIObject
+#if PLATFORM(WIN)
+ , public WebCore::WindowMessageListener
+#endif
+{
+public:
+ static const Type APIType = TypeInspector;
+
+ static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)
+ {
+ return adoptRef(new WebInspectorProxy(page));
+ }
+
+ ~WebInspectorProxy();
+
+ void invalidate();
+
+ // Public APIs
+ WebPageProxy* page() const { return m_page; }
+
+ bool isVisible() const { return m_isVisible; }
+ void show();
+ void close();
+
+#if PLATFORM(MAC)
+ void inspectedViewFrameDidChange();
+#elif PLATFORM(GTK)
+ void windowDestroyed();
+#endif
+
+ void showConsole();
+
+ bool isAttached() const { return m_isAttached; }
+ void attach();
+ void detach();
+ void setAttachedWindowHeight(unsigned);
+
+ bool isDebuggingJavaScript() const { return m_isDebuggingJavaScript; }
+ void toggleJavaScriptDebugging();
+
+ bool isProfilingJavaScript() const { return m_isProfilingJavaScript; }
+ void toggleJavaScriptProfiling();
+
+ bool isProfilingPage() const { return m_isProfilingPage; }
+ void togglePageProfiling();
+
+#if ENABLE(INSPECTOR)
+ // Implemented in generated WebInspectorProxyMessageReceiver.cpp
+ void didReceiveWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+#endif
+
+ static bool isInspectorPage(WebPageProxy*);
+
+private:
+ WebInspectorProxy(WebPageProxy* page);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageProxy* platformCreateInspectorPage();
+ void platformOpen();
+ void platformDidClose();
+ void platformBringToFront();
+ void platformInspectedURLChanged(const String&);
+ unsigned platformInspectedWindowHeight();
+ void platformAttach();
+ void platformDetach();
+ void platformSetAttachedWindowHeight(unsigned);
+
+ // Implemented the platform WebInspectorProxy file
+ String inspectorPageURL() const;
+ String inspectorBaseURL() const;
+
+ // Called by WebInspectorProxy messages
+ void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
+ void didLoadInspectorPage();
+ void didClose();
+ void bringToFront();
+ void inspectedURLChanged(const String&);
+
+ bool canAttach();
+ bool shouldOpenAttached();
+
+ static WebPageGroup* inspectorPageGroup();
+
+#if PLATFORM(WIN)
+ static bool registerInspectorViewWindowClass();
+ static LRESULT CALLBACK InspectorViewWndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+ LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onMinMaxInfoEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onSetFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onCloseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+
+ void onWebViewWindowPosChangingEvent(WPARAM, LPARAM);
+ virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
+#endif
+
+ static const unsigned minimumWindowWidth = 500;
+ static const unsigned minimumWindowHeight = 400;
+
+ static const unsigned initialWindowWidth = 750;
+ static const unsigned initialWindowHeight = 650;
+ static const unsigned minimumAttachedHeight = 250;
+
+ WebPageProxy* m_page;
+
+ bool m_isVisible;
+ bool m_isAttached;
+ bool m_isDebuggingJavaScript;
+ bool m_isProfilingJavaScript;
+ bool m_isProfilingPage;
+
+#if PLATFORM(MAC)
+ RetainPtr<WKWebInspectorWKView> m_inspectorView;
+ RetainPtr<NSWindow> m_inspectorWindow;
+ RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
+#elif PLATFORM(WIN)
+ HWND m_inspectorWindow;
+ RefPtr<WebView> m_inspectorView;
+#elif PLATFORM(GTK)
+ GtkWidget* m_inspectorView;
+ GtkWidget* m_inspectorWindow;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
+
+#endif // WebInspectorProxy_h
diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in b/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
new file mode 100644
index 000000000..a1949858e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
@@ -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.
+
+#if ENABLE(INSPECTOR)
+
+messages -> WebInspectorProxy {
+ CreateInspectorPage() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
+ DidLoadInspectorPage()
+ DidClose()
+ BringToFront()
+ InspectedURLChanged(WTF::String urlString)
+
+ Attach()
+ Detach()
+ SetAttachedWindowHeight(unsigned height)
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp
new file mode 100644
index 000000000..93b6fb914
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.cpp
@@ -0,0 +1,98 @@
+/*
+ * 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 "WebKeyValueStorageManagerProxy.h"
+
+#include "SecurityOriginData.h"
+#include "WebKeyValueStorageManagerMessages.h"
+#include "WebContext.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+PassRefPtr<WebKeyValueStorageManagerProxy> WebKeyValueStorageManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebKeyValueStorageManagerProxy(context));
+}
+
+WebKeyValueStorageManagerProxy::WebKeyValueStorageManagerProxy(WebContext* context)
+ : m_webContext(context)
+{
+}
+
+WebKeyValueStorageManagerProxy::~WebKeyValueStorageManagerProxy()
+{
+}
+
+void WebKeyValueStorageManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+}
+
+bool WebKeyValueStorageManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty();
+}
+
+void WebKeyValueStorageManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebKeyValueStorageManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebKeyValueStorageManagerProxy::getKeyValueStorageOrigins(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process?
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::GetKeyValueStorageOrigins(callbackID));
+}
+
+void WebKeyValueStorageManagerProxy::didGetKeyValueStorageOrigins(const Vector<SecurityOriginData>& originDatas, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ performAPICallbackWithSecurityOriginDataVector(originDatas, callback.get());
+}
+
+void WebKeyValueStorageManagerProxy::deleteEntriesForOrigin(WebSecurityOrigin* origin)
+{
+ SecurityOriginData securityOriginData;
+ securityOriginData.protocol = origin->protocol();
+ securityOriginData.host = origin->host();
+ securityOriginData.port = origin->port();
+
+ // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process?
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteEntriesForOrigin(securityOriginData));
+}
+
+void WebKeyValueStorageManagerProxy::deleteAllEntries()
+{
+ // FIXME (Multi-WebProcess): Should key-value storage be handled in the web process?
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebKeyValueStorageManager::DeleteAllEntries());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h
new file mode 100644
index 000000000..79cb03ee9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.h
@@ -0,0 +1,85 @@
+/*
+ * 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 WebKeyValueStorageManagerProxy_h
+#define WebKeyValueStorageManagerProxy_h
+
+#include "APIObject.h"
+#include "GenericCallback.h"
+#include "ImmutableArray.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+struct SecurityOriginData;
+class WebContext;
+class WebProcessProxy;
+class WebSecurityOrigin;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebKeyValueStorageManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeKeyValueStorageManager;
+
+ static PassRefPtr<WebKeyValueStorageManagerProxy> create(WebContext*);
+ virtual ~WebKeyValueStorageManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void getKeyValueStorageOrigins(PassRefPtr<ArrayCallback>);
+ void deleteEntriesForOrigin(WebSecurityOrigin*);
+ void deleteAllEntries();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ WebKeyValueStorageManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didGetKeyValueStorageOrigins(const Vector<SecurityOriginData>&, uint64_t callbackID);
+
+ void didReceiveWebKeyValueStorageManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+};
+
+} // namespace WebKit
+
+#endif // WebKeyValueStorageManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.messages.in
new file mode 100644
index 000000000..b76389a70
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebKeyValueStorageManagerProxy.messages.in
@@ -0,0 +1,25 @@
+# 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.
+
+messages -> WebKeyValueStorageManagerProxy {
+ DidGetKeyValueStorageOrigins(Vector<WebKit::SecurityOriginData> originIdentifiers, uint64_t callbackID);
+}
diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.cpp b/Source/WebKit2/UIProcess/WebLoaderClient.cpp
new file mode 100644
index 000000000..624169e4e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebLoaderClient.cpp
@@ -0,0 +1,250 @@
+/*
+ * 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 "WebLoaderClient.h"
+
+#include "ImmutableArray.h"
+#include "WebBackForwardListItem.h"
+#include "WKAPICast.h"
+#include <string.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebLoaderClient::didStartProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didStartProvisionalLoadForFrame)
+ return;
+
+ m_client.didStartProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didReceiveServerRedirectForProvisionalLoadForFrame)
+ return;
+
+ m_client.didReceiveServerRedirectForProvisionalLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
+{
+ if (!m_client.didFailProvisionalLoadWithErrorForFrame)
+ return;
+
+ m_client.didFailProvisionalLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didCommitLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didCommitLoadForFrame)
+ return;
+
+ m_client.didCommitLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFinishDocumentLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didFinishDocumentLoadForFrame)
+ return;
+
+ m_client.didFinishDocumentLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFinishLoadForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didFinishLoadForFrame)
+ return;
+
+ m_client.didFinishLoadForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFailLoadWithErrorForFrame(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
+{
+ if (!m_client.didFailLoadWithErrorForFrame)
+ return;
+
+ m_client.didFailLoadWithErrorForFrame(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didSameDocumentNavigationForFrame(WebPageProxy* page, WebFrameProxy* frame, SameDocumentNavigationType type, APIObject* userData)
+{
+ if (!m_client.didSameDocumentNavigationForFrame)
+ return;
+
+ m_client.didSameDocumentNavigationForFrame(toAPI(page), toAPI(frame), toAPI(type), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didReceiveTitleForFrame(WebPageProxy* page, const String& title, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didReceiveTitleForFrame)
+ return;
+
+ m_client.didReceiveTitleForFrame(toAPI(page), toAPI(title.impl()), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFirstLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didFirstLayoutForFrame)
+ return;
+
+ m_client.didFirstLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didFirstVisuallyNonEmptyLayoutForFrame)
+ return;
+
+ m_client.didFirstVisuallyNonEmptyLayoutForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didRemoveFrameFromHierarchy(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didRemoveFrameFromHierarchy)
+ return;
+
+ m_client.didRemoveFrameFromHierarchy(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didDisplayInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didDisplayInsecureContentForFrame)
+ return;
+
+ m_client.didDisplayInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didRunInsecureContentForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didRunInsecureContentForFrame)
+ return;
+
+ m_client.didRunInsecureContentForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+void WebLoaderClient::didDetectXSSForFrame(WebPageProxy* page, WebFrameProxy* frame, APIObject* userData)
+{
+ if (!m_client.didDetectXSSForFrame)
+ return;
+
+ m_client.didDetectXSSForFrame(toAPI(page), toAPI(frame), toAPI(userData), m_client.clientInfo);
+}
+
+bool WebLoaderClient::canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy* page, WebFrameProxy* frame, WebProtectionSpace* protectionSpace)
+{
+ if (!m_client.canAuthenticateAgainstProtectionSpaceInFrame)
+ return false;
+
+ return m_client.canAuthenticateAgainstProtectionSpaceInFrame(toAPI(page), toAPI(frame), toAPI(protectionSpace), m_client.clientInfo);
+}
+
+void WebLoaderClient::didReceiveAuthenticationChallengeInFrame(WebPageProxy* page, WebFrameProxy* frame, AuthenticationChallengeProxy* authenticationChallenge)
+{
+ if (!m_client.didReceiveAuthenticationChallengeInFrame)
+ return;
+
+ m_client.didReceiveAuthenticationChallengeInFrame(toAPI(page), toAPI(frame), toAPI(authenticationChallenge), m_client.clientInfo);
+}
+
+void WebLoaderClient::didStartProgress(WebPageProxy* page)
+{
+ if (!m_client.didStartProgress)
+ return;
+
+ m_client.didStartProgress(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::didChangeProgress(WebPageProxy* page)
+{
+ if (!m_client.didChangeProgress)
+ return;
+
+ m_client.didChangeProgress(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFinishProgress(WebPageProxy* page)
+{
+ if (!m_client.didFinishProgress)
+ return;
+
+ m_client.didFinishProgress(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::processDidBecomeUnresponsive(WebPageProxy* page)
+{
+ if (!m_client.processDidBecomeUnresponsive)
+ return;
+
+ m_client.processDidBecomeUnresponsive(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::processDidBecomeResponsive(WebPageProxy* page)
+{
+ if (!m_client.processDidBecomeResponsive)
+ return;
+
+ m_client.processDidBecomeResponsive(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::processDidCrash(WebPageProxy* page)
+{
+ if (!m_client.processDidCrash)
+ return;
+
+ m_client.processDidCrash(toAPI(page), m_client.clientInfo);
+}
+
+void WebLoaderClient::didChangeBackForwardList(WebPageProxy* page, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems)
+{
+ if (!m_client.didChangeBackForwardList)
+ return;
+
+ RefPtr<ImmutableArray> removedItemsArray;
+ if (removedItems && !removedItems->isEmpty())
+ removedItemsArray = ImmutableArray::adopt(*removedItems);
+
+ m_client.didChangeBackForwardList(toAPI(page), toAPI(addedItem), toAPI(removedItemsArray.get()), m_client.clientInfo);
+}
+
+bool WebLoaderClient::shouldGoToBackForwardListItem(WebPageProxy* page, WebBackForwardListItem* item)
+{
+ if (!m_client.shouldGoToBackForwardListItem)
+ return true;
+
+ return m_client.shouldGoToBackForwardListItem(toAPI(page), toAPI(item), m_client.clientInfo);
+}
+
+void WebLoaderClient::didFailToInitializePlugin(WebPageProxy* page, const String& mimeType)
+{
+ if (!m_client.didFailToInitializePlugin)
+ return;
+
+ m_client.didFailToInitializePlugin(toAPI(page), toAPI(mimeType.impl()), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.h b/Source/WebKit2/UIProcess/WebLoaderClient.h
new file mode 100644
index 000000000..9fe8fce2f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebLoaderClient.h
@@ -0,0 +1,88 @@
+/*
+ * 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 WebLoaderClient_h
+#define WebLoaderClient_h
+
+#include "APIClient.h"
+#include "SameDocumentNavigationType.h"
+#include "WKPage.h"
+#include <wtf/Forward.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+class ResourceError;
+}
+
+namespace WebKit {
+
+class APIObject;
+class AuthenticationChallengeProxy;
+class AuthenticationDecisionListener;
+class WebBackForwardListItem;
+class WebFrameProxy;
+class WebPageProxy;
+class WebProtectionSpace;
+
+class WebLoaderClient : public APIClient<WKPageLoaderClient, kWKPageLoaderClientCurrentVersion> {
+public:
+ void didStartProvisionalLoadForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didReceiveServerRedirectForProvisionalLoadForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didFailProvisionalLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceError&, APIObject*);
+ void didCommitLoadForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didFinishDocumentLoadForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didFinishLoadForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didFailLoadWithErrorForFrame(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceError&, APIObject*);
+ void didSameDocumentNavigationForFrame(WebPageProxy*, WebFrameProxy*, SameDocumentNavigationType, APIObject*);
+ void didReceiveTitleForFrame(WebPageProxy*, const String&, WebFrameProxy*, APIObject*);
+ void didFirstLayoutForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didFirstVisuallyNonEmptyLayoutForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didRemoveFrameFromHierarchy(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didDisplayInsecureContentForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didRunInsecureContentForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+ void didDetectXSSForFrame(WebPageProxy*, WebFrameProxy*, APIObject*);
+
+ bool canAuthenticateAgainstProtectionSpaceInFrame(WebPageProxy*, WebFrameProxy*, WebProtectionSpace*);
+ void didReceiveAuthenticationChallengeInFrame(WebPageProxy*, WebFrameProxy*, AuthenticationChallengeProxy*);
+
+ void didStartProgress(WebPageProxy*);
+ void didChangeProgress(WebPageProxy*);
+ void didFinishProgress(WebPageProxy*);
+
+ // FIXME: These three functions should not be part of this client.
+ void processDidBecomeUnresponsive(WebPageProxy*);
+ void processDidBecomeResponsive(WebPageProxy*);
+ void processDidCrash(WebPageProxy*);
+
+ void didChangeBackForwardList(WebPageProxy*, WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems);
+ bool shouldGoToBackForwardListItem(WebPageProxy*, WebBackForwardListItem*);
+
+ void didFailToInitializePlugin(WebPageProxy*, const String& mimeType);
+};
+
+} // namespace WebKit
+
+#endif // WebLoaderClient_h
diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp
new file mode 100644
index 000000000..3b034d86e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.cpp
@@ -0,0 +1,102 @@
+/*
+ * 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 "WebMediaCacheManagerProxy.h"
+
+#include "WebContext.h"
+#include "WebMediaCacheManagerMessages.h"
+#include "WebSecurityOrigin.h"
+
+namespace WebKit {
+
+PassRefPtr<WebMediaCacheManagerProxy> WebMediaCacheManagerProxy::create(WebContext* context)
+{
+ return adoptRef(new WebMediaCacheManagerProxy(context));
+}
+
+WebMediaCacheManagerProxy::WebMediaCacheManagerProxy(WebContext* context)
+ : m_webContext(context)
+{
+}
+
+WebMediaCacheManagerProxy::~WebMediaCacheManagerProxy()
+{
+}
+
+void WebMediaCacheManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+}
+
+bool WebMediaCacheManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty();
+}
+
+void WebMediaCacheManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ didReceiveWebMediaCacheManagerProxyMessage(connection, messageID, arguments);
+}
+
+void WebMediaCacheManagerProxy::getHostnamesWithMediaCache(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): When we're sending this to multiple processes, we need to aggregate the
+ // callback data when it comes back.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::GetHostnamesWithMediaCache(callbackID));
+}
+
+void WebMediaCacheManagerProxy::didGetHostnamesWithMediaCache(const Vector<String>& hostnameList, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ size_t hostnameCount = hostnameList.size();
+ Vector<RefPtr<APIObject> > hostnames(hostnameCount);
+
+ for (size_t i = 0; i < hostnameCount; ++i)
+ hostnames[i] = WebString::create(hostnameList[i]);
+
+ callback->performCallbackWithReturnValue(ImmutableArray::adopt(hostnames).get());
+}
+
+void WebMediaCacheManagerProxy::clearCacheForHostname(const String& hostname)
+{
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::ClearCacheForHostname(hostname));
+}
+
+void WebMediaCacheManagerProxy::clearCacheForAllHostnames()
+{
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebMediaCacheManager::ClearCacheForAllHostnames());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h
new file mode 100644
index 000000000..43231e5e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.h
@@ -0,0 +1,83 @@
+/*
+ * 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 WebMediaCacheManagerProxy_h
+#define WebMediaCacheManagerProxy_h
+
+#include "APIObject.h"
+#include "GenericCallback.h"
+#include "ImmutableArray.h"
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebProcessProxy;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebMediaCacheManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeMediaCacheManager;
+
+ static PassRefPtr<WebMediaCacheManagerProxy> create(WebContext*);
+ virtual ~WebMediaCacheManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void getHostnamesWithMediaCache(PassRefPtr<ArrayCallback>);
+ void clearCacheForHostname(const String&);
+ void clearCacheForAllHostnames();
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ WebMediaCacheManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ void didGetHostnamesWithMediaCache(const Vector<String>&, uint64_t callbackID);
+
+ void didReceiveWebMediaCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+};
+
+} // namespace WebKit
+
+#endif // WebMediaCacheManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.messages.in
new file mode 100644
index 000000000..7929064a8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebMediaCacheManagerProxy.messages.in
@@ -0,0 +1,25 @@
+# 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.
+
+messages -> WebMediaCacheManagerProxy {
+ DidGetHostnamesWithMediaCache(Vector<WTF::String> hostnames, uint64_t callbackID);
+}
diff --git a/Source/WebKit2/UIProcess/WebNavigationData.cpp b/Source/WebKit2/UIProcess/WebNavigationData.cpp
new file mode 100644
index 000000000..eefc7d096
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebNavigationData.cpp
@@ -0,0 +1,40 @@
+/*
+ * 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 "WebNavigationData.h"
+
+namespace WebKit {
+
+WebNavigationData::WebNavigationData(const WebNavigationDataStore& store)
+ : m_store(store)
+{
+}
+
+WebNavigationData::~WebNavigationData()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebNavigationData.h b/Source/WebKit2/UIProcess/WebNavigationData.h
new file mode 100644
index 000000000..a2788d6bc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebNavigationData.h
@@ -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.
+ */
+
+#ifndef WebNavigationData_h
+#define WebNavigationData_h
+
+#include "APIObject.h"
+#include "WebNavigationDataStore.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebNavigationData : public APIObject {
+public:
+ static const Type APIType = TypeNavigationData;
+
+ static PassRefPtr<WebNavigationData> create(const WebNavigationDataStore& store)
+ {
+ return adoptRef(new WebNavigationData(store));
+ }
+
+ virtual ~WebNavigationData();
+
+ String title() const { return m_store.title; }
+ String url() const { return m_store.url; }
+ const WebCore::ResourceRequest& originalRequest() const { return m_store.originalRequest; }
+
+private:
+ WebNavigationData(const WebNavigationDataStore&);
+
+ virtual Type type() const { return APIType; }
+
+ WebNavigationDataStore m_store;
+};
+
+} // namespace WebKit
+
+#endif // WebNavigationData_h
diff --git a/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp b/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp
new file mode 100644
index 000000000..288a736fb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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 "WebOpenPanelResultListenerProxy.h"
+
+#include "ImmutableArray.h"
+#include "WebPageProxy.h"
+#include <WebCore/KURL.h>
+#include <wtf/Vector.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebOpenPanelResultListenerProxy::WebOpenPanelResultListenerProxy(WebPageProxy* page)
+ : m_page(page)
+{
+}
+
+WebOpenPanelResultListenerProxy::~WebOpenPanelResultListenerProxy()
+{
+}
+
+void WebOpenPanelResultListenerProxy::chooseFiles(ImmutableArray* fileURLsArray)
+{
+ if (!m_page)
+ return;
+
+ size_t size = fileURLsArray->size();
+
+ Vector<String> filePaths;
+ filePaths.reserveInitialCapacity(size);
+
+ for (size_t i = 0; i < size; ++i) {
+ WebURL* webURL = fileURLsArray->at<WebURL>(i);
+ if (webURL) {
+ KURL url(KURL(), webURL->string());
+ filePaths.uncheckedAppend(url.fileSystemPath());
+ }
+ }
+
+ m_page->didChooseFilesForOpenPanel(filePaths);
+}
+
+void WebOpenPanelResultListenerProxy::cancel()
+{
+ if (!m_page)
+ return;
+
+ m_page->didCancelForOpenPanel();
+}
+
+void WebOpenPanelResultListenerProxy::invalidate()
+{
+ m_page = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h b/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h
new file mode 100644
index 000000000..ba931dcf3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.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 WebOpenPanelResultListenerProxy_h
+#define WebOpenPanelResultListenerProxy_h
+
+#include "APIObject.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class ImmutableArray;
+class WebPageProxy;
+
+class WebOpenPanelResultListenerProxy : public APIObject {
+public:
+ static const Type APIType = TypeFramePolicyListener;
+
+ static PassRefPtr<WebOpenPanelResultListenerProxy> create(WebPageProxy* page)
+ {
+ return adoptRef(new WebOpenPanelResultListenerProxy(page));
+ }
+
+ virtual ~WebOpenPanelResultListenerProxy();
+
+ void chooseFiles(ImmutableArray*);
+ void cancel();
+
+ void invalidate();
+
+private:
+ WebOpenPanelResultListenerProxy(WebPageProxy*);
+
+ virtual Type type() const { return APIType; }
+
+ RefPtr<WebPageProxy> m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebOpenPanelResultListenerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp b/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp
new file mode 100644
index 000000000..897511cc5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp
@@ -0,0 +1,85 @@
+/*
+ * 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 "WebPageContextMenuClient.h"
+
+#include "Logging.h"
+#include "MutableArray.h"
+#include "WebContextMenuItem.h"
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+
+namespace WebKit {
+
+bool WebPageContextMenuClient::getContextMenuFromProposedMenu(WebPageProxy* page, const Vector<WebContextMenuItemData>& proposedMenuVector, Vector<WebContextMenuItemData>& customMenu, APIObject* userData)
+{
+ if (!m_client.getContextMenuFromProposedMenu)
+ return false;
+
+ unsigned size = proposedMenuVector.size();
+ RefPtr<MutableArray> proposedMenu = MutableArray::create();
+ proposedMenu->reserveCapacity(size);
+ for (unsigned i = 0; i < size; ++i)
+ proposedMenu->append(WebContextMenuItem::create(proposedMenuVector[i]).get());
+
+ WKArrayRef newMenu = 0;
+ m_client.getContextMenuFromProposedMenu(toAPI(page), toAPI(proposedMenu.get()), &newMenu, toAPI(userData), m_client.clientInfo);
+ RefPtr<ImmutableArray> array = adoptRef(toImpl(newMenu));
+
+ customMenu.clear();
+
+ size_t newSize = array ? array->size() : 0;
+ for (size_t i = 0; i < newSize; ++i) {
+ WebContextMenuItem* item = array->at<WebContextMenuItem>(i);
+ if (!item) {
+ LOG(ContextMenu, "New menu entry at index %i is not a WebContextMenuItem", (int)i);
+ continue;
+ }
+
+ customMenu.append(*item->data());
+ }
+
+ return true;
+}
+
+void WebPageContextMenuClient::customContextMenuItemSelected(WebPageProxy* page, const WebContextMenuItemData& itemData)
+{
+ if (!m_client.customContextMenuItemSelected)
+ return;
+
+ RefPtr<WebContextMenuItem> item = WebContextMenuItem::create(itemData);
+ m_client.customContextMenuItemSelected(toAPI(page), toAPI(item.get()), m_client.clientInfo);
+}
+
+void WebPageContextMenuClient::contextMenuDismissed(WebPageProxy* page)
+{
+ if (!m_client.contextMenuDismissed)
+ return;
+
+ m_client.contextMenuDismissed(toAPI(page), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageContextMenuClient.h b/Source/WebKit2/UIProcess/WebPageContextMenuClient.h
new file mode 100644
index 000000000..5cbb335d9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageContextMenuClient.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 WebPageContextMenuClient_h
+#define WebPageContextMenuClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class APIObject;
+class WebContextMenuItemData;
+class WebPageProxy;
+
+class WebPageContextMenuClient : public APIClient<WKPageContextMenuClient, kWKPageContextMenuClientCurrentVersion> {
+public:
+ bool getContextMenuFromProposedMenu(WebPageProxy*, const Vector<WebContextMenuItemData>& proposedMenu, Vector<WebContextMenuItemData>& customMenu, APIObject* userData);
+ void customContextMenuItemSelected(WebPageProxy*, const WebContextMenuItemData&);
+ void contextMenuDismissed(WebPageProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebPageContextMenuClient_h
diff --git a/Source/WebKit2/UIProcess/WebPageGroup.cpp b/Source/WebKit2/UIProcess/WebPageGroup.cpp
new file mode 100644
index 000000000..72588d4d7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageGroup.cpp
@@ -0,0 +1,131 @@
+/*
+ * 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 "WebPageGroup.h"
+
+#include "WebPageProxy.h"
+#include "WebPreferences.h"
+#include <wtf/HashMap.h>
+#include <wtf/text/StringConcatenate.h>
+
+namespace WebKit {
+
+static uint64_t generatePageGroupID()
+{
+ static uint64_t uniquePageGroupID = 1;
+ return uniquePageGroupID++;
+}
+
+typedef HashMap<uint64_t, WebPageGroup*> WebPageGroupMap;
+
+static WebPageGroupMap& webPageGroupMap()
+{
+ DEFINE_STATIC_LOCAL(WebPageGroupMap, map, ());
+ return map;
+}
+
+PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
+{
+ RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle, visibleToHistoryClient));
+
+ webPageGroupMap().set(pageGroup->pageGroupID(), pageGroup.get());
+
+ return pageGroup.release();
+}
+
+WebPageGroup* WebPageGroup::get(uint64_t pageGroupID)
+{
+ return webPageGroupMap().get(pageGroupID);
+}
+
+WebPageGroup::WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient)
+{
+ m_data.pageGroupID = generatePageGroupID();
+
+ if (!identifier.isNull())
+ m_data.identifer = identifier;
+ else
+ m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID));
+
+ m_data.visibleToInjectedBundle = visibleToInjectedBundle;
+ m_data.visibleToHistoryClient = visibleToHistoryClient;
+}
+
+WebPageGroup::~WebPageGroup()
+{
+ if (m_preferences)
+ m_preferences->removePageGroup(this);
+ webPageGroupMap().remove(pageGroupID());
+}
+
+void WebPageGroup::addPage(WebPageProxy* page)
+{
+ m_pages.add(page);
+}
+
+void WebPageGroup::removePage(WebPageProxy* page)
+{
+ m_pages.remove(page);
+}
+
+void WebPageGroup::setPreferences(WebPreferences* preferences)
+{
+ if (preferences == m_preferences)
+ return;
+
+ if (!m_preferences) {
+ m_preferences = preferences;
+ m_preferences->addPageGroup(this);
+ } else {
+ m_preferences->removePageGroup(this);
+ m_preferences = preferences;
+ m_preferences->addPageGroup(this);
+
+ preferencesDidChange();
+ }
+}
+
+WebPreferences* WebPageGroup::preferences() const
+{
+ if (!m_preferences) {
+ if (!m_data.identifer.isNull())
+ m_preferences = WebPreferences::create(m_data.identifer);
+ else
+ m_preferences = WebPreferences::create();
+ m_preferences->addPageGroup(const_cast<WebPageGroup*>(this));
+ }
+ return m_preferences.get();
+}
+
+void WebPageGroup::preferencesDidChange()
+{
+ for (HashSet<WebPageProxy*>::iterator it = m_pages.begin(), end = m_pages.end(); it != end; ++it) {
+ WebPageProxy* page = *it;
+ page->preferencesDidChange();
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageGroup.h b/Source/WebKit2/UIProcess/WebPageGroup.h
new file mode 100644
index 000000000..ccc14bd91
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageGroup.h
@@ -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.
+ */
+
+#ifndef WebPageGroup_h
+#define WebPageGroup_h
+
+#include "APIObject.h"
+#include "WebPageGroupData.h"
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WebPreferences;
+class WebPageProxy;
+
+class WebPageGroup : public APIObject {
+public:
+ static const Type APIType = TypePageGroup;
+
+ static PassRefPtr<WebPageGroup> create(const String& identifier = String(), bool visibleToInjectedBundle = true, bool visibleToHistoryClient = true);
+ static WebPageGroup* get(uint64_t pageGroupID);
+
+ virtual ~WebPageGroup();
+
+ void addPage(WebPageProxy*);
+ void removePage(WebPageProxy*);
+
+ const String& identifier() const { return m_data.identifer; }
+ uint64_t pageGroupID() const { return m_data.pageGroupID; }
+
+ const WebPageGroupData& data() { return m_data; }
+
+ void setPreferences(WebPreferences*);
+ WebPreferences* preferences() const;
+ void preferencesDidChange();
+
+private:
+ WebPageGroup(const String& identifier, bool visibleToInjectedBundle, bool visibleToHistoryClient);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageGroupData m_data;
+ mutable RefPtr<WebPreferences> m_preferences;
+ HashSet<WebPageProxy*> m_pages;
+};
+
+} // namespace WebKit
+
+#endif // WebPageGroup_h
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
new file mode 100644
index 000000000..15abf9ccc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -0,0 +1,3546 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "AuthenticationDecisionListener.h"
+#include "DataReference.h"
+#include "DownloadProxy.h"
+#include "DrawingAreaProxy.h"
+#include "EventDispatcherMessages.h"
+#include "FindIndicator.h"
+#include "Logging.h"
+#include "MessageID.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "NotificationPermissionRequest.h"
+#include "NotificationPermissionRequestManager.h"
+#include "PageClient.h"
+#include "PrintInfo.h"
+#include "SessionState.h"
+#include "StringPairVector.h"
+#include "TextChecker.h"
+#include "TextCheckerState.h"
+#include "WKContextPrivate.h"
+#include "WebBackForwardList.h"
+#include "WebBackForwardListItem.h"
+#include "WebCertificateInfo.h"
+#include "WebContext.h"
+#include "WebContextMenuProxy.h"
+#include "WebContextUserMessageCoders.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebData.h"
+#include "WebEditCommandProxy.h"
+#include "WebEvent.h"
+#include "WebFormSubmissionListenerProxy.h"
+#include "WebFramePolicyListenerProxy.h"
+#include "WebFullScreenManagerProxy.h"
+#include "WebInspectorProxy.h"
+#include "WebNotificationManagerProxy.h"
+#include "WebOpenPanelResultListenerProxy.h"
+#include "WebPageCreationParameters.h"
+#include "WebPageGroup.h"
+#include "WebPageGroupData.h"
+#include "WebPageMessages.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxy.h"
+#include "WebPreferences.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include "WebProtectionSpace.h"
+#include "WebSecurityOrigin.h"
+#include "WebURLRequest.h"
+#include <WebCore/DragController.h>
+#include <WebCore/DragData.h>
+#include <WebCore/DragSession.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/FocusDirection.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/TextCheckerClient.h>
+#include <WebCore/WindowFeatures.h>
+#include <stdio.h>
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+#include "LayerTreeHostProxyMessages.h"
+#endif
+
+#if PLATFORM(QT)
+#include "ArgumentCodersQt.h"
+#endif
+
+#if PLATFORM(GTK)
+#include "ArgumentCodersGtk.h"
+#endif
+
+#ifndef NDEBUG
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+// This controls what strategy we use for mouse wheel coalescing.
+#define MERGE_WHEEL_EVENTS 1
+
+#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, m_process->connection())
+#define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(m_process->checkURLReceivedFromWebProcess(url), m_process->connection())
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WKPageDebugPaintFlags WebPageProxy::s_debugPaintFlags = 0;
+
+DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy"));
+
+#if !LOG_DISABLED
+static const char* webKeyboardEventTypeString(WebEvent::Type type)
+{
+ switch (type) {
+ case WebEvent::KeyDown:
+ return "KeyDown";
+
+ case WebEvent::KeyUp:
+ return "KeyUp";
+
+ case WebEvent::RawKeyDown:
+ return "RawKeyDown";
+
+ case WebEvent::Char:
+ return "Char";
+
+ default:
+ ASSERT_NOT_REACHED();
+ return "<unknown>";
+ }
+}
+#endif // !LOG_DISABLED
+
+PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
+{
+ return adoptRef(new WebPageProxy(pageClient, process, pageGroup, pageID));
+}
+
+WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> process, WebPageGroup* pageGroup, uint64_t pageID)
+ : m_pageClient(pageClient)
+ , m_process(process)
+ , m_pageGroup(pageGroup)
+ , m_mainFrame(0)
+ , m_userAgent(standardUserAgent())
+ , m_geolocationPermissionRequestManager(this)
+ , m_notificationPermissionRequestManager(this)
+ , m_estimatedProgress(0)
+ , m_isInWindow(m_pageClient->isViewInWindow())
+ , m_isVisible(m_pageClient->isViewVisible())
+ , m_backForwardList(WebBackForwardList::create(this))
+ , m_loadStateAtProcessExit(WebFrameProxy::LoadStateFinished)
+ , m_textZoomFactor(1)
+ , m_pageZoomFactor(1)
+ , m_pageScaleFactor(1)
+ , m_intrinsicDeviceScaleFactor(1)
+ , m_customDeviceScaleFactor(0)
+ , m_drawsBackground(true)
+ , m_drawsTransparentBackground(false)
+ , m_areMemoryCacheClientCallsEnabled(true)
+ , m_useFixedLayout(false)
+ , m_paginationMode(Page::Pagination::Unpaginated)
+ , m_pageLength(0)
+ , m_gapBetweenPages(0)
+ , m_isValid(true)
+ , m_isClosed(false)
+ , m_isInPrintingMode(false)
+ , m_isPerformingDOMPrintOperation(false)
+ , m_inDecidePolicyForResponse(false)
+ , m_syncMimeTypePolicyActionIsValid(false)
+ , m_syncMimeTypePolicyAction(PolicyUse)
+ , m_syncMimeTypePolicyDownloadID(0)
+ , m_inDecidePolicyForNavigationAction(false)
+ , m_syncNavigationActionPolicyActionIsValid(false)
+ , m_syncNavigationActionPolicyAction(PolicyUse)
+ , m_syncNavigationActionPolicyDownloadID(0)
+ , m_processingMouseMoveEvent(false)
+#if ENABLE(TOUCH_EVENTS)
+ , m_needTouchEvents(false)
+#endif
+ , m_pageID(pageID)
+#if PLATFORM(MAC)
+ , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
+#endif
+ , m_spellDocumentTag(0)
+ , m_hasSpellDocumentTag(false)
+ , m_pendingLearnOrIgnoreWordMessageCount(0)
+ , m_mainFrameHasCustomRepresentation(false)
+ , m_mainFrameHasHorizontalScrollbar(false)
+ , m_mainFrameHasVerticalScrollbar(false)
+ , m_mainFrameIsPinnedToLeftSide(false)
+ , m_mainFrameIsPinnedToRightSide(false)
+ , m_pageCount(0)
+ , m_renderTreeSize(0)
+ , m_shouldSendEventsSynchronously(false)
+{
+#ifndef NDEBUG
+ webPageProxyCounter.increment();
+#endif
+
+ WebContext::statistics().wkPageCount++;
+
+ m_pageGroup->addPage(this);
+}
+
+WebPageProxy::~WebPageProxy()
+{
+ if (!m_isClosed)
+ close();
+
+ WebContext::statistics().wkPageCount--;
+
+ if (m_hasSpellDocumentTag)
+ TextChecker::closeSpellDocumentWithTag(m_spellDocumentTag);
+
+ m_pageGroup->removePage(this);
+
+#ifndef NDEBUG
+ webPageProxyCounter.decrement();
+#endif
+}
+
+WebProcessProxy* WebPageProxy::process() const
+{
+ return m_process.get();
+}
+
+PlatformProcessIdentifier WebPageProxy::processIdentifier() const
+{
+ if (!m_process)
+ return 0;
+
+ return m_process->processIdentifier();
+}
+
+bool WebPageProxy::isValid()
+{
+ // A page that has been explicitly closed is never valid.
+ if (m_isClosed)
+ return false;
+
+ return m_isValid;
+}
+
+void WebPageProxy::initializeLoaderClient(const WKPageLoaderClient* loadClient)
+{
+ m_loaderClient.initialize(loadClient);
+}
+
+void WebPageProxy::initializePolicyClient(const WKPagePolicyClient* policyClient)
+{
+ m_policyClient.initialize(policyClient);
+}
+
+void WebPageProxy::initializeFormClient(const WKPageFormClient* formClient)
+{
+ m_formClient.initialize(formClient);
+}
+
+void WebPageProxy::initializeResourceLoadClient(const WKPageResourceLoadClient* client)
+{
+ m_resourceLoadClient.initialize(client);
+}
+
+void WebPageProxy::initializeUIClient(const WKPageUIClient* client)
+{
+ if (!isValid())
+ return;
+
+ m_uiClient.initialize(client);
+
+ process()->send(Messages::WebPage::SetCanRunBeforeUnloadConfirmPanel(m_uiClient.canRunBeforeUnloadConfirmPanel()), m_pageID);
+ process()->send(Messages::WebPage::SetCanRunModal(m_uiClient.canRunModal()), m_pageID);
+}
+
+void WebPageProxy::initializeFindClient(const WKPageFindClient* client)
+{
+ m_findClient.initialize(client);
+}
+
+void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client)
+{
+ m_contextMenuClient.initialize(client);
+}
+
+void WebPageProxy::reattachToWebProcess()
+{
+ ASSERT(!isValid());
+
+ m_isValid = true;
+
+ m_process = m_process->context()->relaunchProcessIfNecessary();
+ process()->addExistingWebPage(this, m_pageID);
+
+ initializeWebPage();
+
+ m_pageClient->didRelaunchProcess();
+ m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
+}
+
+void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
+{
+ if (item && item != m_backForwardList->currentItem())
+ m_backForwardList->goToItem(item);
+
+ reattachToWebProcess();
+
+ if (!item)
+ return;
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID(), sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::initializeWebPage()
+{
+ ASSERT(isValid());
+
+ BackForwardListItemVector items = m_backForwardList->entries();
+ for (size_t i = 0; i < items.size(); ++i)
+ process()->registerNewWebBackForwardListItem(items[i].get());
+
+ m_drawingArea = m_pageClient->createDrawingAreaProxy();
+ ASSERT(m_drawingArea);
+
+ process()->send(Messages::WebProcess::CreateWebPage(m_pageID, creationParameters()), 0);
+}
+
+void WebPageProxy::close()
+{
+ if (!isValid())
+ return;
+
+ m_isClosed = true;
+
+ m_backForwardList->pageClosed();
+ m_pageClient->pageClosed();
+
+ process()->disconnectFramesFromPage(this);
+ m_mainFrame = 0;
+
+#if ENABLE(INSPECTOR)
+ if (m_inspector) {
+ m_inspector->invalidate();
+ m_inspector = 0;
+ }
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ if (m_fullScreenManager) {
+ m_fullScreenManager->invalidate();
+ m_fullScreenManager = 0;
+ }
+#endif
+
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+ }
+
+ m_geolocationPermissionRequestManager.invalidateRequests();
+ m_notificationPermissionRequestManager.invalidateRequests();
+
+ m_toolTip = String();
+
+ m_mainFrameHasHorizontalScrollbar = false;
+ m_mainFrameHasVerticalScrollbar = false;
+
+ m_mainFrameIsPinnedToLeftSide = false;
+ m_mainFrameIsPinnedToRightSide = false;
+
+ m_visibleScrollerThumbRect = IntRect();
+
+ invalidateCallbackMap(m_voidCallbacks);
+ invalidateCallbackMap(m_dataCallbacks);
+ invalidateCallbackMap(m_stringCallbacks);
+ m_loadDependentStringCallbackIDs.clear();
+ invalidateCallbackMap(m_scriptValueCallbacks);
+ invalidateCallbackMap(m_computedPagesCallbacks);
+
+ Vector<WebEditCommandProxy*> editCommandVector;
+ copyToVector(m_editCommandSet, editCommandVector);
+ m_editCommandSet.clear();
+ for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
+ editCommandVector[i]->invalidate();
+
+ m_activePopupMenu = 0;
+
+ m_estimatedProgress = 0.0;
+
+ m_loaderClient.initialize(0);
+ m_policyClient.initialize(0);
+ m_uiClient.initialize(0);
+
+ m_drawingArea = nullptr;
+
+ process()->send(Messages::WebPage::Close(), m_pageID);
+ process()->removeWebPage(m_pageID);
+}
+
+bool WebPageProxy::tryClose()
+{
+ if (!isValid())
+ return true;
+
+ process()->send(Messages::WebPage::TryClose(), m_pageID);
+ process()->responsivenessTimer()->start();
+ return false;
+}
+
+bool WebPageProxy::maybeInitializeSandboxExtensionHandle(const KURL& url, SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ if (!url.isLocalFile())
+ return false;
+
+#if ENABLE(INSPECTOR)
+ // Don't give the inspector full access to the file system.
+ if (WebInspectorProxy::isInspectorPage(this))
+ return false;
+#endif
+
+ SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
+ return true;
+}
+
+void WebPageProxy::loadURL(const String& url)
+{
+ setPendingAPIRequestURL(url);
+
+ if (!isValid())
+ reattachToWebProcess();
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::LoadURL(url, sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
+{
+ setPendingAPIRequestURL(urlRequest->resourceRequest().url());
+
+ if (!isValid())
+ reattachToWebProcess();
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(urlRequest->resourceRequest().url(), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::LoadURLRequest(urlRequest->resourceRequest(), sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL)
+{
+ if (!isValid())
+ reattachToWebProcess();
+
+ process()->assumeReadAccessToBaseURL(baseURL);
+ process()->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL)
+{
+ if (!isValid())
+ reattachToWebProcess();
+
+ if (m_mainFrame)
+ m_mainFrame->setUnreachableURL(unreachableURL);
+
+ process()->assumeReadAccessToBaseURL(baseURL);
+ process()->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::loadPlainTextString(const String& string)
+{
+ if (!isValid())
+ reattachToWebProcess();
+
+ process()->send(Messages::WebPage::LoadPlainTextString(string), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::stopLoading()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::StopLoading(), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::reload(bool reloadFromOrigin)
+{
+ if (m_backForwardList->currentItem())
+ setPendingAPIRequestURL(m_backForwardList->currentItem()->url());
+
+ if (!isValid()) {
+ reattachToWebProcessWithItem(m_backForwardList->currentItem());
+ return;
+ }
+
+ process()->send(Messages::WebPage::Reload(reloadFromOrigin), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::goForward()
+{
+ if (isValid() && !canGoForward())
+ return;
+
+ WebBackForwardListItem* forwardItem = m_backForwardList->forwardItem();
+ if (forwardItem)
+ setPendingAPIRequestURL(forwardItem->url());
+
+ if (!isValid()) {
+ reattachToWebProcessWithItem(forwardItem);
+ return;
+ }
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), forwardItem->url()), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::GoForward(forwardItem->itemID(), sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+bool WebPageProxy::canGoForward() const
+{
+ return m_backForwardList->forwardItem();
+}
+
+void WebPageProxy::goBack()
+{
+ if (isValid() && !canGoBack())
+ return;
+
+ WebBackForwardListItem* backItem = m_backForwardList->backItem();
+ if (backItem)
+ setPendingAPIRequestURL(backItem->url());
+
+ if (!isValid()) {
+ reattachToWebProcessWithItem(backItem);
+ return;
+ }
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), backItem->url()), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::GoBack(backItem->itemID(), sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+bool WebPageProxy::canGoBack() const
+{
+ return m_backForwardList->backItem();
+}
+
+void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
+{
+ if (!isValid()) {
+ reattachToWebProcessWithItem(item);
+ return;
+ }
+
+ setPendingAPIRequestURL(item->url());
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID(), sandboxExtensionHandle), m_pageID);
+ process()->responsivenessTimer()->start();
+}
+
+void WebPageProxy::tryRestoreScrollPosition()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::TryRestoreScrollPosition(), m_pageID);
+}
+
+void WebPageProxy::didChangeBackForwardList(WebBackForwardListItem* added, Vector<RefPtr<APIObject> >* removed)
+{
+ m_loaderClient.didChangeBackForwardList(this, added, removed);
+}
+
+void WebPageProxy::shouldGoToBackForwardListItem(uint64_t itemID, bool& shouldGoToBackForwardItem)
+{
+ WebBackForwardListItem* item = process()->webBackForwardItem(itemID);
+ shouldGoToBackForwardItem = item && m_loaderClient.shouldGoToBackForwardListItem(this, item);
+}
+
+String WebPageProxy::activeURL() const
+{
+ if (!m_mainFrame)
+ return String();
+
+ // If there is a currently pending url, it is the active URL.
+ if (!m_pendingAPIRequestURL.isNull())
+ return m_pendingAPIRequestURL;
+
+ // FIXME: What do we do in the case of the unreachable URL?
+
+ switch (m_mainFrame->loadState()) {
+ case WebFrameProxy::LoadStateProvisional:
+ return m_mainFrame->provisionalURL();
+ case WebFrameProxy::LoadStateCommitted:
+ case WebFrameProxy::LoadStateFinished:
+ return m_mainFrame->url();
+ }
+
+ ASSERT_NOT_REACHED();
+ return String();
+}
+
+String WebPageProxy::provisionalURL() const
+{
+ if (!m_mainFrame)
+ return String();
+ return m_mainFrame->provisionalURL();
+}
+
+String WebPageProxy::committedURL() const
+{
+ if (!m_mainFrame)
+ return String();
+
+ return m_mainFrame->url();
+}
+
+bool WebPageProxy::canShowMIMEType(const String& mimeType) const
+{
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return true;
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return true;
+
+ if (mimeType.startsWith("text/", false))
+ return !MIMETypeRegistry::isUnsupportedTextMIMEType(mimeType);
+
+ String newMimeType = mimeType;
+ PluginModuleInfo plugin = m_process->context()->pluginInfoStore().findPlugin(newMimeType, KURL());
+ if (!plugin.path.isNull())
+ return true;
+
+ return false;
+}
+
+void WebPageProxy::setDrawsBackground(bool drawsBackground)
+{
+ if (m_drawsBackground == drawsBackground)
+ return;
+
+ m_drawsBackground = drawsBackground;
+
+ if (isValid())
+ process()->send(Messages::WebPage::SetDrawsBackground(drawsBackground), m_pageID);
+}
+
+void WebPageProxy::setDrawsTransparentBackground(bool drawsTransparentBackground)
+{
+ if (m_drawsTransparentBackground == drawsTransparentBackground)
+ return;
+
+ m_drawsTransparentBackground = drawsTransparentBackground;
+
+ if (isValid())
+ process()->send(Messages::WebPage::SetDrawsTransparentBackground(drawsTransparentBackground), m_pageID);
+}
+
+void WebPageProxy::viewWillStartLiveResize()
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::ViewWillStartLiveResize(), m_pageID);
+}
+
+void WebPageProxy::viewWillEndLiveResize()
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
+}
+
+void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
+{
+ m_pageClient->setViewNeedsDisplay(rect);
+}
+
+void WebPageProxy::displayView()
+{
+ m_pageClient->displayView();
+}
+
+void WebPageProxy::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ m_pageClient->scrollView(scrollRect, scrollOffset);
+}
+
+void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
+{
+ if (!isValid())
+ return;
+
+ if (flags & ViewIsFocused)
+ process()->send(Messages::WebPage::SetFocused(m_pageClient->isViewFocused()), m_pageID);
+
+ if (flags & ViewWindowIsActive)
+ process()->send(Messages::WebPage::SetActive(m_pageClient->isViewWindowActive()), m_pageID);
+
+ if (flags & ViewIsVisible) {
+ bool isVisible = m_pageClient->isViewVisible();
+ if (isVisible != m_isVisible) {
+ m_isVisible = isVisible;
+ m_drawingArea->visibilityDidChange();
+
+ if (!m_isVisible) {
+ // If we've started the responsiveness timer as part of telling the web process to update the backing store
+ // state, it might not send back a reply (since it won't paint anything if the web page is hidden) so we
+ // stop the unresponsiveness timer here.
+ process()->responsivenessTimer()->stop();
+ }
+ }
+ }
+
+ if (flags & ViewIsInWindow) {
+ bool isInWindow = m_pageClient->isViewInWindow();
+ if (m_isInWindow != isInWindow) {
+ m_isInWindow = isInWindow;
+ process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
+ }
+ }
+
+ updateBackingStoreDiscardableState();
+}
+
+IntSize WebPageProxy::viewSize() const
+{
+ return m_pageClient->viewSize();
+}
+
+void WebPageProxy::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& keyboardEvent)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetInitialFocus(forward, isKeyboardEventValid, keyboardEvent), m_pageID);
+}
+
+void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
+}
+
+void WebPageProxy::clearSelection()
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::ClearSelection(), m_pageID);
+}
+
+void WebPageProxy::validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback> callback)
+{
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_validateCommandCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::ValidateCommand(commandName, callbackID), m_pageID);
+}
+
+void WebPageProxy::setMaintainsInactiveSelection(bool newValue)
+{
+ m_maintainsInactiveSelection = newValue;
+}
+
+void WebPageProxy::executeEditCommand(const String& commandName)
+{
+ if (!isValid())
+ return;
+
+ DEFINE_STATIC_LOCAL(String, ignoreSpellingCommandName, ("ignoreSpelling"));
+ if (commandName == ignoreSpellingCommandName)
+ ++m_pendingLearnOrIgnoreWordMessageCount;
+
+ process()->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
+}
+
+#if USE(TILED_BACKING_STORE)
+void WebPageProxy::setFixedVisibleContentRect(const IntRect& rect)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SetFixedVisibleContentRect(rect), m_pageID);
+}
+
+void WebPageProxy::setViewportSize(const IntSize& size)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SetViewportSize(size), m_pageID);
+}
+#endif
+
+void WebPageProxy::dragEntered(DragData* dragData, const String& dragStorageName)
+{
+ SandboxExtension::Handle sandboxExtensionHandle;
+ performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle);
+}
+
+void WebPageProxy::dragUpdated(DragData* dragData, const String& dragStorageName)
+{
+ SandboxExtension::Handle sandboxExtensionHandle;
+ performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle);
+}
+
+void WebPageProxy::dragExited(DragData* dragData, const String& dragStorageName)
+{
+ SandboxExtension::Handle sandboxExtensionHandle;
+ performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle);
+}
+
+void WebPageProxy::performDrag(DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle);
+}
+
+void WebPageProxy::performDragControllerAction(DragControllerAction action, DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ if (!isValid())
+ return;
+#if PLATFORM(WIN)
+ // FIXME: We should pass the drag data map only on DragEnter.
+ process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(),
+ dragData->draggingSourceOperationMask(), dragData->dragDataMap(), dragData->flags()), m_pageID);
+#elif PLATFORM(QT) || PLATFORM(GTK)
+ process()->send(Messages::WebPage::PerformDragControllerAction(action, *dragData), m_pageID);
+#else
+ process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle), m_pageID);
+#endif
+}
+
+void WebPageProxy::didPerformDragControllerAction(WebCore::DragSession dragSession)
+{
+ m_currentDragSession = dragSession;
+}
+
+#if PLATFORM(QT) || PLATFORM(GTK)
+void WebPageProxy::startDrag(const DragData& dragData, const ShareableBitmap::Handle& dragImageHandle)
+{
+ RefPtr<ShareableBitmap> dragImage = 0;
+ if (!dragImageHandle.isNull()) {
+ dragImage = ShareableBitmap::create(dragImageHandle);
+ if (!dragImage)
+ return;
+ }
+
+ m_pageClient->startDrag(dragData, dragImage.release());
+}
+#endif
+
+void WebPageProxy::dragEnded(const IntPoint& clientPosition, const IntPoint& globalPosition, uint64_t operation)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::DragEnded(clientPosition, globalPosition, operation), m_pageID);
+}
+
+void WebPageProxy::handleMouseEvent(const NativeWebMouseEvent& event)
+{
+ if (!isValid())
+ return;
+
+ // NOTE: This does not start the responsiveness timer because mouse move should not indicate interaction.
+ if (event.type() != WebEvent::MouseMove)
+ process()->responsivenessTimer()->start();
+ else {
+ if (m_processingMouseMoveEvent) {
+ m_nextMouseMoveEvent = adoptPtr(new NativeWebMouseEvent(event));
+ return;
+ }
+
+ m_processingMouseMoveEvent = true;
+ }
+
+ // <https://bugs.webkit.org/show_bug.cgi?id=57904> We need to keep track of the mouse down event in the case where we
+ // display a popup menu for select elements. When the user changes the selected item,
+ // we fake a mouse up event by using this stored down event. This event gets cleared
+ // when the mouse up message is received from WebProcess.
+ if (event.type() == WebEvent::MouseDown)
+ m_currentlyProcessedMouseDownEvent = adoptPtr(new NativeWebMouseEvent(event));
+
+ if (m_shouldSendEventsSynchronously) {
+ bool handled = false;
+ process()->sendSync(Messages::WebPage::MouseEventSyncForTesting(event), Messages::WebPage::MouseEventSyncForTesting::Reply(handled), m_pageID);
+ didReceiveEvent(event.type(), handled);
+ } else
+ process()->send(Messages::WebPage::MouseEvent(event), m_pageID);
+}
+
+void WebPageProxy::handleWheelEvent(const NativeWebWheelEvent& event)
+{
+ if (!isValid())
+ return;
+
+ if (!m_currentlyProcessedWheelEvents.isEmpty()) {
+ m_wheelEventQueue.append(event);
+ return;
+ }
+
+ m_currentlyProcessedWheelEvents.append(event);
+
+ process()->responsivenessTimer()->start();
+
+ if (m_shouldSendEventsSynchronously) {
+ bool handled = false;
+ process()->sendSync(Messages::WebPage::WheelEventSyncForTesting(event), Messages::WebPage::WheelEventSyncForTesting::Reply(handled), m_pageID);
+ didReceiveEvent(event.type(), handled);
+ } else
+ process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, event), 0);
+}
+
+void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
+{
+ if (!isValid())
+ return;
+
+ LOG(KeyHandling, "WebPageProxy::handleKeyboardEvent: %s", webKeyboardEventTypeString(event.type()));
+
+ m_keyEventQueue.append(event);
+
+ process()->responsivenessTimer()->start();
+ if (m_shouldSendEventsSynchronously) {
+ bool handled = false;
+ process()->sendSync(Messages::WebPage::KeyEventSyncForTesting(event), Messages::WebPage::KeyEventSyncForTesting::Reply(handled), m_pageID);
+ didReceiveEvent(event.type(), handled);
+ } else
+ process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
+}
+
+#if ENABLE(GESTURE_EVENTS)
+void WebPageProxy::handleGestureEvent(const WebGestureEvent& event)
+{
+ if (!isValid())
+ return;
+
+ process()->responsivenessTimer()->start();
+ process()->send(Messages::EventDispatcher::GestureEvent(m_pageID, event), 0);
+}
+#endif
+
+#if ENABLE(TOUCH_EVENTS)
+void WebPageProxy::handleTouchEvent(const NativeWebTouchEvent& event)
+{
+ if (!isValid())
+ return;
+
+ if (m_needTouchEvents) {
+ m_touchEventQueue.append(event);
+ process()->responsivenessTimer()->start();
+ if (m_shouldSendEventsSynchronously) {
+ bool handled = false;
+ process()->sendSync(Messages::WebPage::TouchEventSyncForTesting(event), Messages::WebPage::TouchEventSyncForTesting::Reply(handled), m_pageID);
+ didReceiveEvent(event.type(), handled);
+ } else
+ process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
+ } else {
+ if (m_touchEventQueue.isEmpty()) {
+ bool isEventHandled = false;
+ m_pageClient->doneWithTouchEvent(event, isEventHandled);
+ } else {
+ // We attach the incoming events to the newest queued event so that all
+ // the events are delivered in the correct order when the event is dequed.
+ QueuedTouchEvents& lastEvent = m_touchEventQueue.last();
+ lastEvent.deferredTouchEvents.append(event);
+ }
+ }
+}
+#endif
+
+void WebPageProxy::scrollBy(ScrollDirection direction, ScrollGranularity granularity)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::ScrollBy(direction, granularity), m_pageID);
+}
+
+void WebPageProxy::centerSelectionInVisibleArea()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::CenterSelectionInVisibleArea(), m_pageID);
+}
+
+void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
+{
+ if (!isValid())
+ return;
+
+ if (action == PolicyIgnore)
+ clearPendingAPIRequestURL();
+
+ uint64_t downloadID = 0;
+ if (action == PolicyDownload) {
+ // Create a download proxy.
+ DownloadProxy* download = m_process->context()->createDownloadProxy();
+ downloadID = download->downloadID();
+#if PLATFORM(QT)
+ // Our design does not suppport downloads without a WebPage.
+ handleDownloadRequest(download);
+#endif
+ }
+
+ // If we received a policy decision while in decidePolicyForResponse the decision will
+ // be sent back to the web process by decidePolicyForResponse.
+ if (m_inDecidePolicyForResponse) {
+ m_syncMimeTypePolicyActionIsValid = true;
+ m_syncMimeTypePolicyAction = action;
+ m_syncMimeTypePolicyDownloadID = downloadID;
+ return;
+ }
+
+ // If we received a policy decision while in decidePolicyForNavigationAction the decision will
+ // be sent back to the web process by decidePolicyForNavigationAction.
+ if (m_inDecidePolicyForNavigationAction) {
+ m_syncNavigationActionPolicyActionIsValid = true;
+ m_syncNavigationActionPolicyAction = action;
+ m_syncNavigationActionPolicyDownloadID = downloadID;
+ return;
+ }
+
+ process()->send(Messages::WebPage::DidReceivePolicyDecision(frame->frameID(), listenerID, action, downloadID), m_pageID);
+}
+
+String WebPageProxy::pageTitle() const
+{
+ // Return the null string if there is no main frame (e.g. nothing has been loaded in the page yet, WebProcess has
+ // crashed, page has been closed).
+ if (!m_mainFrame)
+ return String();
+
+ return m_mainFrame->title();
+}
+
+void WebPageProxy::setUserAgent(const String& userAgent)
+{
+ if (m_userAgent == userAgent)
+ return;
+ m_userAgent = userAgent;
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetUserAgent(m_userAgent), m_pageID);
+}
+
+void WebPageProxy::setApplicationNameForUserAgent(const String& applicationName)
+{
+ if (m_applicationNameForUserAgent == applicationName)
+ return;
+
+ m_applicationNameForUserAgent = applicationName;
+ if (!m_customUserAgent.isEmpty())
+ return;
+
+ setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
+}
+
+void WebPageProxy::setCustomUserAgent(const String& customUserAgent)
+{
+ if (m_customUserAgent == customUserAgent)
+ return;
+
+ m_customUserAgent = customUserAgent;
+
+ if (m_customUserAgent.isEmpty()) {
+ setUserAgent(standardUserAgent(m_applicationNameForUserAgent));
+ return;
+ }
+
+ setUserAgent(m_customUserAgent);
+}
+
+bool WebPageProxy::supportsTextEncoding() const
+{
+ return !m_mainFrameHasCustomRepresentation && m_mainFrame && !m_mainFrame->isDisplayingStandaloneImageDocument();
+}
+
+void WebPageProxy::setCustomTextEncodingName(const String& encodingName)
+{
+ if (m_customTextEncodingName == encodingName)
+ return;
+ m_customTextEncodingName = encodingName;
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetCustomTextEncodingName(encodingName), m_pageID);
+}
+
+void WebPageProxy::terminateProcess()
+{
+ // NOTE: This uses a check of m_isValid rather than calling isValid() since
+ // we want this to run even for pages being closed or that already closed.
+ if (!m_isValid)
+ return;
+
+ process()->terminate();
+}
+
+#if !USE(CF) || defined(BUILDING_QT__)
+PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback, void* context) const
+{
+ // FIXME: Return session state data for saving Page state.
+ return 0;
+}
+
+void WebPageProxy::restoreFromSessionStateData(WebData*)
+{
+ // FIXME: Restore the Page from the passed in session state data.
+}
+#endif
+
+bool WebPageProxy::supportsTextZoom() const
+{
+ if (m_mainFrameHasCustomRepresentation)
+ return false;
+
+ // FIXME: This should also return false for standalone media and plug-in documents.
+ if (!m_mainFrame || m_mainFrame->isDisplayingStandaloneImageDocument())
+ return false;
+
+ return true;
+}
+
+void WebPageProxy::setTextZoomFactor(double zoomFactor)
+{
+ if (!isValid())
+ return;
+
+ if (m_mainFrameHasCustomRepresentation)
+ return;
+
+ if (m_textZoomFactor == zoomFactor)
+ return;
+
+ m_textZoomFactor = zoomFactor;
+ process()->send(Messages::WebPage::SetTextZoomFactor(m_textZoomFactor), m_pageID);
+}
+
+double WebPageProxy::pageZoomFactor() const
+{
+ return m_mainFrameHasCustomRepresentation ? m_pageClient->customRepresentationZoomFactor() : m_pageZoomFactor;
+}
+
+void WebPageProxy::setPageZoomFactor(double zoomFactor)
+{
+ if (!isValid())
+ return;
+
+ if (m_mainFrameHasCustomRepresentation) {
+ m_pageClient->setCustomRepresentationZoomFactor(zoomFactor);
+ return;
+ }
+
+ if (m_pageZoomFactor == zoomFactor)
+ return;
+
+ m_pageZoomFactor = zoomFactor;
+ process()->send(Messages::WebPage::SetPageZoomFactor(m_pageZoomFactor), m_pageID);
+}
+
+void WebPageProxy::setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor)
+{
+ if (!isValid())
+ return;
+
+ if (m_mainFrameHasCustomRepresentation) {
+ m_pageClient->setCustomRepresentationZoomFactor(pageZoomFactor);
+ return;
+ }
+
+ if (m_pageZoomFactor == pageZoomFactor && m_textZoomFactor == textZoomFactor)
+ return;
+
+ m_pageZoomFactor = pageZoomFactor;
+ m_textZoomFactor = textZoomFactor;
+ process()->send(Messages::WebPage::SetPageAndTextZoomFactors(m_pageZoomFactor, m_textZoomFactor), m_pageID);
+}
+
+void WebPageProxy::scalePage(double scale, const IntPoint& origin)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::ScalePage(scale, origin), m_pageID);
+}
+
+void WebPageProxy::setIntrinsicDeviceScaleFactor(float scaleFactor)
+{
+ if (!isValid())
+ return;
+
+ if (m_intrinsicDeviceScaleFactor == scaleFactor)
+ return;
+
+ m_intrinsicDeviceScaleFactor = scaleFactor;
+ m_drawingArea->deviceScaleFactorDidChange();
+}
+
+void WebPageProxy::windowScreenDidChange(PlatformDisplayID displayID)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::WindowScreenDidChange(displayID), m_pageID);
+}
+
+float WebPageProxy::deviceScaleFactor() const
+{
+ if (m_customDeviceScaleFactor)
+ return m_customDeviceScaleFactor;
+ return m_intrinsicDeviceScaleFactor;
+}
+
+void WebPageProxy::setCustomDeviceScaleFactor(float customScaleFactor)
+{
+ if (!isValid())
+ return;
+
+ if (m_customDeviceScaleFactor == customScaleFactor)
+ return;
+
+ float oldScaleFactor = deviceScaleFactor();
+
+ m_customDeviceScaleFactor = customScaleFactor;
+
+ if (deviceScaleFactor() != oldScaleFactor)
+ m_drawingArea->deviceScaleFactorDidChange();
+}
+
+void WebPageProxy::setUseFixedLayout(bool fixed)
+{
+ if (!isValid())
+ return;
+
+ // This check is fine as the value is initialized in the web
+ // process as part of the creation parameters.
+ if (fixed == m_useFixedLayout)
+ return;
+
+ m_useFixedLayout = fixed;
+ if (!fixed)
+ m_fixedLayoutSize = IntSize();
+ process()->send(Messages::WebPage::SetUseFixedLayout(fixed), m_pageID);
+}
+
+void WebPageProxy::setFixedLayoutSize(const IntSize& size)
+{
+ if (!isValid())
+ return;
+
+ if (size == m_fixedLayoutSize)
+ return;
+
+ m_fixedLayoutSize = size;
+ process()->send(Messages::WebPage::SetFixedLayoutSize(size), m_pageID);
+}
+
+void WebPageProxy::setPaginationMode(WebCore::Page::Pagination::Mode mode)
+{
+ if (mode == m_paginationMode)
+ return;
+
+ m_paginationMode = mode;
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetPaginationMode(mode), m_pageID);
+}
+
+void WebPageProxy::setPageLength(double pageLength)
+{
+ if (pageLength == m_pageLength)
+ return;
+
+ m_pageLength = pageLength;
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetPageLength(pageLength), m_pageID);
+}
+
+void WebPageProxy::setGapBetweenPages(double gap)
+{
+ if (gap == m_gapBetweenPages)
+ return;
+
+ m_gapBetweenPages = gap;
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetGapBetweenPages(gap), m_pageID);
+}
+
+void WebPageProxy::pageScaleFactorDidChange(double scaleFactor)
+{
+ m_pageScaleFactor = scaleFactor;
+}
+
+void WebPageProxy::setMemoryCacheClientCallsEnabled(bool memoryCacheClientCallsEnabled)
+{
+ if (!isValid())
+ return;
+
+ if (m_areMemoryCacheClientCallsEnabled == memoryCacheClientCallsEnabled)
+ return;
+
+ m_areMemoryCacheClientCallsEnabled = memoryCacheClientCallsEnabled;
+ process()->send(Messages::WebPage::SetMemoryCacheMessagesEnabled(memoryCacheClientCallsEnabled), m_pageID);
+}
+
+void WebPageProxy::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ if (m_mainFrameHasCustomRepresentation)
+ m_pageClient->findStringInCustomRepresentation(string, options, maxMatchCount);
+ else
+ process()->send(Messages::WebPage::FindString(string, options, maxMatchCount), m_pageID);
+}
+
+void WebPageProxy::hideFindUI()
+{
+ process()->send(Messages::WebPage::HideFindUI(), m_pageID);
+}
+
+void WebPageProxy::countStringMatches(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ if (m_mainFrameHasCustomRepresentation) {
+ m_pageClient->countStringMatchesInCustomRepresentation(string, options, maxMatchCount);
+ return;
+ }
+
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
+}
+
+void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<ScriptValueCallback> prpCallback)
+{
+ RefPtr<ScriptValueCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_scriptValueCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
+}
+
+void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_stringCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetRenderTreeExternalRepresentation(callbackID), m_pageID);
+}
+
+void WebPageProxy::getSourceForFrame(WebFrameProxy* frame, PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ m_stringCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetSourceForFrame(frame->frameID(), callbackID), m_pageID);
+}
+
+void WebPageProxy::getContentsAsString(PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_loadDependentStringCallbackIDs.add(callbackID);
+ m_stringCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetContentsAsString(callbackID), m_pageID);
+}
+
+void WebPageProxy::getSelectionOrContentsAsString(PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_stringCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetSelectionOrContentsAsString(callbackID), m_pageID);
+}
+
+void WebPageProxy::getMainResourceDataOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
+}
+
+void WebPageProxy::getResourceDataFromFrame(WebFrameProxy* frame, WebURL* resourceURL, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetResourceDataFromFrame(frame->frameID(), resourceURL->string(), callbackID), m_pageID);
+}
+
+void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), callbackID), m_pageID);
+}
+
+void WebPageProxy::forceRepaint(PassRefPtr<VoidCallback> prpCallback)
+{
+ RefPtr<VoidCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_voidCallbacks.set(callbackID, callback.get());
+ m_drawingArea->waitForBackingStoreUpdateOnNextPaint();
+ process()->send(Messages::WebPage::ForceRepaint(callbackID), m_pageID);
+}
+
+void WebPageProxy::preferencesDidChange()
+{
+ if (!isValid())
+ return;
+
+ // FIXME: It probably makes more sense to send individual preference changes.
+ // However, WebKitTestRunner depends on getting a preference change notification
+ // even if nothing changed in UI process, so that overrides get removed.
+
+ // Preferences need to be updated during synchronous printing to make "print backgrounds" preference work when toggled from a print dialog checkbox.
+ process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+
+void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
+ m_drawingArea->didReceiveDrawingAreaProxyMessage(connection, messageID, arguments);
+ return;
+ }
+
+#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER)
+ if (messageID.is<CoreIPC::MessageClassLayerTreeHostProxy>()) {
+ m_drawingArea->didReceiveLayerTreeHostProxyMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
+#if ENABLE(INSPECTOR)
+ if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
+ if (WebInspectorProxy* inspector = this->inspector())
+ inspector->didReceiveWebInspectorProxyMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
+ fullScreenManager()->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
+ didReceiveWebPageProxyMessage(connection, messageID, arguments);
+}
+
+void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+#if ENABLE(INSPECTOR)
+ if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
+ if (WebInspectorProxy* inspector = this->inspector())
+ inspector->didReceiveSyncWebInspectorProxyMessage(connection, messageID, arguments, reply);
+ return;
+ }
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ if (messageID.is<CoreIPC::MessageClassWebFullScreenManagerProxy>()) {
+ fullScreenManager()->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return;
+ }
+#endif
+
+ // FIXME: Do something with reply.
+ didReceiveSyncWebPageProxyMessage(connection, messageID, arguments, reply);
+}
+
+void WebPageProxy::didCreateMainFrame(uint64_t frameID)
+{
+ MESSAGE_CHECK(!m_mainFrame);
+ MESSAGE_CHECK(process()->canCreateFrame(frameID));
+
+ m_mainFrame = WebFrameProxy::create(this, frameID);
+
+ // Add the frame to the process wide map.
+ process()->frameCreated(frameID, m_mainFrame.get());
+}
+
+void WebPageProxy::didCreateSubframe(uint64_t frameID, uint64_t parentFrameID)
+{
+ MESSAGE_CHECK(m_mainFrame);
+
+ WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
+ MESSAGE_CHECK(parentFrame);
+ MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
+
+ MESSAGE_CHECK(process()->canCreateFrame(frameID));
+
+ RefPtr<WebFrameProxy> subFrame = WebFrameProxy::create(this, frameID);
+
+ // Add the frame to the process wide map.
+ process()->frameCreated(frameID, subFrame.get());
+
+ // Insert the frame into the frame hierarchy.
+ parentFrame->appendChild(subFrame.get());
+}
+
+static bool isDisconnectedFrame(WebFrameProxy* frame)
+{
+ return !frame->page() || !frame->page()->mainFrame() || !frame->isDescendantOf(frame->page()->mainFrame());
+}
+
+void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID)
+{
+ MESSAGE_CHECK(m_mainFrame);
+
+ WebFrameProxy* subframe = process()->webFrame(frameID);
+ MESSAGE_CHECK(subframe);
+
+ if (isDisconnectedFrame(subframe))
+ return;
+
+ MESSAGE_CHECK(subframe->isDescendantOf(m_mainFrame.get()));
+
+ subframe->didRemoveFromHierarchy();
+}
+
+void WebPageProxy::didRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID)
+{
+ MESSAGE_CHECK(m_mainFrame);
+
+ WebFrameProxy* subframe = process()->webFrame(frameID);
+ MESSAGE_CHECK(subframe);
+ MESSAGE_CHECK(!subframe->parentFrame());
+ MESSAGE_CHECK(subframe->page() == m_mainFrame->page());
+
+ WebFrameProxy* parentFrame = process()->webFrame(parentFrameID);
+ MESSAGE_CHECK(parentFrame);
+ MESSAGE_CHECK(parentFrame->isDescendantOf(m_mainFrame.get()));
+
+ // Insert the frame into the frame hierarchy.
+ parentFrame->appendChild(subframe);
+}
+
+
+// Always start progress at initialProgressValue. This helps provide feedback as
+// soon as a load starts.
+
+static const double initialProgressValue = 0.1;
+
+double WebPageProxy::estimatedProgress() const
+{
+ if (!pendingAPIRequestURL().isNull())
+ return initialProgressValue;
+ return m_estimatedProgress;
+}
+
+void WebPageProxy::didStartProgress()
+{
+ m_estimatedProgress = initialProgressValue;
+
+ m_loaderClient.didStartProgress(this);
+}
+
+void WebPageProxy::didChangeProgress(double value)
+{
+ m_estimatedProgress = value;
+
+ m_loaderClient.didChangeProgress(this);
+}
+
+void WebPageProxy::didFinishProgress()
+{
+ m_estimatedProgress = 1.0;
+
+ m_loaderClient.didFinishProgress(this);
+}
+
+void WebPageProxy::didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, const String& unreachableURL, CoreIPC::ArgumentDecoder* arguments)
+{
+ clearPendingAPIRequestURL();
+
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(url);
+
+ frame->setUnreachableURL(unreachableURL);
+
+ frame->didStartProvisionalLoad(url);
+ m_loaderClient.didStartProvisionalLoadForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String& url, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(url);
+
+ frame->didReceiveServerRedirectForProvisionalLoad(url);
+
+ m_loaderClient.didReceiveServerRedirectForProvisionalLoadForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didFailProvisionalLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ frame->didFailProvisionalLoad();
+
+ m_loaderClient.didFailProvisionalLoadWithErrorForFrame(this, frame, error, userData.get());
+}
+
+void WebPageProxy::clearLoadDependentCallbacks()
+{
+ Vector<uint64_t> callbackIDsCopy;
+ copyToVector(m_loadDependentStringCallbackIDs, callbackIDsCopy);
+ m_loadDependentStringCallbackIDs.clear();
+
+ for (size_t i = 0; i < callbackIDsCopy.size(); ++i) {
+ RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackIDsCopy[i]);
+ if (callback)
+ callback->invalidate();
+ }
+}
+
+void WebPageProxy::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+#if PLATFORM(MAC)
+ // FIXME (bug 59111): didCommitLoadForFrame comes too late when restoring a page from b/f cache, making us disable secure event mode in password fields.
+ // FIXME (bug 59121): A load going on in one frame shouldn't affect typing in sibling frames.
+ m_pageClient->resetTextInputState();
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ // FIXME: Should this be moved inside resetTextInputState()?
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
+ m_pageClient->dismissDictionaryLookupPanel();
+#endif
+#endif
+
+ clearLoadDependentCallbacks();
+
+ frame->didCommitLoad(mimeType, certificateInfo);
+
+ if (frame->isMainFrame()) {
+ m_mainFrameHasCustomRepresentation = frameHasCustomRepresentation;
+ m_pageClient->didCommitLoadForMainFrame(frameHasCustomRepresentation);
+ }
+
+ m_loaderClient.didCommitLoadForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didFinishDocumentLoadForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ frame->didFinishLoad();
+
+ m_loaderClient.didFinishLoadForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didFailLoadForFrame(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ clearLoadDependentCallbacks();
+
+ frame->didFailLoad();
+
+ m_loaderClient.didFailLoadWithErrorForFrame(this, frame, error, userData.get());
+}
+
+void WebPageProxy::didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t opaqueSameDocumentNavigationType, const String& url, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(url);
+
+ clearPendingAPIRequestURL();
+ frame->didSameDocumentNavigation(url);
+
+ m_loaderClient.didSameDocumentNavigationForFrame(this, frame, static_cast<SameDocumentNavigationType>(opaqueSameDocumentNavigationType), userData.get());
+}
+
+void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String& title, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ frame->didChangeTitle(title);
+
+ m_loaderClient.didReceiveTitleForFrame(this, title, frame, userData.get());
+}
+
+void WebPageProxy::didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didFirstLayoutForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didFirstVisuallyNonEmptyLayoutForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ frame->didRemoveFromHierarchy();
+
+ m_loaderClient.didRemoveFrameFromHierarchy(this, frame, userData.get());
+}
+
+void WebPageProxy::didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didDisplayInsecureContentForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didDetectXSSForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didDetectXSSForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::frameDidBecomeFrameSet(uint64_t frameID, bool value)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ frame->setIsFrameSet(value);
+ if (frame->isMainFrame())
+ m_frameSetLargestFrame = value ? m_mainFrame : 0;
+}
+
+// PolicyClient
+void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ if (request.url() != pendingAPIRequestURL())
+ clearPendingAPIRequestURL();
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(request.url());
+
+ NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
+ WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
+ WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
+
+ RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
+
+ ASSERT(!m_inDecidePolicyForNavigationAction);
+
+ m_inDecidePolicyForNavigationAction = true;
+ m_syncNavigationActionPolicyActionIsValid = false;
+
+ if (!m_policyClient.decidePolicyForNavigationAction(this, frame, navigationType, modifiers, mouseButton, request, listener.get(), userData.get()))
+ listener->use();
+
+ m_inDecidePolicyForNavigationAction = false;
+
+ // Check if we received a policy decision already. If we did, we can just pass it back.
+ receivedPolicyAction = m_syncNavigationActionPolicyActionIsValid;
+ if (m_syncNavigationActionPolicyActionIsValid) {
+ policyAction = m_syncNavigationActionPolicyAction;
+ downloadID = m_syncNavigationActionPolicyDownloadID;
+ }
+}
+
+void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(request.url());
+
+ NavigationType navigationType = static_cast<NavigationType>(opaqueNavigationType);
+ WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
+ WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
+
+ RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
+ if (!m_policyClient.decidePolicyForNewWindowAction(this, frame, navigationType, modifiers, mouseButton, request, frameName, listener.get(), userData.get()))
+ listener->use();
+}
+
+void WebPageProxy::decidePolicyForResponse(uint64_t frameID, const ResourceResponse& response, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(request.url());
+ MESSAGE_CHECK_URL(response.url());
+
+ RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
+
+ ASSERT(!m_inDecidePolicyForResponse);
+
+ m_inDecidePolicyForResponse = true;
+ m_syncMimeTypePolicyActionIsValid = false;
+
+ if (!m_policyClient.decidePolicyForResponse(this, frame, response, request, listener.get(), userData.get()))
+ listener->use();
+
+ m_inDecidePolicyForResponse = false;
+
+ // Check if we received a policy decision already. If we did, we can just pass it back.
+ receivedPolicyAction = m_syncMimeTypePolicyActionIsValid;
+ if (m_syncMimeTypePolicyActionIsValid) {
+ policyAction = m_syncMimeTypePolicyAction;
+ downloadID = m_syncMimeTypePolicyDownloadID;
+ }
+}
+
+void WebPageProxy::unableToImplementPolicy(uint64_t frameID, const ResourceError& error, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_policyClient.unableToImplementPolicy(this, frame, error, userData.get());
+}
+
+// FormClient
+
+void WebPageProxy::willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ WebFrameProxy* sourceFrame = process()->webFrame(sourceFrameID);
+ MESSAGE_CHECK(sourceFrame);
+
+ RefPtr<WebFormSubmissionListenerProxy> listener = frame->setUpFormSubmissionListenerProxy(listenerID);
+ if (!m_formClient.willSubmitForm(this, frame, sourceFrame, textFieldValues.stringPairVector(), userData.get(), listener.get()))
+ listener->continueSubmission();
+}
+
+// ResourceLoad Client
+
+void WebPageProxy::didInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, bool pageIsProvisionallyLoading)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(request.url());
+
+ m_resourceLoadClient.didInitiateLoadForResource(this, frame, resourceIdentifier, request, pageIsProvisionallyLoading);
+}
+
+void WebPageProxy::didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(request.url());
+
+ m_resourceLoadClient.didSendRequestForResource(this, frame, resourceIdentifier, request, redirectResponse);
+}
+
+void WebPageProxy::didReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceResponse& response)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+ MESSAGE_CHECK_URL(response.url());
+
+ m_resourceLoadClient.didReceiveResponseForResource(this, frame, resourceIdentifier, response);
+}
+
+void WebPageProxy::didReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_resourceLoadClient.didReceiveContentLengthForResource(this, frame, resourceIdentifier, contentLength);
+}
+
+void WebPageProxy::didFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_resourceLoadClient.didFinishLoadForResource(this, frame, resourceIdentifier);
+}
+
+void WebPageProxy::didFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceError& error)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_resourceLoadClient.didFailLoadForResource(this, frame, resourceIdentifier, error);
+}
+
+// UIClient
+
+void WebPageProxy::createNewPage(const ResourceRequest& request, const WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
+{
+ RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, request, windowFeatures, static_cast<WebEvent::Modifiers>(opaqueModifiers), static_cast<WebMouseEvent::Button>(opaqueMouseButton));
+ if (newPage) {
+ newPageID = newPage->pageID();
+ newPageParameters = newPage->creationParameters();
+ } else
+ newPageID = 0;
+}
+
+void WebPageProxy::showPage()
+{
+ m_uiClient.showPage(this);
+}
+
+void WebPageProxy::closePage(bool stopResponsivenessTimer)
+{
+ if (stopResponsivenessTimer)
+ process()->responsivenessTimer()->stop();
+
+ m_pageClient->clearAllEditCommands();
+ m_uiClient.close(this);
+}
+
+void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ // Since runJavaScriptAlert() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ m_uiClient.runJavaScriptAlert(this, message, frame);
+}
+
+void WebPageProxy::runJavaScriptConfirm(uint64_t frameID, const String& message, bool& result)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ // Since runJavaScriptConfirm() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ result = m_uiClient.runJavaScriptConfirm(this, message, frame);
+}
+
+void WebPageProxy::runJavaScriptPrompt(uint64_t frameID, const String& message, const String& defaultValue, String& result)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ // Since runJavaScriptPrompt() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
+}
+
+void WebPageProxy::shouldInterruptJavaScript(bool& result)
+{
+ // Since shouldInterruptJavaScript() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ result = m_uiClient.shouldInterruptJavaScript(this);
+}
+
+void WebPageProxy::setStatusText(const String& text)
+{
+ m_uiClient.setStatusText(this, text);
+}
+
+void WebPageProxy::mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
+
+ m_uiClient.mouseDidMoveOverElement(this, hitTestResultData, modifiers, userData.get());
+}
+
+void WebPageProxy::missingPluginButtonClicked(const String& mimeType, const String& url, const String& pluginsPageURL)
+{
+ MESSAGE_CHECK_URL(url);
+ MESSAGE_CHECK_URL(pluginsPageURL);
+
+ m_uiClient.missingPluginButtonClicked(this, mimeType, url, pluginsPageURL);
+}
+
+void WebPageProxy::setToolbarsAreVisible(bool toolbarsAreVisible)
+{
+ m_uiClient.setToolbarsAreVisible(this, toolbarsAreVisible);
+}
+
+void WebPageProxy::getToolbarsAreVisible(bool& toolbarsAreVisible)
+{
+ toolbarsAreVisible = m_uiClient.toolbarsAreVisible(this);
+}
+
+void WebPageProxy::setMenuBarIsVisible(bool menuBarIsVisible)
+{
+ m_uiClient.setMenuBarIsVisible(this, menuBarIsVisible);
+}
+
+void WebPageProxy::getMenuBarIsVisible(bool& menuBarIsVisible)
+{
+ menuBarIsVisible = m_uiClient.menuBarIsVisible(this);
+}
+
+void WebPageProxy::setStatusBarIsVisible(bool statusBarIsVisible)
+{
+ m_uiClient.setStatusBarIsVisible(this, statusBarIsVisible);
+}
+
+void WebPageProxy::getStatusBarIsVisible(bool& statusBarIsVisible)
+{
+ statusBarIsVisible = m_uiClient.statusBarIsVisible(this);
+}
+
+void WebPageProxy::setIsResizable(bool isResizable)
+{
+ m_uiClient.setIsResizable(this, isResizable);
+}
+
+void WebPageProxy::getIsResizable(bool& isResizable)
+{
+ isResizable = m_uiClient.isResizable(this);
+}
+
+void WebPageProxy::setWindowFrame(const FloatRect& newWindowFrame)
+{
+ m_uiClient.setWindowFrame(this, m_pageClient->convertToDeviceSpace(newWindowFrame));
+}
+
+void WebPageProxy::getWindowFrame(FloatRect& newWindowFrame)
+{
+ newWindowFrame = m_pageClient->convertToUserSpace(m_uiClient.windowFrame(this));
+}
+
+void WebPageProxy::screenToWindow(const IntPoint& screenPoint, IntPoint& windowPoint)
+{
+ windowPoint = m_pageClient->screenToWindow(screenPoint);
+}
+
+void WebPageProxy::windowToScreen(const IntRect& viewRect, IntRect& result)
+{
+ result = m_pageClient->windowToScreen(viewRect);
+}
+
+void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ // Since runBeforeUnloadConfirmPanel() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
+}
+
+#if USE(TILED_BACKING_STORE)
+void WebPageProxy::pageDidRequestScroll(const IntPoint& point)
+{
+ m_pageClient->pageDidRequestScroll(point);
+}
+#endif
+
+void WebPageProxy::didChangeViewportProperties(const ViewportArguments& args)
+{
+ m_pageClient->didChangeViewportProperties(args);
+}
+
+void WebPageProxy::pageDidScroll()
+{
+ m_uiClient.pageDidScroll(this);
+#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
+#endif
+}
+
+void WebPageProxy::runOpenPanel(uint64_t frameID, const FileChooserSettings& settings)
+{
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+ }
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(settings);
+ m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
+
+ // Since runOpenPanel() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ if (!m_uiClient.runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
+ didCancelForOpenPanel();
+}
+
+void WebPageProxy::printFrame(uint64_t frameID)
+{
+ ASSERT(!m_isPerformingDOMPrintOperation);
+ m_isPerformingDOMPrintOperation = true;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_uiClient.printFrame(this, frame);
+
+ m_isPerformingDOMPrintOperation = false;
+}
+
+void WebPageProxy::printMainFrame()
+{
+ printFrame(m_mainFrame->frameID());
+}
+
+#if PLATFORM(QT)
+void WebPageProxy::didChangeContentsSize(const IntSize& size)
+{
+ m_pageClient->didChangeContentsSize(size);
+}
+
+void WebPageProxy::didFindZoomableArea(const IntPoint& target, const IntRect& area)
+{
+ m_pageClient->didFindZoomableArea(target, area);
+}
+
+void WebPageProxy::focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area)
+{
+ m_pageClient->focusEditableArea(caret, area);
+}
+
+void WebPageProxy::findZoomableAreaForPoint(const IntPoint& point)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::FindZoomableAreaForPoint(point), m_pageID);
+}
+
+void WebPageProxy::didReceiveMessageFromNavigatorQtObject(const String& contents)
+{
+ m_pageClient->didReceiveMessageFromNavigatorQtObject(contents);
+}
+
+void WebPageProxy::handleDownloadRequest(DownloadProxy* download)
+{
+ m_pageClient->handleDownloadRequest(download);
+}
+#endif
+
+#if ENABLE(TOUCH_EVENTS)
+void WebPageProxy::needTouchEvents(bool needTouchEvents)
+{
+ m_needTouchEvents = needTouchEvents;
+}
+#endif
+
+void WebPageProxy::didDraw()
+{
+ m_uiClient.didDraw(this);
+}
+
+// Inspector
+
+#if ENABLE(INSPECTOR)
+
+WebInspectorProxy* WebPageProxy::inspector()
+{
+ if (isClosed() || !isValid())
+ return 0;
+ if (!m_inspector)
+ m_inspector = WebInspectorProxy::create(this);
+ return m_inspector.get();
+}
+
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+WebFullScreenManagerProxy* WebPageProxy::fullScreenManager()
+{
+ if (!m_fullScreenManager)
+ m_fullScreenManager = WebFullScreenManagerProxy::create(this);
+ return m_fullScreenManager.get();
+}
+#endif
+
+// BackForwardList
+
+void WebPageProxy::backForwardAddItem(uint64_t itemID)
+{
+ m_backForwardList->addItem(process()->webBackForwardItem(itemID));
+}
+
+void WebPageProxy::backForwardGoToItem(uint64_t itemID)
+{
+ m_backForwardList->goToItem(process()->webBackForwardItem(itemID));
+}
+
+void WebPageProxy::backForwardItemAtIndex(int32_t index, uint64_t& itemID)
+{
+ WebBackForwardListItem* item = m_backForwardList->itemAtIndex(index);
+ itemID = item ? item->itemID() : 0;
+}
+
+void WebPageProxy::backForwardBackListCount(int32_t& count)
+{
+ count = m_backForwardList->backListCount();
+}
+
+void WebPageProxy::backForwardForwardListCount(int32_t& count)
+{
+ count = m_backForwardList->forwardListCount();
+}
+
+void WebPageProxy::editorStateChanged(const EditorState& editorState)
+{
+#if PLATFORM(MAC)
+ bool couldChangeSecureInputState = m_editorState.isInPasswordField != editorState.isInPasswordField || m_editorState.selectionIsNone;
+#endif
+
+ m_editorState = editorState;
+
+#if PLATFORM(MAC)
+ m_pageClient->updateTextInputState(couldChangeSecureInputState);
+#endif
+}
+
+// Undo management
+
+void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
+{
+ registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
+}
+
+void WebPageProxy::canUndoRedo(uint32_t action, bool& result)
+{
+ result = m_pageClient->canUndoRedo(static_cast<UndoOrRedo>(action));
+}
+
+void WebPageProxy::executeUndoRedo(uint32_t action, bool& result)
+{
+ m_pageClient->executeUndoRedo(static_cast<UndoOrRedo>(action));
+ result = true;
+}
+
+void WebPageProxy::clearAllEditCommands()
+{
+ m_pageClient->clearAllEditCommands();
+}
+
+void WebPageProxy::didCountStringMatches(const String& string, uint32_t matchCount)
+{
+ m_findClient.didCountStringMatches(this, string, matchCount);
+}
+
+void WebPageProxy::setFindIndicator(const FloatRect& selectionRectInWindowCoordinates, const Vector<FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate)
+{
+ RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRectInWindowCoordinates, textRectsInSelectionRectCoordinates, contentImageScaleFactor, contentImageHandle);
+ m_pageClient->setFindIndicator(findIndicator.release(), fadeOut, animate);
+}
+
+void WebPageProxy::didFindString(const String& string, uint32_t matchCount)
+{
+ m_findClient.didFindString(this, string, matchCount);
+}
+
+void WebPageProxy::didFailToFindString(const String& string)
+{
+ m_findClient.didFailToFindString(this, string);
+}
+
+void WebPageProxy::valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex)
+{
+ process()->send(Messages::WebPage::DidChangeSelectedIndexForActivePopupMenu(newSelectedIndex), m_pageID);
+}
+
+void WebPageProxy::setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index)
+{
+ process()->send(Messages::WebPage::SetTextForActivePopupMenu(index), m_pageID);
+}
+
+NativeWebMouseEvent* WebPageProxy::currentlyProcessedMouseDownEvent()
+{
+ return m_currentlyProcessedMouseDownEvent.get();
+}
+
+#if PLATFORM(GTK)
+void WebPageProxy::failedToShowPopupMenu()
+{
+ process()->send(Messages::WebPage::FailedToShowPopupMenu(), m_pageID);
+}
+#endif
+
+void WebPageProxy::showPopupMenu(const IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
+{
+ if (m_activePopupMenu) {
+ m_activePopupMenu->hidePopupMenu();
+ m_activePopupMenu->invalidate();
+ m_activePopupMenu = 0;
+ }
+
+ m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
+
+ // Since showPopupMenu() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ RefPtr<WebPopupMenuProxy> protectedActivePopupMenu = m_activePopupMenu;
+
+ protectedActivePopupMenu->showPopupMenu(rect, static_cast<TextDirection>(textDirection), m_pageScaleFactor, items, data, selectedIndex);
+
+ // Since Qt doesn't use a nested mainloop the show the popup and get the answer, we need to keep the client pointer valid.
+#if !PLATFORM(QT)
+ protectedActivePopupMenu->invalidate();
+#endif
+ protectedActivePopupMenu = 0;
+}
+
+void WebPageProxy::hidePopupMenu()
+{
+ if (!m_activePopupMenu)
+ return;
+
+ m_activePopupMenu->hidePopupMenu();
+ m_activePopupMenu->invalidate();
+ m_activePopupMenu = 0;
+}
+
+void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const ContextMenuState& contextMenuState, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
+{
+ internalShowContextMenu(menuLocation, contextMenuState, proposedItems, arguments);
+
+ // No matter the result of internalShowContextMenu, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
+ process()->send(Messages::WebPage::ContextMenuHidden(), m_pageID);
+}
+
+void WebPageProxy::internalShowContextMenu(const IntPoint& menuLocation, const ContextMenuState& contextMenuState, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, m_process->context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ m_activeContextMenuState = contextMenuState;
+
+ if (m_activeContextMenu) {
+ m_activeContextMenu->hideContextMenu();
+ m_activeContextMenu = 0;
+ }
+
+ m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
+
+ // Since showContextMenu() can spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ // Give the PageContextMenuClient one last swipe at changing the menu.
+ Vector<WebContextMenuItemData> items;
+ if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, userData.get()))
+ m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
+ else
+ m_activeContextMenu->showContextMenu(menuLocation, items);
+
+ m_contextMenuClient.contextMenuDismissed(this);
+}
+
+void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
+{
+ // Application custom items don't need to round-trip through to WebCore in the WebProcess.
+ if (item.action() >= ContextMenuItemBaseApplicationTag) {
+ m_contextMenuClient.customContextMenuItemSelected(this, item);
+ return;
+ }
+
+#if PLATFORM(MAC)
+ if (item.action() == ContextMenuItemTagSmartCopyPaste) {
+ setSmartInsertDeleteEnabled(!isSmartInsertDeleteEnabled());
+ return;
+ }
+ if (item.action() == ContextMenuItemTagSmartQuotes) {
+ TextChecker::setAutomaticQuoteSubstitutionEnabled(!TextChecker::state().isAutomaticQuoteSubstitutionEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagSmartDashes) {
+ TextChecker::setAutomaticDashSubstitutionEnabled(!TextChecker::state().isAutomaticDashSubstitutionEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagSmartLinks) {
+ TextChecker::setAutomaticLinkDetectionEnabled(!TextChecker::state().isAutomaticLinkDetectionEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagTextReplacement) {
+ TextChecker::setAutomaticTextReplacementEnabled(!TextChecker::state().isAutomaticTextReplacementEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagCorrectSpellingAutomatically) {
+ TextChecker::setAutomaticSpellingCorrectionEnabled(!TextChecker::state().isAutomaticSpellingCorrectionEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagShowSubstitutions) {
+ TextChecker::toggleSubstitutionsPanelIsShowing();
+ return;
+ }
+#endif
+ if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
+ m_process->context()->download(this, KURL(KURL(), m_activeContextMenuState.absoluteImageURLString));
+ return;
+ }
+ if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
+ m_process->context()->download(this, KURL(KURL(), m_activeContextMenuState.absoluteLinkURLString));
+ return;
+ }
+ if (item.action() == ContextMenuItemTagCheckSpellingWhileTyping) {
+ TextChecker::setContinuousSpellCheckingEnabled(!TextChecker::state().isContinuousSpellCheckingEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagCheckGrammarWithSpelling) {
+ TextChecker::setGrammarCheckingEnabled(!TextChecker::state().isGrammarCheckingEnabled);
+ process()->updateTextCheckerState();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagShowSpellingPanel) {
+ if (!TextChecker::spellingUIIsShowing())
+ advanceToNextMisspelling(true);
+ TextChecker::toggleSpellingUIIsShowing();
+ return;
+ }
+ if (item.action() == ContextMenuItemTagLearnSpelling || item.action() == ContextMenuItemTagIgnoreSpelling)
+ ++m_pendingLearnOrIgnoreWordMessageCount;
+
+ process()->send(Messages::WebPage::DidSelectItemFromActiveContextMenu(item), m_pageID);
+}
+
+void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
+{
+ if (!isValid())
+ return;
+
+#if ENABLE(WEB_PROCESS_SANDBOX)
+ // FIXME: The sandbox extensions should be sent with the DidChooseFilesForOpenPanel message. This
+ // is gated on a way of passing SandboxExtension::Handles in a Vector.
+ for (size_t i = 0; i < fileURLs.size(); ++i) {
+ SandboxExtension::Handle sandboxExtensionHandle;
+ SandboxExtension::createHandle(fileURLs[i], SandboxExtension::ReadOnly, sandboxExtensionHandle);
+ process()->send(Messages::WebPage::ExtendSandboxForFileFromOpenPanel(sandboxExtensionHandle), m_pageID);
+ }
+#endif
+
+ process()->send(Messages::WebPage::DidChooseFilesForOpenPanel(fileURLs), m_pageID);
+
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+}
+
+void WebPageProxy::didCancelForOpenPanel()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::DidCancelForOpenPanel(), m_pageID);
+
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+}
+
+void WebPageProxy::advanceToNextMisspelling(bool startBeforeSelection) const
+{
+ process()->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
+}
+
+void WebPageProxy::changeSpellingToWord(const String& word) const
+{
+ if (word.isEmpty())
+ return;
+
+ process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
+}
+
+void WebPageProxy::registerEditCommand(PassRefPtr<WebEditCommandProxy> commandProxy, UndoOrRedo undoOrRedo)
+{
+ m_pageClient->registerEditCommand(commandProxy, undoOrRedo);
+}
+
+void WebPageProxy::addEditCommand(WebEditCommandProxy* command)
+{
+ m_editCommandSet.add(command);
+}
+
+void WebPageProxy::removeEditCommand(WebEditCommandProxy* command)
+{
+ m_editCommandSet.remove(command);
+
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::DidRemoveEditCommand(command->commandID()), m_pageID);
+}
+
+bool WebPageProxy::isValidEditCommand(WebEditCommandProxy* command)
+{
+ return m_editCommandSet.find(command) != m_editCommandSet.end();
+}
+
+int64_t WebPageProxy::spellDocumentTag()
+{
+ if (!m_hasSpellDocumentTag) {
+ m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag(this);
+ m_hasSpellDocumentTag = true;
+ }
+
+ return m_spellDocumentTag;
+}
+
+#if USE(UNIFIED_TEXT_CHECKING)
+void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
+{
+ results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
+}
+#endif
+
+void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
+{
+ TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
+}
+
+void WebPageProxy::checkGrammarOfString(const String& text, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
+{
+ TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
+}
+
+void WebPageProxy::spellingUIIsShowing(bool& isShowing)
+{
+ isShowing = TextChecker::spellingUIIsShowing();
+}
+
+void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ TextChecker::updateSpellingUIWithMisspelledWord(spellDocumentTag(), misspelledWord);
+}
+
+void WebPageProxy::updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+{
+ TextChecker::updateSpellingUIWithGrammarString(spellDocumentTag(), badGrammarPhrase, grammarDetail);
+}
+
+void WebPageProxy::getGuessesForWord(const String& word, const String& context, Vector<String>& guesses)
+{
+ TextChecker::getGuessesForWord(spellDocumentTag(), word, context, guesses);
+}
+
+void WebPageProxy::learnWord(const String& word)
+{
+ MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
+ --m_pendingLearnOrIgnoreWordMessageCount;
+
+ TextChecker::learnWord(spellDocumentTag(), word);
+}
+
+void WebPageProxy::ignoreWord(const String& word)
+{
+ MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
+ --m_pendingLearnOrIgnoreWordMessageCount;
+
+ TextChecker::ignoreWord(spellDocumentTag(), word);
+}
+
+// Other
+
+void WebPageProxy::setFocus(bool focused)
+{
+ if (focused)
+ m_uiClient.focus(this);
+ else
+ m_uiClient.unfocus(this);
+}
+
+void WebPageProxy::takeFocus(uint32_t direction)
+{
+ m_uiClient.takeFocus(this, (static_cast<FocusDirection>(direction) == FocusDirectionForward) ? kWKFocusDirectionForward : kWKFocusDirectionBackward);
+}
+
+void WebPageProxy::setToolTip(const String& toolTip)
+{
+ String oldToolTip = m_toolTip;
+ m_toolTip = toolTip;
+ m_pageClient->toolTipChanged(oldToolTip, m_toolTip);
+}
+
+void WebPageProxy::setCursor(const WebCore::Cursor& cursor)
+{
+ m_pageClient->setCursor(cursor);
+}
+
+void WebPageProxy::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+ m_pageClient->setCursorHiddenUntilMouseMoves(hiddenUntilMouseMoves);
+}
+
+#if MERGE_WHEEL_EVENTS
+static bool canCoalesce(const WebWheelEvent& a, const WebWheelEvent& b)
+{
+ if (a.position() != b.position())
+ return false;
+ if (a.globalPosition() != b.globalPosition())
+ return false;
+ if (a.modifiers() != b.modifiers())
+ return false;
+ if (a.granularity() != b.granularity())
+ return false;
+#if PLATFORM(MAC)
+ if (a.phase() != b.phase())
+ return false;
+ if (a.momentumPhase() != b.momentumPhase())
+ return false;
+ if (a.hasPreciseScrollingDeltas() != b.hasPreciseScrollingDeltas())
+ return false;
+#endif
+
+ return true;
+}
+
+static WebWheelEvent coalesce(const WebWheelEvent& a, const WebWheelEvent& b)
+{
+ ASSERT(canCoalesce(a, b));
+
+ FloatSize mergedDelta = a.delta() + b.delta();
+ FloatSize mergedWheelTicks = a.wheelTicks() + b.wheelTicks();
+
+#if PLATFORM(MAC)
+ return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.phase(), b.momentumPhase(), b.hasPreciseScrollingDeltas(), b.modifiers(), b.timestamp(), b.directionInvertedFromDevice());
+#else
+ return WebWheelEvent(WebEvent::Wheel, b.position(), b.globalPosition(), mergedDelta, mergedWheelTicks, b.granularity(), b.modifiers(), b.timestamp());
+#endif
+}
+#endif
+
+static WebWheelEvent coalescedWheelEvent(Deque<NativeWebWheelEvent>& queue, Vector<NativeWebWheelEvent>& coalescedEvents)
+{
+ ASSERT(!queue.isEmpty());
+ ASSERT(coalescedEvents.isEmpty());
+
+#if MERGE_WHEEL_EVENTS
+ NativeWebWheelEvent firstEvent = queue.takeFirst();
+ coalescedEvents.append(firstEvent);
+
+ WebWheelEvent event = firstEvent;
+ while (!queue.isEmpty() && canCoalesce(event, queue.first())) {
+ NativeWebWheelEvent firstEvent = queue.takeFirst();
+ coalescedEvents.append(firstEvent);
+ event = coalesce(event, firstEvent);
+ }
+
+ return event;
+#else
+ while (!queue.isEmpty())
+ coalescedEvents.append(queue.takeFirst());
+ return coalescedEvents.last();
+#endif
+}
+
+void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
+{
+ WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
+
+ switch (type) {
+ case WebEvent::NoType:
+ case WebEvent::MouseMove:
+ break;
+
+ case WebEvent::MouseDown:
+ case WebEvent::MouseUp:
+ case WebEvent::Wheel:
+ case WebEvent::KeyDown:
+ case WebEvent::KeyUp:
+ case WebEvent::RawKeyDown:
+ case WebEvent::Char:
+#if ENABLE(GESTURE_EVENTS)
+ case WebEvent::GestureScrollBegin:
+ case WebEvent::GestureScrollEnd:
+ case WebEvent::GestureSingleTap:
+#endif
+#if ENABLE(TOUCH_EVENTS)
+ case WebEvent::TouchStart:
+ case WebEvent::TouchMove:
+ case WebEvent::TouchEnd:
+ case WebEvent::TouchCancel:
+#endif
+ process()->responsivenessTimer()->stop();
+ break;
+ }
+
+ switch (type) {
+ case WebEvent::NoType:
+ break;
+ case WebEvent::MouseMove:
+ m_processingMouseMoveEvent = false;
+ if (m_nextMouseMoveEvent) {
+ handleMouseEvent(*m_nextMouseMoveEvent);
+ m_nextMouseMoveEvent = nullptr;
+ }
+ break;
+ case WebEvent::MouseDown:
+#if ENABLE(GESTURE_EVENTS)
+ case WebEvent::GestureScrollBegin:
+ case WebEvent::GestureScrollEnd:
+ case WebEvent::GestureSingleTap:
+#endif
+ break;
+ case WebEvent::MouseUp:
+ m_currentlyProcessedMouseDownEvent = nullptr;
+ break;
+
+ case WebEvent::Wheel: {
+ ASSERT(!m_currentlyProcessedWheelEvents.isEmpty());
+
+ // FIXME: Dispatch additional events to the didNotHandleWheelEvent client function.
+ if (!handled && m_uiClient.implementsDidNotHandleWheelEvent())
+ m_uiClient.didNotHandleWheelEvent(this, m_currentlyProcessedWheelEvents.last());
+
+ m_currentlyProcessedWheelEvents.clear();
+
+ if (!m_wheelEventQueue.isEmpty()) {
+ WebWheelEvent newWheelEvent = coalescedWheelEvent(m_wheelEventQueue, m_currentlyProcessedWheelEvents);
+
+ process()->responsivenessTimer()->start();
+ process()->send(Messages::EventDispatcher::WheelEvent(m_pageID, newWheelEvent), 0);
+ }
+
+ break;
+ }
+
+ case WebEvent::KeyDown:
+ case WebEvent::KeyUp:
+ case WebEvent::RawKeyDown:
+ case WebEvent::Char: {
+ LOG(KeyHandling, "WebPageProxy::didReceiveEvent: %s", webKeyboardEventTypeString(type));
+
+ NativeWebKeyboardEvent event = m_keyEventQueue.first();
+ MESSAGE_CHECK(type == event.type());
+
+ m_keyEventQueue.removeFirst();
+
+ m_pageClient->doneWithKeyEvent(event, handled);
+
+ if (handled)
+ break;
+
+ if (m_uiClient.implementsDidNotHandleKeyEvent())
+ m_uiClient.didNotHandleKeyEvent(this, event);
+#if PLATFORM(WIN)
+ else
+ ::TranslateMessage(event.nativeEvent());
+#endif
+ break;
+ }
+#if ENABLE(TOUCH_EVENTS)
+ case WebEvent::TouchStart:
+ case WebEvent::TouchMove:
+ case WebEvent::TouchEnd:
+ case WebEvent::TouchCancel: {
+ QueuedTouchEvents queuedEvents = m_touchEventQueue.first();
+ MESSAGE_CHECK(type == queuedEvents.forwardedEvent.type());
+ m_touchEventQueue.removeFirst();
+
+ m_pageClient->doneWithTouchEvent(queuedEvents.forwardedEvent, handled);
+ for (size_t i = 0; i < queuedEvents.deferredTouchEvents.size(); ++i) {
+ bool isEventHandled = false;
+ m_pageClient->doneWithTouchEvent(queuedEvents.deferredTouchEvents.at(i), isEventHandled);
+ }
+ break;
+ }
+#endif
+ }
+}
+
+void WebPageProxy::stopResponsivenessTimer()
+{
+ process()->responsivenessTimer()->stop();
+}
+
+void WebPageProxy::voidCallback(uint64_t callbackID)
+{
+ RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallback();
+}
+
+void WebPageProxy::dataCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
+{
+ RefPtr<DataCallback> callback = m_dataCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(WebData::create(dataReference.data(), dataReference.size()).get());
+}
+
+void WebPageProxy::stringCallback(const String& resultString, uint64_t callbackID)
+{
+ RefPtr<StringCallback> callback = m_stringCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ // this can validly happen if a load invalidated the callback, though
+ return;
+ }
+
+ m_loadDependentStringCallbackIDs.remove(callbackID);
+
+ callback->performCallbackWithReturnValue(resultString.impl());
+}
+
+void WebPageProxy::scriptValueCallback(const CoreIPC::DataReference& dataReference, uint64_t callbackID)
+{
+ RefPtr<ScriptValueCallback> callback = m_scriptValueCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ Vector<uint8_t> data;
+ data.reserveInitialCapacity(dataReference.size());
+ data.append(dataReference.data(), dataReference.size());
+
+ callback->performCallbackWithReturnValue(data.size() ? WebSerializedScriptValue::adopt(data).get() : 0);
+}
+
+void WebPageProxy::computedPagesCallback(const Vector<IntRect>& pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
+{
+ RefPtr<ComputedPagesCallback> callback = m_computedPagesCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(pageRects, totalScaleFactorForPrinting);
+}
+
+void WebPageProxy::validateCommandCallback(const String& commandName, bool isEnabled, int state, uint64_t callbackID)
+{
+ RefPtr<ValidateCommandCallback> callback = m_validateCommandCallbacks.take(callbackID);
+ if (!callback) {
+ // FIXME: Log error or assert.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(commandName.impl(), isEnabled, state);
+}
+
+void WebPageProxy::focusedFrameChanged(uint64_t frameID)
+{
+ if (!frameID) {
+ m_focusedFrame = 0;
+ return;
+ }
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_focusedFrame = frame;
+}
+
+void WebPageProxy::frameSetLargestFrameChanged(uint64_t frameID)
+{
+ if (!frameID) {
+ m_frameSetLargestFrame = 0;
+ return;
+ }
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_frameSetLargestFrame = frame;
+}
+
+void WebPageProxy::processDidBecomeUnresponsive()
+{
+ if (!isValid())
+ return;
+
+ updateBackingStoreDiscardableState();
+
+ m_loaderClient.processDidBecomeUnresponsive(this);
+}
+
+void WebPageProxy::processDidBecomeResponsive()
+{
+ if (!isValid())
+ return;
+
+ updateBackingStoreDiscardableState();
+
+ m_loaderClient.processDidBecomeResponsive(this);
+}
+
+void WebPageProxy::processDidCrash()
+{
+ ASSERT(m_pageClient);
+
+ m_isValid = false;
+
+ if (m_mainFrame) {
+ m_urlAtProcessExit = m_mainFrame->url();
+ m_loadStateAtProcessExit = m_mainFrame->loadState();
+ }
+
+ m_mainFrame = nullptr;
+ m_drawingArea = nullptr;
+
+#if ENABLE(INSPECTOR)
+ if (m_inspector) {
+ m_inspector->invalidate();
+ m_inspector = nullptr;
+ }
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ if (m_fullScreenManager) {
+ m_fullScreenManager->invalidate();
+ m_fullScreenManager = nullptr;
+ }
+#endif
+
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = nullptr;
+ }
+
+ m_geolocationPermissionRequestManager.invalidateRequests();
+ m_notificationPermissionRequestManager.invalidateRequests();
+
+ m_toolTip = String();
+
+ m_mainFrameHasHorizontalScrollbar = false;
+ m_mainFrameHasVerticalScrollbar = false;
+
+ m_mainFrameIsPinnedToLeftSide = false;
+ m_mainFrameIsPinnedToRightSide = false;
+
+ m_visibleScrollerThumbRect = IntRect();
+
+ invalidateCallbackMap(m_voidCallbacks);
+ invalidateCallbackMap(m_dataCallbacks);
+ invalidateCallbackMap(m_stringCallbacks);
+ m_loadDependentStringCallbackIDs.clear();
+ invalidateCallbackMap(m_scriptValueCallbacks);
+ invalidateCallbackMap(m_computedPagesCallbacks);
+ invalidateCallbackMap(m_validateCommandCallbacks);
+
+ Vector<WebEditCommandProxy*> editCommandVector;
+ copyToVector(m_editCommandSet, editCommandVector);
+ m_editCommandSet.clear();
+ for (size_t i = 0, size = editCommandVector.size(); i < size; ++i)
+ editCommandVector[i]->invalidate();
+ m_pageClient->clearAllEditCommands();
+
+ m_activePopupMenu = 0;
+
+ m_estimatedProgress = 0.0;
+
+ m_pendingLearnOrIgnoreWordMessageCount = 0;
+
+ m_pageClient->processDidCrash();
+ m_loaderClient.processDidCrash(this);
+
+ if (!m_isValid) {
+ // If the call out to the loader client didn't cause the web process to be relaunched,
+ // we'll call setNeedsDisplay on the view so that we won't have the old contents showing.
+ // If the call did cause the web process to be relaunched, we'll keep the old page contents showing
+ // until the new web process has painted its contents.
+ setViewNeedsDisplay(IntRect(IntPoint(), viewSize()));
+ }
+
+ // Can't expect DidReceiveEvent notifications from a crashed web process.
+ m_keyEventQueue.clear();
+
+ m_wheelEventQueue.clear();
+ m_currentlyProcessedWheelEvents.clear();
+
+ m_nextMouseMoveEvent = nullptr;
+ m_currentlyProcessedMouseDownEvent = nullptr;
+
+ m_processingMouseMoveEvent = false;
+
+#if ENABLE(TOUCH_EVENTS)
+ m_needTouchEvents = false;
+ m_touchEventQueue.clear();
+#endif
+
+#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ dismissCorrectionPanel(ReasonForDismissingCorrectionPanelIgnored);
+ m_pageClient->dismissDictionaryLookupPanel();
+#endif
+}
+
+WebPageCreationParameters WebPageProxy::creationParameters() const
+{
+ WebPageCreationParameters parameters;
+
+ parameters.viewSize = m_pageClient->viewSize();
+ parameters.isActive = m_pageClient->isViewWindowActive();
+ parameters.isFocused = m_pageClient->isViewFocused();
+ parameters.isVisible = m_pageClient->isViewVisible();
+ parameters.isInWindow = m_pageClient->isViewInWindow();
+ parameters.drawingAreaType = m_drawingArea->type();
+ parameters.store = m_pageGroup->preferences()->store();
+ parameters.pageGroupData = m_pageGroup->data();
+ parameters.drawsBackground = m_drawsBackground;
+ parameters.drawsTransparentBackground = m_drawsTransparentBackground;
+ parameters.areMemoryCacheClientCallsEnabled = m_areMemoryCacheClientCallsEnabled;
+ parameters.useFixedLayout = m_useFixedLayout;
+ parameters.fixedLayoutSize = m_fixedLayoutSize;
+ parameters.paginationMode = m_paginationMode;
+ parameters.pageLength = m_pageLength;
+ parameters.gapBetweenPages = m_gapBetweenPages;
+ parameters.userAgent = userAgent();
+ parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex());
+ parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
+ parameters.canRunBeforeUnloadConfirmPanel = m_uiClient.canRunBeforeUnloadConfirmPanel();
+ parameters.canRunModal = m_uiClient.canRunModal();
+ parameters.deviceScaleFactor = m_intrinsicDeviceScaleFactor;
+
+#if PLATFORM(MAC)
+ parameters.isSmartInsertDeleteEnabled = m_isSmartInsertDeleteEnabled;
+#endif
+
+#if PLATFORM(WIN)
+ parameters.nativeWindow = m_pageClient->nativeWindow();
+#endif
+
+ return parameters;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
+{
+ m_pageClient->enterAcceleratedCompositingMode(layerTreeContext);
+}
+
+void WebPageProxy::exitAcceleratedCompositingMode()
+{
+ m_pageClient->exitAcceleratedCompositingMode();
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void WebPageProxy::backForwardClear()
+{
+ m_backForwardList->clear();
+}
+
+void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const ProtectionSpace& coreProtectionSpace, bool& canAuthenticate)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<WebProtectionSpace> protectionSpace = WebProtectionSpace::create(coreProtectionSpace);
+
+ canAuthenticate = m_loaderClient.canAuthenticateAgainstProtectionSpaceInFrame(this, frame, protectionSpace.get());
+}
+
+void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const AuthenticationChallenge& coreChallenge, uint64_t challengeID)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, process());
+
+ m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
+}
+
+void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+
+ newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage);
+}
+
+void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+ RefPtr<GeolocationPermissionRequestProxy> request = m_geolocationPermissionRequestManager.createRequest(geolocationID);
+
+ if (!m_uiClient.decidePolicyForGeolocationPermissionRequest(this, frame, origin.get(), request.get()))
+ request->deny();
+}
+
+void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originIdentifier)
+{
+ if (!isRequestIDValid(requestID))
+ return;
+
+ RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(originIdentifier);
+ RefPtr<NotificationPermissionRequest> request = m_notificationPermissionRequestManager.createRequest(requestID);
+
+ if (!m_uiClient.decidePolicyForNotificationPermissionRequest(this, origin.get(), request.get()))
+ request->deny();
+}
+
+void WebPageProxy::showNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID)
+{
+ m_process->context()->notificationManagerProxy()->show(this, title, body, originIdentifier, notificationID);
+}
+
+float WebPageProxy::headerHeight(WebFrameProxy* frame)
+{
+ if (frame->isDisplayingPDFDocument())
+ return 0;
+ return m_uiClient.headerHeight(this, frame);
+}
+
+float WebPageProxy::footerHeight(WebFrameProxy* frame)
+{
+ if (frame->isDisplayingPDFDocument())
+ return 0;
+ return m_uiClient.footerHeight(this, frame);
+}
+
+void WebPageProxy::drawHeader(WebFrameProxy* frame, const FloatRect& rect)
+{
+ if (frame->isDisplayingPDFDocument())
+ return;
+ m_uiClient.drawHeader(this, frame, rect);
+}
+
+void WebPageProxy::drawFooter(WebFrameProxy* frame, const FloatRect& rect)
+{
+ if (frame->isDisplayingPDFDocument())
+ return;
+ m_uiClient.drawFooter(this, frame, rect);
+}
+
+void WebPageProxy::runModal()
+{
+ // Since runModal() can (and probably will) spin a nested run loop we need to turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+
+ m_uiClient.runModal(this);
+}
+
+void WebPageProxy::notifyScrollerThumbIsVisibleInRect(const IntRect& scrollerThumb)
+{
+ m_visibleScrollerThumbRect = scrollerThumb;
+}
+
+void WebPageProxy::recommendedScrollbarStyleDidChange(int32_t newStyle)
+{
+#if PLATFORM(MAC)
+ m_pageClient->recommendedScrollbarStyleDidChange(newStyle);
+#endif
+}
+
+void WebPageProxy::didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
+{
+ m_mainFrameHasHorizontalScrollbar = hasHorizontalScrollbar;
+ m_mainFrameHasVerticalScrollbar = hasVerticalScrollbar;
+
+ m_pageClient->didChangeScrollbarsForMainFrame();
+}
+
+void WebPageProxy::didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide)
+{
+ m_mainFrameIsPinnedToLeftSide = pinnedToLeftSide;
+ m_mainFrameIsPinnedToRightSide = pinnedToRightSide;
+}
+
+void WebPageProxy::didChangePageCount(unsigned pageCount)
+{
+ m_pageCount = pageCount;
+}
+
+void WebPageProxy::didFailToInitializePlugin(const String& mimeType)
+{
+ m_loaderClient.didFailToInitializePlugin(this, mimeType);
+}
+
+bool WebPageProxy::willHandleHorizontalScrollEvents() const
+{
+ return m_wheelEventHandlerCount > 0;
+}
+
+void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference)
+{
+ m_pageClient->didFinishLoadingDataForCustomRepresentation(suggestedFilename, dataReference);
+}
+
+void WebPageProxy::backForwardRemovedItem(uint64_t itemID)
+{
+ process()->send(Messages::WebPage::DidRemoveBackForwardItem(itemID), m_pageID);
+}
+
+void WebPageProxy::beginPrinting(WebFrameProxy* frame, const PrintInfo& printInfo)
+{
+ if (m_isInPrintingMode)
+ return;
+
+ m_isInPrintingMode = true;
+ process()->send(Messages::WebPage::BeginPrinting(frame->frameID(), printInfo), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+
+void WebPageProxy::endPrinting()
+{
+ if (!m_isInPrintingMode)
+ return;
+
+ m_isInPrintingMode = false;
+ process()->send(Messages::WebPage::EndPrinting(), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+
+void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, PassRefPtr<ComputedPagesCallback> prpCallback)
+{
+ RefPtr<ComputedPagesCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_computedPagesCallbacks.set(callbackID, callback.get());
+ m_isInPrintingMode = true;
+ process()->send(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+
+#if PLATFORM(MAC) || PLATFORM(WIN)
+void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::DrawRectToPDF(frame->frameID(), printInfo, rect, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+
+void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ if (!isValid()) {
+ callback->invalidate();
+ return;
+ }
+
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::DrawPagesToPDF(frame->frameID(), printInfo, first, count, callbackID), m_pageID, m_isPerformingDOMPrintOperation ? CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply : 0);
+}
+#endif
+
+void WebPageProxy::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
+{
+ m_pageClient->flashBackingStoreUpdates(updateRects);
+}
+
+void WebPageProxy::updateBackingStoreDiscardableState()
+{
+ ASSERT(isValid());
+
+ bool isDiscardable;
+
+ if (!process()->responsivenessTimer()->isResponsive())
+ isDiscardable = false;
+ else
+ isDiscardable = !m_pageClient->isViewWindowActive() || !isViewVisible();
+
+ m_drawingArea->setBackingStoreIsDiscardable(isDiscardable);
+}
+
+Color WebPageProxy::viewUpdatesFlashColor()
+{
+ return Color(0, 200, 255);
+}
+
+Color WebPageProxy::backingStoreUpdatesFlashColor()
+{
+ return Color(200, 0, 255);
+}
+
+void WebPageProxy::saveDataToFileInDownloadsFolder(const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData* data)
+{
+ m_uiClient.saveDataToFileInDownloadsFolder(this, suggestedFilename, mimeType, originatingURLString, data);
+}
+
+void WebPageProxy::linkClicked(const String& url, const WebMouseEvent& event)
+{
+ process()->send(Messages::WebPage::LinkClicked(url, event), m_pageID, 0);
+}
+
+#if PLATFORM(MAC)
+
+void WebPageProxy::substitutionsPanelIsShowing(bool& isShowing)
+{
+ isShowing = TextChecker::substitutionsPanelIsShowing();
+}
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+void WebPageProxy::showCorrectionPanel(int32_t panelType, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+ m_pageClient->showCorrectionPanel((CorrectionPanelInfo::PanelType)panelType, boundingBoxOfReplacedString, replacedString, replacementString, alternativeReplacementStrings);
+}
+
+void WebPageProxy::dismissCorrectionPanel(int32_t reason)
+{
+ m_pageClient->dismissCorrectionPanel((ReasonForDismissingCorrectionPanel)reason);
+}
+
+void WebPageProxy::dismissCorrectionPanelSoon(int32_t reason, String& result)
+{
+ result = m_pageClient->dismissCorrectionPanelSoon((ReasonForDismissingCorrectionPanel)reason);
+}
+
+void WebPageProxy::recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString)
+{
+ m_pageClient->recordAutocorrectionResponse((EditorClient::AutocorrectionResponseType)responseType, replacedString, replacementString);
+}
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD)
+
+void WebPageProxy::handleCorrectionPanelResult(const String& result)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (!isClosed())
+ process()->send(Messages::WebPage::HandleCorrectionPanelResult(result), m_pageID, 0);
+#endif
+}
+#endif // PLATFORM(MAC)
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h
new file mode 100644
index 000000000..42a18f3e1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.h
@@ -0,0 +1,1007 @@
+/*
+ * 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 WebPageProxy_h
+#define WebPageProxy_h
+
+#include "APIObject.h"
+#include "Connection.h"
+#include "ContextMenuState.h"
+#include "DragControllerAction.h"
+#include "DrawingAreaProxy.h"
+#include "EditorState.h"
+#include "GeolocationPermissionRequestManagerProxy.h"
+#if ENABLE(TOUCH_EVENTS)
+#include "NativeWebTouchEvent.h"
+#endif
+#if PLATFORM(QT)
+#include "QtNetworkRequestData.h"
+#endif
+#include "NotificationPermissionRequestManagerProxy.h"
+#include "PlatformProcessIdentifier.h"
+#include "SandboxExtension.h"
+#include "ShareableBitmap.h"
+#include "WKBase.h"
+#include "WKPagePrivate.h"
+#include "WebContextMenuItemData.h"
+#include "WebFindClient.h"
+#include "WebFormClient.h"
+#include "WebFrameProxy.h"
+#include "WebHistoryClient.h"
+#include "WebHitTestResult.h"
+#include "WebLoaderClient.h"
+#include "WebPageContextMenuClient.h"
+#include "WebPolicyClient.h"
+#include "WebPopupMenuProxy.h"
+#include "WebResourceLoadClient.h"
+#include "WebUIClient.h"
+#include <WebCore/DragActions.h>
+#include <WebCore/DragSession.h>
+#include <WebCore/HitTestResult.h>
+#include <WebCore/Page.h>
+#include <WebCore/PlatformScreen.h>
+#include <WebCore/ScrollTypes.h>
+#include <WebCore/TextChecking.h>
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+#if PLATFORM(EFL)
+#include <Evas.h>
+#endif
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebCore {
+ class AuthenticationChallenge;
+ class Cursor;
+ class DragData;
+ class FloatRect;
+ class IntSize;
+ class ProtectionSpace;
+ struct FileChooserSettings;
+ struct TextCheckingResult;
+ struct ViewportArguments;
+ struct WindowFeatures;
+}
+
+#if PLATFORM(QT)
+class QQuickNetworkReply;
+#endif
+
+#if PLATFORM(MAC)
+#ifdef __OBJC__
+@class WKView;
+#else
+class WKView;
+#endif
+#endif
+
+namespace WebKit {
+
+class NativeWebKeyboardEvent;
+class NativeWebMouseEvent;
+class NativeWebWheelEvent;
+class PageClient;
+class PlatformCertificateInfo;
+class StringPairVector;
+class WebBackForwardList;
+class WebBackForwardListItem;
+class WebContextMenuProxy;
+class WebData;
+class WebEditCommandProxy;
+class WebFullScreenManagerProxy;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebOpenPanelResultListenerProxy;
+class WebPageGroup;
+class WebProcessProxy;
+class WebURLRequest;
+class WebWheelEvent;
+struct AttributedString;
+struct DictionaryPopupInfo;
+struct EditorState;
+struct PlatformPopupMenuData;
+struct PrintInfo;
+struct WebPageCreationParameters;
+struct WebPopupItem;
+
+#if PLATFORM(WIN)
+struct WindowGeometry;
+#endif
+
+#if ENABLE(GESTURE_EVENTS)
+class WebGestureEvent;
+#endif
+
+typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
+typedef GenericCallback<WKSerializedScriptValueRef, WebSerializedScriptValue*> ScriptValueCallback;
+
+#if ENABLE(TOUCH_EVENTS)
+struct QueuedTouchEvents {
+ QueuedTouchEvents(const NativeWebTouchEvent& event)
+ : forwardedEvent(event)
+ {
+ }
+ NativeWebTouchEvent forwardedEvent;
+ Vector<NativeWebTouchEvent> deferredTouchEvents;
+};
+#endif
+
+// FIXME: Make a version of CallbackBase with three arguments, and define ValidateCommandCallback as a specialization.
+class ValidateCommandCallback : public CallbackBase {
+public:
+ typedef void (*CallbackFunction)(WKStringRef, bool, int32_t, WKErrorRef, void*);
+
+ static PassRefPtr<ValidateCommandCallback> create(void* context, CallbackFunction callback)
+ {
+ return adoptRef(new ValidateCommandCallback(context, callback));
+ }
+
+ virtual ~ValidateCommandCallback()
+ {
+ ASSERT(!m_callback);
+ }
+
+ void performCallbackWithReturnValue(StringImpl* returnValue1, bool returnValue2, int returnValue3)
+ {
+ ASSERT(m_callback);
+
+ m_callback(toAPI(returnValue1), returnValue2, returnValue3, 0, context());
+
+ m_callback = 0;
+ }
+
+ void invalidate()
+ {
+ ASSERT(m_callback);
+
+ RefPtr<WebError> error = WebError::create();
+ m_callback(0, 0, 0, toAPI(error.get()), context());
+
+ m_callback = 0;
+ }
+
+private:
+
+ ValidateCommandCallback(void* context, CallbackFunction callback)
+ : CallbackBase(context)
+ , m_callback(callback)
+ {
+ }
+
+ CallbackFunction m_callback;
+};
+
+class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
+public:
+ static const Type APIType = TypePage;
+
+ static PassRefPtr<WebPageProxy> create(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
+ virtual ~WebPageProxy();
+
+ uint64_t pageID() const { return m_pageID; }
+
+ WebFrameProxy* mainFrame() const { return m_mainFrame.get(); }
+ WebFrameProxy* focusedFrame() const { return m_focusedFrame.get(); }
+ WebFrameProxy* frameSetLargestFrame() const { return m_frameSetLargestFrame.get(); }
+
+ DrawingAreaProxy* drawingArea() const { return m_drawingArea.get(); }
+
+ WebBackForwardList* backForwardList() const { return m_backForwardList.get(); }
+
+#if ENABLE(INSPECTOR)
+ WebInspectorProxy* inspector();
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ WebFullScreenManagerProxy* fullScreenManager();
+#endif
+
+ void initializeContextMenuClient(const WKPageContextMenuClient*);
+ void initializeFindClient(const WKPageFindClient*);
+ void initializeFormClient(const WKPageFormClient*);
+ void initializeLoaderClient(const WKPageLoaderClient*);
+ void initializePolicyClient(const WKPagePolicyClient*);
+ void initializeResourceLoadClient(const WKPageResourceLoadClient*);
+ void initializeUIClient(const WKPageUIClient*);
+
+ void initializeWebPage();
+
+ void close();
+ bool tryClose();
+ bool isClosed() const { return m_isClosed; }
+
+ void loadURL(const String&);
+ void loadURLRequest(WebURLRequest*);
+ void loadHTMLString(const String& htmlString, const String& baseURL);
+ void loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL);
+ void loadPlainTextString(const String& string);
+
+ void stopLoading();
+ void reload(bool reloadFromOrigin);
+
+ void goForward();
+ bool canGoForward() const;
+ void goBack();
+ bool canGoBack() const;
+
+ void goToBackForwardItem(WebBackForwardListItem*);
+ void tryRestoreScrollPosition();
+ void didChangeBackForwardList(WebBackForwardListItem* addedItem, Vector<RefPtr<APIObject> >* removedItems);
+ void shouldGoToBackForwardListItem(uint64_t itemID, bool& shouldGoToBackForwardListItem);
+
+ String activeURL() const;
+ String provisionalURL() const;
+ String committedURL() const;
+
+ bool willHandleHorizontalScrollEvents() const;
+
+ bool canShowMIMEType(const String& mimeType) const;
+
+ bool drawsBackground() const { return m_drawsBackground; }
+ void setDrawsBackground(bool);
+
+ bool drawsTransparentBackground() const { return m_drawsTransparentBackground; }
+ void setDrawsTransparentBackground(bool);
+
+ void viewWillStartLiveResize();
+ void viewWillEndLiveResize();
+
+ void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
+ void setWindowResizerSize(const WebCore::IntSize&);
+
+ void clearSelection();
+
+ void setViewNeedsDisplay(const WebCore::IntRect&);
+ void displayView();
+ void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+
+ enum {
+ ViewWindowIsActive = 1 << 0,
+ ViewIsFocused = 1 << 1,
+ ViewIsVisible = 1 << 2,
+ ViewIsInWindow = 1 << 3,
+ };
+ typedef unsigned ViewStateFlags;
+ void viewStateDidChange(ViewStateFlags flags);
+
+ WebCore::IntSize viewSize() const;
+ bool isViewVisible() const { return m_isVisible; }
+ bool isViewWindowActive() const;
+
+ void executeEditCommand(const String& commandName);
+ void validateCommand(const String& commandName, PassRefPtr<ValidateCommandCallback>);
+
+ const EditorState& editorState() const { return m_editorState; }
+ bool canDelete() const { return hasSelectedRange() && isContentEditable(); }
+ bool hasSelectedRange() const { return m_editorState.selectionIsRange; }
+ bool isContentEditable() const { return m_editorState.isContentEditable; }
+
+ bool maintainsInactiveSelection() const { return m_maintainsInactiveSelection; }
+ void setMaintainsInactiveSelection(bool);
+#if PLATFORM(QT)
+ void registerApplicationScheme(const String& scheme);
+ void resolveApplicationSchemeRequest(QtNetworkRequestData);
+ void sendApplicationSchemeReply(const QQuickNetworkReply*);
+#endif
+
+#if PLATFORM(QT)
+ void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
+ void confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength);
+ void cancelComposition();
+#endif
+#if PLATFORM(MAC)
+ void updateWindowIsVisible(bool windowIsVisible);
+ void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
+
+ void setComposition(const String& text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
+ void confirmComposition();
+ void cancelComposition();
+ bool insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd);
+ void getMarkedRange(uint64_t& location, uint64_t& length);
+ void getSelectedRange(uint64_t& location, uint64_t& length);
+ void getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString&);
+ uint64_t characterIndexForPoint(const WebCore::IntPoint);
+ WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t);
+ bool executeKeypressCommands(const Vector<WebCore::KeypressCommand>&);
+
+ void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
+ CGContextRef containingWindowGraphicsContext();
+ bool shouldDelayWindowOrderingForEvent(const WebMouseEvent&);
+ bool acceptsFirstMouse(int eventNumber, const WebMouseEvent&);
+
+ WKView* wkView() const;
+#endif
+#if PLATFORM(WIN)
+ void didChangeCompositionSelection(bool);
+ void confirmComposition(const String&);
+ void setComposition(const String&, Vector<WebCore::CompositionUnderline>&, int);
+ WebCore::IntRect firstRectForCharacterInSelectedRange(int);
+ String getSelectedText();
+
+ bool gestureWillBegin(const WebCore::IntPoint&);
+ void gestureDidScroll(const WebCore::IntSize&);
+ void gestureDidEnd();
+
+ void setGestureReachedScrollingLimit(bool);
+
+ HWND nativeWindow() const;
+#endif
+#if PLATFORM(GTK)
+ GtkWidget* viewWidget();
+#endif
+#if PLATFORM(EFL)
+ Evas_Object* viewObject();
+#endif
+#if USE(TILED_BACKING_STORE)
+ void setFixedVisibleContentRect(const WebCore::IntRect&);
+ void setViewportSize(const WebCore::IntSize&);
+#endif
+
+ void handleMouseEvent(const NativeWebMouseEvent&);
+ void handleWheelEvent(const NativeWebWheelEvent&);
+ void handleKeyboardEvent(const NativeWebKeyboardEvent&);
+#if ENABLE(GESTURE_EVENTS)
+ void handleGestureEvent(const WebGestureEvent&);
+#endif
+#if ENABLE(TOUCH_EVENTS)
+ void handleTouchEvent(const NativeWebTouchEvent&);
+#endif
+
+ void scrollBy(WebCore::ScrollDirection, WebCore::ScrollGranularity);
+ void centerSelectionInVisibleArea();
+
+ String pageTitle() const;
+ const String& toolTip() const { return m_toolTip; }
+
+ void setUserAgent(const String&);
+ const String& userAgent() const { return m_userAgent; }
+ void setApplicationNameForUserAgent(const String&);
+ const String& applicationNameForUserAgent() const { return m_applicationNameForUserAgent; }
+ void setCustomUserAgent(const String&);
+ const String& customUserAgent() const { return m_customUserAgent; }
+ static String standardUserAgent(const String& applicationName = String());
+
+ bool supportsTextEncoding() const;
+ void setCustomTextEncodingName(const String&);
+ String customTextEncodingName() const { return m_customTextEncodingName; }
+
+ double estimatedProgress() const;
+
+ void terminateProcess();
+
+ typedef bool (*WebPageProxySessionStateFilterCallback)(WKPageRef, WKStringRef type, WKTypeRef object, void* context);
+ PassRefPtr<WebData> sessionStateData(WebPageProxySessionStateFilterCallback, void* context) const;
+ void restoreFromSessionStateData(WebData*);
+
+ bool supportsTextZoom() const;
+ double textZoomFactor() const { return m_mainFrameHasCustomRepresentation ? 1 : m_textZoomFactor; }
+ void setTextZoomFactor(double);
+ double pageZoomFactor() const;
+ void setPageZoomFactor(double);
+ void setPageAndTextZoomFactors(double pageZoomFactor, double textZoomFactor);
+
+ void scalePage(double scale, const WebCore::IntPoint& origin);
+ double pageScaleFactor() const { return m_pageScaleFactor; }
+
+ float deviceScaleFactor() const;
+ void setIntrinsicDeviceScaleFactor(float);
+ void setCustomDeviceScaleFactor(float);
+ void windowScreenDidChange(PlatformDisplayID);
+
+ void setUseFixedLayout(bool);
+ void setFixedLayoutSize(const WebCore::IntSize&);
+ bool useFixedLayout() const { return m_useFixedLayout; };
+ const WebCore::IntSize& fixedLayoutSize() const { return m_fixedLayoutSize; };
+
+ bool hasHorizontalScrollbar() const { return m_mainFrameHasHorizontalScrollbar; }
+ bool hasVerticalScrollbar() const { return m_mainFrameHasVerticalScrollbar; }
+
+ bool isPinnedToLeftSide() const { return m_mainFrameIsPinnedToLeftSide; }
+ bool isPinnedToRightSide() const { return m_mainFrameIsPinnedToRightSide; }
+
+ void setPaginationMode(WebCore::Page::Pagination::Mode);
+ WebCore::Page::Pagination::Mode paginationMode() const { return m_paginationMode; }
+ void setPageLength(double);
+ double pageLength() const { return m_pageLength; }
+ void setGapBetweenPages(double);
+ double gapBetweenPages() const { return m_gapBetweenPages; }
+ unsigned pageCount() const { return m_pageCount; }
+
+#if PLATFORM(MAC)
+ // Called by the web process through a message.
+ void registerWebProcessAccessibilityToken(const CoreIPC::DataReference&);
+ // Called by the UI process when it is ready to send its tokens to the web process.
+ void registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elemenToken, const CoreIPC::DataReference& windowToken);
+ bool writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes);
+ bool readSelectionFromPasteboard(const String& pasteboardName);
+ void makeFirstResponder();
+#endif
+
+ void pageScaleFactorDidChange(double);
+
+ void setMemoryCacheClientCallsEnabled(bool);
+
+ // Find.
+ void findString(const String&, FindOptions, unsigned maxMatchCount);
+ void hideFindUI();
+ void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+ void didCountStringMatches(const String&, uint32_t matchCount);
+ void setFindIndicator(const WebCore::FloatRect& selectionRectInWindowCoordinates, const Vector<WebCore::FloatRect>& textRectsInSelectionRectCoordinates, float contentImageScaleFactor, const ShareableBitmap::Handle& contentImageHandle, bool fadeOut, bool animate);
+ void didFindString(const String&, uint32_t matchCount);
+ void didFailToFindString(const String&);
+#if PLATFORM(WIN)
+ void didInstallOrUninstallPageOverlay(bool);
+#endif
+
+ void getContentsAsString(PassRefPtr<StringCallback>);
+ void getMainResourceDataOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>);
+ void getResourceDataFromFrame(WebFrameProxy*, WebURL*, PassRefPtr<DataCallback>);
+ void getRenderTreeExternalRepresentation(PassRefPtr<StringCallback>);
+ void getSelectionOrContentsAsString(PassRefPtr<StringCallback>);
+ void getSourceForFrame(WebFrameProxy*, PassRefPtr<StringCallback>);
+ void getWebArchiveOfFrame(WebFrameProxy*, PassRefPtr<DataCallback>);
+ void runJavaScriptInMainFrame(const String&, PassRefPtr<ScriptValueCallback>);
+ void forceRepaint(PassRefPtr<VoidCallback>);
+
+ float headerHeight(WebFrameProxy*);
+ float footerHeight(WebFrameProxy*);
+ void drawHeader(WebFrameProxy*, const WebCore::FloatRect&);
+ void drawFooter(WebFrameProxy*, const WebCore::FloatRect&);
+
+#if PLATFORM(MAC)
+ // Dictionary.
+ void performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
+#endif
+
+ void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID);
+
+ void backForwardRemovedItem(uint64_t itemID);
+
+ // Drag and drop support.
+ void dragEntered(WebCore::DragData*, const String& dragStorageName = String());
+ void dragUpdated(WebCore::DragData*, const String& dragStorageName = String());
+ void dragExited(WebCore::DragData*, const String& dragStorageName = String());
+ void performDrag(WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&);
+
+ void didPerformDragControllerAction(WebCore::DragSession);
+ void dragEnded(const WebCore::IntPoint& clientPosition, const WebCore::IntPoint& globalPosition, uint64_t operation);
+#if PLATFORM(MAC)
+ void setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag);
+#endif
+#if PLATFORM(WIN)
+ void startDragDrop(const WebCore::IntPoint& imagePoint, const WebCore::IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, uint64_t fileSize, const String& pathname, const SharedMemory::Handle& fileContentHandle, const WebCore::IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag);
+#endif
+#if PLATFORM(QT) || PLATFORM(GTK)
+ void startDrag(const WebCore::DragData&, const ShareableBitmap::Handle& dragImage);
+#endif
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ void processDidBecomeUnresponsive();
+ void processDidBecomeResponsive();
+ void processDidCrash();
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+#endif
+
+ void didDraw();
+
+ enum UndoOrRedo { Undo, Redo };
+ void addEditCommand(WebEditCommandProxy*);
+ void removeEditCommand(WebEditCommandProxy*);
+ bool isValidEditCommand(WebEditCommandProxy*);
+ void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo);
+
+ WebProcessProxy* process() const;
+ PlatformProcessIdentifier processIdentifier() const;
+
+ WebPageGroup* pageGroup() const { return m_pageGroup.get(); }
+
+ bool isValid();
+
+ const String& urlAtProcessExit() const { return m_urlAtProcessExit; }
+ WebFrameProxy::LoadState loadStateAtProcessExit() const { return m_loadStateAtProcessExit; }
+
+ WebCore::DragSession dragSession() const { return m_currentDragSession; }
+ void resetDragOperation() { m_currentDragSession = WebCore::DragSession(); }
+
+ void preferencesDidChange();
+
+ // Called by the WebContextMenuProxy.
+ void contextMenuItemSelected(const WebContextMenuItemData&);
+
+ // Called by the WebOpenPanelResultListenerProxy.
+ void didChooseFilesForOpenPanel(const Vector<String>&);
+ void didCancelForOpenPanel();
+
+ WebPageCreationParameters creationParameters() const;
+
+#if PLATFORM(QT)
+ void findZoomableAreaForPoint(const WebCore::IntPoint&);
+ void didReceiveMessageFromNavigatorQtObject(const String&);
+ void handleDownloadRequest(DownloadProxy*);
+#endif
+
+ void advanceToNextMisspelling(bool startBeforeSelection) const;
+ void changeSpellingToWord(const String& word) const;
+#if PLATFORM(MAC)
+ void uppercaseWord();
+ void lowercaseWord();
+ void capitalizeWord();
+
+ bool isSmartInsertDeleteEnabled() const { return m_isSmartInsertDeleteEnabled; }
+ void setSmartInsertDeleteEnabled(bool);
+#endif
+
+ void beginPrinting(WebFrameProxy*, const PrintInfo&);
+ void endPrinting();
+ void computePagesForPrinting(WebFrameProxy*, const PrintInfo&, PassRefPtr<ComputedPagesCallback>);
+#if PLATFORM(MAC) || PLATFORM(WIN)
+ void drawRectToPDF(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, PassRefPtr<DataCallback>);
+ void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, PassRefPtr<DataCallback>);
+#endif
+
+ const String& pendingAPIRequestURL() const { return m_pendingAPIRequestURL; }
+
+ void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+
+#if PLATFORM(MAC)
+ void handleCorrectionPanelResult(const String& result);
+#endif
+
+ static void setDebugPaintFlags(WKPageDebugPaintFlags flags) { s_debugPaintFlags = flags; }
+ static WKPageDebugPaintFlags debugPaintFlags() { return s_debugPaintFlags; }
+
+ // Color to be used with kWKDebugFlashViewUpdates.
+ static WebCore::Color viewUpdatesFlashColor();
+
+ // Color to be used with kWKDebugFlashBackingStoreUpdates.
+ static WebCore::Color backingStoreUpdatesFlashColor();
+
+ void saveDataToFileInDownloadsFolder(const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData*);
+
+ void linkClicked(const String&, const WebMouseEvent&);
+
+ WebCore::IntRect visibleScrollerThumbRect() const { return m_visibleScrollerThumbRect; }
+
+ uint64_t renderTreeSize() const { return m_renderTreeSize; }
+
+ void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
+
+ void printMainFrame();
+
+ // WebPopupMenuProxy::Client
+ virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent();
+
+private:
+ WebPageProxy(PageClient*, PassRefPtr<WebProcessProxy>, WebPageGroup*, uint64_t pageID);
+
+ virtual Type type() const { return APIType; }
+
+ // WebPopupMenuProxy::Client
+ virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex);
+ virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index);
+#if PLATFORM(GTK)
+ virtual void failedToShowPopupMenu();
+#endif
+
+ // Implemented in generated WebPageProxyMessageReceiver.cpp
+ void didReceiveWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+
+ void didCreateMainFrame(uint64_t frameID);
+ void didCreateSubframe(uint64_t frameID, uint64_t parentFrameID);
+ void didSaveFrameToPageCache(uint64_t frameID);
+ void didRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID);
+
+ void didStartProvisionalLoadForFrame(uint64_t frameID, const String& url, const String& unreachableURL, CoreIPC::ArgumentDecoder*);
+ void didReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, const String&, CoreIPC::ArgumentDecoder*);
+ void didFailProvisionalLoadForFrame(uint64_t frameID, const WebCore::ResourceError&, CoreIPC::ArgumentDecoder*);
+ void didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo&, CoreIPC::ArgumentDecoder*);
+ void didFinishDocumentLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didFinishLoadForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didFailLoadForFrame(uint64_t frameID, const WebCore::ResourceError&, CoreIPC::ArgumentDecoder*);
+ void didSameDocumentNavigationForFrame(uint64_t frameID, uint32_t sameDocumentNavigationType, const String&, CoreIPC::ArgumentDecoder*);
+ void didReceiveTitleForFrame(uint64_t frameID, const String&, CoreIPC::ArgumentDecoder*);
+ void didFirstLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didRemoveFrameFromHierarchy(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didDisplayInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didRunInsecureContentForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void didDetectXSSForFrame(uint64_t frameID, CoreIPC::ArgumentDecoder*);
+ void frameDidBecomeFrameSet(uint64_t frameID, bool);
+ void didStartProgress();
+ void didChangeProgress(double);
+ void didFinishProgress();
+
+ void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder*, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
+ void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
+ void decidePolicyForResponse(uint64_t frameID, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
+ void unableToImplementPolicy(uint64_t frameID, const WebCore::ResourceError&, CoreIPC::ArgumentDecoder* arguments);
+
+ void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
+
+ // Resource load client
+ void didInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const WebCore::ResourceRequest&, bool pageIsProvisionallyLoading);
+ void didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
+ void didReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, const WebCore::ResourceResponse&);
+ void didReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength);
+ void didFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier);
+ void didFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, const WebCore::ResourceError&);
+
+ // UI client
+ void createNewPage(const WebCore::ResourceRequest&, const WebCore::WindowFeatures&, uint32_t modifiers, int32_t mouseButton, uint64_t& newPageID, WebPageCreationParameters&);
+ void showPage();
+ void closePage(bool stopResponsivenessTimer);
+ void runJavaScriptAlert(uint64_t frameID, const String&);
+ void runJavaScriptConfirm(uint64_t frameID, const String&, bool& result);
+ void runJavaScriptPrompt(uint64_t frameID, const String&, const String&, String& result);
+ void shouldInterruptJavaScript(bool& result);
+ void setStatusText(const String&);
+ void mouseDidMoveOverElement(const WebHitTestResult::Data& hitTestResultData, uint32_t modifiers, CoreIPC::ArgumentDecoder*);
+ void missingPluginButtonClicked(const String& mimeType, const String& url, const String& pluginsPageURL);
+ void setToolbarsAreVisible(bool toolbarsAreVisible);
+ void getToolbarsAreVisible(bool& toolbarsAreVisible);
+ void setMenuBarIsVisible(bool menuBarIsVisible);
+ void getMenuBarIsVisible(bool& menuBarIsVisible);
+ void setStatusBarIsVisible(bool statusBarIsVisible);
+ void getStatusBarIsVisible(bool& statusBarIsVisible);
+ void setIsResizable(bool isResizable);
+ void getIsResizable(bool& isResizable);
+ void setWindowFrame(const WebCore::FloatRect&);
+ void getWindowFrame(WebCore::FloatRect&);
+ void screenToWindow(const WebCore::IntPoint& screenPoint, WebCore::IntPoint& windowPoint);
+ void windowToScreen(const WebCore::IntRect& viewRect, WebCore::IntRect& result);
+ void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose);
+ void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ void pageDidScroll();
+ void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&);
+ void printFrame(uint64_t frameID);
+ void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota);
+ void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
+ void runModal();
+ void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
+ void recommendedScrollbarStyleDidChange(int32_t newStyle);
+ void didChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar);
+ void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide);
+ void didChangePageCount(unsigned);
+ void didFailToInitializePlugin(const String& mimeType);
+ void numWheelEventHandlersChanged(unsigned count) { m_wheelEventHandlerCount = count; }
+
+ void reattachToWebProcess();
+ void reattachToWebProcessWithItem(WebBackForwardListItem*);
+
+ void requestNotificationPermission(uint64_t notificationID, const String& originIdentifier);
+ void showNotification(const String& title, const String& body, const String& originIdentifier, uint64_t notificationID);
+
+#if USE(TILED_BACKING_STORE)
+ void pageDidRequestScroll(const WebCore::IntPoint&);
+#endif
+
+#if PLATFORM(QT)
+ void didChangeContentsSize(const WebCore::IntSize&);
+ void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
+ void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect&);
+#endif
+#if ENABLE(TOUCH_EVENTS)
+ void needTouchEvents(bool);
+#endif
+
+ void editorStateChanged(const EditorState&);
+
+ // Back/Forward list management
+ void backForwardAddItem(uint64_t itemID);
+ void backForwardGoToItem(uint64_t itemID);
+ void backForwardItemAtIndex(int32_t index, uint64_t& itemID);
+ void backForwardBackListCount(int32_t& count);
+ void backForwardForwardListCount(int32_t& count);
+ void backForwardClear();
+
+ // Undo management
+ void registerEditCommandForUndo(uint64_t commandID, uint32_t editAction);
+ void clearAllEditCommands();
+ void canUndoRedo(uint32_t action, bool& result);
+ void executeUndoRedo(uint32_t action, bool& result);
+
+ // Keyboard handling
+#if PLATFORM(MAC)
+ void interpretQueuedKeyEvent(const EditorState&, bool& handled, Vector<WebCore::KeypressCommand>&);
+ void executeSavedCommandBySelector(const String& selector, bool& handled);
+#endif
+
+#if PLATFORM(GTK)
+ void getEditorCommandsForKeyEvent(const AtomicString&, Vector<String>&);
+#endif
+#if PLATFORM(EFL)
+ void getEditorCommandsForKeyEvent(Vector<String>&);
+#endif
+
+ // Popup Menu.
+ void showPopupMenu(const WebCore::IntRect& rect, uint64_t textDirection, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData&);
+ void hidePopupMenu();
+#if PLATFORM(WIN)
+ void setPopupMenuSelectedIndex(int32_t);
+#endif
+
+ // Context Menu.
+ void showContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
+ void internalShowContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
+
+ // Search popup results
+ void saveRecentSearches(const String&, const Vector<String>&);
+ void loadRecentSearches(const String&, Vector<String>&);
+
+#if PLATFORM(MAC)
+ // Speech.
+ void getIsSpeaking(bool&);
+ void speak(const String&);
+ void stopSpeaking();
+
+ // Spotlight.
+ void searchWithSpotlight(const String&);
+
+ // Dictionary.
+ void didPerformDictionaryLookup(const String&, const DictionaryPopupInfo&);
+#endif
+
+ // Spelling and grammar.
+ int64_t spellDocumentTag();
+#if USE(UNIFIED_TEXT_CHECKING)
+ void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
+#endif
+ void checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
+ void checkGrammarOfString(const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
+ void spellingUIIsShowing(bool&);
+ void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
+ void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
+ void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
+ void learnWord(const String& word);
+ void ignoreWord(const String& word);
+
+ void setFocus(bool focused);
+ void takeFocus(uint32_t direction);
+ void setToolTip(const String&);
+ void setCursor(const WebCore::Cursor&);
+ void setCursorHiddenUntilMouseMoves(bool);
+
+ void didReceiveEvent(uint32_t opaqueType, bool handled);
+ void stopResponsivenessTimer();
+
+ void voidCallback(uint64_t);
+ void dataCallback(const CoreIPC::DataReference&, uint64_t);
+ void stringCallback(const String&, uint64_t);
+ void scriptValueCallback(const CoreIPC::DataReference&, uint64_t);
+ void computedPagesCallback(const Vector<WebCore::IntRect>&, double totalScaleFactorForPrinting, uint64_t);
+ void validateCommandCallback(const String&, bool, int, uint64_t);
+
+ void focusedFrameChanged(uint64_t frameID);
+ void frameSetLargestFrameChanged(uint64_t frameID);
+
+ void canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const WebCore::ProtectionSpace&, bool& canAuthenticate);
+ void didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
+
+ void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
+
+#if PLATFORM(MAC)
+ void pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus);
+ void setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState);
+#endif
+
+ void clearPendingAPIRequestURL() { m_pendingAPIRequestURL = String(); }
+ void setPendingAPIRequestURL(const String& pendingAPIRequestURL) { m_pendingAPIRequestURL = pendingAPIRequestURL; }
+
+ bool maybeInitializeSandboxExtensionHandle(const WebCore::KURL&, SandboxExtension::Handle&);
+
+#if PLATFORM(MAC)
+ void substitutionsPanelIsShowing(bool&);
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ void showCorrectionPanel(int32_t panelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
+ void dismissCorrectionPanel(int32_t reason);
+ void dismissCorrectionPanelSoon(int32_t reason, String& result);
+ void recordAutocorrectionResponse(int32_t responseType, const String& replacedString, const String& replacementString);
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD)
+#endif // PLATFORM(MAC)
+
+ void clearLoadDependentCallbacks();
+
+ void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&);
+
+ void updateBackingStoreDiscardableState();
+
+#if PLATFORM(WIN)
+ void scheduleChildWindowGeometryUpdate(const WindowGeometry&);
+#endif
+
+ void setRenderTreeSize(uint64_t treeSize) { m_renderTreeSize = treeSize; }
+
+ PageClient* m_pageClient;
+ WebLoaderClient m_loaderClient;
+ WebPolicyClient m_policyClient;
+ WebFormClient m_formClient;
+ WebResourceLoadClient m_resourceLoadClient;
+ WebUIClient m_uiClient;
+ WebFindClient m_findClient;
+ WebPageContextMenuClient m_contextMenuClient;
+
+ OwnPtr<DrawingAreaProxy> m_drawingArea;
+ RefPtr<WebProcessProxy> m_process;
+ RefPtr<WebPageGroup> m_pageGroup;
+ RefPtr<WebFrameProxy> m_mainFrame;
+ RefPtr<WebFrameProxy> m_focusedFrame;
+ RefPtr<WebFrameProxy> m_frameSetLargestFrame;
+
+ String m_userAgent;
+ String m_applicationNameForUserAgent;
+ String m_customUserAgent;
+ String m_customTextEncodingName;
+
+#if ENABLE(INSPECTOR)
+ RefPtr<WebInspectorProxy> m_inspector;
+#endif
+
+#if ENABLE(FULLSCREEN_API)
+ RefPtr<WebFullScreenManagerProxy> m_fullScreenManager;
+#endif
+
+ HashMap<uint64_t, RefPtr<VoidCallback> > m_voidCallbacks;
+ HashMap<uint64_t, RefPtr<DataCallback> > m_dataCallbacks;
+ HashMap<uint64_t, RefPtr<StringCallback> > m_stringCallbacks;
+ HashSet<uint64_t> m_loadDependentStringCallbackIDs;
+ HashMap<uint64_t, RefPtr<ScriptValueCallback> > m_scriptValueCallbacks;
+ HashMap<uint64_t, RefPtr<ComputedPagesCallback> > m_computedPagesCallbacks;
+ HashMap<uint64_t, RefPtr<ValidateCommandCallback> > m_validateCommandCallbacks;
+
+ HashSet<WebEditCommandProxy*> m_editCommandSet;
+
+ RefPtr<WebPopupMenuProxy> m_activePopupMenu;
+ RefPtr<WebContextMenuProxy> m_activeContextMenu;
+ ContextMenuState m_activeContextMenuState;
+ RefPtr<WebOpenPanelResultListenerProxy> m_openPanelResultListener;
+ GeolocationPermissionRequestManagerProxy m_geolocationPermissionRequestManager;
+ NotificationPermissionRequestManagerProxy m_notificationPermissionRequestManager;
+
+ double m_estimatedProgress;
+
+ // Whether the web page is contained in a top-level window.
+ bool m_isInWindow;
+
+ // Whether the page is visible; if the backing view is visible and inserted into a window.
+ bool m_isVisible;
+
+ bool m_canGoBack;
+ bool m_canGoForward;
+ RefPtr<WebBackForwardList> m_backForwardList;
+
+ bool m_maintainsInactiveSelection;
+
+ String m_toolTip;
+
+ String m_urlAtProcessExit;
+ WebFrameProxy::LoadState m_loadStateAtProcessExit;
+
+ EditorState m_editorState;
+
+ double m_textZoomFactor;
+ double m_pageZoomFactor;
+ double m_pageScaleFactor;
+ float m_intrinsicDeviceScaleFactor;
+ float m_customDeviceScaleFactor;
+
+ bool m_drawsBackground;
+ bool m_drawsTransparentBackground;
+
+ bool m_areMemoryCacheClientCallsEnabled;
+
+ bool m_useFixedLayout;
+ WebCore::IntSize m_fixedLayoutSize;
+
+ WebCore::Page::Pagination::Mode m_paginationMode;
+ double m_pageLength;
+ double m_gapBetweenPages;
+
+ // If the process backing the web page is alive and kicking.
+ bool m_isValid;
+
+ // Whether WebPageProxy::close() has been called on this page.
+ bool m_isClosed;
+
+ bool m_isInPrintingMode;
+ bool m_isPerformingDOMPrintOperation;
+
+ bool m_inDecidePolicyForResponse;
+ bool m_syncMimeTypePolicyActionIsValid;
+ WebCore::PolicyAction m_syncMimeTypePolicyAction;
+ uint64_t m_syncMimeTypePolicyDownloadID;
+
+ bool m_inDecidePolicyForNavigationAction;
+ bool m_syncNavigationActionPolicyActionIsValid;
+ WebCore::PolicyAction m_syncNavigationActionPolicyAction;
+ uint64_t m_syncNavigationActionPolicyDownloadID;
+
+ Deque<NativeWebKeyboardEvent> m_keyEventQueue;
+ Deque<NativeWebWheelEvent> m_wheelEventQueue;
+ Vector<NativeWebWheelEvent> m_currentlyProcessedWheelEvents;
+
+ bool m_processingMouseMoveEvent;
+ OwnPtr<NativeWebMouseEvent> m_nextMouseMoveEvent;
+ OwnPtr<NativeWebMouseEvent> m_currentlyProcessedMouseDownEvent;
+
+#if ENABLE(TOUCH_EVENTS)
+ bool m_needTouchEvents;
+ Deque<QueuedTouchEvents> m_touchEventQueue;
+#endif
+
+ uint64_t m_pageID;
+
+#if PLATFORM(MAC)
+ bool m_isSmartInsertDeleteEnabled;
+#endif
+
+ int64_t m_spellDocumentTag;
+ bool m_hasSpellDocumentTag;
+ unsigned m_pendingLearnOrIgnoreWordMessageCount;
+
+ bool m_mainFrameHasCustomRepresentation;
+ WebCore::DragSession m_currentDragSession;
+
+ String m_pendingAPIRequestURL;
+
+ bool m_mainFrameHasHorizontalScrollbar;
+ bool m_mainFrameHasVerticalScrollbar;
+ int m_wheelEventHandlerCount;
+
+ bool m_mainFrameIsPinnedToLeftSide;
+ bool m_mainFrameIsPinnedToRightSide;
+
+ unsigned m_pageCount;
+
+ WebCore::IntRect m_visibleScrollerThumbRect;
+
+ uint64_t m_renderTreeSize;
+
+ static WKPageDebugPaintFlags s_debugPaintFlags;
+
+ bool m_shouldSendEventsSynchronously;
+
+#if PLATFORM(QT)
+ WTF::HashSet<RefPtr<QtNetworkRequestData> > m_applicationSchemeRequests;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // WebPageProxy_h
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in
new file mode 100644
index 000000000..5c2133ab4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -0,0 +1,279 @@
+# 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.
+
+messages -> WebPageProxy {
+ # UI messages
+ CreateNewPage(WebCore::ResourceRequest request, WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters)
+ ShowPage()
+ ClosePage(bool stopResponsivenessTimer)
+ RunJavaScriptAlert(uint64_t frameID, WTF::String message) -> ()
+ RunJavaScriptConfirm(uint64_t frameID, WTF::String message) -> (bool result)
+ RunJavaScriptPrompt(uint64_t frameID, WTF::String message, WTF::String defaultValue) -> (WTF::String result)
+ ShouldInterruptJavaScript() -> (bool shouldInterupt)
+ MouseDidMoveOverElement(WebKit::WebHitTestResult::Data hitTestResultData, uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData);
+ MissingPluginButtonClicked(WTF::String mimeType, WTF::String url, WTF::String pluginsPageURL)
+ DidChangeViewportProperties(WebCore::ViewportArguments arguments)
+ DidReceiveEvent(uint32_t type, bool handled)
+ StopResponsivenessTimer()
+ SetCursor(WebCore::Cursor cursor)
+ SetCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+ SetStatusText(WTF::String statusText)
+ SetToolTip(WTF::String toolTip)
+ SetFocus(bool focused)
+ TakeFocus(uint32_t direction)
+ FocusedFrameChanged(uint64_t frameID)
+ FrameSetLargestFrameChanged(uint64_t frameID)
+ SetRenderTreeSize(uint64_t treeSize)
+ SetToolbarsAreVisible(bool toolbarsAreVisible)
+ GetToolbarsAreVisible() -> (bool toolbarsAreVisible)
+ SetMenuBarIsVisible(bool menuBarIsVisible);
+ GetMenuBarIsVisible() -> (bool menuBarIsVisible);
+ SetStatusBarIsVisible(bool statusBarIsVisible)
+ GetStatusBarIsVisible() -> (bool statusBarIsVisible)
+ SetIsResizable(bool isResizable)
+ GetIsResizable() -> (bool isResizable)
+ SetWindowFrame(WebCore::FloatRect windowFrame)
+ GetWindowFrame() -> (WebCore::FloatRect windowFrame)
+ ScreenToWindow(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint)
+ WindowToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame)
+ RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose)
+ PageDidScroll()
+ RunOpenPanel(uint64_t frameID, WebCore::FileChooserSettings parameters)
+ PrintFrame(uint64_t frameID) -> ()
+ RunModal()
+ NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
+ RecommendedScrollbarStyleDidChange(int32_t newStyle)
+ DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
+ DidChangeScrollOffsetPinningForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
+ DidChangePageCount(unsigned pageCount);
+ DidFailToInitializePlugin(WTF::String mimeType)
+ NumWheelEventHandlersChanged(unsigned count)
+
+#if USE(TILED_BACKING_STORE)
+ PageDidRequestScroll(WebCore::IntPoint point)
+#endif
+#if PLATFORM(QT)
+ DidChangeContentsSize(WebCore::IntSize newSize)
+ DidFindZoomableArea(WebCore::IntPoint target, WebCore::IntRect area)
+ FocusEditableArea(WebCore::IntRect caret, WebCore::IntRect area)
+#endif
+#if ENABLE(TOUCH_EVENTS)
+ NeedTouchEvents(bool needTouchEvents)
+#endif
+
+ # Policy messages
+ DecidePolicyForResponse(uint64_t frameID, WebCore::ResourceResponse response, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
+ DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
+ DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, WTF::String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
+ UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData)
+
+ # Progress messages
+ DidChangeProgress(double value)
+ DidFinishProgress()
+ DidStartProgress()
+
+ # Frame lifetime messages
+ DidCreateMainFrame(uint64_t frameID)
+ DidCreateSubframe(uint64_t frameID, uint64_t parentFrameID)
+ DidSaveFrameToPageCache(uint64_t frameID);
+ DidRestoreFrameFromPageCache(uint64_t frameID, uint64_t parentFrameID);
+
+ # Frame load messages
+ DidCommitLoadForFrame(uint64_t frameID, WTF::String mimeType, bool hasCustomRepresentation, WebKit::PlatformCertificateInfo certificateInfo, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFailLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFailProvisionalLoadForFrame(uint64_t frameID, WebCore::ResourceError error, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFinishDocumentLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFinishLoadForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFirstLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidRemoveFrameFromHierarchy(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidStartProvisionalLoadForFrame(uint64_t frameID, WTF::String url, WTF::String unreachableURL, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidReceiveTitleForFrame(uint64_t frameID, WTF::String title, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidDisplayInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidRunInsecureContentForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidDetectXSSForFrame(uint64_t frameID, WebKit::InjectedBundleUserMessageEncoder userData)
+ DidSameDocumentNavigationForFrame(uint64_t frameID, uint32_t type, WTF::String url, WebKit::InjectedBundleUserMessageEncoder userData)
+
+ FrameDidBecomeFrameSet(uint64_t frameID, bool value)
+
+ # Resource load messages
+ DidInitiateLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request, bool pageIsProvisionallyLoading)
+ DidSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
+ DidReceiveResponseForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceResponse response)
+ DidReceiveContentLengthForResource(uint64_t frameID, uint64_t resourceIdentifier, uint64_t contentLength)
+ DidFinishLoadForResource(uint64_t frameID, uint64_t resourceIdentifier)
+ DidFailLoadForResource(uint64_t frameID, uint64_t resourceIdentifier, WebCore::ResourceError error)
+#if PLATFORM(QT)
+ ResolveApplicationSchemeRequest(WebKit::QtNetworkRequestData request)
+#endif
+
+
+ # Custom representations
+ DidFinishLoadingDataForCustomRepresentation(WTF::String suggestedFilename, CoreIPC::DataReference data)
+
+ # Forms messages
+ WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
+
+ # Callback messages
+ VoidCallback(uint64_t callbackID)
+ DataCallback(CoreIPC::DataReference resultData, uint64_t callbackID)
+ StringCallback(WTF::String resultString, uint64_t callbackID)
+ ScriptValueCallback(CoreIPC::DataReference resultData, uint64_t callbackID)
+ ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
+ ValidateCommandCallback(WTF::String command, bool isEnabled, int32_t state, uint64_t callbackID)
+
+ PageScaleFactorDidChange(double scaleFactor)
+
+#if PLATFORM(GTK)
+ # Support for GTK+ platform keybindings
+ GetEditorCommandsForKeyEvent(AtomicString eventType) -> (Vector<WTF::String> commandsList)
+#endif
+
+ # BackForward messages
+ BackForwardAddItem(uint64_t itemID)
+ BackForwardGoToItem(uint64_t itemID)
+ BackForwardItemAtIndex(int32_t itemIndex) -> (uint64_t itemID)
+ BackForwardBackListCount() -> (int32_t count)
+ BackForwardForwardListCount() -> (int32_t count)
+ BackForwardClear()
+ ShouldGoToBackForwardListItem(uint64_t itemID) -> (bool shouldGoToBackForwardListItem)
+
+ # Undo/Redo messages
+ RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
+ ClearAllEditCommands()
+ CanUndoRedo(uint32_t action) -> (bool result)
+ ExecuteUndoRedo(uint32_t action) -> (bool result)
+
+ # Editor notifications
+ EditorStateChanged(WebKit::EditorState editorState)
+#if PLATFORM(WIN)
+ DidChangeCompositionSelection(bool hasChanged)
+#endif
+
+ # Find messages
+ DidCountStringMatches(WTF::String string, uint32_t matchCount)
+ SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, float contentImageScaleFactor, WebKit::ShareableBitmap::Handle contentImageHandle, bool fadeOut, bool animate)
+ DidFindString(WTF::String string, uint32_t matchCount)
+ DidFailToFindString(WTF::String string)
+#if PLATFORM(WIN)
+ DidInstallOrUninstallPageOverlay(bool didInstall)
+#endif
+
+ # PopupMenu messages
+ ShowPopupMenu(WebCore::IntRect rect, uint64_t textDirection, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
+ HidePopupMenu()
+#if PLATFORM(WIN)
+ SetPopupMenuSelectedIndex(int32_t selectedIndex)
+#endif
+
+ # ContextMenu messages
+ ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::ContextMenuState state, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData)
+
+ # Authentication messages
+ CanAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, WebCore::ProtectionSpace protectionSpace) -> (bool canAuthenticate)
+ DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
+
+ # Database messages
+ ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseName, WTF::String databaseDisplayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage) -> (uint64_t newQuota)
+
+ # Geolocation messages
+ RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier)
+
+ # Notification messages
+ RequestNotificationPermission(uint64_t requestID, WTF::String originIdentifier)
+ ShowNotification(WTF::String title, WTF::String body, WTF::String originIdentifier, uint64_t notificationID)
+
+ # Spelling and grammar messages
+#if USE(UNIFIED_TEXT_CHECKING)
+ CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
+#endif
+ CheckSpellingOfString(WTF::String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
+ CheckGrammarOfString(WTF::String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)
+ SpellingUIIsShowing() -> (bool isShowing)
+ UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
+ UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail)
+ GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
+ LearnWord(WTF::String word);
+ IgnoreWord(WTF::String word);
+
+ # Drag and drop messages
+ DidPerformDragControllerAction(WebCore::DragSession dragSession)
+#if PLATFORM(MAC)
+ SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, bool linkDrag)
+#endif
+#if PLATFORM(WIN)
+ StartDragDrop(WebCore::IntPoint imagePoint, WebCore::IntPoint dragPoint, uint64_t okEffect, HashMap<UINT,Vector<String> > dataMap, uint64_t fileSize, String pathname, WebKit::SharedMemory::Handle fileContentHandle, WebCore::IntSize dragImageSize, WebKit::SharedMemory::Handle dragImage, bool linkDrag)
+#endif
+#if PLATFORM(QT) || PLATFORM(GTK)
+ StartDrag(WebCore::DragData dragData, WebKit::ShareableBitmap::Handle dragImage)
+#endif
+
+#if PLATFORM(MAC)
+ # Dictionary support.
+ DidPerformDictionaryLookup(WTF::String text, WebKit::DictionaryPopupInfo dictionaryPopupInfo)
+
+ # Keyboard input support messages
+ InterpretQueuedKeyEvent(WebKit::EditorState state) -> (bool handled, Vector<WebCore::KeypressCommand> savedCommands)
+ ExecuteSavedCommandBySelector(WTF::String selector) -> (bool handled)
+
+ # Remote accessibility messages
+ RegisterWebProcessAccessibilityToken(CoreIPC::DataReference data)
+
+ # Plug-in complex text input support messages
+ PluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
+ SetPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState)
+
+ # Speech messages
+ GetIsSpeaking() -> (bool isSpeaking)
+ Speak(WTF::String string)
+ StopSpeaking()
+
+ MakeFirstResponder()
+
+ # Spotlight
+ SearchWithSpotlight(WTF::String string)
+#endif
+
+#if PLATFORM(MAC)
+ SubstitutionsPanelIsShowing() -> (bool isShowing)
+#endif
+#if PLATFORM(MAC) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ # Autocorrection messages
+ ShowCorrectionPanel(int32_t panelType, WebCore::FloatRect boundingBoxOfReplacedString, String replacedString, String replacementString, Vector<String> alternativeReplacementStrings)
+ DismissCorrectionPanel(int32_t reason)
+ DismissCorrectionPanelSoon(int32_t reason) -> (String result)
+ RecordAutocorrectionResponse(int32_t responseType, String replacedString, String replacementString);
+#endif
+
+#if PLATFORM(WIN)
+ # Windows 7 Gesture Messages
+ SetGestureReachedScrollingLimit(bool limitReached)
+
+ # Miscellaneous Windows messages
+ ScheduleChildWindowGeometryUpdate(WebKit::WindowGeometry geometry)
+#endif
+
+ # Search popup menus
+ SaveRecentSearches(WTF::String name, Vector<String> searchItems)
+ LoadRecentSearches(WTF::String name) -> (Vector<String> result)
+}
diff --git a/Source/WebKit2/UIProcess/WebPolicyClient.cpp b/Source/WebKit2/UIProcess/WebPolicyClient.cpp
new file mode 100644
index 000000000..c57c896b3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPolicyClient.cpp
@@ -0,0 +1,79 @@
+/*
+ * 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 "WebPolicyClient.h"
+
+#include "APIObject.h"
+#include "WKAPICast.h"
+#include "WebURLRequest.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, WebFrameProxy* frame, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const ResourceRequest& resourceRequest, WebFramePolicyListenerProxy* listener, APIObject* userData)
+{
+ if (!m_client.decidePolicyForNavigationAction)
+ return false;
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+
+ m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toAPI(request.get()), toAPI(listener), toAPI(userData), m_client.clientInfo);
+ return true;
+}
+
+bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, WebFrameProxy* frame, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const ResourceRequest& resourceRequest, const String& frameName, WebFramePolicyListenerProxy* listener, APIObject* userData)
+{
+ if (!m_client.decidePolicyForNewWindowAction)
+ return false;
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+
+ m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toAPI(request.get()), toAPI(frameName.impl()), toAPI(listener), toAPI(userData), m_client.clientInfo);
+ return true;
+}
+
+bool WebPolicyClient::decidePolicyForResponse(WebPageProxy* page, WebFrameProxy* frame, const ResourceResponse& resourceResponse, const ResourceRequest& resourceRequest, WebFramePolicyListenerProxy* listener, APIObject* userData)
+{
+ if (!m_client.decidePolicyForResponse)
+ return false;
+
+ RefPtr<WebURLResponse> response = WebURLResponse::create(resourceResponse);
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+
+ m_client.decidePolicyForResponse(toAPI(page), toAPI(frame), toAPI(response.get()), toAPI(request.get()), toAPI(listener), toAPI(userData), m_client.clientInfo);
+ return true;
+}
+
+void WebPolicyClient::unableToImplementPolicy(WebPageProxy* page, WebFrameProxy* frame, const ResourceError& error, APIObject* userData)
+{
+ if (!m_client.unableToImplementPolicy)
+ return;
+
+ m_client.unableToImplementPolicy(toAPI(page), toAPI(frame), toAPI(error), toAPI(userData), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPolicyClient.h b/Source/WebKit2/UIProcess/WebPolicyClient.h
new file mode 100644
index 000000000..e4eef4867
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPolicyClient.h
@@ -0,0 +1,58 @@
+/*
+ * 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 WebPolicyClient_h
+#define WebPolicyClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include "WebEvent.h"
+#include <WebCore/FrameLoaderTypes.h>
+#include <wtf/Forward.h>
+
+namespace WebCore {
+ class ResourceError;
+ class ResourceRequest;
+ class ResourceResponse;
+}
+
+namespace WebKit {
+
+class APIObject;
+class WebPageProxy;
+class WebFrameProxy;
+class WebFramePolicyListenerProxy;
+
+class WebPolicyClient : public APIClient<WKPagePolicyClient, kWKPagePolicyClientCurrentVersion> {
+public:
+ bool decidePolicyForNavigationAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
+ bool decidePolicyForNewWindowAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, const String& frameName, WebFramePolicyListenerProxy*, APIObject* userData);
+ bool decidePolicyForResponse(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceResponse&, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
+ void unableToImplementPolicy(WebPageProxy*, WebFrameProxy*, const WebCore::ResourceError&, APIObject* userData);
+};
+
+} // namespace WebKit
+
+#endif // WebPolicyClient_h
diff --git a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
new file mode 100644
index 000000000..3cefc0d67
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
@@ -0,0 +1,81 @@
+/*
+ * 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 WebPopupMenuProxy_h
+#define WebPopupMenuProxy_h
+
+#include <WebCore/TextDirection.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+ class IntRect;
+}
+
+namespace WebKit {
+
+struct PlatformPopupMenuData;
+struct WebPopupItem;
+class NativeWebMouseEvent;
+
+class WebPopupMenuProxy : public RefCounted<WebPopupMenuProxy> {
+public:
+ class Client {
+ protected:
+ virtual ~Client()
+ {
+ }
+
+ public:
+ virtual void valueChangedForPopupMenu(WebPopupMenuProxy*, int32_t newSelectedIndex) = 0;
+ virtual void setTextFromItemForPopupMenu(WebPopupMenuProxy*, int32_t index) = 0;
+ virtual NativeWebMouseEvent* currentlyProcessedMouseDownEvent() = 0;
+#if PLATFORM(GTK)
+ virtual void failedToShowPopupMenu() = 0;
+#endif
+ };
+
+ virtual ~WebPopupMenuProxy()
+ {
+ }
+
+ virtual void showPopupMenu(const WebCore::IntRect& rect, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex) = 0;
+ virtual void hidePopupMenu() = 0;
+
+ void invalidate() { m_client = 0; }
+
+protected:
+ WebPopupMenuProxy(Client* client)
+ : m_client(client)
+ {
+ }
+
+ Client* m_client;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxy_h
diff --git a/Source/WebKit2/UIProcess/WebPreferences.cpp b/Source/WebKit2/UIProcess/WebPreferences.cpp
new file mode 100644
index 000000000..efda4cdf0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPreferences.cpp
@@ -0,0 +1,106 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include "WebPageGroup.h"
+
+namespace WebKit {
+
+WebPreferences::WebPreferences()
+{
+ platformInitializeStore();
+}
+
+WebPreferences::WebPreferences(const String& identifier)
+ : m_identifier(identifier)
+{
+ platformInitializeStore();
+}
+
+WebPreferences::~WebPreferences()
+{
+}
+
+void WebPreferences::addPageGroup(WebPageGroup* pageGroup)
+{
+ m_pageGroups.add(pageGroup);
+}
+
+void WebPreferences::removePageGroup(WebPageGroup* pageGroup)
+{
+ m_pageGroups.remove(pageGroup);
+}
+
+void WebPreferences::update()
+{
+ for (HashSet<WebPageGroup*>::iterator it = m_pageGroups.begin(), end = m_pageGroups.end(); it != end; ++it)
+ (*it)->preferencesDidChange();
+}
+
+void WebPreferences::updateStringValueForKey(const String& key, const String& value)
+{
+ platformUpdateStringValueForKey(key, value);
+ update(); // FIXME: Only send over the changed key and value.
+}
+
+void WebPreferences::updateBoolValueForKey(const String& key, bool value)
+{
+ platformUpdateBoolValueForKey(key, value);
+ update(); // FIXME: Only send over the changed key and value.
+}
+
+void WebPreferences::updateUInt32ValueForKey(const String& key, uint32_t value)
+{
+ platformUpdateUInt32ValueForKey(key, value);
+ update(); // FIXME: Only send over the changed key and value.
+}
+
+void WebPreferences::updateDoubleValueForKey(const String& key, double value)
+{
+ platformUpdateDoubleValueForKey(key, value);
+ update(); // FIXME: Only send over the changed key and value.
+}
+
+#define DEFINE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+ void WebPreferences::set##KeyUpper(const Type& value) \
+ { \
+ if (!m_store.set##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), value)) \
+ return; \
+ update##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key(), value); \
+ \
+ } \
+ \
+ Type WebPreferences::KeyLower() const \
+ { \
+ return m_store.get##TypeName##ValueForKey(WebPreferencesKey::KeyLower##Key()); \
+ } \
+
+FOR_EACH_WEBKIT_PREFERENCE(DEFINE_PREFERENCE_GETTER_AND_SETTERS)
+
+#undef DEFINE_PREFERENCE_GETTER_AND_SETTERS
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPreferences.h b/Source/WebKit2/UIProcess/WebPreferences.h
new file mode 100644
index 000000000..0f4943ab6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPreferences.h
@@ -0,0 +1,98 @@
+/*
+ * 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 WebPreferences_h
+#define WebPreferences_h
+
+#include "APIObject.h"
+#include "FontSmoothingLevel.h"
+#include "WebPreferencesStore.h"
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+ void set##KeyUpper(const Type& value); \
+ Type KeyLower() const;
+
+namespace WebKit {
+
+class WebPageGroup;
+
+class WebPreferences : public APIObject {
+public:
+ static const Type APIType = TypePreferences;
+
+ static PassRefPtr<WebPreferences> create()
+ {
+ return adoptRef(new WebPreferences);
+ }
+ static PassRefPtr<WebPreferences> create(const String& identifier)
+ {
+ return adoptRef(new WebPreferences(identifier));
+ }
+
+ virtual ~WebPreferences();
+
+ void addPageGroup(WebPageGroup*);
+ void removePageGroup(WebPageGroup*);
+
+ const WebPreferencesStore& store() const { return m_store; }
+
+#define DECLARE_PREFERENCE_GETTER_AND_SETTERS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+ void set##KeyUpper(const Type& value); \
+ Type KeyLower() const; \
+
+ FOR_EACH_WEBKIT_PREFERENCE(DECLARE_PREFERENCE_GETTER_AND_SETTERS)
+
+#undef DECLARE_PREFERENCE_GETTER_AND_SETTERS
+
+private:
+ WebPreferences();
+ WebPreferences(const String& identifier);
+
+ void platformInitializeStore();
+
+ virtual Type type() const { return APIType; }
+
+ void update();
+
+ void updateStringValueForKey(const String& key, const String& value);
+ void updateBoolValueForKey(const String& key, bool value);
+ void updateUInt32ValueForKey(const String& key, uint32_t value);
+ void updateDoubleValueForKey(const String& key, double value);
+ void platformUpdateStringValueForKey(const String& key, const String& value);
+ void platformUpdateBoolValueForKey(const String& key, bool value);
+ void platformUpdateUInt32ValueForKey(const String& key, uint32_t value);
+ void platformUpdateDoubleValueForKey(const String& key, double value);
+
+ HashSet<WebPageGroup*> m_pageGroups;
+ WebPreferencesStore m_store;
+ String m_identifier;
+};
+
+} // namespace WebKit
+
+#endif // WebPreferences_h
diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.cpp b/Source/WebKit2/UIProcess/WebProcessProxy.cpp
new file mode 100644
index 000000000..0c11caa5b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.cpp
@@ -0,0 +1,491 @@
+/*
+ * 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 "WebProcessProxy.h"
+
+#include "DataReference.h"
+#include "PluginInfoStore.h"
+#include "PluginProcessManager.h"
+#include "TextChecker.h"
+#include "TextCheckerState.h"
+#include "WebBackForwardListItem.h"
+#include "WebContext.h"
+#include "WebNavigationDataStore.h"
+#include "WebNotificationManagerProxy.h"
+#include "WebPageProxy.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxyMessages.h"
+#include <WebCore/KURL.h>
+#include <stdio.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+using namespace std;
+
+#define MESSAGE_CHECK_URL(url) MESSAGE_CHECK_BASE(checkURLReceivedFromWebProcess(url), connection())
+
+namespace WebKit {
+
+template<typename HashMap>
+static inline bool isGoodKey(const typename HashMap::KeyType& key)
+{
+ return key != HashTraits<typename HashMap::KeyType>::emptyValue() && !HashTraits<typename HashMap::KeyType>::isDeletedValue(key);
+}
+
+static uint64_t generatePageID()
+{
+ static uint64_t uniquePageID = 1;
+ return uniquePageID++;
+}
+
+PassRefPtr<WebProcessProxy> WebProcessProxy::create(PassRefPtr<WebContext> context)
+{
+ return adoptRef(new WebProcessProxy(context));
+}
+
+WebProcessProxy::WebProcessProxy(PassRefPtr<WebContext> context)
+ : m_responsivenessTimer(this)
+ , m_context(context)
+ , m_mayHaveUniversalFileReadSandboxExtension(false)
+{
+ connect();
+}
+
+WebProcessProxy::~WebProcessProxy()
+{
+ if (m_connection)
+ m_connection->invalidate();
+
+ for (size_t i = 0; i < m_pendingMessages.size(); ++i)
+ m_pendingMessages[i].first.releaseArguments();
+
+ if (m_processLauncher) {
+ m_processLauncher->invalidate();
+ m_processLauncher = 0;
+ }
+
+ if (m_threadLauncher) {
+ m_threadLauncher->invalidate();
+ m_threadLauncher = 0;
+ }
+}
+
+void WebProcessProxy::connect()
+{
+ if (m_context->processModel() == ProcessModelSharedSecondaryThread) {
+ ASSERT(!m_threadLauncher);
+ m_threadLauncher = ThreadLauncher::create(this);
+ } else {
+ ASSERT(!m_processLauncher);
+
+ ProcessLauncher::LaunchOptions launchOptions;
+ launchOptions.processType = ProcessLauncher::WebProcess;
+
+#if PLATFORM(MAC)
+ // We want the web process to match the architecture of the UI process.
+ launchOptions.architecture = ProcessLauncher::LaunchOptions::MatchCurrentArchitecture;
+ launchOptions.executableHeap = false;
+#endif
+ m_processLauncher = ProcessLauncher::create(this, launchOptions);
+ }
+}
+
+void WebProcessProxy::disconnect()
+{
+ if (m_connection) {
+ m_connection->invalidate();
+ m_connection = nullptr;
+ }
+
+ m_responsivenessTimer.stop();
+
+ Vector<RefPtr<WebFrameProxy> > frames;
+ copyValuesToVector(m_frameMap, frames);
+
+ for (size_t i = 0, size = frames.size(); i < size; ++i)
+ frames[i]->disconnect();
+ m_frameMap.clear();
+
+ m_context->disconnectProcess(this);
+}
+
+bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments, unsigned messageSendFlags)
+{
+ // If we're waiting for the web process to launch, we need to stash away the messages so we can send them once we have
+ // a CoreIPC connection.
+ if (isLaunching()) {
+ m_pendingMessages.append(make_pair(CoreIPC::Connection::OutgoingMessage(messageID, arguments), messageSendFlags));
+ return true;
+ }
+
+ // If the web process has exited, m_connection will be null here.
+ if (!m_connection)
+ return false;
+
+ return connection()->sendMessage(messageID, arguments, messageSendFlags);
+}
+
+bool WebProcessProxy::isLaunching() const
+{
+ if (m_processLauncher)
+ return m_processLauncher->isLaunching();
+ if (m_threadLauncher)
+ return m_threadLauncher->isLaunching();
+
+ return false;
+}
+
+void WebProcessProxy::terminate()
+{
+ if (m_processLauncher)
+ m_processLauncher->terminateProcess();
+}
+
+WebPageProxy* WebProcessProxy::webPage(uint64_t pageID) const
+{
+ return m_pageMap.get(pageID);
+}
+
+PassRefPtr<WebPageProxy> WebProcessProxy::createWebPage(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup)
+{
+ ASSERT(context->process() == this);
+
+ uint64_t pageID = generatePageID();
+ RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, this, pageGroup, pageID);
+ m_pageMap.set(pageID, webPage.get());
+ return webPage.release();
+}
+
+void WebProcessProxy::addExistingWebPage(WebPageProxy* webPage, uint64_t pageID)
+{
+ m_pageMap.set(pageID, webPage);
+}
+
+void WebProcessProxy::removeWebPage(uint64_t pageID)
+{
+ m_pageMap.remove(pageID);
+}
+
+WebBackForwardListItem* WebProcessProxy::webBackForwardItem(uint64_t itemID) const
+{
+ return m_backForwardListItemMap.get(itemID).get();
+}
+
+void WebProcessProxy::registerNewWebBackForwardListItem(WebBackForwardListItem* item)
+{
+ // This item was just created by the UIProcess and is being added to the map for the first time
+ // so we should not already have an item for this ID.
+ ASSERT(!m_backForwardListItemMap.contains(item->itemID()));
+
+ m_backForwardListItemMap.set(item->itemID(), item);
+}
+
+void WebProcessProxy::assumeReadAccessToBaseURL(const String& urlString)
+{
+ KURL url(KURL(), urlString);
+ if (!url.isLocalFile())
+ return;
+
+ // There's a chance that urlString does not point to a directory.
+ // Get url's base URL to add to m_localPathsWithAssumedReadAccess.
+ KURL baseURL(KURL(), url.baseAsString());
+
+ // Client loads an alternate string. This doesn't grant universal file read, but the web process is assumed
+ // to have read access to this directory already.
+ m_localPathsWithAssumedReadAccess.add(baseURL.fileSystemPath());
+}
+
+bool WebProcessProxy::checkURLReceivedFromWebProcess(const String& urlString)
+{
+ return checkURLReceivedFromWebProcess(KURL(KURL(), urlString));
+}
+
+bool WebProcessProxy::checkURLReceivedFromWebProcess(const KURL& url)
+{
+ // FIXME: Consider checking that the URL is valid. Currently, WebProcess sends invalid URLs in many cases, but it probably doesn't have good reasons to do that.
+
+ // Any other non-file URL is OK.
+ if (!url.isLocalFile())
+ return true;
+
+ // Any file URL is also OK if we've loaded a file URL through API before, granting universal read access.
+ if (m_mayHaveUniversalFileReadSandboxExtension)
+ return true;
+
+ // If we loaded a string with a file base URL before, loading resources from that subdirectory is fine.
+ // There are no ".." components, because all URLs received from WebProcess are parsed with KURL, which removes those.
+ String path = url.fileSystemPath();
+ for (HashSet<String>::const_iterator iter = m_localPathsWithAssumedReadAccess.begin(); iter != m_localPathsWithAssumedReadAccess.end(); ++iter) {
+ if (path.startsWith(*iter))
+ return true;
+ }
+
+ // A Web process that was never asked to load a file URL should not ever ask us to do anything with a file URL.
+ return false;
+}
+
+#if !PLATFORM(MAC)
+bool WebProcessProxy::fullKeyboardAccessEnabled()
+{
+ return false;
+}
+#endif
+
+void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& originalURL, const String& url, const String& title, const CoreIPC::DataReference& backForwardData)
+{
+ MESSAGE_CHECK_URL(originalURL);
+ MESSAGE_CHECK_URL(url);
+
+ std::pair<WebBackForwardListItemMap::iterator, bool> result = m_backForwardListItemMap.add(itemID, 0);
+ if (result.second) {
+ // New item.
+ result.first->second = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);
+ return;
+ }
+
+ // Update existing item.
+ result.first->second->setOriginalURL(originalURL);
+ result.first->second->setURL(url);
+ result.first->second->setTitle(title);
+ result.first->second->setBackForwardData(backForwardData.data(), backForwardData.size());
+}
+
+#if ENABLE(PLUGIN_PROCESS)
+void WebProcessProxy::getPluginProcessConnection(const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply> reply)
+{
+ PluginProcessManager::shared().getPluginProcessConnection(context()->pluginInfoStore(), pluginPath, reply);
+}
+
+void WebProcessProxy::pluginSyncMessageSendTimedOut(const String& pluginPath)
+{
+ PluginProcessManager::shared().pluginSyncMessageSendTimedOut(pluginPath);
+}
+#endif
+
+void WebProcessProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) {
+ didReceiveWebProcessProxyMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebContext>()
+ || messageID.is<CoreIPC::MessageClassWebContextLegacy>()
+ || messageID.is<CoreIPC::MessageClassDownloadProxy>()
+ || messageID.is<CoreIPC::MessageClassWebApplicationCacheManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebCookieManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebDatabaseManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebIconDatabase>()
+ || messageID.is<CoreIPC::MessageClassWebKeyValueStorageManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebMediaCacheManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebNotificationManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebResourceCacheManagerProxy>()) {
+ m_context->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+ uint64_t pageID = arguments->destinationID();
+ if (!pageID)
+ return;
+
+ WebPageProxy* pageProxy = webPage(pageID);
+ if (!pageProxy)
+ return;
+
+ pageProxy->didReceiveMessage(connection, messageID, arguments);
+}
+
+void WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
+{
+ if (messageID.is<CoreIPC::MessageClassWebProcessProxy>()) {
+ didReceiveSyncWebProcessProxyMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebContext>() || messageID.is<CoreIPC::MessageClassWebContextLegacy>()
+ || messageID.is<CoreIPC::MessageClassDownloadProxy>() || messageID.is<CoreIPC::MessageClassWebIconDatabase>()) {
+ m_context->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebNotificationManagerProxy>()) {
+ m_context->notificationManagerProxy()->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+ uint64_t pageID = arguments->destinationID();
+ if (!pageID)
+ return;
+
+ WebPageProxy* pageProxy = webPage(pageID);
+ if (!pageProxy)
+ return;
+
+ pageProxy->didReceiveSyncMessage(connection, messageID, arguments, reply);
+}
+
+void WebProcessProxy::didClose(CoreIPC::Connection*)
+{
+ // Protect ourselves, as the call to disconnect() below may otherwise cause us
+ // to be deleted before we can finish our work.
+ RefPtr<WebProcessProxy> protect(this);
+
+ Vector<RefPtr<WebPageProxy> > pages;
+ copyValuesToVector(m_pageMap, pages);
+
+ disconnect();
+
+ for (size_t i = 0, size = pages.size(); i < size; ++i)
+ pages[i]->processDidCrash();
+}
+
+void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID)
+{
+ // This fprintf is intentionally left because this function should
+ // only be hit in the case of a misbehaving web process.
+ fprintf(stderr, "Receive an invalid message from the web process with message ID %x\n", messageID.toInt());
+
+ // Terminate the WebProcesses.
+ terminate();
+}
+
+void WebProcessProxy::syncMessageSendTimedOut(CoreIPC::Connection*)
+{
+}
+
+void WebProcessProxy::didBecomeUnresponsive(ResponsivenessTimer*)
+{
+ Vector<RefPtr<WebPageProxy> > pages;
+ copyValuesToVector(m_pageMap, pages);
+ for (size_t i = 0, size = pages.size(); i < size; ++i)
+ pages[i]->processDidBecomeUnresponsive();
+}
+
+void WebProcessProxy::didBecomeResponsive(ResponsivenessTimer*)
+{
+ Vector<RefPtr<WebPageProxy> > pages;
+ copyValuesToVector(m_pageMap, pages);
+ for (size_t i = 0, size = pages.size(); i < size; ++i)
+ pages[i]->processDidBecomeResponsive();
+}
+
+void WebProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ didFinishLaunching(connectionIdentifier);
+}
+
+void WebProcessProxy::didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ didFinishLaunching(connectionIdentifier);
+}
+
+void WebProcessProxy::didFinishLaunching(CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ ASSERT(!m_connection);
+
+ m_connection = WebConnectionToWebProcess::create(this, connectionIdentifier, RunLoop::main());
+
+ for (size_t i = 0; i < m_pendingMessages.size(); ++i) {
+ CoreIPC::Connection::OutgoingMessage& outgoingMessage = m_pendingMessages[i].first;
+ unsigned messageSendFlags = m_pendingMessages[i].second;
+ connection()->sendMessage(outgoingMessage.messageID(), adoptPtr(outgoingMessage.arguments()), messageSendFlags);
+ }
+
+ m_pendingMessages.clear();
+
+ // Tell the context that we finished launching.
+ m_context->processDidFinishLaunching(this);
+}
+
+WebFrameProxy* WebProcessProxy::webFrame(uint64_t frameID) const
+{
+ return isGoodKey<WebFrameProxyMap>(frameID) ? m_frameMap.get(frameID).get() : 0;
+}
+
+bool WebProcessProxy::canCreateFrame(uint64_t frameID) const
+{
+ return isGoodKey<WebFrameProxyMap>(frameID) && !m_frameMap.contains(frameID);
+}
+
+void WebProcessProxy::frameCreated(uint64_t frameID, WebFrameProxy* frameProxy)
+{
+ ASSERT(canCreateFrame(frameID));
+ m_frameMap.set(frameID, frameProxy);
+}
+
+void WebProcessProxy::didDestroyFrame(uint64_t frameID)
+{
+ // If the page is closed before it has had the chance to send the DidCreateMainFrame message
+ // back to the UIProcess, then the frameDestroyed message will still be received because it
+ // gets sent directly to the WebProcessProxy.
+ ASSERT(isGoodKey<WebFrameProxyMap>(frameID));
+ m_frameMap.remove(frameID);
+}
+
+void WebProcessProxy::disconnectFramesFromPage(WebPageProxy* page)
+{
+ Vector<RefPtr<WebFrameProxy> > frames;
+ copyValuesToVector(m_frameMap, frames);
+ for (size_t i = 0, size = frames.size(); i < size; ++i) {
+ if (frames[i]->page() == page)
+ frames[i]->disconnect();
+ }
+}
+
+size_t WebProcessProxy::frameCountInPage(WebPageProxy* page) const
+{
+ size_t result = 0;
+ for (HashMap<uint64_t, RefPtr<WebFrameProxy> >::const_iterator iter = m_frameMap.begin(); iter != m_frameMap.end(); ++iter) {
+ if (iter->second->page() == page)
+ ++result;
+ }
+ return result;
+}
+
+void WebProcessProxy::shouldTerminate(bool& shouldTerminate)
+{
+ if (!m_pageMap.isEmpty() || !m_context->shouldTerminate(this)) {
+ shouldTerminate = false;
+ return;
+ }
+
+ shouldTerminate = true;
+
+ // We know that the web process is going to terminate so disconnect it from the context.
+ disconnect();
+}
+
+void WebProcessProxy::updateTextCheckerState()
+{
+ if (!isValid())
+ return;
+
+ send(Messages::WebProcess::SetTextCheckerState(TextChecker::state()), 0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.h b/Source/WebKit2/UIProcess/WebProcessProxy.h
new file mode 100644
index 000000000..129e0ea1b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.h
@@ -0,0 +1,227 @@
+/*
+ * 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 WebProcessProxy_h
+#define WebProcessProxy_h
+
+#include "PlatformProcessIdentifier.h"
+#include "PluginInfoStore.h"
+#include "ProcessLauncher.h"
+#include "ProcessModel.h"
+#include "ResponsivenessTimer.h"
+#include "ThreadLauncher.h"
+#include "WebConnectionToWebProcess.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxyMessages.h"
+#include <WebCore/LinkHash.h>
+#include <wtf/Forward.h>
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+ class KURL;
+};
+
+namespace WebKit {
+
+#if PLATFORM(MAC)
+class SecItemRequestData;
+class SecItemResponseData;
+#endif
+
+class WebBackForwardListItem;
+class WebContext;
+class WebPageGroup;
+struct WebNavigationDataStore;
+
+class WebProcessProxy : public RefCounted<WebProcessProxy>, CoreIPC::Connection::Client, ResponsivenessTimer::Client, ProcessLauncher::Client, ThreadLauncher::Client {
+public:
+ typedef HashMap<uint64_t, RefPtr<WebFrameProxy> > WebFrameProxyMap;
+ typedef HashMap<uint64_t, RefPtr<WebBackForwardListItem> > WebBackForwardListItemMap;
+
+ static PassRefPtr<WebProcessProxy> create(PassRefPtr<WebContext>);
+ ~WebProcessProxy();
+
+ void terminate();
+
+ template<typename T> bool send(const T& message, uint64_t destinationID, unsigned messageSendFlags = 0);
+ template<typename U> bool sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout = 1);
+
+ CoreIPC::Connection* connection() const
+ {
+ ASSERT(m_connection);
+
+ return m_connection->connection();
+ }
+ WebConnection* webConnection() const { return m_connection.get(); }
+
+ WebContext* context() const { return m_context.get(); }
+
+ PlatformProcessIdentifier processIdentifier() const { return m_processLauncher->processIdentifier(); }
+
+ WebPageProxy* webPage(uint64_t pageID) const;
+ PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebContext*, WebPageGroup*);
+ void addExistingWebPage(WebPageProxy*, uint64_t pageID);
+ void removeWebPage(uint64_t pageID);
+
+ WebBackForwardListItem* webBackForwardItem(uint64_t itemID) const;
+
+ ResponsivenessTimer* responsivenessTimer() { return &m_responsivenessTimer; }
+
+ bool isValid() const { return m_connection; }
+ bool isLaunching() const;
+ bool canSendMessage() const { return isValid() || isLaunching(); }
+
+ WebFrameProxy* webFrame(uint64_t) const;
+ bool canCreateFrame(uint64_t frameID) const;
+ void frameCreated(uint64_t, WebFrameProxy*);
+ void disconnectFramesFromPage(WebPageProxy*); // Including main frame.
+ size_t frameCountInPage(WebPageProxy*) const; // Including main frame.
+
+ void updateTextCheckerState();
+
+ void registerNewWebBackForwardListItem(WebBackForwardListItem*);
+
+ void willAcquireUniversalFileReadSandboxExtension() { m_mayHaveUniversalFileReadSandboxExtension = true; }
+ void assumeReadAccessToBaseURL(const String&);
+
+ bool checkURLReceivedFromWebProcess(const String&);
+ bool checkURLReceivedFromWebProcess(const WebCore::KURL&);
+
+ static bool fullKeyboardAccessEnabled();
+
+ // FIXME: This variant of send is deprecated. All clients should move to an overload that take a message type.
+ template<typename E, typename T> bool deprecatedSend(E messageID, uint64_t destinationID, const T& arguments);
+
+private:
+ explicit WebProcessProxy(PassRefPtr<WebContext>);
+
+ // Initializes the process or thread launcher which will begin launching the process.
+ void connect();
+
+ // Called when the web process has crashed or we know that it will terminate soon.
+ // Will potentially cause the WebProcessProxy object to be freed.
+ void disconnect();
+
+ bool sendMessage(CoreIPC::MessageID, PassOwnPtr<CoreIPC::ArgumentEncoder>, unsigned messageSendFlags);
+
+ // CoreIPC message handlers.
+ void addBackForwardItem(uint64_t itemID, const String& originalURLString, const String& urlString, const String& title, const CoreIPC::DataReference& backForwardData);
+ void didDestroyFrame(uint64_t);
+
+ void shouldTerminate(bool& shouldTerminate);
+
+#if ENABLE(PLUGIN_PROCESS)
+ void getPluginProcessConnection(const String& pluginPath, PassRefPtr<Messages::WebProcessProxy::GetPluginProcessConnection::DelayedReply>);
+ void pluginSyncMessageSendTimedOut(const String& pluginPath);
+#endif
+#if PLATFORM(MAC)
+ void secItemCopyMatching(const SecItemRequestData&, SecItemResponseData&);
+ void secItemAdd(const SecItemRequestData&, SecItemResponseData&);
+ void secItemUpdate(const SecItemRequestData&, SecItemResponseData&);
+ void secItemDelete(const SecItemRequestData&, SecItemResponseData&);
+ void secKeychainItemCopyContent(const SecKeychainItemRequestData&, SecKeychainItemResponseData&);
+ void secKeychainItemCreateFromContent(const SecKeychainItemRequestData&, SecKeychainItemResponseData&);
+ void secKeychainItemModifyContent(const SecKeychainItemRequestData&, SecKeychainItemResponseData&);
+#endif
+
+ // CoreIPC::Connection::Client
+ friend class WebConnectionToWebProcess;
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, OwnPtr<CoreIPC::ArgumentEncoder>&);
+ virtual void didClose(CoreIPC::Connection*);
+ virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
+ virtual void syncMessageSendTimedOut(CoreIPC::Connection*);
+#if PLATFORM(WIN)
+ virtual Vector<HWND> windowsToReceiveSentMessagesWhileWaitingForSyncReply();
+#endif
+
+ // ResponsivenessTimer::Client
+ void didBecomeUnresponsive(ResponsivenessTimer*);
+ void didBecomeResponsive(ResponsivenessTimer*);
+
+ // ProcessLauncher::Client
+ virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
+
+ // ThreadLauncher::Client
+ virtual void didFinishLaunching(ThreadLauncher*, CoreIPC::Connection::Identifier);
+
+ void didFinishLaunching(CoreIPC::Connection::Identifier);
+
+ // Implemented in generated WebProcessProxyMessageReceiver.cpp
+ void didReceiveWebProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncWebProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply);
+
+ ResponsivenessTimer m_responsivenessTimer;
+
+ // This is not a CoreIPC::Connection so that we can wrap the CoreIPC::Connection in
+ // an API object.
+ RefPtr<WebConnectionToWebProcess> m_connection;
+
+ Vector<std::pair<CoreIPC::Connection::OutgoingMessage, unsigned> > m_pendingMessages;
+ RefPtr<ProcessLauncher> m_processLauncher;
+ RefPtr<ThreadLauncher> m_threadLauncher;
+
+ RefPtr<WebContext> m_context;
+
+ bool m_mayHaveUniversalFileReadSandboxExtension; // True if a read extension for "/" was ever granted - we don't track whether WebProcess still has it.
+ HashSet<String> m_localPathsWithAssumedReadAccess;
+
+ HashMap<uint64_t, WebPageProxy*> m_pageMap;
+ WebFrameProxyMap m_frameMap;
+ WebBackForwardListItemMap m_backForwardListItemMap;
+};
+
+template<typename E, typename T>
+bool WebProcessProxy::deprecatedSend(E messageID, uint64_t destinationID, const T& arguments)
+{
+ OwnPtr<CoreIPC::ArgumentEncoder> argumentEncoder = CoreIPC::ArgumentEncoder::create(destinationID);
+ argumentEncoder->encode(arguments);
+
+ return sendMessage(CoreIPC::MessageID(messageID), argumentEncoder.release(), 0);
+}
+
+template<typename T>
+bool WebProcessProxy::send(const T& message, uint64_t destinationID, unsigned messageSendFlags)
+{
+ OwnPtr<CoreIPC::ArgumentEncoder> argumentEncoder = CoreIPC::ArgumentEncoder::create(destinationID);
+ argumentEncoder->encode(message);
+
+ return sendMessage(CoreIPC::MessageID(T::messageID), argumentEncoder.release(), messageSendFlags);
+}
+
+template<typename U>
+bool WebProcessProxy::sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout)
+{
+ if (!m_connection)
+ return false;
+
+ return connection()->sendSync(message, reply, destinationID, timeout);
+}
+
+} // namespace WebKit
+
+#endif // WebProcessProxy_h
diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.messages.in b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in
new file mode 100644
index 000000000..8943ffc70
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in
@@ -0,0 +1,46 @@
+# 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.
+
+messages -> WebProcessProxy {
+
+ AddBackForwardItem(uint64_t itemID, WTF::String originalURL, WTF::String url, WTF::String title, CoreIPC::DataReference backForwardData)
+ DidDestroyFrame(uint64_t frameID)
+
+ ShouldTerminate() -> (bool shouldTerminate)
+
+#if ENABLE(PLUGIN_PROCESS)
+ GetPluginProcessConnection(WTF::String pluginPath) -> (CoreIPC::Attachment connectionHandle) Delayed
+ PluginSyncMessageSendTimedOut(WTF::String pluginPath)
+#endif
+
+#if PLATFORM(MAC)
+ SecItemCopyMatching(WebKit::SecItemRequestData query) -> (WebKit::SecItemResponseData result)
+ SecItemAdd(WebKit::SecItemRequestData query) -> (WebKit::SecItemResponseData result)
+ SecItemUpdate(WebKit::SecItemRequestData query) -> (WebKit::SecItemResponseData result)
+ SecItemDelete(WebKit::SecItemRequestData query) -> (WebKit::SecItemResponseData result)
+
+ SecKeychainItemCopyContent(WebKit::SecKeychainItemRequestData query) -> (WebKit::SecKeychainItemResponseData result)
+ SecKeychainItemCreateFromContent(WebKit::SecKeychainItemRequestData query) -> (WebKit::SecKeychainItemResponseData result)
+ SecKeychainItemModifyContent(WebKit::SecKeychainItemRequestData query) -> (WebKit::SecKeychainItemResponseData result)
+#endif
+
+}
diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp
new file mode 100644
index 000000000..8c06bdc83
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp
@@ -0,0 +1,96 @@
+/*
+ * 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 "WebResourceCacheManagerProxy.h"
+
+#include "ImmutableArray.h"
+#include "ImmutableDictionary.h"
+#include "SecurityOriginData.h"
+#include "WebContext.h"
+#include "WebResourceCacheManagerMessages.h"
+#include "WebSecurityOrigin.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebResourceCacheManagerProxy> WebResourceCacheManagerProxy::create(WebContext* webContext)
+{
+ return adoptRef(new WebResourceCacheManagerProxy(webContext));
+}
+
+WebResourceCacheManagerProxy::WebResourceCacheManagerProxy(WebContext* webContext)
+ : m_webContext(webContext)
+{
+}
+
+WebResourceCacheManagerProxy::~WebResourceCacheManagerProxy()
+{
+}
+
+void WebResourceCacheManagerProxy::invalidate()
+{
+ invalidateCallbackMap(m_arrayCallbacks);
+}
+
+bool WebResourceCacheManagerProxy::shouldTerminate(WebProcessProxy*) const
+{
+ return m_arrayCallbacks.isEmpty();
+}
+
+void WebResourceCacheManagerProxy::getCacheOrigins(PassRefPtr<ArrayCallback> prpCallback)
+{
+ RefPtr<ArrayCallback> callback = prpCallback;
+ m_webContext->relaunchProcessIfNecessary();
+ uint64_t callbackID = callback->callbackID();
+ m_arrayCallbacks.set(callbackID, callback.release());
+
+ // FIXME (Multi-WebProcess): When multi-process is enabled, we need to aggregate the callback data from all processes.
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::GetCacheOrigins(callbackID));
+}
+
+void WebResourceCacheManagerProxy::didGetCacheOrigins(const Vector<SecurityOriginData>& origins, uint64_t callbackID)
+{
+ RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
+ performAPICallbackWithSecurityOriginDataVector(origins, callback.get());
+}
+
+void WebResourceCacheManagerProxy::clearCacheForOrigin(WebSecurityOrigin* origin, ResourceCachesToClear cachesToClear)
+{
+ SecurityOriginData securityOrigin;
+ securityOrigin.protocol = origin->protocol();
+ securityOrigin.host = origin->host();
+ securityOrigin.port = origin->port();
+
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::ClearCacheForOrigin(securityOrigin, cachesToClear));
+}
+
+void WebResourceCacheManagerProxy::clearCacheForAllOrigins(ResourceCachesToClear cachesToClear)
+{
+ m_webContext->sendToAllProcessesRelaunchingThemIfNecessary(Messages::WebResourceCacheManager::ClearCacheForAllOrigins(cachesToClear));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h
new file mode 100644
index 000000000..f0c7bb549
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h
@@ -0,0 +1,83 @@
+/*
+ * 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 WebResourceCacheManagerProxy_h
+#define WebResourceCacheManagerProxy_h
+
+#include "APIObject.h"
+#include "Arguments.h"
+#include "GenericCallback.h"
+#include "ResourceCachesToClear.h"
+#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
+
+namespace CoreIPC {
+class ArgumentDecoder;
+class Connection;
+class MessageID;
+}
+
+namespace WebKit {
+
+struct SecurityOriginData;
+class WebContext;
+class WebProcessProxy;
+class WebSecurityOrigin;
+
+typedef GenericCallback<WKArrayRef> ArrayCallback;
+
+class WebResourceCacheManagerProxy : public APIObject {
+public:
+ static const Type APIType = TypeCacheManager;
+
+ static PassRefPtr<WebResourceCacheManagerProxy> create(WebContext*);
+ virtual ~WebResourceCacheManagerProxy();
+
+ void invalidate();
+ void clearContext() { m_webContext = 0; }
+
+ void getCacheOrigins(PassRefPtr<ArrayCallback>);
+ void clearCacheForOrigin(WebSecurityOrigin*, ResourceCachesToClear);
+ void clearCacheForAllOrigins(ResourceCachesToClear);
+
+ void didReceiveWebResourceCacheManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+
+ bool shouldTerminate(WebProcessProxy*) const;
+
+private:
+ explicit WebResourceCacheManagerProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ // Message handlers.
+ void didGetCacheOrigins(const Vector<SecurityOriginData>& originIdentifiers, uint64_t callbackID);
+
+ WebContext* m_webContext;
+ HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
+};
+
+} // namespace WebKit
+
+#endif // DatabaseManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.messages.in b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.messages.in
new file mode 100644
index 000000000..c1e73a9af
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.messages.in
@@ -0,0 +1,25 @@
+# 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.
+
+messages -> WebResourceCacheManagerProxy {
+ DidGetCacheOrigins(Vector<WebKit::SecurityOriginData> originIdentifiers, uint64_t callbackID)
+}
diff --git a/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp b/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp
new file mode 100644
index 000000000..f6dbe593b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp
@@ -0,0 +1,91 @@
+/*
+ * 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 "WebResourceLoadClient.h"
+
+#include "WKAPICast.h"
+#include "WebURLRequest.h"
+#include "WebURLResponse.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebResourceLoadClient::didInitiateLoadForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier, const ResourceRequest& resourceRequest, bool pageIsProvisionallyLoading)
+{
+ if (!m_client.didInitiateLoadForResource)
+ return;
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+ return m_client.didInitiateLoadForResource(toAPI(page), toAPI(frame), resourceIdentifier, toAPI(request.get()), pageIsProvisionallyLoading, m_client.clientInfo);
+}
+
+void WebResourceLoadClient::didSendRequestForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier, const ResourceRequest& resourceRequest, const ResourceResponse& redirectResourceResponse)
+{
+ if (!m_client.didSendRequestForResource)
+ return;
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+ RefPtr<WebURLResponse> response;
+ if (!redirectResourceResponse.isNull())
+ response = WebURLResponse::create(redirectResourceResponse);
+ return m_client.didSendRequestForResource(toAPI(page), toAPI(frame), resourceIdentifier, toAPI(request.get()), toAPI(response.get()), m_client.clientInfo);
+}
+
+void WebResourceLoadClient::didReceiveResponseForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier, const ResourceResponse& resourceResponse)
+{
+ if (!m_client.didReceiveResponseForResource)
+ return;
+
+ RefPtr<WebURLResponse> response = WebURLResponse::create(resourceResponse);
+ return m_client.didReceiveResponseForResource(toAPI(page), toAPI(frame), resourceIdentifier, toAPI(response.get()), m_client.clientInfo);
+}
+
+void WebResourceLoadClient::didReceiveContentLengthForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier, uint64_t contentLength)
+{
+ if (!m_client.didReceiveContentLengthForResource)
+ return;
+
+ return m_client.didReceiveContentLengthForResource(toAPI(page), toAPI(frame), resourceIdentifier, contentLength, m_client.clientInfo);
+}
+
+void WebResourceLoadClient::didFinishLoadForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier)
+{
+ if (!m_client.didFinishLoadForResource)
+ return;
+
+ return m_client.didFinishLoadForResource(toAPI(page), toAPI(frame), resourceIdentifier, m_client.clientInfo);
+}
+
+void WebResourceLoadClient::didFailLoadForResource(WebPageProxy* page, WebFrameProxy* frame, uint64_t resourceIdentifier, const ResourceError& error)
+{
+ if (!m_client.didFailLoadForResource)
+ return;
+
+ return m_client.didFailLoadForResource(toAPI(page), toAPI(frame), resourceIdentifier, toAPI(error), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebResourceLoadClient.h b/Source/WebKit2/UIProcess/WebResourceLoadClient.h
new file mode 100644
index 000000000..125546cd0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceLoadClient.h
@@ -0,0 +1,56 @@
+/*
+ * 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 WebResourceLoadClient_h
+#define WebResourceLoadClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+
+namespace WebCore {
+class ResourceError;
+class ResourceRequest;
+class ResourceResponse;
+}
+
+namespace WebKit {
+
+class APIObject;
+class WebFrameProxy;
+class WebPageProxy;
+
+class WebResourceLoadClient : public APIClient<WKPageResourceLoadClient, kWKPageResourceLoadClientCurrentVersion> {
+public:
+ void didInitiateLoadForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, const WebCore::ResourceRequest&, bool pageIsProvisionallyLoading);
+ void didSendRequestForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+ void didReceiveResponseForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, const WebCore::ResourceResponse&);
+ void didReceiveContentLengthForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, uint64_t contentLength);
+ void didFinishLoadForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier);
+ void didFailLoadForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, const WebCore::ResourceError&);
+};
+
+} // namespace WebKit
+
+#endif // WebResourceLoadClient_h
diff --git a/Source/WebKit2/UIProcess/WebTextChecker.cpp b/Source/WebKit2/UIProcess/WebTextChecker.cpp
new file mode 100644
index 000000000..276184419
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebTextChecker.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "WebTextChecker.h"
+
+#include "TextChecker.h"
+#include "WKAPICast.h"
+#include "WebContext.h"
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+WebTextChecker* WebTextChecker::shared()
+{
+ static WebTextChecker* textChecker = adoptRef(new WebTextChecker).leakRef();
+ return textChecker;
+}
+
+WebTextChecker::WebTextChecker()
+{
+}
+
+void WebTextChecker::setClient(const WKTextCheckerClient* client)
+{
+ m_client.initialize(client);
+}
+
+static void updateStateForAllWebProcesses()
+{
+ const Vector<WebContext*>& contexts = WebContext::allContexts();
+ for (size_t i = 0; i < contexts.size(); ++i) {
+ WebProcessProxy* webProcess = contexts[i]->process();
+ if (!webProcess)
+ continue;
+ webProcess->updateTextCheckerState();
+ }
+}
+
+void WebTextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ TextChecker::continuousSpellCheckingEnabledStateChanged(enabled);
+ updateStateForAllWebProcesses();
+}
+
+void WebTextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ TextChecker::grammarCheckingEnabledStateChanged(enabled);
+ updateStateForAllWebProcesses();
+}
+
+void WebTextChecker::checkSpelling(const WebPageProxy* page, bool startBeforeSelection)
+{
+ page->advanceToNextMisspelling(startBeforeSelection);
+}
+
+void WebTextChecker::changeSpellingToWord(const WebPageProxy* page, const String& text)
+{
+ page->changeSpellingToWord(text);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebTextChecker.h b/Source/WebKit2/UIProcess/WebTextChecker.h
new file mode 100644
index 000000000..a1c574ca9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebTextChecker.h
@@ -0,0 +1,63 @@
+/*
+ * 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 WebTextChecker_h
+#define WebTextChecker_h
+
+#include "APIObject.h"
+#include "WKTextChecker.h"
+#include "WebTextCheckerClient.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebTextChecker : public APIObject {
+public:
+ static const Type APIType = TypeTextChecker;
+
+ static WebTextChecker* shared();
+
+ void setClient(const WKTextCheckerClient*);
+ WebTextCheckerClient& client() { return m_client; }
+
+ void continuousSpellCheckingEnabledStateChanged(bool);
+ void grammarCheckingEnabledStateChanged(bool);
+
+ void checkSpelling(const WebPageProxy*, bool startBeforeSelection);
+ void changeSpellingToWord(const WebPageProxy*, const String&);
+
+private:
+ WebTextChecker();
+
+ virtual Type type() const { return APIType; }
+
+ WebTextCheckerClient m_client;
+};
+
+} // namespace WebKit
+
+#endif // WebTextChecker_h
diff --git a/Source/WebKit2/UIProcess/WebTextCheckerClient.cpp b/Source/WebKit2/UIProcess/WebTextCheckerClient.cpp
new file mode 100644
index 000000000..86e52c637
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebTextCheckerClient.cpp
@@ -0,0 +1,175 @@
+/*
+ * 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 "WebTextCheckerClient.h"
+
+#include "ImmutableArray.h"
+#include "WKAPICast.h"
+#include "WKSharedAPICast.h"
+#include "WebGrammarDetail.h"
+#include "WebPageProxy.h"
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+bool WebTextCheckerClient::continuousSpellCheckingAllowed()
+{
+ if (!m_client.continuousSpellCheckingAllowed)
+ return false;
+
+ return m_client.continuousSpellCheckingAllowed(m_client.clientInfo);
+}
+
+bool WebTextCheckerClient::continuousSpellCheckingEnabled()
+{
+ if (!m_client.continuousSpellCheckingEnabled)
+ return false;
+
+ return m_client.continuousSpellCheckingEnabled(m_client.clientInfo);
+}
+
+void WebTextCheckerClient::setContinuousSpellCheckingEnabled(bool enabled)
+{
+ if (!m_client.setContinuousSpellCheckingEnabled)
+ return;
+
+ m_client.setContinuousSpellCheckingEnabled(enabled, m_client.clientInfo);
+}
+
+bool WebTextCheckerClient::grammarCheckingEnabled()
+{
+ if (!m_client.grammarCheckingEnabled)
+ return false;
+
+ return m_client.grammarCheckingEnabled(m_client.clientInfo);
+}
+
+void WebTextCheckerClient::setGrammarCheckingEnabled(bool enabled)
+{
+ if (!m_client.setGrammarCheckingEnabled)
+ return;
+
+ m_client.setGrammarCheckingEnabled(enabled, m_client.clientInfo);
+}
+
+uint64_t WebTextCheckerClient::uniqueSpellDocumentTag(WebPageProxy* page)
+{
+ if (!m_client.uniqueSpellDocumentTag)
+ return 0;
+
+ return m_client.uniqueSpellDocumentTag(toAPI(page), m_client.clientInfo);
+}
+
+void WebTextCheckerClient::closeSpellDocumentWithTag(uint64_t tag)
+{
+ if (!m_client.closeSpellDocumentWithTag)
+ return;
+
+ m_client.closeSpellDocumentWithTag(tag, m_client.clientInfo);
+}
+
+void WebTextCheckerClient::checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
+{
+ if (!m_client.checkSpellingOfString)
+ return;
+
+ m_client.checkSpellingOfString(tag, toAPI(text.impl()), &misspellingLocation, &misspellingLength, m_client.clientInfo);
+}
+
+void WebTextCheckerClient::checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
+{
+ if (!m_client.checkGrammarOfString)
+ return;
+
+ WKArrayRef wkGrammarDetailsRef = 0;
+ m_client.checkGrammarOfString(tag, toAPI(text.impl()), &wkGrammarDetailsRef, &badGrammarLocation, &badGrammarLength, m_client.clientInfo);
+
+ RefPtr<ImmutableArray> wkGrammarDetails = adoptRef(toImpl(wkGrammarDetailsRef));
+ size_t numGrammarDetails = wkGrammarDetails->size();
+ for (size_t i = 0; i < numGrammarDetails; ++i)
+ grammarDetails.append(wkGrammarDetails->at<WebGrammarDetail>(i)->grammarDetail());
+}
+
+bool WebTextCheckerClient::spellingUIIsShowing()
+{
+ if (!m_client.spellingUIIsShowing)
+ return false;
+
+ return m_client.spellingUIIsShowing(m_client.clientInfo);
+}
+
+void WebTextCheckerClient::toggleSpellingUIIsShowing()
+{
+ if (!m_client.toggleSpellingUIIsShowing)
+ return;
+
+ return m_client.toggleSpellingUIIsShowing(m_client.clientInfo);
+}
+
+void WebTextCheckerClient::updateSpellingUIWithMisspelledWord(uint64_t tag, const String& misspelledWord)
+{
+ if (!m_client.updateSpellingUIWithMisspelledWord)
+ return;
+
+ m_client.updateSpellingUIWithMisspelledWord(tag, toAPI(misspelledWord.impl()), m_client.clientInfo);
+}
+
+void WebTextCheckerClient::updateSpellingUIWithGrammarString(uint64_t tag, const String& badGrammarPhrase, const WebCore::GrammarDetail& grammarDetail)
+{
+ if (!m_client.updateSpellingUIWithGrammarString)
+ return;
+
+ m_client.updateSpellingUIWithGrammarString(tag, toAPI(badGrammarPhrase.impl()), toAPI(grammarDetail), m_client.clientInfo);
+}
+
+void WebTextCheckerClient::guessesForWord(uint64_t tag, const String& word, Vector<String>& guesses)
+{
+ if (!m_client.guessesForWord)
+ return;
+
+ RefPtr<ImmutableArray> wkGuesses = adoptRef(toImpl(m_client.guessesForWord(tag, toAPI(word.impl()), m_client.clientInfo)));
+ size_t numGuesses = wkGuesses->size();
+ for (size_t i = 0; i < numGuesses; ++i)
+ guesses.append(wkGuesses->at<WebString>(i)->string());
+}
+
+void WebTextCheckerClient::learnWord(uint64_t tag, const String& word)
+{
+ if (!m_client.learnWord)
+ return;
+
+ m_client.learnWord(tag, toAPI(word.impl()), m_client.clientInfo);
+}
+
+void WebTextCheckerClient::ignoreWord(uint64_t tag, const String& word)
+{
+ if (!m_client.ignoreWord)
+ return;
+
+ m_client.ignoreWord(tag, toAPI(word.impl()), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebTextCheckerClient.h b/Source/WebKit2/UIProcess/WebTextCheckerClient.h
new file mode 100644
index 000000000..b65003d11
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebTextCheckerClient.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 WebTextCheckerClient_h
+#define WebTextCheckerClient_h
+
+#include "APIClient.h"
+#include "WKTextChecker.h"
+#include <WebCore/TextCheckerClient.h>
+#include <wtf/Forward.h>
+#include <wtf/Vector.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebTextCheckerClient : public APIClient<WKTextCheckerClient, kWKTextCheckerClientCurrentVersion> {
+public:
+ bool continuousSpellCheckingAllowed();
+ bool continuousSpellCheckingEnabled();
+ void setContinuousSpellCheckingEnabled(bool);
+ bool grammarCheckingEnabled();
+ void setGrammarCheckingEnabled(bool);
+ uint64_t uniqueSpellDocumentTag(WebPageProxy*);
+ void closeSpellDocumentWithTag(uint64_t);
+ void checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
+ void checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
+ bool spellingUIIsShowing();
+ void toggleSpellingUIIsShowing();
+ void updateSpellingUIWithMisspelledWord(uint64_t tag, const String& misspelledWord);
+ void updateSpellingUIWithGrammarString(uint64_t tag, const String& badGrammarPhrase, const WebCore::GrammarDetail&);
+ void guessesForWord(uint64_t tag, const String& word, Vector<String>& guesses);
+ void learnWord(uint64_t tag, const String& word);
+ void ignoreWord(uint64_t tag, const String& word);
+};
+
+} // namespace WebKit
+
+#endif // WebTextCheckerClient_h
diff --git a/Source/WebKit2/UIProcess/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp
new file mode 100644
index 000000000..d01312208
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebUIClient.cpp
@@ -0,0 +1,414 @@
+/*
+ * 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 "WebUIClient.h"
+
+#include "ImmutableDictionary.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "NotificationPermissionRequest.h"
+#include "WKAPICast.h"
+#include "WebNumber.h"
+#include "WebOpenPanelResultListenerProxy.h"
+#include "WebPageProxy.h"
+#include <WebCore/FloatRect.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/WindowFeatures.h>
+#include <string.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassRefPtr<WebPageProxy> WebUIClient::createNewPage(WebPageProxy* page, const ResourceRequest& resourceRequest, const WindowFeatures& windowFeatures, WebEvent::Modifiers modifiers, WebMouseEvent::Button button)
+{
+ if (!m_client.version && !m_client.createNewPage_deprecatedForUseWithV0)
+ return 0;
+
+ if (m_client.version == kWKPageUIClientCurrentVersion && !m_client.createNewPage)
+ return 0;
+
+ ImmutableDictionary::MapType map;
+ if (windowFeatures.xSet)
+ map.set("x", WebDouble::create(windowFeatures.x));
+ if (windowFeatures.ySet)
+ map.set("y", WebDouble::create(windowFeatures.y));
+ if (windowFeatures.widthSet)
+ map.set("width", WebDouble::create(windowFeatures.width));
+ if (windowFeatures.heightSet)
+ map.set("height", WebDouble::create(windowFeatures.height));
+ map.set("menuBarVisible", WebBoolean::create(windowFeatures.menuBarVisible));
+ map.set("statusBarVisible", WebBoolean::create(windowFeatures.statusBarVisible));
+ map.set("toolBarVisible", WebBoolean::create(windowFeatures.toolBarVisible));
+ map.set("locationBarVisible", WebBoolean::create(windowFeatures.locationBarVisible));
+ map.set("scrollbarsVisible", WebBoolean::create(windowFeatures.scrollbarsVisible));
+ map.set("resizable", WebBoolean::create(windowFeatures.resizable));
+ map.set("fullscreen", WebBoolean::create(windowFeatures.fullscreen));
+ map.set("dialog", WebBoolean::create(windowFeatures.dialog));
+ RefPtr<ImmutableDictionary> featuresMap = ImmutableDictionary::adopt(map);
+
+ if (!m_client.version)
+ return adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(page), toAPI(featuresMap.get()), toAPI(modifiers), toAPI(button), m_client.clientInfo)));
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+ return adoptRef(toImpl(m_client.createNewPage(toAPI(page), toAPI(request.get()), toAPI(featuresMap.get()), toAPI(modifiers), toAPI(button), m_client.clientInfo)));
+}
+
+void WebUIClient::showPage(WebPageProxy* page)
+{
+ if (!m_client.showPage)
+ return;
+
+ m_client.showPage(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::close(WebPageProxy* page)
+{
+ if (!m_client.close)
+ return;
+
+ m_client.close(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::takeFocus(WebPageProxy* page, WKFocusDirection direction)
+{
+ if (!m_client.takeFocus)
+ return;
+
+ m_client.takeFocus(toAPI(page), direction, m_client.clientInfo);
+}
+
+void WebUIClient::focus(WebPageProxy* page)
+{
+ if (!m_client.focus)
+ return;
+
+ m_client.focus(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::unfocus(WebPageProxy* page)
+{
+ if (!m_client.unfocus)
+ return;
+
+ m_client.unfocus(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::runJavaScriptAlert(WebPageProxy* page, const String& message, WebFrameProxy* frame)
+{
+ if (!m_client.runJavaScriptAlert)
+ return;
+
+ m_client.runJavaScriptAlert(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+bool WebUIClient::runJavaScriptConfirm(WebPageProxy* page, const String& message, WebFrameProxy* frame)
+{
+ if (!m_client.runJavaScriptConfirm)
+ return false;
+
+ return m_client.runJavaScriptConfirm(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+String WebUIClient::runJavaScriptPrompt(WebPageProxy* page, const String& message, const String& defaultValue, WebFrameProxy* frame)
+{
+ if (!m_client.runJavaScriptPrompt)
+ return String();
+
+ WebString* string = toImpl(m_client.runJavaScriptPrompt(toAPI(page), toAPI(message.impl()), toAPI(defaultValue.impl()), toAPI(frame), m_client.clientInfo));
+ if (!string)
+ return String();
+
+ String result = string->string();
+ string->deref();
+
+ return result;
+}
+
+void WebUIClient::setStatusText(WebPageProxy* page, const String& text)
+{
+ if (!m_client.setStatusText)
+ return;
+
+ m_client.setStatusText(toAPI(page), toAPI(text.impl()), m_client.clientInfo);
+}
+
+void WebUIClient::mouseDidMoveOverElement(WebPageProxy* page, const WebHitTestResult::Data& data, WebEvent::Modifiers modifiers, APIObject* userData)
+{
+ if (!m_client.mouseDidMoveOverElement && !m_client.mouseDidMoveOverElement_deprecatedForUseWithV0)
+ return;
+
+ if (m_client.version == kWKPageUIClientCurrentVersion && !m_client.mouseDidMoveOverElement)
+ return;
+
+ if (!m_client.version) {
+ m_client.mouseDidMoveOverElement_deprecatedForUseWithV0(toAPI(page), toAPI(modifiers), toAPI(userData), m_client.clientInfo);
+ return;
+ }
+
+ RefPtr<WebHitTestResult> webHitTestResult = WebHitTestResult::create(data);
+ m_client.mouseDidMoveOverElement(toAPI(page), toAPI(webHitTestResult.get()), toAPI(modifiers), toAPI(userData), m_client.clientInfo);
+}
+
+void WebUIClient::missingPluginButtonClicked(WebPageProxy* page, const String& mimeType, const String& url, const String& pluginsPageURL)
+{
+ if (!m_client.missingPluginButtonClicked)
+ return;
+
+ m_client.missingPluginButtonClicked(toAPI(page), toAPI(mimeType.impl()), toAPI(url.impl()), toAPI(pluginsPageURL.impl()), m_client.clientInfo);
+}
+
+bool WebUIClient::implementsDidNotHandleKeyEvent() const
+{
+ return m_client.didNotHandleKeyEvent;
+}
+
+void WebUIClient::didNotHandleKeyEvent(WebPageProxy* page, const NativeWebKeyboardEvent& event)
+{
+ if (!m_client.didNotHandleKeyEvent)
+ return;
+ m_client.didNotHandleKeyEvent(toAPI(page), event.nativeEvent(), m_client.clientInfo);
+}
+
+bool WebUIClient::implementsDidNotHandleWheelEvent() const
+{
+ return m_client.didNotHandleWheelEvent;
+}
+
+void WebUIClient::didNotHandleWheelEvent(WebPageProxy* page, const NativeWebWheelEvent& event)
+{
+ if (!m_client.didNotHandleWheelEvent)
+ return;
+ m_client.didNotHandleWheelEvent(toAPI(page), event.nativeEvent(), m_client.clientInfo);
+}
+
+bool WebUIClient::toolbarsAreVisible(WebPageProxy* page)
+{
+ if (!m_client.toolbarsAreVisible)
+ return true;
+ return m_client.toolbarsAreVisible(toAPI(page), m_client.clientInfo);
+
+}
+void WebUIClient::setToolbarsAreVisible(WebPageProxy* page, bool visible)
+{
+ if (!m_client.setToolbarsAreVisible)
+ return;
+ m_client.setToolbarsAreVisible(toAPI(page), visible, m_client.clientInfo);
+}
+
+bool WebUIClient::menuBarIsVisible(WebPageProxy* page)
+{
+ if (!m_client.menuBarIsVisible)
+ return true;
+ return m_client.menuBarIsVisible(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::setMenuBarIsVisible(WebPageProxy* page, bool visible)
+{
+ if (!m_client.setMenuBarIsVisible)
+ return;
+ m_client.setMenuBarIsVisible(toAPI(page), visible, m_client.clientInfo);
+}
+
+bool WebUIClient::statusBarIsVisible(WebPageProxy* page)
+{
+ if (!m_client.statusBarIsVisible)
+ return true;
+ return m_client.statusBarIsVisible(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::setStatusBarIsVisible(WebPageProxy* page, bool visible)
+{
+ if (!m_client.setStatusBarIsVisible)
+ return;
+ m_client.setStatusBarIsVisible(toAPI(page), visible, m_client.clientInfo);
+}
+
+bool WebUIClient::isResizable(WebPageProxy* page)
+{
+ if (!m_client.isResizable)
+ return true;
+ return m_client.isResizable(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::setIsResizable(WebPageProxy* page, bool resizable)
+{
+ if (!m_client.setIsResizable)
+ return;
+ m_client.setIsResizable(toAPI(page), resizable, m_client.clientInfo);
+}
+
+void WebUIClient::setWindowFrame(WebPageProxy* page, const FloatRect& frame)
+{
+ if (!m_client.setWindowFrame)
+ return;
+
+ m_client.setWindowFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
+FloatRect WebUIClient::windowFrame(WebPageProxy* page)
+{
+ if (!m_client.getWindowFrame)
+ return FloatRect();
+
+ return toFloatRect(m_client.getWindowFrame(toAPI(page), m_client.clientInfo));
+}
+
+bool WebUIClient::canRunBeforeUnloadConfirmPanel() const
+{
+ return m_client.runBeforeUnloadConfirmPanel;
+}
+
+bool WebUIClient::runBeforeUnloadConfirmPanel(WebPageProxy* page, const String& message, WebFrameProxy* frame)
+{
+ if (!m_client.runBeforeUnloadConfirmPanel)
+ return true;
+
+ return m_client.runBeforeUnloadConfirmPanel(toAPI(page), toAPI(message.impl()), toAPI(frame), m_client.clientInfo);
+}
+
+void WebUIClient::didDraw(WebPageProxy* page)
+{
+ if (!m_client.didDraw)
+ return;
+
+ m_client.didDraw(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::pageDidScroll(WebPageProxy* page)
+{
+ if (!m_client.pageDidScroll)
+ return;
+
+ m_client.pageDidScroll(toAPI(page), m_client.clientInfo);
+}
+
+unsigned long long WebUIClient::exceededDatabaseQuota(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage)
+{
+ if (!m_client.exceededDatabaseQuota)
+ return currentQuota;
+
+ return m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, m_client.clientInfo);
+}
+
+bool WebUIClient::runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
+{
+ if (!m_client.runOpenPanel)
+ return false;
+
+ m_client.runOpenPanel(toAPI(page), toAPI(frame), toAPI(parameters), toAPI(listener), m_client.clientInfo);
+ return true;
+}
+
+bool WebUIClient::decidePolicyForGeolocationPermissionRequest(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, GeolocationPermissionRequestProxy* permissionRequest)
+{
+ if (!m_client.decidePolicyForGeolocationPermissionRequest)
+ return false;
+
+ m_client.decidePolicyForGeolocationPermissionRequest(toAPI(page), toAPI(frame), toAPI(origin), toAPI(permissionRequest), m_client.clientInfo);
+ return true;
+}
+
+bool WebUIClient::decidePolicyForNotificationPermissionRequest(WebPageProxy* page, WebSecurityOrigin* origin, NotificationPermissionRequest* permissionRequest)
+{
+ if (!m_client.decidePolicyForNotificationPermissionRequest)
+ return false;
+
+ m_client.decidePolicyForNotificationPermissionRequest(toAPI(page), toAPI(origin), toAPI(permissionRequest), m_client.clientInfo);
+ return true;
+}
+
+float WebUIClient::headerHeight(WebPageProxy* page, WebFrameProxy* frame)
+{
+ if (!m_client.headerHeight)
+ return 0;
+
+ return m_client.headerHeight(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
+float WebUIClient::footerHeight(WebPageProxy* page, WebFrameProxy* frame)
+{
+ if (!m_client.footerHeight)
+ return 0;
+
+ return m_client.footerHeight(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
+void WebUIClient::drawHeader(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect)
+{
+ if (!m_client.drawHeader)
+ return;
+
+ m_client.drawHeader(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo);
+}
+
+void WebUIClient::drawFooter(WebPageProxy* page, WebFrameProxy* frame, const WebCore::FloatRect& rect)
+{
+ if (!m_client.drawFooter)
+ return;
+
+ m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.clientInfo);
+}
+
+void WebUIClient::printFrame(WebPageProxy* page, WebFrameProxy* frame)
+{
+ if (!m_client.printFrame)
+ return;
+
+ m_client.printFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
+}
+
+bool WebUIClient::canRunModal() const
+{
+ return m_client.runModal;
+}
+
+void WebUIClient::runModal(WebPageProxy* page)
+{
+ if (!m_client.runModal)
+ return;
+
+ m_client.runModal(toAPI(page), m_client.clientInfo);
+}
+
+void WebUIClient::saveDataToFileInDownloadsFolder(WebPageProxy* page, const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData* data)
+{
+ if (!m_client.saveDataToFileInDownloadsFolder)
+ return;
+
+ m_client.saveDataToFileInDownloadsFolder(toAPI(page), toAPI(suggestedFilename.impl()), toAPI(mimeType.impl()), toURLRef(originatingURLString.impl()), toAPI(data), m_client.clientInfo);
+}
+
+bool WebUIClient::shouldInterruptJavaScript(WebPageProxy* page)
+{
+ if (!m_client.shouldInterruptJavaScript)
+ return false;
+
+ return m_client.shouldInterruptJavaScript(toAPI(page), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h
new file mode 100644
index 000000000..835e6ceb7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebUIClient.h
@@ -0,0 +1,122 @@
+/*
+ * 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 WebUIClient_h
+#define WebUIClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include "WebEvent.h"
+#include "WebHitTestResult.h"
+#include "WebOpenPanelParameters.h"
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+ class FloatRect;
+ class IntSize;
+ class ResourceRequest;
+ struct WindowFeatures;
+}
+
+namespace WebKit {
+
+class APIObject;
+class GeolocationPermissionRequestProxy;
+class NativeWebKeyboardEvent;
+class NativeWebWheelEvent;
+class NotificationPermissionRequest;
+class WebData;
+class WebFrameProxy;
+class WebPageProxy;
+class WebSecurityOrigin;
+class WebOpenPanelResultListenerProxy;
+
+class WebUIClient : public APIClient<WKPageUIClient, kWKPageUIClientCurrentVersion> {
+public:
+ PassRefPtr<WebPageProxy> createNewPage(WebPageProxy*, const WebCore::ResourceRequest&, const WebCore::WindowFeatures&, WebEvent::Modifiers, WebMouseEvent::Button);
+ void showPage(WebPageProxy*);
+ void close(WebPageProxy*);
+
+ void takeFocus(WebPageProxy*, WKFocusDirection);
+ void focus(WebPageProxy*);
+ void unfocus(WebPageProxy*);
+
+ void runJavaScriptAlert(WebPageProxy*, const String&, WebFrameProxy*);
+ bool runJavaScriptConfirm(WebPageProxy*, const String&, WebFrameProxy*);
+ String runJavaScriptPrompt(WebPageProxy*, const String&, const String&, WebFrameProxy*);
+
+ void setStatusText(WebPageProxy*, const String&);
+ void mouseDidMoveOverElement(WebPageProxy*, const WebHitTestResult::Data&, WebEvent::Modifiers, APIObject*);
+ void missingPluginButtonClicked(WebPageProxy*, const String& mimeType, const String& url, const String& pluginsPageURL);
+
+ bool implementsDidNotHandleKeyEvent() const;
+ void didNotHandleKeyEvent(WebPageProxy*, const NativeWebKeyboardEvent&);
+
+ bool implementsDidNotHandleWheelEvent() const;
+ void didNotHandleWheelEvent(WebPageProxy*, const NativeWebWheelEvent&);
+
+ bool toolbarsAreVisible(WebPageProxy*);
+ void setToolbarsAreVisible(WebPageProxy*, bool);
+ bool menuBarIsVisible(WebPageProxy*);
+ void setMenuBarIsVisible(WebPageProxy*, bool);
+ bool statusBarIsVisible(WebPageProxy*);
+ void setStatusBarIsVisible(WebPageProxy*, bool);
+ bool isResizable(WebPageProxy*);
+ void setIsResizable(WebPageProxy*, bool);
+
+ void setWindowFrame(WebPageProxy*, const WebCore::FloatRect&);
+ WebCore::FloatRect windowFrame(WebPageProxy*);
+
+ bool canRunBeforeUnloadConfirmPanel() const;
+ bool runBeforeUnloadConfirmPanel(WebPageProxy*, const String&, WebFrameProxy*);
+
+ void didDraw(WebPageProxy*);
+ void pageDidScroll(WebPageProxy*);
+
+ unsigned long long exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage);
+
+ bool runOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*);
+ bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy*);
+ bool decidePolicyForNotificationPermissionRequest(WebPageProxy*, WebSecurityOrigin*, NotificationPermissionRequest*);
+
+ // Printing.
+ float headerHeight(WebPageProxy*, WebFrameProxy*);
+ float footerHeight(WebPageProxy*, WebFrameProxy*);
+ void drawHeader(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&);
+ void drawFooter(WebPageProxy*, WebFrameProxy*, const WebCore::FloatRect&);
+ void printFrame(WebPageProxy*, WebFrameProxy*);
+
+ bool canRunModal() const;
+ void runModal(WebPageProxy*);
+
+ void saveDataToFileInDownloadsFolder(WebPageProxy*, const String& suggestedFilename, const String& mimeType, const String& originatingURLString, WebData*);
+
+ bool shouldInterruptJavaScript(WebPageProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebUIClient_h
diff --git a/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp b/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp
new file mode 100644
index 000000000..51608a588
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cairo/BackingStoreCairo.cpp
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2011 Apple 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 "BackingStore.h"
+
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+#include "WebPageProxy.h"
+#include <WebCore/GraphicsContext.h>
+#include <cairo/cairo.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void BackingStore::paint(cairo_t* context, const IntRect& rect)
+{
+ ASSERT(m_backingStore);
+
+ cairo_set_operator(context, CAIRO_OPERATOR_SOURCE);
+ cairo_set_source_surface(context, m_backingStore->cairoSurface(), 0, 0);
+ cairo_rectangle(context, rect.x(), rect.y(), rect.width(), rect.height());
+ cairo_fill(context);
+}
+
+void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
+{
+ if (!m_backingStore)
+ m_backingStore = WidgetBackingStore::create(m_webPageProxy->viewWidget(), size());
+
+ scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
+
+ // Paint all update rects.
+ IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+ RefPtr<cairo_t> context(adoptRef(cairo_create(m_backingStore->cairoSurface())));
+ GraphicsContext graphicsContext(context.get());
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
+ IntRect updateRect = updateInfo.updateRects[i];
+ IntRect srcRect = updateRect;
+ srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
+ bitmap->paint(graphicsContext, updateRect.location(), srcRect);
+ }
+}
+
+void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ if (scrollOffset.isZero())
+ return;
+
+ ASSERT(m_backingStore);
+ m_backingStore->scroll(scrollRect, scrollOffset);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
new file mode 100644
index 000000000..72c3617af
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
@@ -0,0 +1,171 @@
+/*
+ * 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 "WebBackForwardList.h"
+
+#include "Logging.h"
+#include <wtf/RetainPtr.h>
+#include <CoreFoundation/CoreFoundation.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t generateWebBackForwardItemID()
+{
+ // These IDs exist in the UIProcess for items created by the UIProcess.
+ // The IDs generated here need to never collide with the IDs created in WebBackForwardListProxy in the WebProcess.
+ // We accomplish this by starting from 2, and only ever using even ids.
+ static uint64_t uniqueHistoryItemID = 0;
+ uniqueHistoryItemID += 2;
+ return uniqueHistoryItemID;
+}
+
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryCurrentIndexKey, (CFSTR("SessionHistoryCurrentIndex")));
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntriesKey, (CFSTR("SessionHistoryEntries")));
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryTitleKey, (CFSTR("SessionHistoryEntryTitle")));
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryURLKey, (CFSTR("SessionHistoryEntryURL")));
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryOriginalURLKey, (CFSTR("SessionHistoryEntryOriginalURL")));
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryDataKey, (CFSTR("SessionHistoryEntryData")));
+
+CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback filter, void* context) const
+{
+ ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+
+ RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks));
+
+ // We may need to update the current index to account for entries that are filtered by the callback.
+ int currentIndex = m_current;
+
+ for (size_t i = 0; i < m_entries.size(); ++i) {
+ RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url());
+ if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) {
+ if (i <= static_cast<size_t>(m_current))
+ currentIndex--;
+ continue;
+ }
+
+ RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString());
+ RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString());
+ RetainPtr<CFStringRef> originalURL(AdoptCF, m_entries[i]->originalURL().createCFString());
+
+ // FIXME: This uses the CoreIPC data encoding format, which means that whenever we change the CoreIPC encoding we need to bump the CurrentSessionStateDataVersion
+ // constant in WebPageProxyCF.cpp. The CoreIPC data format is meant to be an implementation detail, and not something that should be written to disk.
+ RetainPtr<CFDataRef> entryData(AdoptCF, CFDataCreate(kCFAllocatorDefault, m_entries[i]->backForwardData().data(), m_entries[i]->backForwardData().size()));
+
+ const void* keys[4] = { SessionHistoryEntryURLKey(), SessionHistoryEntryTitleKey(), SessionHistoryEntryOriginalURLKey(), SessionHistoryEntryDataKey() };
+ const void* values[4] = { url.get(), title.get(), originalURL.get(), entryData.get() };
+
+ RetainPtr<CFDictionaryRef> entryDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+ CFArrayAppendValue(entries.get(), entryDictionary.get());
+ }
+
+ ASSERT(currentIndex < CFArrayGetCount(entries.get()) && currentIndex >= static_cast<int>(NoCurrentItemIndex));
+ RetainPtr<CFNumberRef> currentIndexNumber(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &currentIndex));
+
+ const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() };
+ const void* values[2] = { currentIndexNumber.get(), entries.get() };
+
+ return CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+}
+
+bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef dictionary)
+{
+ CFNumberRef cfIndex = (CFNumberRef)CFDictionaryGetValue(dictionary, SessionHistoryCurrentIndexKey());
+ if (!cfIndex || CFGetTypeID(cfIndex) != CFNumberGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList dictionary representation does not have a valid current index");
+ return false;
+ }
+
+ CFIndex currentIndex;
+ if (!CFNumberGetValue(cfIndex, kCFNumberCFIndexType, &currentIndex)) {
+ LOG(SessionState, "WebBackForwardList dictionary representation does not have a valid integer current index");
+ return false;
+ }
+
+ CFArrayRef cfEntries = (CFArrayRef)CFDictionaryGetValue(dictionary, SessionHistoryEntriesKey());
+ if (!cfEntries || CFGetTypeID(cfEntries) != CFArrayGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList dictionary representation does not have a valid list of entries");
+ return false;
+ }
+
+ CFIndex size = CFArrayGetCount(cfEntries);
+ if (currentIndex != static_cast<CFIndex>(NoCurrentItemIndex) && currentIndex >= size) {
+ LOG(SessionState, "WebBackForwardList dictionary representation contains an invalid current index (%ld) for the number of entries (%ld)", currentIndex, size);
+ return false;
+ }
+
+ if (currentIndex == static_cast<CFIndex>(NoCurrentItemIndex) && size) {
+ LOG(SessionState, "WebBackForwardList dictionary representation says there is no current item index, but there is a list of %ld entries - this is bogus", size);
+ return false;
+ }
+
+ BackForwardListItemVector newEntries;
+ newEntries.reserveCapacity(size);
+ for (CFIndex i = 0; i < size; ++i) {
+ CFDictionaryRef entryDictionary = (CFDictionaryRef)CFArrayGetValueAtIndex(cfEntries, i);
+ if (!entryDictionary || CFGetTypeID(entryDictionary) != CFDictionaryGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList entry array does not have a valid entry at index %i", (int)i);
+ return false;
+ }
+
+ CFStringRef entryURL = (CFStringRef)CFDictionaryGetValue(entryDictionary, SessionHistoryEntryURLKey());
+ if (!entryURL || CFGetTypeID(entryURL) != CFStringGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList entry at index %i does not have a valid URL", (int)i);
+ return false;
+ }
+
+ CFStringRef entryTitle = (CFStringRef)CFDictionaryGetValue(entryDictionary, SessionHistoryEntryTitleKey());
+ if (!entryTitle || CFGetTypeID(entryTitle) != CFStringGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList entry at index %i does not have a valid title", (int)i);
+ return false;
+ }
+
+ CFStringRef originalURL = (CFStringRef)CFDictionaryGetValue(entryDictionary, SessionHistoryEntryOriginalURLKey());
+ if (!originalURL || CFGetTypeID(originalURL) != CFStringGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList entry at index %i does not have a valid original URL", (int)i);
+ return false;
+ }
+
+ CFDataRef backForwardData = (CFDataRef)CFDictionaryGetValue(entryDictionary, SessionHistoryEntryDataKey());
+ if (!backForwardData || CFGetTypeID(backForwardData) != CFDataGetTypeID()) {
+ LOG(SessionState, "WebBackForwardList entry at index %i does not have back/forward data", (int)i);
+ return false;
+ }
+
+ newEntries.append(WebBackForwardListItem::create(originalURL, entryURL, entryTitle, CFDataGetBytePtr(backForwardData), CFDataGetLength(backForwardData), generateWebBackForwardItemID()));
+ }
+
+ m_entries = newEntries;
+ m_current = currentIndex;
+ // Perform a sanity check: in case we're out of range, we reset.
+ if (m_current != NoCurrentItemIndex && m_current >= newEntries.size())
+ m_current = NoCurrentItemIndex;
+
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp b/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
new file mode 100644
index 000000000..41fd01baa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
@@ -0,0 +1,229 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "DataReference.h"
+#include "Logging.h"
+#include "SessionState.h"
+#include "WebBackForwardList.h"
+#include "WebData.h"
+#include "WebPageMessages.h"
+#include "WebProcessProxy.h"
+
+#include <wtf/RetainPtr.h>
+#include <CoreFoundation/CFPropertyList.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryKey, (CFSTR("SessionHistory")));
+DEFINE_STATIC_GETTER(CFStringRef, ProvisionalURLKey, (CFSTR("ProvisionalURL")));
+
+static const UInt32 CurrentSessionStateDataVersion = 3;
+
+PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const
+{
+ const void* keys[2];
+ const void* values[2];
+ CFIndex numValues = 0;
+
+ RetainPtr<CFDictionaryRef> sessionHistoryDictionary(AdoptCF, m_backForwardList->createCFDictionaryRepresentation(filter, context));
+ if (sessionHistoryDictionary) {
+ keys[numValues] = SessionHistoryKey();
+ values[numValues] = sessionHistoryDictionary.get();
+ ++numValues;
+ }
+
+ RetainPtr<CFStringRef> provisionalURLString;
+ if (m_mainFrame) {
+ String provisionalURL = pendingAPIRequestURL();
+ if (provisionalURL.isEmpty())
+ provisionalURL = m_mainFrame->provisionalURL();
+ if (!provisionalURL.isEmpty()) {
+ provisionalURLString.adoptCF(provisionalURL.createCFString());
+ keys[numValues] = ProvisionalURLKey();
+ values[numValues] = provisionalURLString.get();
+ ++numValues;
+ }
+ }
+
+ if (!numValues)
+ return 0;
+
+ RetainPtr<CFDictionaryRef> stateDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, numValues, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+
+ RetainPtr<CFWriteStreamRef> writeStream(AdoptCF, CFWriteStreamCreateWithAllocatedBuffers(0, 0));
+ if (!writeStream)
+ return 0;
+
+ if (!CFWriteStreamOpen(writeStream.get()))
+ return 0;
+
+ if (!CFPropertyListWriteToStream(stateDictionary.get(), writeStream.get(), kCFPropertyListBinaryFormat_v1_0, 0))
+ return 0;
+
+ RetainPtr<CFDataRef> stateCFData(AdoptCF, (CFDataRef)CFWriteStreamCopyProperty(writeStream.get(), kCFStreamPropertyDataWritten));
+
+ CFIndex length = CFDataGetLength(stateCFData.get());
+ Vector<unsigned char> stateVector(length + sizeof(UInt32));
+
+ // Put the session state version number at the start of the buffer
+ stateVector.data()[0] = (CurrentSessionStateDataVersion & 0xFF000000) >> 24;
+ stateVector.data()[1] = (CurrentSessionStateDataVersion & 0x00FF0000) >> 16;
+ stateVector.data()[2] = (CurrentSessionStateDataVersion & 0x0000FF00) >> 8;
+ stateVector.data()[3] = (CurrentSessionStateDataVersion & 0x000000FF);
+
+ // Copy in the actual session state data
+ CFDataGetBytes(stateCFData.get(), CFRangeMake(0, length), stateVector.data() + sizeof(UInt32));
+
+ return WebData::create(stateVector);
+}
+
+void WebPageProxy::restoreFromSessionStateData(WebData* webData)
+{
+ if (!webData || webData->size() < sizeof(UInt32))
+ return;
+
+ const unsigned char* buffer = webData->bytes();
+ UInt32 versionHeader = (buffer[0] << 24) + (buffer[1] << 16) + (buffer[2] << 8) + buffer[3];
+
+ if (versionHeader != CurrentSessionStateDataVersion) {
+ LOG(SessionState, "Unrecognized version header for session state data - cannot restore");
+ return;
+ }
+
+ RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(0, webData->bytes() + sizeof(UInt32), webData->size() - sizeof(UInt32)));
+
+ CFStringRef propertyListError = 0;
+ RetainPtr<CFPropertyListRef> propertyList(AdoptCF, CFPropertyListCreateFromXMLData(0, data.get(), kCFPropertyListImmutable, &propertyListError));
+ if (propertyListError) {
+ CFRelease(propertyListError);
+ LOG(SessionState, "Could not read session state property list");
+ return;
+ }
+
+ if (!propertyList)
+ return;
+
+ if (CFGetTypeID(propertyList.get()) != CFDictionaryGetTypeID()) {
+ LOG(SessionState, "SessionState property list is not a CFDictionaryRef (%i) - its CFTypeID is %i", (int)CFDictionaryGetTypeID(), (int)CFGetTypeID(propertyList.get()));
+ return;
+ }
+
+ CFDictionaryRef backForwardListDictionary = 0;
+ if (CFTypeRef value = CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), SessionHistoryKey())) {
+ if (CFGetTypeID(value) != CFDictionaryGetTypeID())
+ LOG(SessionState, "SessionState dictionary has a SessionHistory key, but the value is not a dictionary");
+ else
+ backForwardListDictionary = static_cast<CFDictionaryRef>(value);
+ }
+
+ CFStringRef provisionalURL = 0;
+ if (CFTypeRef value = CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), ProvisionalURLKey())) {
+ if (CFGetTypeID(value) != CFStringGetTypeID())
+ LOG(SessionState, "SessionState dictionary has a ProvisionalValue key, but the value is not a string");
+ else
+ provisionalURL = static_cast<CFStringRef>(value);
+ }
+
+ if (backForwardListDictionary) {
+ if (!m_backForwardList->restoreFromCFDictionaryRepresentation(backForwardListDictionary))
+ LOG(SessionState, "Failed to restore back/forward list from SessionHistory dictionary");
+ else {
+ const BackForwardListItemVector& entries = m_backForwardList->entries();
+ if (size_t size = entries.size()) {
+ for (size_t i = 0; i < size; ++i)
+ process()->registerNewWebBackForwardListItem(entries[i].get());
+
+ SessionState state(m_backForwardList->entries(), m_backForwardList->currentIndex());
+ if (provisionalURL)
+ process()->send(Messages::WebPage::RestoreSession(state), m_pageID);
+ else {
+ SandboxExtension::Handle sandboxExtensionHandle;
+ if (WebBackForwardListItem* item = m_backForwardList->currentItem()) {
+ bool createdExtension = maybeInitializeSandboxExtensionHandle(KURL(KURL(), item->url()), sandboxExtensionHandle);
+ if (createdExtension)
+ process()->willAcquireUniversalFileReadSandboxExtension();
+ setPendingAPIRequestURL(item->url());
+ }
+
+ process()->send(Messages::WebPage::RestoreSessionAndNavigateToCurrentItem(state, sandboxExtensionHandle), m_pageID);
+ }
+ }
+ }
+ }
+
+ if (provisionalURL)
+ loadURL(provisionalURL);
+}
+
+static RetainPtr<CFStringRef> autosaveKey(const String& name)
+{
+ String key = "com.apple.WebKit.searchField:" + name;
+ return RetainPtr<CFStringRef>(AdoptCF, key.createCFString());
+}
+
+void WebPageProxy::saveRecentSearches(const String& name, const Vector<String>& searchItems)
+{
+ // The WebProcess shouldn't have bothered to send this message if the name was empty.
+ ASSERT(!name.isEmpty());
+
+ RetainPtr<CFMutableArrayRef> items;
+
+ if (size_t size = searchItems.size()) {
+ items.adoptCF(CFArrayCreateMutable(0, size, &kCFTypeArrayCallBacks));
+ for (size_t i = 0; i < size; ++i) {
+ RetainPtr<CFStringRef> item(AdoptCF, searchItems[i].createCFString());
+ CFArrayAppendValue(items.get(), item.get());
+ }
+ }
+
+ CFPreferencesSetAppValue(autosaveKey(name).get(), items.get(), kCFPreferencesCurrentApplication);
+ CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
+}
+
+void WebPageProxy::loadRecentSearches(const String& name, Vector<String>& searchItems)
+{
+ // The WebProcess shouldn't have bothered to send this message if the name was empty.
+ ASSERT(!name.isEmpty());
+
+ searchItems.clear();
+ RetainPtr<CFArrayRef> items(AdoptCF, reinterpret_cast<CFArrayRef>(CFPreferencesCopyAppValue(autosaveKey(name).get(), kCFPreferencesCurrentApplication)));
+
+ if (!items || CFGetTypeID(items.get()) != CFArrayGetTypeID())
+ return;
+
+ size_t size = CFArrayGetCount(items.get());
+ for (size_t i = 0; i < size; ++i) {
+ CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(items.get(), i);
+ if (CFGetTypeID(item) == CFStringGetTypeID())
+ searchItems.append(item);
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
new file mode 100644
index 000000000..5f6ca9d27
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
@@ -0,0 +1,146 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include <wtf/RetainPtr.h>
+#include <wtf/text/StringConcatenate.h>
+
+#if !PLATFORM(MAC)
+
+namespace WebKit {
+
+static RetainPtr<CFStringRef> cfStringFromWebCoreString(const String& string)
+{
+ return RetainPtr<CFStringRef>(AdoptCF, CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar*>(string.characters()), string.length()));
+}
+
+static inline RetainPtr<CFStringRef> makeKey(const String& identifier, const String& baseKey)
+{
+ return cfStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey));
+}
+
+static void setStringValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store)
+{
+ RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication));
+ if (!value)
+ return;
+ if (CFGetTypeID(value.get()) != CFStringGetTypeID())
+ return;
+
+ store.setStringValueForKey(baseKey, (CFStringRef)value.get());
+}
+
+static void setBoolValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store)
+{
+ RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication));
+ if (!value)
+ return;
+ if (CFGetTypeID(value.get()) != CFBooleanGetTypeID())
+ return;
+
+ store.setBoolValueForKey(baseKey, CFBooleanGetValue((CFBooleanRef)value.get()) ? true : false);
+}
+
+static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store)
+{
+ RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication));
+ if (!value)
+ return;
+ if (CFGetTypeID(value.get()) != CFNumberGetTypeID())
+ return;
+ int32_t intValue = 0;
+ if (!CFNumberGetValue((CFNumberRef)value.get(), kCFNumberSInt32Type, &intValue))
+ return;
+
+ store.setUInt32ValueForKey(baseKey, intValue);
+}
+
+static void setDoubleValueIfInUserDefaults(const String& identifier, const String& baseKey, WebPreferencesStore& store)
+{
+ RetainPtr<CFPropertyListRef> value(AdoptCF, CFPreferencesCopyAppValue(makeKey(identifier, baseKey).get(), kCFPreferencesCurrentApplication));
+ if (!value)
+ return;
+ if (CFGetTypeID(value.get()) != CFNumberGetTypeID())
+ return;
+ double doubleValue = 0;
+ if (!CFNumberGetValue((CFNumberRef)value.get(), kCFNumberDoubleType, &doubleValue))
+ return;
+
+ store.setDoubleValueForKey(baseKey, doubleValue);
+}
+
+void WebPreferences::platformInitializeStore()
+{
+ if (!m_identifier)
+ return;
+
+#define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+ set##TypeName##ValueIfInUserDefaults(m_identifier, WebPreferencesKey::KeyLower##Key(), m_store);
+
+ FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS)
+
+#undef INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS
+
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String& key, const String& value)
+{
+ if (!m_identifier)
+ return;
+
+ CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), cfStringFromWebCoreString(value).get(), kCFPreferencesCurrentApplication);
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String& key, bool value)
+{
+ if (!m_identifier)
+ return;
+
+ CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), value ? kCFBooleanTrue : kCFBooleanFalse, kCFPreferencesCurrentApplication);
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String& key, uint32_t value)
+{
+ if (!m_identifier)
+ return;
+
+ RetainPtr<CFNumberRef> number(AdoptCF, CFNumberCreate(0, kCFNumberSInt32Type, &value));
+ CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), number.get(), kCFPreferencesCurrentApplication);
+}
+
+void WebPreferences::platformUpdateDoubleValueForKey(const String& key, double value)
+{
+ if (!m_identifier)
+ return;
+
+ RetainPtr<CFNumberRef> number(AdoptCF, CFNumberCreate(0, kCFNumberDoubleType, &value));
+ CFPreferencesSetAppValue(makeKey(m_identifier, key).get(), number.get(), kCFPreferencesCurrentApplication);
+}
+
+} // namespace WebKit
+
+#endif // !PLATFORM(MAC)
diff --git a/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp b/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp
new file mode 100644
index 000000000..aa33f2f4c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp
@@ -0,0 +1,127 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "TextCheckerState.h"
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static TextCheckerState textCheckerState;
+
+const TextCheckerState& TextChecker::state()
+{
+ notImplemented();
+ return textCheckerState;
+}
+
+bool TextChecker::isContinuousSpellCheckingAllowed()
+{
+ notImplemented();
+ return false;
+}
+
+void TextChecker::setContinuousSpellCheckingEnabled(bool)
+{
+ notImplemented();
+}
+
+void TextChecker::setGrammarCheckingEnabled(bool)
+{
+ notImplemented();
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ notImplemented();
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ notImplemented();
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
+{
+ notImplemented();
+}
+
+void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
+{
+ notImplemented();
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ notImplemented();
+ return false;
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ notImplemented();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&)
+{
+ notImplemented();
+}
+
+void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t, const String&, const String&, Vector<String>&)
+{
+ notImplemented();
+}
+
+void TextChecker::learnWord(int64_t, const String&)
+{
+ notImplemented();
+}
+
+void TextChecker::ignoreWord(int64_t, const String&)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp
new file mode 100644
index 000000000..ac77ef3f2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/efl/WebContextEfl.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "WebContext.h"
+
+#include <WebCore/ApplicationCacheStorage.h>
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+String WebContext::applicationCacheDirectory()
+{
+ return WebCore::cacheStorage().cacheDirectory();
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters&)
+{
+ notImplemented();
+}
+
+void WebContext::platformInvalidateContext()
+{
+ notImplemented();
+}
+
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+ notImplemented();
+ return "";
+}
+
+String WebContext::platformDefaultIconDatabasePath() const
+{
+ notImplemented();
+ return "";
+}
+
+String WebContext::platformDefaultLocalStorageDirectory() const
+{
+ notImplemented();
+ return "";
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp b/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp
new file mode 100644
index 000000000..9e7696716
--- /dev/null
+++ b/Source/WebKit2/UIProcess/efl/WebInspectorEfl.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <WebCore/NotImplemented.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String&)
+{
+ notImplemented();
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ notImplemented();
+ return String();
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ notImplemented();
+ return String();
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
new file mode 100644
index 000000000..ae314b857
--- /dev/null
+++ b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp
@@ -0,0 +1,79 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "NotImplemented.h"
+#include "PageClientImpl.h"
+
+#include <sys/utsname.h>
+
+namespace WebKit {
+
+Evas_Object* WebPageProxy::viewObject()
+{
+ return static_cast<PageClientImpl*>(m_pageClient)->viewObject();
+}
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ WTF::String platform;
+ WTF::String version;
+ WTF::String osVersion;
+
+#if PLATFORM(X11)
+ platform = "X11";
+#else
+ platform = "Unknown";
+#endif
+ version = makeString(String::number(WEBKIT_USER_AGENT_MAJOR_VERSION), '.',
+ String::number(WEBKIT_USER_AGENT_MINOR_VERSION), '+');
+ struct utsname name;
+ if (uname(&name) != -1)
+ osVersion = WTF::String(name.sysname) + " " + WTF::String(name.machine);
+ else
+ osVersion = "Unknown";
+
+ return makeString("Mozilla/5.0 (", platform, "; ", osVersion, ") AppleWebKit/", version)
+ + makeString(" (KHTML, like Gecko) Version/5.0 Safari/", version);
+}
+
+void WebPageProxy::getEditorCommandsForKeyEvent(Vector<WTF::String>& commandsList)
+{
+ notImplemented();
+}
+
+void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
+{
+ notImplemented();
+}
+
+void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp
new file mode 100644
index 000000000..b49ad2998
--- /dev/null
+++ b/Source/WebKit2/UIProcess/efl/WebPreferencesEfl.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void WebPreferences::platformInitializeStore()
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String&, bool)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp
new file mode 100644
index 000000000..5b26d1207
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp
@@ -0,0 +1,140 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "TextCheckerState.h"
+#include "WebTextChecker.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static TextCheckerState textCheckerState;
+
+const TextCheckerState& TextChecker::state()
+{
+ static bool didInitializeState;
+ if (didInitializeState)
+ return textCheckerState;
+
+ WebTextCheckerClient& client = WebTextChecker::shared()->client();
+ textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
+ textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled();
+
+ didInitializeState = true;
+
+ return textCheckerState;
+}
+
+bool TextChecker::isContinuousSpellCheckingAllowed()
+{
+ return WebTextChecker::shared()->client().continuousSpellCheckingAllowed();
+}
+
+void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+{
+ if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
+ return;
+ textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
+ WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
+}
+
+void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
+{
+ if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
+ return;
+ textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
+ WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled);
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isGrammarCheckingEnabled = enabled;
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page)
+{
+ return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page);
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+{
+ WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag);
+}
+
+void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
+{
+ WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
+}
+
+void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
+{
+ WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength);
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ return WebTextChecker::shared()->client().spellingUIIsShowing();
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ WebTextChecker::shared()->client().toggleSpellingUIIsShowing();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord)
+{
+ WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord);
+}
+
+void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+{
+ WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail);
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses);
+}
+
+void TextChecker::learnWord(int64_t spellDocumentTag, const String& word)
+{
+ WebTextChecker::shared()->client().learnWord(spellDocumentTag, word);
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp
new file mode 100644
index 000000000..71c7bbe3c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 "WebContext.h"
+#include <WebCore/FileSystem.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+namespace WebKit {
+
+WTF::String WebContext::applicationCacheDirectory()
+{
+ GOwnPtr<gchar> cacheDirectory(g_build_filename(g_get_user_cache_dir(), "webkitgtk", "applications", NULL));
+ return WebCore::filenameToString(cacheDirectory.get());
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters&)
+{
+}
+
+void WebContext::platformInvalidateContext()
+{
+}
+
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+ GOwnPtr<gchar> databaseDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "databases", NULL));
+ return WebCore::filenameToString(databaseDirectory.get());
+}
+
+String WebContext::platformDefaultIconDatabasePath() const
+{
+ // FIXME: Implement.
+ return WTF::String();
+}
+
+String WebContext::platformDefaultLocalStorageDirectory() const
+{
+ GOwnPtr<gchar> storageDirectory(g_build_filename(g_get_user_data_dir(), "webkitgtk", "localstorage", NULL));
+ return WebCore::filenameToString(storageDirectory.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp
new file mode 100644
index 000000000..d85b3dda2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp
@@ -0,0 +1,126 @@
+/*
+ * 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 "WebContextMenuProxyGtk.h"
+
+#include "NativeWebMouseEvent.h"
+#include "WebContextMenuItemData.h"
+#include "WebPageProxy.h"
+#include <WebCore/ContextMenu.h>
+#include <WebCore/GtkUtilities.h>
+#include <gtk/gtk.h>
+#include <wtf/text/CString.h>
+
+
+static const char* gContextMenuActionId = "webkit-context-menu-action";
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static void contextMenuItemActivatedCallback(GtkAction* action, WebPageProxy* page)
+{
+ gboolean isToggle = GTK_IS_TOGGLE_ACTION(action);
+ WebKit::WebContextMenuItemData item(isToggle ? WebCore::CheckableActionType : WebCore::ActionType,
+ static_cast<WebCore::ContextMenuAction>(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), gContextMenuActionId))),
+ gtk_action_get_label(action), gtk_action_get_sensitive(action),
+ isToggle ? gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) : false);
+ page->contextMenuItemSelected(item);
+}
+
+GtkMenu* WebContextMenuProxyGtk::createGtkMenu(const Vector<WebContextMenuItemData>& items)
+{
+ ContextMenu menu;
+ for (size_t i = 0; i < items.size(); i++) {
+ const WebContextMenuItemData& item = items.at(i);
+ ContextMenuItem menuItem(item.type(), item.action(), item.title(), item.enabled(), item.checked());
+ GtkAction* action = menuItem.gtkAction();
+
+ if (action && (item.type() == WebCore::ActionType || item.type() == WebCore::CheckableActionType)) {
+ g_object_set_data(G_OBJECT(action), gContextMenuActionId, GINT_TO_POINTER(item.action()));
+ g_signal_connect(action, "activate", G_CALLBACK(contextMenuItemActivatedCallback), m_page);
+ }
+
+ if (item.type() == WebCore::SubmenuType) {
+ ContextMenu subMenu(createGtkMenu(item.submenu()));
+ menuItem.setSubMenu(&subMenu);
+ }
+ menu.appendItem(menuItem);
+ }
+ return menu.releasePlatformDescription();
+}
+
+void WebContextMenuProxyGtk::showContextMenu(const WebCore::IntPoint& position, const Vector<WebContextMenuItemData>& items)
+{
+ if (items.isEmpty())
+ return;
+
+ m_popup = createGtkMenu(items);
+ m_popupPosition = convertWidgetPointToScreenPoint(m_webView, position);
+
+ // Display menu initiated by right click (mouse button pressed = 3).
+ NativeWebMouseEvent* mouseEvent = m_page->currentlyProcessedMouseDownEvent();
+ const GdkEvent* event = mouseEvent ? mouseEvent->nativeEvent() : 0;
+ gtk_menu_popup(m_popup, 0, 0, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this,
+ event ? event->button.button : 3, event ? event->button.time : GDK_CURRENT_TIME);
+}
+
+void WebContextMenuProxyGtk::hideContextMenu()
+{
+ gtk_menu_popdown(m_popup);
+}
+
+WebContextMenuProxyGtk::WebContextMenuProxyGtk(GtkWidget* webView, WebPageProxy* page)
+ : m_webView(webView)
+ , m_page(page)
+ , m_popup(0)
+{
+}
+
+WebContextMenuProxyGtk::~WebContextMenuProxyGtk()
+{
+ if (m_popup)
+ gtk_widget_destroy(GTK_WIDGET(m_popup));
+}
+
+void WebContextMenuProxyGtk::menuPositionFunction(GtkMenu* menu, gint* x, gint* y, gboolean* pushIn, WebContextMenuProxyGtk* popupMenu)
+{
+ GtkRequisition menuSize;
+ gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, 0);
+
+ GdkScreen* screen = gtk_widget_get_screen(popupMenu->m_webView);
+ *x = popupMenu->m_popupPosition.x();
+ if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
+ *x -= menuSize.width;
+
+ *y = popupMenu->m_popupPosition.y();
+ if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
+ *y -= menuSize.height;
+
+ *pushIn = FALSE;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h b/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h
new file mode 100644
index 000000000..b6a95778b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h
@@ -0,0 +1,63 @@
+/*
+ * 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 WebContextMenuProxyGtk_h
+#define WebContextMenuProxyGtk_h
+
+#include "WebContextMenuProxy.h"
+#include <WebCore/IntPoint.h>
+
+namespace WebKit {
+
+class WebContextMenuItemData;
+class WebPageProxy;
+
+class WebContextMenuProxyGtk : public WebContextMenuProxy {
+public:
+ static PassRefPtr<WebContextMenuProxyGtk> create(GtkWidget* webView, WebPageProxy* page)
+ {
+ return adoptRef(new WebContextMenuProxyGtk(webView, page));
+ }
+ ~WebContextMenuProxyGtk();
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ virtual void hideContextMenu();
+
+private:
+ WebContextMenuProxyGtk(GtkWidget*, WebPageProxy*);
+ GtkMenu* createGtkMenu(const Vector<WebContextMenuItemData>&);
+
+ static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, WebContextMenuProxyGtk*);
+
+ GtkWidget* m_webView;
+ WebPageProxy* m_page;
+ GtkMenu* m_popup;
+ WebCore::IntPoint m_popupPosition;
+};
+
+
+} // namespace WebKit
+
+#endif // WebContextMenuProxyGtk_h
diff --git a/Source/WebKit2/UIProcess/gtk/WebFullScreenManagerProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebFullScreenManagerProxyGtk.cpp
new file mode 100644
index 000000000..5b5bf0242
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebFullScreenManagerProxyGtk.cpp
@@ -0,0 +1,86 @@
+/*
+ * 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 "WebFullScreenManagerProxy.h"
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "WebContext.h"
+#include "WebFullScreenManagerMessages.h"
+#include "WebFullScreenManagerProxyMessages.h"
+#include "WebProcess.h"
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void WebFullScreenManagerProxy::invalidate()
+{
+ m_webView = 0;
+}
+
+void WebFullScreenManagerProxy::enterFullScreen()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::exitFullScreen()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::beganEnterFullScreenAnimation()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::finishedEnterFullScreenAnimation(bool completed)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::beganExitFullScreenAnimation()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::finishedExitFullScreenAnimation(bool completed)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::enterAcceleratedCompositingMode(const LayerTreeContext& context)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::exitAcceleratedCompositingMode()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::getFullScreenRect(WebCore::IntRect& rect)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(FULLSCREEN_API)
diff --git a/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp
new file mode 100644
index 000000000..1be2a0000
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp
@@ -0,0 +1,155 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebKitWebViewBasePrivate.h"
+#include "WebProcessProxy.h"
+
+#include <WebCore/FileSystem.h>
+#include <WebCore/NotImplemented.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+static const char* inspectorFilesBasePath()
+{
+ const gchar* environmentPath = g_getenv("WEBKIT_INSPECTOR_PATH");
+ if (environmentPath && g_file_test(environmentPath, G_FILE_TEST_IS_DIR))
+ return environmentPath;
+
+ static const char* inspectorFilesPath = DATA_DIR""G_DIR_SEPARATOR_S
+ "webkitgtk-"WEBKITGTK_API_VERSION_STRING""G_DIR_SEPARATOR_S
+ "webinspector"G_DIR_SEPARATOR_S;
+ return inspectorFilesPath;
+}
+
+static gboolean inspectorWindowDestroyed(GtkWidget* window, GdkEvent*, gpointer userData)
+{
+ WebInspectorProxy* inspectorProxy = static_cast<WebInspectorProxy*>(userData);
+
+ // Inform WebProcess about webinspector closure. Not doing so,
+ // results in failure of subsequent invocation of webinspector.
+ inspectorProxy->close();
+ inspectorProxy->windowDestroyed();
+
+ return FALSE;
+}
+
+void WebInspectorProxy::windowDestroyed()
+{
+ ASSERT(m_inspectorView);
+ ASSERT(m_inspectorWindow);
+ m_inspectorView = 0;
+ m_inspectorWindow = 0;
+}
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(m_page);
+ ASSERT(!m_inspectorView);
+ m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(page()->process()->context(), inspectorPageGroup()));
+ return webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_inspectorView));
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ ASSERT(!m_inspectorWindow);
+ m_inspectorWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), _("Web Inspector"));
+ gtk_window_set_default_size(GTK_WINDOW(m_inspectorWindow), initialWindowWidth, initialWindowHeight);
+ g_signal_connect(m_inspectorWindow, "delete-event", G_CALLBACK(inspectorWindowDestroyed), this);
+
+ gtk_container_add(GTK_CONTAINER(m_inspectorWindow), m_inspectorView);
+ gtk_widget_show(m_inspectorView);
+ gtk_widget_show(m_inspectorWindow);
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ if (m_inspectorWindow) {
+ gtk_widget_destroy(m_inspectorWindow);
+ m_inspectorWindow = 0;
+ m_inspectorView = 0;
+ }
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String& url)
+{
+ GOwnPtr<gchar> title(g_strdup_printf("%s - %s", _("Web Inspector"), url.utf8().data()));
+ gtk_window_set_title(GTK_WINDOW(m_inspectorWindow), title.get());
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ GOwnPtr<gchar> filePath(g_build_filename(inspectorFilesBasePath(), "inspector.html", NULL));
+ GOwnPtr<gchar> fileURI(g_filename_to_uri(filePath.get(), 0, 0));
+ return WebCore::filenameToString(fileURI.get());
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ GOwnPtr<gchar> fileURI(g_filename_to_uri(inspectorFilesBasePath(), 0, 0));
+ return WebCore::filenameToString(fileURI.get());
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
new file mode 100644
index 000000000..1127dde84
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
@@ -0,0 +1,62 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "NativeWebKeyboardEvent.h"
+#include "NotImplemented.h"
+#include "PageClientImpl.h"
+
+namespace WebKit {
+
+GtkWidget* WebPageProxy::viewWidget()
+{
+ return static_cast<PageClientImpl*>(m_pageClient)->viewWidget();
+}
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ // FIXME: This should not be hard coded.
+ return "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.7 (KHTML, like Gecko) Version/5.0 Safari/534.7";
+}
+
+void WebPageProxy::getEditorCommandsForKeyEvent(const AtomicString& eventType, Vector<WTF::String>& commandsList)
+{
+ m_pageClient->getEditorCommandsForKeyEvent(m_keyEventQueue.first(), eventType, commandsList);
+}
+
+void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
+{
+ notImplemented();
+}
+
+void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp
new file mode 100644
index 000000000..521cf5320
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp
@@ -0,0 +1,138 @@
+/*
+ * 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 "WebPopupMenuProxyGtk.h"
+
+#include "NativeWebMouseEvent.h"
+#include "WebPopupItem.h"
+#include <WebCore/GtkUtilities.h>
+#include <gtk/gtk.h>
+#include <wtf/gobject/GOwnPtr.h>
+#include <wtf/text/CString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyGtk::WebPopupMenuProxyGtk(GtkWidget* webView, WebPopupMenuProxy::Client* client)
+ : WebPopupMenuProxy(client)
+ , m_webView(webView)
+ , m_activeItem(-1)
+ , m_runLoop(0)
+{
+}
+
+WebPopupMenuProxyGtk::~WebPopupMenuProxyGtk()
+{
+ if (m_popup) {
+ g_signal_handlers_disconnect_matched(m_popup->platformMenu(), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, this);
+ hidePopupMenu();
+ }
+}
+
+GtkAction* WebPopupMenuProxyGtk::createGtkActionForMenuItem(const WebPopupItem& item, int itemIndex)
+{
+ GOwnPtr<char> actionName(g_strdup_printf("popup-menu-action-%d", itemIndex));
+ GtkAction* action = gtk_action_new(actionName.get(), item.m_text.utf8().data(), item.m_toolTip.utf8().data(), 0);
+ g_object_set_data(G_OBJECT(action), "popup-menu-action-index", GINT_TO_POINTER(itemIndex));
+ g_signal_connect(action, "activate", G_CALLBACK(menuItemActivated), this);
+ gtk_action_set_sensitive(action, item.m_isEnabled);
+
+ return action;
+}
+
+void WebPopupMenuProxyGtk::showPopupMenu(const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
+{
+ if (m_popup)
+ m_popup->clear();
+ else
+ m_popup = GtkPopupMenu::create();
+
+ const int size = items.size();
+ for (int i = 0; i < size; i++) {
+ if (items[i].m_type == WebPopupItem::Separator)
+ m_popup->appendSeparator();
+ else {
+ GRefPtr<GtkAction> action = adoptGRef(createGtkActionForMenuItem(items[i], i));
+ m_popup->appendItem(action.get());
+ }
+ }
+
+ IntPoint menuPosition = convertWidgetPointToScreenPoint(m_webView, rect.location());
+ menuPosition.move(0, rect.height());
+
+ gulong unmapHandler = g_signal_connect(m_popup->platformMenu(), "unmap", G_CALLBACK(menuUnmapped), this);
+ m_popup->popUp(rect.size(), menuPosition, size, selectedIndex, m_client->currentlyProcessedMouseDownEvent() ? m_client->currentlyProcessedMouseDownEvent()->nativeEvent() : 0);
+
+ // PopupMenu can fail to open when there is no mouse grab.
+ // Ensure WebCore does not go into some pesky state.
+ if (!gtk_widget_get_visible(m_popup->platformMenu())) {
+ m_client->failedToShowPopupMenu();
+ return;
+ }
+
+ // WebPageProxy expects the menu to run in a nested run loop, since it invalidates the
+ // menu right after calling WebPopupMenuProxy::showPopupMenu().
+ m_runLoop = g_main_loop_new(0, FALSE);
+
+ GDK_THREADS_LEAVE();
+ g_main_loop_run(m_runLoop);
+ GDK_THREADS_ENTER();
+
+ g_main_loop_unref(m_runLoop);
+ m_runLoop = 0;
+
+ g_signal_handler_disconnect(m_popup->platformMenu(), unmapHandler);
+
+ if (!m_client)
+ return;
+
+ m_client->valueChangedForPopupMenu(this, m_activeItem);
+}
+
+void WebPopupMenuProxyGtk::hidePopupMenu()
+{
+ m_popup->popDown();
+}
+
+void WebPopupMenuProxyGtk::shutdownRunLoop()
+{
+ if (g_main_loop_is_running(m_runLoop))
+ g_main_loop_quit(m_runLoop);
+}
+
+void WebPopupMenuProxyGtk::menuItemActivated(GtkAction* action, WebPopupMenuProxyGtk* popupMenu)
+{
+ popupMenu->setActiveItem(GPOINTER_TO_INT(g_object_get_data(G_OBJECT(action), "popup-menu-action-index")));
+ popupMenu->shutdownRunLoop();
+}
+
+void WebPopupMenuProxyGtk::menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk* popupMenu)
+{
+ popupMenu->shutdownRunLoop();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h b/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h
new file mode 100644
index 000000000..9399ec11f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h
@@ -0,0 +1,62 @@
+/*
+ * 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 WebPopupMenuProxyGtk_h
+#define WebPopupMenuProxyGtk_h
+
+#include "WebPopupMenuProxy.h"
+#include <WebCore/GtkPopupMenu.h>
+#include <WebCore/IntRect.h>
+
+typedef struct _GMainLoop GMainLoop;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebPopupMenuProxyGtk : public WebPopupMenuProxy {
+public:
+ static PassRefPtr<WebPopupMenuProxyGtk> create(GtkWidget* webView, WebPopupMenuProxy::Client* client)
+ {
+ return adoptRef(new WebPopupMenuProxyGtk(webView, client));
+ }
+ ~WebPopupMenuProxyGtk();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+private:
+ WebPopupMenuProxyGtk(GtkWidget*, WebPopupMenuProxy::Client*);
+ void shutdownRunLoop();
+ void setActiveItem(int activeItem) { m_activeItem = activeItem; }
+ GtkAction* createGtkActionForMenuItem(const WebPopupItem&, int itemIndex);
+
+ static void menuItemActivated(GtkAction*, WebPopupMenuProxyGtk*);
+ static void menuUnmapped(GtkWidget*, WebPopupMenuProxyGtk*);
+
+ GtkWidget* m_webView;
+ OwnPtr<WebCore::GtkPopupMenu> m_popup;
+ int m_activeItem;
+ GMainLoop* m_runLoop;
+};
+
+} // namespace WebKit
+
+
+#endif // WebPopupMenuProxyGtk_h
diff --git a/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
new file mode 100644
index 000000000..c69820416
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
@@ -0,0 +1,59 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void WebPreferences::platformInitializeStore()
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String&, bool)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
+{
+ notImplemented();
+}
+
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
new file mode 100644
index 000000000..646962f7e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.mm
@@ -0,0 +1,143 @@
+/*
+ * 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 "BackingStore.h"
+
+#import "CGUtilities.h"
+#import "ShareableBitmap.h"
+#import "UpdateInfo.h"
+#import "WebPageProxy.h"
+#import <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect)
+{
+ if (m_cgLayer) {
+ CGContextSaveGState(context);
+ CGContextClipToRect(context, rect);
+
+ CGContextScaleCTM(context, 1, -1);
+ CGContextDrawLayerAtPoint(context, CGPointMake(0, -m_size.height()), m_cgLayer.get());
+
+ CGContextRestoreGState(context);
+ return;
+ }
+
+ ASSERT(m_bitmapContext);
+ paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect);
+}
+
+CGContextRef BackingStore::backingStoreContext()
+{
+ if (m_cgLayer)
+ return CGLayerGetContext(m_cgLayer.get());
+
+ // Try to create a layer.
+ if (CGContextRef containingWindowContext = m_webPageProxy->containingWindowGraphicsContext()) {
+ m_cgLayer.adoptCF(CGLayerCreateWithContext(containingWindowContext, NSSizeToCGSize(m_size), 0));
+ CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get());
+
+ CGContextSetBlendMode(layerContext, kCGBlendModeCopy);
+
+ // We want the origin to be in the top left corner so flip the backing store context.
+ CGContextTranslateCTM(layerContext, 0, m_size.height());
+ CGContextScaleCTM(layerContext, 1, -1);
+
+ if (m_bitmapContext) {
+ // Paint the contents of the bitmap into the layer context.
+ paintBitmapContext(layerContext, m_bitmapContext.get(), CGPointZero, CGRectMake(0, 0, m_size.width(), m_size.height()));
+ m_bitmapContext = nullptr;
+ }
+
+ return layerContext;
+ }
+
+ if (!m_bitmapContext) {
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+
+ m_bitmapContext.adoptCF(CGBitmapContextCreate(0, m_size.width(), m_size.height(), 8, m_size.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+
+ CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy);
+
+ // We want the origin to be in the top left corner so flip the backing store context.
+ CGContextTranslateCTM(m_bitmapContext.get(), 0, m_size.height());
+ CGContextScaleCTM(m_bitmapContext.get(), 1, -1);
+ }
+
+ return m_bitmapContext.get();
+}
+
+void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
+{
+ CGContextRef context = backingStoreContext();
+
+ scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
+
+ IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+
+ GraphicsContext graphicsContext(context);
+
+ // Paint all update rects.
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
+ IntRect updateRect = updateInfo.updateRects[i];
+ IntRect srcRect = updateRect;
+ srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
+
+ bitmap->paint(graphicsContext, updateInfo.deviceScaleFactor, updateRect.location(), srcRect);
+ }
+}
+
+void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ if (scrollOffset.isZero())
+ return;
+
+ if (m_cgLayer) {
+ CGContextRef layerContext = CGLayerGetContext(m_cgLayer.get());
+
+ // Scroll the layer by painting it into itself with the given offset.
+ CGContextSaveGState(layerContext);
+ CGContextClipToRect(layerContext, scrollRect);
+ CGContextScaleCTM(layerContext, 1, -1);
+ CGContextDrawLayerAtPoint(layerContext, CGPointMake(scrollOffset.width(), -m_size.height() - scrollOffset.height()), m_cgLayer.get());
+ CGContextRestoreGState(layerContext);
+
+ return;
+ }
+
+ ASSERT(m_bitmapContext);
+
+ CGContextSaveGState(m_bitmapContext.get());
+ CGContextClipToRect(m_bitmapContext.get(), scrollRect);
+ CGPoint destination = CGPointMake(scrollRect.x() + scrollOffset.width(), scrollRect.y() + scrollOffset.height());
+ paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect);
+ CGContextRestoreGState(m_bitmapContext.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.h b/Source/WebKit2/UIProcess/mac/CorrectionPanel.h
new file mode 100644
index 000000000..66793a974
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.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 CorrectionPanel_h
+#define CorrectionPanel_h
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+#import <AppKit/NSSpellChecker.h>
+#import <WebCore/SpellingCorrectionController.h>
+#import <wtf/RetainPtr.h>
+
+@class WKView;
+
+namespace WebKit {
+
+class CorrectionPanel {
+public:
+ CorrectionPanel();
+ ~CorrectionPanel();
+ void show(WKView*, WebCore::CorrectionPanelInfo::PanelType, const WebCore::FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings);
+ String dismiss(WebCore::ReasonForDismissingCorrectionPanel);
+ static void recordAutocorrectionResponse(WKView*, NSCorrectionResponse, const String& replacedString, const String& replacementString);
+
+private:
+ bool isShowing() const { return m_view; }
+ String dismissInternal(WebCore::ReasonForDismissingCorrectionPanel, bool dismissingExternally);
+ void handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType);
+
+ bool m_wasDismissedExternally;
+ WebCore::ReasonForDismissingCorrectionPanel m_reasonForDismissing;
+ RetainPtr<WKView> m_view;
+ RetainPtr<NSString> m_resultForDismissal;
+};
+
+} // namespace WebKit
+
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD)
+
+#endif // CorrectionPanel_h
diff --git a/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm
new file mode 100644
index 000000000..86dd16a56
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/CorrectionPanel.mm
@@ -0,0 +1,149 @@
+/*
+ * 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"
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+#import "CorrectionPanel.h"
+
+#import "WebPageProxy.h"
+#import "WKView.h"
+#import "WKViewInternal.h"
+
+using namespace WebCore;
+
+static inline NSCorrectionIndicatorType correctionIndicatorType(CorrectionPanelInfo::PanelType panelType)
+{
+ switch (panelType) {
+ case CorrectionPanelInfo::PanelTypeCorrection:
+ return NSCorrectionIndicatorTypeDefault;
+ case CorrectionPanelInfo::PanelTypeReversion:
+ return NSCorrectionIndicatorTypeReversion;
+ case CorrectionPanelInfo::PanelTypeSpellingSuggestions:
+ return NSCorrectionIndicatorTypeGuesses;
+ }
+ ASSERT_NOT_REACHED();
+ return NSCorrectionIndicatorTypeDefault;
+}
+
+namespace WebKit {
+
+CorrectionPanel::CorrectionPanel()
+ : m_wasDismissedExternally(false)
+ , m_reasonForDismissing(ReasonForDismissingCorrectionPanelIgnored)
+{
+}
+
+CorrectionPanel::~CorrectionPanel()
+{
+ dismissInternal(ReasonForDismissingCorrectionPanelIgnored, false);
+}
+
+void CorrectionPanel::show(WKView* view, CorrectionPanelInfo::PanelType type, const FloatRect& boundingBoxOfReplacedString, const String& replacedString, const String& replacementString, const Vector<String>& alternativeReplacementStrings)
+{
+ dismissInternal(ReasonForDismissingCorrectionPanelIgnored, false);
+
+ if (!view)
+ return;
+
+ NSString* replacedStringAsNSString = replacedString;
+ NSString* replacementStringAsNSString = replacementString;
+ m_view = view;
+ NSCorrectionIndicatorType indicatorType = correctionIndicatorType(type);
+
+ NSMutableArray* alternativeStrings = 0;
+ if (!alternativeReplacementStrings.isEmpty()) {
+ size_t size = alternativeReplacementStrings.size();
+ alternativeStrings = [NSMutableArray arrayWithCapacity:size];
+ for (size_t i = 0; i < size; ++i)
+ [alternativeStrings addObject:(NSString*)alternativeReplacementStrings[i]];
+ }
+
+ NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
+ [spellChecker showCorrectionIndicatorOfType:indicatorType primaryString:replacementStringAsNSString alternativeStrings:alternativeStrings forStringInRect:boundingBoxOfReplacedString view:m_view.get() completionHandler:^(NSString* acceptedString) {
+ handleAcceptedReplacement(acceptedString, replacedStringAsNSString, replacementStringAsNSString, indicatorType);
+ }];
+}
+
+String CorrectionPanel::dismiss(ReasonForDismissingCorrectionPanel reason)
+{
+ return dismissInternal(reason, true);
+}
+
+String CorrectionPanel::dismissInternal(ReasonForDismissingCorrectionPanel reason, bool dismissingExternally)
+{
+ if (!isShowing())
+ return String();
+
+ m_wasDismissedExternally = dismissingExternally;
+ m_reasonForDismissing = reason;
+ m_resultForDismissal.clear();
+ [[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:m_view.get()];
+ return m_resultForDismissal.get();
+}
+
+void CorrectionPanel::recordAutocorrectionResponse(WKView* view, NSCorrectionResponse response, const String& replacedString, const String& replacementString)
+{
+ [[NSSpellChecker sharedSpellChecker] recordResponse:response toCorrection:replacementString forWord:replacedString language:nil inSpellDocumentWithTag:[view spellCheckerDocumentTag]];
+}
+
+void CorrectionPanel::handleAcceptedReplacement(NSString* acceptedReplacement, NSString* replaced, NSString* proposedReplacement, NSCorrectionIndicatorType correctionIndicatorType)
+{
+ if (!m_view)
+ return;
+
+ NSSpellChecker* spellChecker = [NSSpellChecker sharedSpellChecker];
+ NSInteger documentTag = [m_view.get() spellCheckerDocumentTag];
+
+ switch (correctionIndicatorType) {
+ case NSCorrectionIndicatorTypeDefault:
+ if (acceptedReplacement)
+ [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+ else {
+ if (!m_wasDismissedExternally || m_reasonForDismissing == ReasonForDismissingCorrectionPanelCancelled)
+ [spellChecker recordResponse:NSCorrectionResponseRejected toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+ else
+ [spellChecker recordResponse:NSCorrectionResponseIgnored toCorrection:proposedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+ }
+ break;
+ case NSCorrectionIndicatorTypeReversion:
+ if (acceptedReplacement)
+ [spellChecker recordResponse:NSCorrectionResponseReverted toCorrection:replaced forWord:acceptedReplacement language:nil inSpellDocumentWithTag:documentTag];
+ break;
+ case NSCorrectionIndicatorTypeGuesses:
+ if (acceptedReplacement)
+ [spellChecker recordResponse:NSCorrectionResponseAccepted toCorrection:acceptedReplacement forWord:replaced language:nil inSpellDocumentWithTag:documentTag];
+ break;
+ }
+
+ [m_view.get() handleCorrectionPanelResult:acceptedReplacement];
+ m_view.clear();
+ if (acceptedReplacement)
+ m_resultForDismissal.adoptNS([acceptedReplacement copy]);
+}
+
+} // namespace WebKit
+
+#endif //!defined(BUILDING_ON_SNOW_LEOPARD)
+
diff --git a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
new file mode 100644
index 000000000..20a63ea03
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
@@ -0,0 +1,402 @@
+/*
+ * 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 "TextChecker.h"
+
+#import "TextCheckerState.h"
+#import <WebCore/NotImplemented.h>
+#import <wtf/RetainPtr.h>
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+@interface NSSpellChecker (WebNSSpellCheckerDetails)
+- (NSString *)languageForWordRange:(NSRange)range inString:(NSString *)string orthography:(NSOrthography *)orthography;
+@end
+#endif
+
+static NSString* const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
+static NSString* const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
+static NSString* const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
+static NSString* const WebSmartInsertDeleteEnabled = @"WebSmartInsertDeleteEnabled";
+static NSString* const WebAutomaticQuoteSubstitutionEnabled = @"WebAutomaticQuoteSubstitutionEnabled";
+static NSString* const WebAutomaticDashSubstitutionEnabled = @"WebAutomaticDashSubstitutionEnabled";
+static NSString* const WebAutomaticLinkDetectionEnabled = @"WebAutomaticLinkDetectionEnabled";
+static NSString* const WebAutomaticTextReplacementEnabled = @"WebAutomaticTextReplacementEnabled";
+
+using namespace WebCore;
+
+namespace WebKit {
+
+TextCheckerState textCheckerState;
+
+static void initializeState()
+{
+ static bool didInitializeState;
+ if (didInitializeState)
+ return;
+
+ textCheckerState.isContinuousSpellCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebContinuousSpellCheckingEnabled] && TextChecker::isContinuousSpellCheckingAllowed();
+ textCheckerState.isGrammarCheckingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebGrammarCheckingEnabled];
+ textCheckerState.isAutomaticSpellingCorrectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticSpellingCorrectionEnabled];
+ textCheckerState.isAutomaticQuoteSubstitutionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticQuoteSubstitutionEnabled];
+ textCheckerState.isAutomaticDashSubstitutionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticDashSubstitutionEnabled];
+ textCheckerState.isAutomaticLinkDetectionEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticLinkDetectionEnabled];
+ textCheckerState.isAutomaticTextReplacementEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:WebAutomaticTextReplacementEnabled];
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ if (![[NSUserDefaults standardUserDefaults] objectForKey:WebAutomaticSpellingCorrectionEnabled])
+ textCheckerState.isAutomaticSpellingCorrectionEnabled = [NSSpellChecker isAutomaticSpellingCorrectionEnabled];
+#endif
+
+ didInitializeState = true;
+}
+
+const TextCheckerState& TextChecker::state()
+{
+ initializeState();
+ return textCheckerState;
+}
+
+bool TextChecker::isContinuousSpellCheckingAllowed()
+{
+ static bool allowContinuousSpellChecking = true;
+ static bool readAllowContinuousSpellCheckingDefault = false;
+
+ if (!readAllowContinuousSpellCheckingDefault) {
+ if ([[NSUserDefaults standardUserDefaults] objectForKey:@"NSAllowContinuousSpellChecking"])
+ allowContinuousSpellChecking = [[NSUserDefaults standardUserDefaults] boolForKey:@"NSAllowContinuousSpellChecking"];
+
+ readAllowContinuousSpellCheckingDefault = true;
+ }
+
+ return allowContinuousSpellChecking;
+}
+
+void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+{
+ if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
+ return;
+
+ textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isContinuousSpellCheckingEnabled forKey:WebContinuousSpellCheckingEnabled];
+
+ // FIXME: preflight the spell checker.
+}
+
+void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
+{
+ if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
+ return;
+
+ textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isGrammarCheckingEnabled forKey:WebGrammarCheckingEnabled];
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+
+ // We call preflightSpellChecker() when turning continuous spell checking on, but we don't need to do that here
+ // because grammar checking only occurs on code paths that already preflight spell checking appropriately.
+}
+
+void TextChecker::setAutomaticSpellingCorrectionEnabled(bool isAutomaticSpellingCorrectionEnabled)
+{
+ if (state().isAutomaticSpellingCorrectionEnabled == isAutomaticSpellingCorrectionEnabled)
+ return;
+
+ textCheckerState.isAutomaticSpellingCorrectionEnabled = isAutomaticSpellingCorrectionEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isAutomaticSpellingCorrectionEnabled forKey:WebAutomaticSpellingCorrectionEnabled];
+
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticQuoteSubstitutionEnabled(bool isAutomaticQuoteSubstitutionEnabled)
+{
+ if (state().isAutomaticQuoteSubstitutionEnabled == isAutomaticQuoteSubstitutionEnabled)
+ return;
+
+ textCheckerState.isAutomaticQuoteSubstitutionEnabled = isAutomaticQuoteSubstitutionEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isAutomaticQuoteSubstitutionEnabled forKey:WebAutomaticQuoteSubstitutionEnabled];
+
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticDashSubstitutionEnabled(bool isAutomaticDashSubstitutionEnabled)
+{
+ if (state().isAutomaticDashSubstitutionEnabled == isAutomaticDashSubstitutionEnabled)
+ return;
+
+ textCheckerState.isAutomaticDashSubstitutionEnabled = isAutomaticDashSubstitutionEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isAutomaticDashSubstitutionEnabled forKey:WebAutomaticDashSubstitutionEnabled];
+
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticLinkDetectionEnabled(bool isAutomaticLinkDetectionEnabled)
+{
+ if (state().isAutomaticLinkDetectionEnabled == isAutomaticLinkDetectionEnabled)
+ return;
+
+ textCheckerState.isAutomaticLinkDetectionEnabled = isAutomaticLinkDetectionEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isAutomaticLinkDetectionEnabled forKey:WebAutomaticLinkDetectionEnabled];
+
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+void TextChecker::setAutomaticTextReplacementEnabled(bool isAutomaticTextReplacementEnabled)
+{
+ if (state().isAutomaticTextReplacementEnabled == isAutomaticTextReplacementEnabled)
+ return;
+
+ textCheckerState.isAutomaticTextReplacementEnabled = isAutomaticTextReplacementEnabled;
+ [[NSUserDefaults standardUserDefaults] setBool:isAutomaticTextReplacementEnabled forKey:WebAutomaticTextReplacementEnabled];
+
+ [[NSSpellChecker sharedSpellChecker] updatePanels];
+}
+
+static bool smartInsertDeleteEnabled;
+
+bool TextChecker::isSmartInsertDeleteEnabled()
+{
+ static bool readSmartInsertDeleteEnabledDefault;
+
+ if (!readSmartInsertDeleteEnabledDefault) {
+ smartInsertDeleteEnabled = ![[NSUserDefaults standardUserDefaults] objectForKey:WebSmartInsertDeleteEnabled] || [[NSUserDefaults standardUserDefaults] boolForKey:WebSmartInsertDeleteEnabled];
+
+ readSmartInsertDeleteEnabledDefault = true;
+ }
+
+ return smartInsertDeleteEnabled;
+}
+
+void TextChecker::setSmartInsertDeleteEnabled(bool flag)
+{
+ if (flag == isSmartInsertDeleteEnabled())
+ return;
+
+ smartInsertDeleteEnabled = flag;
+
+ [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
+}
+
+bool TextChecker::substitutionsPanelIsShowing()
+{
+ return [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
+}
+
+void TextChecker::toggleSubstitutionsPanelIsShowing()
+{
+ NSPanel *substitutionsPanel = [[NSSpellChecker sharedSpellChecker] substitutionsPanel];
+ if ([substitutionsPanel isVisible]) {
+ [substitutionsPanel orderOut:nil];
+ return;
+ }
+ [substitutionsPanel orderFront:nil];
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isGrammarCheckingEnabled = enabled;
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
+{
+ return [NSSpellChecker uniqueSpellDocumentTag];
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+{
+ [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag];
+}
+
+#if USE(UNIFIED_TEXT_CHECKING)
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ Vector<TextCheckingResult> results;
+
+ RetainPtr<NSString> textString(AdoptNS, [[NSString alloc] initWithCharactersNoCopy:const_cast<UChar*>(text) length:length freeWhenDone:NO]);
+ NSArray *incomingResults = [[NSSpellChecker sharedSpellChecker] checkString:textString .get()
+ range:NSMakeRange(0, length)
+ types:checkingTypes | NSTextCheckingTypeOrthography
+ options:nil
+ inSpellDocumentWithTag:spellDocumentTag
+ orthography:NULL
+ wordCount:NULL];
+ for (NSTextCheckingResult *incomingResult in incomingResults) {
+ NSRange resultRange = [incomingResult range];
+ NSTextCheckingType resultType = [incomingResult resultType];
+ ASSERT(resultRange.location != NSNotFound);
+ ASSERT(resultRange.length > 0);
+ if (resultType == NSTextCheckingTypeSpelling && (checkingTypes & NSTextCheckingTypeSpelling)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeSpelling;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeGrammar && (checkingTypes & NSTextCheckingTypeGrammar)) {
+ TextCheckingResult result;
+ NSArray *details = [incomingResult grammarDetails];
+ result.type = TextCheckingTypeGrammar;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ for (NSDictionary *incomingDetail in details) {
+ ASSERT(incomingDetail);
+ GrammarDetail detail;
+ NSValue *detailRangeAsNSValue = [incomingDetail objectForKey:NSGrammarRange];
+ ASSERT(detailRangeAsNSValue);
+ NSRange detailNSRange = [detailRangeAsNSValue rangeValue];
+ ASSERT(detailNSRange.location != NSNotFound);
+ ASSERT(detailNSRange.length > 0);
+ detail.location = detailNSRange.location;
+ detail.length = detailNSRange.length;
+ detail.userDescription = [incomingDetail objectForKey:NSGrammarUserDescription];
+ NSArray *guesses = [incomingDetail objectForKey:NSGrammarCorrections];
+ for (NSString *guess in guesses)
+ detail.guesses.append(String(guess));
+ result.details.append(detail);
+ }
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeLink && (checkingTypes & NSTextCheckingTypeLink)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeLink;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [[incomingResult URL] absoluteString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeQuote && (checkingTypes & NSTextCheckingTypeQuote)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeQuote;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeDash && (checkingTypes & NSTextCheckingTypeDash)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeDash;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeReplacement && (checkingTypes & NSTextCheckingTypeReplacement)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeReplacement;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ } else if (resultType == NSTextCheckingTypeCorrection && (checkingTypes & NSTextCheckingTypeCorrection)) {
+ TextCheckingResult result;
+ result.type = TextCheckingTypeCorrection;
+ result.location = resultRange.location;
+ result.length = resultRange.length;
+ result.replacement = [incomingResult replacementString];
+ results.append(result);
+ }
+ }
+
+ return results;
+}
+
+#endif
+
+void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
+{
+ // Mac uses checkTextOfParagraph instead.
+ notImplemented();
+}
+
+void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
+{
+ // Mac uses checkTextOfParagraph instead.
+ notImplemented();
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ return [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ NSPanel *spellingPanel = [[NSSpellChecker sharedSpellChecker] spellingPanel];
+ if ([spellingPanel isVisible])
+ [spellingPanel orderOut:nil];
+ else
+ [spellingPanel orderFront:nil];
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String& misspelledWord)
+{
+ [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
+}
+
+void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+{
+ RetainPtr<NSMutableArray> corrections(AdoptNS, [[NSMutableArray alloc] init]);
+ for (size_t i = 0; i < grammarDetail.guesses.size(); ++i) {
+ NSString *guess = grammarDetail.guesses[i];
+ [corrections.get() addObject:guess];
+ }
+
+ NSRange grammarRange = NSMakeRange(grammarDetail.location, grammarDetail.length);
+ NSString *grammarUserDescription = grammarDetail.userDescription;
+ RetainPtr<NSDictionary> grammarDetailDict(AdoptNS, [[NSDictionary alloc] initWithObjectsAndKeys:[NSValue valueWithRange:grammarRange], NSGrammarRange, grammarUserDescription, NSGrammarUserDescription, corrections.get(), NSGrammarCorrections, nil]);
+
+ [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithGrammarString:badGrammarPhrase detail:grammarDetailDict.get()];
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSString* language = nil;
+ NSOrthography* orthography = nil;
+ NSSpellChecker *checker = [NSSpellChecker sharedSpellChecker];
+ if (context.length()) {
+ [checker checkString:context range:NSMakeRange(0, context.length()) types:NSTextCheckingTypeOrthography options:0 inSpellDocumentWithTag:spellDocumentTag orthography:&orthography wordCount:0];
+ language = [checker languageForWordRange:NSMakeRange(0, context.length()) inString:context orthography:orthography];
+ }
+ NSArray* stringsArray = [checker guessesForWordRange:NSMakeRange(0, word.length()) inString:word language:language inSpellDocumentWithTag:spellDocumentTag];
+#else
+ NSArray* stringsArray = [[NSSpellChecker sharedSpellChecker] guessesForWord:word];
+#endif
+
+ for (NSString *guess in stringsArray)
+ guesses.append(guess);
+}
+
+void TextChecker::learnWord(int64_t, const String& word)
+{
+ [[NSSpellChecker sharedSpellChecker] learnWord:word];
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ [[NSSpellChecker sharedSpellChecker] ignoreWord:word inSpellDocumentWithTag:spellDocumentTag];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h b/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h
new file mode 100644
index 000000000..75b95c408
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.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.
+ */
+
+#ifndef TiledCoreAnimationDrawingAreaProxy_h
+#define TiledCoreAnimationDrawingAreaProxy_h
+
+#include "DrawingAreaProxy.h"
+#include <wtf/PassOwnPtr.h>
+
+namespace WebKit {
+
+class TiledCoreAnimationDrawingAreaProxy : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<TiledCoreAnimationDrawingAreaProxy> create(WebPageProxy*);
+ virtual ~TiledCoreAnimationDrawingAreaProxy();
+
+private:
+ explicit TiledCoreAnimationDrawingAreaProxy(WebPageProxy*);
+
+ // DrawingAreaProxy
+ virtual void deviceScaleFactorDidChange() OVERRIDE;
+ virtual void sizeDidChange() OVERRIDE;
+ virtual void enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext&) OVERRIDE;
+ virtual void exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&) OVERRIDE;
+
+ // Message handlers.
+ virtual void didUpdateGeometry() OVERRIDE;
+
+ void sendUpdateGeometry();
+
+ // Whether we're waiting for a DidUpdateGeometry message from the web process.
+ bool m_isWaitingForDidUpdateGeometry;
+
+ // The last size we sent to the web process.
+ WebCore::IntSize m_lastSentSize;
+};
+
+} // namespace WebKit
+
+#endif // TiledCoreAnimationDrawingAreaProxy_h
diff --git a/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm b/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
new file mode 100644
index 000000000..25d4e44a1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm
@@ -0,0 +1,111 @@
+/*
+ * 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 "TiledCoreAnimationDrawingAreaProxy.h"
+
+#import "DrawingAreaMessages.h"
+#import "DrawingAreaProxyMessages.h"
+#import "LayerTreeContext.h"
+#import "WebPageProxy.h"
+#import "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<TiledCoreAnimationDrawingAreaProxy> TiledCoreAnimationDrawingAreaProxy::create(WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new TiledCoreAnimationDrawingAreaProxy(webPageProxy));
+}
+
+TiledCoreAnimationDrawingAreaProxy::TiledCoreAnimationDrawingAreaProxy(WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaTypeTiledCoreAnimation, webPageProxy)
+ , m_isWaitingForDidUpdateGeometry(false)
+{
+}
+
+TiledCoreAnimationDrawingAreaProxy::~TiledCoreAnimationDrawingAreaProxy()
+{
+}
+
+void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
+{
+ // FIXME: Implement.
+}
+
+void TiledCoreAnimationDrawingAreaProxy::sizeDidChange()
+{
+ if (!m_webPageProxy->isValid())
+ return;
+
+ // We only want one UpdateGeometry message in flight at once, so if we've already sent one but
+ // haven't yet received the reply we'll just return early here.
+ if (m_isWaitingForDidUpdateGeometry)
+ return;
+
+ sendUpdateGeometry();
+
+ if (m_webPageProxy->process()->isLaunching())
+ return;
+
+ // The timeout, in seconds, we use when waiting for a DidUpdateGeometry message.
+ static const double didUpdateBackingStoreStateTimeout = 0.5;
+ m_webPageProxy->process()->connection()->waitForAndDispatchImmediately<Messages::DrawingAreaProxy::DidUpdateGeometry>(m_webPageProxy->pageID(), didUpdateBackingStoreStateTimeout);
+}
+
+void TiledCoreAnimationDrawingAreaProxy::enterAcceleratedCompositingMode(uint64_t backingStoreStateID, const LayerTreeContext& layerTreeContext)
+{
+ m_webPageProxy->enterAcceleratedCompositingMode(layerTreeContext);
+}
+
+void TiledCoreAnimationDrawingAreaProxy::exitAcceleratedCompositingMode(uint64_t backingStoreStateID, const UpdateInfo&)
+{
+ // This should never be called.
+ ASSERT_NOT_REACHED();
+}
+
+void TiledCoreAnimationDrawingAreaProxy::didUpdateGeometry()
+{
+ ASSERT(m_isWaitingForDidUpdateGeometry);
+
+ m_isWaitingForDidUpdateGeometry = false;
+
+ // If the WKView was resized while we were waiting for a DidUpdateGeometry reply from the web process,
+ // we need to resend the new size here.
+ if (m_lastSentSize != m_size)
+ sendUpdateGeometry();
+}
+
+void TiledCoreAnimationDrawingAreaProxy::sendUpdateGeometry()
+{
+ ASSERT(!m_isWaitingForDidUpdateGeometry);
+
+ m_lastSentSize = m_size;
+ m_webPageProxy->process()->send(Messages::DrawingArea::UpdateGeometry(m_size), m_webPageProxy->pageID());
+ m_isWaitingForDidUpdateGeometry = true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.h b/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.h
new file mode 100644
index 000000000..8b9e81dbc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.h
@@ -0,0 +1,40 @@
+/*
+ * 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 WKFullKeyboardAccessWatcher_h
+#define WKFullKeyboardAccessWatcher_h
+
+#import <Cocoa/Cocoa.h>
+
+@interface WKFullKeyboardAccessWatcher : NSObject {
+@private
+ BOOL fullKeyboardAccessEnabled;
+}
+
++ (BOOL)fullKeyboardAccessEnabled;
+
+@end;
+
+#endif // WKFullKeyboardAccessWatcher_h
diff --git a/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.mm b/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.mm
new file mode 100644
index 000000000..0908a46cb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WKFullKeyboardAccessWatcher.mm
@@ -0,0 +1,86 @@
+/*
+ * 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 "WKFullKeyboardAccessWatcher.h"
+
+#import "WebContext.h"
+
+NSString * const KeyboardUIModeDidChangeNotification = @"com.apple.KeyboardUIModeDidChange";
+const CFStringRef AppleKeyboardUIMode = CFSTR("AppleKeyboardUIMode");
+const CFStringRef UniversalAccessDomain = CFSTR("com.apple.universalaccess");
+
+using namespace WebKit;
+
+@implementation WKFullKeyboardAccessWatcher
+
+- (void)notifyAllWebContexts
+{
+ const Vector<WebContext*>& contexts = WebContext::allContexts();
+ for (size_t i = 0; i < contexts.size(); ++i)
+ contexts[i]->fullKeyboardAccessModeChanged(fullKeyboardAccessEnabled);
+}
+
+- (void)retrieveKeyboardUIModeFromPreferences:(NSNotification *)notification
+{
+ BOOL oldValue = fullKeyboardAccessEnabled;
+
+ CFPreferencesAppSynchronize(UniversalAccessDomain);
+
+ Boolean keyExistsAndHasValidFormat;
+ int mode = CFPreferencesGetAppIntegerValue(AppleKeyboardUIMode, UniversalAccessDomain, &keyExistsAndHasValidFormat);
+ if (keyExistsAndHasValidFormat) {
+ // The keyboard access mode is reported by two bits:
+ // Bit 0 is set if feature is on
+ // Bit 1 is set if full keyboard access works for any control, not just text boxes and lists.
+ fullKeyboardAccessEnabled = (mode & 0x2);
+ }
+
+ if (fullKeyboardAccessEnabled != oldValue)
+ [self notifyAllWebContexts];
+}
+
+- (id)init
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ [self retrieveKeyboardUIModeFromPreferences:nil];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ addObserver:self selector:@selector(retrieveKeyboardUIModeFromPreferences:)
+ name:KeyboardUIModeDidChangeNotification object:nil];
+
+ return self;
+}
+
++ (BOOL)fullKeyboardAccessEnabled
+{
+ static WKFullKeyboardAccessWatcher *watcher = [[WKFullKeyboardAccessWatcher alloc] init];
+ return watcher->fullKeyboardAccessEnabled;
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
new file mode 100644
index 000000000..74e794704
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
@@ -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.
+ */
+
+#if ENABLE(FULLSCREEN_API)
+
+#import <wtf/OwnPtr.h>
+#import <wtf/RetainPtr.h>
+
+namespace WebKit {
+class LayerTreeContext;
+}
+
+namespace WebCore {
+class DisplaySleepDisabler;
+class IntRect;
+}
+
+@class WKView;
+
+@interface WKFullScreenWindowController : NSWindowController {
+@private
+ WKView *_webView;
+ RetainPtr<NSView> _webViewPlaceholder;
+ RetainPtr<NSView> _layerHostingView;
+
+ BOOL _isEnteringFullScreen;
+ BOOL _isExitingFullScreen;
+ BOOL _isFullScreen;
+ BOOL _forceDisableAnimation;
+ BOOL _isPlaying;
+ OwnPtr<WebCore::DisplaySleepDisabler> _displaySleepDisabler;
+}
+
+- (WKView*)webView;
+- (void)setWebView:(WKView*)webView;
+
+- (void)enterFullScreen:(NSScreen *)screen;
+- (void)exitFullScreen;
+- (void)beganEnterFullScreenAnimation;
+- (void)beganExitFullScreenAnimation;
+- (void)finishedEnterFullScreenAnimation:(bool)completed;
+- (void)finishedExitFullScreenAnimation:(bool)completed;
+- (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)context;
+- (void)exitAcceleratedCompositingMode;
+- (WebCore::IntRect)getFullScreenRect;
+- (void)close;
+
+@end
+
+#endif
diff --git a/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
new file mode 100644
index 000000000..204439fa9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm
@@ -0,0 +1,644 @@
+/*
+ * Copyright (C) 2009, 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"
+
+#if ENABLE(FULLSCREEN_API)
+
+#import "WKFullScreenWindowController.h"
+
+#import "LayerTreeContext.h"
+#import "WKAPICast.h"
+#import "WKViewInternal.h"
+#import "WKViewPrivate.h"
+#import "WebFullScreenManagerProxy.h"
+#import "WebPageProxy.h"
+#import <Carbon/Carbon.h> // For SetSystemUIMode()
+#import <QuartzCore/QuartzCore.h>
+#import <WebCore/DisplaySleepDisabler.h>
+#import <WebCore/FloatRect.h>
+#import <WebCore/IntRect.h>
+#import <WebKit/WebNSWindowExtras.h>
+#import <WebKitSystemInterface.h>
+#import <wtf/UnusedParam.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+#if defined(BUILDING_ON_LEOPARD)
+@interface CATransaction(SnowLeopardConvenienceFunctions)
++ (void)setDisableActions:(BOOL)flag;
++ (void)setAnimationDuration:(CFTimeInterval)dur;
+@end
+
+@implementation CATransaction(SnowLeopardConvenienceFunctions)
++ (void)setDisableActions:(BOOL)flag
+{
+ [self setValue:[NSNumber numberWithBool:flag] forKey:kCATransactionDisableActions];
+}
+
++ (void)setAnimationDuration:(CFTimeInterval)dur
+{
+ [self setValue:[NSNumber numberWithDouble:dur] forKey:kCATransactionAnimationDuration];
+}
+@end
+
+#endif
+
+@interface WKFullScreenWindow : NSWindow
+{
+ NSView* _animationView;
+ CALayer* _backgroundLayer;
+}
+- (CALayer*)backgroundLayer;
+- (NSView*)animationView;
+@end
+
+static void continueExitCompositingModeAfterRepaintCallback(WKErrorRef error, void* context);
+
+@interface WKFullScreenWindowController(Private)
+- (void)_requestExitFullScreenWithAnimation:(BOOL)animation;
+- (void)_updateMenuAndDockForFullScreen;
+- (void)_updatePowerAssertions;
+- (WKFullScreenWindow *)_fullScreenWindow;
+- (CFTimeInterval)_animationDuration;
+- (void)_swapView:(NSView*)view with:(NSView*)otherView;
+- (WebPageProxy*)_page;
+- (WebFullScreenManagerProxy*)_manager;
+- (void)_continueExitCompositingModeAfterRepaint;
+@end
+
+@interface NSWindow(IsOnActiveSpaceAdditionForTigerAndLeopard)
+- (BOOL)isOnActiveSpace;
+@end
+
+@implementation WKFullScreenWindowController
+
+#pragma mark -
+#pragma mark Initialization
+- (id)init
+{
+ NSWindow *window = [[WKFullScreenWindow alloc] initWithContentRect:NSZeroRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
+ self = [super initWithWindow:window];
+ [window release];
+ if (!self)
+ return nil;
+ [self windowDidLoad];
+
+ return self;
+}
+
+- (void)dealloc
+{
+ [self setWebView:nil];
+
+ [NSObject cancelPreviousPerformRequestsWithTarget:self];
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+ [super dealloc];
+}
+
+- (void)windowDidLoad
+{
+ [super windowDidLoad];
+
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidResignActive:) name:NSApplicationDidResignActiveNotification object:NSApp];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeScreenParameters:) name:NSApplicationDidChangeScreenParametersNotification object:NSApp];
+}
+
+#pragma mark -
+#pragma mark Accessors
+
+- (WKView*)webView
+{
+ return _webView;
+}
+
+- (void)setWebView:(WKView *)webView
+{
+ [webView retain];
+ [_webView release];
+ _webView = webView;
+}
+
+#pragma mark -
+#pragma mark Notifications
+
+- (void)applicationDidResignActive:(NSNotification*)notification
+{
+ // Check to see if the fullScreenWindow is on the active space; this function is available
+ // on 10.6 and later, so default to YES if the function is not available:
+ NSWindow* fullScreenWindow = [self _fullScreenWindow];
+ BOOL isOnActiveSpace = ([fullScreenWindow respondsToSelector:@selector(isOnActiveSpace)] ? [fullScreenWindow isOnActiveSpace] : YES);
+
+ // Replicate the QuickTime Player (X) behavior when losing active application status:
+ // Is the fullScreen screen the main screen? (Note: this covers the case where only a
+ // single screen is available.) Is the fullScreen screen on the current space? IFF so,
+ // then exit fullScreen mode.
+ if ([fullScreenWindow screen] == [[NSScreen screens] objectAtIndex:0] && isOnActiveSpace)
+ [self _requestExitFullScreenWithAnimation:NO];
+}
+
+- (void)applicationDidChangeScreenParameters:(NSNotification*)notification
+{
+ // The user may have changed the main screen by moving the menu bar, or they may have changed
+ // the Dock's size or location, or they may have changed the fullScreen screen's dimensions.
+ // Update our presentation parameters, and ensure that the full screen window occupies the
+ // entire screen:
+ [self _updateMenuAndDockForFullScreen];
+ NSWindow* window = [self window];
+ [window setFrame:[[window screen] frame] display:YES];
+}
+
+#pragma mark -
+#pragma mark Exposed Interface
+
+- (void)enterFullScreen:(NSScreen *)screen
+{
+ if (_isFullScreen)
+ return;
+
+ _isFullScreen = YES;
+
+ NSDisableScreenUpdates();
+
+ if (!screen)
+ screen = [NSScreen mainScreen];
+ NSRect screenFrame = [screen frame];
+
+#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+ NSRect webViewFrame = [_webView convertRectToBase:[_webView frame]];
+ webViewFrame.origin = [[_webView window] convertBaseToScreen:webViewFrame.origin];
+#else
+ NSRect webViewFrame = [[_webView window] convertRectToScreen:
+ [_webView convertRect:[_webView frame] toView:nil]];
+#endif
+
+ // In the case of a multi-monitor setup where the webView straddles two
+ // monitors, we must create a window large enough to contain the destination
+ // frame and the initial frame.
+ NSRect windowFrame = NSUnionRect(screenFrame, webViewFrame);
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [[self window] setFrame:windowFrame display:YES];
+
+ CALayer* backgroundLayer = [[self _fullScreenWindow] backgroundLayer];
+ NSRect backgroundFrame = {[[self window] convertScreenToBase:screenFrame.origin], screenFrame.size};
+ backgroundFrame = [[[self window] contentView] convertRectFromBase:backgroundFrame];
+
+ [backgroundLayer setFrame:NSRectToCGRect(backgroundFrame)];
+ [CATransaction commit];
+
+ CFTimeInterval duration = [self _animationDuration];
+ [self _manager]->willEnterFullScreen();
+ [self _manager]->beginEnterFullScreenAnimation(duration);
+}
+
+- (void)beganEnterFullScreenAnimation
+{
+ if (_isEnteringFullScreen)
+ return;
+ _isEnteringFullScreen = YES;
+
+ if (_isExitingFullScreen)
+ [self finishedExitFullScreenAnimation:NO];
+
+ [self _updateMenuAndDockForFullScreen];
+ [self _updatePowerAssertions];
+
+ // In a previous incarnation, the NSWindow attached to this controller may have
+ // been on a different screen. Temporarily change the collectionBehavior of the window:
+ NSWindow* fullScreenWindow = [self window];
+ NSWindowCollectionBehavior behavior = [fullScreenWindow collectionBehavior];
+ [fullScreenWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
+ [fullScreenWindow makeKeyAndOrderFront:self];
+ [fullScreenWindow setCollectionBehavior:behavior];
+
+ // Start the opacity animation. We can use implicit animations here because we don't care when
+ // the animation finishes.
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:[self _animationDuration]];
+ [[[self _fullScreenWindow] backgroundLayer] setOpacity:1];
+ [CATransaction commit];
+
+ NSEnableScreenUpdates();
+}
+
+- (void)finishedEnterFullScreenAnimation:(bool)completed
+{
+ if (!_isEnteringFullScreen)
+ return;
+ _isEnteringFullScreen = NO;
+
+ if (completed) {
+ NSDisableScreenUpdates();
+
+ // Swap the webView placeholder into place.
+ if (!_webViewPlaceholder)
+ _webViewPlaceholder.adoptNS([[NSView alloc] init]);
+ NSResponder *webWindowFirstResponder = [[_webView window] firstResponder];
+ [self _swapView:_webView with:_webViewPlaceholder.get()];
+
+ // Then insert the WebView into the full screen window
+ NSView* contentView = [[self _fullScreenWindow] contentView];
+ [contentView addSubview:_webView positioned:NSWindowBelow relativeTo:nil];
+ [_webView setFrame:[contentView bounds]];
+ [[self window] makeResponder:webWindowFirstResponder firstResponderIfDescendantOfView:_webView];
+
+ NSWindow *webWindow = [_webViewPlaceholder.get() window];
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that
+ // behavior here, making sure to reset the animation behavior afterward.
+ NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior];
+ [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];
+#endif
+ [webWindow orderOut:self];
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ [webWindow setAnimationBehavior:animationBehavior];
+#endif
+ [self _manager]->didEnterFullScreen();
+ }
+
+ // Complete the animation once -(void)exitCompositingMode is called.
+}
+
+- (void)exitFullScreen
+{
+ if (!_isFullScreen)
+ return;
+
+ _isFullScreen = NO;
+
+ NSDisableScreenUpdates();
+
+ [self _manager]->willExitFullScreen();
+ [self _manager]->beginExitFullScreenAnimation([self _animationDuration]);
+}
+
+- (void)beganExitFullScreenAnimation
+{
+ if (_isExitingFullScreen)
+ return;
+ _isExitingFullScreen = YES;
+
+ if (_isEnteringFullScreen)
+ [self finishedEnterFullScreenAnimation:NO];
+
+ [self _updateMenuAndDockForFullScreen];
+ [self _updatePowerAssertions];
+
+ // Swap the webView back into its original position:
+ if ([_webView window] == [self window]) {
+ NSResponder *fullScreenWindowFirstResponder = [[self _fullScreenWindow] firstResponder];
+#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
+ // Work around a bug in AppKit <rdar://problem/9443385> where moving a
+ // layer-hosted view from a layer-backed view to a non-layer-backed view
+ // generates an exception.
+ if (![_webView wantsLayer] && [_webView layer]) {
+ [_webView removeFromSuperview];
+ for (NSView* child in [_webView subviews])
+ [[child layer] removeFromSuperlayer];
+ }
+#endif
+ [self _swapView:_webViewPlaceholder.get() with:_webView];
+ [[_webView window] makeResponder:fullScreenWindowFirstResponder firstResponderIfDescendantOfView:_webView];
+ NSWindow* webWindow = [_webView window];
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ // In Lion, NSWindow will animate into and out of orderOut operations. Suppress that
+ // behavior here, making sure to reset the animation behavior afterward.
+ NSWindowAnimationBehavior animationBehavior = [webWindow animationBehavior];
+ [webWindow setAnimationBehavior:NSWindowAnimationBehaviorNone];
+#endif
+ // If the user has moved the fullScreen window into a new space, temporarily change
+ // the collectionBehavior of the webView's window so that it is pulled into the active space:
+ if (![webWindow isOnActiveSpace]) {
+ NSWindowCollectionBehavior behavior = [webWindow collectionBehavior];
+ [webWindow setCollectionBehavior:NSWindowCollectionBehaviorCanJoinAllSpaces];
+ [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
+ [webWindow setCollectionBehavior:behavior];
+ } else
+ [webWindow orderWindow:NSWindowBelow relativeTo:[[self window] windowNumber]];
+
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+ [webWindow setAnimationBehavior:animationBehavior];
+#endif
+ }
+
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:[self _animationDuration]];
+ [[[self _fullScreenWindow] backgroundLayer] setOpacity:0];
+ [CATransaction commit];
+
+ NSEnableScreenUpdates();
+}
+
+- (void)finishedExitFullScreenAnimation:(bool)completed
+{
+ if (!_isExitingFullScreen)
+ return;
+ _isExitingFullScreen = NO;
+
+ NSDisableScreenUpdates();
+
+ [self _updateMenuAndDockForFullScreen];
+ [self _updatePowerAssertions];
+ [NSCursor setHiddenUntilMouseMoves:YES];
+
+ [self _manager]->didExitFullScreen();
+}
+
+- (void)enterAcceleratedCompositingMode:(const WebKit::LayerTreeContext&)layerTreeContext
+{
+ if (_layerHostingView)
+ return;
+
+ // Create an NSView that will host our layer tree.
+ _layerHostingView.adoptNS([[NSView alloc] initWithFrame:[[self window] frame]]);
+ [_layerHostingView.get() setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ WKFullScreenWindow* window = [self _fullScreenWindow];
+ [[window contentView] addSubview:_layerHostingView.get() positioned:NSWindowAbove relativeTo:nil];
+
+ // 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];
+
+ [_layerHostingView.get() setLayer:rootLayer.get()];
+ [_layerHostingView.get() setWantsLayer:YES];
+ [[window backgroundLayer] setHidden:NO];
+ [CATransaction commit];
+}
+
+- (void)exitAcceleratedCompositingMode
+{
+ if (!_layerHostingView)
+ return;
+
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [_layerHostingView.get() removeFromSuperview];
+ [_layerHostingView.get() setLayer:nil];
+ [_layerHostingView.get() setWantsLayer:NO];
+ [[[self _fullScreenWindow] backgroundLayer] setHidden:YES];
+ [CATransaction commit];
+
+ // Complete the animation out of full-screen mode
+ // by hiding the full-screen window:
+ if (!_isFullScreen) {
+ [[_webView window] display];
+ [[self window] orderOut:self];
+ [[_webView window] makeKeyAndOrderFront:self];
+ }
+
+ _layerHostingView = 0;
+ [self _page]->forceRepaint(VoidCallback::create(self, continueExitCompositingModeAfterRepaintCallback));
+}
+
+static void continueExitCompositingModeAfterRepaintCallback(WKErrorRef error, void* context)
+{
+ [(WKFullScreenWindowController*)context _continueExitCompositingModeAfterRepaint];
+}
+
+- (void)_continueExitCompositingModeAfterRepaint
+{
+ NSEnableScreenUpdates();
+
+ [self _manager]->disposeOfLayerClient();
+}
+
+- (WebCore::IntRect)getFullScreenRect
+{
+ return enclosingIntRect([[self window] frame]);
+}
+
+- (void)close
+{
+ // We are being asked to close rapidly, most likely because the page
+ // has closed or the web process has crashed. Just walk through our
+ // normal exit full screen sequence, but don't wait to be called back
+ // in response.
+ if (_isFullScreen) {
+ [self exitFullScreen];
+ [self beganExitFullScreenAnimation];
+ }
+
+ if (_isExitingFullScreen)
+ [self finishedExitFullScreenAnimation:YES];
+
+ [super close];
+}
+
+#pragma mark -
+#pragma mark Internal Interface
+
+- (void)_updateMenuAndDockForFullScreen
+{
+ // NSApplicationPresentationOptions is available on > 10.6 only:
+#ifndef BUILDING_ON_LEOPARD
+ NSApplicationPresentationOptions options = NSApplicationPresentationDefault;
+ NSScreen* fullScreenScreen = [[self window] screen];
+
+ if (_isFullScreen) {
+ // Auto-hide the menu bar if the fullScreenScreen contains the menu bar:
+ // NOTE: if the fullScreenScreen contains the menu bar but not the dock, we must still
+ // auto-hide the dock, or an exception will be thrown.
+ if ([[NSScreen screens] objectAtIndex:0] == fullScreenScreen)
+ options |= (NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock);
+ // Check if the current screen contains the dock by comparing the screen's frame to its
+ // visibleFrame; if a dock is present, the visibleFrame will differ. If the current screen
+ // contains the dock, hide it.
+ else if (!NSEqualRects([fullScreenScreen frame], [fullScreenScreen visibleFrame]))
+ options |= NSApplicationPresentationAutoHideDock;
+ }
+
+ if ([NSApp respondsToSelector:@selector(setPresentationOptions:)])
+ [NSApp setPresentationOptions:options];
+ else
+#endif
+ SetSystemUIMode(_isFullScreen ? kUIModeNormal : kUIModeAllHidden, 0);
+}
+
+- (void)_updatePowerAssertions
+{
+ // FIXME: _isPlaying is never modified so we never disable display sleep here! (<rdar://problem/10151029>)
+ if (_isPlaying && _isFullScreen) {
+ if (!_displaySleepDisabler)
+ _displaySleepDisabler = DisplaySleepDisabler::create("com.apple.WebKit2 - Fullscreen video");
+ } else
+ _displaySleepDisabler = nullptr;
+}
+
+- (WebPageProxy*)_page
+{
+ return toImpl([_webView pageRef]);
+}
+
+- (WebFullScreenManagerProxy*)_manager
+{
+ WebPageProxy* webPage = [self _page];
+ if (!webPage)
+ return 0;
+ return webPage->fullScreenManager();
+}
+
+- (void)_requestExit
+{
+ [self exitFullScreen];
+ _forceDisableAnimation = NO;
+}
+
+- (void)_requestExitFullScreenWithAnimation:(BOOL)animation
+{
+ _forceDisableAnimation = !animation;
+ [self performSelector:@selector(_requestExit) withObject:nil afterDelay:0];
+
+}
+
+- (void)_swapView:(NSView*)view with:(NSView*)otherView
+{
+ [CATransaction begin];
+ [CATransaction setDisableActions:YES];
+ [otherView setFrame:[view frame]];
+ [otherView setAutoresizingMask:[view autoresizingMask]];
+ [otherView removeFromSuperview];
+ [[view superview] replaceSubview:view with:otherView];
+ [CATransaction commit];
+}
+
+#pragma mark -
+#pragma mark Utility Functions
+
+- (WKFullScreenWindow *)_fullScreenWindow
+{
+ ASSERT([[self window] isKindOfClass:[WKFullScreenWindow class]]);
+ return (WKFullScreenWindow *)[self window];
+}
+
+- (CFTimeInterval)_animationDuration
+{
+ static const CFTimeInterval defaultDuration = 0.5;
+ CFTimeInterval duration = defaultDuration;
+#ifndef BUILDING_ON_LEOPARD
+ NSUInteger modifierFlags = [NSEvent modifierFlags];
+#else
+ NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags];
+#endif
+ if ((modifierFlags & NSControlKeyMask) == NSControlKeyMask)
+ duration *= 2;
+ if ((modifierFlags & NSShiftKeyMask) == NSShiftKeyMask)
+ duration *= 10;
+ if (_forceDisableAnimation) {
+ // This will disable scale animation
+ duration = 0;
+ }
+ return duration;
+}
+
+@end
+
+#pragma mark -
+@implementation WKFullScreenWindow
+
+- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
+{
+ UNUSED_PARAM(aStyle);
+ self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag];
+ if (!self)
+ return nil;
+ [self setOpaque:NO];
+ [self setBackgroundColor:[NSColor clearColor]];
+ [self setIgnoresMouseEvents:NO];
+ [self setAcceptsMouseMovedEvents:YES];
+ [self setReleasedWhenClosed:NO];
+ [self setHasShadow:YES];
+#ifndef BUILDING_ON_LEOPARD
+ [self setMovable:NO];
+#else
+ [self setMovableByWindowBackground:NO];
+#endif
+
+ NSView* contentView = [self contentView];
+ [contentView setWantsLayer:YES];
+ _animationView = [[NSView alloc] initWithFrame:[contentView bounds]];
+
+ CALayer* contentLayer = [[CALayer alloc] init];
+ [_animationView setLayer:contentLayer];
+ [_animationView setWantsLayer:YES];
+ [_animationView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
+ [contentView addSubview:_animationView];
+
+ _backgroundLayer = [[CALayer alloc] init];
+ [contentLayer addSublayer:_backgroundLayer];
+
+ [_backgroundLayer setBackgroundColor:CGColorGetConstantColor(kCGColorBlack)];
+ [_backgroundLayer setOpacity:0];
+ return self;
+}
+
+- (void)dealloc
+{
+ [_animationView release];
+ [_backgroundLayer release];
+ [super dealloc];
+}
+
+- (BOOL)canBecomeKeyWindow
+{
+ return YES;
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ if ([[theEvent charactersIgnoringModifiers] isEqual:@"\e"]) // Esacpe key-code
+ [self cancelOperation:self];
+ else [super keyDown:theEvent];
+}
+
+- (void)cancelOperation:(id)sender
+{
+ UNUSED_PARAM(sender);
+ [[self windowController] _requestExitFullScreenWithAnimation:YES];
+}
+
+- (CALayer*)backgroundLayer
+{
+ return _backgroundLayer;
+}
+
+- (NSView*)animationView
+{
+ return _animationView;
+}
+@end
+
+#endif
diff --git a/Source/WebKit2/UIProcess/mac/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm
new file mode 100644
index 000000000..5270b7396
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm
@@ -0,0 +1,151 @@
+/*
+ * 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 "WebContext.h"
+
+#import "WebKitSystemInterface.h"
+#import "WebProcessCreationParameters.h"
+#import <WebCore/FileSystem.h>
+#import <sys/param.h>
+
+using namespace WebCore;
+
+NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory";
+NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
+NSString *WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey";
+
+static NSString *WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification = @"NSApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification";
+
+// FIXME: <rdar://problem/9138817> - After this "backwards compatibility" radar is removed, this code should be removed to only return an empty String.
+NSString *WebIconDatabaseDirectoryDefaultsKey = @"WebIconDatabaseDirectoryDefaultsKey";
+
+namespace WebKit {
+
+String WebContext::applicationCacheDirectory()
+{
+ NSString *appName = [[NSBundle mainBundle] bundleIdentifier];
+ if (!appName)
+ appName = [[NSProcessInfo processInfo] processName];
+
+ ASSERT(appName);
+
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSString *cacheDir = [defaults objectForKey:WebKitLocalCacheDefaultsKey];
+
+ if (!cacheDir || ![cacheDir isKindOfClass:[NSString class]]) {
+ char cacheDirectory[MAXPATHLEN];
+ size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
+
+ if (cacheDirectoryLen)
+ cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
+ }
+
+ return [cacheDir stringByAppendingPathComponent:appName];
+}
+
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
+{
+ if (!omitPDFSupport()) {
+ // We want to use a PDF view in the UI process for PDF MIME types.
+ HashSet<String, CaseFoldingHash> mimeType = pdfAndPostScriptMIMETypes();
+ parameters.mimeTypesWithCustomRepresentation.appendRange(mimeType.begin(), mimeType.end());
+ }
+
+ RetainPtr<CFStringRef> cachePath(AdoptCF, WKCopyFoundationCacheDirectory());
+ if (!cachePath)
+ cachePath = reinterpret_cast<CFStringRef>(NSHomeDirectory());
+
+ NSURLCache *urlCache = [NSURLCache sharedURLCache];
+
+ parameters.parentProcessName = [[NSProcessInfo processInfo] processName];
+ parameters.nsURLCachePath = [(NSString *)cachePath.get() stringByStandardizingPath];
+ parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity];
+ parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity];
+
+ ASSERT(!parameters.nsURLCachePath.isEmpty());
+
+#if ENABLE(PLUGIN_PROCESS)
+ parameters.disablePluginProcessMessageTimeout = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitDisablePluginProcessMessageTimeout"];
+#endif
+
+#if USE(ACCELERATED_COMPOSITING) && HAVE(HOSTED_CORE_ANIMATION)
+ mach_port_t renderServerPort = WKInitializeRenderServer();
+ if (renderServerPort != MACH_PORT_NULL)
+ parameters.acceleratedCompositingPort = CoreIPC::MachPort(renderServerPort, MACH_MSG_TYPE_COPY_SEND);
+#endif
+
+ // FIXME: This should really be configurable; we shouldn't just blindly allow read access to the UI process bundle.
+ parameters.uiProcessBundleResourcePath = [[NSBundle mainBundle] resourcePath];
+
+#if USE(CFURLSTORAGESESSIONS)
+ parameters.uiProcessBundleIdentifier = String([[NSBundle mainBundle] bundleIdentifier]);
+#endif
+
+ // Listen for enhanced accessibility changes and propagate them to the WebProcess.
+ m_enhancedAccessibilityObserver = [[NSNotificationCenter defaultCenter] addObserverForName:WebKitApplicationDidChangeAccessibilityEnhancedUserInterfaceNotification object:nil queue:[NSOperationQueue currentQueue] usingBlock:^(NSNotification *note) {
+ setEnhancedAccessibility([[[note userInfo] objectForKey:@"AXEnhancedUserInterface"] boolValue]);
+ }];
+}
+
+void WebContext::platformInvalidateContext()
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:(id)m_enhancedAccessibilityObserver.get()];
+}
+
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+ NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebDatabaseDirectoryDefaultsKey];
+ if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
+ databasesDirectory = @"~/Library/WebKit/Databases";
+ return [databasesDirectory stringByStandardizingPath];
+}
+
+String WebContext::platformDefaultIconDatabasePath() const
+{
+ // FIXME: <rdar://problem/9138817> - After this "backwards compatibility" radar is removed, this code should be removed to only return an empty String.
+ NSString *databasesDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebIconDatabaseDirectoryDefaultsKey];
+ if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
+ databasesDirectory = @"~/Library/Icons/WebpageIcons.db";
+ return [databasesDirectory stringByStandardizingPath];
+}
+
+String WebContext::platformDefaultLocalStorageDirectory() const
+{
+ NSString *localStorageDirectory = [[NSUserDefaults standardUserDefaults] objectForKey:WebStorageDirectoryDefaultsKey];
+ if (!localStorageDirectory || ![localStorageDirectory isKindOfClass:[NSString class]])
+ localStorageDirectory = @"~/Library/WebKit/LocalStorage";
+ return [localStorageDirectory stringByStandardizingPath];
+}
+
+bool WebContext::omitPDFSupport()
+{
+ // Since this is a "secret default" we don't bother registering it.
+ return [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h
new file mode 100644
index 000000000..20ffd0b67
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.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 WebContextMenuProxyMac_h
+#define WebContextMenuProxyMac_h
+
+#include "WebContextMenuProxy.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS NSPopUpButtonCell;
+OBJC_CLASS WKView;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebContextMenuProxyMac : public WebContextMenuProxy {
+public:
+ static PassRefPtr<WebContextMenuProxyMac> create(WKView* webView, WebPageProxy* page)
+ {
+ return adoptRef(new WebContextMenuProxyMac(webView, page));
+ }
+ ~WebContextMenuProxyMac();
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ virtual void hideContextMenu();
+
+ void contextMenuItemSelected(const WebContextMenuItemData&);
+
+private:
+ WebContextMenuProxyMac(WKView*, WebPageProxy*);
+
+ void populate(const Vector<WebContextMenuItemData>&);
+
+ RetainPtr<NSPopUpButtonCell> m_popup;
+ WKView* m_webView;
+ WebPageProxy* m_page;
+};
+
+} // namespace WebKit
+
+#endif // WebContextMenuProxyMac_h
diff --git a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
new file mode 100644
index 000000000..81552dc5e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
@@ -0,0 +1,234 @@
+/*
+ * 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 "WebContextMenuProxyMac.h"
+
+#import "PageClientImpl.h"
+#import "WebContextMenuItemData.h"
+#import "WKView.h"
+
+#import <WebCore/IntRect.h>
+#import <WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+@interface WKUserDataWrapper : NSObject {
+ RefPtr<WebKit::APIObject> _webUserData;
+}
+- (id)initWithUserData:(WebKit::APIObject*)userData;
+- (WebKit::APIObject*)userData;
+@end
+
+@implementation WKUserDataWrapper
+
+- (id)initWithUserData:(WebKit::APIObject*)userData
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _webUserData = userData;
+ return self;
+}
+
+- (WebKit::APIObject*)userData
+{
+ return _webUserData.get();
+}
+
+@end
+
+@interface WKMenuTarget : NSObject {
+ WebKit::WebContextMenuProxyMac* _menuProxy;
+}
++ (WKMenuTarget*)sharedMenuTarget;
+- (WebKit::WebContextMenuProxyMac*)menuProxy;
+- (void)setMenuProxy:(WebKit::WebContextMenuProxyMac*)menuProxy;
+- (void)forwardContextMenuAction:(id)sender;
+@end
+
+@implementation WKMenuTarget
+
++ (WKMenuTarget*)sharedMenuTarget
+{
+ static WKMenuTarget* target = [[WKMenuTarget alloc] init];
+ return target;
+}
+
+- (WebKit::WebContextMenuProxyMac*)menuProxy
+{
+ return _menuProxy;
+}
+
+- (void)setMenuProxy:(WebKit::WebContextMenuProxyMac*)menuProxy
+{
+ _menuProxy = menuProxy;
+}
+
+- (void)forwardContextMenuAction:(id)sender
+{
+ WebKit::WebContextMenuItemData item(ActionType, static_cast<ContextMenuAction>([sender tag]), [sender title], [sender isEnabled], [sender state] == NSOnState);
+
+ if (id representedObject = [sender representedObject]) {
+ ASSERT([representedObject isKindOfClass:[WKUserDataWrapper class]]);
+ item.setUserData([static_cast<WKUserDataWrapper *>(representedObject) userData]);
+ }
+
+ _menuProxy->contextMenuItemSelected(item);
+}
+
+@end
+
+namespace WebKit {
+
+WebContextMenuProxyMac::WebContextMenuProxyMac(WKView* webView, WebPageProxy* page)
+ : m_webView(webView)
+ , m_page(page)
+{
+}
+
+WebContextMenuProxyMac::~WebContextMenuProxyMac()
+{
+ if (m_popup)
+ [m_popup.get() setControlView:nil];
+}
+
+void WebContextMenuProxyMac::contextMenuItemSelected(const WebContextMenuItemData& item)
+{
+ m_page->contextMenuItemSelected(item);
+}
+
+static void populateNSMenu(NSMenu* menu, const Vector<RetainPtr<NSMenuItem> >& menuItemVector)
+{
+ for (unsigned i = 0; i < menuItemVector.size(); ++i) {
+ NSInteger oldState = [menuItemVector[i].get() state];
+ [menu addItem:menuItemVector[i].get()];
+ [menuItemVector[i].get() setState:oldState];
+ }
+}
+
+static Vector<RetainPtr<NSMenuItem> > nsMenuItemVector(const Vector<WebContextMenuItemData>& items)
+{
+ Vector<RetainPtr<NSMenuItem> > result;
+
+ unsigned size = items.size();
+ result.reserveCapacity(size);
+ for (unsigned i = 0; i < size; i++) {
+ switch (items[i].type()) {
+ case ActionType:
+ case CheckableActionType: {
+ NSMenuItem* menuItem = [[NSMenuItem alloc] initWithTitle:nsStringFromWebCoreString(items[i].title()) action:@selector(forwardContextMenuAction:) keyEquivalent:@""];
+ [menuItem setTag:items[i].action()];
+ [menuItem setEnabled:items[i].enabled()];
+ [menuItem setState:items[i].checked() ? NSOnState : NSOffState];
+
+ if (items[i].userData()) {
+ WKUserDataWrapper *wrapper = [[WKUserDataWrapper alloc] initWithUserData:items[i].userData()];
+ [menuItem setRepresentedObject:wrapper];
+ [wrapper release];
+ }
+
+ result.append(RetainPtr<NSMenuItem>(AdoptNS, menuItem));
+ break;
+ }
+ case SeparatorType:
+ result.append([NSMenuItem separatorItem]);
+ break;
+ case SubmenuType: {
+ NSMenu* menu = [[NSMenu alloc] initWithTitle:nsStringFromWebCoreString(items[i].title())];
+ [menu setAutoenablesItems:NO];
+ populateNSMenu(menu, nsMenuItemVector(items[i].submenu()));
+
+ NSMenuItem* menuItem = [[NSMenuItem alloc] initWithTitle:nsStringFromWebCoreString(items[i].title()) action:@selector(forwardContextMenuAction:) keyEquivalent:@""];
+ [menuItem setEnabled:items[i].enabled()];
+ [menuItem setSubmenu:menu];
+ [menu release];
+
+ result.append(RetainPtr<NSMenuItem>(AdoptNS, menuItem));
+
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+
+ WKMenuTarget* target = [WKMenuTarget sharedMenuTarget];
+ for (unsigned i = 0; i < size; ++i)
+ [result[i].get() setTarget:target];
+
+ return result;
+}
+
+void WebContextMenuProxyMac::populate(const Vector<WebContextMenuItemData>& items)
+{
+ if (m_popup)
+ [m_popup.get() removeAllItems];
+ else {
+ m_popup.adoptNS([[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]);
+ [m_popup.get() setUsesItemFromMenu:NO];
+ [m_popup.get() setAutoenablesItems:NO];
+ }
+
+ NSMenu* menu = [m_popup.get() menu];
+ populateNSMenu(menu, nsMenuItemVector(items));
+}
+
+void WebContextMenuProxyMac::showContextMenu(const IntPoint& menuLocation, const Vector<WebContextMenuItemData>& items)
+{
+ if (items.isEmpty())
+ return;
+
+ populate(items);
+ [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
+
+ NSRect menuRect = NSMakeRect(menuLocation.x(), menuLocation.y(), 0, 0);
+
+ [m_popup.get() attachPopUpWithFrame:menuRect inView:m_webView];
+
+ NSMenu* menu = [m_popup.get() menu];
+
+ // These values were borrowed from AppKit to match their placement of the menu.
+ NSRect titleFrame = [m_popup.get() titleRectForBounds:menuRect];
+ if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
+ titleFrame = menuRect;
+ float vertOffset = roundf((NSMaxY(menuRect) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
+ NSPoint location = NSMakePoint(NSMinX(menuRect), NSMaxY(menuRect) - vertOffset);
+
+ location = [m_webView convertPoint:location toView:nil];
+ location = [m_webView.window convertBaseToScreen:location];
+
+ WKPopupContextMenu(menu, location);
+
+ [m_popup.get() dismissPopUp];
+}
+
+void WebContextMenuProxyMac::hideContextMenu()
+{
+ [m_popup.get() dismissPopUp];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm
new file mode 100644
index 000000000..6a3134647
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebCookieManagerProxyMac.mm
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011, 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 "WebCookieManagerProxy.h"
+
+namespace WebKit {
+
+void WebCookieManagerProxy::persistHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
+{
+ // FIXME: The sandbox appears to prevent persisting the new policy to disk, so we must set the
+ // policy in the UI Process as well as in the Web Process (to make sure it gets set on any
+ // Private Browsing Cookie Storage).
+ [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:policy];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm
new file mode 100644
index 000000000..20e92c054
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebFullScreenManagerProxyMac.mm
@@ -0,0 +1,112 @@
+/*
+ * 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 "WebFullScreenManagerProxy.h"
+
+#import "LayerTreeContext.h"
+#import "WKFullScreenWindowController.h"
+#import "WKViewInternal.h"
+#import <WebCore/IntRect.h>
+
+#if ENABLE(FULLSCREEN_API)
+
+namespace WebKit {
+
+void WebFullScreenManagerProxy::invalidate()
+{
+ if (!m_webView)
+ return;
+
+ [m_webView closeFullScreenWindowController];
+ m_webView = 0;
+}
+
+void WebFullScreenManagerProxy::enterFullScreen()
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] enterFullScreen:nil];
+}
+
+void WebFullScreenManagerProxy::exitFullScreen()
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] exitFullScreen];
+}
+
+void WebFullScreenManagerProxy::beganEnterFullScreenAnimation()
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] beganEnterFullScreenAnimation];
+}
+
+void WebFullScreenManagerProxy::finishedEnterFullScreenAnimation(bool completed)
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] finishedEnterFullScreenAnimation:completed];
+}
+
+void WebFullScreenManagerProxy::beganExitFullScreenAnimation()
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] beganExitFullScreenAnimation];
+}
+
+void WebFullScreenManagerProxy::finishedExitFullScreenAnimation(bool completed)
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] finishedExitFullScreenAnimation:completed];
+}
+
+void WebFullScreenManagerProxy::enterAcceleratedCompositingMode(const LayerTreeContext& context)
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] enterAcceleratedCompositingMode:context];
+}
+
+void WebFullScreenManagerProxy::exitAcceleratedCompositingMode()
+{
+ if (!m_webView)
+ return;
+ [[m_webView fullScreenWindowController] exitAcceleratedCompositingMode];
+}
+
+void WebFullScreenManagerProxy::getFullScreenRect(WebCore::IntRect& rect)
+{
+ if (!m_webView)
+ return;
+ rect = [[m_webView fullScreenWindowController] getFullScreenRect];
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
new file mode 100644
index 000000000..26410bce0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
@@ -0,0 +1,283 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#import "WKAPICast.h"
+#import "WebContext.h"
+#import "WKInspectorMac.h"
+#import "WKViewPrivate.h"
+#import "WebPageProxy.h"
+#import "WebProcessProxy.h"
+#import <WebKitSystemInterface.h>
+#import <WebCore/InspectorFrontendClientLocal.h>
+#import <WebCore/LocalizedStrings.h>
+#import <WebCore/NotImplemented.h>
+#import <wtf/text/WTFString.h>
+
+using namespace WebCore;
+using namespace WebKit;
+
+// The height needed to match a typical NSToolbar.
+static const CGFloat windowContentBorderThickness = 55;
+
+// WKWebInspectorProxyObjCAdapter is a helper ObjC object used as a delegate or notification observer
+// for the sole purpose of getting back into the C++ code from an ObjC caller.
+
+@interface WKWebInspectorProxyObjCAdapter : NSObject <NSWindowDelegate> {
+ WebInspectorProxy* _inspectorProxy; // Not retained to prevent cycles
+}
+
+- (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy;
+
+@end
+
+@implementation WKWebInspectorProxyObjCAdapter
+
+- (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy
+{
+ ASSERT_ARG(inspectorProxy, inspectorProxy);
+
+ if (!(self = [super init]))
+ return nil;
+
+ _inspectorProxy = inspectorProxy; // Not retained to prevent cycles
+
+ return self;
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+ _inspectorProxy->close();
+}
+
+- (void)inspectedViewFrameDidChange:(NSNotification *)notification
+{
+ _inspectorProxy->inspectedViewFrameDidChange();
+}
+
+@end
+
+@interface WKWebInspectorWKView : WKView
+@end
+
+@implementation WKWebInspectorWKView
+
+- (NSInteger)tag
+{
+ return WKInspectorViewTag;
+}
+
+@end
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(m_page);
+ ASSERT(!m_inspectorView);
+
+ m_inspectorView.adoptNS([[WKWebInspectorWKView alloc] initWithFrame:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]);
+ ASSERT(m_inspectorView);
+
+ [m_inspectorView.get() setDrawsBackground:NO];
+
+ return toImpl(m_inspectorView.get().pageRef);
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ ASSERT(!m_inspectorWindow);
+
+ m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
+
+ bool useTexturedWindow = page()->process()->context()->overrideWebInspectorPagePath().isEmpty();
+
+ NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask);
+ if (useTexturedWindow)
+ styleMask |= NSTexturedBackgroundWindowMask;
+
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
+ [window setDelegate:m_inspectorProxyObjCAdapter.get()];
+ [window setMinSize:NSMakeSize(minimumWindowWidth, minimumWindowHeight)];
+ [window setReleasedWhenClosed:NO];
+
+ if (useTexturedWindow) {
+ [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
+ [window setContentBorderThickness:windowContentBorderThickness forEdge:NSMaxYEdge];
+ WKNSWindowMakeBottomCornersSquare(window);
+ }
+
+ // Center the window initially before setting the frame autosave name so that the window will be in a good
+ // position if there is no saved frame yet.
+ [window center];
+ [window setFrameAutosaveName:@"Web Inspector 2"];
+
+ NSView *contentView = [window contentView];
+ [m_inspectorView.get() setFrame:[contentView bounds]];
+ [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+ [contentView addSubview:m_inspectorView.get()];
+
+ m_inspectorWindow.adoptNS(window);
+
+ if (m_isAttached)
+ platformAttach();
+ else
+ [window makeKeyAndOrderFront:nil];
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ [m_inspectorWindow.get() setDelegate:nil];
+ [m_inspectorWindow.get() orderOut:nil];
+
+ m_inspectorWindow = 0;
+ m_inspectorView = 0;
+ m_inspectorProxyObjCAdapter = 0;
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ // FIXME: this will not bring a background tab in Safari to the front, only its window.
+ [m_inspectorView.get().window makeKeyAndOrderFront:nil];
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String& urlString)
+{
+ NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString];
+ [m_inspectorWindow.get() setTitle:title];
+}
+
+void WebInspectorProxy::inspectedViewFrameDidChange()
+{
+ if (!m_isAttached)
+ return;
+
+ WKView *inspectedView = m_page->wkView();
+ NSRect inspectedViewFrame = [inspectedView frame];
+
+ CGFloat inspectedLeft = NSMinX(inspectedViewFrame);
+ CGFloat inspectedTop = NSMaxY(inspectedViewFrame);
+ CGFloat inspectedWidth = NSWidth(inspectedViewFrame);
+ CGFloat inspectorHeight = NSHeight([m_inspectorView.get() frame]);
+
+ CGFloat parentHeight = NSHeight([[inspectedView superview] frame]);
+ inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(inspectorHeight, parentHeight);
+
+ [m_inspectorView.get() setFrame:NSMakeRect(inspectedLeft, 0.0, inspectedWidth, inspectorHeight)];
+ [inspectedView setFrame:NSMakeRect(inspectedLeft, inspectorHeight, inspectedWidth, inspectedTop - inspectorHeight)];
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ WKView *inspectedView = m_page->wkView();
+ NSRect inspectedViewRect = [inspectedView frame];
+ return static_cast<unsigned>(inspectedViewRect.size.height);
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ WKView *inspectedView = m_page->wkView();
+ [[NSNotificationCenter defaultCenter] addObserver:m_inspectorProxyObjCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView];
+
+ [m_inspectorView.get() removeFromSuperview];
+
+ [[inspectedView superview] addSubview:m_inspectorView.get() positioned:NSWindowBelow relativeTo:inspectedView];
+
+ [m_inspectorWindow.get() orderOut:nil];
+
+ inspectedViewFrameDidChange();
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ WKView *inspectedView = m_page->wkView();
+ [[NSNotificationCenter defaultCenter] removeObserver:m_inspectorProxyObjCAdapter.get() name:NSViewFrameDidChangeNotification object:inspectedView];
+
+ [m_inspectorView.get() removeFromSuperview];
+
+ // Move the inspector view back into the inspector window.
+ NSView *inspectorWindowContentView = [m_inspectorWindow.get() contentView];
+ [m_inspectorView.get() setFrame:[inspectorWindowContentView bounds]];
+ [inspectorWindowContentView addSubview:m_inspectorView.get()];
+
+ // Make sure that we size the inspected view's frame after detaching so that it takes up the space that the
+ // attached inspector used to. This assumes the previous height was the Y origin.
+ NSRect inspectedViewRect = [inspectedView frame];
+ inspectedViewRect.size.height += NSMinY(inspectedViewRect);
+ inspectedViewRect.origin.y = 0.0;
+ [inspectedView setFrame:inspectedViewRect];
+
+ if (m_isVisible)
+ [m_inspectorWindow.get() makeKeyAndOrderFront:nil];
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned height)
+{
+ if (!m_isAttached)
+ return;
+
+ WKView *inspectedView = m_page->wkView();
+ NSRect inspectedViewFrame = [inspectedView frame];
+
+ // The inspector view shares the width and the left starting point of the inspected view.
+ [m_inspectorView.get() setFrame:NSMakeRect(NSMinX(inspectedViewFrame), 0.0, NSWidth(inspectedViewFrame), height)];
+
+ inspectedViewFrameDidChange();
+
+ [m_inspectorView.get() setNeedsDisplay:YES];
+ [inspectedView setNeedsDisplay:YES];
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ NSString *path = page()->process()->context()->overrideWebInspectorPagePath();
+ if (![path length])
+ path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
+
+ ASSERT([path length]);
+
+ return [[NSURL fileURLWithPath:path] absoluteString];
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ NSString *path = page()->process()->context()->overrideWebInspectorBaseDirectory();
+ if (![path length]) {
+ // WebCore's Web Inspector uses localized strings, which are not contained within inspector directory.
+ path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] resourcePath];
+ }
+
+ ASSERT([path length]);
+
+ return [[NSURL fileURLWithPath:path] absoluteString];
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
new file mode 100644
index 000000000..192eb419f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
@@ -0,0 +1,404 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#import "AttributedString.h"
+#import "DataReference.h"
+#import "DictionaryPopupInfo.h"
+#import "EditorState.h"
+#import "NativeWebKeyboardEvent.h"
+#import "PluginComplexTextInputState.h"
+#import "PageClient.h"
+#import "PageClientImpl.h"
+#import "TextChecker.h"
+#import "WebPageMessages.h"
+#import "WebProcessProxy.h"
+#import <WebKitSystemInterface.h>
+#import <wtf/text/StringConcatenate.h>
+
+@interface NSApplication (Details)
+- (void)speakString:(NSString *)string;
+@end
+
+#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process()->connection())
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#if defined(__ppc__) || defined(__ppc64__)
+#define PROCESSOR "PPC"
+#elif defined(__i386__) || defined(__x86_64__)
+#define PROCESSOR "Intel"
+#else
+#error Unknown architecture
+#endif
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
+
+static String macOSXVersionString()
+{
+ // Use underscores instead of dots because when we first added the Mac OS X version to the user agent string
+ // we were concerned about old DHTML libraries interpreting "4." as Netscape 4. That's no longer a concern for us
+ // but we're sticking with the underscores for compatibility with the format used by older versions of Safari.
+ return [WKGetMacOSXVersionString() stringByReplacingOccurrencesOfString:@"." withString:@"_"];
+}
+
+#else
+
+static inline int callGestalt(OSType selector)
+{
+ SInt32 value = 0;
+ Gestalt(selector, &value);
+ return value;
+}
+
+// Uses underscores instead of dots because if "4." ever appears in a user agent string, old DHTML libraries treat it as Netscape 4.
+static String macOSXVersionString()
+{
+ // Can't use -[NSProcessInfo operatingSystemVersionString] because it has too much stuff we don't want.
+ int major = callGestalt(gestaltSystemVersionMajor);
+ ASSERT(major);
+
+ int minor = callGestalt(gestaltSystemVersionMinor);
+ int bugFix = callGestalt(gestaltSystemVersionBugFix);
+ if (bugFix)
+ return String::format("%d_%d_%d", major, minor, bugFix);
+ if (minor)
+ return String::format("%d_%d", major, minor);
+ return String::format("%d", major);
+}
+
+#endif // !defined(BUILDING_ON_SNOW_LEOPARD) && !defined(BUILDING_ON_LION)
+
+static String userVisibleWebKitVersionString()
+{
+ // If the version is 4 digits long or longer, then the first digit represents
+ // the version of the OS. Our user agent string should not include this first digit,
+ // so strip it off and report the rest as the version. <rdar://problem/4997547>
+ NSString *fullVersion = [[NSBundle bundleForClass:NSClassFromString(@"WKView")] objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey];
+ NSRange nonDigitRange = [fullVersion rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]];
+ if (nonDigitRange.location == NSNotFound && [fullVersion length] >= 4)
+ return [fullVersion substringFromIndex:1];
+ if (nonDigitRange.location != NSNotFound && nonDigitRange.location >= 4)
+ return [fullVersion substringFromIndex:1];
+ return fullVersion;
+}
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ DEFINE_STATIC_LOCAL(String, osVersion, (macOSXVersionString()));
+ DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString()));
+
+ if (applicationNameForUserAgent.isEmpty())
+ return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)");
+ return makeString("Mozilla/5.0 (Macintosh; " PROCESSOR " Mac OS X ", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent);
+}
+
+void WebPageProxy::getIsSpeaking(bool& isSpeaking)
+{
+ isSpeaking = [NSApp isSpeaking];
+}
+
+void WebPageProxy::speak(const String& string)
+{
+ [NSApp speakString:nsStringFromWebCoreString(string)];
+}
+
+void WebPageProxy::stopSpeaking()
+{
+ [NSApp stopSpeaking:nil];
+}
+
+void WebPageProxy::searchWithSpotlight(const String& string)
+{
+ [[NSWorkspace sharedWorkspace] showSearchResultsForQueryString:nsStringFromWebCoreString(string)];
+}
+
+CGContextRef WebPageProxy::containingWindowGraphicsContext()
+{
+ return m_pageClient->containingWindowGraphicsContext();
+}
+
+void WebPageProxy::updateWindowIsVisible(bool windowIsVisible)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetWindowIsVisible(windowIsVisible), m_pageID);
+}
+
+void WebPageProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates, const IntPoint& accessibilityViewCoordinates)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::WindowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates, accessibilityViewCoordinates), m_pageID);
+}
+
+void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
+{
+ if (!isValid()) {
+ // If this fails, we should call -discardMarkedText on input context to notify the input method.
+ // This will happen naturally later, as part of reloading the page.
+ return;
+ }
+
+ process()->sendSync(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), Messages::WebPage::SetComposition::Reply(m_editorState), m_pageID);
+}
+
+void WebPageProxy::confirmComposition()
+{
+ if (!isValid())
+ return;
+
+ process()->sendSync(Messages::WebPage::ConfirmComposition(), Messages::WebPage::ConfirmComposition::Reply(m_editorState), m_pageID);
+}
+
+void WebPageProxy::cancelComposition()
+{
+ if (!isValid())
+ return;
+
+ process()->sendSync(Messages::WebPage::CancelComposition(), Messages::WebPage::ConfirmComposition::Reply(m_editorState), m_pageID);
+}
+
+bool WebPageProxy::insertText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
+{
+ if (!isValid())
+ return true;
+
+ bool handled = true;
+ process()->sendSync(Messages::WebPage::InsertText(text, replacementRangeStart, replacementRangeEnd), Messages::WebPage::InsertText::Reply(handled, m_editorState), m_pageID);
+ return handled;
+}
+
+void WebPageProxy::getMarkedRange(uint64_t& location, uint64_t& length)
+{
+ location = NSNotFound;
+ length = 0;
+
+ if (!isValid())
+ return;
+
+ process()->sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID);
+}
+
+void WebPageProxy::getSelectedRange(uint64_t& location, uint64_t& length)
+{
+ location = NSNotFound;
+ length = 0;
+
+ if (!isValid())
+ return;
+
+ process()->sendSync(Messages::WebPage::GetSelectedRange(), Messages::WebPage::GetSelectedRange::Reply(location, length), m_pageID);
+}
+
+void WebPageProxy::getAttributedSubstringFromRange(uint64_t location, uint64_t length, AttributedString& result)
+{
+ if (!isValid())
+ return;
+ process()->sendSync(Messages::WebPage::GetAttributedSubstringFromRange(location, length), Messages::WebPage::GetAttributedSubstringFromRange::Reply(result), m_pageID);
+}
+
+uint64_t WebPageProxy::characterIndexForPoint(const IntPoint point)
+{
+ if (!isValid())
+ return 0;
+
+ uint64_t result = 0;
+ process()->sendSync(Messages::WebPage::CharacterIndexForPoint(point), Messages::WebPage::CharacterIndexForPoint::Reply(result), m_pageID);
+ return result;
+}
+
+IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uint64_t length)
+{
+ if (!isValid())
+ return IntRect();
+
+ IntRect resultRect;
+ process()->sendSync(Messages::WebPage::FirstRectForCharacterRange(location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID);
+ return resultRect;
+}
+
+bool WebPageProxy::executeKeypressCommands(const Vector<WebCore::KeypressCommand>& commands)
+{
+ if (!isValid())
+ return false;
+
+ bool result = false;
+ process()->sendSync(Messages::WebPage::ExecuteKeypressCommands(commands), Messages::WebPage::ExecuteKeypressCommands::Reply(result, m_editorState), m_pageID);
+ return result;
+}
+
+bool WebPageProxy::writeSelectionToPasteboard(const String& pasteboardName, const Vector<String>& pasteboardTypes)
+{
+ if (!isValid())
+ return false;
+
+ bool result = false;
+ const double messageTimeout = 20;
+ process()->sendSync(Messages::WebPage::WriteSelectionToPasteboard(pasteboardName, pasteboardTypes), Messages::WebPage::WriteSelectionToPasteboard::Reply(result), m_pageID, messageTimeout);
+ return result;
+}
+
+bool WebPageProxy::readSelectionFromPasteboard(const String& pasteboardName)
+{
+ if (!isValid())
+ return false;
+
+ bool result = false;
+ const double messageTimeout = 20;
+ process()->sendSync(Messages::WebPage::ReadSelectionFromPasteboard(pasteboardName), Messages::WebPage::ReadSelectionFromPasteboard::Reply(result), m_pageID, messageTimeout);
+ return result;
+}
+
+void WebPageProxy::setDragImage(const WebCore::IntPoint& clientPosition, const ShareableBitmap::Handle& dragImageHandle, bool isLinkDrag)
+{
+ RefPtr<ShareableBitmap> dragImage = ShareableBitmap::create(dragImageHandle);
+ if (!dragImage)
+ return;
+
+ m_pageClient->setDragImage(clientPosition, dragImage.release(), isLinkDrag);
+}
+
+void WebPageProxy::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::PerformDictionaryLookupAtLocation(point), m_pageID);
+}
+
+void WebPageProxy::interpretQueuedKeyEvent(const EditorState& state, bool& handled, Vector<WebCore::KeypressCommand>& commands)
+{
+ m_editorState = state;
+ handled = m_pageClient->interpretKeyEvent(m_keyEventQueue.first(), commands);
+}
+
+// Complex text input support for plug-ins.
+void WebPageProxy::sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SendComplexTextInputToPlugin(pluginComplexTextInputIdentifier, textInput), m_pageID);
+}
+
+void WebPageProxy::uppercaseWord()
+{
+ process()->send(Messages::WebPage::UppercaseWord(), m_pageID);
+}
+
+void WebPageProxy::lowercaseWord()
+{
+ process()->send(Messages::WebPage::LowercaseWord(), m_pageID);
+}
+
+void WebPageProxy::capitalizeWord()
+{
+ process()->send(Messages::WebPage::CapitalizeWord(), m_pageID);
+}
+
+void WebPageProxy::setSmartInsertDeleteEnabled(bool isSmartInsertDeleteEnabled)
+{
+ if (m_isSmartInsertDeleteEnabled == isSmartInsertDeleteEnabled)
+ return;
+
+ TextChecker::setSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled);
+ m_isSmartInsertDeleteEnabled = isSmartInsertDeleteEnabled;
+ process()->send(Messages::WebPage::SetSmartInsertDeleteEnabled(isSmartInsertDeleteEnabled), m_pageID);
+}
+
+void WebPageProxy::didPerformDictionaryLookup(const String& text, const DictionaryPopupInfo& dictionaryPopupInfo)
+{
+ m_pageClient->didPerformDictionaryLookup(text, m_pageScaleFactor, dictionaryPopupInfo);
+}
+
+void WebPageProxy::registerWebProcessAccessibilityToken(const CoreIPC::DataReference& data)
+{
+ m_pageClient->accessibilityWebProcessTokenReceived(data);
+}
+
+void WebPageProxy::makeFirstResponder()
+{
+ m_pageClient->makeFirstResponder();
+}
+
+void WebPageProxy::registerUIProcessAccessibilityTokens(const CoreIPC::DataReference& elementToken, const CoreIPC::DataReference& windowToken)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::RegisterUIProcessAccessibilityTokens(elementToken, windowToken), m_pageID);
+}
+
+void WebPageProxy::pluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
+{
+ m_pageClient->pluginFocusOrWindowFocusChanged(pluginComplexTextInputIdentifier, pluginHasFocusAndWindowHasFocus);
+}
+
+void WebPageProxy::setPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t pluginComplexTextInputState)
+{
+ MESSAGE_CHECK(isValidPluginComplexTextInputState(pluginComplexTextInputState));
+
+ m_pageClient->setPluginComplexTextInputState(pluginComplexTextInputIdentifier, static_cast<PluginComplexTextInputState>(pluginComplexTextInputState));
+}
+
+void WebPageProxy::executeSavedCommandBySelector(const String& selector, bool& handled)
+{
+ handled = m_pageClient->executeSavedCommandBySelector(selector);
+}
+
+bool WebPageProxy::shouldDelayWindowOrderingForEvent(const WebKit::WebMouseEvent& event)
+{
+ if (!process()->isValid())
+ return false;
+
+ bool result = false;
+ const double messageTimeout = 3;
+ process()->sendSync(Messages::WebPage::ShouldDelayWindowOrderingEvent(event), Messages::WebPage::ShouldDelayWindowOrderingEvent::Reply(result), m_pageID, messageTimeout);
+ return result;
+}
+
+bool WebPageProxy::acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent& event)
+{
+ if (!isValid())
+ return false;
+
+ bool result = false;
+ const double messageTimeout = 3;
+ process()->sendSync(Messages::WebPage::AcceptsFirstMouse(eventNumber, event), Messages::WebPage::AcceptsFirstMouse::Reply(result), m_pageID, messageTimeout);
+ return result;
+}
+
+WKView* WebPageProxy::wkView() const
+{
+ return m_pageClient->wkView();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
new file mode 100644
index 000000000..ad22e0a81
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
@@ -0,0 +1,61 @@
+/*
+ * 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 WebPopupMenuProxyMac_h
+#define WebPopupMenuProxyMac_h
+
+#include "WebPopupMenuProxy.h"
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS NSPopUpButtonCell;
+OBJC_CLASS WKView;
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebPopupMenuProxyMac : public WebPopupMenuProxy {
+public:
+ static PassRefPtr<WebPopupMenuProxyMac> create(WKView *webView, WebPopupMenuProxy::Client* client)
+ {
+ return adoptRef(new WebPopupMenuProxyMac(webView, client));
+ }
+ ~WebPopupMenuProxyMac();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+private:
+ WebPopupMenuProxyMac(WKView *, WebPopupMenuProxy::Client*);
+
+ void populate(const Vector<WebPopupItem>&, NSFont *, WebCore::TextDirection);
+
+ RetainPtr<NSPopUpButtonCell> m_popup;
+ WKView *m_webView;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyMac_h
diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
new file mode 100644
index 000000000..30e2e2087
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
@@ -0,0 +1,177 @@
+/*
+ * 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 "WebPopupMenuProxyMac.h"
+
+#import "NativeWebMouseEvent.h"
+#import "PageClientImpl.h"
+#import "PlatformPopupMenuData.h"
+#import "WKView.h"
+#import "WebPopupItem.h"
+#import <WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyMac::WebPopupMenuProxyMac(WKView *webView, WebPopupMenuProxy::Client* client)
+ : WebPopupMenuProxy(client)
+ , m_webView(webView)
+{
+}
+
+WebPopupMenuProxyMac::~WebPopupMenuProxyMac()
+{
+ if (m_popup)
+ [m_popup.get() setControlView:nil];
+}
+
+void WebPopupMenuProxyMac::populate(const Vector<WebPopupItem>& items, NSFont *font, TextDirection menuTextDirection)
+{
+ if (m_popup)
+ [m_popup.get() removeAllItems];
+ else {
+ m_popup.adoptNS([[NSPopUpButtonCell alloc] initTextCell:@"" pullsDown:NO]);
+ [m_popup.get() setUsesItemFromMenu:NO];
+ [m_popup.get() setAutoenablesItems:NO];
+ }
+
+ int size = items.size();
+
+ for (int i = 0; i < size; i++) {
+ if (items[i].m_type == WebPopupItem::Separator)
+ [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]];
+ else {
+ [m_popup.get() addItemWithTitle:@""];
+ NSMenuItem *menuItem = [m_popup.get() lastItem];
+
+ RetainPtr<NSMutableParagraphStyle> paragraphStyle(AdoptNS, [[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
+ NSWritingDirection writingDirection = items[i].m_textDirection == LTR ? NSWritingDirectionLeftToRight : NSWritingDirectionRightToLeft;
+ [paragraphStyle.get() setBaseWritingDirection:writingDirection];
+ [paragraphStyle.get() setAlignment:menuTextDirection == LTR ? NSLeftTextAlignment : NSRightTextAlignment];
+ RetainPtr<NSMutableDictionary> attributes(AdoptNS, [[NSMutableDictionary alloc] initWithObjectsAndKeys:
+ paragraphStyle.get(), NSParagraphStyleAttributeName,
+ font, NSFontAttributeName,
+ nil]);
+ if (items[i].m_hasTextDirectionOverride) {
+ RetainPtr<NSNumber> writingDirectionValue(AdoptNS, [[NSNumber alloc] initWithInteger:writingDirection + NSTextWritingDirectionOverride]);
+ RetainPtr<NSArray> writingDirectionArray(AdoptNS, [[NSArray alloc] initWithObjects:writingDirectionValue.get(), nil]);
+ [attributes.get() setObject:writingDirectionArray.get() forKey:NSWritingDirectionAttributeName];
+ }
+ RetainPtr<NSAttributedString> string(AdoptNS, [[NSAttributedString alloc] initWithString:nsStringFromWebCoreString(items[i].m_text) attributes:attributes.get()]);
+
+ [menuItem setAttributedTitle:string.get()];
+ [menuItem setEnabled:items[i].m_isEnabled];
+ [menuItem setToolTip:nsStringFromWebCoreString(items[i].m_toolTip)];
+ }
+ }
+}
+
+void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, TextDirection textDirection, double pageScaleFactor, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
+{
+ NSFont *font;
+ if (data.fontInfo.fontAttributeDictionary) {
+ NSFontDescriptor *fontDescriptor = [NSFontDescriptor fontDescriptorWithFontAttributes:(NSDictionary *)data.fontInfo.fontAttributeDictionary.get()];
+ font = [NSFont fontWithDescriptor:fontDescriptor size:((pageScaleFactor != 1) ? [fontDescriptor pointSize] * pageScaleFactor : 0)];
+ } else
+ font = [NSFont menuFontOfSize:0];
+
+ populate(items, font, textDirection);
+
+ [m_popup.get() attachPopUpWithFrame:rect inView:m_webView];
+ [m_popup.get() selectItemAtIndex:selectedIndex];
+ [m_popup.get() setUserInterfaceLayoutDirection:textDirection == LTR ? NSUserInterfaceLayoutDirectionLeftToRight : NSUserInterfaceLayoutDirectionRightToLeft];
+
+ NSMenu *menu = [m_popup.get() menu];
+
+ // These values were borrowed from AppKit to match their placement of the menu.
+ const int popOverHorizontalAdjust = -10;
+ const int popUnderHorizontalAdjust = 6;
+ const int popUnderVerticalAdjust = 6;
+
+ // Menus that pop-over directly obscure the node that generated the popup menu.
+ // Menus that pop-under are offset underneath it.
+ NSPoint location;
+ if (data.shouldPopOver) {
+ NSRect titleFrame = [m_popup.get() titleRectForBounds:rect];
+ if (titleFrame.size.width <= 0 || titleFrame.size.height <= 0)
+ titleFrame = rect;
+ float vertOffset = roundf((NSMaxY(rect) - NSMaxY(titleFrame)) + NSHeight(titleFrame));
+ location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset);
+ } else
+ location = NSMakePoint(NSMinX(rect) + popUnderHorizontalAdjust, NSMaxY(rect) + popUnderVerticalAdjust);
+
+ RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:rect]);
+ [m_webView addSubview:dummyView.get()];
+ location = [dummyView.get() convertPoint:location fromView:m_webView];
+
+ WKPopupMenu(menu, location, roundf(NSWidth(rect)), dummyView.get(), selectedIndex, font);
+
+ [m_popup.get() dismissPopUp];
+ [dummyView.get() removeFromSuperview];
+
+ if (!m_client)
+ return;
+
+ m_client->valueChangedForPopupMenu(this, [m_popup.get() indexOfSelectedItem]);
+
+ // <https://bugs.webkit.org/show_bug.cgi?id=57904> This code is adopted from EventHandler::sendFakeEventsAfterWidgetTracking().
+ if (!m_client->currentlyProcessedMouseDownEvent())
+ return;
+
+ NSEvent* initiatingNSEvent = m_client->currentlyProcessedMouseDownEvent()->nativeEvent();
+ if ([initiatingNSEvent type] != NSLeftMouseDown)
+ return;
+
+ NSEvent *fakeEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
+ location:[initiatingNSEvent locationInWindow]
+ modifierFlags:[initiatingNSEvent modifierFlags]
+ timestamp:[initiatingNSEvent timestamp]
+ windowNumber:[initiatingNSEvent windowNumber]
+ context:[initiatingNSEvent context]
+ eventNumber:[initiatingNSEvent eventNumber]
+ clickCount:[initiatingNSEvent clickCount]
+ pressure:[initiatingNSEvent pressure]];
+
+ [NSApp postEvent:fakeEvent atStart:YES];
+ fakeEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:[[m_webView window] convertScreenToBase:[NSEvent mouseLocation]]
+ modifierFlags:[initiatingNSEvent modifierFlags]
+ timestamp:[initiatingNSEvent timestamp]
+ windowNumber:[initiatingNSEvent windowNumber]
+ context:[initiatingNSEvent context]
+ eventNumber:0
+ clickCount:0
+ pressure:0];
+ [NSApp postEvent:fakeEvent atStart:YES];
+}
+
+void WebPopupMenuProxyMac::hidePopupMenu()
+{
+ [m_popup.get() dismissPopUp];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm b/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm
new file mode 100644
index 000000000..f2f41d331
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm
@@ -0,0 +1,128 @@
+/*
+ * 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 "WebPreferences.h"
+
+#import "PageClientImpl.h"
+#import <wtf/text/StringConcatenate.h>
+
+namespace WebKit {
+
+static inline NSString* makeKey(const String& identifier, const String& baseKey)
+{
+ return nsStringFromWebCoreString(makeString(identifier, ".WebKit2", baseKey));
+}
+
+static void setStringValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+ id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+ if (!object)
+ return;
+ if (![object isKindOfClass:[NSString class]])
+ return;
+
+ store.setStringValueForKey(key, (NSString *)object);
+}
+
+static void setBoolValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+ id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+ if (!object)
+ return;
+ if (![object respondsToSelector:@selector(boolValue)])
+ return;
+
+ store.setBoolValueForKey(key, [object boolValue]);
+}
+
+static void setUInt32ValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+ id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+ if (!object)
+ return;
+ if (![object respondsToSelector:@selector(intValue)])
+ return;
+
+ store.setUInt32ValueForKey(key, [object intValue]);
+}
+
+static void setDoubleValueIfInUserDefaults(const String& identifier, const String& key, WebPreferencesStore& store)
+{
+ id object = [[NSUserDefaults standardUserDefaults] objectForKey:makeKey(identifier, key)];
+ if (!object)
+ return;
+ if (![object respondsToSelector:@selector(doubleValue)])
+ return;
+
+ store.setDoubleValueForKey(key, [object doubleValue]);
+}
+
+void WebPreferences::platformInitializeStore()
+{
+ if (!m_identifier)
+ return;
+
+#define INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS(KeyUpper, KeyLower, TypeName, Type, DefaultValue) \
+ set##TypeName##ValueIfInUserDefaults(m_identifier, WebPreferencesKey::KeyLower##Key(), m_store);
+
+ FOR_EACH_WEBKIT_PREFERENCE(INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS)
+
+#undef INITIALIZE_PREFERENCE_FROM_NSUSERDEFAULTS
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String& key, const String& value)
+{
+ if (!m_identifier)
+ return;
+
+ [[NSUserDefaults standardUserDefaults] setObject:nsStringFromWebCoreString(value) forKey:makeKey(m_identifier, key)];
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String& key, bool value)
+{
+ if (!m_identifier)
+ return;
+
+ [[NSUserDefaults standardUserDefaults] setBool:value forKey:makeKey(m_identifier, key)];
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String& key, uint32_t value)
+{
+ if (!m_identifier)
+ return;
+
+ [[NSUserDefaults standardUserDefaults] setInteger:value forKey:makeKey(m_identifier, key)];
+}
+
+void WebPreferences::platformUpdateDoubleValueForKey(const String& key, double value)
+{
+ if (!m_identifier)
+ return;
+
+ [[NSUserDefaults standardUserDefaults] setDouble:value forKey:makeKey(m_identifier, key)];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm
new file mode 100644
index 000000000..467155e92
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebProcessProxyMac.mm
@@ -0,0 +1,116 @@
+/*
+ * 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 "WebProcessProxy.h"
+
+#import "SecItemRequestData.h"
+#import "SecItemResponseData.h"
+#import "SecKeychainItemRequestData.h"
+#import "SecKeychainItemResponseData.h"
+#import "WKFullKeyboardAccessWatcher.h"
+#import <Security/SecItem.h>
+
+namespace WebKit {
+
+void WebProcessProxy::secItemCopyMatching(const SecItemRequestData& queryData, SecItemResponseData& result)
+{
+ CFDictionaryRef query = queryData.query();
+ CFTypeRef resultObjectRef;
+ OSStatus resultCode = SecItemCopyMatching(query, &resultObjectRef);
+
+ RetainPtr<CFTypeRef> resultObject(AdoptCF, resultObjectRef);
+ result = SecItemResponseData(resultCode, resultObject.get());
+}
+
+void WebProcessProxy::secItemAdd(const SecItemRequestData& queryData, SecItemResponseData& result)
+{
+ CFDictionaryRef query = queryData.query();
+ CFTypeRef resultObjectRef;
+ OSStatus resultCode = SecItemAdd(query, &resultObjectRef);
+
+ RetainPtr<CFTypeRef> resultObject(AdoptCF, resultObjectRef);
+ result = SecItemResponseData(resultCode, resultObject.get());
+}
+
+void WebProcessProxy::secItemUpdate(const SecItemRequestData& queryData, SecItemResponseData& result)
+{
+ CFDictionaryRef query = queryData.query();
+ CFDictionaryRef attributesToMatch = queryData.attributesToMatch();
+ OSStatus resultCode;
+
+ resultCode = SecItemUpdate(query, attributesToMatch);
+
+ result = SecItemResponseData(resultCode, 0);
+}
+
+void WebProcessProxy::secItemDelete(const SecItemRequestData& queryData, SecItemResponseData& result)
+{
+ CFDictionaryRef query = queryData.query();
+ OSStatus resultCode;
+
+ resultCode = SecItemDelete(query);
+
+ result = SecItemResponseData(resultCode, 0);
+}
+
+void WebProcessProxy::secKeychainItemCopyContent(const SecKeychainItemRequestData& request, SecKeychainItemResponseData& response)
+{
+ SecKeychainItemRef item = request.keychainItem();
+ SecItemClass itemClass;
+ SecKeychainAttributeList* attrList = request.attributeList();
+ UInt32 length = 0;
+ void* outData = 0;
+
+ OSStatus resultCode = SecKeychainItemCopyContent(item, &itemClass, attrList, &length, &outData);
+
+ RetainPtr<CFDataRef> data(AdoptCF, CFDataCreate(0, static_cast<const UInt8*>(outData), length));
+ response = SecKeychainItemResponseData(resultCode, itemClass, attrList, data.get());
+
+ SecKeychainItemFreeContent(attrList, outData);
+}
+
+void WebProcessProxy::secKeychainItemCreateFromContent(const SecKeychainItemRequestData& request, SecKeychainItemResponseData& response)
+{
+ SecKeychainItemRef keychainItem;
+
+ OSStatus resultCode = SecKeychainItemCreateFromContent(request.itemClass(), request.attributeList(), request.length(), request.data(), 0, 0, &keychainItem);
+
+ response = SecKeychainItemResponseData(resultCode, RetainPtr<SecKeychainItemRef>(AdoptCF, keychainItem));
+}
+
+void WebProcessProxy::secKeychainItemModifyContent(const SecKeychainItemRequestData& request, SecKeychainItemResponseData& response)
+{
+ OSStatus resultCode = SecKeychainItemModifyContent(request.keychainItem(), request.attributeList(), request.length(), request.data());
+
+ response = resultCode;
+}
+
+bool WebProcessProxy::fullKeyboardAccessEnabled()
+{
+ return [WKFullKeyboardAccessWatcher fullKeyboardAccessEnabled];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/BackingStoreQt.cpp b/Source/WebKit2/UIProcess/qt/BackingStoreQt.cpp
new file mode 100644
index 000000000..1af16d842
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/BackingStoreQt.cpp
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Andreas Kling <kling@webkit.org>
+ *
+ * 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 "BackingStore.h"
+
+#include "UpdateInfo.h"
+#include "ShareableBitmap.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntRect.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void BackingStore::paint(QPainter* painter, const IntRect& rect)
+{
+ ASSERT(!m_pixmap.isNull());
+ painter->drawPixmap(rect, m_pixmap, rect);
+}
+
+void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
+{
+ if (m_pixmap.isNull())
+ m_pixmap = QPixmap(m_size);
+
+ scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
+
+ IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+
+ QPainter painter(&m_pixmap);
+ GraphicsContext graphicsContext(&painter);
+
+ // Paint all update rects.
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
+ IntRect updateRect = updateInfo.updateRects[i];
+ IntRect srcRect = updateRect;
+ srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
+ bitmap->paint(graphicsContext, updateRect.location(), srcRect);
+ }
+}
+
+void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ if (scrollOffset.isZero())
+ return;
+
+ m_pixmap.scroll(scrollOffset.width(), scrollOffset.height(), scrollRect);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
new file mode 100644
index 000000000..a1dd272a7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
@@ -0,0 +1,635 @@
+/*
+ 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"
+
+#if USE(ACCELERATED_COMPOSITING)
+#include "LayerTreeHostProxy.h"
+
+#include "LayerTreeHostMessages.h"
+#include "MainThread.h"
+#include "MessageID.h"
+#include "ShareableBitmap.h"
+#include "TextureMapperGL.h"
+#include "UpdateInfo.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebLayerTreeInfo.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include "texmap/GraphicsLayerTextureMapper.h"
+#include "texmap/TextureMapper.h"
+#include "texmap/TextureMapperNode.h"
+#include <QDateTime>
+#include <cairo/OpenGLShims.h>
+
+namespace WebKit {
+
+class LayerTreeMessageToRenderer {
+public:
+ enum Type {
+ DeleteLayer,
+ CreateTile,
+ RemoveTile,
+ UpdateTile,
+ CreateImage,
+ DestroyImage,
+ SyncLayerParameters,
+ FlushLayerChanges,
+ SetRootLayer
+ };
+ virtual ~LayerTreeMessageToRenderer() { }
+ virtual Type type() const = 0;
+};
+
+template<class MessageData, LayerTreeMessageToRenderer::Type messageType>
+class LayerTreeMessageToRendererWithData : public LayerTreeMessageToRenderer {
+public:
+ virtual Type type() const { return messageType; }
+
+ static PassOwnPtr<LayerTreeMessageToRenderer> create(const MessageData& data = MessageData())
+ {
+ return adoptPtr(new LayerTreeMessageToRendererWithData(data));
+ }
+
+ const MessageData& data() const
+ {
+ return m_data;
+ }
+
+private:
+ LayerTreeMessageToRendererWithData(const MessageData& data)
+ : m_data(data)
+ {
+ }
+
+ MessageData m_data;
+};
+
+
+namespace {
+struct CreateTileMessageData {
+ WebLayerID layerID;
+ int remoteTileID;
+ float scale;
+};
+
+struct UpdateTileMessageData {
+ WebLayerID layerID;
+ int remoteTileID;
+ IntRect sourceRect;
+ IntRect targetRect;
+ QImage image;
+};
+
+struct RemoveTileMessageData {
+ WebLayerID layerID;
+ int remoteTileID;
+};
+
+struct CreateImageMessageData {
+ int64_t imageID;
+ QImage image;
+};
+
+struct DestroyImageMessageData {
+ int64_t imageID;
+};
+
+struct SyncLayerParametersMessageData {
+ WebLayerInfo layerInfo;
+};
+
+struct EmptyMessageData { };
+struct DeleteLayerMessageData {
+ WebLayerID layerID;
+};
+struct SetRootLayerMessageData {
+ WebLayerID layerID;
+};
+
+class CreateTileMessage
+ : public LayerTreeMessageToRendererWithData<CreateTileMessageData, LayerTreeMessageToRenderer::CreateTile> { };
+class UpdateTileMessage
+ : public LayerTreeMessageToRendererWithData<UpdateTileMessageData, LayerTreeMessageToRenderer::UpdateTile> { };
+class RemoveTileMessage
+ : public LayerTreeMessageToRendererWithData<RemoveTileMessageData, LayerTreeMessageToRenderer::RemoveTile> { };
+class CreateImageMessage
+ : public LayerTreeMessageToRendererWithData<CreateImageMessageData, LayerTreeMessageToRenderer::CreateImage> { };
+class DestroyImageMessage
+ : public LayerTreeMessageToRendererWithData<DestroyImageMessageData, LayerTreeMessageToRenderer::DestroyImage> { };
+class FlushLayerChangesMessage
+ : public LayerTreeMessageToRendererWithData<EmptyMessageData, LayerTreeMessageToRenderer::FlushLayerChanges> { };
+class SyncLayerParametersMessage
+ : public LayerTreeMessageToRendererWithData<SyncLayerParametersMessageData, LayerTreeMessageToRenderer::SyncLayerParameters> { };
+class DeleteLayerMessage
+ : public LayerTreeMessageToRendererWithData<DeleteLayerMessageData, LayerTreeMessageToRenderer::DeleteLayer> { };
+class SetRootLayerMessage
+ : public LayerTreeMessageToRendererWithData<SetRootLayerMessageData, LayerTreeMessageToRenderer::SetRootLayer> { };
+}
+
+PassOwnPtr<GraphicsLayer> LayerTreeHostProxy::createLayer(WebLayerID layerID)
+{
+ GraphicsLayer* newLayer = new GraphicsLayerTextureMapper(this);
+ TextureMapperNode* node = toTextureMapperNode(newLayer);
+ node->setID(layerID);
+ node->setTileOwnership(TextureMapperNode::ExternallyManagedTiles);
+ return adoptPtr(newLayer);
+}
+
+LayerTreeHostProxy::LayerTreeHostProxy(DrawingAreaProxy* drawingAreaProxy)
+ : m_animationTimer(RunLoop::main(), this, &LayerTreeHostProxy::updateViewport)
+ , m_drawingAreaProxy(drawingAreaProxy)
+ , m_viewportUpdateTimer(this, &LayerTreeHostProxy::didFireViewportUpdateTimer)
+ , m_rootLayerID(0)
+{
+}
+
+LayerTreeHostProxy::~LayerTreeHostProxy()
+{
+}
+
+// This function needs to be reentrant.
+void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity)
+{
+ if (!m_textureMapper)
+ m_textureMapper = TextureMapperGL::create();
+
+ syncRemoteContent();
+ GraphicsLayer* currentRootLayer = rootLayer();
+ if (!currentRootLayer)
+ return;
+
+ TextureMapperNode* node = toTextureMapperNode(currentRootLayer);
+
+ if (!node)
+ return;
+
+ GLint viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
+ IntRect viewportRect(viewport[0], viewport[1], viewport[2], viewport[3]);
+ m_textureMapper->setViewportSize(IntSize(viewport[2], viewport[3]));
+ node->setTextureMapper(m_textureMapper.get());
+ m_textureMapper->beginPainting();
+ m_textureMapper->bindSurface(0);
+
+ if (currentRootLayer->opacity() != opacity || currentRootLayer->transform() != matrix) {
+ currentRootLayer->setOpacity(opacity);
+ currentRootLayer->setTransform(matrix);
+ currentRootLayer->syncCompositingStateForThisLayerOnly();
+ }
+
+ TextureMapperNode::NodeRectMap nodeVisualContentsRectMap;
+ if (node->collectVisibleContentsRects(nodeVisualContentsRectMap, viewportRect)) {
+ TextureMapperNode::NodeRectMap::iterator endIterator = nodeVisualContentsRectMap.end();
+ for (TextureMapperNode::NodeRectMap::iterator it = nodeVisualContentsRectMap.begin(); it != endIterator; ++it) {
+ WebLayerID layerID = it->first->id();
+ // avoid updating non-synced root layer
+ if (!layerID)
+ continue;
+ IntRect visibleRect = IntRect(it->second);
+ setVisibleContentsRectForLayer(layerID, visibleRect);
+ }
+ }
+ node->paint();
+
+ m_textureMapper->endPainting();
+
+ if (node->descendantsOrSelfHaveRunningAnimations()) {
+ node->syncAnimationsRecursively();
+ m_viewportUpdateTimer.startOneShot(0);
+ }
+}
+
+void LayerTreeHostProxy::didFireViewportUpdateTimer(Timer<LayerTreeHostProxy>*)
+{
+ updateViewport();
+}
+
+void LayerTreeHostProxy::updateViewport()
+{
+ m_drawingAreaProxy->updateViewport();
+}
+
+void LayerTreeHostProxy::setVisibleContentsRectForLayer(WebLayerID layerID, const IntRect& rect)
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectForLayer(layerID, rect), m_drawingAreaProxy->page()->pageID());
+}
+
+int LayerTreeHostProxy::remoteTileIDToNodeTileID(int tileID) const
+{
+ HashMap<int, int>::const_iterator it = m_tileToNodeTile.find(tileID);
+ if (it == m_tileToNodeTile.end())
+ return 0;
+ return it->second;
+}
+
+void LayerTreeHostProxy::syncLayerParameters(const WebLayerInfo& layerInfo)
+{
+ WebLayerID id = layerInfo.id;
+ ensureLayer(id);
+ LayerMap::iterator it = m_layers.find(id);
+ GraphicsLayer* layer = it->second;
+
+ layer->setName(layerInfo.name);
+
+ layer->setReplicatedByLayer(layerByID(layerInfo.replica));
+ layer->setMaskLayer(layerByID(layerInfo.mask));
+
+ layer->setPosition(layerInfo.pos);
+ layer->setSize(layerInfo.size);
+ layer->setTransform(layerInfo.transform);
+ layer->setAnchorPoint(layerInfo.anchorPoint);
+ layer->setChildrenTransform(layerInfo.childrenTransform);
+ layer->setBackfaceVisibility(layerInfo.backfaceVisible);
+ layer->setContentsOpaque(layerInfo.contentsOpaque);
+ layer->setContentsRect(layerInfo.contentsRect);
+ layer->setDrawsContent(layerInfo.drawsContent);
+
+ if (layerInfo.imageIsUpdated)
+ assignImageToLayer(layer, layerInfo.imageBackingStoreID);
+
+ // Never make the root layer clip.
+ layer->setMasksToBounds(layerInfo.isRootLayer ? false : layerInfo.masksToBounds);
+ layer->setOpacity(layerInfo.opacity);
+ layer->setPreserves3D(layerInfo.preserves3D);
+ Vector<GraphicsLayer*> children;
+
+ for (size_t i = 0; i < layerInfo.children.size(); ++i) {
+ WebLayerID childID = layerInfo.children[i];
+ GraphicsLayer* child = layerByID(childID);
+ if (!child) {
+ child = createLayer(childID).leakPtr();
+ m_layers.add(childID, child);
+ }
+ children.append(child);
+ }
+ layer->setChildren(children);
+
+ for (size_t i = 0; i < layerInfo.animations.size(); ++i) {
+ const WebKit::WebLayerAnimation anim = layerInfo.animations[i];
+
+ switch (anim.operation) {
+ case WebKit::WebLayerAnimation::AddAnimation: {
+ const IntSize boxSize = anim.boxSize;
+ layer->addAnimation(anim.keyframeList, boxSize, anim.animation.get(), anim.name, anim.startTime);
+ break;
+ }
+ case WebKit::WebLayerAnimation::RemoveAnimation:
+ layer->removeAnimation(anim.name);
+ break;
+ case WebKit::WebLayerAnimation::PauseAnimation:
+ double offset = WTF::currentTime() - anim.startTime;
+ layer->pauseAnimation(anim.name, offset);
+ break;
+ }
+ }
+
+ if (layerInfo.isRootLayer && m_rootLayerID != id)
+ setRootLayerID(id);
+}
+
+void LayerTreeHostProxy::deleteLayer(WebLayerID layerID)
+{
+ GraphicsLayer* layer = layerByID(layerID);
+ if (!layer)
+ return;
+
+ layer->removeFromParent();
+ m_layers.remove(layerID);
+ delete layer;
+}
+
+
+void LayerTreeHostProxy::ensureLayer(WebLayerID id)
+{
+ // We have to leak the new layer's pointer and manage it ourselves,
+ // because OwnPtr is not copyable.
+ if (m_layers.find(id) == m_layers.end())
+ m_layers.add(id, createLayer(id).leakPtr());
+}
+
+void LayerTreeHostProxy::setRootLayerID(WebLayerID layerID)
+{
+ if (layerID == m_rootLayerID)
+ return;
+
+ m_rootLayerID = layerID;
+
+ m_rootLayer->removeAllChildren();
+
+ if (!layerID)
+ return;
+
+ GraphicsLayer* layer = layerByID(layerID);
+ if (!layer)
+ return;
+
+ m_rootLayer->addChild(layer);
+}
+
+void LayerTreeHostProxy::createTile(WebLayerID layerID, int tileID, float scale)
+{
+ ensureLayer(layerID);
+ TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
+
+ int nodeTileID = node->createContentsTile(scale);
+ m_tileToNodeTile.add(tileID, nodeTileID);
+}
+
+void LayerTreeHostProxy::removeTile(WebLayerID layerID, int tileID)
+{
+ TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
+ if (!node)
+ return;
+
+ int nodeTileID = remoteTileIDToNodeTileID(tileID);
+ if (!nodeTileID)
+ return;
+
+ node->removeContentsTile(nodeTileID);
+ m_tileToNodeTile.remove(tileID);
+}
+
+void LayerTreeHostProxy::updateTile(WebLayerID layerID, int tileID, const IntRect& sourceRect, const IntRect& targetRect, const QImage& image)
+{
+ ensureLayer(layerID);
+ TextureMapperNode* node = toTextureMapperNode(layerByID(layerID));
+ if (!node)
+ return;
+
+ int nodeTileID = remoteTileIDToNodeTileID(tileID);
+ if (!nodeTileID)
+ return;
+
+ QImage imageRef(image);
+ node->setTextureMapper(m_textureMapper.get());
+ node->setContentsTileBackBuffer(nodeTileID, sourceRect, targetRect, imageRef.bits(), BitmapTexture::BGRAFormat);
+}
+
+void LayerTreeHostProxy::createImage(int64_t imageID, const QImage& image)
+{
+ TiledImage tiledImage;
+ static const int TileDimension = 1024;
+ bool imageHasAlpha = image.hasAlphaChannel();
+ IntRect imageRect(0, 0, image.width(), image.height());
+ for (int y = 0; y < image.height(); y += TileDimension) {
+ for (int x = 0; x < image.width(); x += TileDimension) {
+ QImage subImage;
+ IntRect rect(x, y, TileDimension, TileDimension);
+ rect.intersect(imageRect);
+ if (QSize(rect.size()) == image.size())
+ subImage = image;
+ else
+ subImage = image.copy(rect);
+ RefPtr<BitmapTexture> texture = m_textureMapper->createTexture();
+ texture->reset(rect.size(), !imageHasAlpha);
+ texture->updateContents(imageHasAlpha ? BitmapTexture::BGRAFormat : BitmapTexture::BGRFormat, IntRect(IntPoint::zero(), rect.size()), subImage.bits());
+ tiledImage.add(rect.location(), texture);
+ }
+ }
+
+ m_directlyCompositedImages.remove(imageID);
+ m_directlyCompositedImages.add(imageID, tiledImage);
+}
+
+void LayerTreeHostProxy::destroyImage(int64_t imageID)
+{
+ m_directlyCompositedImages.remove(imageID);
+}
+
+void LayerTreeHostProxy::assignImageToLayer(GraphicsLayer* layer, int64_t imageID)
+{
+ TextureMapperNode* node = toTextureMapperNode(layer);
+ if (!node)
+ return;
+
+ if (!imageID) {
+ node->clearAllDirectlyCompositedImageTiles();
+ return;
+ }
+
+ FloatSize size(layer->size());
+ FloatRect contentsRect(layer->contentsRect());
+ float horizontalFactor = contentsRect.width() / size.width();
+ float verticalFactor = contentsRect.height() / size.height();
+ HashMap<int64_t, TiledImage>::iterator it = m_directlyCompositedImages.find(imageID);
+ if (it == m_directlyCompositedImages.end())
+ return;
+
+ TiledImage::iterator endTileIterator = it->second.end();
+ for (TiledImage::iterator tileIt = it->second.begin(); tileIt != endTileIterator; ++tileIt) {
+ FloatRect sourceRect(FloatPoint(tileIt->first), FloatSize(tileIt->second->size()));
+ FloatRect targetRect(sourceRect.x() * horizontalFactor + contentsRect.x(),
+ sourceRect.y() * verticalFactor + contentsRect.y(),
+ sourceRect.width() * horizontalFactor,
+ sourceRect.height() * verticalFactor);
+ int newTileID = node->createContentsTile(1.0);
+ node->setTileBackBufferTextureForDirectlyCompositedImage(newTileID, IntRect(sourceRect), targetRect, tileIt->second.get());
+ }
+}
+
+void LayerTreeHostProxy::flushLayerChanges()
+{
+ m_rootLayer->syncCompositingState(FloatRect());
+}
+
+void LayerTreeHostProxy::ensureRootLayer()
+{
+ if (m_rootLayer)
+ return;
+ m_rootLayer = createLayer(InvalidWebLayerID);
+ m_rootLayer->setMasksToBounds(false);
+ m_rootLayer->setDrawsContent(false);
+ m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));
+
+ // The root layer should not have zero size, or it would be optimized out.
+ m_rootLayer->setSize(FloatSize(1.0, 1.0));
+ m_textureMapper = TextureMapperGL::create();
+ toTextureMapperNode(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
+}
+
+void LayerTreeHostProxy::syncRemoteContent()
+{
+ // We enqueue messages and execute them during paint, as they require an active GL context.
+ ensureRootLayer();
+
+ while (OwnPtr<LayerTreeMessageToRenderer> nextMessage = m_messagesToRenderer.tryGetMessage()) {
+ switch (nextMessage->type()) {
+ case LayerTreeMessageToRenderer::SetRootLayer: {
+ const SetRootLayerMessageData& data = static_cast<SetRootLayerMessage*>(nextMessage.get())->data();
+ setRootLayerID(data.layerID);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::DeleteLayer: {
+ const DeleteLayerMessageData& data = static_cast<DeleteLayerMessage*>(nextMessage.get())->data();
+ deleteLayer(data.layerID);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::SyncLayerParameters: {
+ const SyncLayerParametersMessageData& data = static_cast<SyncLayerParametersMessage*>(nextMessage.get())->data();
+ syncLayerParameters(data.layerInfo);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::CreateTile: {
+ const CreateTileMessageData& data = static_cast<CreateTileMessage*>(nextMessage.get())->data();
+ createTile(data.layerID, data.remoteTileID, data.scale);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::RemoveTile: {
+ const RemoveTileMessageData& data = static_cast<RemoveTileMessage*>(nextMessage.get())->data();
+ removeTile(data.layerID, data.remoteTileID);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::UpdateTile: {
+ const UpdateTileMessageData& data = static_cast<UpdateTileMessage*>(nextMessage.get())->data();
+ updateTile(data.layerID, data.remoteTileID, data.sourceRect, data.targetRect, data.image);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::CreateImage: {
+ const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data();
+ createImage(data.imageID, data.image);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::DestroyImage: {
+ const CreateImageMessageData& data = static_cast<CreateImageMessage*>(nextMessage.get())->data();
+ destroyImage(data.imageID);
+ break;
+ }
+
+ case LayerTreeMessageToRenderer::FlushLayerChanges:
+ flushLayerChanges();
+ break;
+ }
+ }
+}
+
+void LayerTreeHostProxy::pushUpdateToQueue(PassOwnPtr<LayerTreeMessageToRenderer> message)
+{
+ m_messagesToRenderer.append(message);
+ updateViewport();
+}
+
+void LayerTreeHostProxy::createTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo& updateInfo)
+{
+ CreateTileMessageData data;
+ data.layerID = layerID;
+ data.remoteTileID = tileID;
+ data.scale = updateInfo.updateScaleFactor;
+ pushUpdateToQueue(CreateTileMessage::create(data));
+ updateTileForLayer(layerID, tileID, updateInfo);
+}
+
+void LayerTreeHostProxy::updateTileForLayer(int layerID, int tileID, const WebKit::UpdateInfo& updateInfo)
+{
+ UpdateTileMessageData data;
+ data.layerID = layerID;
+ data.remoteTileID = tileID;
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
+ data.image = bitmap->createQImage().copy();
+ data.sourceRect = IntRect(IntPoint::zero(), updateInfo.updateRectBounds.size());
+ data.targetRect = updateInfo.updateRectBounds;
+ pushUpdateToQueue(UpdateTileMessage::create(data));
+}
+
+void LayerTreeHostProxy::removeTileForLayer(int layerID, int tileID)
+{
+ RemoveTileMessageData data;
+ data.layerID = layerID;
+ data.remoteTileID = tileID;
+ pushUpdateToQueue(RemoveTileMessage::create(data));
+}
+
+
+void LayerTreeHostProxy::deleteCompositingLayer(WebLayerID id)
+{
+ DeleteLayerMessageData data;
+ data.layerID = id;
+ pushUpdateToQueue(DeleteLayerMessage::create(data));
+}
+
+void LayerTreeHostProxy::setRootCompositingLayer(WebLayerID id)
+{
+ SetRootLayerMessageData data;
+ data.layerID = id;
+ pushUpdateToQueue(SetRootLayerMessage::create(data));
+}
+
+void LayerTreeHostProxy::syncCompositingLayerState(const WebLayerInfo& info)
+{
+ SyncLayerParametersMessageData data;
+ data.layerInfo = info;
+ pushUpdateToQueue(SyncLayerParametersMessage::create(data));
+}
+
+void LayerTreeHostProxy::didRenderFrame()
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
+ pushUpdateToQueue(FlushLayerChangesMessage::create());
+ updateViewport();
+}
+
+void LayerTreeHostProxy::createDirectlyCompositedImage(int64_t key, const WebKit::ShareableBitmap::Handle& handle)
+{
+ CreateImageMessageData data;
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(handle);
+ data.imageID = key;
+ data.image = bitmap->createQImage().copy();
+ pushUpdateToQueue(CreateImageMessage::create(data));
+}
+
+void LayerTreeHostProxy::destroyDirectlyCompositedImage(int64_t key)
+{
+ DestroyImageMessageData data;
+ data.imageID = key;
+ pushUpdateToQueue(DestroyImageMessage::create(data));
+}
+
+void LayerTreeHostProxy::setVisibleContentRectTrajectoryVector(const FloatPoint& trajectoryVector)
+{
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectTrajectoryVector(trajectoryVector), m_drawingAreaProxy->page()->pageID());
+}
+
+void LayerTreeHostProxy::setVisibleContentsRectAndScale(const IntRect& rect, float scale)
+{
+ m_visibleContentsRect = rect;
+ m_contentsScale = scale;
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::SetVisibleContentRectAndScale(rect, scale), m_drawingAreaProxy->page()->pageID());
+}
+
+void LayerTreeHostProxy::purgeGLResources()
+{
+ TextureMapperNode* node = toTextureMapperNode(rootLayer());
+
+ node->purgeNodeTexturesRecursive();
+ m_directlyCompositedImages.clear();
+
+ m_textureMapper.clear();
+
+ m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::PurgeBackingStores(), m_drawingAreaProxy->page()->pageID());
+}
+
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
new file mode 100644
index 000000000..32de21af7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp
@@ -0,0 +1,136 @@
+/*
+ * 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 "QtDialogRunner.h"
+
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtQuick/QQuickItem>
+#include <wtf/PassOwnPtr.h>
+
+QtDialogRunner::QtDialogRunner()
+ : QEventLoop()
+ , m_wasAccepted(false)
+{
+}
+
+QtDialogRunner::~QtDialogRunner()
+{
+}
+
+class DialogContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString message READ message CONSTANT)
+ Q_PROPERTY(QString defaultValue READ defaultValue CONSTANT)
+
+public:
+ DialogContextObject(const QString& message, const QString& defaultValue = QString())
+ : QObject()
+ , m_message(message)
+ , m_defaultValue(defaultValue)
+ {
+ }
+ QString message() const { return m_message; }
+ QString defaultValue() const { return m_defaultValue; }
+
+public slots:
+ void dismiss() { emit dismissed(); }
+ void accept() { emit accepted(); }
+ void accept(const QString& result) { emit accepted(result); }
+ void reject() { emit rejected(); }
+
+signals:
+ void dismissed();
+ void accepted();
+ void accepted(const QString& result);
+ void rejected();
+
+private:
+ QString m_message;
+ QString m_defaultValue;
+};
+
+bool QtDialogRunner::initForAlert(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& message)
+{
+ DialogContextObject* contextObject = new DialogContextObject(message);
+ if (!createDialog(component, dialogParent, contextObject))
+ return false;
+
+ connect(contextObject, SIGNAL(dismissed()), SLOT(quit()));
+ return true;
+}
+
+bool QtDialogRunner::initForConfirm(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& message)
+{
+ DialogContextObject* contextObject = new DialogContextObject(message);
+ if (!createDialog(component, dialogParent, contextObject))
+ return false;
+
+ connect(contextObject, SIGNAL(accepted()), SLOT(onAccepted()));
+ connect(contextObject, SIGNAL(accepted()), SLOT(quit()));
+ connect(contextObject, SIGNAL(rejected()), SLOT(quit()));
+ return true;
+}
+
+bool QtDialogRunner::initForPrompt(QDeclarativeComponent* component, QQuickItem* dialogParent, const QString& message, const QString& defaultValue)
+{
+ DialogContextObject* contextObject = new DialogContextObject(message, defaultValue);
+ if (!createDialog(component, dialogParent, contextObject))
+ return false;
+
+ connect(contextObject, SIGNAL(accepted(QString)), SLOT(onAccepted(QString)));
+ connect(contextObject, SIGNAL(accepted(QString)), SLOT(quit()));
+ connect(contextObject, SIGNAL(rejected()), SLOT(quit()));
+ return true;
+}
+
+bool QtDialogRunner::createDialog(QDeclarativeComponent* component, QQuickItem* dialogParent, QObject* contextObject)
+{
+ QDeclarativeContext* baseContext = component->creationContext();
+ if (!baseContext)
+ baseContext = QDeclarativeEngine::contextForObject(dialogParent);
+ m_dialogContext = adoptPtr(new QDeclarativeContext(baseContext));
+
+ // This makes both "message" and "model.message" work for the dialog, just like QtQuick's ListView delegates.
+ contextObject->setParent(m_dialogContext.get());
+ m_dialogContext->setContextProperty(QLatin1String("model"), contextObject);
+ m_dialogContext->setContextObject(contextObject);
+
+ QObject* object = component->create(m_dialogContext.get());
+ if (!object) {
+ m_dialogContext.clear();
+ return false;
+ }
+
+ m_dialog = adoptPtr(qobject_cast<QQuickItem*>(object));
+ if (!m_dialog) {
+ m_dialogContext.clear();
+ m_dialog.clear();
+ return false;
+ }
+
+ m_dialog->setParentItem(dialogParent);
+ return true;
+}
+
+#include "QtDialogRunner.moc"
+#include "moc_QtDialogRunner.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/QtDialogRunner.h b/Source/WebKit2/UIProcess/qt/QtDialogRunner.h
new file mode 100644
index 000000000..bfa530264
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtDialogRunner.h
@@ -0,0 +1,63 @@
+/*
+ * 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 QtDialogRunner_h
+#define QtDialogRunner_h
+
+#include <QtCore/QEventLoop>
+#include <wtf/OwnPtr.h>
+
+class QDeclarativeComponent;
+class QDeclarativeContext;
+class QQuickItem;
+
+class QtDialogRunner : public QEventLoop {
+ Q_OBJECT
+
+public:
+ QtDialogRunner();
+ virtual ~QtDialogRunner();
+
+ bool initForAlert(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message);
+ bool initForConfirm(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message);
+ bool initForPrompt(QDeclarativeComponent*, QQuickItem* dialogParent, const QString& message, const QString& defaultValue);
+
+ QQuickItem* dialog() const { return m_dialog.get(); }
+
+ bool wasAccepted() const { return m_wasAccepted; }
+ QString result() const { return m_result; }
+
+public slots:
+ void onAccepted(const QString& result = QString())
+ {
+ m_wasAccepted = true;
+ m_result = result;
+ }
+
+private:
+ bool createDialog(QDeclarativeComponent*, QQuickItem* dialogParent, QObject* contextObject);
+
+ OwnPtr<QDeclarativeContext> m_dialogContext;
+ OwnPtr<QQuickItem> m_dialog;
+ QString m_result;
+ bool m_wasAccepted;
+};
+
+#endif // QtDialogRunner_h
diff --git a/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp b/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp
new file mode 100644
index 000000000..99c4dc58e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtDownloadManager.cpp
@@ -0,0 +1,145 @@
+/*
+ * 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 "QtDownloadManager.h"
+
+#include "DownloadProxy.h"
+#include "QtWebError.h"
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include "WebContext.h"
+#include "qwebdownloaditem_p.h"
+#include "qwebdownloaditem_p_p.h"
+
+namespace WebKit {
+
+QtDownloadManager::QtDownloadManager(WebContext* context)
+{
+ WKContextDownloadClient downloadClient;
+ memset(&downloadClient, 0, sizeof(WKContextDownloadClient));
+ downloadClient.version = kWKContextDownloadClientCurrentVersion;
+ downloadClient.clientInfo = this;
+ downloadClient.didReceiveResponse = didReceiveResponse;
+ downloadClient.didReceiveData = didReceiveDataForDownload;
+ downloadClient.didCreateDestination = didCreateDestination;
+ downloadClient.didFinish = didFinishDownload;
+ downloadClient.didFail = didFailDownload;
+ WKContextSetDownloadClient(toAPI(context), &downloadClient);
+}
+
+QtDownloadManager::~QtDownloadManager()
+{
+}
+
+void QtDownloadManager::addDownload(DownloadProxy* download, QWebDownloadItem* downloadItem)
+{
+ m_downloads[download->downloadID()] = downloadItem;
+}
+
+void QtDownloadManager::downloadReceivedResponse(DownloadProxy* download, const WebCore::ResourceResponse& response)
+{
+ // Will be called when the headers are read by WebProcess.
+ QWebDownloadItem* downloadItem = m_downloads.value(download->downloadID());
+ ASSERT(downloadItem);
+
+ downloadItem->d->sourceUrl = response.url();
+ downloadItem->d->mimeType = response.mimeType();
+ downloadItem->d->expectedContentLength = response.expectedContentLength();
+ downloadItem->d->suggestedFilename = response.suggestedFilename();
+
+ downloadItem->d->didReceiveResponse(downloadItem);
+}
+
+void QtDownloadManager::downloadCreatedDestination(DownloadProxy* download, const QString& path)
+{
+ QWebDownloadItem* downloadItem = m_downloads.value(download->downloadID());
+ ASSERT(downloadItem);
+ downloadItem->d->destinationPath = path;
+ emit downloadItem->destinationFileCreated(downloadItem->d->destinationPath);
+}
+
+void QtDownloadManager::downloadFinished(DownloadProxy* download)
+{
+ // Will be called when download finishes with success.
+ QWebDownloadItem* downloadItem = m_downloads.take(download->downloadID());
+ ASSERT(downloadItem);
+ emit downloadItem->succeeded();
+}
+
+void QtDownloadManager::downloadFailed(DownloadProxy* download, const QtWebError& error)
+{
+ // Will be called when download fails or is aborted.
+ QWebDownloadItem* downloadItem = m_downloads.take(download->downloadID());
+ ASSERT(downloadItem);
+
+ // If the parent is null at this point, the download failed before it
+ // received a response and downloadRequested was emitted.
+ // Due to this the item will never be parented and we have to delete it
+ // manually at this point.
+ if (!downloadItem->parent()) {
+ delete downloadItem;
+ return;
+ }
+
+ emit downloadItem->failed(error.errorCodeAsDownloadError(), error.url(), error.description());
+}
+
+void QtDownloadManager::downloadDataReceived(DownloadProxy* download, uint64_t length)
+{
+ // Will be called everytime bytes were written to destination file by WebProcess.
+ QWebDownloadItem* downloadItem = m_downloads.value(download->downloadID());
+ ASSERT(downloadItem);
+ downloadItem->d->totalBytesReceived += length;
+ emit downloadItem->totalBytesReceivedChanged(length);
+}
+
+static inline QtDownloadManager* toQtDownloadManager(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtDownloadManager*>(const_cast<void*>(clientInfo));
+}
+
+void QtDownloadManager::didReceiveResponse(WKContextRef, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo)
+{
+ toQtDownloadManager(clientInfo)->downloadReceivedResponse(toImpl(download), toImpl(response)->resourceResponse());
+}
+
+void QtDownloadManager::didCreateDestination(WKContextRef, WKDownloadRef download, WKStringRef path, const void *clientInfo)
+{
+ toQtDownloadManager(clientInfo)->downloadCreatedDestination(toImpl(download), WKStringCopyQString(path));
+}
+
+void QtDownloadManager::didFinishDownload(WKContextRef, WKDownloadRef download, const void *clientInfo)
+{
+ toQtDownloadManager(clientInfo)->downloadFinished(toImpl(download));
+}
+
+void QtDownloadManager::didFailDownload(WKContextRef, WKDownloadRef download, WKErrorRef error, const void *clientInfo)
+{
+ toQtDownloadManager(clientInfo)->downloadFailed(toImpl(download), QtWebError(error));
+}
+
+void QtDownloadManager::didReceiveDataForDownload(WKContextRef, WKDownloadRef download, uint64_t length, const void *clientInfo)
+{
+ toQtDownloadManager(clientInfo)->downloadDataReceived(toImpl(download), length);
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtDownloadManager.h b/Source/WebKit2/UIProcess/qt/QtDownloadManager.h
new file mode 100644
index 000000000..5e8d5ee43
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtDownloadManager.h
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef QtDownloadManager_h
+#define QtDownloadManager_h
+
+#include <QMap>
+#include <WKContext.h>
+
+class QtWebError;
+class QWebDownloadItem;
+
+namespace WebCore {
+class ResourceResponse;
+}
+
+namespace WebKit {
+
+class DownloadProxy;
+class WebContext;
+
+class QtDownloadManager {
+public:
+ QtDownloadManager(WebContext*);
+ ~QtDownloadManager();
+
+ void addDownload(DownloadProxy*, QWebDownloadItem*);
+
+private:
+ void downloadReceivedResponse(DownloadProxy*, const WebCore::ResourceResponse&);
+ void downloadCreatedDestination(DownloadProxy*, const QString& path);
+ void downloadFinished(DownloadProxy*);
+ void downloadFailed(DownloadProxy*, const QtWebError&);
+ void downloadDataReceived(DownloadProxy*, uint64_t length);
+
+ // WKContextDownloadClient callbacks.
+ static void didReceiveResponse(WKContextRef, WKDownloadRef, WKURLResponseRef, const void* clientInfo);
+ static void didCreateDestination(WKContextRef, WKDownloadRef, WKStringRef path, const void* clientInfo);
+ static void didFinishDownload(WKContextRef, WKDownloadRef, const void* clientInfo);
+ static void didFailDownload(WKContextRef, WKDownloadRef, WKErrorRef, const void* clientInfo);
+ static void didReceiveDataForDownload(WKContextRef, WKDownloadRef, uint64_t length, const void* clientInfo);
+
+ QMap<uint64_t, QWebDownloadItem*> m_downloads;
+};
+
+}
+#endif /* QtDownloadManager_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp
new file mode 100644
index 000000000..0c62452c6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 "QtGestureRecognizer.h"
+
+#include "QtWebPageEventHandler.h"
+
+namespace WebKit {
+
+QtGestureRecognizer::QtGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : m_eventHandler(eventHandler)
+ , m_state(NoGesture)
+{
+}
+
+void QtGestureRecognizer::reset()
+{
+ m_state = NoGesture;
+}
+
+QtViewportInteractionEngine* QtGestureRecognizer::interactionEngine()
+{
+ return m_eventHandler->interactionEngine();
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h b/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h
new file mode 100644
index 000000000..4c191f6e2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 QtGestureRecognizer_h
+#define QtGestureRecognizer_h
+
+class QtWebPageEventHandler;
+
+namespace WebKit {
+
+class QtViewportInteractionEngine;
+
+class QtGestureRecognizer {
+public:
+ bool isRecognized() const { return m_state == GestureRecognized; }
+
+protected:
+ QtGestureRecognizer(QtWebPageEventHandler*);
+ void reset();
+
+ QtWebPageEventHandler* m_eventHandler;
+ enum State {
+ NoGesture,
+ GestureRecognitionStarted,
+ GestureRecognized
+ } m_state;
+
+ QtViewportInteractionEngine* interactionEngine();
+};
+
+}
+
+#endif /* QtGestureRecognizer_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.cpp b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
new file mode 100644
index 000000000..b173776d8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPageClient.cpp
@@ -0,0 +1,256 @@
+/*
+ * 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 "QtPageClient.h"
+
+#include "QtWebPageEventHandler.h"
+#include "QtWebUndoController.h"
+#include "WebContextMenuProxyQt.h"
+#include "WebEditCommandProxy.h"
+#include "WebPopupMenuProxyQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <QGuiApplication>
+#include <WebCore/Cursor.h>
+#include <WebCore/DragData.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/NotImplemented.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+QtPageClient::QtPageClient()
+ : m_webView(0)
+ , m_eventHandler(0)
+ , m_undoController(0)
+{
+}
+
+QtPageClient::~QtPageClient()
+{
+}
+
+void QtPageClient::initialize(QQuickWebView* webView, QtWebPageEventHandler* eventHandler, QtWebUndoController* undoController)
+{
+ m_webView = webView;
+ m_eventHandler = eventHandler;
+ m_undoController = undoController;
+}
+
+PassOwnPtr<DrawingAreaProxy> QtPageClient::createDrawingAreaProxy()
+{
+ return QQuickWebViewPrivate::get(m_webView)->createDrawingAreaProxy();
+}
+
+void QtPageClient::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ m_webView->page()->update();
+}
+
+void QtPageClient::pageDidRequestScroll(const IntPoint& pos)
+{
+ QQuickWebViewPrivate::get(m_webView)->pageDidRequestScroll(pos);
+}
+
+void QtPageClient::processDidCrash()
+{
+ QQuickWebViewPrivate::get(m_webView)->processDidCrash();
+}
+
+void QtPageClient::didRelaunchProcess()
+{
+ QQuickWebViewPrivate::get(m_webView)->didRelaunchProcess();
+}
+
+void QtPageClient::didChangeContentsSize(const IntSize& newSize)
+{
+ QQuickWebViewPrivate::get(m_webView)->didChangeContentsSize(newSize);
+}
+
+void QtPageClient::didChangeViewportProperties(const WebCore::ViewportArguments& args)
+{
+ QQuickWebViewPrivate::get(m_webView)->didChangeViewportProperties(args);
+}
+
+void QtPageClient::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ m_eventHandler->startDrag(dragData, dragImage);
+}
+
+void QtPageClient::handleDownloadRequest(DownloadProxy* download)
+{
+ QQuickWebViewPrivate::get(m_webView)->handleDownloadRequest(download);
+}
+
+void QtPageClient::handleApplicationSchemeRequest(PassRefPtr<QtNetworkRequestData> requestData)
+{
+ if (!m_webView || !m_webView->experimental())
+ return;
+ m_webView->experimental()->invokeApplicationSchemeHandler(requestData.get());
+}
+
+void QtPageClient::setCursor(const WebCore::Cursor& cursor)
+{
+ // FIXME: This is a temporary fix until we get cursor support in QML items.
+ QGuiApplication::setOverrideCursor(*cursor.platformCursor());
+}
+
+void QtPageClient::setCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
+{
+ notImplemented();
+}
+
+void QtPageClient::toolTipChanged(const String&, const String& newTooltip)
+{
+ // There is not yet any UI defined for the tooltips for mobile so we ignore the change.
+}
+
+void QtPageClient::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_undoController->registerEditCommand(command, undoOrRedo);
+}
+
+void QtPageClient::clearAllEditCommands()
+{
+ m_undoController->clearAllEditCommands();
+}
+
+bool QtPageClient::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return m_undoController->canUndoRedo(undoOrRedo);
+}
+
+void QtPageClient::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_undoController->executeUndoRedo(undoOrRedo);
+}
+
+FloatRect QtPageClient::convertToDeviceSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+FloatRect QtPageClient::convertToUserSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+IntPoint QtPageClient::screenToWindow(const IntPoint& point)
+{
+ return point;
+}
+
+IntRect QtPageClient::windowToScreen(const IntRect& rect)
+{
+ return rect;
+}
+
+PassRefPtr<WebPopupMenuProxy> QtPageClient::createPopupMenuProxy(WebPageProxy* webPageProxy)
+{
+ return WebPopupMenuProxyQt::create(webPageProxy, m_webView);
+}
+
+PassRefPtr<WebContextMenuProxy> QtPageClient::createContextMenuProxy(WebPageProxy* webPageProxy)
+{
+ return WebContextMenuProxyQt::create(webPageProxy);
+}
+
+void QtPageClient::flashBackingStoreUpdates(const Vector<IntRect>&)
+{
+ notImplemented();
+}
+
+void QtPageClient::didFindZoomableArea(const IntPoint& target, const IntRect& area)
+{
+ ASSERT(m_eventHandler);
+ m_eventHandler->didFindZoomableArea(target, area);
+}
+
+void QtPageClient::focusEditableArea(const IntRect& caret, const IntRect& area)
+{
+ ASSERT(m_eventHandler);
+ m_eventHandler->focusEditableArea(caret, area);
+}
+
+void QtPageClient::didReceiveMessageFromNavigatorQtObject(const String& message)
+{
+ QQuickWebViewPrivate::get(m_webView)->didReceiveMessageFromNavigatorQtObject(message);
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void QtPageClient::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
+{
+ ASSERT(m_eventHandler);
+ m_eventHandler->doneWithTouchEvent(event, wasEventHandled);
+}
+#endif
+
+void QtPageClient::displayView()
+{
+ // FIXME: Implement.
+}
+
+void QtPageClient::scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset)
+{
+ // FIXME: Implement.
+}
+
+WebCore::IntSize QtPageClient::viewSize()
+{
+ return QQuickWebViewPrivate::get(m_webView)->viewSize();
+}
+
+bool QtPageClient::isViewWindowActive()
+{
+ // FIXME: The scene graph does not have the concept of being active or not when this was written.
+ return true;
+}
+
+bool QtPageClient::isViewFocused()
+{
+ if (!m_webView)
+ return false;
+ return m_webView->hasFocus();
+}
+
+bool QtPageClient::isViewVisible()
+{
+ if (!m_webView)
+ return false;
+ return m_webView->isVisible() && m_webView->page()->isVisible();
+}
+
+bool QtPageClient::isViewInWindow()
+{
+ // FIXME: Implement.
+ return true;
+}
+
+void QtPageClient::enterAcceleratedCompositingMode(const LayerTreeContext&)
+{
+ // FIXME: Implement.
+}
+
+void QtPageClient::exitAcceleratedCompositingMode()
+{
+ // FIXME: Implement.
+}
+
diff --git a/Source/WebKit2/UIProcess/qt/QtPageClient.h b/Source/WebKit2/UIProcess/qt/QtPageClient.h
new file mode 100644
index 000000000..a3149b631
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPageClient.h
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef QtPageClient_h
+#define QtPageClient_h
+
+#include "DrawingAreaProxy.h"
+#include "LayerTreeContext.h"
+#include "PageClient.h"
+#include "ShareableBitmap.h"
+#include "ViewportArguments.h"
+
+class QtWebPageEventHandler;
+class QtWebUndoController;
+class QQuickWebView;
+
+using namespace WebKit;
+
+class QtPageClient : public WebKit::PageClient {
+public:
+ QtPageClient();
+ ~QtPageClient();
+
+ void initialize(QQuickWebView*, QtWebPageEventHandler*, QtWebUndoController*);
+
+ // QQuickWebView.
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual void didReceiveMessageFromNavigatorQtObject(const String&);
+ virtual void pageDidRequestScroll(const WebCore::IntPoint&);
+ virtual void didChangeContentsSize(const WebCore::IntSize&);
+ virtual void didChangeViewportProperties(const WebCore::ViewportArguments&);
+ virtual void processDidCrash();
+ virtual void didRelaunchProcess();
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void handleDownloadRequest(DownloadProxy*);
+ virtual void handleApplicationSchemeRequest(PassRefPtr<QtNetworkRequestData>);
+
+ virtual void displayView();
+ virtual void scrollView(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollOffset);
+ virtual bool isViewWindowActive();
+ virtual bool isViewInWindow();
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+#endif // USE(ACCELERATED_COMPOSITING)
+ virtual void pageClosed() { }
+ virtual void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setCursorHiddenUntilMouseMoves(bool);
+ virtual void toolTipChanged(const String&, const String&);
+
+ // QtWebUndoController
+ 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 didCommitLoadForMainFrame(bool useCustomRepresentation) { }
+ virtual void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&) { }
+ virtual double customRepresentationZoomFactor() { return 1; }
+ virtual void setCustomRepresentationZoomFactor(double) { }
+ virtual void didChangeScrollbarsForMainFrame() const { }
+ virtual void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+ virtual void findStringInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
+ virtual void countStringMatchesInCustomRepresentation(const String&, WebKit::FindOptions, unsigned maxMatchCount) { }
+ virtual void didFindZoomableArea(const WebCore::IntPoint&, const WebCore::IntRect&);
+ virtual void focusEditableArea(const WebCore::IntRect&, const WebCore::IntRect&);
+
+#if ENABLE(TOUCH_EVENTS)
+ virtual void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
+#endif
+
+private:
+ QQuickWebView* m_webView;
+ QtWebPageEventHandler* m_eventHandler;
+ QtWebUndoController* m_undoController;
+};
+
+#endif /* QtPageClient_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
new file mode 100644
index 000000000..6f93c9391
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 "QtPanGestureRecognizer.h"
+
+#include "QtWebPageEventHandler.h"
+#include <QTouchEvent>
+
+namespace WebKit {
+
+QtPanGestureRecognizer::QtPanGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
+{
+ reset();
+}
+
+bool QtPanGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis)
+{
+ if (!interactionEngine())
+ return false;
+
+ // Pan gesture always starts on TouchBegin unless the engine is suspended, or
+ // we ignored the event.
+ if (m_state == NoGesture && event->type() != QEvent::TouchBegin)
+ return false;
+
+ // Having multiple touch points cancel the panning gesture.
+ if (event->touchPoints().size() > 1) {
+ if (m_state == GestureRecognized)
+ interactionEngine()->panGestureCancelled();
+ reset();
+ return false;
+ }
+
+ const QTouchEvent::TouchPoint& touchPoint = event->touchPoints().first();
+
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ ASSERT(m_state == NoGesture);
+ m_state = GestureRecognitionStarted;
+ m_firstPosition = touchPoint.screenPos();
+ return false;
+ case QEvent::TouchUpdate: {
+ ASSERT(m_state != NoGesture);
+ if (m_state == GestureRecognitionStarted) {
+ // To start the gesture, the delta from start in screen coordinates
+ // must be bigger than the trigger threshold.
+ QPointF totalOffsetFromStart(touchPoint.screenPos() - m_firstPosition);
+ if (qAbs(totalOffsetFromStart.x()) < panningInitialTriggerDistanceThreshold && qAbs(totalOffsetFromStart.y()) < panningInitialTriggerDistanceThreshold)
+ return false;
+
+ m_state = GestureRecognized;
+ interactionEngine()->panGestureStarted(touchPoint.pos(), eventTimestampMillis);
+ }
+
+ ASSERT(m_state == GestureRecognized);
+ interactionEngine()->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis);
+ return true;
+ }
+ case QEvent::TouchEnd:
+ if (m_state == GestureRecognized) {
+ interactionEngine()->panGestureEnded(touchPoint.pos(), eventTimestampMillis);
+ reset();
+ return true;
+ }
+ ASSERT(m_state == GestureRecognitionStarted);
+ reset();
+ return false;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ return false;
+}
+
+void QtPanGestureRecognizer::reset()
+{
+ QtGestureRecognizer::reset();
+ m_firstPosition = QPointF();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h
new file mode 100644
index 000000000..532507e09
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 QtPanGestureRecognizer_h
+#define QtPanGestureRecognizer_h
+
+#include "QtGestureRecognizer.h"
+
+#include <QPointF>
+#include <QtCore/QtGlobal>
+
+QT_BEGIN_NAMESPACE
+class QTouchEvent;
+QT_END_NAMESPACE
+
+namespace WebKit {
+
+const qreal panningInitialTriggerDistanceThreshold = 5.;
+
+class QtPanGestureRecognizer : public QtGestureRecognizer {
+public:
+ QtPanGestureRecognizer(QtWebPageEventHandler*);
+ bool recognize(const QTouchEvent*, qint64 eventTimestampMillis);
+ void reset();
+
+private:
+ QPointF m_firstPosition;
+};
+
+} // namespace WebKit
+
+#endif /* QtPanGestureRecognizer_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
new file mode 100644
index 000000000..9167792c4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 "QtPinchGestureRecognizer.h"
+
+#include "QtWebPageEventHandler.h"
+#include <QtCore/QLineF>
+
+namespace WebKit {
+
+const qreal pinchInitialTriggerDistanceThreshold = 5.;
+
+static inline int findTouchPointIndex(const QList<QTouchEvent::TouchPoint>& touchPoints, const QtPinchGestureRecognizer::TouchPointInformation& pointInformation)
+{
+ const int touchCount = touchPoints.size();
+ for (int i = 0; i < touchCount; ++i) {
+ const QTouchEvent::TouchPoint& touchPoint = touchPoints.at(i);
+ if (touchPoint.id() == pointInformation.id)
+ return i;
+ }
+ return -1;
+}
+
+static inline QPointF computePinchCenter(const QTouchEvent::TouchPoint& point1, const QTouchEvent::TouchPoint& point2)
+{
+ return (point1.pos() + point2.pos()) / 2.0f;
+}
+
+QtPinchGestureRecognizer::QtPinchGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
+{
+ reset();
+}
+
+bool QtPinchGestureRecognizer::recognize(const QTouchEvent* event)
+{
+ if (!interactionEngine())
+ return false;
+
+ const QList<QTouchEvent::TouchPoint>& touchPoints = event->touchPoints();
+ if (touchPoints.size() < 2) {
+ if (m_state == GestureRecognized)
+ interactionEngine()->pinchGestureEnded();
+ reset();
+ return false;
+ }
+
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ switch (m_state) {
+ case NoGesture:
+ initializeGesture(touchPoints);
+ return false;
+ case GestureRecognitionStarted:
+ case GestureRecognized:
+ ASSERT(m_point1.isValid());
+ ASSERT(m_point2.isValid());
+
+ const int point1Index = findTouchPointIndex(touchPoints, m_point1);
+ if (point1Index < 0) {
+ reset();
+ return false;
+ }
+ const int point2Index = findTouchPointIndex(touchPoints, m_point2);
+ if (point2Index < 0) {
+ reset();
+ return false;
+ }
+
+ const QTouchEvent::TouchPoint& point1 = touchPoints.at(point1Index);
+ const QTouchEvent::TouchPoint& point2 = touchPoints.at(point2Index);
+ if (m_state == GestureRecognitionStarted) {
+ // FIXME: The gesture should only start if the touch events were not accepted at the start of the touch sequence.
+ const qreal pinchDistance = qAbs(QLineF(point1.screenPos(), point2.screenPos()).length() - QLineF(m_point1.initialScreenPosition, m_point2.initialScreenPosition).length());
+ if (pinchDistance < pinchInitialTriggerDistanceThreshold)
+ return false;
+ m_state = GestureRecognized;
+ interactionEngine()->pinchGestureStarted(computePinchCenter(point1, point2));
+
+ // We reset the initial position to the previous position in order to avoid the jump caused
+ // by skipping all the events between the beginning and when the threshold is hit.
+ m_point1.initialPosition = point1.lastPos();
+ m_point1.initialScreenPosition = point1.lastScreenPos();
+ m_point2.initialPosition = point2.lastPos();
+ m_point2.initialScreenPosition = point2.lastScreenPos();
+ }
+ ASSERT(m_state == GestureRecognized);
+ const qreal currentSpanDistance = QLineF(point1.screenPos(), point2.screenPos()).length();
+ const qreal initialSpanDistance = QLineF(m_point1.initialScreenPosition, m_point2.initialScreenPosition).length();
+ const qreal totalScaleFactor = currentSpanDistance / initialSpanDistance;
+ const QPointF touchCenterInPageViewCoordinates = computePinchCenter(point1, point2);
+ interactionEngine()->pinchGestureRequestUpdate(touchCenterInPageViewCoordinates, totalScaleFactor);
+ return true;
+ break;
+ }
+ break;
+ case QEvent::TouchEnd:
+ if (m_state == GestureRecognized) {
+ interactionEngine()->pinchGestureEnded();
+ reset();
+ return true;
+ }
+ reset();
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ return false;
+}
+
+void QtPinchGestureRecognizer::reset()
+{
+ QtGestureRecognizer::reset();
+ m_point1 = TouchPointInformation();
+ m_point2 = TouchPointInformation();
+}
+
+void QtPinchGestureRecognizer::initializeGesture(const QList<QTouchEvent::TouchPoint>& touchPoints)
+{
+ ASSERT(!m_point1.isValid());
+ ASSERT(!m_point2.isValid());
+
+ m_state = GestureRecognitionStarted;
+
+ m_point1 = TouchPointInformation(touchPoints.at(0));
+ m_point2 = TouchPointInformation(touchPoints.at(1));
+
+ ASSERT(m_point1.isValid());
+ ASSERT(m_point2.isValid());
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h
new file mode 100644
index 000000000..7dd3d911b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@webkit.org>
+ *
+ * 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 QtPinchGestureRecognizer_h
+#define QtPinchGestureRecognizer_h
+
+#include "QtGestureRecognizer.h"
+
+#include <QTouchEvent>
+#include <QtCore/QList>
+#include <QtCore/QPointF>
+
+QT_BEGIN_NAMESPACE
+class QTouchEvent;
+QT_END_NAMESPACE
+
+namespace WebKit {
+
+class QtPinchGestureRecognizer : public QtGestureRecognizer {
+public:
+ struct TouchPointInformation {
+ inline TouchPointInformation();
+ inline TouchPointInformation(const QTouchEvent::TouchPoint&);
+ inline bool isValid() const;
+
+ int id;
+ QPointF initialScreenPosition;
+ QPointF initialPosition;
+ };
+
+ QtPinchGestureRecognizer(QtWebPageEventHandler*);
+ bool recognize(const QTouchEvent*);
+ void reset();
+
+private:
+ void initializeGesture(const QList<QTouchEvent::TouchPoint>& touchPoints);
+
+ TouchPointInformation m_point1;
+ TouchPointInformation m_point2;
+};
+
+inline QtPinchGestureRecognizer::TouchPointInformation::TouchPointInformation()
+ : id(-1)
+{
+}
+
+inline QtPinchGestureRecognizer::TouchPointInformation::TouchPointInformation(const QTouchEvent::TouchPoint& touchPoint)
+ : id(touchPoint.id())
+ , initialScreenPosition(touchPoint.screenPos())
+ , initialPosition(touchPoint.pos())
+{
+}
+
+inline bool QtPinchGestureRecognizer::TouchPointInformation::isValid() const
+{
+ return id >= 0;
+}
+
+}
+
+#endif /* QtPinchGestureRecognizer_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp b/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp
new file mode 100644
index 000000000..229bafc7c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "QtSGTileNode.h"
+
+#include <QtQuick/QSGEngine>
+#include <QtQuick/QSGFlatColorMaterial>
+#include <QtQuick/QSGTexture>
+
+namespace WebKit {
+
+QtSGTileNode::QtSGTileNode(QSGEngine* engine)
+ : m_engine(engine)
+ , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4)
+ , m_textureMaterialsCreated(false)
+{
+ setFlags(OwnsMaterial | OwnsOpaqueMaterial);
+ setGeometry(&m_geometry);
+ setMaterial(new QSGFlatColorMaterial);
+ setOpaqueMaterial(new QSGFlatColorMaterial);
+}
+
+void QtSGTileNode::setBackBuffer(const QImage& backBuffer, const QRectF& sourceRect, const QRectF& targetRect)
+{
+ m_backBufferTexture.reset(m_engine->createTextureFromImage(backBuffer));
+ m_backBufferTargetRect = targetRect;
+ m_backBufferSourceRect = m_backBufferTexture->convertToNormalizedSourceRect(sourceRect);
+
+ // Force the texture upload.
+ m_backBufferTexture->bind();
+}
+
+void QtSGTileNode::swapBuffersIfNeeded()
+{
+ if (!m_backBufferTexture)
+ return;
+
+ if (!m_textureMaterialsCreated) {
+ setMaterial(new QSGTextureMaterial);
+ setOpaqueMaterial(new QSGOpaqueTextureMaterial);
+ m_textureMaterialsCreated = true;
+ }
+
+ static_cast<QSGTextureMaterial*>(material())->setTexture(m_backBufferTexture.data());
+ static_cast<QSGOpaqueTextureMaterial*>(opaqueMaterial())->setTexture(m_backBufferTexture.data());
+ markDirty(DirtyMaterial);
+
+ QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_backBufferTargetRect, m_backBufferSourceRect);
+ markDirty(DirtyGeometry);
+
+ m_frontBufferTexture.swap(m_backBufferTexture);
+ m_backBufferTexture.reset();
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtSGTileNode.h b/Source/WebKit2/UIProcess/qt/QtSGTileNode.h
new file mode 100644
index 000000000..11aaecad8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtSGTileNode.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 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 QtSGTileNode_h
+#define QtSGTileNode_h
+
+#include <QtQuick/QSGGeometryNode>
+#include <QtQuick/QSGOpaqueTextureMaterial>
+#include <QtQuick/QSGTextureMaterial>
+
+QT_BEGIN_NAMESPACE
+class QSGEngine;
+class QSGTexture;
+QT_END_NAMESPACE
+
+namespace WebKit {
+
+class QtSGTileNode : public QSGGeometryNode {
+public:
+ QtSGTileNode(QSGEngine*);
+ void setBackBuffer(const QImage&, const QRectF& sourceRect, const QRectF& targetRect);
+ void swapBuffersIfNeeded();
+
+private:
+ QSGEngine* m_engine;
+ QSGGeometry m_geometry;
+ QScopedPointer<QSGTexture> m_frontBufferTexture;
+ QScopedPointer<QSGTexture> m_backBufferTexture;
+ bool m_textureMaterialsCreated;
+
+ QRectF m_backBufferTargetRect;
+ QRectF m_backBufferSourceRect;
+};
+
+}
+
+#endif // QtSGTileNode_h
diff --git a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp
new file mode 100644
index 000000000..7b1675dfe
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp
@@ -0,0 +1,170 @@
+/*
+ * 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 "QtSGUpdateQueue.h"
+
+#include "PassOwnPtr.h"
+#include "QtSGTileNode.h"
+#include <QtQuick/QQuickItem>
+
+namespace WebKit {
+
+struct NodeUpdateCreateTile : public NodeUpdate {
+ NodeUpdateCreateTile(int nodeID, float scale)
+ : NodeUpdate(CreateTile)
+ , nodeID(nodeID)
+ , scale(scale)
+ { }
+ int nodeID;
+ float scale;
+};
+
+struct NodeUpdateRemoveTile : public NodeUpdate {
+ NodeUpdateRemoveTile(int nodeID)
+ : NodeUpdate(RemoveTile)
+ , nodeID(nodeID)
+ { }
+ int nodeID;
+};
+
+struct NodeUpdateSetBackBuffer : public NodeUpdate {
+ NodeUpdateSetBackBuffer(int nodeID, const QImage& backBuffer, const QRect& sourceRect, const QRect& targetRect)
+ : NodeUpdate(SetBackBuffer)
+ , nodeID(nodeID)
+ , backBuffer(backBuffer)
+ , sourceRect(sourceRect)
+ , targetRect(targetRect)
+ { }
+ int nodeID;
+ QImage backBuffer;
+ QRect sourceRect;
+ QRect targetRect;
+};
+
+struct NodeUpdateSwapTileBuffers : public NodeUpdate {
+ NodeUpdateSwapTileBuffers()
+ : NodeUpdate(SwapTileBuffers)
+ { }
+};
+
+QtSGUpdateQueue::QtSGUpdateQueue(QQuickItem *item)
+ : item(item)
+ , lastScale(0)
+ , lastScaleNode(0)
+ , nextNodeID(1)
+ , m_isSwapPending(false)
+{
+}
+
+int QtSGUpdateQueue::createTileNode(float scale)
+{
+ int nodeID = nextNodeID++;
+ nodeUpdateQueue.append(adoptPtr(new NodeUpdateCreateTile(nodeID, scale)));
+ item->update();
+ return nodeID;
+}
+
+void QtSGUpdateQueue::removeTileNode(int nodeID)
+{
+ nodeUpdateQueue.append(adoptPtr(new NodeUpdateRemoveTile(nodeID)));
+ item->update();
+}
+
+void QtSGUpdateQueue::setNodeBackBuffer(int nodeID, const QImage& backBuffer, const QRect& sourceRect, const QRect& targetRect)
+{
+ nodeUpdateQueue.append(adoptPtr(new NodeUpdateSetBackBuffer(nodeID, backBuffer, sourceRect, targetRect)));
+ item->update();
+}
+
+void QtSGUpdateQueue::swapTileBuffers()
+{
+ nodeUpdateQueue.append(adoptPtr(new NodeUpdateSwapTileBuffers()));
+ m_isSwapPending = true;
+ item->update();
+}
+
+void QtSGUpdateQueue::applyUpdates(QSGNode* itemNode)
+{
+ while (!nodeUpdateQueue.isEmpty()) {
+ OwnPtr<NodeUpdate> nodeUpdate(nodeUpdateQueue.takeFirst());
+ switch (nodeUpdate->type) {
+ case NodeUpdate::CreateTile: {
+ NodeUpdateCreateTile* createTileUpdate = static_cast<NodeUpdateCreateTile*>(nodeUpdate.get());
+ QtSGTileNode* tileNode = new QtSGTileNode(item->sceneGraphEngine());
+ getScaleNode(createTileUpdate->scale, itemNode)->prependChildNode(tileNode);
+ nodes.set(createTileUpdate->nodeID, tileNode);
+ break;
+ }
+ case NodeUpdate::RemoveTile: {
+ NodeUpdateRemoveTile* removeUpdate = static_cast<NodeUpdateRemoveTile*>(nodeUpdate.get());
+ QSGNode* node = nodes.take(removeUpdate->nodeID);
+ QSGNode* scaleNode = node->parent();
+
+ scaleNode->removeChildNode(node);
+ if (!scaleNode->childCount()) {
+ if (scaleNode == lastScaleNode) {
+ lastScale = 0;
+ lastScaleNode = 0;
+ }
+ delete scaleNode;
+ }
+ delete node;
+ break;
+ }
+ case NodeUpdate::SetBackBuffer: {
+ NodeUpdateSetBackBuffer* setBackBufferUpdate = static_cast<NodeUpdateSetBackBuffer*>(nodeUpdate.get());
+ QtSGTileNode* tileNode = nodes.get(setBackBufferUpdate->nodeID);
+ tileNode->setBackBuffer(setBackBufferUpdate->backBuffer, setBackBufferUpdate->sourceRect, setBackBufferUpdate->targetRect);
+ break;
+ }
+ case NodeUpdate::SwapTileBuffers: {
+ HashMap<int, QtSGTileNode*>::iterator end = nodes.end();
+ for (HashMap<int, QtSGTileNode*>::iterator it = nodes.begin(); it != end; ++it)
+ it->second->swapBuffersIfNeeded();
+ m_isSwapPending = false;
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+}
+
+QSGNode* QtSGUpdateQueue::getScaleNode(float scale, QSGNode* itemNode)
+{
+ if (scale == lastScale)
+ return lastScaleNode;
+
+ QSGTransformNode* scaleNode = new QSGTransformNode;
+ QMatrix4x4 scaleMatrix;
+ // Use scale(float,float) to prevent scaling the Z component.
+ // Reverse the item's transform scale since our tiles were generated for this specific scale.
+ scaleMatrix.scale(1 / scale, 1 / scale);
+ scaleNode->setMatrix(scaleMatrix);
+ // Prepend instead of append to paint the new, incomplete, scale before/behind the previous one.
+ itemNode->prependChildNode(scaleNode);
+
+ lastScale = scale;
+ lastScaleNode = scaleNode;
+ return lastScaleNode;
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h
new file mode 100644
index 000000000..f70c50668
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h
@@ -0,0 +1,82 @@
+/*
+ * 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 QtSGUpdateQueue_h
+#define QtSGUpdateQueue_h
+
+#include "Deque.h"
+#include "HashMap.h"
+#include "OwnPtr.h"
+
+class QImage;
+class QRect;
+class QQuickItem;
+class QSGNode;
+class QSize;
+
+namespace WebKit {
+
+class NodeUpdate;
+class PageNode;
+class QtSGTileNode;
+
+// Takes care of taking update requests then fulfilling them asynchronously on the scene graph thread.
+class QtSGUpdateQueue {
+public:
+ QtSGUpdateQueue(QQuickItem*);
+
+ int createTileNode(float scale);
+ void removeTileNode(int nodeID);
+ void setNodeBackBuffer(int nodeID, const QImage& texture, const QRect& sourceRect, const QRect& targetRect);
+ void swapTileBuffers();
+
+ // Called by the QQuickItem.
+ void applyUpdates(QSGNode* itemNode);
+ bool isSwapPending() const { return m_isSwapPending; }
+
+private:
+ QSGNode* getScaleNode(float scale, QSGNode* itemNode);
+
+ QQuickItem* item;
+ Deque<OwnPtr<NodeUpdate> > nodeUpdateQueue;
+ HashMap<int, QtSGTileNode*> nodes;
+ float lastScale;
+ QSGNode* lastScaleNode;
+ int nextNodeID;
+ bool m_isSwapPending;
+};
+
+struct NodeUpdate {
+ enum Type {
+ CreateTile,
+ RemoveTile,
+ SetBackBuffer,
+ SwapTileBuffers
+ };
+ NodeUpdate(Type type)
+ : type(type)
+ { }
+ virtual ~NodeUpdate() { }
+ Type type;
+};
+
+}
+
+#endif // QtSGUpdateQueue_h
diff --git a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp
new file mode 100644
index 000000000..2ed773c11
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp
@@ -0,0 +1,161 @@
+/*
+ * 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 "QtTapGestureRecognizer.h"
+
+#include "QtWebPageEventHandler.h"
+#include <QLineF>
+#include <QTouchEvent>
+
+namespace WebKit {
+
+QtTapGestureRecognizer::QtTapGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
+ , m_tapState(NoTap)
+{
+ reset();
+}
+
+bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis)
+{
+ if (event->touchPoints().size() != 1) {
+ reset();
+ return false;
+ }
+
+ switch (event->type()) {
+ case QEvent::TouchBegin:
+ ASSERT(m_tapState == NoTap);
+ ASSERT(!m_tapAndHoldTimer.isActive());
+
+ m_tapAndHoldTimer.start(tapAndHoldTime, this);
+
+ if (m_doubleTapTimer.isActive()) {
+ // Might be double tap.
+ ASSERT(m_touchBeginEventForTap);
+ m_doubleTapTimer.stop();
+ QPointF lastPosition = m_touchBeginEventForTap->touchPoints().first().screenPos();
+ QPointF newPosition = event->touchPoints().first().screenPos();
+ if (QLineF(lastPosition, newPosition).length() < maxDoubleTapDistance)
+ m_tapState = DoubleTapCandidate;
+ else {
+ // Received a new tap, that is unrelated to the previous one.
+ tapTimeout();
+ m_tapState = SingleTapStarted;
+ }
+ } else
+ m_tapState = SingleTapStarted;
+ m_touchBeginEventForTap = adoptPtr(new QTouchEvent(*event));
+ break;
+ case QEvent::TouchUpdate:
+ // If the touch point moves further than the threshold, we cancel the tap gesture.
+ if (m_tapState == SingleTapStarted) {
+ const QTouchEvent::TouchPoint& touchPoint = event->touchPoints().first();
+ QPointF offset(touchPoint.scenePos() - m_touchBeginEventForTap->touchPoints().first().scenePos());
+ const qreal distX = qAbs(offset.x());
+ const qreal distY = qAbs(offset.y());
+ if (distX > initialTriggerDistanceThreshold || distY > initialTriggerDistanceThreshold)
+ reset();
+ }
+ break;
+ case QEvent::TouchEnd:
+ m_tapAndHoldTimer.stop();
+
+ switch (m_tapState) {
+ case DoubleTapCandidate:
+ {
+ ASSERT(!m_doubleTapTimer.isActive());
+ m_tapState = NoTap;
+
+ const QTouchEvent::TouchPoint& touchPoint = event->touchPoints().first();
+ QPointF startPosition = touchPoint.startScreenPos();
+ QPointF endPosition = touchPoint.screenPos();
+ if (QLineF(endPosition, startPosition).length() < maxDoubleTapDistance && m_eventHandler)
+ m_eventHandler->handleDoubleTapEvent(touchPoint);
+ break;
+ }
+ case SingleTapStarted:
+ ASSERT(!m_doubleTapTimer.isActive());
+ m_doubleTapTimer.start(doubleClickInterval, this);
+ m_tapState = NoTap;
+ break;
+ case TapAndHold:
+ m_tapState = NoTap;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+void QtTapGestureRecognizer::tapTimeout()
+{
+ m_doubleTapTimer.stop();
+ m_eventHandler->handleSingleTapEvent(m_touchBeginEventForTap->touchPoints().at(0));
+ m_touchBeginEventForTap.clear();
+}
+
+void QtTapGestureRecognizer::tapAndHoldTimeout()
+{
+ ASSERT(m_touchBeginEventForTap);
+ m_tapAndHoldTimer.stop();
+#if 0 // No support for synthetic context menus in WK2 yet.
+ QTouchEvent::TouchPoint tapPoint = m_touchBeginEventForTap->touchPoints().at(0);
+ WebGestureEvent gesture(WebEvent::GestureTapAndHold, tapPoint.pos().toPoint(), tapPoint.screenPos().toPoint(), WebEvent::Modifiers(0), 0);
+ if (m_webPageProxy)
+ m_webPageProxy->handleGestureEvent(gesture);
+#endif
+ m_touchBeginEventForTap.clear();
+ m_tapState = TapAndHold;
+
+ ASSERT(!m_doubleTapTimer.isActive());
+ m_doubleTapTimer.stop();
+}
+
+void QtTapGestureRecognizer::reset()
+{
+ m_tapState = NoTap;
+ m_touchBeginEventForTap.clear();
+ m_tapAndHoldTimer.stop();
+
+ QtGestureRecognizer::reset();
+}
+
+void QtTapGestureRecognizer::timerEvent(QTimerEvent* ev)
+{
+ int timerId = ev->timerId();
+ if (timerId == m_doubleTapTimer.timerId())
+ tapTimeout();
+ else if (timerId == m_tapAndHoldTimer.timerId())
+ tapAndHoldTimeout();
+ else
+ QObject::timerEvent(ev);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h
new file mode 100644
index 000000000..a4ec41eff
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h
@@ -0,0 +1,76 @@
+/*
+ * 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 QtTapGestureRecognizer_h
+#define QtTapGestureRecognizer_h
+
+#include "QtGestureRecognizer.h"
+
+#include <QtCore/QBasicTimer>
+#include <QtCore/QObject>
+#include <QtCore/QtGlobal>
+#include <wtf/OwnPtr.h>
+
+QT_BEGIN_NAMESPACE
+class QTouchEvent;
+QT_END_NAMESPACE
+
+// FIXME: These constants should possibly depend on DPI.
+const qreal initialTriggerDistanceThreshold = 5;
+const qreal maxDoubleTapDistance = 120;
+const int tapAndHoldTime = 800;
+const int doubleClickInterval = 400;
+
+class QtWebPageEventHandler;
+
+namespace WebKit {
+
+class QtTapGestureRecognizer : public QObject, private QtGestureRecognizer {
+public:
+ QtTapGestureRecognizer(QtWebPageEventHandler*);
+ bool recognize(const QTouchEvent*, qint64 eventTimestampMillis);
+ void reset();
+
+protected:
+ void timerEvent(QTimerEvent*);
+ void tapTimeout();
+ void tapAndHoldTimeout();
+
+private:
+ QBasicTimer m_doubleTapTimer;
+ QBasicTimer m_tapAndHoldTimer;
+ OwnPtr<QTouchEvent> m_touchBeginEventForTap;
+
+ enum {
+ NoTap,
+ SingleTapStarted,
+ DoubleTapCandidate,
+ TapAndHold
+ } m_tapState;
+};
+
+} // namespace WebKit
+
+#endif /* QtTapGestureRecognizer_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
new file mode 100644
index 000000000..788349ae0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
@@ -0,0 +1,589 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@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 "QtViewportInteractionEngine.h"
+
+#include "PassOwnPtr.h"
+#include <QPointF>
+#include <QScrollEvent>
+#include <QScrollPrepareEvent>
+#include <QScrollerProperties>
+#include <QWheelEvent>
+#include <QtQuick/qquickitem.h>
+
+namespace WebKit {
+
+static const int kScaleAnimationDurationMillis = 250;
+
+// UPDATE DEFERRING (SUSPEND/RESUME)
+// =================================
+//
+// When interaction with the content, either by animating or by the hand of the user,
+// it is important to ensure smooth animations of at least 60fps in order to give a
+// good user experience.
+//
+// In order to do this we need to get rid of unknown factors. These include device
+// sensors (geolocation, orientation updates etc), CSS3 animations, JavaScript
+// exectution, sub resource loads etc. We do this by emitting suspend and resume
+// signals, which are then handled by the viewport and propagates to the right place.
+//
+// For this reason the ViewportUpdateDeferrer guard must be used when we interact
+// or animate the content.
+//
+// It should be noted that when we update content properties, we might receive notify
+// signals send my the content item itself, and care should be taken to not act on
+// these unconditionally. An example of this is the pinch zoom, which changes the
+// position and will thus result in a QQuickWebPage::geometryChanged() signal getting
+// emitted.
+//
+// If something should only be executed during update deferring, it is possible to
+// check for that using ASSERT(m_suspendCount).
+
+class ViewportUpdateDeferrer {
+public:
+ ViewportUpdateDeferrer(QtViewportInteractionEngine* engine)
+ : engine(engine)
+ {
+ if (engine->m_suspendCount++)
+ return;
+
+ emit engine->contentSuspendRequested();
+ }
+
+ ~ViewportUpdateDeferrer()
+ {
+ if (--(engine->m_suspendCount))
+ return;
+
+ emit engine->contentResumeRequested();
+
+ // Make sure that tiles all around the viewport will be requested.
+ emit engine->viewportTrajectoryVectorChanged(QPointF());
+ }
+
+private:
+ QtViewportInteractionEngine* const engine;
+};
+
+inline qreal QtViewportInteractionEngine::cssScaleFromItem(qreal itemScale)
+{
+ return itemScale / m_constraints.devicePixelRatio;
+}
+
+inline qreal QtViewportInteractionEngine::itemScaleFromCSS(qreal cssScale)
+{
+ return cssScale * m_constraints.devicePixelRatio;
+}
+
+inline qreal QtViewportInteractionEngine::itemCoordFromCSS(qreal value)
+{
+ return value * m_constraints.devicePixelRatio;
+}
+
+inline QRectF QtViewportInteractionEngine::itemRectFromCSS(const QRectF& cssRect)
+{
+ QRectF itemRect;
+
+ itemRect.setX(itemCoordFromCSS(cssRect.x()));
+ itemRect.setY(itemCoordFromCSS(cssRect.y()));
+ itemRect.setWidth(itemCoordFromCSS(cssRect.width()));
+ itemRect.setHeight(itemCoordFromCSS(cssRect.height()));
+
+ return itemRect;
+}
+
+QtViewportInteractionEngine::QtViewportInteractionEngine(const QQuickItem* viewport, QQuickItem* content)
+ : m_viewport(viewport)
+ , m_content(content)
+ , m_suspendCount(0)
+ , m_scaleAnimation(new ScaleAnimation(this))
+ , m_pinchStartScale(-1)
+{
+ reset();
+
+ QScrollerProperties properties = scroller()->scrollerProperties();
+
+ // The QtPanGestureRecognizer is responsible for recognizing the gesture
+ // thus we need to disable the drag start distance.
+ properties.setScrollMetric(QScrollerProperties::DragStartDistance, 0.0);
+
+ // Set some default QScroller constrains to mimic the physics engine of the N9 browser.
+ properties.setScrollMetric(QScrollerProperties::AxisLockThreshold, 0.66);
+ properties.setScrollMetric(QScrollerProperties::ScrollingCurve, QEasingCurve(QEasingCurve::OutExpo));
+ properties.setScrollMetric(QScrollerProperties::DecelerationFactor, 0.05);
+ properties.setScrollMetric(QScrollerProperties::MaximumVelocity, 0.635);
+ properties.setScrollMetric(QScrollerProperties::OvershootDragResistanceFactor, 0.33);
+ properties.setScrollMetric(QScrollerProperties::OvershootScrollDistanceFactor, 0.33);
+
+ scroller()->setScrollerProperties(properties);
+
+ connect(m_content, SIGNAL(widthChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
+ connect(m_content, SIGNAL(heightChanged()), this, SLOT(itemSizeChanged()), Qt::DirectConnection);
+
+ connect(m_scaleAnimation, SIGNAL(valueChanged(QVariant)),
+ SLOT(scaleAnimationValueChanged(QVariant)), Qt::DirectConnection);
+ connect(m_scaleAnimation, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)),
+ SLOT(scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)), Qt::DirectConnection);
+
+ connect(scroller(), SIGNAL(stateChanged(QScroller::State)),
+ SLOT(scrollStateChanged(QScroller::State)), Qt::DirectConnection);
+}
+
+QtViewportInteractionEngine::~QtViewportInteractionEngine()
+{
+}
+
+qreal QtViewportInteractionEngine::innerBoundedCSSScale(qreal cssScale)
+{
+ return qBound(m_constraints.minimumScale, cssScale, m_constraints.maximumScale);
+}
+
+qreal QtViewportInteractionEngine::outerBoundedCSSScale(qreal cssScale)
+{
+ if (m_constraints.isUserScalable) {
+ // Bounded by [0.1, 10.0] like the viewport meta code in WebCore.
+ qreal hardMin = qMax<qreal>(0.1, qreal(0.5) * m_constraints.minimumScale);
+ qreal hardMax = qMin<qreal>(10, qreal(2.0) * m_constraints.maximumScale);
+ return qBound(hardMin, cssScale, hardMax);
+ }
+ return innerBoundedCSSScale(cssScale);
+}
+
+void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect)
+{
+ ViewportUpdateDeferrer guard(this);
+
+ qreal itemScale = m_viewport->width() / itemRect.width();
+
+ m_content->setScale(itemScale);
+
+ // We need to animate the content but the position represents the viewport hence we need to invert the position here.
+ // To animate the position together with the scale we multiply the position with the current scale;
+ m_content->setPos(- itemRect.topLeft() * itemScale);
+}
+
+bool QtViewportInteractionEngine::animateItemRectVisible(const QRectF& itemRect)
+{
+ QRectF currentItemRectVisible = m_content->mapRectFromItem(m_viewport, m_viewport->boundingRect());
+ if (itemRect == currentItemRectVisible)
+ return false;
+
+ m_scaleAnimation->setDuration(kScaleAnimationDurationMillis);
+ m_scaleAnimation->setEasingCurve(QEasingCurve::OutCubic);
+
+ m_scaleAnimation->setStartValue(currentItemRectVisible);
+ m_scaleAnimation->setEndValue(itemRect);
+
+ m_scaleAnimation->start();
+ return true;
+}
+
+void QtViewportInteractionEngine::scaleAnimationStateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State /*oldState*/)
+{
+ switch (newState) {
+ case QAbstractAnimation::Running:
+ if (!m_scaleUpdateDeferrer)
+ m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
+ break;
+ case QAbstractAnimation::Stopped:
+ m_scaleUpdateDeferrer.clear();
+ break;
+ default:
+ break;
+ }
+}
+
+void QtViewportInteractionEngine::scrollStateChanged(QScroller::State newState)
+{
+ switch (newState) {
+ case QScroller::Inactive:
+ // FIXME: QScroller gets when even when tapping while it is scrolling.
+ m_scrollUpdateDeferrer.clear();
+ break;
+ case QScroller::Pressed:
+ case QScroller::Dragging:
+ case QScroller::Scrolling:
+ if (m_scrollUpdateDeferrer)
+ break;
+ m_scrollUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
+ break;
+ default:
+ break;
+ }
+}
+
+bool QtViewportInteractionEngine::event(QEvent* event)
+{
+ switch (event->type()) {
+ case QEvent::ScrollPrepare: {
+ QScrollPrepareEvent* prepareEvent = static_cast<QScrollPrepareEvent*>(event);
+ const QRectF viewportRect = m_viewport->boundingRect();
+ const QRectF contentRect = m_viewport->mapRectFromItem(m_content, m_content->boundingRect());
+ const QRectF posRange = computePosRangeForItemAtScale(m_content->scale());
+ prepareEvent->setContentPosRange(posRange);
+ prepareEvent->setViewportSize(viewportRect.size());
+
+ // As we want to push the contents and not actually scroll it, we need to invert the positions here.
+ prepareEvent->setContentPos(-contentRect.topLeft());
+ prepareEvent->accept();
+ return true;
+ }
+ case QEvent::Scroll: {
+ QScrollEvent* scrollEvent = static_cast<QScrollEvent*>(event);
+ QPointF newPos = -scrollEvent->contentPos() - scrollEvent->overshootDistance();
+ if (m_content->pos() != newPos) {
+ QPointF currentPosInContentCoordinates = m_content->mapToItem(m_content->parentItem(), m_content->pos());
+ QPointF newPosInContentCoordinates = m_content->mapToItem(m_content->parentItem(), newPos);
+
+ // This must be emitted before viewportUpdateRequested so that the web process knows where to look for tiles.
+ emit viewportTrajectoryVectorChanged(currentPosInContentCoordinates- newPosInContentCoordinates);
+ m_content->setPos(newPos);
+ }
+ return true;
+ }
+ default:
+ break;
+ }
+ return QObject::event(event);
+}
+
+static inline QPointF boundPosition(const QPointF minPosition, const QPointF& position, const QPointF& maxPosition)
+{
+ return QPointF(qBound(minPosition.x(), position.x(), maxPosition.x()),
+ qBound(minPosition.y(), position.y(), maxPosition.y()));
+}
+
+void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev)
+{
+ if (scrollAnimationActive() || scaleAnimationActive() || pinchGestureActive())
+ return; // Ignore.
+
+ int delta = ev->delta();
+ QPointF newPos = -m_content->pos();
+
+ // A delta that is not mod 120 indicates a device that is sending
+ // fine-resolution scroll events, so use the delta as number of wheel ticks
+ // and number of pixels to scroll. See also webkit.org/b/29601
+ bool fullTick = !(delta % 120);
+
+ static const int cDefaultQtScrollStep = 20;
+ static const int wheelScrollLines = 3;
+ int scrollLines = (fullTick) ? wheelScrollLines * cDefaultQtScrollStep : 1;
+
+ delta = (fullTick) ? delta / 120.0f : delta;
+ delta *= scrollLines;
+
+ if (ev->orientation() == Qt::Horizontal)
+ newPos.rx() += delta;
+ else
+ newPos.ry() += delta;
+
+ QRectF endPosRange = computePosRangeForItemAtScale(m_content->scale());
+ m_content->setPos(-boundPosition(endPosRange.topLeft(), newPos, endPosRange.bottomRight()));
+}
+
+void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition)
+{
+ // Ignore the request if suspended. Can only happen due to delay in event delivery.
+ if (m_suspendCount)
+ return;
+
+ qreal endItemScale = m_content->scale(); // Stay at same scale.
+
+ QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
+ QPointF endPosition = boundPosition(endPosRange.topLeft(), pagePosition * endItemScale, endPosRange.bottomRight());
+
+ QRectF endVisibleContentRect(endPosition / endItemScale, m_viewport->boundingRect().size() / endItemScale);
+
+ setItemRectVisible(endVisibleContentRect);
+}
+
+QRectF QtViewportInteractionEngine::computePosRangeForItemAtScale(qreal itemScale) const
+{
+ const QSizeF contentItemSize = m_content->boundingRect().size() * itemScale;
+ const QSizeF viewportItemSize = m_viewport->boundingRect().size();
+
+ const qreal horizontalRange = contentItemSize.width() - viewportItemSize.width();
+ const qreal verticalRange = contentItemSize.height() - viewportItemSize.height();
+
+ return QRectF(QPointF(0, 0), QSizeF(horizontalRange, verticalRange));
+}
+
+void QtViewportInteractionEngine::focusEditableArea(const QRectF& caretArea, const QRectF& targetArea)
+{
+ QRectF endArea = itemRectFromCSS(targetArea);
+
+ qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(2.0));
+ const QRectF viewportRect = m_viewport->boundingRect();
+
+ qreal x;
+ const qreal borderOffset = 10;
+ if ((endArea.width() + borderOffset) * endItemScale <= viewportRect.width()) {
+ // Center the input field in the middle of the view, if it is smaller than
+ // the view at the scale target.
+ x = viewportRect.center().x() - endArea.width() * endItemScale / 2.0;
+ } else {
+ // Ensure that the caret always has borderOffset contents pixels to the right
+ // of it, and secondarily (if possible), that the area has borderOffset
+ // contents pixels to the left of it.
+ qreal caretOffset = itemCoordFromCSS(caretArea.x()) - endArea.x();
+ x = qMin(viewportRect.width() - (caretOffset + borderOffset) * endItemScale, borderOffset * endItemScale);
+ }
+
+ const QPointF hotspot = QPointF(endArea.x(), endArea.center().y());
+ const QPointF viewportHotspot = QPointF(x, /* FIXME: visibleCenter */ viewportRect.center().y());
+
+ QPointF endPosition = hotspot * endItemScale - viewportHotspot;
+ QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
+
+ endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
+
+ QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
+
+ animateItemRectVisible(endVisibleContentRect);
+}
+
+void QtViewportInteractionEngine::zoomToAreaGestureEnded(const QPointF& touchPoint, const QRectF& targetArea)
+{
+ if (!targetArea.isValid())
+ return;
+
+ if (scrollAnimationActive() || scaleAnimationActive())
+ return;
+
+ const int margin = 10; // We want at least a little bit or margin.
+ QRectF endArea = itemRectFromCSS(targetArea.adjusted(-margin, -margin, margin, margin));
+
+ const QRectF viewportRect = m_viewport->boundingRect();
+
+ qreal targetCSSScale = cssScaleFromItem(viewportRect.size().width() / endArea.size().width());
+ qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(qMin(targetCSSScale, qreal(2.5))));
+
+ // We want to end up with the target area filling the whole width of the viewport (if possible),
+ // and centralized vertically where the user requested zoom. Thus our hotspot is the center of
+ // the targetArea x-wise and the requested zoom position, y-wise.
+ const QPointF hotspot = QPointF(endArea.center().x(), touchPoint.y() * m_constraints.devicePixelRatio);
+ const QPointF viewportHotspot = viewportRect.center();
+
+ QPointF endPosition = hotspot * endItemScale - viewportHotspot;
+
+ QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
+ endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
+
+ QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
+
+ animateItemRectVisible(endVisibleContentRect);
+}
+
+bool QtViewportInteractionEngine::ensureContentWithinViewportBoundary(bool immediate)
+{
+ ASSERT(m_suspendCount);
+
+ if (scrollAnimationActive() || scaleAnimationActive())
+ return false;
+
+ qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(currentCSSScale()));
+
+ const QRectF viewportRect = m_viewport->boundingRect();
+ QPointF viewportHotspot = viewportRect.center();
+
+ QPointF endPosition = m_content->mapFromItem(m_viewport, viewportHotspot) * endItemScale - viewportHotspot;
+
+ QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
+ endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
+
+ QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
+
+ if (immediate) {
+ setItemRectVisible(endVisibleContentRect);
+ return true;
+ }
+ return !animateItemRectVisible(endVisibleContentRect);
+}
+
+void QtViewportInteractionEngine::reset()
+{
+ ASSERT(!m_suspendCount);
+
+ m_hadUserInteraction = false;
+
+ scroller()->stop();
+ m_scaleAnimation->stop();
+}
+
+void QtViewportInteractionEngine::applyConstraints(const Constraints& constraints)
+{
+ // We always have to apply the constrains even if they didn't change, as
+ // the initial scale might need to be applied.
+
+ ViewportUpdateDeferrer guard(this);
+
+ m_constraints = constraints;
+
+ if (!m_hadUserInteraction) {
+ qreal initialScale = innerBoundedCSSScale(m_constraints.initialScale);
+ m_content->setScale(itemScaleFromCSS(initialScale));
+ }
+
+ // If the web app changes successively changes the viewport on purpose
+ // it wants to be in control and we should disable animations.
+ ensureContentWithinViewportBoundary(/* immediate */ true);
+}
+
+qreal QtViewportInteractionEngine::currentCSSScale()
+{
+ return cssScaleFromItem(m_content->scale());
+}
+
+bool QtViewportInteractionEngine::scrollAnimationActive() const
+{
+ QScroller* scroller = const_cast<QtViewportInteractionEngine*>(this)->scroller();
+ return scroller->state() == QScroller::Scrolling;
+}
+
+void QtViewportInteractionEngine::interruptScrollAnimation()
+{
+ // Stopping the scroller immediately stops kinetic scrolling and if the view is out of bounds it
+ // is moved inside valid bounds immediately as well. This is the behavior that we want.
+ scroller()->stop();
+}
+
+bool QtViewportInteractionEngine::panGestureActive() const
+{
+ QScroller* scroller = const_cast<QtViewportInteractionEngine*>(this)->scroller();
+ return scroller->state() == QScroller::Pressed || scroller->state() == QScroller::Dragging;
+}
+
+void QtViewportInteractionEngine::panGestureStarted(const QPointF& touchPoint, qint64 eventTimestampMillis)
+{
+ m_hadUserInteraction = true;
+ scroller()->handleInput(QScroller::InputPress, m_viewport->mapFromItem(m_content, touchPoint), eventTimestampMillis);
+}
+
+void QtViewportInteractionEngine::panGestureRequestUpdate(const QPointF& touchPoint, qint64 eventTimestampMillis)
+{
+ scroller()->handleInput(QScroller::InputMove, m_viewport->mapFromItem(m_content, touchPoint), eventTimestampMillis);
+}
+
+void QtViewportInteractionEngine::panGestureCancelled()
+{
+ // Stopping the scroller immediately stops kinetic scrolling and if the view is out of bounds it
+ // is moved inside valid bounds immediately as well. This is the behavior that we want.
+ scroller()->stop();
+}
+
+void QtViewportInteractionEngine::panGestureEnded(const QPointF& touchPoint, qint64 eventTimestampMillis)
+{
+ scroller()->handleInput(QScroller::InputRelease, m_viewport->mapFromItem(m_content, touchPoint), eventTimestampMillis);
+}
+
+bool QtViewportInteractionEngine::scaleAnimationActive() const
+{
+ return m_scaleAnimation->state() == QAbstractAnimation::Running;
+}
+
+void QtViewportInteractionEngine::interruptScaleAnimation()
+{
+ // This interrupts the scale animation exactly where it is, even if it is out of bounds.
+ m_scaleAnimation->stop();
+}
+
+bool QtViewportInteractionEngine::pinchGestureActive() const
+{
+ return m_pinchStartScale > 0;
+}
+
+void QtViewportInteractionEngine::pinchGestureStarted(const QPointF& pinchCenterInContentCoordinates)
+{
+ ASSERT(!m_suspendCount);
+
+ if (!m_constraints.isUserScalable)
+ return;
+
+ m_hadUserInteraction = true;
+
+ m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this));
+
+ m_lastPinchCenterInViewportCoordinates = m_viewport->mapFromItem(m_content, pinchCenterInContentCoordinates);
+ m_pinchStartScale = m_content->scale();
+
+ // Reset the tiling look-ahead vector so that tiles all around the viewport will be requested on pinch-end.
+ emit viewportTrajectoryVectorChanged(QPointF());
+}
+
+void QtViewportInteractionEngine::pinchGestureRequestUpdate(const QPointF& pinchCenterInContentCoordinates, qreal totalScaleFactor)
+{
+ ASSERT(m_suspendCount);
+
+ if (!m_constraints.isUserScalable)
+ return;
+
+ // Changes of the center position should move the page even if the zoom factor
+ // does not change.
+ const qreal cssScale = cssScaleFromItem(m_pinchStartScale * totalScaleFactor);
+
+ // Allow zooming out beyond mimimum scale on pages that do not explicitly disallow it.
+ const qreal targetCSSScale = outerBoundedCSSScale(cssScale);
+
+ QPointF pinchCenterInViewportCoordinates = m_viewport->mapFromItem(m_content, pinchCenterInContentCoordinates);
+
+ scaleContent(pinchCenterInContentCoordinates, targetCSSScale);
+
+ const QPointF positionDiff = pinchCenterInViewportCoordinates - m_lastPinchCenterInViewportCoordinates;
+ m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates;
+ m_content->setPos(m_content->pos() + positionDiff);
+}
+
+void QtViewportInteractionEngine::pinchGestureEnded()
+{
+ ASSERT(m_suspendCount);
+
+ if (!m_constraints.isUserScalable)
+ return;
+
+ m_pinchStartScale = -1;
+ // Clear the update deferrer now if we're in our final position and there won't be any animation to clear it later.
+ if (ensureContentWithinViewportBoundary())
+ m_scaleUpdateDeferrer.clear();
+}
+
+void QtViewportInteractionEngine::itemSizeChanged()
+{
+ // FIXME: This needs to be done smarter. What happens if it resizes when we were interacting?
+ if (m_suspendCount)
+ return;
+
+ ViewportUpdateDeferrer guard(this);
+ ensureContentWithinViewportBoundary();
+}
+
+void QtViewportInteractionEngine::scaleContent(const QPointF& centerInContentCoordinates, qreal cssScale)
+{
+ QPointF oldPinchCenterOnParent = m_content->mapToItem(m_content->parentItem(), centerInContentCoordinates);
+ m_content->setScale(itemScaleFromCSS(cssScale));
+ QPointF newPinchCenterOnParent = m_content->mapToItem(m_content->parentItem(), centerInContentCoordinates);
+ m_content->setPos(m_content->pos() - (newPinchCenterOnParent - oldPinchCenterOnParent));
+}
+
+#include "moc_QtViewportInteractionEngine.cpp"
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
new file mode 100644
index 000000000..68377a41c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ * Copyright (C) 2011 Benjamin Poulain <benjamin@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 QtViewportInteractionEngine_h
+#define QtViewportInteractionEngine_h
+
+#include "OwnPtr.h"
+#include <QScroller>
+#include "qwebkitglobal.h"
+#include <QtCore/QObject>
+#include <QtCore/QRectF>
+#include <QtCore/QVariant>
+#include <QtCore/QVariantAnimation>
+
+QT_BEGIN_NAMESPACE
+class QPointF;
+class QQuickItem;
+class QWheelEvent;
+QT_END_NAMESPACE
+
+namespace WebKit {
+
+class ViewportUpdateDeferrer;
+
+class QtViewportInteractionEngine : public QObject {
+ Q_OBJECT
+
+public:
+ QtViewportInteractionEngine(const QQuickItem*, QQuickItem*);
+ ~QtViewportInteractionEngine();
+
+ struct Constraints {
+ Constraints()
+ : initialScale(1.0)
+ , minimumScale(0.25)
+ , maximumScale(1.8)
+ , devicePixelRatio(1.0)
+ , isUserScalable(true)
+ , layoutSize(QSize())
+ { }
+
+ qreal initialScale;
+ qreal minimumScale;
+ qreal maximumScale;
+ qreal devicePixelRatio;
+ bool isUserScalable;
+ QSize layoutSize;
+ };
+
+ bool event(QEvent*);
+
+ void reset();
+ void applyConstraints(const Constraints&);
+
+ void setItemRectVisible(const QRectF&);
+ bool animateItemRectVisible(const QRectF&);
+
+ void wheelEvent(QWheelEvent*);
+ void pagePositionRequest(const QPoint& pos);
+
+ bool scrollAnimationActive() const;
+ void interruptScrollAnimation();
+
+ bool panGestureActive() const;
+ void panGestureStarted(const QPointF& touchPoint, qint64 eventTimestampMillis);
+ void panGestureRequestUpdate(const QPointF& touchPoint, qint64 eventTimestampMillis);
+ void panGestureCancelled();
+ void panGestureEnded(const QPointF& touchPoint, qint64 eventTimestampMillis);
+
+ bool scaleAnimationActive() const;
+ void interruptScaleAnimation();
+
+ bool pinchGestureActive() const;
+ void pinchGestureStarted(const QPointF& pinchCenterInContentCoordinates);
+ void pinchGestureRequestUpdate(const QPointF& pinchCenterInContentCoordinates, qreal totalScaleFactor);
+ void pinchGestureEnded();
+
+ void zoomToAreaGestureEnded(const QPointF& touchPoint, const QRectF& targetArea);
+ void focusEditableArea(const QRectF& caretArea, const QRectF& targetArea);
+
+ const Constraints& constraints() const { return m_constraints; }
+ qreal currentCSSScale();
+
+Q_SIGNALS:
+ void contentSuspendRequested();
+ void contentResumeRequested();
+
+ void viewportTrajectoryVectorChanged(const QPointF&);
+
+private Q_SLOTS:
+ // Respond to changes of content that are not driven by us, like the page resizing itself.
+ void itemSizeChanged();
+
+ void scrollStateChanged(QScroller::State);
+ void scaleAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State);
+ void scaleAnimationValueChanged(QVariant value) { setItemRectVisible(value.toRectF()); }
+
+private:
+ friend class ViewportUpdateDeferrer;
+
+ qreal cssScaleFromItem(qreal);
+ qreal itemScaleFromCSS(qreal);
+ qreal itemCoordFromCSS(qreal);
+ QRectF itemRectFromCSS(const QRectF&);
+
+ qreal innerBoundedCSSScale(qreal);
+ qreal outerBoundedCSSScale(qreal);
+
+ QRectF computePosRangeForItemAtScale(qreal itemScale) const;
+ bool ensureContentWithinViewportBoundary(bool immediate = false);
+
+ void scaleContent(const QPointF& centerInContentCoordinates, qreal scale);
+
+ // As long as the object exists this function will always return the same QScroller instance.
+ QScroller* scroller() { return QScroller::scroller(this); }
+
+
+ const QQuickItem* const m_viewport;
+ QQuickItem* const m_content;
+
+ Constraints m_constraints;
+
+ int m_suspendCount;
+ OwnPtr<ViewportUpdateDeferrer> m_scaleUpdateDeferrer;
+ OwnPtr<ViewportUpdateDeferrer> m_scrollUpdateDeferrer;
+
+ bool m_hadUserInteraction;
+
+ class ScaleAnimation : public QVariantAnimation {
+ public:
+ ScaleAnimation(QObject* parent = 0)
+ : QVariantAnimation(parent)
+ { }
+
+ virtual void updateCurrentValue(const QVariant&) { }
+ };
+
+ ScaleAnimation* m_scaleAnimation;
+ QPointF m_lastPinchCenterInViewportCoordinates;
+ qreal m_pinchStartScale;
+};
+
+inline bool operator==(const QtViewportInteractionEngine::Constraints& a, const QtViewportInteractionEngine::Constraints& b)
+{
+ return a.initialScale == b.initialScale
+ && a.minimumScale == b.minimumScale
+ && a.maximumScale == b.maximumScale
+ && a.isUserScalable == b.isUserScalable;
+}
+
+}
+
+#endif // QtViewportInteractionEngine_h
diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.cpp b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp
new file mode 100644
index 000000000..29a547ba9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebContext.cpp
@@ -0,0 +1,157 @@
+/*
+ * 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 "QtWebContext.h"
+
+#include "MutableArray.h"
+#include "QtDownloadManager.h"
+#include "QtWebIconDatabaseClient.h"
+#include "WKAPICast.h"
+#include "WebContext.h"
+#include "WebPageProxy.h"
+#include <WKArray.h>
+#include <WKPage.h>
+#include <WKString.h>
+#include <WKType.h>
+
+namespace WebKit {
+
+static uint64_t generateContextID()
+{
+ static uint64_t uniqueContextID = 1;
+ return uniqueContextID++;
+}
+
+static HashMap<uint64_t, QtWebContext*> contextMap;
+
+QtWebContext* QtWebContext::s_defaultContext = 0;
+
+QtWebContext::QtWebContext(WebContext* context)
+ : m_context(context)
+{
+ m_contextID = generateContextID();
+ contextMap.set(m_contextID, this);
+}
+
+QtWebContext::~QtWebContext()
+{
+ if (s_defaultContext == this)
+ s_defaultContext = 0;
+ contextMap.remove(m_contextID);
+}
+
+// Used only by WebKitTestRunner. It avoids calling initialize(), so that we don't register any clients.
+PassRefPtr<QtWebContext> QtWebContext::create(WebContext* context)
+{
+ return adoptRef(new QtWebContext(context));
+}
+
+PassRefPtr<QtWebContext> QtWebContext::defaultContext()
+{
+ if (s_defaultContext)
+ return PassRefPtr<QtWebContext>(s_defaultContext);
+
+ RefPtr<WebContext> context = WebContext::create(String());
+ RefPtr<QtWebContext> defaultContext = QtWebContext::create(context.get());
+ s_defaultContext = defaultContext.get();
+ defaultContext->initialize();
+
+ return defaultContext.release();
+}
+
+PassRefPtr<WebPageProxy> QtWebContext::createWebPage(PageClient* client, WebPageGroup* pageGroup)
+{
+ return m_context->createWebPage(client, pageGroup);
+}
+
+void QtWebContext::setNavigatorQtObjectEnabled(WebPageProxy* webPageProxy, bool enabled)
+{
+ static String messageName("SetNavigatorQtObjectEnabled");
+ RefPtr<MutableArray> body = MutableArray::create();
+ body->append(webPageProxy);
+ RefPtr<WebBoolean> webEnabled = WebBoolean::create(enabled);
+ body->append(webEnabled.get());
+ m_context->postMessageToInjectedBundle(messageName, body.get());
+}
+
+void QtWebContext::postMessageToNavigatorQtObject(WebPageProxy* webPageProxy, const QString& message)
+{
+ static String messageName("MessageToNavigatorQtObject");
+ RefPtr<MutableArray> body = MutableArray::create();
+ body->append(webPageProxy);
+ RefPtr<WebString> contents = WebString::create(String(message));
+ body->append(contents.get());
+ m_context->postMessageToInjectedBundle(messageName, body.get());
+}
+
+QtWebContext* QtWebContext::contextByID(uint64_t id)
+{
+ return contextMap.get(id);
+}
+
+void QtWebContext::initialize()
+{
+ m_downloadManager = adoptPtr(new QtDownloadManager(m_context.get()));
+ m_iconDatabase = adoptPtr(new QtWebIconDatabaseClient(this));
+ initializeContextInjectedBundleClient();
+}
+
+void QtWebContext::initializeContextInjectedBundleClient()
+{
+ WKContextInjectedBundleClient injectedBundleClient;
+ memset(&injectedBundleClient, 0, sizeof(WKContextInjectedBundleClient));
+ injectedBundleClient.version = kWKContextInjectedBundleClientCurrentVersion;
+ injectedBundleClient.clientInfo = this;
+ injectedBundleClient.didReceiveMessageFromInjectedBundle = didReceiveMessageFromInjectedBundle;
+ WKContextSetInjectedBundleClient(toAPI(m_context.get()), &injectedBundleClient);
+}
+
+static QtWebContext* toQtWebContext(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtWebContext*>(const_cast<void*>(clientInfo));
+}
+
+void QtWebContext::didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void* clientInfo)
+{
+ toQtWebContext(clientInfo)->didReceiveMessageFromInjectedBundle(messageName, messageBody);
+}
+
+void QtWebContext::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
+{
+ if (!WKStringIsEqualToUTF8CString(messageName, "MessageFromNavigatorQtObject"))
+ return;
+
+ ASSERT(messageBody);
+ ASSERT(WKGetTypeID(messageBody) == WKArrayGetTypeID());
+
+ WKArrayRef body = static_cast<WKArrayRef>(messageBody);
+ ASSERT(WKArrayGetSize(body) == 2);
+ ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 0)) == WKPageGetTypeID());
+ ASSERT(WKGetTypeID(WKArrayGetItemAtIndex(body, 1)) == WKStringGetTypeID());
+
+ WKPageRef page = static_cast<WKPageRef>(WKArrayGetItemAtIndex(body, 0));
+ WKStringRef str = static_cast<WKStringRef>(WKArrayGetItemAtIndex(body, 1));
+
+ toImpl(page)->didReceiveMessageFromNavigatorQtObject(toImpl(str)->string());
+}
+
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebContext.h b/Source/WebKit2/UIProcess/qt/QtWebContext.h
new file mode 100644
index 000000000..202db2242
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebContext.h
@@ -0,0 +1,82 @@
+/*
+ * 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 QtWebContext_h
+#define QtWebContext_h
+
+#include <WKContext.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <qglobal.h>
+
+QT_BEGIN_NAMESPACE
+class QString;
+QT_END_NAMESPACE
+
+namespace WebKit {
+
+class PageClient;
+class QtDownloadManager;
+class QtWebIconDatabaseClient;
+class WebContext;
+class WebPageGroup;
+class WebPageProxy;
+
+class QtWebContext : public RefCounted<QtWebContext> {
+public:
+ ~QtWebContext();
+
+ static PassRefPtr<QtWebContext> create(WebContext*);
+ static PassRefPtr<QtWebContext> defaultContext();
+
+ PassRefPtr<WebPageProxy> createWebPage(PageClient*, WebPageGroup*);
+
+ WebContext* context() { return m_context.get(); }
+ QtDownloadManager* downloadManager() { return m_downloadManager.get(); }
+ QtWebIconDatabaseClient* iconDatabase() { return m_iconDatabase.get(); }
+
+ void setNavigatorQtObjectEnabled(WebPageProxy*, bool);
+ void postMessageToNavigatorQtObject(WebPageProxy*, const QString&);
+
+ uint64_t contextID() const { return m_contextID; }
+
+ static QtWebContext* contextByID(uint64_t id);
+
+private:
+ explicit QtWebContext(WebContext*);
+
+ void initialize();
+ void initializeContextInjectedBundleClient();
+
+ static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
+ void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
+
+ static QtWebContext* s_defaultContext;
+
+ uint64_t m_contextID;
+ RefPtr<WebContext> m_context;
+ OwnPtr<QtDownloadManager> m_downloadManager;
+ OwnPtr<QtWebIconDatabaseClient> m_iconDatabase;
+};
+
+}
+
+#endif // QtWebContext_h
diff --git a/Source/WebKit2/UIProcess/qt/QtWebError.cpp b/Source/WebKit2/UIProcess/qt/QtWebError.cpp
new file mode 100644
index 000000000..d5b1cbd1b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebError.cpp
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 Andreas Kling <kling@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 "QtWebError.h"
+
+#include <QtCore/QUrl>
+#include <WKSharedAPICast.h>
+#include <WKString.h>
+#include <WKStringQt.h>
+#include <WKType.h>
+#include <WKURL.h>
+#include <WKURLQt.h>
+
+using namespace WebKit;
+
+QtWebError::QtWebError(WKErrorRef errorRef)
+ : error(errorRef)
+{
+}
+
+QtWebError::Type QtWebError::type() const
+{
+ WKRetainPtr<WKStringRef> errorDomainPtr = adoptWK(WKErrorCopyDomain(error.get()));
+ WTF::String errorDomain = toWTFString(errorDomainPtr.get());
+
+ if (errorDomain == "QtNetwork")
+ return QtWebError::NetworkError;
+ if (errorDomain == "HTTP")
+ return QtWebError::HttpError;
+ if (errorDomain == "Download")
+ return QtWebError::DownloadError;
+ return QtWebError::InternalError;
+}
+
+int QtWebError::errorCode() const
+{
+ return WKErrorGetErrorCode(error.get());
+}
+
+QUrl QtWebError::url() const
+{
+ WKRetainPtr<WKURLRef> failingURL = adoptWK(WKErrorCopyFailingURL(error.get()));
+ return WKURLCopyQUrl(failingURL.get());
+}
+
+QString QtWebError::description() const
+{
+ return WKStringCopyQString(WKErrorCopyLocalizedDescription(error.get()));
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebError.h b/Source/WebKit2/UIProcess/qt/QtWebError.h
new file mode 100644
index 000000000..3bd7bd508
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebError.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 Andreas Kling <kling@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 QtWebError_h
+#define QtWebError_h
+
+#include "qwebdownloaditem_p.h"
+#include "qwebkitglobal.h"
+#include <QtNetwork/QNetworkReply>
+#include <WKError.h>
+#include <WKRetainPtr.h>
+
+QT_BEGIN_NAMESPACE
+class QUrl;
+QT_END_NAMESPACE
+
+class QtWebError {
+public:
+ enum Type {
+ InternalError,
+ NetworkError,
+ HttpError,
+ DownloadError
+ };
+
+ Type type() const;
+ QUrl url() const;
+ int errorCode() const;
+ QString description() const;
+
+ int errorCodeAsHttpStatusCode() const { return errorCode(); }
+ QNetworkReply::NetworkError errorCodeAsNetworkError() const { return static_cast<QNetworkReply::NetworkError>(errorCode()); }
+ QWebDownloadItem::DownloadError errorCodeAsDownloadError() const { return static_cast<QWebDownloadItem::DownloadError>(errorCode()); }
+
+ QtWebError(const QtWebError&);
+
+ QtWebError(WKErrorRef);
+
+private:
+ WKRetainPtr<WKErrorRef> error;
+};
+
+#endif /* QtWebError_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp
new file mode 100644
index 000000000..8b09b20f3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.cpp
@@ -0,0 +1,122 @@
+/*
+ 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 "QtWebIconDatabaseClient.h"
+
+#include "Image.h"
+#include "KURL.h"
+#include "QtWebContext.h"
+#include "SharedBuffer.h"
+#include "WKURLQt.h"
+#include "WebContext.h"
+#include "WebIconDatabase.h"
+#include <QtCore/QHash>
+#include <QtCore/QObject>
+#include <QtCore/QUrl>
+#include <QtGui/QImage>
+
+using namespace WebKit;
+
+static inline QtWebIconDatabaseClient* toQtWebIconDatabaseClient(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtWebIconDatabaseClient*>(const_cast<void*>(clientInfo));
+}
+
+QtWebIconDatabaseClient::QtWebIconDatabaseClient(QtWebContext *qtWebContext)
+{
+ m_contextId = qtWebContext->contextID();
+ // The setter calls the getter here as it triggers the startup of the icon database.
+ WebContext* context = qtWebContext->context();
+ context->setIconDatabasePath(context->iconDatabasePath());
+ m_iconDatabase = context->iconDatabase();
+
+ WKIconDatabaseClient iconDatabaseClient;
+ memset(&iconDatabaseClient, 0, sizeof(WKIconDatabaseClient));
+ iconDatabaseClient.version = kWKIconDatabaseClientCurrentVersion;
+ iconDatabaseClient.clientInfo = this;
+ iconDatabaseClient.didChangeIconForPageURL = didChangeIconForPageURL;
+ WKIconDatabaseSetIconDatabaseClient(toAPI(m_iconDatabase), &iconDatabaseClient);
+}
+
+QtWebIconDatabaseClient::~QtWebIconDatabaseClient()
+{
+}
+
+void QtWebIconDatabaseClient::didChangeIconForPageURL(WKIconDatabaseRef iconDatabase, WKURLRef pageURL, const void* clientInfo)
+{
+ QUrl qUrl = WKURLCopyQUrl(pageURL);
+ toQtWebIconDatabaseClient(clientInfo)->requestIconForPageURL(qUrl);
+}
+
+QImage QtWebIconDatabaseClient::iconImageForPageURL(const String& pageURL, const QSize& iconSize)
+{
+ MutexLocker locker(m_imageLock);
+
+ WebCore::IntSize size(iconSize.width(), iconSize.height());
+ RefPtr<WebCore::Image> image = m_iconDatabase->imageForPageURL(pageURL, size);
+ if (!image)
+ return QImage();
+
+ QPixmap* nativeImage = image->nativeImageForCurrentFrame();
+ if (!nativeImage)
+ return QImage();
+
+ return nativeImage->toImage();
+}
+
+unsigned QtWebIconDatabaseClient::iconURLHashForPageURL(const String& pageURL)
+{
+ String iconURL;
+ m_iconDatabase->synchronousIconURLForPageURL(pageURL, iconURL);
+ return StringHash::hash(iconURL);
+}
+
+void QtWebIconDatabaseClient::requestIconForPageURL(const QUrl& pageURL)
+{
+ String pageURLString = WebCore::KURL(pageURL).string();
+ if (iconImageForPageURL(pageURLString).isNull())
+ return;
+
+ unsigned iconID = iconURLHashForPageURL(pageURLString);
+ QUrl url;
+ url.setScheme(QStringLiteral("image"));
+ url.setHost(QStringLiteral("webicon"));
+ QString path;
+ path.append(QLatin1Char('/'));
+ path.append(QString::number(m_contextId));
+ path.append(QLatin1Char('/'));
+ path.append(QString::number(iconID));
+ url.setPath(path);
+ url.setEncodedFragment(pageURL.toEncoded());
+ emit iconChangedForPageURL(pageURL, url);
+}
+
+void QtWebIconDatabaseClient::retainIconForPageURL(const String& pageURL)
+{
+ m_iconDatabase->retainIconForPageURL(pageURL);
+}
+
+void QtWebIconDatabaseClient::releaseIconForPageURL(const String& pageURL)
+{
+ m_iconDatabase->releaseIconForPageURL(pageURL);
+}
+
+#include "moc_QtWebIconDatabaseClient.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.h
new file mode 100644
index 000000000..e8d056248
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebIconDatabaseClient.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 QtWebIconDatabaseClient_h
+#define QtWebIconDatabaseClient_h
+
+#include "WKIconDatabase.h"
+#include "qwebkitglobal.h"
+#include <QtCore/QObject>
+#include <QtCore/QSize>
+#include <wtf/Threading.h>
+#include <wtf/text/WTFString.h>
+
+QT_BEGIN_NAMESPACE
+class QImage;
+class QUrl;
+QT_END_NAMESPACE
+
+namespace WebKit {
+class QtWebContext;
+class WebIconDatabase;
+
+class QtWebIconDatabaseClient : public QObject {
+ Q_OBJECT
+
+public:
+ QtWebIconDatabaseClient(QtWebContext*);
+ ~QtWebIconDatabaseClient();
+
+ QImage iconImageForPageURL(const String& pageURL, const QSize& iconSize = QSize(32, 32));
+ void retainIconForPageURL(const String&);
+ void releaseIconForPageURL(const String&);
+
+public Q_SLOTS:
+ void requestIconForPageURL(const QUrl&);
+
+public:
+ Q_SIGNAL void iconChangedForPageURL(const QUrl& pageURL, const QUrl& iconURL);
+
+private:
+ unsigned iconURLHashForPageURL(const String&);
+ static void didChangeIconForPageURL(WKIconDatabaseRef, WKURLRef pageURL, const void* clientInfo);
+ uint64_t m_contextId;
+ WebKit::WebIconDatabase* m_iconDatabase;
+ Mutex m_imageLock;
+};
+
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
new file mode 100644
index 000000000..d0196880d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
@@ -0,0 +1,500 @@
+/*
+ * 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 "QtWebPageEventHandler.h"
+
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "QtViewportInteractionEngine.h"
+#include "qquickwebpage_p.h"
+#include <QDrag>
+#include <QGraphicsSceneMouseEvent>
+#include <QGuiApplication>
+#include <QMimeData>
+#include <QtQuick/QQuickCanvas>
+#include <QStyleHints>
+#include <QTextFormat>
+#include <QTouchEvent>
+#include <WebCore/DragData.h>
+#include <WebCore/Editor.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+static inline Qt::DropAction dragOperationToDropAction(unsigned dragOperation)
+{
+ Qt::DropAction result = Qt::IgnoreAction;
+ if (dragOperation & DragOperationCopy)
+ result = Qt::CopyAction;
+ else if (dragOperation & DragOperationMove)
+ result = Qt::MoveAction;
+ else if (dragOperation & DragOperationGeneric)
+ result = Qt::MoveAction;
+ else if (dragOperation & DragOperationLink)
+ result = Qt::LinkAction;
+ return result;
+}
+
+static inline Qt::DropActions dragOperationToDropActions(unsigned dragOperations)
+{
+ Qt::DropActions result = Qt::IgnoreAction;
+ if (dragOperations & DragOperationCopy)
+ result |= Qt::CopyAction;
+ if (dragOperations & DragOperationMove)
+ result |= Qt::MoveAction;
+ if (dragOperations & DragOperationGeneric)
+ result |= Qt::MoveAction;
+ if (dragOperations & DragOperationLink)
+ result |= Qt::LinkAction;
+ return result;
+}
+
+static inline WebCore::DragOperation dropActionToDragOperation(Qt::DropActions actions)
+{
+ unsigned result = 0;
+ if (actions & Qt::CopyAction)
+ result |= DragOperationCopy;
+ if (actions & Qt::MoveAction)
+ result |= (DragOperationMove | DragOperationGeneric);
+ if (actions & Qt::LinkAction)
+ result |= DragOperationLink;
+ if (result == (DragOperationCopy | DragOperationMove | DragOperationGeneric | DragOperationLink))
+ result = DragOperationEvery;
+ return (DragOperation)result;
+}
+
+QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* qmlWebPage)
+ : m_webPageProxy(toImpl(pageRef))
+ , m_panGestureRecognizer(this)
+ , m_pinchGestureRecognizer(this)
+ , m_tapGestureRecognizer(this)
+ , m_webPage(qmlWebPage)
+ , m_previousClickButton(Qt::NoButton)
+ , m_clickCount(0)
+{
+}
+
+QtWebPageEventHandler::~QtWebPageEventHandler()
+{
+}
+
+bool QtWebPageEventHandler::handleEvent(QEvent* ev)
+{
+ switch (ev->type()) {
+ case QEvent::MouseMove:
+ return handleMouseMoveEvent(static_cast<QMouseEvent*>(ev));
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ // If a MouseButtonDblClick was received then we got a MouseButtonPress before
+ // handleMousePressEvent will take care of double clicks.
+ return handleMousePressEvent(static_cast<QMouseEvent*>(ev));
+ case QEvent::MouseButtonRelease:
+ return handleMouseReleaseEvent(static_cast<QMouseEvent*>(ev));
+ case QEvent::Wheel:
+ return handleWheelEvent(static_cast<QWheelEvent*>(ev));
+ case QEvent::HoverLeave:
+ return handleHoverLeaveEvent(static_cast<QHoverEvent*>(ev));
+ case QEvent::HoverEnter: // Fall-through, for WebKit the distinction doesn't matter.
+ case QEvent::HoverMove:
+ return handleHoverMoveEvent(static_cast<QHoverEvent*>(ev));
+ case QEvent::DragEnter:
+ return handleDragEnterEvent(static_cast<QDragEnterEvent*>(ev));
+ case QEvent::DragLeave:
+ return handleDragLeaveEvent(static_cast<QDragLeaveEvent*>(ev));
+ case QEvent::DragMove:
+ return handleDragMoveEvent(static_cast<QDragMoveEvent*>(ev));
+ case QEvent::Drop:
+ return handleDropEvent(static_cast<QDropEvent*>(ev));
+ case QEvent::KeyPress:
+ return handleKeyPressEvent(static_cast<QKeyEvent*>(ev));
+ case QEvent::KeyRelease:
+ return handleKeyReleaseEvent(static_cast<QKeyEvent*>(ev));
+ case QEvent::FocusIn:
+ return handleFocusInEvent(static_cast<QFocusEvent*>(ev));
+ case QEvent::FocusOut:
+ return handleFocusOutEvent(static_cast<QFocusEvent*>(ev));
+ case QEvent::TouchBegin:
+ case QEvent::TouchEnd:
+ case QEvent::TouchUpdate:
+ touchEvent(static_cast<QTouchEvent*>(ev));
+ return true;
+ case QEvent::InputMethod:
+ inputMethodEvent(static_cast<QInputMethodEvent*>(ev));
+ return false; // Look at comment in qquickwebpage.cpp
+ }
+
+ // FIXME: Move all common event handling here.
+ return false;
+}
+
+bool QtWebPageEventHandler::handleMouseMoveEvent(QMouseEvent* ev)
+{
+ // For some reason mouse press results in mouse hover (which is
+ // converted to mouse move for WebKit). We ignore these hover
+ // events by comparing lastPos with newPos.
+ // NOTE: lastPos from the event always comes empty, so we work
+ // around that here.
+ static QPointF lastPos = QPointF();
+ if (lastPos == ev->pos())
+ return ev->isAccepted();
+ lastPos = ev->pos();
+
+ m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount*/ 0));
+
+ return ev->isAccepted();
+}
+
+bool QtWebPageEventHandler::handleMousePressEvent(QMouseEvent* ev)
+{
+ if (m_clickTimer.isActive()
+ && m_previousClickButton == ev->button()
+ && (ev->pos() - m_lastClick).manhattanLength() < qApp->styleHints()->startDragDistance()) {
+ m_clickCount++;
+ } else {
+ m_clickCount = 1;
+ m_previousClickButton = ev->button();
+ }
+
+ m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, m_clickCount));
+
+ m_lastClick = ev->pos();
+ m_clickTimer.start(qApp->styleHints()->mouseDoubleClickInterval(), this);
+ return ev->isAccepted();
+}
+
+bool QtWebPageEventHandler::handleMouseReleaseEvent(QMouseEvent* ev)
+{
+ m_webPageProxy->handleMouseEvent(NativeWebMouseEvent(ev, /*eventClickCount*/ 0));
+ return ev->isAccepted();
+}
+
+bool QtWebPageEventHandler::handleWheelEvent(QWheelEvent* ev)
+{
+ m_webPageProxy->handleWheelEvent(NativeWebWheelEvent(ev));
+ // FIXME: Handle whether the page used the wheel event or not.
+ if (m_interactionEngine)
+ m_interactionEngine->wheelEvent(ev);
+ return ev->isAccepted();
+}
+
+bool QtWebPageEventHandler::handleHoverLeaveEvent(QHoverEvent* ev)
+{
+ // To get the correct behavior of mouseout, we need to turn the Leave event of our webview into a mouse move
+ // to a very far region.
+ QHoverEvent fakeEvent(QEvent::HoverMove, QPoint(INT_MIN, INT_MIN), ev->oldPos());
+ fakeEvent.setTimestamp(ev->timestamp());
+ return handleHoverMoveEvent(&fakeEvent);
+}
+
+bool QtWebPageEventHandler::handleHoverMoveEvent(QHoverEvent* ev)
+{
+ QMouseEvent me(QEvent::MouseMove, ev->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ me.setAccepted(ev->isAccepted());
+ me.setTimestamp(ev->timestamp());
+
+ return handleMouseMoveEvent(&me);
+}
+
+bool QtWebPageEventHandler::handleDragEnterEvent(QDragEnterEvent* ev)
+{
+ m_webPageProxy->resetDragOperation();
+ // FIXME: Should not use QCursor::pos()
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), dropActionToDragOperation(ev->possibleActions()));
+ m_webPageProxy->dragEntered(&dragData);
+ ev->acceptProposedAction();
+ return true;
+}
+
+bool QtWebPageEventHandler::handleDragLeaveEvent(QDragLeaveEvent* ev)
+{
+ bool accepted = ev->isAccepted();
+
+ // FIXME: Should not use QCursor::pos()
+ DragData dragData(0, IntPoint(), QCursor::pos(), DragOperationNone);
+ m_webPageProxy->dragExited(&dragData);
+ m_webPageProxy->resetDragOperation();
+
+ ev->setAccepted(accepted);
+ return accepted;
+}
+
+bool QtWebPageEventHandler::handleDragMoveEvent(QDragMoveEvent* ev)
+{
+ bool accepted = ev->isAccepted();
+
+ // FIXME: Should not use QCursor::pos()
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), dropActionToDragOperation(ev->possibleActions()));
+ m_webPageProxy->dragUpdated(&dragData);
+ ev->setDropAction(dragOperationToDropAction(m_webPageProxy->dragSession().operation));
+ if (m_webPageProxy->dragSession().operation != DragOperationNone)
+ ev->accept();
+
+ ev->setAccepted(accepted);
+ return accepted;
+}
+
+bool QtWebPageEventHandler::handleDropEvent(QDropEvent* ev)
+{
+ bool accepted = ev->isAccepted();
+
+ // FIXME: Should not use QCursor::pos()
+ DragData dragData(ev->mimeData(), ev->pos(), QCursor::pos(), dropActionToDragOperation(ev->possibleActions()));
+ SandboxExtension::Handle handle;
+ m_webPageProxy->performDrag(&dragData, String(), handle);
+ ev->setDropAction(dragOperationToDropAction(m_webPageProxy->dragSession().operation));
+ ev->accept();
+
+ ev->setAccepted(accepted);
+ return accepted;
+}
+
+void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& point)
+{
+ WebGestureEvent gesture(WebEvent::GestureSingleTap, point.pos().toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0);
+ m_webPageProxy->handleGestureEvent(gesture);
+}
+
+void QtWebPageEventHandler::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
+{
+ m_webPageProxy->findZoomableAreaForPoint(point.pos().toPoint());
+}
+
+void QtWebPageEventHandler::timerEvent(QTimerEvent* ev)
+{
+ int timerId = ev->timerId();
+ if (timerId == m_clickTimer.timerId())
+ m_clickTimer.stop();
+ else
+ QObject::timerEvent(ev);
+}
+
+bool QtWebPageEventHandler::handleKeyPressEvent(QKeyEvent* ev)
+{
+ m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
+ return true;
+}
+
+bool QtWebPageEventHandler::handleKeyReleaseEvent(QKeyEvent* ev)
+{
+ m_webPageProxy->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
+ return true;
+}
+
+bool QtWebPageEventHandler::handleFocusInEvent(QFocusEvent*)
+{
+ m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+ return true;
+}
+
+bool QtWebPageEventHandler::handleFocusOutEvent(QFocusEvent*)
+{
+ m_webPageProxy->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+ return true;
+}
+
+void QtWebPageEventHandler::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
+{
+ m_interactionEngine = engine;
+}
+
+void QtWebPageEventHandler::inputMethodEvent(QInputMethodEvent* ev)
+{
+ QString commit = ev->commitString();
+ QString composition = ev->preeditString();
+
+ int replacementStart = ev->replacementStart();
+ int replacementLength = ev->replacementLength();
+
+ // NOTE: We might want to handle events of one char as special
+ // and resend them as key events to make web site completion work.
+
+ int cursorPositionWithinComposition = 0;
+
+ Vector<CompositionUnderline> underlines;
+
+ for (int i = 0; i < ev->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute& attr = ev->attributes().at(i);
+ switch (attr.type) {
+ case QInputMethodEvent::TextFormat: {
+ if (composition.isEmpty())
+ break;
+
+ QTextCharFormat textCharFormat = attr.value.value<QTextFormat>().toCharFormat();
+ QColor qcolor = textCharFormat.underlineColor();
+ Color color = makeRGBA(qcolor.red(), qcolor.green(), qcolor.blue(), qcolor.alpha());
+ int start = qMin(attr.start, (attr.start + attr.length));
+ int end = qMax(attr.start, (attr.start + attr.length));
+ underlines.append(CompositionUnderline(start, end, color, false));
+ break;
+ }
+ case QInputMethodEvent::Cursor:
+ if (attr.length)
+ cursorPositionWithinComposition = attr.start;
+ break;
+ // Selection is handled further down.
+ default: break;
+ }
+ }
+
+ if (composition.isEmpty()) {
+ int selectionStart = -1;
+ int selectionLength = 0;
+ for (int i = 0; i < ev->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute& attr = ev->attributes().at(i);
+ if (attr.type == QInputMethodEvent::Selection) {
+ selectionStart = attr.start;
+ selectionLength = attr.length;
+
+ ASSERT(selectionStart >= 0);
+ ASSERT(selectionLength >= 0);
+ break;
+ }
+ }
+
+ m_webPageProxy->confirmComposition(commit, selectionStart, selectionLength);
+ } else {
+ ASSERT(cursorPositionWithinComposition >= 0);
+ ASSERT(replacementStart >= 0);
+
+ m_webPageProxy->setComposition(composition, underlines,
+ cursorPositionWithinComposition, cursorPositionWithinComposition,
+ replacementStart, replacementLength);
+ }
+
+ ev->accept();
+}
+
+void QtWebPageEventHandler::touchEvent(QTouchEvent* event)
+{
+#if ENABLE(TOUCH_EVENTS)
+ m_webPageProxy->handleTouchEvent(NativeWebTouchEvent(event));
+ event->accept();
+#else
+ ASSERT_NOT_REACHED();
+ ev->ignore();
+#endif
+}
+
+void QtWebPageEventHandler::resetGestureRecognizers()
+{
+ m_panGestureRecognizer.reset();
+ m_pinchGestureRecognizer.reset();
+ m_tapGestureRecognizer.reset();
+}
+
+void QtWebPageEventHandler::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
+{
+ if (!m_interactionEngine)
+ return;
+
+ if (wasEventHandled || event.type() == WebEvent::TouchCancel) {
+ resetGestureRecognizers();
+ return;
+ }
+
+ const QTouchEvent* ev = event.nativeEvent();
+
+ switch (ev->type()) {
+ case QEvent::TouchBegin:
+ ASSERT(!m_interactionEngine->panGestureActive());
+ ASSERT(!m_interactionEngine->pinchGestureActive());
+
+ // The interaction engine might still be animating kinetic scrolling or a scale animation
+ // such as double-tap to zoom or the bounce back effect. A touch stops the kinetic scrolling
+ // where as it does not stop the scale animation.
+ if (m_interactionEngine->scrollAnimationActive())
+ m_interactionEngine->interruptScrollAnimation();
+ break;
+ case QEvent::TouchUpdate:
+ // The scale animation can only be interrupted by a pinch gesture, which will then take over.
+ if (m_interactionEngine->scaleAnimationActive() && m_pinchGestureRecognizer.isRecognized())
+ m_interactionEngine->interruptScaleAnimation();
+ break;
+ default:
+ break;
+ }
+
+ // If the scale animation is active we don't pass the event to the recognizers. In the future
+ // we would want to queue the event here and repost then when the animation ends.
+ if (m_interactionEngine->scaleAnimationActive())
+ return;
+
+ // Convert the event timestamp from second to millisecond.
+ qint64 eventTimestampMillis = static_cast<qint64>(event.timestamp() * 1000);
+ m_panGestureRecognizer.recognize(ev, eventTimestampMillis);
+ m_pinchGestureRecognizer.recognize(ev);
+
+ if (m_panGestureRecognizer.isRecognized() || m_pinchGestureRecognizer.isRecognized())
+ m_tapGestureRecognizer.reset();
+ else {
+ const QTouchEvent* ev = event.nativeEvent();
+ m_tapGestureRecognizer.recognize(ev, eventTimestampMillis);
+ }
+}
+
+void QtWebPageEventHandler::didFindZoomableArea(const IntPoint& target, const IntRect& area)
+{
+ if (!m_interactionEngine)
+ return;
+
+ // FIXME: As the find method might not respond immediately during load etc,
+ // we should ignore all but the latest request.
+ m_interactionEngine->zoomToAreaGestureEnded(QPointF(target), QRectF(area));
+}
+
+void QtWebPageEventHandler::focusEditableArea(const IntRect& caret, const IntRect& area)
+{
+ if (!m_interactionEngine)
+ return;
+
+ m_interactionEngine->focusEditableArea(QRectF(caret), QRectF(area));
+}
+
+void QtWebPageEventHandler::startDrag(const WebCore::DragData& dragData, PassRefPtr<ShareableBitmap> dragImage)
+{
+ QImage dragQImage;
+ if (dragImage)
+ dragQImage = dragImage->createQImage();
+ else if (dragData.platformData() && dragData.platformData()->hasImage())
+ dragQImage = qvariant_cast<QImage>(dragData.platformData()->imageData());
+
+ DragOperation dragOperationMask = dragData.draggingSourceOperationMask();
+ QMimeData* mimeData = const_cast<QMimeData*>(dragData.platformData());
+ Qt::DropActions supportedDropActions = dragOperationToDropActions(dragOperationMask);
+
+ QPoint clientPosition;
+ QPoint globalPosition;
+ Qt::DropAction actualDropAction = Qt::IgnoreAction;
+
+ if (QWindow* window = m_webPage->canvas()) {
+ QDrag* drag = new QDrag(window);
+ drag->setPixmap(QPixmap::fromImage(dragQImage));
+ drag->setMimeData(mimeData);
+ actualDropAction = drag->exec(supportedDropActions);
+ globalPosition = QCursor::pos();
+ clientPosition = window->mapFromGlobal(globalPosition);
+ }
+
+ m_webPageProxy->dragEnded(clientPosition, globalPosition, dropActionToDragOperation(actualDropAction));
+}
+
+#include "moc_QtWebPageEventHandler.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
new file mode 100644
index 000000000..dfab4c8b9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ *
+ */
+
+#ifndef QtWebPageEventHandler_h
+#define QtWebPageEventHandler_h
+
+#include "QtPanGestureRecognizer.h"
+#include "QtPinchGestureRecognizer.h"
+#include "QtTapGestureRecognizer.h"
+#include "QtViewportInteractionEngine.h"
+#include "WebPageProxy.h"
+#include <QBasicTimer>
+#include <QKeyEvent>
+#include <QInputMethodEvent>
+#include <QTouchEvent>
+#include <WKPage.h>
+
+class QQuickWebPage;
+
+using namespace WebKit;
+
+class QtWebPageEventHandler : public QObject {
+ Q_OBJECT
+
+public:
+ QtWebPageEventHandler(WKPageRef, QQuickWebPage*);
+ ~QtWebPageEventHandler();
+
+ bool handleEvent(QEvent*);
+
+ void setViewportInteractionEngine(QtViewportInteractionEngine*);
+
+ void handleSingleTapEvent(const QTouchEvent::TouchPoint&);
+ void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
+
+ void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area);
+ void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area);
+ void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
+ void resetGestureRecognizers();
+
+ QtViewportInteractionEngine* interactionEngine() { return m_interactionEngine; }
+
+ void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
+
+protected:
+ WebPageProxy* m_webPageProxy;
+ QtViewportInteractionEngine* m_interactionEngine;
+ QtPanGestureRecognizer m_panGestureRecognizer;
+ QtPinchGestureRecognizer m_pinchGestureRecognizer;
+ QtTapGestureRecognizer m_tapGestureRecognizer;
+ QQuickWebPage* m_webPage;
+
+private:
+ bool handleKeyPressEvent(QKeyEvent*);
+ bool handleKeyReleaseEvent(QKeyEvent*);
+ bool handleFocusInEvent(QFocusEvent*);
+ bool handleFocusOutEvent(QFocusEvent*);
+ bool handleMouseMoveEvent(QMouseEvent*);
+ bool handleMousePressEvent(QMouseEvent*);
+ bool handleMouseReleaseEvent(QMouseEvent*);
+ bool handleWheelEvent(QWheelEvent*);
+ bool handleHoverLeaveEvent(QHoverEvent*);
+ bool handleHoverMoveEvent(QHoverEvent*);
+ bool handleDragEnterEvent(QDragEnterEvent*);
+ bool handleDragLeaveEvent(QDragLeaveEvent*);
+ bool handleDragMoveEvent(QDragMoveEvent*);
+ bool handleDropEvent(QDropEvent*);
+
+ void timerEvent(QTimerEvent*);
+
+ void touchEvent(QTouchEvent*);
+ void inputMethodEvent(QInputMethodEvent*);
+
+ QPoint m_lastClick;
+ QBasicTimer m_clickTimer;
+ Qt::MouseButton m_previousClickButton;
+ int m_clickCount;
+};
+
+#endif /* QtWebPageEventHandler_h */
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp
new file mode 100644
index 000000000..3ba8c74f6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp
@@ -0,0 +1,197 @@
+/*
+ * 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 "QtWebPageLoadClient.h"
+
+#include "WKStringQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <WKFrame.h>
+
+QtWebPageLoadClient::QtWebPageLoadClient(WKPageRef pageRef, QQuickWebView* webView)
+ : m_webView(webView)
+ , m_loadProgress(0)
+{
+ WKPageLoaderClient loadClient;
+ memset(&loadClient, 0, sizeof(WKPageLoaderClient));
+ loadClient.version = kWKPageLoaderClientCurrentVersion;
+ loadClient.clientInfo = this;
+ loadClient.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame;
+ loadClient.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame;
+ loadClient.didCommitLoadForFrame = didCommitLoadForFrame;
+ loadClient.didFinishLoadForFrame = didFinishLoadForFrame;
+ loadClient.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame;
+ loadClient.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame;
+ loadClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
+ loadClient.didStartProgress = didStartProgress;
+ loadClient.didChangeProgress = didChangeProgress;
+ loadClient.didFinishProgress = didFinishProgress;
+ loadClient.didFirstVisuallyNonEmptyLayoutForFrame = didFirstVisuallyNonEmptyLayoutForFrame;
+ loadClient.didChangeBackForwardList = didChangeBackForwardList;
+ WKPageSetPageLoaderClient(pageRef, &loadClient);
+}
+
+void QtWebPageLoadClient::didStartProvisionalLoadForFrame()
+{
+ emit m_webView->navigationStateChanged();
+ emit m_webView->loadStarted();
+}
+
+void QtWebPageLoadClient::didCommitLoadForFrame(const QUrl& url)
+{
+ emit m_webView->navigationStateChanged();
+ emit m_webView->urlChanged(url);
+ m_webView->d_func()->loadDidCommit();
+}
+
+void QtWebPageLoadClient::didSameDocumentNavigationForFrame(const QUrl& url)
+{
+ emit m_webView->navigationStateChanged();
+ emit m_webView->urlChanged(url);
+}
+
+void QtWebPageLoadClient::didReceiveTitleForFrame(const QString& title)
+{
+ emit m_webView->titleChanged(title);
+}
+
+void QtWebPageLoadClient::didFirstVisuallyNonEmptyLayoutForFrame()
+{
+ m_webView->d_func()->didFinishFirstNonEmptyLayout();
+}
+
+void QtWebPageLoadClient::didChangeBackForwardList()
+{
+ m_webView->d_func()->didChangeBackForwardList();
+}
+
+void QtWebPageLoadClient::dispatchLoadSucceeded()
+{
+ emit m_webView->navigationStateChanged();
+ emit m_webView->loadSucceeded();
+}
+
+void QtWebPageLoadClient::dispatchLoadFailed(WKErrorRef error)
+{
+ emit m_webView->navigationStateChanged();
+
+ int errorCode = WKErrorGetErrorCode(error);
+ if (toImpl(error)->platformError().isCancellation() || errorCode == kWKErrorCodeFrameLoadInterruptedByPolicyChange || errorCode == kWKErrorCodePlugInWillHandleLoad)
+ return;
+
+ QtWebError qtError(error);
+ emit m_webView->loadFailed(static_cast<QQuickWebView::ErrorDomain>(qtError.type()), qtError.errorCode(), qtError.url(), qtError.description());
+}
+
+void QtWebPageLoadClient::setLoadProgress(int loadProgress)
+{
+ m_loadProgress = loadProgress;
+ emit m_webView->loadProgressChanged(m_loadProgress);
+}
+
+static QtWebPageLoadClient* toQtWebPageLoadClient(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtWebPageLoadClient*>(const_cast<void*>(clientInfo));
+}
+
+void QtWebPageLoadClient::didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ toQtWebPageLoadClient(clientInfo)->didStartProvisionalLoadForFrame();
+}
+
+void QtWebPageLoadClient::didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(error);
+}
+
+void QtWebPageLoadClient::didCommitLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ WebFrameProxy* wkframe = toImpl(frame);
+ QString urlStr(wkframe->url());
+ QUrl qUrl = urlStr;
+ toQtWebPageLoadClient(clientInfo)->didCommitLoadForFrame(qUrl);
+}
+
+void QtWebPageLoadClient::didFinishLoadForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ toQtWebPageLoadClient(clientInfo)->dispatchLoadSucceeded();
+}
+
+void QtWebPageLoadClient::didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef frame, WKErrorRef error, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ toQtWebPageLoadClient(clientInfo)->dispatchLoadFailed(error);
+}
+
+void QtWebPageLoadClient::didSameDocumentNavigationForFrame(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void* clientInfo)
+{
+ WebFrameProxy* wkframe = toImpl(frame);
+ QString urlStr(wkframe->url());
+ QUrl qUrl = urlStr;
+ toQtWebPageLoadClient(clientInfo)->didSameDocumentNavigationForFrame(qUrl);
+}
+
+void QtWebPageLoadClient::didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef frame, WKTypeRef, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ QString qTitle = WKStringCopyQString(title);
+ toQtWebPageLoadClient(clientInfo)->didReceiveTitleForFrame(qTitle);
+}
+
+void QtWebPageLoadClient::didStartProgress(WKPageRef, const void* clientInfo)
+{
+ QtWebPageLoadClient* client = toQtWebPageLoadClient(clientInfo);
+ client->setLoadProgress(0);
+ client->m_webView->d_func()->setIcon(QUrl());
+}
+
+void QtWebPageLoadClient::didChangeProgress(WKPageRef page, const void* clientInfo)
+{
+ toQtWebPageLoadClient(clientInfo)->setLoadProgress(WKPageGetEstimatedProgress(page) * 100);
+}
+
+void QtWebPageLoadClient::didFinishProgress(WKPageRef, const void* clientInfo)
+{
+ toQtWebPageLoadClient(clientInfo)->setLoadProgress(100);
+}
+
+void QtWebPageLoadClient::didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFrameRef frame, WKTypeRef, const void *clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ toQtWebPageLoadClient(clientInfo)->didFirstVisuallyNonEmptyLayoutForFrame();
+}
+
+void QtWebPageLoadClient::didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo)
+{
+ toQtWebPageLoadClient(clientInfo)->didChangeBackForwardList();
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.h
new file mode 100644
index 000000000..fbdb92e7b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.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 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 QtWebPageLoadClient_h
+#define QtWebPageLoadClient_h
+
+#include "QtWebError.h"
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <WKPage.h>
+
+class QQuickWebView;
+
+class QtWebPageLoadClient {
+public:
+ QtWebPageLoadClient(WKPageRef, QQuickWebView*);
+
+ int loadProgress() const { return m_loadProgress; }
+
+private:
+ void didStartProvisionalLoadForFrame();
+ void didCommitLoadForFrame(const QUrl&);
+ void didSameDocumentNavigationForFrame(const QUrl&);
+ void didReceiveTitleForFrame(const QString&);
+ void didFirstVisuallyNonEmptyLayoutForFrame();
+ void didChangeBackForwardList();
+
+ void dispatchLoadSucceeded();
+ void dispatchLoadFailed(WKErrorRef);
+ void setLoadProgress(int);
+
+ // WKPageLoadClient callbacks.
+ static void didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+ static void didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo);
+ static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+ static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+ static void didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef userData, const void* clientInfo);
+ static void didSameDocumentNavigationForFrame(WKPageRef, WKFrameRef, WKSameDocumentNavigationType, WKTypeRef userData, const void* clientInfo);
+ static void didReceiveTitleForFrame(WKPageRef, WKStringRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+ static void didStartProgress(WKPageRef, const void* clientInfo);
+ static void didChangeProgress(WKPageRef, const void* clientInfo);
+ static void didFinishProgress(WKPageRef, const void* clientInfo);
+ static void didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef userData, const void* clientInfo);
+ static void didChangeBackForwardList(WKPageRef, WKBackForwardListItemRef, WKArrayRef, const void *clientInfo);
+
+ QQuickWebView* m_webView;
+ int m_loadProgress;
+};
+
+#endif // QtWebPageLoadClient_h
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp
new file mode 100644
index 000000000..e77fb1463
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.cpp
@@ -0,0 +1,136 @@
+/*
+ * 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 "QtWebPagePolicyClient.h"
+
+#include "WKFrame.h"
+#include "WKURLQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include "qwebnavigationrequest_p.h"
+#include <QtCore/QObject>
+#include <WKFramePolicyListener.h>
+#include <WKURLRequest.h>
+
+QtWebPagePolicyClient::QtWebPagePolicyClient(WKPageRef pageRef, QQuickWebView* webView)
+ : m_webView(webView)
+{
+ WKPagePolicyClient policyClient;
+ memset(&policyClient, 0, sizeof(WKPagePolicyClient));
+ policyClient.version = kWKPagePolicyClientCurrentVersion;
+ policyClient.clientInfo = this;
+ policyClient.decidePolicyForNavigationAction = decidePolicyForNavigationAction;
+ policyClient.decidePolicyForResponse = decidePolicyForResponse;
+ WKPageSetPagePolicyClient(pageRef, &policyClient);
+}
+
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton mouseButton, Qt::KeyboardModifiers keyboardModifiers, WKFramePolicyListenerRef listener)
+{
+ // NOTE: even though the C API (and the WebKit2 IPC) supports an asynchronous answer, this is not currently working.
+ // We are expected to call the listener immediately. See the patch for https://bugs.webkit.org/show_bug.cgi?id=53785.
+ QWebNavigationRequest navigationRequest(url, originatingUrl, mouseButton, keyboardModifiers);
+ emit m_webView->navigationRequested(&navigationRequest);
+
+ switch (navigationRequest.action()) {
+ case QQuickWebView::IgnoreRequest:
+ WKFramePolicyListenerIgnore(listener);
+ return;
+ case QQuickWebViewExperimental::DownloadRequest:
+ WKFramePolicyListenerDownload(listener);
+ return;
+ case QQuickWebView::AcceptRequest:
+ WKFramePolicyListenerUse(listener);
+ return;
+ }
+ ASSERT_NOT_REACHED();
+}
+
+static inline QtWebPagePolicyClient* toQtWebPagePolicyClient(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtWebPagePolicyClient*>(const_cast<void*>(clientInfo));
+}
+
+static Qt::MouseButton toQtMouseButton(WKEventMouseButton button)
+{
+ switch (button) {
+ case kWKEventMouseButtonLeftButton:
+ return Qt::LeftButton;
+ case kWKEventMouseButtonMiddleButton:
+ return Qt::MiddleButton;
+ case kWKEventMouseButtonRightButton:
+ return Qt::RightButton;
+ case kWKEventMouseButtonNoButton:
+ return Qt::NoButton;
+ }
+ ASSERT_NOT_REACHED();
+ return Qt::NoButton;
+}
+
+static Qt::KeyboardModifiers toQtKeyboardModifiers(WKEventModifiers modifiers)
+{
+ Qt::KeyboardModifiers qtModifiers = Qt::NoModifier;
+ if (modifiers & kWKEventModifiersShiftKey)
+ qtModifiers |= Qt::ShiftModifier;
+ if (modifiers & kWKEventModifiersControlKey)
+ qtModifiers |= Qt::ControlModifier;
+ if (modifiers & kWKEventModifiersAltKey)
+ qtModifiers |= Qt::AltModifier;
+ if (modifiers & kWKEventModifiersMetaKey)
+ qtModifiers |= Qt::MetaModifier;
+ return qtModifiers;
+}
+
+void QtWebPagePolicyClient::decidePolicyForNavigationAction(WKPageRef, WKFrameRef frame, WKFrameNavigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef, const void* clientInfo)
+{
+ WKRetainPtr<WKURLRef> frameURL(AdoptWK, WKFrameCopyURL(frame));
+ WKRetainPtr<WKURLRef> requestURL(AdoptWK, WKURLRequestCopyURL(request));
+ QUrl qUrlFrame = WKURLCopyQUrl(frameURL.get());
+ QUrl qUrl = WKURLCopyQUrl(requestURL.get());
+ toQtWebPagePolicyClient(clientInfo)->decidePolicyForNavigationAction(qUrl, qUrlFrame, toQtMouseButton(mouseButton), toQtKeyboardModifiers(modifiers), listener);
+}
+
+void QtWebPagePolicyClient::decidePolicyForResponse(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef, WKFramePolicyListenerRef listener, WKTypeRef, const void*)
+{
+ String type = toImpl(response)->resourceResponse().mimeType();
+ type.makeLower();
+ bool canShowMIMEType = toImpl(frame)->canShowMIMEType(type);
+
+ if (WKPageGetMainFrame(page) == frame) {
+ if (canShowMIMEType) {
+ WKFramePolicyListenerUse(listener);
+ return;
+ }
+
+ // If we can't use (show) it then we should download it.
+ WKFramePolicyListenerDownload(listener);
+ return;
+ }
+
+ // We should ignore downloadable top-level content for subframes, with an exception for text/xml and application/xml so we can still support Acid3 test.
+ // It makes the browser intentionally behave differently when it comes to text(application)/xml content in subframes vs. mainframe.
+ if (!canShowMIMEType && !(type == "text/xml" || type == "application/xml")) {
+ WKFramePolicyListenerIgnore(listener);
+ return;
+ }
+
+ WKFramePolicyListenerUse(listener);
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h
new file mode 100644
index 000000000..8c6021398
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPagePolicyClient.h
@@ -0,0 +1,43 @@
+/*
+ * 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 QtWebPagePolicyClient_h
+#define QtWebPagePolicyClient_h
+
+#include <QtCore/QUrl>
+#include <WKPage.h>
+
+class QQuickWebView;
+
+class QtWebPagePolicyClient {
+public:
+ QtWebPagePolicyClient(WKPageRef, QQuickWebView*);
+
+private:
+ void decidePolicyForNavigationAction(const QUrl&, const QUrl&, Qt::MouseButton, Qt::KeyboardModifiers, WKFramePolicyListenerRef);
+
+ // WKPagePolicyClient callbacks.
+ static void decidePolicyForNavigationAction(WKPageRef, WKFrameRef, WKFrameNavigationType, WKEventModifiers, WKEventMouseButton, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
+ static void decidePolicyForResponse(WKPageRef, WKFrameRef, WKURLResponseRef, WKURLRequestRef, WKFramePolicyListenerRef, WKTypeRef userData, const void* clientInfo);
+
+ QQuickWebView* m_webView;
+};
+
+#endif // QtWebPagePolicyClient_h
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp
new file mode 100644
index 000000000..ef764c5c9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.cpp
@@ -0,0 +1,147 @@
+/*
+ * 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 "QtWebPageUIClient.h"
+
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include "qwebpermissionrequest_p.h"
+#include <WKAPICast.h>
+#include <WKHitTestResult.h>
+#include <WKOpenPanelParameters.h>
+#include <WKOpenPanelResultListener.h>
+
+QtWebPageUIClient::QtWebPageUIClient(WKPageRef pageRef, QQuickWebView* webView)
+ : m_webView(webView)
+{
+ WKPageUIClient uiClient;
+ memset(&uiClient, 0, sizeof(WKPageUIClient));
+ uiClient.version = kWKPageUIClientCurrentVersion;
+ uiClient.clientInfo = this;
+ uiClient.runJavaScriptAlert = runJavaScriptAlert;
+ uiClient.runJavaScriptConfirm = runJavaScriptConfirm;
+ uiClient.runJavaScriptPrompt = runJavaScriptPrompt;
+ uiClient.runOpenPanel = runOpenPanel;
+ uiClient.mouseDidMoveOverElement = mouseDidMoveOverElement;
+ uiClient.decidePolicyForGeolocationPermissionRequest = policyForGeolocationPermissionRequest;
+ WKPageSetPageUIClient(pageRef, &uiClient);
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(const QString& message)
+{
+ m_webView->d_func()->runJavaScriptAlert(message);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(const QString& message)
+{
+ return m_webView->d_func()->runJavaScriptConfirm(message);
+}
+
+QString QtWebPageUIClient::runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok)
+{
+ return m_webView->d_func()->runJavaScriptPrompt(message, defaultValue, ok);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKOpenPanelResultListenerRef listenerRef, const QStringList& selectedFileNames, FileChooserType type)
+{
+ m_webView->d_func()->chooseFiles(listenerRef, selectedFileNames, type);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle)
+{
+ if (linkURL == m_lastHoveredURL && linkTitle == m_lastHoveredTitle)
+ return;
+ m_lastHoveredURL = linkURL;
+ m_lastHoveredTitle = linkTitle;
+ emit m_webView->linkHovered(m_lastHoveredURL, m_lastHoveredTitle);
+}
+
+void QtWebPageUIClient::permissionRequest(QWebPermissionRequest* request)
+{
+ request->setParent(m_webView);
+ emit m_webView->experimental()->permissionRequested(request);
+}
+
+static QtWebPageUIClient* toQtWebPageUIClient(const void* clientInfo)
+{
+ ASSERT(clientInfo);
+ return reinterpret_cast<QtWebPageUIClient*>(const_cast<void*>(clientInfo));
+}
+
+void QtWebPageUIClient::runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo)
+{
+ QString qAlertText = WKStringCopyQString(alertText);
+ toQtWebPageUIClient(clientInfo)->runJavaScriptAlert(qAlertText);
+}
+
+bool QtWebPageUIClient::runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo)
+{
+ QString qMessage = WKStringCopyQString(message);
+ return toQtWebPageUIClient(clientInfo)->runJavaScriptConfirm(qMessage);
+}
+
+static inline WKStringRef createNullWKString()
+{
+ RefPtr<WebString> webString = WebString::createNull();
+ return toAPI(webString.release().leakRef());
+}
+
+WKStringRef QtWebPageUIClient::runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo)
+{
+ QString qMessage = WKStringCopyQString(message);
+ QString qDefaultValue = WKStringCopyQString(defaultValue);
+ bool ok = false;
+ QString result = toQtWebPageUIClient(clientInfo)->runJavaScriptPrompt(qMessage, qDefaultValue, ok);
+ if (!ok)
+ return createNullWKString();
+ return WKStringCreateWithQString(result);
+}
+
+void QtWebPageUIClient::runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo)
+{
+ Vector<String> wkSelectedFileNames = toImpl(parameters)->selectedFileNames();
+
+ QStringList selectedFileNames;
+ for (size_t i = 0; i < wkSelectedFileNames.size(); ++i)
+ selectedFileNames += wkSelectedFileNames.at(i);
+
+ FileChooserType allowMultipleFiles = WKOpenPanelParametersGetAllowsMultipleFiles(parameters) ? MultipleFilesSelection : SingleFileSelection;
+ toQtWebPageUIClient(clientInfo)->runOpenPanel(listener, selectedFileNames, allowMultipleFiles);
+}
+
+void QtWebPageUIClient::mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
+{
+ const QUrl absoluteLinkUrl = WKURLCopyQUrl(adoptWK(WKHitTestResultCopyAbsoluteLinkURL(hitTestResult)).get());
+ const QString linkTitle = WKStringCopyQString(adoptWK(WKHitTestResultCopyLinkTitle(hitTestResult)).get());
+ toQtWebPageUIClient(clientInfo)->mouseDidMoveOverElement(absoluteLinkUrl, linkTitle);
+}
+
+void QtWebPageUIClient::policyForGeolocationPermissionRequest(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef request, const void* clientInfo)
+{
+ if (!request)
+ return;
+
+ QWebPermissionRequest* req = QWebPermissionRequest::create(origin, request);
+ toQtWebPageUIClient(clientInfo)->permissionRequest(req);
+}
+
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h
new file mode 100644
index 000000000..8cfe13c21
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageUIClient.h
@@ -0,0 +1,64 @@
+/*
+ * 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 QtWebPageUIClient_h
+#define QtWebPageUIClient_h
+
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <WKFrame.h>
+#include <WKGeolocationPermissionRequest.h>
+#include <WKPage.h>
+#include <WKSecurityOrigin.h>
+
+class QQuickWebView;
+class QWebPermissionRequest;
+
+class QtWebPageUIClient {
+public:
+ enum FileChooserType {
+ SingleFileSelection,
+ MultipleFilesSelection
+ };
+
+ QtWebPageUIClient(WKPageRef, QQuickWebView*);
+
+private:
+ void runJavaScriptAlert(const QString& message);
+ bool runJavaScriptConfirm(const QString& message);
+ QString runJavaScriptPrompt(const QString& message, const QString& defaultValue, bool& ok);
+ void runOpenPanel(WKOpenPanelResultListenerRef, const QStringList& selectedFileNames, FileChooserType);
+ void mouseDidMoveOverElement(const QUrl& linkURL, const QString& linkTitle);
+ void permissionRequest(QWebPermissionRequest*);
+
+ // WKPageUIClient callbacks.
+ static void runJavaScriptAlert(WKPageRef, WKStringRef alertText, WKFrameRef, const void* clientInfo);
+ static bool runJavaScriptConfirm(WKPageRef, WKStringRef message, WKFrameRef, const void* clientInfo);
+ static WKStringRef runJavaScriptPrompt(WKPageRef, WKStringRef message, WKStringRef defaultValue, WKFrameRef, const void* clientInfo);
+ static void runOpenPanel(WKPageRef, WKFrameRef, WKOpenPanelParametersRef, WKOpenPanelResultListenerRef, const void* clientInfo);
+ static void mouseDidMoveOverElement(WKPageRef, WKHitTestResultRef, WKEventModifiers, WKTypeRef userData, const void* clientInfo);
+ static void policyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKGeolocationPermissionRequestRef, const void*);
+
+ QQuickWebView* m_webView;
+ QUrl m_lastHoveredURL;
+ QString m_lastHoveredTitle;
+};
+
+#endif // QtWebPageUIClient_h
diff --git a/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp b/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp
new file mode 100644
index 000000000..62d31e8ab
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebUndoController.cpp
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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 "QtWebUndoController.h"
+
+#include <qglobal.h>
+#include <wtf/RefPtr.h>
+
+using namespace WebKit;
+
+void QtWebUndoController::registerEditCommand(PassRefPtr<WebEditCommandProxy> command, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (undoOrRedo == WebPageProxy::Undo)
+ m_undoStack.append(command);
+ else
+ m_redoStack.append(command);
+}
+
+void QtWebUndoController::clearAllEditCommands()
+{
+ m_undoStack.clear();
+ m_redoStack.clear();
+}
+
+bool QtWebUndoController::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (undoOrRedo == WebPageProxy::Undo)
+ return !m_undoStack.isEmpty();
+ else
+ return !m_redoStack.isEmpty();
+}
+
+void QtWebUndoController::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ RefPtr<WebEditCommandProxy> command;
+ if (undoOrRedo == WebPageProxy::Undo) {
+ command = m_undoStack.last();
+ m_undoStack.removeLast();
+ command->unapply();
+ } else {
+ command = m_redoStack.last();
+ m_redoStack.removeLast();
+ command->reapply();
+ }
+}
diff --git a/Source/WebKit2/UIProcess/qt/QtWebUndoController.h b/Source/WebKit2/UIProcess/qt/QtWebUndoController.h
new file mode 100644
index 000000000..a260ca2fd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/QtWebUndoController.h
@@ -0,0 +1,41 @@
+/*
+ Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
+ Copyright (C) 2007 Staikos Computing Services Inc.
+
+ 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 QtWebUndoController_h
+#define QtWebUndoController_h
+
+#include "PageClient.h"
+#include "WebEditCommandProxy.h"
+#include "WebPageProxy.h"
+
+class QtWebUndoController {
+public:
+ // Page Client.
+ void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
+ void clearAllEditCommands();
+ bool canUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
+ void executeUndoRedo(WebKit::WebPageProxy::UndoOrRedo);
+
+ typedef Vector<RefPtr<WebKit::WebEditCommandProxy> > CommandVector;
+ CommandVector m_undoStack;
+ CommandVector m_redoStack;
+};
+
+#endif // QtWebUndoController_h
diff --git a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp
new file mode 100644
index 000000000..4a3318405
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp
@@ -0,0 +1,129 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "TextCheckerState.h"
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static TextCheckerState textCheckerState;
+
+const TextCheckerState& TextChecker::state()
+{
+ notImplemented();
+
+ return textCheckerState;
+}
+
+bool TextChecker::isContinuousSpellCheckingAllowed()
+{
+ notImplemented();
+
+ return false;
+}
+
+void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+{
+ notImplemented();
+}
+
+void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
+{
+ notImplemented();
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ notImplemented();
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ notImplemented();
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
+{
+ notImplemented();
+}
+
+void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
+{
+ notImplemented();
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ notImplemented();
+ return false;
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ notImplemented();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&)
+{
+ notImplemented();
+}
+
+void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
+void TextChecker::learnWord(int64_t, const String&)
+{
+ notImplemented();
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp
new file mode 100644
index 000000000..2c76062f5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp
@@ -0,0 +1,83 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "TiledDrawingAreaProxy.h"
+
+#include "QtSGUpdateQueue.h"
+#include "qquickwebpage_p.h"
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+#include "WKAPICast.h"
+#include "WebPageProxy.h"
+
+using namespace WebCore;
+
+#define TILE_DEBUG_LOG
+
+namespace WebKit {
+
+void TiledDrawingAreaProxy::updateWebView(const Vector<IntRect>& paintedArea)
+{
+ // SG updates are triggered through QtSGUpdateQueue.
+}
+
+WebPageProxy* TiledDrawingAreaProxy::page()
+{
+ return m_webPageProxy;
+}
+
+void TiledDrawingAreaProxy::createTile(int tileID, const UpdateInfo& updateInfo)
+{
+ int nodeID = m_webView->sceneGraphUpdateQueue()->createTileNode(updateInfo.updateScaleFactor);
+ m_tileNodeMap.set(tileID, nodeID);
+ updateTile(tileID, updateInfo);
+}
+
+void TiledDrawingAreaProxy::updateTile(int tileID, const UpdateInfo& updateInfo)
+{
+ int nodeID = m_tileNodeMap.get(tileID);
+ ASSERT(nodeID);
+
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle);
+ // FIXME: We could avoid this copy by carying the ShareableBitmap all the way up to texture uploading.
+ // Currently won't work since the SharedMemory handle is owned by updateInfo.
+ QImage image(bitmap->createQImage().copy());
+ QRect sourceRect(0, 0, updateInfo.updateRectBounds.width(), updateInfo.updateRectBounds.height());
+ m_webView->sceneGraphUpdateQueue()->setNodeBackBuffer(nodeID, image, sourceRect, updateInfo.updateRectBounds);
+}
+
+void TiledDrawingAreaProxy::didRenderFrame()
+{
+ m_webView->sceneGraphUpdateQueue()->swapTileBuffers();
+}
+
+void TiledDrawingAreaProxy::removeTile(int tileID)
+{
+ int nodeID = m_tileNodeMap.take(tileID);
+ m_webView->sceneGraphUpdateQueue()->removeTileNode(nodeID);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp
new file mode 100644
index 000000000..b00951014
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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.
+ */
+
+#include "config.h"
+#include "WebContextMenuProxyQt.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebContextMenuProxyQt::WebContextMenuProxyQt(WebPageProxy*)
+{
+}
+
+PassRefPtr<WebContextMenuProxyQt> WebContextMenuProxyQt::create(WebPageProxy* webPageProxy)
+{
+ return adoptRef(new WebContextMenuProxyQt(webPageProxy));
+}
+
+void WebContextMenuProxyQt::showContextMenu(const IntPoint& position, const Vector<WebContextMenuItemData>& items)
+{
+}
+
+void WebContextMenuProxyQt::hideContextMenu()
+{
+}
+
+#include "moc_WebContextMenuProxyQt.cpp"
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h
new file mode 100644
index 000000000..bd7aebd6f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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 WebContextMenuProxyQt_h
+#define WebContextMenuProxyQt_h
+
+#include "WebContextMenuProxy.h"
+#include <QtCore/QObject>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebContextMenuProxyQt : public QObject, public WebContextMenuProxy {
+ Q_OBJECT
+public:
+ static PassRefPtr<WebContextMenuProxyQt> create(WebPageProxy*);
+
+private:
+ WebContextMenuProxyQt(WebPageProxy*);
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ virtual void hideContextMenu();
+};
+
+} // namespace WebKit
+
+#endif // WebContextMenuProxyQt_h
diff --git a/Source/WebKit2/UIProcess/qt/WebContextQt.cpp b/Source/WebKit2/UIProcess/qt/WebContextQt.cpp
new file mode 100644
index 000000000..b0d5ac4ba
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextQt.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010 University of Szeged
+ *
+ * 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 "WebContext.h"
+
+#include "ApplicationCacheStorage.h"
+#include "FileSystem.h"
+#include "WKSharedAPICast.h"
+#if ENABLE(GEOLOCATION)
+#include "WebGeolocationProviderQt.h"
+#endif
+#include "WebProcessCreationParameters.h"
+
+#include <QCoreApplication>
+#include <QStandardPaths>
+#include <QDir>
+#include <QProcess>
+
+namespace WebKit {
+
+static QString defaultDataLocation()
+{
+ static QString s_dataLocation;
+
+ if (!s_dataLocation.isEmpty())
+ return s_dataLocation;
+
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
+ if (dataLocation.isEmpty())
+ dataLocation = WebCore::pathByAppendingComponent(QDir::homePath(), QCoreApplication::applicationName());
+ s_dataLocation = WebCore::pathByAppendingComponent(dataLocation, ".QtWebKit/");
+ WebCore::makeAllDirectories(s_dataLocation);
+ return s_dataLocation;
+}
+
+static QString s_defaultDatabaseDirectory;
+static QString s_defaultLocalStorageDirectory;
+
+String WebContext::applicationCacheDirectory()
+{
+ return WebCore::cacheStorage().cacheDirectory();
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
+{
+ qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
+ parameters.cookieStorageDirectory = defaultDataLocation();
+#if ENABLE(GEOLOCATION)
+ static WebGeolocationProviderQt* location = WebGeolocationProviderQt::create(toAPI(geolocationManagerProxy()));
+ WKGeolocationManagerSetProvider(toAPI(geolocationManagerProxy()), WebGeolocationProviderQt::provider(location));
+#endif
+}
+
+void WebContext::platformInvalidateContext()
+{
+}
+
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+ if (!s_defaultDatabaseDirectory.isEmpty())
+ return s_defaultDatabaseDirectory;
+
+ s_defaultDatabaseDirectory = defaultDataLocation() + QLatin1String("Databases");
+ QDir().mkpath(s_defaultDatabaseDirectory);
+ return s_defaultDatabaseDirectory;
+}
+
+String WebContext::platformDefaultIconDatabasePath() const
+{
+ return defaultDataLocation() + QLatin1String("WebpageIcons.db");
+}
+
+String WebContext::platformDefaultLocalStorageDirectory() const
+{
+ if (!s_defaultLocalStorageDirectory.isEmpty())
+ return s_defaultLocalStorageDirectory;
+
+ s_defaultLocalStorageDirectory = defaultDataLocation() + QLatin1String("LocalStorage");
+ QDir().mkpath(s_defaultLocalStorageDirectory);
+ return s_defaultLocalStorageDirectory;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebFullScreenManagerProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebFullScreenManagerProxyQt.cpp
new file mode 100644
index 000000000..c4a13fad8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebFullScreenManagerProxyQt.cpp
@@ -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 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 "WebFullScreenManagerProxy.h"
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "WebContext.h"
+#include "WebFullScreenManagerMessages.h"
+#include "WebFullScreenManagerProxyMessages.h"
+#include "WebProcess.h"
+
+#include <WebCore/NotImplemented.h>
+
+namespace WebKit {
+
+void WebFullScreenManagerProxy::invalidate()
+{
+ m_webView = 0;
+}
+
+void WebFullScreenManagerProxy::enterFullScreen()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::exitFullScreen()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::beganEnterFullScreenAnimation()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::finishedEnterFullScreenAnimation(bool completed)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::beganExitFullScreenAnimation()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::finishedExitFullScreenAnimation(bool completed)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::enterAcceleratedCompositingMode(const LayerTreeContext& context)
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::exitAcceleratedCompositingMode()
+{
+ notImplemented();
+}
+
+void WebFullScreenManagerProxy::getFullScreenRect(WebCore::IntRect& rect)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(FULLSCREEN_API)
diff --git a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp
new file mode 100644
index 000000000..70d7b5733
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.cpp
@@ -0,0 +1,119 @@
+/*
+ * 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 "WebGeolocationProviderQt.h"
+
+#if ENABLE(GEOLOCATION)
+
+#include <QtLocation/QGeoPositionInfoSource>
+
+using namespace WebKit;
+
+static inline const WebGeolocationProviderQt* toLocationProvider(const void* clientInfo)
+{
+ return static_cast<const WebGeolocationProviderQt*>(clientInfo);
+}
+
+static void locationStartUpdating(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
+{
+ toLocationProvider(clientInfo)->startUpdating();
+}
+
+static void locationStopUpdating(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
+{
+ toLocationProvider(clientInfo)->stopUpdating();
+}
+
+WebGeolocationProviderQt* WebGeolocationProviderQt::create(WKGeolocationManagerRef manager)
+{
+ return new WebGeolocationProviderQt(manager);
+}
+
+WKGeolocationProvider* WebGeolocationProviderQt::provider(const WebGeolocationProviderQt* location)
+{
+ static WKGeolocationProvider provider = {
+ 0, // This features the version.
+ location, // This points to the object implementer.
+ locationStartUpdating, // The callbacks are next.
+ locationStopUpdating
+ };
+
+ return &provider;
+}
+
+WebGeolocationProviderQt::WebGeolocationProviderQt(WKGeolocationManagerRef manager)
+ : m_manager(manager)
+ , m_source(0)
+{
+}
+
+WebGeolocationProviderQt::~WebGeolocationProviderQt()
+{
+}
+
+void WebGeolocationProviderQt::updateTimeout()
+{
+ WKGeolocationManagerProviderDidFailToDeterminePosition(m_manager);
+}
+
+void WebGeolocationProviderQt::positionUpdated(const QGeoPositionInfo& geoPosition)
+{
+ if (!geoPosition.isValid())
+ return;
+
+ QGeoCoordinate coord = geoPosition.coordinate();
+ double latitude = coord.latitude();
+ double longitude = coord.longitude();
+ double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy);
+ double timeStampInSeconds = geoPosition.timestamp().toMSecsSinceEpoch() / 1000;
+
+ m_lastPosition.adopt(WKGeolocationPositionCreate(timeStampInSeconds, latitude, longitude, accuracy));
+
+ WKGeolocationManagerProviderDidChangePosition(m_manager, m_lastPosition.get());
+}
+
+void WebGeolocationProviderQt::startUpdating() const
+{
+ if (!m_source) {
+ if (!(m_source = QGeoPositionInfoSource::createDefaultSource(const_cast<WebGeolocationProviderQt*>(this)))) {
+ // Let the manager known that the provider is not available.
+ WKGeolocationManagerSetProvider(m_manager, 0);
+ // Notify failure at retrieving the position.
+ WKGeolocationManagerProviderDidFailToDeterminePosition(m_manager);
+ return;
+ }
+
+ connect(m_source, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
+ connect(m_source, SIGNAL(updateTimeout()), this, SLOT(updateTimeout()));
+ }
+
+ m_source->startUpdates();
+}
+
+void WebGeolocationProviderQt::stopUpdating() const
+{
+ if (m_source)
+ m_source->stopUpdates();
+}
+
+#include "moc_WebGeolocationProviderQt.cpp"
+
+#endif // ENABLE(GEOLOCATION)
diff --git a/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h
new file mode 100644
index 000000000..e59e3d75b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebGeolocationProviderQt.h
@@ -0,0 +1,56 @@
+/*
+ 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 WebGeolocationProviderQt_h
+#define WebGeolocationProviderQt_h
+
+#include <QObject>
+#include <WebKit2/WKGeolocationManager.h>
+#include <WebKit2/WKGeolocationPosition.h>
+#include <WebKit2/WKRetainPtr.h>
+
+class QGeoPositionInfoSource;
+class QGeoPositionInfo;
+
+class WebGeolocationProviderQt : public QObject {
+ Q_OBJECT
+public:
+ static WebGeolocationProviderQt* create(WKGeolocationManagerRef);
+ static WKGeolocationProvider* provider(const WebGeolocationProviderQt*);
+
+ virtual ~WebGeolocationProviderQt();
+
+ void startUpdating() const;
+ void stopUpdating() const;
+
+public Q_SLOTS:
+ void updateTimeout();
+ void positionUpdated(const QGeoPositionInfo&);
+
+private:
+ Q_DISABLE_COPY(WebGeolocationProviderQt);
+ WebGeolocationProviderQt(WKGeolocationManagerRef);
+
+ WKGeolocationManagerRef m_manager;
+ WKRetainPtr<WKGeolocationPositionRef> m_lastPosition;
+ mutable QGeoPositionInfoSource* m_source;
+};
+
+#endif /* WebGeolocationProviderQt_h */
diff --git a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
new file mode 100644
index 000000000..6b69e9975
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <WebCore/NotImplemented.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String&)
+{
+ notImplemented();
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
+{
+ notImplemented();
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ notImplemented();
+ return String();
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ notImplemented();
+ return String();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp
new file mode 100644
index 000000000..ac9fde418
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "PageClient.h"
+#include "QtNetworkReplyData.h"
+#include "QtPageClient.h"
+#include "qquicknetworkreply_p.h"
+#include "WebPageMessages.h"
+#include "WebProcessProxy.h"
+#include <WebCore/Editor.h>
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ // FIXME: This should not be hard coded.
+ return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4";
+}
+
+void WebPageProxy::saveRecentSearches(const String&, const Vector<String>&)
+{
+ notImplemented();
+}
+
+void WebPageProxy::loadRecentSearches(const String&, Vector<String>&)
+{
+ notImplemented();
+}
+
+void WebPageProxy::setComposition(const String& text, Vector<CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
+{
+ // FIXME: We need to find out how to proper handle the crashes case.
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SetComposition(text, underlines, selectionStart, selectionEnd, replacementRangeStart, replacementRangeEnd), m_pageID);
+}
+
+void WebPageProxy::confirmComposition(const String& compositionString, int64_t selectionStart, int64_t selectionLength)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::ConfirmComposition(compositionString, selectionStart, selectionLength), m_pageID);
+}
+
+void WebPageProxy::cancelComposition()
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::CancelComposition(), m_pageID);
+}
+
+void WebPageProxy::registerApplicationScheme(const String& scheme)
+{
+ process()->send(Messages::WebPage::RegisterApplicationScheme(scheme), m_pageID);
+}
+
+void WebPageProxy::resolveApplicationSchemeRequest(QtNetworkRequestData request)
+{
+ RefPtr<QtNetworkRequestData> requestData = adoptRef(new QtNetworkRequestData(request));
+ m_applicationSchemeRequests.add(requestData);
+ static_cast<QtPageClient*>(m_pageClient)->handleApplicationSchemeRequest(requestData);
+}
+
+void WebPageProxy::sendApplicationSchemeReply(const QQuickNetworkReply* reply)
+{
+ RefPtr<QtNetworkRequestData> requestData = reply->networkRequestData();
+ if (m_applicationSchemeRequests.contains(requestData)) {
+ RefPtr<QtNetworkReplyData> replyData = reply->networkReplyData();
+ process()->send(Messages::WebPage::ApplicationSchemeReply(*replyData), pageID());
+ m_applicationSchemeRequests.remove(requestData);
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
new file mode 100644
index 000000000..4c0deadc2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -0,0 +1,316 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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 "WebPopupMenuProxyQt.h"
+
+#include "PlatformPopupMenuData.h"
+#include "WebPopupItem.h"
+#include "qquickwebview_p.h"
+#include "qquickwebview_p_p.h"
+#include <QtCore/QAbstractListModel>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeEngine>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static QHash<int, QByteArray> createRoleNamesHash();
+
+class PopupMenuItemModel : public QAbstractListModel {
+ Q_OBJECT
+
+public:
+ enum Roles {
+ GroupRole = Qt::UserRole,
+ EnabledRole = Qt::UserRole + 1,
+ SelectedRole = Qt::UserRole + 2,
+ IsSeparatorRole = Qt::UserRole + 3
+ };
+
+ PopupMenuItemModel(const Vector<WebPopupItem>&, int selectedOriginalIndex);
+ virtual int rowCount(const QModelIndex& parent = QModelIndex()) const { return m_items.size(); }
+ virtual QVariant data(const QModelIndex&, int role = Qt::DisplayRole) const;
+
+ Q_INVOKABLE void select(int);
+
+ int selectedOriginalIndex() const;
+
+private:
+ struct Item {
+ Item(const WebPopupItem& webPopupItem, const QString& group, int originalIndex, bool selected)
+ : text(webPopupItem.m_text)
+ , toolTip(webPopupItem.m_toolTip)
+ , group(group)
+ , originalIndex(originalIndex)
+ , enabled(webPopupItem.m_isEnabled)
+ , selected(selected)
+ , isSeparator(webPopupItem.m_type == WebPopupItem::Separator)
+ { }
+
+ QString text;
+ QString toolTip;
+ QString group;
+ // Keep track of originalIndex because we don't add the label (group) items to our vector.
+ int originalIndex;
+ bool enabled;
+ bool selected;
+ bool isSeparator;
+ };
+
+ void buildItems(const Vector<WebPopupItem>& webPopupItems, int selectedOriginalIndex);
+
+ Vector<Item> m_items;
+ int m_selectedModelIndex;
+};
+
+class ItemSelectorContextObject : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QRect elementRect READ elementRect CONSTANT FINAL)
+ Q_PROPERTY(QObject* items READ items CONSTANT FINAL)
+
+public:
+ ItemSelectorContextObject(const IntRect& elementRect, const Vector<WebPopupItem>&, int selectedIndex);
+
+ QRect elementRect() const { return m_elementRect; }
+ PopupMenuItemModel* items() { return &m_items; }
+
+ Q_INVOKABLE void accept(int index = -1);
+ Q_INVOKABLE void reject() { emit rejected(); }
+
+Q_SIGNALS:
+ void acceptedWithOriginalIndex(int);
+ void rejected();
+
+private:
+ QRect m_elementRect;
+ PopupMenuItemModel m_items;
+};
+
+ItemSelectorContextObject::ItemSelectorContextObject(const IntRect& elementRect, const Vector<WebPopupItem>& webPopupItems, int selectedIndex)
+ : m_elementRect(elementRect)
+ , m_items(webPopupItems, selectedIndex)
+{
+}
+
+void ItemSelectorContextObject::accept(int index)
+{
+ if (index != -1)
+ m_items.select(index);
+ int originalIndex = m_items.selectedOriginalIndex();
+ emit acceptedWithOriginalIndex(originalIndex);
+}
+
+static QHash<int, QByteArray> createRoleNamesHash()
+{
+ QHash<int, QByteArray> roles;
+ roles[Qt::DisplayRole] = "text";
+ roles[Qt::ToolTipRole] = "tooltip";
+ roles[PopupMenuItemModel::GroupRole] = "group";
+ roles[PopupMenuItemModel::EnabledRole] = "enabled";
+ roles[PopupMenuItemModel::SelectedRole] = "selected";
+ roles[PopupMenuItemModel::IsSeparatorRole] = "isSeparator";
+ return roles;
+}
+
+PopupMenuItemModel::PopupMenuItemModel(const Vector<WebPopupItem>& webPopupItems, int selectedOriginalIndex)
+ : m_selectedModelIndex(-1)
+{
+ static QHash<int, QByteArray> roles = createRoleNamesHash();
+ setRoleNames(roles);
+ buildItems(webPopupItems, selectedOriginalIndex);
+}
+
+QVariant PopupMenuItemModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size())
+ return QVariant();
+
+ const Item& item = m_items[index.row()];
+ if (item.isSeparator) {
+ if (role == IsSeparatorRole)
+ return true;
+ return QVariant();
+ }
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return item.text;
+ case Qt::ToolTipRole:
+ return item.toolTip;
+ case GroupRole:
+ return item.group;
+ case EnabledRole:
+ return item.enabled;
+ case SelectedRole:
+ return item.selected;
+ case IsSeparatorRole:
+ return false;
+ }
+
+ return QVariant();
+}
+
+void PopupMenuItemModel::select(int index)
+{
+ int oldIndex = m_selectedModelIndex;
+ if (index == oldIndex)
+ return;
+ if (index < 0 || index >= m_items.size())
+ return;
+ Item& item = m_items[index];
+ if (!item.enabled)
+ return;
+
+ Item& oldItem = m_items[oldIndex];
+ oldItem.selected = false;
+ item.selected = true;
+ m_selectedModelIndex = index;
+
+ emit dataChanged(this->index(oldIndex), this->index(oldIndex));
+ emit dataChanged(this->index(index), this->index(index));
+}
+
+int PopupMenuItemModel::selectedOriginalIndex() const
+{
+ if (m_selectedModelIndex == -1)
+ return -1;
+ return m_items[m_selectedModelIndex].originalIndex;
+}
+
+void PopupMenuItemModel::buildItems(const Vector<WebPopupItem>& webPopupItems, int selectedOriginalIndex)
+{
+ QString currentGroup;
+ m_items.reserveInitialCapacity(webPopupItems.size());
+ for (int i = 0; i < webPopupItems.size(); i++) {
+ const WebPopupItem& webPopupItem = webPopupItems[i];
+ if (webPopupItem.m_isLabel) {
+ currentGroup = webPopupItem.m_text;
+ continue;
+ }
+ const bool selected = i == selectedOriginalIndex;
+ if (selected)
+ m_selectedModelIndex = m_items.size();
+ m_items.append(Item(webPopupItem, currentGroup, i, selected));
+ }
+}
+
+WebPopupMenuProxyQt::WebPopupMenuProxyQt(WebPopupMenuProxy::Client* client, QQuickWebView* webView)
+ : WebPopupMenuProxy(client)
+ , m_webView(webView)
+{
+}
+
+WebPopupMenuProxyQt::~WebPopupMenuProxyQt()
+{
+}
+
+void WebPopupMenuProxyQt::showPopupMenu(const IntRect& rect, WebCore::TextDirection, double, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
+{
+ m_selectedIndex = selectedIndex;
+
+ ItemSelectorContextObject* contextObject = new ItemSelectorContextObject(rect, items, m_selectedIndex);
+ createItem(contextObject);
+ if (!m_itemSelector) {
+ notifyValueChanged();
+ return;
+ }
+}
+
+void WebPopupMenuProxyQt::hidePopupMenu()
+{
+ m_itemSelector.clear();
+ m_context.clear();
+ notifyValueChanged();
+}
+
+void WebPopupMenuProxyQt::selectIndex(int index)
+{
+ m_selectedIndex = index;
+}
+
+void WebPopupMenuProxyQt::createItem(QObject* contextObject)
+{
+ QDeclarativeComponent* component = m_webView->experimental()->itemSelector();
+ if (!component) {
+ delete contextObject;
+ return;
+ }
+
+ createContext(component, contextObject);
+ QObject* object = component->beginCreate(m_context.get());
+ if (!object) {
+ m_context.clear();
+ return;
+ }
+
+ m_itemSelector = adoptPtr(qobject_cast<QQuickItem*>(object));
+ if (!m_itemSelector) {
+ m_context.clear();
+ m_itemSelector.clear();
+ return;
+ }
+
+ connect(contextObject, SIGNAL(acceptedWithOriginalIndex(int)), SLOT(selectIndex(int)));
+
+ // We enqueue these because they are triggered by m_itemSelector and will lead to its destruction.
+ connect(contextObject, SIGNAL(acceptedWithOriginalIndex(int)), SLOT(hidePopupMenu()), Qt::QueuedConnection);
+ connect(contextObject, SIGNAL(rejected()), SLOT(hidePopupMenu()), Qt::QueuedConnection);
+
+ QQuickWebViewPrivate::get(m_webView)->setViewInAttachedProperties(m_itemSelector.get());
+ component->completeCreate();
+
+ m_itemSelector->setParentItem(m_webView);
+}
+
+void WebPopupMenuProxyQt::createContext(QDeclarativeComponent* component, QObject* contextObject)
+{
+ QDeclarativeContext* baseContext = component->creationContext();
+ if (!baseContext)
+ baseContext = QDeclarativeEngine::contextForObject(m_webView);
+ m_context = adoptPtr(new QDeclarativeContext(baseContext));
+
+ contextObject->setParent(m_context.get());
+ m_context->setContextProperty(QLatin1String("model"), contextObject);
+ m_context->setContextObject(contextObject);
+}
+
+void WebPopupMenuProxyQt::notifyValueChanged()
+{
+ if (m_client) {
+ m_client->valueChangedForPopupMenu(this, m_selectedIndex);
+ invalidate();
+ }
+}
+
+} // namespace WebKit
+
+// Since we define QObjects in WebPopupMenuProxyQt.cpp, this will trigger moc to run on .cpp.
+#include "WebPopupMenuProxyQt.moc"
+
+// And we can't compile the moc for WebPopupMenuProxyQt.h by itself, since it doesn't include "config.h"
+#include "moc_WebPopupMenuProxyQt.cpp"
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
new file mode 100644
index 000000000..ea22bbdd6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * 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 WebPopupMenuProxyQt_h
+#define WebPopupMenuProxyQt_h
+
+#include "WebPopupMenuProxy.h"
+
+#include <QtCore/QObject>
+#include <wtf/OwnPtr.h>
+
+class QDeclarativeComponent;
+class QDeclarativeContext;
+class QQuickWebView;
+class QQuickItem;
+
+namespace WebKit {
+
+class WebPopupMenuProxyQt : public QObject, public WebPopupMenuProxy {
+ Q_OBJECT
+
+public:
+ static PassRefPtr<WebPopupMenuProxyQt> create(WebPopupMenuProxy::Client* client, QQuickWebView* webView)
+ {
+ return adoptRef(new WebPopupMenuProxyQt(client, webView));
+ }
+ ~WebPopupMenuProxyQt();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+
+public Q_SLOTS:
+ virtual void hidePopupMenu();
+
+private Q_SLOTS:
+ void selectIndex(int);
+
+private:
+ WebPopupMenuProxyQt(WebPopupMenuProxy::Client*, QQuickWebView*);
+ void createItem(QObject*);
+ void createContext(QDeclarativeComponent*, QObject*);
+
+ void notifyValueChanged();
+
+ OwnPtr<QDeclarativeContext> m_context;
+ OwnPtr<QQuickItem> m_itemSelector;
+
+ QQuickWebView* m_webView;
+ int32_t m_selectedIndex;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyQt_h
diff --git a/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp b/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
new file mode 100644
index 000000000..fae4a2d76
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp
@@ -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.
+ */
+
+#include "config.h"
+#include "WebPreferences.h"
+
+namespace WebKit {
+
+void WebPreferences::platformInitializeStore()
+{
+}
+
+void WebPreferences::platformUpdateStringValueForKey(const String&, const String&)
+{
+}
+
+void WebPreferences::platformUpdateBoolValueForKey(const String&, bool)
+{
+}
+
+void WebPreferences::platformUpdateUInt32ValueForKey(const String&, uint32_t)
+{
+}
+
+void WebPreferences::platformUpdateDoubleValueForKey(const String&, double)
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp b/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp
new file mode 100644
index 000000000..60bba75bf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/BackingStoreWin.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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 "BackingStore.h"
+
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntRect.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class BitmapDC {
+ WTF_MAKE_NONCOPYABLE(BitmapDC);
+
+public:
+ BitmapDC(HBITMAP, HDC destinationDC);
+ ~BitmapDC();
+
+ operator HDC() const { return m_dc.get(); }
+
+private:
+ OwnPtr<HDC> m_dc;
+ HBITMAP m_originalBitmap;
+};
+
+BitmapDC::BitmapDC(HBITMAP bitmap, HDC destinationDC)
+ : m_dc(adoptPtr(::CreateCompatibleDC(destinationDC)))
+ , m_originalBitmap(static_cast<HBITMAP>(::SelectObject(m_dc.get(), bitmap)))
+{
+}
+
+BitmapDC::~BitmapDC()
+{
+ ::SelectObject(m_dc.get(), m_originalBitmap);
+}
+
+void BackingStore::paint(HDC dc, const IntRect& rect)
+{
+ ASSERT(m_bitmap);
+ ::BitBlt(dc, rect.x(), rect.y(), rect.width(), rect.height(), BitmapDC(m_bitmap.get(), dc), rect.x(), rect.y(), SRCCOPY);
+}
+
+static PassOwnPtr<HBITMAP> createBitmap(const IntSize& size)
+{
+ // FIXME: Maybe it would be better for performance to create a device-dependent bitmap here?
+ BitmapInfo info = BitmapInfo::createBottomUp(size);
+ void* bits;
+ return adoptPtr(::CreateDIBSection(0, &info, DIB_RGB_COLORS, &bits, 0, 0));
+}
+
+void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
+{
+ if (!m_bitmap)
+ m_bitmap = createBitmap(m_size);
+
+ scroll(updateInfo.scrollRect, updateInfo.scrollOffset);
+
+ IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+
+ BitmapDC backingStoreDC(m_bitmap.get(), 0);
+ HDC bitmapDC = bitmap->windowsContext();
+
+ // Paint all update rects.
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i) {
+ IntRect updateRect = updateInfo.updateRects[i];
+ IntRect srcRect = updateRect;
+ srcRect.move(-updateRectLocation.x(), -updateRectLocation.y());
+
+ ::BitBlt(backingStoreDC, updateRect.location().x(), updateRect.location().y(), updateRect.size().width(), updateRect.size().height(),
+ bitmapDC, srcRect.x(), srcRect.y(), SRCCOPY);
+ }
+}
+
+void BackingStore::scroll(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ if (scrollOffset.isZero())
+ return;
+
+ RECT winScrollRect = scrollRect;
+ ::ScrollDC(BitmapDC(m_bitmap.get(), 0), scrollOffset.width(), scrollOffset.height(), &winScrollRect, &winScrollRect, 0, 0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp
new file mode 100644
index 000000000..9f7c766f4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp
@@ -0,0 +1,140 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "TextCheckerState.h"
+#include "WebTextChecker.h"
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static TextCheckerState textCheckerState;
+
+const TextCheckerState& TextChecker::state()
+{
+ static bool didInitializeState;
+ if (didInitializeState)
+ return textCheckerState;
+
+ WebTextCheckerClient& client = WebTextChecker::shared()->client();
+ textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
+ textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled();
+
+ didInitializeState = true;
+
+ return textCheckerState;
+}
+
+bool TextChecker::isContinuousSpellCheckingAllowed()
+{
+ return WebTextChecker::shared()->client().continuousSpellCheckingAllowed();
+}
+
+void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
+{
+ if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
+ return;
+ textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
+ WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
+}
+
+void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
+{
+ if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
+ return;
+ textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
+ WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled);
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+ textCheckerState.isGrammarCheckingEnabled = enabled;
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page)
+{
+ return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page);
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+{
+ WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag);
+}
+
+void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
+{
+ WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
+}
+
+void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
+{
+ WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength);
+}
+
+bool TextChecker::spellingUIIsShowing()
+{
+ return WebTextChecker::shared()->client().spellingUIIsShowing();
+}
+
+void TextChecker::toggleSpellingUIIsShowing()
+{
+ WebTextChecker::shared()->client().toggleSpellingUIIsShowing();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord)
+{
+ WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord);
+}
+
+void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
+{
+ WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail);
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses);
+}
+
+void TextChecker::learnWord(int64_t spellDocumentTag, const String& word)
+{
+ WebTextChecker::shared()->client().learnWord(spellDocumentTag, word);
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp
new file mode 100644
index 000000000..4b5a5a70d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp
@@ -0,0 +1,107 @@
+/*
+ * 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 "WebContextMenuProxyWin.h"
+
+#include <WebCore/NotImplemented.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebContextMenuProxyWin::WebContextMenuProxyWin(HWND parentWindow, WebPageProxy* page)
+ : m_window(parentWindow)
+ , m_page(page)
+ , m_menu(0)
+{
+}
+
+void WebContextMenuProxyWin::populateMenu(HMENU menu, const Vector<WebContextMenuItemData>& items)
+{
+ for (size_t i = 0; i < items.size(); ++i) {
+ const WebContextMenuItemData& itemData = items[i];
+ switch (itemData.type()) {
+ case ActionType:
+ case CheckableActionType: {
+ UINT flags = itemData.enabled() ? MF_ENABLED : MF_DISABLED;
+ if (itemData.checked())
+ flags |= MF_CHECKED;
+ String title = itemData.title();
+ ::AppendMenu(menu, flags, itemData.action(), title.charactersWithNullTermination());
+
+ m_actionMap.add(itemData.action(), itemData);
+ break;
+ }
+ case SeparatorType:
+ ::AppendMenu(menu, MF_SEPARATOR, 0, 0);
+ break;
+ case SubmenuType: {
+ HMENU subMenu = ::CreatePopupMenu();
+ populateMenu(subMenu, itemData.submenu());
+ String title = itemData.title();
+ ::AppendMenu(menu, MF_POPUP, reinterpret_cast<UINT>(subMenu), title.charactersWithNullTermination());
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ }
+}
+
+void WebContextMenuProxyWin::showContextMenu(const IntPoint& origin, const Vector<WebContextMenuItemData>& items)
+{
+ if (items.isEmpty())
+ return;
+
+ // Hide any context menu we have showing (this also destroys the menu).
+ hideContextMenu();
+
+ m_menu = ::CreatePopupMenu();
+ populateMenu(m_menu, items);
+
+ POINT point = POINT(origin);
+ if (!::ClientToScreen(m_window, &point))
+ return;
+
+ UINT flags = TPM_RIGHTBUTTON | TPM_TOPALIGN | TPM_VERPOSANIMATION | TPM_HORIZONTAL | TPM_LEFTALIGN | TPM_HORPOSANIMATION | TPM_RETURNCMD | TPM_NONOTIFY;
+ int selectedCommand = ::TrackPopupMenuEx(m_menu, flags, point.x, point.y, m_window, 0);
+ if (!selectedCommand)
+ return;
+
+ m_page->contextMenuItemSelected(m_actionMap.get(selectedCommand));
+}
+
+void WebContextMenuProxyWin::hideContextMenu()
+{
+ if (m_menu) {
+ ::DestroyMenu(m_menu);
+ m_menu = 0;
+ }
+
+ m_actionMap.clear();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.h
new file mode 100644
index 000000000..a843b2625
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.h
@@ -0,0 +1,61 @@
+/*
+ * 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 WebContextMenuProxyWin_h
+#define WebContextMenuProxyWin_h
+
+#include "WebContextMenuItemData.h"
+#include "WebContextMenuProxy.h"
+#include "WebPageProxy.h"
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class WebContextMenuProxyWin : public WebContextMenuProxy {
+public:
+ static PassRefPtr<WebContextMenuProxyWin> create(HWND parentWindow, WebPageProxy* page)
+ {
+ return adoptRef(new WebContextMenuProxyWin(parentWindow, page));
+ }
+
+private:
+ WebContextMenuProxyWin(HWND parentWindow, WebPageProxy* page);
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ virtual void hideContextMenu();
+
+ void populateMenu(HMENU, const Vector<WebContextMenuItemData>&);
+
+ HMENU m_menu;
+ HWND m_window;
+ WebPageProxy* m_page;
+
+ // Creates a map from the context menu item's action to the context menu item itself.
+ HashMap<int, WebContextMenuItemData> m_actionMap;
+};
+
+} // namespace WebKit
+
+#endif // WebContextMenuProxyWin_h
diff --git a/Source/WebKit2/UIProcess/win/WebContextWin.cpp b/Source/WebKit2/UIProcess/win/WebContextWin.cpp
new file mode 100644
index 000000000..9964de06c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebContextWin.cpp
@@ -0,0 +1,101 @@
+/*
+ * 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 "WebContext.h"
+
+#include "WebProcessCreationParameters.h"
+#include "WebProcessMessages.h"
+#include <WebCore/FileSystem.h>
+
+#if USE(CFNETWORK)
+#include <CFNetwork/CFURLCachePriv.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+String WebContext::applicationCacheDirectory()
+{
+ return localUserSpecificStorageDirectory();
+}
+
+void WebContext::setShouldPaintNativeControls(bool b)
+{
+ m_shouldPaintNativeControls = b;
+
+ sendToAllProcesses(Messages::WebProcess::SetShouldPaintNativeControls(m_shouldPaintNativeControls));
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
+{
+ parameters.shouldPaintNativeControls = m_shouldPaintNativeControls;
+
+#if USE(CFNETWORK)
+ RetainPtr<CFURLCacheRef> cfurlCache(AdoptCF, CFURLCacheCopySharedURLCache());
+ parameters.cfURLCacheDiskCapacity = CFURLCacheDiskCapacity(cfurlCache.get());
+ parameters.cfURLCacheMemoryCapacity = CFURLCacheMemoryCapacity(cfurlCache.get());
+
+ RetainPtr<CFStringRef> cfURLCachePath(AdoptCF, wkCopyFoundationCacheDirectory(0));
+ parameters.cfURLCachePath = String(cfURLCachePath.get());
+ // Remove the ending '\' (necessary to have CFNetwork find the Cache file).
+ ASSERT(parameters.cfURLCachePath.length());
+ if (parameters.cfURLCachePath[parameters.cfURLCachePath.length() - 1] == '\\')
+ parameters.cfURLCachePath.remove(parameters.cfURLCachePath.length() - 1);
+
+#if USE(CFURLSTORAGESESSIONS)
+ parameters.uiProcessBundleIdentifier = String(reinterpret_cast<CFStringRef>(CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleIdentifierKey)));
+ parameters.serializedDefaultStorageSession.adoptCF(wkCopySerializedDefaultStorageSession());
+#endif // USE(CFURLSTORAGESESSIONS)
+
+ parameters.initialHTTPCookieAcceptPolicy = m_initialHTTPCookieAcceptPolicy;
+
+#endif // USE(CFNETWORK)
+}
+
+void WebContext::platformInvalidateContext()
+{
+}
+
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+ return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases");
+}
+
+String WebContext::platformDefaultIconDatabasePath() const
+{
+ // IconDatabase should be disabled by default on Windows, and should therefore have no default path.
+ return String();
+}
+
+String WebContext::platformDefaultLocalStorageDirectory() const
+{
+ return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "LocalStorage");
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/win/WebFullScreenManagerProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebFullScreenManagerProxyWin.cpp
new file mode 100644
index 000000000..878fa134e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebFullScreenManagerProxyWin.cpp
@@ -0,0 +1,111 @@
+/*
+ * 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 "WebFullScreenManagerProxy.h"
+
+#if ENABLE(FULLSCREEN_API)
+
+#include "WebView.h"
+#include <WebCore/FullScreenController.h>
+#include <WebCore/IntRect.h>
+
+namespace WebKit {
+
+void WebFullScreenManagerProxy::invalidate()
+{
+ if (!m_webView)
+ return;
+
+ m_webView->fullScreenController()->close();
+ m_webView = 0;
+}
+
+void WebFullScreenManagerProxy::enterFullScreen()
+{
+ if (!m_webView)
+ return;
+ m_webView->fullScreenController()->enterFullScreen();
+}
+
+void WebFullScreenManagerProxy::exitFullScreen()
+{
+ if (!m_webView)
+ return;
+ m_webView->fullScreenController()->exitFullScreen();
+}
+
+void WebFullScreenManagerProxy::beganEnterFullScreenAnimation()
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::finishedEnterFullScreenAnimation(bool completed)
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::beganExitFullScreenAnimation()
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::finishedExitFullScreenAnimation(bool completed)
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::enterAcceleratedCompositingMode(const LayerTreeContext& context)
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::exitAcceleratedCompositingMode()
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+void WebFullScreenManagerProxy::getFullScreenRect(WebCore::IntRect& rect)
+{
+ if (!m_webView)
+ return;
+ // FIXME: Implement
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp
new file mode 100644
index 000000000..f0c533410
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp
@@ -0,0 +1,340 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebKitBundle.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include "WebView.h"
+#include <WebCore/InspectorFrontendClientLocal.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebCore/WindowMessageBroadcaster.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/text/StringConcatenate.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const LPCWSTR kWebKit2InspectorWindowClassName = L"WebKit2InspectorWindowClass";
+
+bool WebInspectorProxy::registerInspectorViewWindowClass()
+{
+ static bool haveRegisteredWindowClass = false;
+ if (haveRegisteredWindowClass)
+ return true;
+ haveRegisteredWindowClass = true;
+
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.style = CS_DBLCLKS;
+ wcex.lpfnWndProc = WebInspectorProxy::InspectorViewWndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = sizeof(WebInspectorProxy*);
+ wcex.hInstance = instanceHandle();
+ wcex.hIcon = 0;
+ wcex.hCursor = ::LoadCursor(0, IDC_ARROW);
+ wcex.hbrBackground = 0;
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = kWebKit2InspectorWindowClassName;
+ wcex.hIconSm = 0;
+
+ return !!::RegisterClassEx(&wcex);
+}
+
+LRESULT CALLBACK WebInspectorProxy::InspectorViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
+
+ if (WebInspectorProxy* inspectorView = reinterpret_cast<WebInspectorProxy*>(longPtr))
+ return inspectorView->wndProc(hWnd, message, wParam, lParam);
+
+ if (message == WM_CREATE) {
+ LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
+
+ // Associate the WebInspectorProxy with the window.
+ ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
+ return 0;
+ }
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+void WebInspectorProxy::windowReceivedMessage(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ ASSERT(m_isAttached);
+
+ switch (msg) {
+ case WM_WINDOWPOSCHANGING:
+ onWebViewWindowPosChangingEvent(wParam, lParam);
+ break;
+ default:
+ break;
+ }
+}
+
+LRESULT WebInspectorProxy::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT lResult = 0;
+ bool handled = true;
+
+ switch (message) {
+ case WM_SIZE:
+ lResult = onSizeEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_GETMINMAXINFO:
+ lResult = onMinMaxInfoEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SETFOCUS:
+ lResult = onSetFocusEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_CLOSE:
+ lResult = onCloseEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ default:
+ handled = false;
+ break;
+ }
+
+ if (!handled)
+ lResult = ::DefWindowProc(hWnd, message, wParam, lParam);
+
+ return lResult;
+}
+
+LRESULT WebInspectorProxy::onSizeEvent(HWND, UINT, WPARAM, LPARAM, bool&)
+{
+ RECT rect;
+ ::GetClientRect(m_inspectorWindow, &rect);
+
+ ::SetWindowPos(m_inspectorView->window(), 0, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
+
+ return 0;
+}
+
+LRESULT WebInspectorProxy::onSetFocusEvent(HWND, UINT, WPARAM, LPARAM lParam, bool&)
+{
+ ::SetFocus(m_inspectorView->window());
+
+ return 0;
+}
+
+LRESULT WebInspectorProxy::onMinMaxInfoEvent(HWND, UINT, WPARAM, LPARAM lParam, bool&)
+{
+ MINMAXINFO* info = reinterpret_cast<MINMAXINFO*>(lParam);
+ POINT size = {minimumWindowWidth, minimumWindowHeight};
+ info->ptMinTrackSize = size;
+
+ return 0;
+}
+
+LRESULT WebInspectorProxy::onCloseEvent(HWND, UINT, WPARAM, LPARAM, bool&)
+{
+ ::ShowWindow(m_inspectorWindow, SW_HIDE);
+ close();
+
+ return 0;
+}
+
+void WebInspectorProxy::onWebViewWindowPosChangingEvent(WPARAM wParam, LPARAM lParam)
+{
+ WINDOWPOS* windowPos = reinterpret_cast<WINDOWPOS*>(lParam);
+
+ if (windowPos->flags & SWP_NOSIZE)
+ return;
+
+ HWND inspectorWindow = m_inspectorView->window();
+
+ RECT inspectorRect;
+ ::GetClientRect(inspectorWindow, &inspectorRect);
+ unsigned inspectorHeight = inspectorRect.bottom - inspectorRect.top;
+
+ RECT parentRect;
+ ::GetClientRect(::GetParent(inspectorWindow), &parentRect);
+ inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(inspectorHeight, parentRect.bottom - parentRect.top);
+
+ windowPos->cy -= inspectorHeight;
+
+ ::SetWindowPos(inspectorWindow, 0, windowPos->x, windowPos->y + windowPos->cy, windowPos->cx, inspectorHeight, SWP_NOZORDER);
+}
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(!m_inspectorView);
+ ASSERT(!m_inspectorWindow);
+
+ RECT initialRect = { 0, 0, initialWindowWidth, initialWindowHeight };
+ m_inspectorView = WebView::create(initialRect, m_page->process()->context(), inspectorPageGroup(), 0);
+
+ return m_inspectorView->page();
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ registerInspectorViewWindowClass();
+
+ m_inspectorWindow = ::CreateWindowEx(0, kWebKit2InspectorWindowClassName, 0, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ 0, 0, initialWindowWidth, initialWindowHeight, 0, 0, instanceHandle(), this);
+ ASSERT(::IsWindow(m_inspectorWindow));
+
+ m_inspectorView->setParentWindow(m_inspectorWindow);
+
+ if (m_isAttached)
+ platformAttach();
+ else
+ ::ShowWindow(m_inspectorWindow, SW_SHOW);
+}
+
+void WebInspectorProxy::platformDidClose()
+{
+ ASSERT(!m_isAttached);
+ ASSERT(!m_isVisible || m_inspectorWindow);
+ ASSERT(!m_isVisible || m_inspectorView);
+
+ if (m_inspectorWindow) {
+ ASSERT(::IsWindow(m_inspectorWindow));
+ ::DestroyWindow(m_inspectorWindow);
+ }
+
+ m_inspectorWindow = 0;
+ m_inspectorView = 0;
+}
+
+void WebInspectorProxy::platformBringToFront()
+{
+ // FIXME: this will not bring a background tab in Safari to the front, only its window.
+ HWND parentWindow = m_isAttached ? ::GetAncestor(m_page->nativeWindow(), GA_ROOT) : m_inspectorWindow;
+ if (!parentWindow)
+ return;
+
+ ASSERT(::IsWindow(parentWindow));
+ ::SetWindowPos(parentWindow, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
+}
+
+void WebInspectorProxy::platformInspectedURLChanged(const String& urlString)
+{
+ // FIXME: this should be made localizable once WebKit2 supports it. <rdar://problem/8728860>
+ String title = makeString("Web Inspector ", static_cast<UChar>(0x2014), ' ', urlString);
+ ::SetWindowTextW(m_inspectorWindow, title.charactersWithNullTermination());
+}
+
+unsigned WebInspectorProxy::platformInspectedWindowHeight()
+{
+ HWND inspectedWindow = m_page->nativeWindow();
+
+ RECT inspectedWindowRect;
+ ::GetWindowRect(inspectedWindow, &inspectedWindowRect);
+
+ return static_cast<unsigned>(inspectedWindowRect.bottom - inspectedWindowRect.top);
+}
+
+void WebInspectorProxy::platformAttach()
+{
+ HWND webViewWindow = m_page->nativeWindow();
+ HWND parentWindow = ::GetParent(webViewWindow);
+
+ WindowMessageBroadcaster::addListener(webViewWindow, this);
+ m_inspectorView->setParentWindow(parentWindow);
+ ::ShowWindow(m_inspectorWindow, SW_HIDE);
+
+ ::PostMessage(parentWindow, WM_SIZE, 0, 0);
+}
+
+void WebInspectorProxy::platformDetach()
+{
+ HWND webViewWindow = m_page->nativeWindow();
+ WindowMessageBroadcaster::removeListener(webViewWindow, this);
+
+ m_inspectorView->setParentWindow(m_inspectorWindow);
+
+ if (m_isVisible)
+ ::ShowWindow(m_inspectorWindow, SW_SHOW);
+
+ // Send the detached inspector window and the WebView's parent window WM_SIZE messages
+ // to have them re-layout correctly.
+ ::PostMessage(m_inspectorWindow, WM_SIZE, 0, 0);
+ ::PostMessage(::GetParent(webViewWindow), WM_SIZE, 0, 0);
+}
+
+void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned height)
+{
+ if (!m_isAttached)
+ return;
+
+ HWND inspectedWindow = m_page->nativeWindow();
+ HWND parentWindow = ::GetParent(inspectedWindow);
+
+ RECT parentWindowRect;
+ ::GetWindowRect(parentWindow, &parentWindowRect);
+
+ RECT inspectedWindowRect;
+ ::GetWindowRect(inspectedWindow, &inspectedWindowRect);
+
+ int totalHeight = parentWindowRect.bottom - parentWindowRect.top;
+ int webViewWidth = inspectedWindowRect.right - inspectedWindowRect.left;
+
+ POINT inspectedWindowOrigin = { inspectedWindowRect.left, inspectedWindowRect.top };
+ ::ScreenToClient(parentWindow, &inspectedWindowOrigin);
+
+ HWND inspectorWindow = m_inspectorView->window();
+ ::SetWindowPos(inspectorWindow, 0, inspectedWindowOrigin.x, totalHeight - height, webViewWidth, height, SWP_NOZORDER);
+
+ // We want to set the inspected web view height to the totalHeight, because the height adjustment
+ // of the inspected WebView happens in onWindowPosChanging, not here.
+ ::SetWindowPos(inspectedWindow, 0, inspectedWindowOrigin.x, inspectedWindowOrigin.y, webViewWidth, totalHeight, SWP_NOZORDER);
+
+ ::RedrawWindow(inspectorWindow, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW);
+ ::RedrawWindow(inspectedWindow, 0, 0, RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_UPDATENOW);
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(webKitBundle(), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
+ if (!htmlURLRef)
+ return String();
+
+ return String(CFURLGetString(htmlURLRef.get()));
+}
+
+String WebInspectorProxy::inspectorBaseURL() const
+{
+ // Web Inspector uses localized strings, so it's not contained within inspector directory.
+ RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourcesDirectoryURL(webKitBundle()));
+ if (!htmlURLRef)
+ return String();
+
+ return String(CFURLGetString(htmlURLRef.get()));
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp
new file mode 100644
index 000000000..bc1fa57c8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp
@@ -0,0 +1,201 @@
+/*
+* 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 "WebPageProxy.h"
+
+#include "PageClient.h"
+#include "WebDragSource.h"
+#include "WebPageMessages.h"
+#include "WebPopupMenuProxyWin.h"
+#include "WebProcessProxy.h"
+
+#include "resource.h"
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/COMPtr.h>
+#include <WebCore/ClipboardUtilitiesWin.h>
+#include <WebCore/SystemInfo.h>
+#include <WebCore/WCDataObject.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <tchar.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/StringConcatenate.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static String userVisibleWebKitVersionString()
+{
+ LPWSTR buildNumberStringPtr;
+ if (!::LoadStringW(instanceHandle(), BUILD_NUMBER, reinterpret_cast<LPWSTR>(&buildNumberStringPtr), 0) || !buildNumberStringPtr)
+ return "534+";
+
+ return buildNumberStringPtr;
+}
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ DEFINE_STATIC_LOCAL(String, osVersion, (windowsVersionForUAString()));
+ DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString()));
+
+ return makeString("Mozilla/5.0 (", osVersion, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)", applicationNameForUserAgent.isEmpty() ? "" : " ", applicationNameForUserAgent);
+}
+
+void WebPageProxy::setPopupMenuSelectedIndex(int32_t selectedIndex)
+{
+ if (!m_activePopupMenu)
+ return;
+
+ static_cast<WebPopupMenuProxyWin*>(m_activePopupMenu.get())->setFocusedIndex(selectedIndex);
+}
+
+HWND WebPageProxy::nativeWindow() const
+{
+ return m_pageClient->nativeWindow();
+}
+
+void WebPageProxy::scheduleChildWindowGeometryUpdate(const WindowGeometry& geometry)
+{
+ m_pageClient->scheduleChildWindowGeometryUpdate(geometry);
+}
+
+void WebPageProxy::didInstallOrUninstallPageOverlay(bool didInstall)
+{
+ m_pageClient->didInstallOrUninstallPageOverlay(didInstall);
+}
+
+IntRect WebPageProxy::firstRectForCharacterInSelectedRange(int characterPosition)
+{
+ IntRect resultRect;
+ process()->sendSync(Messages::WebPage::FirstRectForCharacterInSelectedRange(characterPosition), Messages::WebPage::FirstRectForCharacterInSelectedRange::Reply(resultRect), m_pageID);
+ return resultRect;
+}
+
+String WebPageProxy::getSelectedText()
+{
+ String text;
+ process()->sendSync(Messages::WebPage::GetSelectedText(), Messages::WebPage::GetSelectedText::Reply(text), m_pageID);
+ return text;
+}
+
+bool WebPageProxy::gestureWillBegin(const IntPoint& point)
+{
+ bool canBeginPanning = false;
+ process()->sendSync(Messages::WebPage::GestureWillBegin(point), Messages::WebPage::GestureWillBegin::Reply(canBeginPanning), m_pageID);
+ return canBeginPanning;
+}
+
+void WebPageProxy::gestureDidScroll(const IntSize& size)
+{
+ process()->send(Messages::WebPage::GestureDidScroll(size), m_pageID);
+}
+
+void WebPageProxy::gestureDidEnd()
+{
+ process()->send(Messages::WebPage::GestureDidEnd(), m_pageID);
+}
+
+void WebPageProxy::setGestureReachedScrollingLimit(bool limitReached)
+{
+ m_pageClient->setGestureReachedScrollingLimit(limitReached);
+}
+
+void WebPageProxy::startDragDrop(const IntPoint& imageOrigin, const IntPoint& dragPoint, uint64_t okEffect, const HashMap<UINT, Vector<String> >& dataMap, uint64_t fileSize, const String& pathname, const SharedMemory::Handle& fileContentHandle, const IntSize& dragImageSize, const SharedMemory::Handle& dragImageHandle, bool isLinkDrag)
+{
+ COMPtr<WCDataObject> dataObject;
+ WCDataObject::createInstance(&dataObject, dataMap);
+
+ if (fileSize) {
+ RefPtr<SharedMemory> fileContentBuffer = SharedMemory::create(fileContentHandle, SharedMemory::ReadOnly);
+ setFileDescriptorData(dataObject.get(), fileSize, pathname);
+ setFileContentData(dataObject.get(), fileSize, fileContentBuffer->data());
+ }
+
+ RefPtr<SharedMemory> memoryBuffer = SharedMemory::create(dragImageHandle, SharedMemory::ReadOnly);
+ if (!memoryBuffer)
+ return;
+
+ RefPtr<WebDragSource> source = WebDragSource::createInstance();
+ if (!source)
+ return;
+
+ COMPtr<IDragSourceHelper> helper;
+ if (FAILED(::CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, IID_IDragSourceHelper, reinterpret_cast<LPVOID*>(&helper))))
+ return;
+
+ BitmapInfo bitmapInfo = BitmapInfo::create(dragImageSize);
+ void* bits;
+ OwnPtr<HBITMAP> hbmp = adoptPtr(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &bits, 0, 0));
+ memcpy(bits, memoryBuffer->data(), memoryBuffer->size());
+
+ SHDRAGIMAGE sdi;
+ sdi.sizeDragImage.cx = bitmapInfo.bmiHeader.biWidth;
+ sdi.sizeDragImage.cy = bitmapInfo.bmiHeader.biHeight;
+ sdi.crColorKey = 0xffffffff;
+ sdi.hbmpDragImage = hbmp.leakPtr();
+ sdi.ptOffset.x = dragPoint.x() - imageOrigin.x();
+ sdi.ptOffset.y = dragPoint.y() - imageOrigin.y();
+ if (isLinkDrag)
+ sdi.ptOffset.y = bitmapInfo.bmiHeader.biHeight - sdi.ptOffset.y;
+
+ helper->InitializeFromBitmap(&sdi, dataObject.get());
+
+ DWORD effect = DROPEFFECT_NONE;
+
+ DragOperation operation = DragOperationNone;
+ if (::DoDragDrop(dataObject.get(), source.get(), okEffect, &effect) == DRAGDROP_S_DROP) {
+ if (effect & DROPEFFECT_COPY)
+ operation = DragOperationCopy;
+ else if (effect & DROPEFFECT_LINK)
+ operation = DragOperationLink;
+ else if (effect & DROPEFFECT_MOVE)
+ operation = DragOperationMove;
+ }
+ POINT globalPoint;
+ ::GetCursorPos(&globalPoint);
+ POINT localPoint = globalPoint;
+ ::ScreenToClient(m_pageClient->nativeWindow(), &localPoint);
+
+ dragEnded(localPoint, globalPoint, operation);
+}
+
+void WebPageProxy::didChangeCompositionSelection(bool hasComposition)
+{
+ m_pageClient->compositionSelectionChanged(hasComposition);
+}
+
+void WebPageProxy::confirmComposition(const String& compositionString)
+{
+ process()->send(Messages::WebPage::ConfirmComposition(compositionString), m_pageID);
+}
+
+void WebPageProxy::setComposition(const String& compositionString, Vector<CompositionUnderline>& underlines, int cursorPosition)
+{
+ process()->send(Messages::WebPage::SetComposition(compositionString, underlines, cursorPosition), m_pageID);
+}
+
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
new file mode 100644
index 000000000..d32e0f817
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
@@ -0,0 +1,961 @@
+/*
+ * 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.
+ */
+
+// NOTE: This implementation is very similar to the implementation of popups in WebCore::PopupMenuWin.
+// We should try and factor out the common bits and share them.
+
+#include "config.h"
+#include "WebPopupMenuProxyWin.h"
+
+#include "NativeWebMouseEvent.h"
+#include "WebView.h"
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebCore/ScrollbarTheme.h>
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/PlatformMouseEvent.h>
+#include <windowsx.h>
+
+using namespace WebCore;
+using namespace std;
+
+namespace WebKit {
+
+static const LPCWSTR kWebKit2WebPopupMenuProxyWindowClassName = L"WebKit2WebPopupMenuProxyWindowClass";
+
+static const int defaultAnimationDuration = 200;
+static const int maxPopupHeight = 320;
+static const int popupWindowBorderWidth = 1;
+static const int separatorPadding = 4;
+static const int separatorHeight = 1;
+
+// This is used from within our custom message pump when we want to send a
+// message to the web view and not have our message stolen and sent to
+// the popup window.
+static const UINT WM_HOST_WINDOW_FIRST = WM_USER;
+static const UINT WM_HOST_WINDOW_CHAR = WM_USER + WM_CHAR;
+static const UINT WM_HOST_WINDOW_MOUSEMOVE = WM_USER + WM_MOUSEMOVE;
+
+static inline bool isASCIIPrintable(unsigned c)
+{
+ return c >= 0x20 && c <= 0x7E;
+}
+
+static void translatePoint(LPARAM& lParam, HWND from, HWND to)
+{
+ POINT pt;
+ pt.x = static_cast<short>(GET_X_LPARAM(lParam));
+ pt.y = static_cast<short>(GET_Y_LPARAM(lParam));
+ ::MapWindowPoints(from, to, &pt, 1);
+ lParam = MAKELPARAM(pt.x, pt.y);
+}
+
+LRESULT CALLBACK WebPopupMenuProxyWin::WebPopupMenuProxyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
+
+ if (WebPopupMenuProxyWin* popupMenuProxy = reinterpret_cast<WebPopupMenuProxyWin*>(longPtr))
+ return popupMenuProxy->wndProc(hWnd, message, wParam, lParam);
+
+ if (message == WM_CREATE) {
+ LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
+
+ // Associate the WebView with the window.
+ ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
+ return 0;
+ }
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+LRESULT WebPopupMenuProxyWin::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT lResult = 0;
+ bool handled = true;
+
+ switch (message) {
+ case WM_MOUSEACTIVATE:
+ lResult = onMouseActivate(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SIZE:
+ lResult = onSize(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_KEYDOWN:
+ lResult = onKeyDown(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_CHAR:
+ lResult = onChar(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_MOUSEMOVE:
+ lResult = onMouseMove(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_LBUTTONDOWN:
+ lResult = onLButtonDown(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_LBUTTONUP:
+ lResult = onLButtonUp(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_MOUSEWHEEL:
+ lResult = onMouseWheel(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_PAINT:
+ lResult = onPaint(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_PRINTCLIENT:
+ lResult = onPrintClient(hWnd, message, wParam, lParam, handled);
+ break;
+ default:
+ handled = false;
+ break;
+ }
+
+ if (!handled)
+ lResult = ::DefWindowProc(hWnd, message, wParam, lParam);
+
+ return lResult;
+}
+
+bool WebPopupMenuProxyWin::registerWindowClass()
+{
+ static bool haveRegisteredWindowClass = false;
+ if (haveRegisteredWindowClass)
+ return true;
+ haveRegisteredWindowClass = true;
+
+ WNDCLASSEX wcex;
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.style = CS_DROPSHADOW;
+ wcex.lpfnWndProc = WebPopupMenuProxyWin::WebPopupMenuProxyWndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = sizeof(WebPopupMenuProxyWin*);
+ wcex.hInstance = instanceHandle();
+ wcex.hIcon = 0;
+ wcex.hCursor = ::LoadCursor(0, IDC_ARROW);
+ wcex.hbrBackground = 0;
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = kWebKit2WebPopupMenuProxyWindowClassName;
+ wcex.hIconSm = 0;
+
+ return !!::RegisterClassEx(&wcex);
+}
+
+WebPopupMenuProxyWin::WebPopupMenuProxyWin(WebView* webView, WebPopupMenuProxy::Client* client)
+ : WebPopupMenuProxy(client)
+ , m_webView(webView)
+ , m_newSelectedIndex(0)
+ , m_popup(0)
+ , m_DC(0)
+ , m_bmp(0)
+ , m_itemHeight(0)
+ , m_scrollOffset(0)
+ , m_wheelDelta(0)
+ , m_focusedIndex(0)
+ , m_wasClicked(false)
+ , m_scrollbarCapturingMouse(false)
+ , m_showPopup(false)
+{
+}
+
+WebPopupMenuProxyWin::~WebPopupMenuProxyWin()
+{
+ if (m_bmp)
+ ::DeleteObject(m_bmp);
+ if (m_DC)
+ ::DeleteDC(m_DC);
+ if (m_popup)
+ ::DestroyWindow(m_popup);
+ if (m_scrollbar)
+ m_scrollbar->setParent(0);
+}
+
+void WebPopupMenuProxyWin::showPopupMenu(const IntRect& rect, TextDirection, double, const Vector<WebPopupItem>& items, const PlatformPopupMenuData& data, int32_t selectedIndex)
+{
+ m_items = items;
+ m_data = data;
+ m_newSelectedIndex = selectedIndex;
+
+ calculatePositionAndSize(rect);
+ if (clientRect().isEmpty())
+ return;
+
+ HWND hostWindow = m_webView->window();
+
+ if (!m_scrollbar && visibleItems() < m_items.size()) {
+ m_scrollbar = Scrollbar::createNativeScrollbar(this, VerticalScrollbar, SmallScrollbar);
+ m_scrollbar->styleChanged();
+ }
+
+ if (!m_popup) {
+ registerWindowClass();
+
+ DWORD exStyle = WS_EX_LTRREADING;
+
+ m_popup = ::CreateWindowEx(exStyle, kWebKit2WebPopupMenuProxyWindowClassName, TEXT("PopupMenu"),
+ WS_POPUP | WS_BORDER,
+ m_windowRect.x(), m_windowRect.y(), m_windowRect.width(), m_windowRect.height(),
+ hostWindow, 0, instanceHandle(), this);
+
+ if (!m_popup)
+ return;
+ }
+
+ BOOL shouldAnimate = FALSE;
+ ::SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &shouldAnimate, 0);
+
+ if (shouldAnimate) {
+ RECT viewRect = {0};
+ ::GetWindowRect(hostWindow, &viewRect);
+
+ if (!::IsRectEmpty(&viewRect)) {
+ // Popups should slide into view away from the <select> box
+ // NOTE: This may have to change for Vista
+ DWORD slideDirection = (m_windowRect.y() < viewRect.top + rect.location().y()) ? AW_VER_NEGATIVE : AW_VER_POSITIVE;
+
+ ::AnimateWindow(m_popup, defaultAnimationDuration, AW_SLIDE | slideDirection);
+ }
+ } else
+ ::ShowWindow(m_popup, SW_SHOWNOACTIVATE);
+
+
+ int index = selectedIndex;
+ if (index >= 0)
+ setFocusedIndex(index);
+
+ m_showPopup = true;
+
+ // Protect the popup menu in case its owner is destroyed while we're running the message pump.
+ RefPtr<WebPopupMenuProxyWin> protect(this);
+
+ ::SetCapture(hostWindow);
+
+ MSG msg;
+ HWND activeWindow;
+
+ while (::GetMessage(&msg, 0, 0, 0)) {
+ switch (msg.message) {
+ case WM_HOST_WINDOW_MOUSEMOVE:
+ case WM_HOST_WINDOW_CHAR:
+ if (msg.hwnd == m_popup) {
+ // This message should be sent to the host window.
+ msg.hwnd = hostWindow;
+ msg.message -= WM_HOST_WINDOW_FIRST;
+ }
+ break;
+
+ // Steal mouse messages.
+ case WM_NCMOUSEMOVE:
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCRBUTTONDOWN:
+ case WM_NCRBUTTONUP:
+ case WM_NCRBUTTONDBLCLK:
+ case WM_NCMBUTTONDOWN:
+ case WM_NCMBUTTONUP:
+ case WM_NCMBUTTONDBLCLK:
+ case WM_MOUSEWHEEL:
+ msg.hwnd = m_popup;
+ break;
+
+ // These mouse messages use client coordinates so we need to convert them.
+ case WM_MOUSEMOVE:
+ case WM_LBUTTONDOWN:
+ case WM_LBUTTONUP:
+ case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDOWN:
+ case WM_RBUTTONUP:
+ case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONUP:
+ case WM_MBUTTONDBLCLK: {
+ // Translate the coordinate.
+ translatePoint(msg.lParam, msg.hwnd, m_popup);
+ msg.hwnd = m_popup;
+ break;
+ }
+
+ // Steal all keyboard messages.
+ case WM_KEYDOWN:
+ case WM_KEYUP:
+ case WM_CHAR:
+ case WM_DEADCHAR:
+ case WM_SYSKEYUP:
+ case WM_SYSCHAR:
+ case WM_SYSDEADCHAR:
+ msg.hwnd = m_popup;
+ break;
+ }
+
+ ::TranslateMessage(&msg);
+ ::DispatchMessage(&msg);
+
+ if (!m_showPopup)
+ break;
+ activeWindow = ::GetActiveWindow();
+ if (activeWindow != hostWindow && !::IsChild(activeWindow, hostWindow))
+ break;
+ if (::GetCapture() != hostWindow)
+ break;
+ }
+
+ if (::GetCapture() == hostWindow)
+ ::ReleaseCapture();
+
+ m_showPopup = false;
+ ::ShowWindow(m_popup, SW_HIDE);
+
+ if (!WebPopupMenuProxy::m_client)
+ return;
+
+ WebPopupMenuProxy::m_client->valueChangedForPopupMenu(this, m_newSelectedIndex);
+
+ // <https://bugs.webkit.org/show_bug.cgi?id=57904> In order to properly call the onClick()
+ // handler on a <select> element, we need to fake a mouse up event in the main window.
+ // The main window already received the mouse down, which showed this popup, but upon
+ // selection of an item the mouse up gets eaten by the popup menu. So we take the mouse down
+ // event, change the message type to a mouse up event, and post that in the message queue.
+ // Thus, we are virtually clicking at the
+ // same location where the mouse down event occurred. This allows the hit test to select
+ // the correct element, and thereby call the onClick() JS handler.
+ if (!WebPopupMenuProxy::m_client->currentlyProcessedMouseDownEvent())
+ return;
+
+ const MSG* initiatingWinEvent = WebPopupMenuProxy::m_client->currentlyProcessedMouseDownEvent()->nativeEvent();
+ MSG fakeEvent = *initiatingWinEvent;
+ fakeEvent.message = WM_LBUTTONUP;
+ ::PostMessage(fakeEvent.hwnd, fakeEvent.message, fakeEvent.wParam, fakeEvent.lParam);
+}
+
+void WebPopupMenuProxyWin::hidePopupMenu()
+{
+ if (!m_showPopup)
+ return;
+ m_showPopup = false;
+
+ ::ShowWindow(m_popup, SW_HIDE);
+
+ // Post a WM_NULL message to wake up the message pump if necessary.
+ ::PostMessage(m_popup, WM_NULL, 0, 0);
+}
+
+void WebPopupMenuProxyWin::calculatePositionAndSize(const IntRect& rect)
+{
+ // Convert the rect (which is in view cooridates) into screen coordinates.
+ IntRect rectInScreenCoords = rect;
+ POINT location(rectInScreenCoords .location());
+ if (!::ClientToScreen(m_webView->window(), &location))
+ return;
+ rectInScreenCoords.setLocation(location);
+
+ int itemCount = m_items.size();
+ m_itemHeight = m_data.m_itemHeight;
+
+ int naturalHeight = m_itemHeight * itemCount;
+ int popupHeight = min(maxPopupHeight, naturalHeight);
+
+ // The popup should show an integral number of items (i.e. no partial items should be visible)
+ popupHeight -= popupHeight % m_itemHeight;
+
+ // Next determine its width
+ int popupWidth = m_data.m_popupWidth;
+
+ if (naturalHeight > maxPopupHeight) {
+ // We need room for a scrollbar
+ popupWidth += ScrollbarTheme::theme()->scrollbarThickness(SmallScrollbar);
+ }
+
+ popupHeight += 2 * popupWindowBorderWidth;
+
+ // The popup should be at least as wide as the control on the page
+ popupWidth = max(rectInScreenCoords.width() - m_data.m_clientInsetLeft - m_data.m_clientInsetRight, popupWidth);
+
+ // Always left-align items in the popup. This matches popup menus on the mac.
+ int popupX = rectInScreenCoords.x() + m_data.m_clientInsetLeft;
+
+ IntRect popupRect(popupX, rectInScreenCoords.maxY(), popupWidth, popupHeight);
+
+ // The popup needs to stay within the bounds of the screen and not overlap any toolbars
+ HMONITOR monitor = ::MonitorFromWindow(m_webView->window(), MONITOR_DEFAULTTOPRIMARY);
+ MONITORINFOEX monitorInfo;
+ monitorInfo.cbSize = sizeof(MONITORINFOEX);
+ ::GetMonitorInfo(monitor, &monitorInfo);
+ FloatRect screen = monitorInfo.rcWork;
+
+ // Check that we don't go off the screen vertically
+ if (popupRect.maxY() > screen.height()) {
+ // The popup will go off the screen, so try placing it above the client
+ if (rectInScreenCoords.y() - popupRect.height() < 0) {
+ // The popup won't fit above, either, so place it whereever's bigger and resize it to fit
+ if ((rectInScreenCoords.y() + rectInScreenCoords.height() / 2) < (screen.height() / 2)) {
+ // Below is bigger
+ popupRect.setHeight(screen.height() - popupRect.y());
+ } else {
+ // Above is bigger
+ popupRect.setY(0);
+ popupRect.setHeight(rectInScreenCoords.y());
+ }
+ } else {
+ // The popup fits above, so reposition it
+ popupRect.setY(rectInScreenCoords.y() - popupRect.height());
+ }
+ }
+
+ // Check that we don't go off the screen horizontally
+ if (popupRect.x() < screen.x()) {
+ popupRect.setWidth(popupRect.width() - (screen.x() - popupRect.x()));
+ popupRect.setX(screen.x());
+ }
+
+ m_windowRect = popupRect;
+}
+
+IntRect WebPopupMenuProxyWin::clientRect() const
+{
+ IntRect clientRect = m_windowRect;
+ clientRect.inflate(-popupWindowBorderWidth);
+ clientRect.setLocation(IntPoint(0, 0));
+ return clientRect;
+}
+
+void WebPopupMenuProxyWin::invalidateItem(int index)
+{
+ if (!m_popup)
+ return;
+
+ IntRect damageRect(clientRect());
+ damageRect.setY(m_itemHeight * (index - m_scrollOffset));
+ damageRect.setHeight(m_itemHeight);
+ if (m_scrollbar)
+ damageRect.setWidth(damageRect.width() - m_scrollbar->frameRect().width());
+
+ RECT r = damageRect;
+ ::InvalidateRect(m_popup, &r, TRUE);
+}
+
+int WebPopupMenuProxyWin::scrollSize(ScrollbarOrientation orientation) const
+{
+ return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0;
+}
+
+int WebPopupMenuProxyWin::scrollPosition(Scrollbar*) const
+{
+ return m_scrollOffset;
+}
+
+void WebPopupMenuProxyWin::setScrollOffset(const IntPoint& offset)
+{
+ scrollTo(offset.y());
+}
+
+void WebPopupMenuProxyWin::scrollTo(int offset)
+{
+ ASSERT(m_scrollbar);
+
+ if (!m_popup)
+ return;
+
+ if (m_scrollOffset == offset)
+ return;
+
+ int scrolledLines = m_scrollOffset - offset;
+ m_scrollOffset = offset;
+
+ UINT flags = SW_INVALIDATE;
+
+#ifdef CAN_SET_SMOOTH_SCROLLING_DURATION
+ BOOL shouldSmoothScroll = FALSE;
+ ::SystemParametersInfo(SPI_GETLISTBOXSMOOTHSCROLLING, 0, &shouldSmoothScroll, 0);
+ if (shouldSmoothScroll)
+ flags |= MAKEWORD(SW_SMOOTHSCROLL, smoothScrollAnimationDuration);
+#endif
+
+ IntRect listRect = clientRect();
+ if (m_scrollbar)
+ listRect.setWidth(listRect.width() - m_scrollbar->frameRect().width());
+ RECT r = listRect;
+ ::ScrollWindowEx(m_popup, 0, scrolledLines * m_itemHeight, &r, 0, 0, 0, flags);
+ if (m_scrollbar) {
+ r = m_scrollbar->frameRect();
+ ::InvalidateRect(m_popup, &r, TRUE);
+ }
+ ::UpdateWindow(m_popup);
+}
+
+void WebPopupMenuProxyWin::invalidateScrollbarRect(Scrollbar* scrollbar, const IntRect& rect)
+{
+ IntRect scrollRect = rect;
+ scrollRect.move(scrollbar->x(), scrollbar->y());
+ RECT r = scrollRect;
+ ::InvalidateRect(m_popup, &r, false);
+}
+
+// Message pump messages.
+
+LRESULT WebPopupMenuProxyWin::onMouseActivate(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
+{
+ handled = true;
+ return MA_NOACTIVATE;
+}
+
+LRESULT WebPopupMenuProxyWin::onSize(HWND hWnd, UINT message, WPARAM, LPARAM lParam, bool& handled)
+{
+ handled = true;
+ if (!scrollbar())
+ return 0;
+
+ IntSize size(LOWORD(lParam), HIWORD(lParam));
+ scrollbar()->setFrameRect(IntRect(size.width() - scrollbar()->width(), 0, scrollbar()->width(), size.height()));
+
+ int visibleItems = this->visibleItems();
+ scrollbar()->setEnabled(visibleItems < m_items.size());
+ scrollbar()->setSteps(1, max(1, visibleItems - 1));
+ scrollbar()->setProportion(visibleItems, m_items.size());
+ return 0;
+}
+
+LRESULT WebPopupMenuProxyWin::onKeyDown(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ handled = true;
+
+ LRESULT lResult = 0;
+ switch (LOWORD(wParam)) {
+ case VK_DOWN:
+ case VK_RIGHT:
+ down();
+ break;
+ case VK_UP:
+ case VK_LEFT:
+ up();
+ break;
+ case VK_HOME:
+ focusFirst();
+ break;
+ case VK_END:
+ focusLast();
+ break;
+ case VK_PRIOR:
+ if (focusedIndex() != scrollOffset()) {
+ // Set the selection to the first visible item
+ int firstVisibleItem = scrollOffset();
+ up(focusedIndex() - firstVisibleItem);
+ } else {
+ // The first visible item is selected, so move the selection back one page
+ up(visibleItems());
+ }
+ break;
+ case VK_NEXT: {
+ int lastVisibleItem = scrollOffset() + visibleItems() - 1;
+ if (focusedIndex() != lastVisibleItem) {
+ // Set the selection to the last visible item
+ down(lastVisibleItem - focusedIndex());
+ } else {
+ // The last visible item is selected, so move the selection forward one page
+ down(visibleItems());
+ }
+ break;
+ }
+ case VK_TAB:
+ ::SendMessage(m_webView->window(), message, wParam, lParam);
+ hide();
+ break;
+ case VK_ESCAPE:
+ hide();
+ break;
+ default:
+ if (isASCIIPrintable(wParam)) {
+ // Send the keydown to the WebView so it can be used for type-to-select.
+ // Since we know that the virtual key is ASCII printable, it's OK to convert this to
+ // a WM_CHAR message. (We don't want to call TranslateMessage because that will post a
+ // WM_CHAR message that will be stolen and redirected to the popup HWND.
+ ::PostMessage(m_popup, WM_HOST_WINDOW_CHAR, wParam, lParam);
+ } else
+ lResult = 1;
+ break;
+ }
+
+ return lResult;
+}
+
+LRESULT WebPopupMenuProxyWin::onChar(HWND hWnd, UINT message, WPARAM wParam, LPARAM, bool& handled)
+{
+ handled = true;
+
+ LRESULT lResult = 0;
+ int index;
+ switch (wParam) {
+ case 0x0D: // Enter/Return
+ hide();
+ index = focusedIndex();
+ ASSERT(index >= 0);
+ // FIXME: Do we need to send back the index right away?
+ m_newSelectedIndex = index;
+ break;
+ case 0x1B: // Escape
+ hide();
+ break;
+ case 0x09: // TAB
+ case 0x08: // Backspace
+ case 0x0A: // Linefeed
+ default: // Character
+ lResult = 1;
+ break;
+ }
+
+ return lResult;
+}
+
+LRESULT WebPopupMenuProxyWin::onMouseMove(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ handled = true;
+
+ IntPoint mousePoint(MAKEPOINTS(lParam));
+ if (scrollbar()) {
+ IntRect scrollBarRect = scrollbar()->frameRect();
+ if (scrollbarCapturingMouse() || scrollBarRect.contains(mousePoint)) {
+ // Put the point into coordinates relative to the scroll bar
+ mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
+ PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
+ scrollbar()->mouseMoved(event);
+ return 0;
+ }
+ }
+
+ BOOL shouldHotTrack = FALSE;
+ ::SystemParametersInfo(SPI_GETHOTTRACKING, 0, &shouldHotTrack, 0);
+
+ RECT bounds;
+ ::GetClientRect(m_popup, &bounds);
+ if (!::PtInRect(&bounds, mousePoint) && !(wParam & MK_LBUTTON)) {
+ // When the mouse is not inside the popup menu and the left button isn't down, just
+ // repost the message to the web view.
+
+ // Translate the coordinate.
+ translatePoint(lParam, m_popup, m_webView->window());
+
+ ::PostMessage(m_popup, WM_HOST_WINDOW_MOUSEMOVE, wParam, lParam);
+ return 0;
+ }
+
+ if ((shouldHotTrack || wParam & MK_LBUTTON) && ::PtInRect(&bounds, mousePoint))
+ setFocusedIndex(listIndexAtPoint(mousePoint), true);
+
+ return 0;
+}
+
+LRESULT WebPopupMenuProxyWin::onLButtonDown(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ handled = true;
+
+ IntPoint mousePoint(MAKEPOINTS(lParam));
+ if (scrollbar()) {
+ IntRect scrollBarRect = scrollbar()->frameRect();
+ if (scrollBarRect.contains(mousePoint)) {
+ // Put the point into coordinates relative to the scroll bar
+ mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
+ PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
+ scrollbar()->mouseDown(event);
+ setScrollbarCapturingMouse(true);
+ return 0;
+ }
+ }
+
+ // If the mouse is inside the window, update the focused index. Otherwise,
+ // hide the popup.
+ RECT bounds;
+ ::GetClientRect(m_popup, &bounds);
+ if (::PtInRect(&bounds, mousePoint))
+ setFocusedIndex(listIndexAtPoint(mousePoint), true);
+ else
+ hide();
+
+ return 0;
+}
+
+
+LRESULT WebPopupMenuProxyWin::onLButtonUp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ handled = true;
+
+ IntPoint mousePoint(MAKEPOINTS(lParam));
+ if (scrollbar()) {
+ IntRect scrollBarRect = scrollbar()->frameRect();
+ if (scrollbarCapturingMouse() || scrollBarRect.contains(mousePoint)) {
+ setScrollbarCapturingMouse(false);
+ // Put the point into coordinates relative to the scroll bar
+ mousePoint.move(-scrollBarRect.x(), -scrollBarRect.y());
+ PlatformMouseEvent event(hWnd, message, wParam, MAKELPARAM(mousePoint.x(), mousePoint.y()));
+ scrollbar()->mouseUp(event);
+ // FIXME: This is a hack to work around Scrollbar not invalidating correctly when it doesn't have a parent widget
+ RECT r = scrollBarRect;
+ ::InvalidateRect(m_popup, &r, TRUE);
+ return 0;
+ }
+ }
+ // Only hide the popup if the mouse is inside the popup window.
+ RECT bounds;
+ ::GetClientRect(m_popup, &bounds);
+ if (::PtInRect(&bounds, mousePoint)) {
+ hide();
+ int index = focusedIndex();
+ if (index >= 0) {
+ // FIXME: Do we need to send back the index right away?
+ m_newSelectedIndex = index;
+ }
+ }
+
+ return 0;
+}
+
+LRESULT WebPopupMenuProxyWin::onMouseWheel(HWND hWnd, UINT message, WPARAM wParam, LPARAM, bool& handled)
+{
+ handled = true;
+
+ if (!scrollbar())
+ return 0;
+
+ int i = 0;
+ for (incrementWheelDelta(GET_WHEEL_DELTA_WPARAM(wParam)); abs(wheelDelta()) >= WHEEL_DELTA; reduceWheelDelta(WHEEL_DELTA)) {
+ if (wheelDelta() > 0)
+ ++i;
+ else
+ --i;
+ }
+
+ ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i));
+ return 0;
+}
+
+LRESULT WebPopupMenuProxyWin::onPaint(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
+{
+ handled = true;
+
+ PAINTSTRUCT paintStruct;
+ ::BeginPaint(m_popup, &paintStruct);
+ paint(paintStruct.rcPaint, paintStruct.hdc);
+ ::EndPaint(m_popup, &paintStruct);
+
+ return 0;
+}
+
+LRESULT WebPopupMenuProxyWin::onPrintClient(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool& handled)
+{
+ handled = true;
+
+ HDC hdc = reinterpret_cast<HDC>(wParam);
+ paint(clientRect(), hdc);
+
+ return 0;
+}
+
+bool WebPopupMenuProxyWin::down(unsigned lines)
+{
+ int size = m_items.size();
+
+ int lastSelectableIndex, selectedListIndex;
+ lastSelectableIndex = selectedListIndex = focusedIndex();
+ for (int i = selectedListIndex + 1; i >= 0 && i < size; ++i) {
+ if (m_items[i].m_isEnabled) {
+ lastSelectableIndex = i;
+ if (i >= selectedListIndex + (int)lines)
+ break;
+ }
+ }
+
+ return setFocusedIndex(lastSelectableIndex);
+}
+
+bool WebPopupMenuProxyWin::up(unsigned lines)
+{
+ int size = m_items.size();
+
+ int lastSelectableIndex, selectedListIndex;
+ lastSelectableIndex = selectedListIndex = focusedIndex();
+ for (int i = selectedListIndex - 1; i >= 0 && i < size; --i) {
+ if (m_items[i].m_isEnabled) {
+ lastSelectableIndex = i;
+ if (i <= selectedListIndex - (int)lines)
+ break;
+ }
+ }
+
+ return setFocusedIndex(lastSelectableIndex);
+}
+
+void WebPopupMenuProxyWin::paint(const IntRect& damageRect, HDC hdc)
+{
+ if (!m_popup)
+ return;
+
+ if (!m_DC) {
+ m_DC = ::CreateCompatibleDC(::GetDC(m_popup));
+ if (!m_DC)
+ return;
+ }
+
+ if (m_bmp) {
+ bool keepBitmap = false;
+ BITMAP bitmap;
+ if (::GetObject(m_bmp, sizeof(bitmap), &bitmap))
+ keepBitmap = bitmap.bmWidth == clientRect().width() && bitmap.bmHeight == clientRect().height();
+ if (!keepBitmap) {
+ ::DeleteObject(m_bmp);
+ m_bmp = 0;
+ }
+ }
+
+ if (!m_bmp) {
+ BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(clientRect().size());
+ void* pixels = 0;
+ m_bmp = ::CreateDIBSection(m_DC, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0);
+ if (!m_bmp)
+ return;
+ ::SelectObject(m_DC, m_bmp);
+ }
+
+ GraphicsContext context(m_DC);
+
+ IntRect translatedDamageRect = damageRect;
+ translatedDamageRect.move(IntSize(0, m_scrollOffset * m_itemHeight));
+ m_data.m_notSelectedBackingStore->paint(context, damageRect.location(), translatedDamageRect);
+
+ IntRect selectedIndexRectInBackingStore(0, focusedIndex() * m_itemHeight, m_data.m_selectedBackingStore->size().width(), m_itemHeight);
+ IntPoint selectedIndexDstPoint = selectedIndexRectInBackingStore.location();
+ selectedIndexDstPoint.move(0, -m_scrollOffset * m_itemHeight);
+
+ m_data.m_selectedBackingStore->paint(context, selectedIndexDstPoint, selectedIndexRectInBackingStore);
+
+ if (m_scrollbar)
+ m_scrollbar->paint(&context, damageRect);
+
+ HDC localDC = hdc ? hdc : ::GetDC(m_popup);
+
+ ::BitBlt(localDC, damageRect.x(), damageRect.y(), damageRect.width(), damageRect.height(), m_DC, damageRect.x(), damageRect.y(), SRCCOPY);
+
+ if (!hdc)
+ ::ReleaseDC(m_popup, localDC);
+}
+
+bool WebPopupMenuProxyWin::setFocusedIndex(int i, bool hotTracking)
+{
+ if (i < 0 || i >= m_items.size() || i == focusedIndex())
+ return false;
+
+ if (!m_items[i].m_isEnabled)
+ return false;
+
+ invalidateItem(focusedIndex());
+ invalidateItem(i);
+
+ m_focusedIndex = i;
+
+ if (!hotTracking) {
+ if (WebPopupMenuProxy::m_client)
+ WebPopupMenuProxy::m_client->setTextFromItemForPopupMenu(this, i);
+ }
+
+ if (!scrollToRevealSelection())
+ ::UpdateWindow(m_popup);
+
+ return true;
+}
+
+int WebPopupMenuProxyWin::visibleItems() const
+{
+ return clientRect().height() / m_itemHeight;
+}
+
+int WebPopupMenuProxyWin::listIndexAtPoint(const IntPoint& point) const
+{
+ return m_scrollOffset + point.y() / m_itemHeight;
+}
+
+int WebPopupMenuProxyWin::focusedIndex() const
+{
+ return m_focusedIndex;
+}
+
+void WebPopupMenuProxyWin::focusFirst()
+{
+ int size = m_items.size();
+
+ for (int i = 0; i < size; ++i) {
+ if (m_items[i].m_isEnabled) {
+ setFocusedIndex(i);
+ break;
+ }
+ }
+}
+
+void WebPopupMenuProxyWin::focusLast()
+{
+ int size = m_items.size();
+
+ for (int i = size - 1; i > 0; --i) {
+ if (m_items[i].m_isEnabled) {
+ setFocusedIndex(i);
+ break;
+ }
+ }
+}
+
+
+void WebPopupMenuProxyWin::incrementWheelDelta(int delta)
+{
+ m_wheelDelta += delta;
+}
+
+void WebPopupMenuProxyWin::reduceWheelDelta(int delta)
+{
+ ASSERT(delta >= 0);
+ ASSERT(delta <= abs(m_wheelDelta));
+
+ if (m_wheelDelta > 0)
+ m_wheelDelta -= delta;
+ else if (m_wheelDelta < 0)
+ m_wheelDelta += delta;
+ else
+ return;
+}
+
+bool WebPopupMenuProxyWin::scrollToRevealSelection()
+{
+ if (!m_scrollbar)
+ return false;
+
+ int index = focusedIndex();
+
+ if (index < m_scrollOffset) {
+ ScrollableArea::scrollToYOffsetWithoutAnimation(index);
+ return true;
+ }
+
+ if (index >= m_scrollOffset + visibleItems()) {
+ ScrollableArea::scrollToYOffsetWithoutAnimation(index - visibleItems() + 1);
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
new file mode 100644
index 000000000..b7c4d6d29
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
@@ -0,0 +1,144 @@
+/*
+ * 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 WebPopupMenuProxyWin_h
+#define WebPopupMenuProxyWin_h
+
+#include "PlatformPopupMenuData.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxy.h"
+#include <WebCore/Scrollbar.h>
+#include <WebCore/ScrollableArea.h>
+
+typedef struct HWND__* HWND;
+typedef struct HDC__* HDC;
+typedef struct HBITMAP__* HBITMAP;
+
+namespace WebKit {
+
+class WebView;
+
+class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollableArea {
+public:
+ static PassRefPtr<WebPopupMenuProxyWin> create(WebView* webView, WebPopupMenuProxy::Client* client)
+ {
+ return adoptRef(new WebPopupMenuProxyWin(webView, client));
+ }
+ ~WebPopupMenuProxyWin();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, WebCore::TextDirection, double pageScaleFactor, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+ bool setFocusedIndex(int index, bool hotTracking = false);
+
+ void hide() { hidePopupMenu(); }
+
+private:
+ WebPopupMenuProxyWin(WebView*, WebPopupMenuProxy::Client*);
+
+ WebCore::Scrollbar* scrollbar() const { return m_scrollbar.get(); }
+
+ // ScrollableArea
+ virtual int scrollSize(WebCore::ScrollbarOrientation) const;
+ virtual int scrollPosition(WebCore::Scrollbar*) const;
+ virtual void setScrollOffset(const WebCore::IntPoint&);
+ virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&);
+ virtual void invalidateScrollCornerRect(const WebCore::IntRect&) { }
+ virtual bool isActive() const { return true; }
+ virtual bool isScrollCornerVisible() const { return false; }
+ virtual WebCore::IntRect scrollCornerRect() const { return WebCore::IntRect(); }
+ virtual WebCore::Scrollbar* verticalScrollbar() const { return m_scrollbar.get(); }
+ virtual WebCore::ScrollableArea* enclosingScrollableArea() const { return 0; }
+
+ // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
+ void scrollTo(int offset);
+
+ static bool registerWindowClass();
+ static LRESULT CALLBACK WebPopupMenuProxyWndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+ // Message pump messages.
+ LRESULT onMouseActivate(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onSize(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onKeyDown(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onChar(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onMouseMove(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onLButtonDown(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onLButtonUp(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onMouseWheel(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onPaint(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onPrintClient(HWND, UINT message, WPARAM, LPARAM, bool& handled);
+
+ void calculatePositionAndSize(const WebCore::IntRect&);
+ WebCore::IntRect clientRect() const;
+ void invalidateItem(int index);
+
+ int itemHeight() const { return m_itemHeight; }
+ const WebCore::IntRect& windowRect() const { return m_windowRect; }
+ int wheelDelta() const { return m_wheelDelta; }
+ void setWasClicked(bool b = true) { m_wasClicked = b; }
+ bool wasClicked() const { return m_wasClicked; }
+ void setScrollOffset(int offset) { m_scrollOffset = offset; }
+ int scrollOffset() const { return m_scrollOffset; }
+ bool scrollbarCapturingMouse() const { return m_scrollbarCapturingMouse; }
+ void setScrollbarCapturingMouse(bool b) { m_scrollbarCapturingMouse = b; }
+
+
+ bool up(unsigned lines = 1);
+ bool down(unsigned lines = 1);
+
+ void paint(const WebCore::IntRect& damageRect, HDC = 0);
+ int visibleItems() const;
+ int listIndexAtPoint(const WebCore::IntPoint&) const;
+ int focusedIndex() const;
+ void focusFirst();
+ void focusLast();
+ bool scrollToRevealSelection();
+ void incrementWheelDelta(int delta);
+ void reduceWheelDelta(int delta);
+
+ WebView* m_webView;
+ Vector<WebPopupItem> m_items;
+ PlatformPopupMenuData m_data;
+ int m_newSelectedIndex;
+
+ RefPtr<WebCore::Scrollbar> m_scrollbar;
+ HWND m_popup;
+ HDC m_DC;
+ HBITMAP m_bmp;
+ WebCore::IntRect m_windowRect;
+
+ int m_itemHeight;
+ int m_scrollOffset;
+ int m_wheelDelta;
+ int m_focusedIndex;
+ bool m_wasClicked;
+ bool m_scrollbarCapturingMouse;
+ bool m_showPopup;
+};
+
+} // namespace WebKit
+
+#endif // WebPopupMenuProxyWin_h
diff --git a/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp
new file mode 100644
index 000000000..1856b3b00
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebProcessProxyWin.cpp
@@ -0,0 +1,36 @@
+/*
+ * 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 "WebProcessProxy.h"
+
+namespace WebKit {
+
+Vector<HWND> WebProcessProxy::windowsToReceiveSentMessagesWhileWaitingForSyncReply()
+{
+ return Vector<HWND>();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebUndoClient.cpp b/Source/WebKit2/UIProcess/win/WebUndoClient.cpp
new file mode 100644
index 000000000..a408bc3a2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebUndoClient.cpp
@@ -0,0 +1,69 @@
+/*
+ * 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 "WebUndoClient.h"
+
+#include "WKAPICast.h"
+#include "WebEditCommandProxy.h"
+#include "WebView.h"
+
+namespace WebKit {
+
+void WebUndoClient::registerEditCommand(WebView* view, PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (!m_client.registerEditCommand)
+ return;
+
+ RefPtr<WebEditCommandProxy> command = prpCommand;
+ m_client.registerEditCommand(toAPI(view), toAPI(command.release().leakRef()), (undoOrRedo == WebPageProxy::Undo) ? kWKViewUndo : kWKViewRedo, m_client.clientInfo);
+}
+
+void WebUndoClient::clearAllEditCommands(WebView* view)
+{
+ if (!m_client.clearAllEditCommands)
+ return;
+
+ m_client.clearAllEditCommands(toAPI(view), m_client.clientInfo);
+}
+
+bool WebUndoClient::canUndoRedo(WebView* view, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (!m_client.canUndoRedo)
+ return false;
+
+ return m_client.canUndoRedo(toAPI(view), undoOrRedo, m_client.clientInfo);
+}
+
+void WebUndoClient::executeUndoRedo(WebView* view, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ if (!m_client.executeUndoRedo)
+ return;
+
+ m_client.executeUndoRedo(toAPI(view), undoOrRedo, m_client.clientInfo);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/win/WebUndoClient.h b/Source/WebKit2/UIProcess/win/WebUndoClient.h
new file mode 100644
index 000000000..67e6cdf63
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebUndoClient.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.
+ */
+
+#ifndef WebUndoClient_h
+#define WebUndoClient_h
+
+#include "APIClient.h"
+#include "WKView.h"
+#include "WebPageProxy.h"
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebEditCommandProxy;
+
+class WebUndoClient : public APIClient<WKViewUndoClient, kWKViewUndoClientCurrentVersion> {
+public:
+ void registerEditCommand(WebView*, PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ void clearAllEditCommands(WebView*);
+ bool canUndoRedo(WebView*, WebPageProxy::UndoOrRedo);
+ void executeUndoRedo(WebView*, WebPageProxy::UndoOrRedo);
+};
+
+} // namespace WebKit
+
+#endif // WebUndoClient_h
diff --git a/Source/WebKit2/UIProcess/win/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp
new file mode 100644
index 000000000..d44e25560
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebView.cpp
@@ -0,0 +1,1782 @@
+/*
+ * 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 "WebView.h"
+
+#include "DrawingAreaProxyImpl.h"
+#include "FindIndicator.h"
+#include "Logging.h"
+#include "NativeWebKeyboardEvent.h"
+#include "NativeWebMouseEvent.h"
+#include "NativeWebWheelEvent.h"
+#include "RunLoop.h"
+#include "WKAPICast.h"
+#if USE(CG)
+#include "WKCACFViewWindow.h"
+#endif
+#include "WebContext.h"
+#include "WebContextMenuProxyWin.h"
+#include "WebEditCommandProxy.h"
+#include "WebEventFactory.h"
+#include "WebPageProxy.h"
+#include "WebPopupMenuProxyWin.h"
+#include <Commctrl.h>
+#include <WebCore/BitmapInfo.h>
+#include <WebCore/Cursor.h>
+#include <WebCore/DragSession.h>
+#include <WebCore/Editor.h>
+#include <WebCore/FloatRect.h>
+#if USE(CG)
+#include <WebCore/GraphicsContextCG.h>
+#endif
+#include <WebCore/IntRect.h>
+#include <WebCore/NotImplemented.h>
+#include <WebCore/Region.h>
+#include <WebCore/SoftLinking.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebCore/WindowMessageBroadcaster.h>
+#include <WebCore/WindowsTouch.h>
+#include <wtf/text/WTFString.h>
+
+#if ENABLE(FULLSCREEN_API)
+#include "WebFullScreenManagerProxy.h"
+#include <WebCore/FullScreenController.h>
+#endif
+
+namespace Ime {
+// We need these functions in a separate namespace, because in the global namespace they conflict
+// with the definitions in imm.h only by the type modifier (the macro defines them as static) and
+// imm.h is included by windows.h
+SOFT_LINK_LIBRARY(IMM32)
+SOFT_LINK(IMM32, ImmGetContext, HIMC, WINAPI, (HWND hwnd), (hwnd))
+SOFT_LINK(IMM32, ImmReleaseContext, BOOL, WINAPI, (HWND hWnd, HIMC hIMC), (hWnd, hIMC))
+SOFT_LINK(IMM32, ImmGetCompositionStringW, LONG, WINAPI, (HIMC hIMC, DWORD dwIndex, LPVOID lpBuf, DWORD dwBufLen), (hIMC, dwIndex, lpBuf, dwBufLen))
+SOFT_LINK(IMM32, ImmSetCandidateWindow, BOOL, WINAPI, (HIMC hIMC, LPCANDIDATEFORM lpCandidate), (hIMC, lpCandidate))
+SOFT_LINK(IMM32, ImmSetOpenStatus, BOOL, WINAPI, (HIMC hIMC, BOOL fOpen), (hIMC, fOpen))
+SOFT_LINK(IMM32, ImmNotifyIME, BOOL, WINAPI, (HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue), (hIMC, dwAction, dwIndex, dwValue))
+SOFT_LINK(IMM32, ImmAssociateContextEx, BOOL, WINAPI, (HWND hWnd, HIMC hIMC, DWORD dwFlags), (hWnd, hIMC, dwFlags))
+};
+
+// Soft link functions for gestures and panning.
+SOFT_LINK_LIBRARY(USER32);
+SOFT_LINK_OPTIONAL(USER32, GetGestureInfo, BOOL, WINAPI, (HGESTUREINFO, PGESTUREINFO));
+SOFT_LINK_OPTIONAL(USER32, SetGestureConfig, BOOL, WINAPI, (HWND, DWORD, UINT, PGESTURECONFIG, UINT));
+SOFT_LINK_OPTIONAL(USER32, CloseGestureInfoHandle, BOOL, WINAPI, (HGESTUREINFO));
+
+SOFT_LINK_LIBRARY(Uxtheme);
+SOFT_LINK_OPTIONAL(Uxtheme, BeginPanningFeedback, BOOL, WINAPI, (HWND));
+SOFT_LINK_OPTIONAL(Uxtheme, EndPanningFeedback, BOOL, WINAPI, (HWND, BOOL));
+SOFT_LINK_OPTIONAL(Uxtheme, UpdatePanningFeedback, BOOL, WINAPI, (HWND, LONG, LONG, BOOL));
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const LPCWSTR kWebKit2WebViewWindowClassName = L"WebKit2WebViewWindowClass";
+
+// Constants not available on all platforms.
+const int WM_XP_THEMECHANGED = 0x031A;
+const int WM_VISTA_MOUSEHWHEEL = 0x020E;
+
+static const int kMaxToolTipWidth = 250;
+
+enum {
+ UpdateActiveStateTimer = 1,
+};
+
+LRESULT CALLBACK WebView::WebViewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LONG_PTR longPtr = ::GetWindowLongPtr(hWnd, 0);
+
+ if (WebView* webView = reinterpret_cast<WebView*>(longPtr))
+ return webView->wndProc(hWnd, message, wParam, lParam);
+
+ if (message == WM_CREATE) {
+ LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam);
+
+ // Associate the WebView with the window.
+ ::SetWindowLongPtr(hWnd, 0, (LONG_PTR)createStruct->lpCreateParams);
+ return 0;
+ }
+
+ return ::DefWindowProc(hWnd, message, wParam, lParam);
+}
+
+LRESULT WebView::wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT lResult = 0;
+ bool handled = true;
+
+ switch (message) {
+ case WM_CLOSE:
+ m_page->tryClose();
+ break;
+ case WM_DESTROY:
+ m_isBeingDestroyed = true;
+ close();
+ break;
+ case WM_ERASEBKGND:
+ lResult = 1;
+ break;
+ case WM_PAINT:
+ lResult = onPaintEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_PRINTCLIENT:
+ lResult = onPrintClientEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_MOUSEACTIVATE:
+ setWasActivatedByMouseEvent(true);
+ handled = false;
+ break;
+ case WM_MOUSEMOVE:
+ case WM_LBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MOUSELEAVE:
+ lResult = onMouseEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_MOUSEWHEEL:
+ case WM_VISTA_MOUSEHWHEEL:
+ lResult = onWheelEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_HSCROLL:
+ lResult = onHorizontalScroll(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_VSCROLL:
+ lResult = onVerticalScroll(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_GESTURENOTIFY:
+ lResult = onGestureNotify(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_GESTURE:
+ lResult = onGesture(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SYSKEYDOWN:
+ case WM_KEYDOWN:
+ case WM_SYSCHAR:
+ case WM_CHAR:
+ case WM_SYSKEYUP:
+ case WM_KEYUP:
+ lResult = onKeyEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SIZE:
+ lResult = onSizeEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_WINDOWPOSCHANGED:
+ lResult = onWindowPositionChangedEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SETFOCUS:
+ lResult = onSetFocusEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_KILLFOCUS:
+ lResult = onKillFocusEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_TIMER:
+ lResult = onTimerEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SHOWWINDOW:
+ lResult = onShowWindowEvent(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_SETCURSOR:
+ lResult = onSetCursor(hWnd, message, wParam, lParam, handled);
+ break;
+ case WM_IME_STARTCOMPOSITION:
+ handled = onIMEStartComposition();
+ break;
+ case WM_IME_REQUEST:
+ lResult = onIMERequest(wParam, lParam);
+ break;
+ case WM_IME_COMPOSITION:
+ handled = onIMEComposition(lParam);
+ break;
+ case WM_IME_ENDCOMPOSITION:
+ handled = onIMEEndComposition();
+ break;
+ case WM_IME_SELECT:
+ handled = onIMESelect(wParam, lParam);
+ break;
+ case WM_IME_SETCONTEXT:
+ handled = onIMESetContext(wParam, lParam);
+ break;
+ default:
+ handled = false;
+ break;
+ }
+
+ if (!handled)
+ lResult = ::DefWindowProc(hWnd, message, wParam, lParam);
+
+ return lResult;
+}
+
+bool WebView::registerWebViewWindowClass()
+{
+ static bool haveRegisteredWindowClass = false;
+ if (haveRegisteredWindowClass)
+ return true;
+ haveRegisteredWindowClass = true;
+
+ WNDCLASSEX wcex;
+
+ wcex.cbSize = sizeof(WNDCLASSEX);
+ wcex.style = CS_DBLCLKS;
+ wcex.lpfnWndProc = WebView::WebViewWndProc;
+ wcex.cbClsExtra = 0;
+ wcex.cbWndExtra = sizeof(WebView*);
+ wcex.hInstance = instanceHandle();
+ wcex.hIcon = 0;
+ wcex.hCursor = ::LoadCursor(0, IDC_ARROW);
+ wcex.hbrBackground = 0;
+ wcex.lpszMenuName = 0;
+ wcex.lpszClassName = kWebKit2WebViewWindowClassName;
+ wcex.hIconSm = 0;
+
+ return !!::RegisterClassEx(&wcex);
+}
+
+WebView::WebView(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND parentWindow)
+ : m_topLevelParentWindow(0)
+ , m_toolTipWindow(0)
+ , m_lastCursorSet(0)
+ , m_webCoreCursor(0)
+ , m_overrideCursor(0)
+ , m_trackingMouseLeave(false)
+ , m_isInWindow(false)
+ , m_isVisible(false)
+ , m_wasActivatedByMouseEvent(false)
+ , m_isBeingDestroyed(false)
+ , m_inIMEComposition(0)
+ , m_findIndicatorCallback(0)
+ , m_findIndicatorCallbackContext(0)
+ , m_pageOverlayInstalled(false)
+ , m_lastPanX(0)
+ , m_lastPanY(0)
+ , m_overPanY(0)
+ , m_gestureReachedScrollingLimit(false)
+#if USE(ACCELERATED_COMPOSITING)
+ , m_layerHostWindow(0)
+#endif
+{
+ registerWebViewWindowClass();
+
+ m_window = ::CreateWindowExW(0, kWebKit2WebViewWindowClassName, 0, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE,
+ rect.top, rect.left, rect.right - rect.left, rect.bottom - rect.top, parentWindow ? parentWindow : HWND_MESSAGE, 0, instanceHandle(), this);
+ ASSERT(::IsWindow(m_window));
+ // We only check our window style, and not ::IsWindowVisible, because m_isVisible only tracks
+ // this window's visibility status, while ::IsWindowVisible takes our ancestors' visibility
+ // status into account. <http://webkit.org/b/54104>
+ ASSERT(m_isVisible == static_cast<bool>(::GetWindowLong(m_window, GWL_STYLE) & WS_VISIBLE));
+
+ m_page = context->createWebPage(this, pageGroup);
+ m_page->initializeWebPage();
+
+ CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, (void**)&m_dropTargetHelper);
+
+ // FIXME: Initializing the tooltip window here matches WebKit win, but seems like something
+ // we could do on demand to save resources.
+ initializeToolTipWindow();
+
+ // Initialize the top level parent window and register it with the WindowMessageBroadcaster.
+ windowAncestryDidChange();
+
+#if ENABLE(FULLSCREEN_API)
+ m_page->fullScreenManager()->setWebView(this);
+#endif
+}
+
+WebView::~WebView()
+{
+ // Tooltip window needs to be explicitly destroyed since it isn't a WS_CHILD.
+ if (::IsWindow(m_toolTipWindow))
+ ::DestroyWindow(m_toolTipWindow);
+}
+
+void WebView::initialize()
+{
+ ::RegisterDragDrop(m_window, this);
+
+ if (shouldInitializeTrackPointHack()) {
+ // If we detected a registry key belonging to a TrackPoint driver, then create fake
+ // scrollbars, so the WebView will receive WM_VSCROLL and WM_HSCROLL messages.
+ // We create an invisible vertical scrollbar and an invisible horizontal scrollbar to allow
+ // for receiving both types of messages.
+ ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTHSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_HORZ, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
+ ::CreateWindow(TEXT("SCROLLBAR"), TEXT("FAKETRACKPOINTVSCROLLBAR"), WS_CHILD | WS_VISIBLE | SBS_VERT, 0, 0, 0, 0, m_window, 0, instanceHandle(), 0);
+ }
+}
+
+void WebView::initializeUndoClient(const WKViewUndoClient* client)
+{
+ m_undoClient.initialize(client);
+}
+
+void WebView::setParentWindow(HWND parentWindow)
+{
+ if (m_window) {
+ // If the host window hasn't changed, bail.
+ if (::GetParent(m_window) == parentWindow)
+ return;
+ if (parentWindow)
+ ::SetParent(m_window, parentWindow);
+ else if (!m_isBeingDestroyed) {
+ // Turn the WebView into a message-only window so it will no longer be a child of the
+ // old parent window and will be hidden from screen. We only do this when
+ // isBeingDestroyed() is false because doing this while handling WM_DESTROY can leave
+ // m_window in a weird state (see <http://webkit.org/b/29337>).
+ ::SetParent(m_window, HWND_MESSAGE);
+ }
+ }
+
+ windowAncestryDidChange();
+}
+
+static HWND findTopLevelParentWindow(HWND window)
+{
+ if (!window)
+ return 0;
+
+ HWND current = window;
+ for (HWND parent = GetParent(current); current; current = parent, parent = GetParent(parent)) {
+ if (!parent || !(GetWindowLongPtr(current, GWL_STYLE) & (WS_POPUP | WS_CHILD)))
+ return current;
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void WebView::windowAncestryDidChange()
+{
+ HWND newTopLevelParentWindow;
+ if (m_window)
+ newTopLevelParentWindow = findTopLevelParentWindow(m_window);
+ else {
+ // There's no point in tracking active state changes of our parent window if we don't have
+ // a window ourselves.
+ newTopLevelParentWindow = 0;
+ }
+
+ if (newTopLevelParentWindow == m_topLevelParentWindow)
+ return;
+
+ if (m_topLevelParentWindow)
+ WindowMessageBroadcaster::removeListener(m_topLevelParentWindow, this);
+
+ m_topLevelParentWindow = newTopLevelParentWindow;
+
+ if (m_topLevelParentWindow)
+ WindowMessageBroadcaster::addListener(m_topLevelParentWindow, this);
+
+ updateActiveState();
+}
+
+LRESULT WebView::onMouseEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ NativeWebMouseEvent mouseEvent = NativeWebMouseEvent(hWnd, message, wParam, lParam, m_wasActivatedByMouseEvent);
+ setWasActivatedByMouseEvent(false);
+
+ switch (message) {
+ case WM_LBUTTONDOWN:
+ case WM_MBUTTONDOWN:
+ case WM_RBUTTONDOWN:
+ ::SetFocus(m_window);
+ ::SetCapture(m_window);
+ break;
+ case WM_LBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_RBUTTONUP:
+ ::ReleaseCapture();
+ break;
+ case WM_MOUSEMOVE:
+ startTrackingMouseLeave();
+ break;
+ case WM_MOUSELEAVE:
+ stopTrackingMouseLeave();
+ break;
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDBLCLK:
+ case WM_RBUTTONDBLCLK:
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ m_page->handleMouseEvent(mouseEvent);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onWheelEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ NativeWebWheelEvent wheelEvent(hWnd, message, wParam, lParam);
+ if (wheelEvent.controlKey()) {
+ // We do not want WebKit to handle Control + Wheel, this should be handled by the client application
+ // to zoom the page.
+ handled = false;
+ return 0;
+ }
+
+ m_page->handleWheelEvent(wheelEvent);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onHorizontalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+ switch (LOWORD(wParam)) {
+ case SB_LINELEFT:
+ granularity = ScrollByLine;
+ direction = ScrollLeft;
+ break;
+ case SB_LINERIGHT:
+ granularity = ScrollByLine;
+ direction = ScrollRight;
+ break;
+ case SB_PAGELEFT:
+ granularity = ScrollByDocument;
+ direction = ScrollLeft;
+ break;
+ case SB_PAGERIGHT:
+ granularity = ScrollByDocument;
+ direction = ScrollRight;
+ break;
+ default:
+ handled = false;
+ return 0;
+ }
+
+ m_page->scrollBy(direction, granularity);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onVerticalScroll(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+ switch (LOWORD(wParam)) {
+ case SB_LINEDOWN:
+ granularity = ScrollByLine;
+ direction = ScrollDown;
+ break;
+ case SB_LINEUP:
+ granularity = ScrollByLine;
+ direction = ScrollUp;
+ break;
+ case SB_PAGEDOWN:
+ granularity = ScrollByDocument;
+ direction = ScrollDown;
+ break;
+ case SB_PAGEUP:
+ granularity = ScrollByDocument;
+ direction = ScrollUp;
+ break;
+ default:
+ handled = false;
+ return 0;
+ }
+
+ m_page->scrollBy(direction, granularity);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onGestureNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ // We shouldn't be getting any gesture messages without SetGestureConfig soft-linking correctly.
+ ASSERT(SetGestureConfigPtr());
+
+ GESTURENOTIFYSTRUCT* gn = reinterpret_cast<GESTURENOTIFYSTRUCT*>(lParam);
+
+ POINT localPoint = { gn->ptsLocation.x, gn->ptsLocation.y };
+ ::ScreenToClient(m_window, &localPoint);
+
+ bool canPan = m_page->gestureWillBegin(localPoint);
+
+ DWORD dwPanWant = GC_PAN | GC_PAN_WITH_INERTIA | GC_PAN_WITH_GUTTER;
+ DWORD dwPanBlock = GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY;
+ if (canPan)
+ dwPanWant |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+ else
+ dwPanBlock |= GC_PAN_WITH_SINGLE_FINGER_VERTICALLY;
+
+ GESTURECONFIG gc = { GID_PAN, dwPanWant, dwPanBlock };
+ return SetGestureConfigPtr()(m_window, 0, 1, &gc, sizeof(gc));
+}
+
+LRESULT WebView::onGesture(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ ASSERT(GetGestureInfoPtr());
+ ASSERT(CloseGestureInfoHandlePtr());
+ ASSERT(UpdatePanningFeedbackPtr());
+ ASSERT(BeginPanningFeedbackPtr());
+ ASSERT(EndPanningFeedbackPtr());
+
+ if (!GetGestureInfoPtr() || !CloseGestureInfoHandlePtr() || !UpdatePanningFeedbackPtr() || !BeginPanningFeedbackPtr() || !EndPanningFeedbackPtr()) {
+ handled = false;
+ return 0;
+ }
+
+ HGESTUREINFO gestureHandle = reinterpret_cast<HGESTUREINFO>(lParam);
+ GESTUREINFO gi = {0};
+ gi.cbSize = sizeof(GESTUREINFO);
+
+ if (!GetGestureInfoPtr()(gestureHandle, &gi)) {
+ handled = false;
+ return 0;
+ }
+
+ switch (gi.dwID) {
+ case GID_BEGIN:
+ m_lastPanX = gi.ptsLocation.x;
+ m_lastPanY = gi.ptsLocation.y;
+ break;
+ case GID_END:
+ m_page->gestureDidEnd();
+ break;
+ case GID_PAN: {
+ int currentX = gi.ptsLocation.x;
+ int currentY = gi.ptsLocation.y;
+
+ // Reverse the calculations because moving your fingers up should move the screen down, and
+ // vice-versa.
+ int deltaX = m_lastPanX - currentX;
+ int deltaY = m_lastPanY - currentY;
+
+ m_lastPanX = currentX;
+ m_lastPanY = currentY;
+
+ // Calculate the overpan for window bounce.
+ m_overPanY -= deltaY;
+
+ if (deltaX || deltaY)
+ m_page->gestureDidScroll(IntSize(deltaX, deltaY));
+
+ if (gi.dwFlags & GF_BEGIN) {
+ BeginPanningFeedbackPtr()(m_window);
+ m_gestureReachedScrollingLimit = false;
+ m_overPanY = 0;
+ } else if (gi.dwFlags & GF_END) {
+ EndPanningFeedbackPtr()(m_window, true);
+ m_overPanY = 0;
+ }
+
+ // FIXME: Support horizontal window bounce - <http://webkit.org/b/58068>.
+ // FIXME: Window Bounce doesn't undo until user releases their finger - <http://webkit.org/b/58069>.
+
+ if (m_gestureReachedScrollingLimit)
+ UpdatePanningFeedbackPtr()(m_window, 0, m_overPanY, gi.dwFlags & GF_INERTIA);
+
+ CloseGestureInfoHandlePtr()(gestureHandle);
+
+ handled = true;
+ return 0;
+ }
+ default:
+ break;
+ }
+
+ // If we get to this point, the gesture has not been handled. We forward
+ // the call to DefWindowProc by returning false, and we don't need to
+ // to call CloseGestureInfoHandle.
+ // http://msdn.microsoft.com/en-us/library/dd353228(VS.85).aspx
+ handled = false;
+ return 0;
+}
+
+LRESULT WebView::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+#if ENABLE(FULLSCREEN_API)
+ // Trap the ESC key when in full screen mode.
+ if (message == WM_KEYDOWN && wParam == VK_ESCAPE && m_fullScreenController && m_fullScreenController->isFullScreen()) {
+ m_fullScreenController->exitFullScreen();
+ return false;
+ }
+#endif
+
+ m_page->handleKeyboardEvent(NativeWebKeyboardEvent(hWnd, message, wParam, lParam));
+
+ // We claim here to always have handled the event. If the event is not in fact handled, we will
+ // find out later in didNotHandleKeyEvent.
+ handled = true;
+ return 0;
+}
+
+static void drawPageBackground(HDC dc, const WebPageProxy* page, const RECT& rect)
+{
+ if (!page->drawsBackground() || page->drawsTransparentBackground())
+ return;
+
+ ::FillRect(dc, &rect, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1));
+}
+
+void WebView::paint(HDC hdc, const IntRect& dirtyRect)
+{
+ m_page->endPrinting();
+ if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(m_page->drawingArea())) {
+ // FIXME: We should port WebKit1's rect coalescing logic here.
+ Region unpaintedRegion;
+ drawingArea->paint(hdc, dirtyRect, unpaintedRegion);
+
+ Vector<IntRect> unpaintedRects = unpaintedRegion.rects();
+ for (size_t i = 0; i < unpaintedRects.size(); ++i) {
+ RECT winRect = unpaintedRects[i];
+ drawPageBackground(hdc, m_page.get(), unpaintedRects[i]);
+ }
+ } else
+ drawPageBackground(hdc, m_page.get(), dirtyRect);
+
+ m_page->didDraw();
+}
+
+static void flashRects(HDC dc, const IntRect rects[], size_t rectCount, HBRUSH brush)
+{
+ for (size_t i = 0; i < rectCount; ++i) {
+ RECT winRect = rects[i];
+ ::FillRect(dc, &winRect, brush);
+ }
+
+ ::GdiFlush();
+ ::Sleep(50);
+}
+
+static OwnPtr<HBRUSH> createBrush(const Color& color)
+{
+ return adoptPtr(::CreateSolidBrush(RGB(color.red(), color.green(), color.blue())));
+}
+
+LRESULT WebView::onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
+{
+ // Update child windows now so that any areas of our window they reveal will be included in the
+ // invalid region that ::BeginPaint sees.
+ updateChildWindowGeometries();
+
+ PAINTSTRUCT paintStruct;
+ HDC hdc = ::BeginPaint(m_window, &paintStruct);
+
+ if (WebPageProxy::debugPaintFlags() & kWKDebugFlashViewUpdates) {
+ static HBRUSH brush = createBrush(WebPageProxy::viewUpdatesFlashColor().rgb()).leakPtr();
+ IntRect rect = paintStruct.rcPaint;
+ flashRects(hdc, &rect, 1, brush);
+ }
+
+ paint(hdc, paintStruct.rcPaint);
+
+ ::EndPaint(m_window, &paintStruct);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onPrintClientEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool& handled)
+{
+ HDC hdc = reinterpret_cast<HDC>(wParam);
+ RECT winRect;
+ ::GetClientRect(hWnd, &winRect);
+
+ // Twidding the visibility flags tells the DrawingArea to resume painting. Right now, the
+ // the visible state of the view only affects whether or not painting happens, but in the
+ // future it could affect more, which we wouldn't want to touch here.
+
+ // FIXME: We should have a better way of telling the WebProcess to draw even if we're
+ // invisible than twiddling the visibility flag.
+
+ bool wasVisible = isViewVisible();
+ if (!wasVisible)
+ setIsVisible(true);
+
+ paint(hdc, winRect);
+
+ if (!wasVisible)
+ setIsVisible(false);
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onSizeEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
+{
+ int width = LOWORD(lParam);
+ int height = HIWORD(lParam);
+
+ if (m_page && m_page->drawingArea()) {
+ m_page->drawingArea()->setSize(IntSize(width, height), m_nextResizeScrollOffset);
+ m_nextResizeScrollOffset = IntSize();
+ }
+
+#if USE(ACCELERATED_COMPOSITING)
+ if (m_layerHostWindow)
+ ::MoveWindow(m_layerHostWindow, 0, 0, width, height, FALSE);
+#endif
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onWindowPositionChangedEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
+{
+ if (reinterpret_cast<WINDOWPOS*>(lParam)->flags & SWP_SHOWWINDOW)
+ updateActiveStateSoon();
+
+ handled = false;
+ return 0;
+}
+
+LRESULT WebView::onSetFocusEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
+{
+ m_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onKillFocusEvent(HWND, UINT, WPARAM, LPARAM lParam, bool& handled)
+{
+ m_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onTimerEvent(HWND hWnd, UINT, WPARAM wParam, LPARAM, bool& handled)
+{
+ switch (wParam) {
+ case UpdateActiveStateTimer:
+ ::KillTimer(hWnd, UpdateActiveStateTimer);
+ updateActiveState();
+ break;
+ }
+
+ handled = true;
+ return 0;
+}
+
+LRESULT WebView::onShowWindowEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ // lParam is 0 when the message is sent because of a ShowWindow call.
+ // FIXME: Since we don't get notified when an ancestor window is hidden or shown, we will keep
+ // painting even when we have a hidden ancestor. <http://webkit.org/b/54104>
+ if (!lParam)
+ setIsVisible(wParam);
+
+ handled = false;
+ return 0;
+}
+
+LRESULT WebView::onSetCursor(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ if (!m_lastCursorSet) {
+ handled = false;
+ return 0;
+ }
+
+ ::SetCursor(m_lastCursorSet);
+ return 0;
+}
+
+void WebView::updateActiveState()
+{
+ m_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+}
+
+void WebView::updateActiveStateSoon()
+{
+ // This function is called while processing the WM_NCACTIVATE message.
+ // While processing WM_NCACTIVATE when we are being deactivated, GetActiveWindow() will
+ // still return our window. If we were to call updateActiveState() in that case, we would
+ // wrongly think that we are still the active window. To work around this, we update our
+ // active state after a 0-delay timer fires, at which point GetActiveWindow() will return
+ // the newly-activated window.
+
+ ::SetTimer(m_window, UpdateActiveStateTimer, 0, 0);
+}
+
+static bool initCommonControls()
+{
+ static bool haveInitialized = false;
+ if (haveInitialized)
+ return true;
+
+ INITCOMMONCONTROLSEX init;
+ init.dwSize = sizeof(init);
+ init.dwICC = ICC_TREEVIEW_CLASSES;
+ haveInitialized = !!::InitCommonControlsEx(&init);
+ return haveInitialized;
+}
+
+void WebView::initializeToolTipWindow()
+{
+ if (!initCommonControls())
+ return;
+
+ m_toolTipWindow = ::CreateWindowEx(WS_EX_TRANSPARENT, TOOLTIPS_CLASS, 0, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ m_window, 0, 0, 0);
+ if (!m_toolTipWindow)
+ return;
+
+ TOOLINFO info = {0};
+ info.cbSize = sizeof(info);
+ info.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
+ info.uId = reinterpret_cast<UINT_PTR>(m_window);
+
+ ::SendMessage(m_toolTipWindow, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&info));
+ ::SendMessage(m_toolTipWindow, TTM_SETMAXTIPWIDTH, 0, kMaxToolTipWidth);
+ ::SetWindowPos(m_toolTipWindow, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+}
+
+void WebView::startTrackingMouseLeave()
+{
+ if (m_trackingMouseLeave)
+ return;
+ m_trackingMouseLeave = true;
+
+ TRACKMOUSEEVENT trackMouseEvent;
+ trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT);
+ trackMouseEvent.dwFlags = TME_LEAVE;
+ trackMouseEvent.hwndTrack = m_window;
+
+ ::TrackMouseEvent(&trackMouseEvent);
+}
+
+void WebView::stopTrackingMouseLeave()
+{
+ if (!m_trackingMouseLeave)
+ return;
+ m_trackingMouseLeave = false;
+
+ TRACKMOUSEEVENT trackMouseEvent;
+ trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT);
+ trackMouseEvent.dwFlags = TME_LEAVE | TME_CANCEL;
+ trackMouseEvent.hwndTrack = m_window;
+
+ ::TrackMouseEvent(&trackMouseEvent);
+}
+
+bool WebView::shouldInitializeTrackPointHack()
+{
+ static bool shouldCreateScrollbars;
+ static bool hasRunTrackPointCheck;
+
+ if (hasRunTrackPointCheck)
+ return shouldCreateScrollbars;
+
+ hasRunTrackPointCheck = true;
+ const wchar_t* trackPointKeys[] = {
+ L"Software\\Lenovo\\TrackPoint",
+ L"Software\\Lenovo\\UltraNav",
+ L"Software\\Alps\\Apoint\\TrackPoint",
+ L"Software\\Synaptics\\SynTPEnh\\UltraNavUSB",
+ L"Software\\Synaptics\\SynTPEnh\\UltraNavPS2"
+ };
+
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(trackPointKeys); ++i) {
+ HKEY trackPointKey;
+ int readKeyResult = ::RegOpenKeyExW(HKEY_CURRENT_USER, trackPointKeys[i], 0, KEY_READ, &trackPointKey);
+ ::RegCloseKey(trackPointKey);
+ if (readKeyResult == ERROR_SUCCESS) {
+ shouldCreateScrollbars = true;
+ return shouldCreateScrollbars;
+ }
+ }
+
+ return shouldCreateScrollbars;
+}
+
+void WebView::close()
+{
+ m_undoClient.initialize(0);
+ ::RevokeDragDrop(m_window);
+ if (m_window) {
+ // We can't check IsWindow(m_window) here, because that will return true even while
+ // we're already handling WM_DESTROY. So we check !m_isBeingDestroyed instead.
+ if (!m_isBeingDestroyed)
+ DestroyWindow(m_window);
+ // Either we just destroyed m_window, or it's in the process of being destroyed. Either
+ // way, we clear it out to make sure we don't try to use it later.
+ m_window = 0;
+ }
+ setParentWindow(0);
+ m_page->close();
+}
+
+// PageClient
+
+PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
+{
+ return DrawingAreaProxyImpl::create(m_page.get());
+}
+
+void WebView::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ RECT r = rect;
+ ::InvalidateRect(m_window, &r, false);
+}
+
+void WebView::displayView()
+{
+ ::UpdateWindow(m_window);
+}
+
+void WebView::scrollView(const IntRect& scrollRect, const IntSize& scrollOffset)
+{
+ // FIXME: Actually scroll the view contents.
+ setViewNeedsDisplay(scrollRect);
+}
+
+void WebView::flashBackingStoreUpdates(const Vector<IntRect>& updateRects)
+{
+ static HBRUSH brush = createBrush(WebPageProxy::backingStoreUpdatesFlashColor().rgb()).leakPtr();
+ HDC dc = ::GetDC(m_window);
+ flashRects(dc, updateRects.data(), updateRects.size(), brush);
+ ::ReleaseDC(m_window, dc);
+}
+
+WebCore::IntSize WebView::viewSize()
+{
+ RECT clientRect;
+ GetClientRect(m_window, &clientRect);
+
+ return IntRect(clientRect).size();
+}
+
+bool WebView::isViewWindowActive()
+{
+ HWND activeWindow = ::GetActiveWindow();
+ return (activeWindow && m_topLevelParentWindow == findTopLevelParentWindow(activeWindow));
+}
+
+bool WebView::isViewFocused()
+{
+ return ::GetFocus() == m_window;
+}
+
+bool WebView::isViewVisible()
+{
+ return m_isVisible;
+}
+
+bool WebView::isViewInWindow()
+{
+ return m_isInWindow;
+}
+
+void WebView::pageClosed()
+{
+}
+
+void WebView::processDidCrash()
+{
+ updateNativeCursor();
+ ::InvalidateRect(m_window, 0, TRUE);
+}
+
+void WebView::didRelaunchProcess()
+{
+ updateNativeCursor();
+ ::InvalidateRect(m_window, 0, TRUE);
+}
+
+void WebView::toolTipChanged(const String&, const String& newToolTip)
+{
+ if (!m_toolTipWindow)
+ return;
+
+ if (!newToolTip.isEmpty()) {
+ // This is necessary because String::charactersWithNullTermination() is not const.
+ String toolTip = newToolTip;
+
+ TOOLINFO info = {0};
+ info.cbSize = sizeof(info);
+ info.uFlags = TTF_IDISHWND;
+ info.uId = reinterpret_cast<UINT_PTR>(m_window);
+ info.lpszText = const_cast<UChar*>(toolTip.charactersWithNullTermination());
+ ::SendMessage(m_toolTipWindow, TTM_UPDATETIPTEXT, 0, reinterpret_cast<LPARAM>(&info));
+ }
+
+ ::SendMessage(m_toolTipWindow, TTM_ACTIVATE, !newToolTip.isEmpty(), 0);
+}
+
+HCURSOR WebView::cursorToShow() const
+{
+ if (!m_page->isValid())
+ return 0;
+
+ // We only show the override cursor if the default (arrow) cursor is showing.
+ static HCURSOR arrowCursor = ::LoadCursor(0, IDC_ARROW);
+ if (m_overrideCursor && m_webCoreCursor == arrowCursor)
+ return m_overrideCursor;
+
+ return m_webCoreCursor;
+}
+
+void WebView::updateNativeCursor()
+{
+ m_lastCursorSet = cursorToShow();
+ if (!m_lastCursorSet)
+ return;
+ ::SetCursor(m_lastCursorSet);
+}
+
+void WebView::setCursor(const WebCore::Cursor& cursor)
+{
+ if (!cursor.platformCursor()->nativeCursor())
+ return;
+ m_webCoreCursor = cursor.platformCursor()->nativeCursor();
+ updateNativeCursor();
+}
+
+void WebView::setCursorHiddenUntilMouseMoves(bool)
+{
+ notImplemented();
+}
+
+void WebView::setOverrideCursor(HCURSOR overrideCursor)
+{
+ m_overrideCursor = overrideCursor;
+ updateNativeCursor();
+}
+
+void WebView::setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent& event)
+{
+ m_page->setInitialFocus(forward, isKeyboardEventValid, event);
+}
+
+void WebView::setScrollOffsetOnNextResize(const IntSize& scrollOffset)
+{
+ // The next time we get a WM_SIZE message, scroll by the specified amount in onSizeEvent().
+ m_nextResizeScrollOffset = scrollOffset;
+}
+
+void WebView::didChangeViewportProperties(const WebCore::ViewportArguments&)
+{
+}
+
+void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ RefPtr<WebEditCommandProxy> command = prpCommand;
+ m_undoClient.registerEditCommand(this, command, undoOrRedo);
+}
+
+void WebView::clearAllEditCommands()
+{
+ m_undoClient.clearAllEditCommands(this);
+}
+
+bool WebView::canUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ return m_undoClient.canUndoRedo(this, undoOrRedo);
+}
+
+void WebView::executeUndoRedo(WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ m_undoClient.executeUndoRedo(this, undoOrRedo);
+}
+
+void WebView::reapplyEditCommand(WebEditCommandProxy* command)
+{
+ if (!m_page->isValid() || !m_page->isValidEditCommand(command))
+ return;
+
+ command->reapply();
+}
+
+void WebView::unapplyEditCommand(WebEditCommandProxy* command)
+{
+ if (!m_page->isValid() || !m_page->isValidEditCommand(command))
+ return;
+
+ command->unapply();
+}
+
+void WebView::setCustomDropTarget(IDropTarget* dropTarget)
+{
+ if (!m_page->isValid() || !m_window)
+ return;
+
+ ::RevokeDragDrop(m_window);
+
+ if (dropTarget)
+ ::RegisterDragDrop(m_window, dropTarget);
+ else
+ ::RegisterDragDrop(m_window, this);
+}
+
+FloatRect WebView::convertToDeviceSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+IntPoint WebView::screenToWindow(const IntPoint& point)
+{
+ return point;
+}
+
+IntRect WebView::windowToScreen(const IntRect& rect)
+{
+ return rect;
+}
+
+FloatRect WebView::convertToUserSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+HIMC WebView::getIMMContext()
+{
+ return Ime::ImmGetContext(m_window);
+}
+
+void WebView::prepareCandidateWindow(HIMC hInputContext)
+{
+ IntRect caret = m_page->firstRectForCharacterInSelectedRange(0);
+ CANDIDATEFORM form;
+ form.dwIndex = 0;
+ form.dwStyle = CFS_EXCLUDE;
+ form.ptCurrentPos.x = caret.x();
+ form.ptCurrentPos.y = caret.maxY();
+ form.rcArea.top = caret.y();
+ form.rcArea.bottom = caret.maxY();
+ form.rcArea.left = caret.x();
+ form.rcArea.right = caret.maxX();
+ Ime::ImmSetCandidateWindow(hInputContext, &form);
+}
+
+void WebView::resetIME()
+{
+ HIMC hInputContext = getIMMContext();
+ if (!hInputContext)
+ return;
+ Ime::ImmNotifyIME(hInputContext, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
+ Ime::ImmReleaseContext(m_window, hInputContext);
+}
+
+void WebView::setInputMethodState(bool enabled)
+{
+ Ime::ImmAssociateContextEx(m_window, 0, enabled ? IACE_DEFAULT : 0);
+}
+
+void WebView::compositionSelectionChanged(bool hasChanged)
+{
+ if (m_page->editorState().hasComposition && !hasChanged)
+ resetIME();
+}
+
+bool WebView::onIMEStartComposition()
+{
+ LOG(TextInput, "onIMEStartComposition");
+ m_inIMEComposition++;
+
+ HIMC hInputContext = getIMMContext();
+ if (!hInputContext)
+ return false;
+ prepareCandidateWindow(hInputContext);
+ Ime::ImmReleaseContext(m_window, hInputContext);
+ return true;
+}
+
+static bool getCompositionString(HIMC hInputContext, DWORD type, String& result)
+{
+ LONG compositionLength = Ime::ImmGetCompositionStringW(hInputContext, type, 0, 0);
+ if (compositionLength <= 0)
+ return false;
+ Vector<UChar> compositionBuffer(compositionLength / 2);
+ compositionLength = Ime::ImmGetCompositionStringW(hInputContext, type, compositionBuffer.data(), compositionLength);
+ result = String::adopt(compositionBuffer);
+ return true;
+}
+
+static void compositionToUnderlines(const Vector<DWORD>& clauses, const Vector<BYTE>& attributes, Vector<CompositionUnderline>& underlines)
+{
+ if (clauses.isEmpty()) {
+ underlines.clear();
+ return;
+ }
+
+ size_t numBoundaries = clauses.size() - 1;
+ underlines.resize(numBoundaries);
+ for (unsigned i = 0; i < numBoundaries; ++i) {
+ underlines[i].startOffset = clauses[i];
+ underlines[i].endOffset = clauses[i + 1];
+ BYTE attribute = attributes[clauses[i]];
+ underlines[i].thick = attribute == ATTR_TARGET_CONVERTED || attribute == ATTR_TARGET_NOTCONVERTED;
+ underlines[i].color = Color::black;
+ }
+}
+
+#if !LOG_DISABLED
+#define APPEND_ARGUMENT_NAME(name) \
+ if (lparam & name) { \
+ if (needsComma) \
+ result += ", "; \
+ result += #name; \
+ needsComma = true; \
+ }
+
+static String imeCompositionArgumentNames(LPARAM lparam)
+{
+ String result;
+ bool needsComma = false;
+
+ APPEND_ARGUMENT_NAME(GCS_COMPATTR);
+ APPEND_ARGUMENT_NAME(GCS_COMPCLAUSE);
+ APPEND_ARGUMENT_NAME(GCS_COMPREADSTR);
+ APPEND_ARGUMENT_NAME(GCS_COMPREADATTR);
+ APPEND_ARGUMENT_NAME(GCS_COMPREADCLAUSE);
+ APPEND_ARGUMENT_NAME(GCS_COMPSTR);
+ APPEND_ARGUMENT_NAME(GCS_CURSORPOS);
+ APPEND_ARGUMENT_NAME(GCS_DELTASTART);
+ APPEND_ARGUMENT_NAME(GCS_RESULTCLAUSE);
+ APPEND_ARGUMENT_NAME(GCS_RESULTREADCLAUSE);
+ APPEND_ARGUMENT_NAME(GCS_RESULTREADSTR);
+ APPEND_ARGUMENT_NAME(GCS_RESULTSTR);
+ APPEND_ARGUMENT_NAME(CS_INSERTCHAR);
+ APPEND_ARGUMENT_NAME(CS_NOMOVECARET);
+
+ return result;
+}
+
+static String imeRequestName(WPARAM wparam)
+{
+ switch (wparam) {
+ case IMR_CANDIDATEWINDOW:
+ return "IMR_CANDIDATEWINDOW";
+ case IMR_COMPOSITIONFONT:
+ return "IMR_COMPOSITIONFONT";
+ case IMR_COMPOSITIONWINDOW:
+ return "IMR_COMPOSITIONWINDOW";
+ case IMR_CONFIRMRECONVERTSTRING:
+ return "IMR_CONFIRMRECONVERTSTRING";
+ case IMR_DOCUMENTFEED:
+ return "IMR_DOCUMENTFEED";
+ case IMR_QUERYCHARPOSITION:
+ return "IMR_QUERYCHARPOSITION";
+ case IMR_RECONVERTSTRING:
+ return "IMR_RECONVERTSTRING";
+ default:
+ return "Unknown (" + String::number(wparam) + ")";
+ }
+}
+#endif
+
+bool WebView::onIMEComposition(LPARAM lparam)
+{
+ LOG(TextInput, "onIMEComposition %s", imeCompositionArgumentNames(lparam).latin1().data());
+ HIMC hInputContext = getIMMContext();
+ if (!hInputContext)
+ return true;
+
+ if (!m_page->editorState().isContentEditable)
+ return true;
+
+ prepareCandidateWindow(hInputContext);
+
+ if (lparam & GCS_RESULTSTR || !lparam) {
+ String compositionString;
+ if (!getCompositionString(hInputContext, GCS_RESULTSTR, compositionString) && lparam)
+ return true;
+
+ m_page->confirmComposition(compositionString);
+ return true;
+ }
+
+ String compositionString;
+ if (!getCompositionString(hInputContext, GCS_COMPSTR, compositionString))
+ return true;
+
+ // Composition string attributes
+ int numAttributes = Ime::ImmGetCompositionStringW(hInputContext, GCS_COMPATTR, 0, 0);
+ Vector<BYTE> attributes(numAttributes);
+ Ime::ImmGetCompositionStringW(hInputContext, GCS_COMPATTR, attributes.data(), numAttributes);
+
+ // Get clauses
+ int numBytes = Ime::ImmGetCompositionStringW(hInputContext, GCS_COMPCLAUSE, 0, 0);
+ Vector<DWORD> clauses(numBytes / sizeof(DWORD));
+ Ime::ImmGetCompositionStringW(hInputContext, GCS_COMPCLAUSE, clauses.data(), numBytes);
+
+ Vector<CompositionUnderline> underlines;
+ compositionToUnderlines(clauses, attributes, underlines);
+
+ int cursorPosition = LOWORD(Ime::ImmGetCompositionStringW(hInputContext, GCS_CURSORPOS, 0, 0));
+
+ m_page->setComposition(compositionString, underlines, cursorPosition);
+
+ return true;
+}
+
+bool WebView::onIMEEndComposition()
+{
+ LOG(TextInput, "onIMEEndComposition");
+ // If the composition hasn't been confirmed yet, it needs to be cancelled.
+ // This happens after deleting the last character from inline input hole.
+ if (m_page->editorState().hasComposition)
+ m_page->confirmComposition(String());
+
+ if (m_inIMEComposition)
+ m_inIMEComposition--;
+
+ return true;
+}
+
+LRESULT WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos)
+{
+ if (charPos->dwCharPos && !m_page->editorState().hasComposition)
+ return 0;
+ IntRect caret = m_page->firstRectForCharacterInSelectedRange(charPos->dwCharPos);
+ charPos->pt.x = caret.x();
+ charPos->pt.y = caret.y();
+ ::ClientToScreen(m_window, &charPos->pt);
+ charPos->cLineHeight = caret.height();
+ ::GetWindowRect(m_window, &charPos->rcDocument);
+ return true;
+}
+
+LRESULT WebView::onIMERequestReconvertString(RECONVERTSTRING* reconvertString)
+{
+ String text = m_page->getSelectedText();
+ unsigned totalSize = sizeof(RECONVERTSTRING) + text.length() * sizeof(UChar);
+
+ if (!reconvertString)
+ return totalSize;
+
+ if (totalSize > reconvertString->dwSize)
+ return 0;
+ reconvertString->dwCompStrLen = text.length();
+ reconvertString->dwStrLen = text.length();
+ reconvertString->dwTargetStrLen = text.length();
+ reconvertString->dwStrOffset = sizeof(RECONVERTSTRING);
+ memcpy(reconvertString + 1, text.characters(), text.length() * sizeof(UChar));
+ return totalSize;
+}
+
+LRESULT WebView::onIMERequest(WPARAM request, LPARAM data)
+{
+ LOG(TextInput, "onIMERequest %s", imeRequestName(request).latin1().data());
+ if (!m_page->editorState().isContentEditable)
+ return 0;
+
+ switch (request) {
+ case IMR_RECONVERTSTRING:
+ return onIMERequestReconvertString(reinterpret_cast<RECONVERTSTRING*>(data));
+
+ case IMR_QUERYCHARPOSITION:
+ return onIMERequestCharPosition(reinterpret_cast<IMECHARPOSITION*>(data));
+ }
+ return 0;
+}
+
+bool WebView::onIMESelect(WPARAM wparam, LPARAM lparam)
+{
+ UNUSED_PARAM(wparam);
+ UNUSED_PARAM(lparam);
+ LOG(TextInput, "onIMESelect locale %ld %s", lparam, wparam ? "select" : "deselect");
+ return false;
+}
+
+bool WebView::onIMESetContext(WPARAM wparam, LPARAM)
+{
+ LOG(TextInput, "onIMESetContext %s", wparam ? "active" : "inactive");
+ return false;
+}
+
+void WebView::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool wasEventHandled)
+{
+ // Calling ::DefWindowProcW will ensure that pressing the Alt key will generate a WM_SYSCOMMAND
+ // event, e.g. See <http://webkit.org/b/47671>.
+ if (!wasEventHandled)
+ ::DefWindowProcW(event.nativeEvent()->hwnd, event.nativeEvent()->message, event.nativeEvent()->wParam, event.nativeEvent()->lParam);
+}
+
+PassRefPtr<WebPopupMenuProxy> WebView::createPopupMenuProxy(WebPageProxy* page)
+{
+ return WebPopupMenuProxyWin::create(this, page);
+}
+
+PassRefPtr<WebContextMenuProxy> WebView::createContextMenuProxy(WebPageProxy* page)
+{
+ return WebContextMenuProxyWin::create(m_window, page);
+}
+
+void WebView::setFindIndicator(PassRefPtr<FindIndicator> prpFindIndicator, bool fadeOut, bool animate)
+{
+ UNUSED_PARAM(animate);
+
+ if (!m_findIndicatorCallback)
+ return;
+
+ HBITMAP hbmp = 0;
+ IntRect selectionRect;
+
+ if (RefPtr<FindIndicator> findIndicator = prpFindIndicator) {
+ if (ShareableBitmap* contentImage = findIndicator->contentImage()) {
+ // Render the contentImage to an HBITMAP.
+ void* bits;
+ HDC hdc = ::CreateCompatibleDC(0);
+ int width = contentImage->bounds().width();
+ int height = contentImage->bounds().height();
+ BitmapInfo bitmapInfo = BitmapInfo::create(contentImage->size());
+
+ hbmp = CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, static_cast<void**>(&bits), 0, 0);
+ HBITMAP hbmpOld = static_cast<HBITMAP>(SelectObject(hdc, hbmp));
+#if USE(CG)
+ RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate(bits, width, height,
+ 8, width * sizeof(RGBQUAD), deviceRGBColorSpaceRef(), kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst));
+
+ GraphicsContext graphicsContext(context.get());
+ contentImage->paint(graphicsContext, IntPoint(), contentImage->bounds());
+#else
+ // FIXME: Implement!
+#endif
+
+ ::SelectObject(hdc, hbmpOld);
+ ::DeleteDC(hdc);
+ }
+
+ selectionRect = IntRect(findIndicator->selectionRectInWindowCoordinates());
+ }
+
+ // The callback is responsible for calling ::DeleteObject(hbmp).
+ (*m_findIndicatorCallback)(toAPI(this), hbmp, selectionRect, fadeOut, m_findIndicatorCallbackContext);
+}
+
+void WebView::setFindIndicatorCallback(WKViewFindIndicatorCallback callback, void* context)
+{
+ m_findIndicatorCallback = callback;
+ m_findIndicatorCallbackContext = context;
+}
+
+WKViewFindIndicatorCallback WebView::getFindIndicatorCallback(void** context)
+{
+ if (context)
+ *context = m_findIndicatorCallbackContext;
+
+ return m_findIndicatorCallback;
+}
+
+void WebView::didInstallOrUninstallPageOverlay(bool didInstall)
+{
+ m_pageOverlayInstalled = didInstall;
+}
+
+void WebView::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+}
+
+void WebView::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&)
+{
+}
+
+double WebView::customRepresentationZoomFactor()
+{
+ return 1;
+}
+
+void WebView::setCustomRepresentationZoomFactor(double)
+{
+}
+
+void WebView::didChangeScrollbarsForMainFrame() const
+{
+}
+
+void WebView::findStringInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+}
+
+void WebView::countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned)
+{
+}
+
+void WebView::setIsInWindow(bool isInWindow)
+{
+ m_isInWindow = isInWindow;
+ m_page->viewStateDidChange(WebPageProxy::ViewIsInWindow);
+}
+
+void WebView::setIsVisible(bool isVisible)
+{
+ m_isVisible = isVisible;
+
+ if (m_page)
+ m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+
+void WebView::enterAcceleratedCompositingMode(const LayerTreeContext& context)
+{
+#if HAVE(WKQCA)
+ ASSERT(!context.isEmpty());
+
+ m_layerHostWindow = context.window;
+
+ IntSize size = viewSize();
+ // Ensure the layer host window is behind all other child windows (since otherwise it would obscure them).
+ ::SetWindowPos(m_layerHostWindow, HWND_BOTTOM, 0, 0, size.width(), size.height(), SWP_SHOWWINDOW | SWP_NOACTIVATE);
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+void WebView::exitAcceleratedCompositingMode()
+{
+#if HAVE(WKQCA)
+ ASSERT(m_layerHostWindow);
+
+ // Tell the WKCACFViewWindow to destroy itself. We can't call ::DestroyWindow directly because
+ // the window is owned by another thread.
+ ::PostMessageW(m_layerHostWindow, WKCACFViewWindow::customDestroyMessage, 0, 0);
+ m_layerHostWindow = 0;
+#else
+ ASSERT_NOT_REACHED();
+#endif
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+HWND WebView::nativeWindow()
+{
+ return m_window;
+}
+
+void WebView::scheduleChildWindowGeometryUpdate(const WindowGeometry& geometry)
+{
+ m_geometriesUpdater.addPendingUpdate(geometry);
+}
+
+void WebView::updateChildWindowGeometries()
+{
+ m_geometriesUpdater.updateGeometries(DoNotBringToTop);
+}
+
+// WebCore::WindowMessageListener
+
+void WebView::windowReceivedMessage(HWND, UINT message, WPARAM wParam, LPARAM)
+{
+ switch (message) {
+ case WM_NCACTIVATE:
+ updateActiveStateSoon();
+ break;
+ case WM_SETTINGCHANGE:
+ // systemParameterChanged(wParam);
+ break;
+ }
+}
+
+HRESULT STDMETHODCALLTYPE WebView::QueryInterface(REFIID riid, void** ppvObject)
+{
+ *ppvObject = 0;
+ if (IsEqualGUID(riid, IID_IUnknown))
+ *ppvObject = static_cast<IUnknown*>(this);
+ else if (IsEqualGUID(riid, IID_IDropTarget))
+ *ppvObject = static_cast<IDropTarget*>(this);
+ else
+ return E_NOINTERFACE;
+
+ AddRef();
+ return S_OK;
+}
+
+ULONG STDMETHODCALLTYPE WebView::AddRef(void)
+{
+ ref();
+ return refCount();
+}
+
+ULONG STDMETHODCALLTYPE WebView::Release(void)
+{
+ deref();
+ return refCount();
+}
+
+static DWORD dragOperationToDragCursor(DragOperation op)
+{
+ DWORD res = DROPEFFECT_NONE;
+ if (op & DragOperationCopy)
+ res = DROPEFFECT_COPY;
+ else if (op & DragOperationLink)
+ res = DROPEFFECT_LINK;
+ else if (op & DragOperationMove)
+ res = DROPEFFECT_MOVE;
+ else if (op & DragOperationGeneric)
+ res = DROPEFFECT_MOVE; // This appears to be the Firefox behaviour
+ return res;
+}
+
+WebCore::DragOperation WebView::keyStateToDragOperation(DWORD grfKeyState) const
+{
+ if (!m_page)
+ return DragOperationNone;
+
+ // Conforms to Microsoft's key combinations as documented for
+ // IDropTarget::DragOver. Note, grfKeyState is the current
+ // state of the keyboard modifier keys on the keyboard. See:
+ // <http://msdn.microsoft.com/en-us/library/ms680129(VS.85).aspx>.
+ DragOperation operation = m_page->dragSession().operation;
+
+ if ((grfKeyState & (MK_CONTROL | MK_SHIFT)) == (MK_CONTROL | MK_SHIFT))
+ operation = DragOperationLink;
+ else if ((grfKeyState & MK_CONTROL) == MK_CONTROL)
+ operation = DragOperationCopy;
+ else if ((grfKeyState & MK_SHIFT) == MK_SHIFT)
+ operation = DragOperationGeneric;
+
+ return operation;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
+{
+ m_dragData = 0;
+ m_page->resetDragOperation();
+
+ if (m_dropTargetHelper)
+ m_dropTargetHelper->DragEnter(m_window, pDataObject, (POINT*)&pt, *pdwEffect);
+
+ POINTL localpt = pt;
+ ::ScreenToClient(m_window, (LPPOINT)&localpt);
+ DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
+ m_page->dragEntered(&data);
+ *pdwEffect = dragOperationToDragCursor(m_page->dragSession().operation);
+
+ m_lastDropEffect = *pdwEffect;
+ m_dragData = pDataObject;
+
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
+{
+ if (m_dropTargetHelper)
+ m_dropTargetHelper->DragOver((POINT*)&pt, *pdwEffect);
+
+ if (m_dragData) {
+ POINTL localpt = pt;
+ ::ScreenToClient(m_window, (LPPOINT)&localpt);
+ DragData data(m_dragData.get(), IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
+ m_page->dragUpdated(&data);
+ *pdwEffect = dragOperationToDragCursor(m_page->dragSession().operation);
+ } else
+ *pdwEffect = DROPEFFECT_NONE;
+
+ m_lastDropEffect = *pdwEffect;
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::DragLeave()
+{
+ if (m_dropTargetHelper)
+ m_dropTargetHelper->DragLeave();
+
+ if (m_dragData) {
+ DragData data(m_dragData.get(), IntPoint(), IntPoint(), DragOperationNone);
+ m_page->dragExited(&data);
+ m_dragData = 0;
+ m_page->resetDragOperation();
+ }
+ return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebView::Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
+{
+ if (m_dropTargetHelper)
+ m_dropTargetHelper->Drop(pDataObject, (POINT*)&pt, *pdwEffect);
+
+ m_dragData = 0;
+ *pdwEffect = m_lastDropEffect;
+ POINTL localpt = pt;
+ ::ScreenToClient(m_window, (LPPOINT)&localpt);
+ DragData data(pDataObject, IntPoint(localpt.x, localpt.y), IntPoint(pt.x, pt.y), keyStateToDragOperation(grfKeyState));
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ m_page->performDrag(&data, String(), sandboxExtensionHandle);
+ return S_OK;
+}
+
+#if ENABLE(FULLSCREEN_API)
+FullScreenController* WebView::fullScreenController()
+{
+ if (!m_fullScreenController)
+ m_fullScreenController = adoptPtr(new FullScreenController(this));
+ return m_fullScreenController.get();
+}
+
+HWND WebView::fullScreenClientWindow() const
+{
+ return m_window;
+}
+
+HWND WebView::fullScreenClientParentWindow() const
+{
+ return ::GetParent(m_window);
+}
+
+void WebView::fullScreenClientSetParentWindow(HWND hostWindow)
+{
+ setParentWindow(hostWindow);
+}
+
+void WebView::fullScreenClientWillEnterFullScreen()
+{
+ page()->fullScreenManager()->willEnterFullScreen();
+}
+
+void WebView::fullScreenClientDidEnterFullScreen()
+{
+ page()->fullScreenManager()->didEnterFullScreen();
+}
+
+void WebView::fullScreenClientWillExitFullScreen()
+{
+ page()->fullScreenManager()->willExitFullScreen();
+}
+
+void WebView::fullScreenClientDidExitFullScreen()
+{
+ page()->fullScreenManager()->didExitFullScreen();
+}
+
+static void fullScreenClientForceRepaintCompleted(WKErrorRef, void* context)
+{
+ ASSERT(context);
+ static_cast<WebView*>(context)->fullScreenController()->repaintCompleted();
+}
+
+void WebView::fullScreenClientForceRepaint()
+{
+ page()->forceRepaint(VoidCallback::create(this, &fullScreenClientForceRepaintCompleted));
+}
+
+#endif
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h
new file mode 100644
index 000000000..ecd708071
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebView.h
@@ -0,0 +1,292 @@
+/*
+ * 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 WebView_h
+#define WebView_h
+
+#include "APIObject.h"
+#include "CoalescedWindowGeometriesUpdater.h"
+#include "PageClient.h"
+#include "WKView.h"
+#include "WebPageProxy.h"
+#include "WebUndoClient.h"
+#include <ShlObj.h>
+#include <WebCore/COMPtr.h>
+#include <WebCore/DragActions.h>
+#include <WebCore/DragData.h>
+#include <WebCore/WindowMessageListener.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+#if ENABLE(FULLSCREEN_API)
+#include <WebCore/FullScreenControllerClient.h>
+#endif
+
+namespace WebCore {
+ class FullScreenController;
+}
+
+interface IDropTargetHelper;
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+
+class WebView
+ : public APIObject
+ , public PageClient
+ , WebCore::WindowMessageListener
+ , public IDropTarget
+#if ENABLE(FULLSCREEN_API)
+ , WebCore::FullScreenControllerClient
+#endif
+{
+public:
+ static PassRefPtr<WebView> create(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND parentWindow)
+ {
+ RefPtr<WebView> webView = adoptRef(new WebView(rect, context, pageGroup, parentWindow));
+ webView->initialize();
+ return webView;
+ }
+ ~WebView();
+
+ HWND window() const { return m_window; }
+ void setParentWindow(HWND);
+ void windowAncestryDidChange();
+ void setIsInWindow(bool);
+ void setIsVisible(bool);
+ void setOverrideCursor(HCURSOR);
+ void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&);
+ void setScrollOffsetOnNextResize(const WebCore::IntSize&);
+ void setFindIndicatorCallback(WKViewFindIndicatorCallback, void*);
+ WKViewFindIndicatorCallback getFindIndicatorCallback(void**);
+ bool pageOverlayInstalled() const { return m_pageOverlayInstalled; }
+ void initialize();
+
+ void initializeUndoClient(const WKViewUndoClient*);
+ void reapplyEditCommand(WebEditCommandProxy*);
+ void unapplyEditCommand(WebEditCommandProxy*);
+
+ void setCustomDropTarget(IDropTarget*);
+
+ // IUnknown
+ virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
+ virtual ULONG STDMETHODCALLTYPE AddRef(void);
+ virtual ULONG STDMETHODCALLTYPE Release(void);
+
+ // IDropTarget
+ virtual HRESULT STDMETHODCALLTYPE DragEnter(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
+ virtual HRESULT STDMETHODCALLTYPE DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
+ virtual HRESULT STDMETHODCALLTYPE DragLeave();
+ virtual HRESULT STDMETHODCALLTYPE Drop(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect);
+
+ WebPageProxy* page() const { return m_page.get(); }
+
+#if ENABLE(FULLSCREEN_API)
+ WebCore::FullScreenController* fullScreenController();
+#endif
+
+private:
+ WebView(RECT, WebContext*, WebPageGroup*, HWND parentWindow);
+
+ virtual Type type() const { return TypeView; }
+
+ static bool registerWebViewWindowClass();
+ static LRESULT CALLBACK WebViewWndProc(HWND, UINT, WPARAM, LPARAM);
+ LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+
+ LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onWheelEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onHorizontalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onVerticalScroll(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onGestureNotify(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onGesture(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onPrintClientEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onWindowPositionChangedEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onSetFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onKillFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onTimerEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onShowWindowEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onSetCursor(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+
+ void paint(HDC, const WebCore::IntRect& dirtyRect);
+ void setWasActivatedByMouseEvent(bool flag) { m_wasActivatedByMouseEvent = flag; }
+ bool onIMEStartComposition();
+ bool onIMEComposition(LPARAM);
+ bool onIMEEndComposition();
+ LRESULT onIMERequest(WPARAM, LPARAM);
+ bool onIMESelect(WPARAM, LPARAM);
+ bool onIMESetContext(WPARAM, LPARAM);
+ void resetIME();
+ void setInputMethodState(bool);
+ HIMC getIMMContext();
+ void prepareCandidateWindow(HIMC);
+ LRESULT onIMERequestCharPosition(IMECHARPOSITION*);
+ LRESULT onIMERequestReconvertString(RECONVERTSTRING*);
+
+ void updateActiveState();
+ void updateActiveStateSoon();
+
+ void initializeToolTipWindow();
+
+ void startTrackingMouseLeave();
+ void stopTrackingMouseLeave();
+
+ bool shouldInitializeTrackPointHack();
+
+ void close();
+
+ HCURSOR cursorToShow() const;
+ void updateNativeCursor();
+
+ void updateChildWindowGeometries();
+
+ // PageClient
+ 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 void flashBackingStoreUpdates(const Vector<WebCore::IntRect>& updateRects);
+
+ 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 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 void compositionSelectionChanged(bool);
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut, bool animate);
+ virtual void didInstallOrUninstallPageOverlay(bool);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void enterAcceleratedCompositingMode(const LayerTreeContext&);
+ virtual void exitAcceleratedCompositingMode();
+#endif
+
+ void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ void didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference&);
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+ WebCore::DragOperation keyStateToDragOperation(DWORD grfKeyState) const;
+ virtual void didChangeScrollbarsForMainFrame() const;
+
+ virtual void findStringInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount);
+ virtual void countStringMatchesInCustomRepresentation(const String&, FindOptions, unsigned maxMatchCount);
+
+ virtual HWND nativeWindow();
+ virtual void scheduleChildWindowGeometryUpdate(const WindowGeometry&);
+
+ virtual void setGestureReachedScrollingLimit(bool limitReached) { m_gestureReachedScrollingLimit = limitReached; }
+
+ // WebCore::WindowMessageListener
+ virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
+
+#if ENABLE(FULLSCREEN_API)
+ virtual HWND fullScreenClientWindow() const;
+ virtual HWND fullScreenClientParentWindow() const;
+ virtual void fullScreenClientSetParentWindow(HWND);
+ virtual void fullScreenClientWillEnterFullScreen();
+ virtual void fullScreenClientDidEnterFullScreen();
+ virtual void fullScreenClientWillExitFullScreen();
+ virtual void fullScreenClientDidExitFullScreen();
+ virtual void fullScreenClientForceRepaint();
+#endif
+
+ HWND m_window;
+ HWND m_topLevelParentWindow;
+ HWND m_toolTipWindow;
+
+ WebCore::IntSize m_nextResizeScrollOffset;
+
+ HCURSOR m_lastCursorSet;
+ HCURSOR m_webCoreCursor;
+ HCURSOR m_overrideCursor;
+
+ bool m_isInWindow;
+ bool m_isVisible;
+ bool m_wasActivatedByMouseEvent;
+ bool m_trackingMouseLeave;
+ bool m_isBeingDestroyed;
+
+ RefPtr<WebPageProxy> m_page;
+
+ unsigned m_inIMEComposition;
+
+ WebUndoClient m_undoClient;
+
+ WKViewFindIndicatorCallback m_findIndicatorCallback;
+ void* m_findIndicatorCallbackContext;
+ bool m_pageOverlayInstalled;
+
+ COMPtr<IDataObject> m_dragData;
+ COMPtr<IDropTargetHelper> m_dropTargetHelper;
+ // FIXME: This variable is part of a workaround. The drop effect (pdwEffect) passed to Drop is incorrect.
+ // We set this variable in DragEnter and DragOver so that it can be used in Drop to set the correct drop effect.
+ // Thus, on return from DoDragDrop we have the correct pdwEffect for the drag-and-drop operation.
+ // (see https://bugs.webkit.org/show_bug.cgi?id=29264)
+ DWORD m_lastDropEffect;
+
+ int m_lastPanX;
+ int m_lastPanY;
+
+ int m_overPanY;
+
+ bool m_gestureReachedScrollingLimit;
+
+ CoalescedWindowGeometriesUpdater m_geometriesUpdater;
+
+#if ENABLE(FULLSCREEN_API)
+ OwnPtr<WebCore::FullScreenController> m_fullScreenController;
+#endif
+
+#if USE(ACCELERATED_COMPOSITING)
+ HWND m_layerHostWindow;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // WebView_h