summaryrefslogtreecommitdiffstats
path: root/Source/WebKit2/UIProcess
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-13 16:23:25 +0100
committerBen Murdoch <benm@google.com>2011-05-16 11:35:02 +0100
commit65f03d4f644ce73618e5f4f50dd694b26f55ae12 (patch)
treef478babb801e720de7bfaee23443ffe029f58731 /Source/WebKit2/UIProcess
parent47de4a2fb7262c7ebdb9cd133ad2c54c187454d0 (diff)
downloadexternal_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.zip
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.gz
external_webkit-65f03d4f644ce73618e5f4f50dd694b26f55ae12.tar.bz2
Merge WebKit at r75993: Initial merge by git.
Change-Id: I602bbdc3974787a3b0450456a30a7868286921c3
Diffstat (limited to 'Source/WebKit2/UIProcess')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAPICast.h233
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp58
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.h46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp76
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardList.h52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.cpp178
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContext.h133
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKContextPrivate.h61
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredential.cpp49
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredential.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKCredentialTypes.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp153
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h106
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDownload.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKDownload.h49
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.cpp41
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.cpp164
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFrame.h89
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h45
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp53
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationManager.h58
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp42
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h43
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.cpp110
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.h70
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNativeEvent.h52
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKNavigationData.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp41
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp46
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.h44
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp431
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h352
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp58
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPageGroup.h48
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPagePrivate.h48
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.cpp451
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.h153
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h99
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKProtectionSpace.cpp71
-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/WebKit2.h63
-rw-r--r--Source/WebKit2/UIProcess/API/C/qt/WKNativeEvent.h35
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h41
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h35
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.h47
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKContextWin.cpp37
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.cpp72
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKView.h53
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp36
-rw-r--r--Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.h42
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h212
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp42
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.h30
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp42
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.h31
-rw-r--r--Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h77
-rw-r--r--Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.mm245
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.h74
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PDFViewController.mm297
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.h103
-rw-r--r--Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm350
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h44
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm156
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.h47
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm1795
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKViewInternal.h66
-rw-r--r--Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp169
-rw-r--r--Source/WebKit2/UIProcess/API/qt/ClientImpl.h58
-rw-r--r--Source/WebKit2/UIProcess/API/qt/WKView.h28
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp442
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h102
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp67
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkcontext.h44
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h37
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp182
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkhistory.h81
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h64
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage.cpp759
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage.h151
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpage_p.h134
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp185
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpreferences.h72
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h28
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp97
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h80
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp58
-rw-r--r--Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.h62
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebCredential.cpp45
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebCredential.h66
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.cpp72
-rw-r--r--Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.h63
-rw-r--r--Source/WebKit2/UIProcess/BackingStore.cpp51
-rw-r--r--Source/WebKit2/UIProcess/BackingStore.h74
-rw-r--r--Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.cpp174
-rw-r--r--Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.h109
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp179
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.h90
-rw-r--r--Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in33
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.cpp60
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.h97
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in26
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp137
-rw-r--r--Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h65
-rw-r--r--Source/WebKit2/UIProcess/FindIndicator.cpp173
-rw-r--r--Source/WebKit2/UIProcess/FindIndicator.h66
-rw-r--r--Source/WebKit2/UIProcess/GenericCallback.h105
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.cpp69
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.h56
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp61
-rw-r--r--Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.h61
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp96
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h99
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp65
-rw-r--r--Source/WebKit2/UIProcess/Launcher/ThreadLauncher.h71
-rw-r--r--Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp86
-rw-r--r--Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp39
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm311
-rw-r--r--Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm72
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp223
-rw-r--r--Source/WebKit2/UIProcess/Launcher/qt/ThreadLauncherQt.cpp77
-rw-r--r--Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp122
-rw-r--r--Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp69
-rw-r--r--Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.cpp171
-rw-r--r--Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.h98
-rw-r--r--Source/WebKit2/UIProcess/PageClient.h135
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp220
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h94
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessManager.cpp81
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessManager.h61
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.cpp154
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h101
-rw-r--r--Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in30
-rw-r--r--Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoStoreGtk.cpp67
-rw-r--r--Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm101
-rw-r--r--Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm46
-rw-r--r--Source/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp72
-rw-r--r--Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp417
-rw-r--r--Source/WebKit2/UIProcess/ProcessModel.h39
-rw-r--r--Source/WebKit2/UIProcess/ResponsivenessTimer.cpp84
-rw-r--r--Source/WebKit2/UIProcess/ResponsivenessTimer.h64
-rw-r--r--Source/WebKit2/UIProcess/TextChecker.h66
-rw-r--r--Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp624
-rw-r--r--Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h189
-rw-r--r--Source/WebKit2/UIProcess/TiledDrawingAreaTile.h89
-rw-r--r--Source/WebKit2/UIProcess/VisitedLinkProvider.cpp179
-rw-r--r--Source/WebKit2/UIProcess/VisitedLinkProvider.h66
-rw-r--r--Source/WebKit2/UIProcess/WebBackForwardList.cpp208
-rw-r--r--Source/WebKit2/UIProcess/WebBackForwardList.h100
-rw-r--r--Source/WebKit2/UIProcess/WebContext.cpp602
-rw-r--r--Source/WebKit2/UIProcess/WebContext.h210
-rw-r--r--Source/WebKit2/UIProcess/WebContext.messages.in38
-rw-r--r--Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp53
-rw-r--r--Source/WebKit2/UIProcess/WebContextInjectedBundleClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebContextMenuProxy.cpp37
-rw-r--r--Source/WebKit2/UIProcess/WebContextMenuProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebContextUserMessageCoders.h141
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp222
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h98
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxy.messages.in28
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.cpp48
-rw-r--r--Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebDownloadClient.cpp117
-rw-r--r--Source/WebKit2/UIProcess/WebDownloadClient.h59
-rw-r--r--Source/WebKit2/UIProcess/WebEditCommandProxy.cpp68
-rw-r--r--Source/WebKit2/UIProcess/WebEditCommandProxy.h63
-rw-r--r--Source/WebKit2/UIProcess/WebFindClient.cpp58
-rw-r--r--Source/WebKit2/UIProcess/WebFindClient.h46
-rw-r--r--Source/WebKit2/UIProcess/WebFormClient.cpp49
-rw-r--r--Source/WebKit2/UIProcess/WebFormClient.h49
-rw-r--r--Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.cpp40
-rw-r--r--Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebFrameListenerProxy.cpp56
-rw-r--r--Source/WebKit2/UIProcess/WebFrameListenerProxy.h57
-rw-r--r--Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.cpp52
-rw-r--r--Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.h54
-rw-r--r--Source/WebKit2/UIProcess/WebFrameProxy.cpp308
-rw-r--r--Source/WebKit2/UIProcess/WebFrameProxy.h159
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp99
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h79
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationManagerProxy.messages.in26
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationProvider.cpp49
-rw-r--r--Source/WebKit2/UIProcess/WebGeolocationProvider.h45
-rw-r--r--Source/WebKit2/UIProcess/WebHistoryClient.cpp77
-rw-r--r--Source/WebKit2/UIProcess/WebHistoryClient.h53
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.cpp194
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.h159
-rw-r--r--Source/WebKit2/UIProcess/WebInspectorProxy.messages.in31
-rw-r--r--Source/WebKit2/UIProcess/WebLoaderClient.cpp219
-rw-r--r--Source/WebKit2/UIProcess/WebLoaderClient.h81
-rw-r--r--Source/WebKit2/UIProcess/WebNavigationData.cpp39
-rw-r--r--Source/WebKit2/UIProcess/WebNavigationData.h59
-rw-r--r--Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp80
-rw-r--r--Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h64
-rw-r--r--Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp76
-rw-r--r--Source/WebKit2/UIProcess/WebPageContextMenuClient.h47
-rw-r--r--Source/WebKit2/UIProcess/WebPageGroup.cpp120
-rw-r--r--Source/WebKit2/UIProcess/WebPageGroup.h72
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.cpp2367
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.h621
-rw-r--r--Source/WebKit2/UIProcess/WebPageProxy.messages.in192
-rw-r--r--Source/WebKit2/UIProcess/WebPolicyClient.cpp62
-rw-r--r--Source/WebKit2/UIProcess/WebPolicyClient.h50
-rw-r--r--Source/WebKit2/UIProcess/WebPopupMenuProxy.h73
-rw-r--r--Source/WebKit2/UIProcess/WebPreferences.cpp105
-rw-r--r--Source/WebKit2/UIProcess/WebPreferences.h98
-rw-r--r--Source/WebKit2/UIProcess/WebProcessManager.cpp95
-rw-r--r--Source/WebKit2/UIProcess/WebProcessManager.h56
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.cpp415
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.h183
-rw-r--r--Source/WebKit2/UIProcess/WebProcessProxy.messages.in28
-rw-r--r--Source/WebKit2/UIProcess/WebResourceLoadClient.cpp90
-rw-r--r--Source/WebKit2/UIProcess/WebResourceLoadClient.h56
-rw-r--r--Source/WebKit2/UIProcess/WebUIClient.cpp276
-rw-r--r--Source/WebKit2/UIProcess/WebUIClient.h93
-rw-r--r--Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp144
-rw-r--r--Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp138
-rw-r--r--Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp54
-rw-r--r--Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp97
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp62
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp37
-rw-r--r--Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp58
-rw-r--r--Source/WebKit2/UIProcess/mac/BackingStoreMac.mm93
-rw-r--r--Source/WebKit2/UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm108
-rw-r--r--Source/WebKit2/UIProcess/mac/LayerBackedDrawingAreaProxyMac.mm92
-rw-r--r--Source/WebKit2/UIProcess/mac/TextCheckerMac.mm328
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMac.mm93
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h69
-rw-r--r--Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm232
-rw-r--r--Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm142
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm113
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h66
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm109
-rw-r--r--Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm127
-rw-r--r--Source/WebKit2/UIProcess/qt/ChunkedUpdateDrawingAreaProxyQt.cpp81
-rw-r--r--Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp98
-rw-r--r--Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp71
-rw-r--r--Source/WebKit2/UIProcess/qt/TiledDrawingAreaTileQt.cpp160
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp144
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h55
-rw-r--r--Source/WebKit2/UIProcess/qt/WebContextQt.cpp47
-rw-r--r--Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp61
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp36
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp52
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h50
-rw-r--r--Source/WebKit2/UIProcess/qt/WebPreferencesQt.cpp50
-rw-r--r--Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp106
-rw-r--r--Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp65
-rw-r--r--Source/WebKit2/UIProcess/win/TextCheckerWin.cpp98
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp103
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.h61
-rw-r--r--Source/WebKit2/UIProcess/win/WebContextWin.cpp56
-rw-r--r--Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp194
-rw-r--r--Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp113
-rw-r--r--Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp937
-rw-r--r--Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h136
-rw-r--r--Source/WebKit2/UIProcess/win/WebView.cpp1085
-rw-r--r--Source/WebKit2/UIProcess/win/WebView.h170
268 files changed, 33982 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 0000000..15cb7ee
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAPICast.h
@@ -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.
+ */
+
+#ifndef WKAPICast_h
+#define WKAPICast_h
+
+#include "CacheModel.h"
+#include "FontSmoothingLevel.h"
+#include "WKContext.h"
+#include "WKCredentialTypes.h"
+#include "WKPage.h"
+#include "WKPreferencesPrivate.h"
+#include "WKProtectionSpaceTypes.h"
+#include "WKSharedAPICast.h"
+#include <WebCore/Credential.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/ProtectionSpace.h>
+
+namespace WebKit {
+
+class AuthenticationChallengeProxy;
+class AuthenticationDecisionListener;
+class DownloadProxy;
+class GeolocationPermissionRequestProxy;
+class WebBackForwardList;
+class WebBackForwardListItem;
+class WebContext;
+class WebCredential;
+class WebDatabaseManagerProxy;
+class WebFormSubmissionListenerProxy;
+class WebFramePolicyListenerProxy;
+class WebFrameProxy;
+class WebGeolocationManagerProxy;
+class WebGeolocationPosition;
+class WebInspectorProxy;
+class WebNavigationData;
+class WebOpenPanelParameters;
+class WebOpenPanelResultListenerProxy;
+class WebPageGroup;
+class WebPageProxy;
+class WebPreferences;
+class WebProtectionSpace;
+
+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(WKContextRef, WebContext)
+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(WKNavigationDataRef, WebNavigationData)
+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(WKPreferencesRef, WebPreferences)
+WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
+
+#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 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;
+ }
+}
+
+} // namespace WebKit
+
+#if defined(WIN32) || defined(_WIN32)
+#include "WKAPICastWin.h"
+#endif
+
+#endif // WKAPICast_h
diff --git a/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp
new file mode 100644
index 0000000..0997577
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationChallenge.cpp
@@ -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.
+ */
+
+#include "WKAuthenticationChallenge.h"
+
+#include "AuthenticationChallengeProxy.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 0000000..3802f41
--- /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 0000000..959f5c2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKAuthenticationDecisionListener.cpp
@@ -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.
+ */
+
+#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 0000000..f072461
--- /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 0000000..c2343ca
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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 "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).releaseRef());
+}
+
+WKArrayRef WKBackForwardListCopyForwardListWithLimit(WKBackForwardListRef listRef, unsigned limit)
+{
+ return toAPI(toImpl(listRef)->forwardListAsImmutableArrayWithLimit(limit).releaseRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardList.h
new file mode 100644
index 0000000..214a6bc
--- /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 0000000..2165737
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.cpp
@@ -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.
+ */
+
+#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());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h
new file mode 100644
index 0000000..b0bf1de
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKBackForwardListItem.h
@@ -0,0 +1,44 @@
+/*
+ * 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);
+
+#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 0000000..c207225
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.cpp
@@ -0,0 +1,178 @@
+/*
+ * 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 "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;
+
+WKTypeID WKContextGetTypeID()
+{
+ return toAPI(WebContext::APIType);
+}
+
+WKContextRef WKContextCreate()
+{
+ RefPtr<WebContext> context = WebContext::create(String());
+ return toAPI(context.release().releaseRef());
+}
+
+WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef pathRef)
+{
+ RefPtr<WebContext> context = WebContext::create(toImpl(pathRef)->string());
+ return toAPI(context.release().releaseRef());
+}
+
+WKContextRef WKContextGetSharedProcessContext()
+{
+ return toAPI(WebContext::sharedProcessContext());
+}
+
+WKContextRef WKContextGetSharedThreadContext()
+{
+ return toAPI(WebContext::sharedThreadContext());
+}
+
+void WKContextSetInjectedBundleClient(WKContextRef contextRef, const WKContextInjectedBundleClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(contextRef)->initializeInjectedBundleClient(wkClient);
+}
+
+void WKContextSetHistoryClient(WKContextRef contextRef, const WKContextHistoryClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(contextRef)->initializeHistoryClient(wkClient);
+}
+
+void WKContextSetDownloadClient(WKContextRef contextRef, const WKContextDownloadClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(contextRef)->initializeDownloadClient(wkClient);
+}
+
+void WKContextDownloadURLRequest(WKContextRef contextRef, const WKURLRequestRef requestRef)
+{
+ 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 _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());
+}
+
+void WKContextClearResourceCaches(WKContextRef contextRef)
+{
+ toImpl(contextRef)->clearResourceCaches();
+}
+
+void WKContextClearApplicationCache(WKContextRef contextRef)
+{
+ toImpl(contextRef)->clearApplicationCache();
+}
+
+WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->databaseManagerProxy());
+}
+
+WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef contextRef)
+{
+ return toAPI(toImpl(contextRef)->geolocationManagerProxy());
+}
+
+void WKContextStartMemorySampler(WKContextRef contextRef, WKDoubleRef interval)
+{
+ toImpl(contextRef)->startMemorySampler(toImpl(interval)->value());
+}
+
+void WKContextStopMemorySampler(WKContextRef contextRef)
+{
+ toImpl(contextRef)->stopMemorySampler();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKContext.h b/Source/WebKit2/UIProcess/API/C/WKContext.h
new file mode 100644
index 0000000..810ad20
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContext.h
@@ -0,0 +1,133 @@
+/*
+ * 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 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;
+
+// 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;
+
+// Download Client
+typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, 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;
+ WKContextDownloadDidReceiveResponseCallback didReceiveResponse;
+ WKContextDownloadDidReceiveDataCallback didReceiveData;
+ WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType;
+ WKContextDownloadDecideDestinationWithSuggestedFilenameCallback decideDestinationWithSuggestedFilename;
+ WKContextDownloadDidCreateDestinationCallback didCreateDestination;
+ WKContextDownloadDidFinishCallback didFinish;
+ WKContextDownloadDidFailCallback didFail;
+ WKContextDownloadDidCancel didCancel;
+ WKContextDownloadProcessDidCrashCallback processDidCrash;
+};
+typedef struct WKContextDownloadClient WKContextDownloadClient;
+
+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 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 WKContextClearResourceCaches(WKContextRef context);
+WK_EXPORT void WKContextClearApplicationCache(WKContextRef context);
+
+WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
+WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
+
+WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context);
+WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(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 0000000..8bcb1b6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKContextPrivate.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 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 WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme);
+
+WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKContextPrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKCredential.cpp b/Source/WebKit2/UIProcess/API/C/WKCredential.cpp
new file mode 100644
index 0000000..25e1185
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCredential.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 "WKCredential.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().releaseRef());
+}
+
+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 0000000..8b2602e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKCredential.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 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 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 0000000..bba31ac
--- /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 0000000..226ef8c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.cpp
@@ -0,0 +1,153 @@
+/*
+ * 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 "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()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetOriginQuotaKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::originQuotaKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetOriginUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::originUsageKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsNameKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsDisplayNameKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsExpectedUsageKey()).releaseRef();
+ return toAPI(key);
+}
+
+WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey()
+{
+ static WebString* key = WebString::create(WebDatabaseManagerProxy::databaseDetailsCurrentUsageKey()).releaseRef();
+ 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 0000000..0a5eff6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDatabaseManager.h
@@ -0,0 +1,106 @@
+/*
+ * 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;
+
+
+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 0000000..8960e2a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKDownload.cpp
@@ -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.
+ */
+
+#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 0000000..b812681
--- /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 0000000..ae98831
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFormSubmissionListener.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 "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 0000000..4b9b79a
--- /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 0000000..7c9ae11
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.cpp
@@ -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.
+ */
+
+#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());
+}
+
+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().releaseRef());
+}
+
+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, WKFrameGetMainResourceDataFunction callback, void* context)
+{
+ toImpl(frameRef)->getMainResourceData(DataCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callGetMainResourceDataBlockAndDispose(WKDataRef data, WKErrorRef error, void* context)
+{
+ WKFrameGetMainResourceDataBlock block = (WKFrameGetMainResourceDataBlock)context;
+ block(data, error);
+ Block_release(block);
+}
+
+void WKFrameGetMainResourceData_b(WKFrameRef frameRef, WKFrameGetMainResourceDataBlock block)
+{
+ WKFrameGetMainResourceData(frameRef, callGetMainResourceDataBlockAndDispose, 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 0000000..f812aeb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFrame.h
@@ -0,0 +1,89 @@
+/*
+ * 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 WKFrameLoadState {
+ kWKFrameLoadStateProvisional = 0,
+ kWKFrameLoadStateCommitted = 1,
+ kWKFrameLoadStateFinished = 2
+};
+typedef enum WKFrameLoadState 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 WKStringRef WKFrameCopyMIMEType(WKFrameRef frame);
+WK_EXPORT WKStringRef WKFrameCopyTitle(WKFrameRef frame);
+
+WK_EXPORT WKPageRef WKFrameGetPage(WKFrameRef frame);
+
+WK_EXPORT WKArrayRef WKFrameCopyChildFrames(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 (*WKFrameGetMainResourceDataFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
+WK_EXPORT void WKFrameGetMainResourceData(WKFrameRef frame, WKFrameGetMainResourceDataFunction function, void* functionContext);
+#ifdef __BLOCKS__
+typedef void (^WKFrameGetMainResourceDataBlock)(WKDataRef data, WKErrorRef error);
+WK_EXPORT void WKFrameGetMainResourceData_b(WKFrameRef frame, WKFrameGetMainResourceDataBlock 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 0000000..d44d0d3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp
@@ -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.
+ */
+
+#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 0000000..99b013d
--- /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 0000000..ed399ad
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.cpp
@@ -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.
+ */
+
+#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)
+{
+ if (wkProvider && wkProvider->version)
+ return;
+ 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 0000000..07cbd79
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationManager.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 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;
+
+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 0000000..ca52798
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPermissionRequest.cpp
@@ -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.
+ */
+
+#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 0000000..ee27b66
--- /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 0000000..7977369
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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 "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().releaseRef());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h b/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.h
new file mode 100644
index 0000000..85183fd
--- /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/WKInspector.cpp b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
new file mode 100644
index 0000000..7a87265
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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 "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 0000000..c147015
--- /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/WKNativeEvent.h b/Source/WebKit2/UIProcess/API/C/WKNativeEvent.h
new file mode 100644
index 0000000..ee0bd17
--- /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 0000000..90eb142
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.cpp
@@ -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.
+ */
+
+#include "WKNavigationData.h"
+
+#include "WKAPICast.h"
+#include "WebNavigationData.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());
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKNavigationData.h b/Source/WebKit2/UIProcess/API/C/WKNavigationData.h
new file mode 100644
index 0000000..c855b54
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKNavigationData.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 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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKNavigationData_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.cpp
new file mode 100644
index 0000000..3cf89cf
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.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 "WKOpenPanelParameters.h"
+
+#include "WKAPICast.h"
+#include "WebOpenPanelParameters.h"
+
+using namespace WebKit;
+
+WKTypeID WKOpenPanelParametersGetTypeID()
+{
+ return toAPI(WebOpenPanelParameters::APIType);
+}
+
+bool WKOpenPanelParametersGetAllowsMultipleFiles(WKOpenPanelParametersRef parametersRef)
+{
+ return toImpl(parametersRef)->allowMultipleFiles();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.h
new file mode 100644
index 0000000..f32731c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelParameters.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 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);
+
+#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 0000000..5b143f2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKOpenPanelResultListener.cpp
@@ -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.
+ */
+
+#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 0000000..d581738
--- /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 0000000..edcbf87
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -0,0 +1,431 @@
+/*
+ * 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 "WKPage.h"
+#include "WKPagePrivate.h"
+
+#include "WKAPICast.h"
+#include "WebBackForwardList.h"
+#include "WebData.h"
+#include "WebPageProxy.h"
+
+#ifdef __BLOCKS__
+#include <Block.h>
+#endif
+
+using namespace WebKit;
+
+WKTypeID WKPageGetTypeID()
+{
+ return toAPI(WebPageProxy::APIType);
+}
+
+WKContextRef WKPageGetContext(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->context());
+}
+
+WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->pageGroup());
+}
+
+void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
+{
+ toImpl(pageRef)->loadURL(toImpl(URLRef)->string());
+}
+
+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));
+}
+
+WKBackForwardListRef WKPageGetBackForwardList(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->backForwardList());
+}
+
+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());
+}
+
+#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
+WKInspectorRef WKPageGetInspector(WKPageRef pageRef)
+{
+ return toAPI(toImpl(pageRef)->inspector());
+}
+#endif
+
+double WKPageGetEstimatedProgress(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->estimatedProgress();
+}
+
+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").releaseRef();
+ return toAPI(sessionHistoryURLValueType);
+}
+
+WKDataRef WKPageCopySessionState(WKPageRef pageRef, void *context, WKPageSessionStateFilterCallback filter)
+{
+ return toAPI(toImpl(pageRef)->sessionStateData(filter, context).releaseRef());
+}
+
+void WKPageRestoreFromSessionState(WKPageRef pageRef, WKDataRef sessionStateData)
+{
+ toImpl(pageRef)->restoreFromSessionStateData(toImpl(sessionStateData));
+}
+
+double WKPageGetTextZoomFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->textZoomFactor();
+}
+
+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 WKPageScaleWebView(WKPageRef pageRef, double scale, WKPoint origin)
+{
+ toImpl(pageRef)->scaleWebView(scale, toIntPoint(origin));
+}
+
+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());
+}
+
+double WKPageGetViewScaleFactor(WKPageRef pageRef)
+{
+ return toImpl(pageRef)->viewScaleFactor();
+}
+
+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)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeContextMenuClient(wkClient);
+}
+
+void WKPageSetPageFindClient(WKPageRef pageRef, const WKPageFindClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeFindClient(wkClient);
+}
+
+void WKPageSetPageFormClient(WKPageRef pageRef, const WKPageFormClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeFormClient(wkClient);
+}
+
+void WKPageSetPageLoaderClient(WKPageRef pageRef, const WKPageLoaderClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeLoaderClient(wkClient);
+}
+
+void WKPageSetPagePolicyClient(WKPageRef pageRef, const WKPagePolicyClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializePolicyClient(wkClient);
+}
+
+void WKPageSetPageResourceLoadClient(WKPageRef pageRef, const WKPageResourceLoadClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeResourceLoadClient(wkClient);
+}
+
+void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClient* wkClient)
+{
+ if (wkClient && wkClient->version)
+ return;
+ toImpl(pageRef)->initializeUIClient(wkClient);
+}
+
+void WKPageRunJavaScriptInMainFrame(WKPageRef pageRef, WKStringRef scriptRef, void* context, WKPageRunJavaScriptFunction callback)
+{
+ toImpl(pageRef)->runJavaScriptInMainFrame(toImpl(scriptRef)->string(), StringCallback::create(context, callback));
+}
+
+#ifdef __BLOCKS__
+static void callRunJavaScriptBlockAndRelease(WKStringRef 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
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
new file mode 100644
index 0000000..05730e5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -0,0 +1,352 @@
+/*
+ * 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 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
+
+// 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 bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
+typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
+
+// Progress Client
+typedef void (*WKPageDidStartProgressCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageDidChangeProgressCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageDidFinishProgressCallback)(WKPageRef page, const void *clientInfo);
+
+// WebProcess Client
+// FIXME: These three functions should not be part of this client.
+typedef void (*WKPageProcessDidBecomeUnresponsiveCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageProcessDidBecomeResponsiveCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageProcessDidCrashCallback)(WKPageRef page, const void *clientInfo);
+
+typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, 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.
+ WKPageDidStartProgressCallback didStartProgress;
+ WKPageDidChangeProgressCallback didChangeProgress;
+ WKPageDidFinishProgressCallback didFinishProgress;
+
+ // FIXME: These three functions should not be part of this client.
+ WKPageProcessDidBecomeUnresponsiveCallback processDidBecomeUnresponsive;
+ WKPageProcessDidBecomeResponsiveCallback processDidBecomeResponsive;
+ WKPageProcessDidCrashCallback processDidCrash;
+
+ WKPageDidChangeBackForwardListCallback didChangeBackForwardList;
+};
+typedef struct WKPageLoaderClient WKPageLoaderClient;
+
+// Policy Client.
+typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
+typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
+typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
+
+struct WKPagePolicyClient {
+ int version;
+ const void * clientInfo;
+ WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
+ WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
+ WKPageDecidePolicyForMIMETypeCallback decidePolicyForMIMEType;
+};
+typedef struct WKPagePolicyClient WKPagePolicyClient;
+
+// 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;
+
+// Resource Load Client.
+typedef void (*WKPageDidInitiateLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, 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;
+
+// UI Client
+typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
+typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageCloseCallback)(WKPageRef page, 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 (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
+typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, const void* clientInfo);
+typedef void (*WKPageDidNotHandleKeyEventCallback)(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 void (*WKPageDidDrawCallback)(WKPageRef page, const void *clientInfo);
+typedef void (*WKPageDidScrollCallback)(WKPageRef page, 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 currentUsage, 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);
+
+struct WKPageUIClient {
+ int version;
+ const void * clientInfo;
+ WKPageCreateNewPageCallback createNewPage;
+ WKPageShowPageCallback showPage;
+ WKPageCloseCallback close;
+ WKPageRunJavaScriptAlertCallback runJavaScriptAlert;
+ WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm;
+ WKPageRunJavaScriptPromptCallback runJavaScriptPrompt;
+ WKPageSetStatusTextCallback setStatusText;
+ WKPageMouseDidMoveOverElementCallback mouseDidMoveOverElement;
+ WKPageMissingPluginButtonClickedCallback missingPluginButtonClicked;
+ WKPageDidNotHandleKeyEventCallback didNotHandleKeyEvent;
+ WKPageGetToolbarsAreVisibleCallback toolbarsAreVisible;
+ WKPageSetToolbarsAreVisibleCallback setToolbarsAreVisible;
+ WKPageGetMenuBarIsVisibleCallback menuBarIsVisible;
+ WKPageSetMenuBarIsVisibleCallback setMenuBarIsVisible;
+ WKPageGetStatusBarIsVisibleCallback statusBarIsVisible;
+ WKPageSetStatusBarIsVisibleCallback setStatusBarIsVisible;
+ WKPageGetIsResizableCallback isResizable;
+ WKPageSetIsResizableCallback setIsResizable;
+ WKPageGetWindowFrameCallback getWindowFrame;
+ WKPageSetWindowFrameCallback setWindowFrame;
+ WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel;
+ WKPageDidDrawCallback didDraw;
+ WKPageDidScrollCallback pageDidScroll;
+ WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota;
+ WKPageRunOpenPanelCallback runOpenPanel;
+ WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest;
+};
+typedef struct WKPageUIClient WKPageUIClient;
+
+// 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 {
+ 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);
+
+struct WKPageContextMenuClient {
+ int version;
+ const void * clientInfo;
+ WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
+ WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
+};
+typedef struct WKPageContextMenuClient WKPageContextMenuClient;
+
+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 WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
+
+WK_EXPORT WKStringRef WKPageCopyTitle(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);
+
+#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 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 WKPageScaleWebView(WKPageRef page, double scale, WKPoint origin);
+WK_EXPORT double WKPageGetViewScaleFactor(WKPageRef page);
+
+WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
+WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
+WK_EXPORT bool WKPageUseFixedLayout(WKPageRef pageRef);
+WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef pageRef);
+
+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)(WKStringRef, WKErrorRef, void*);
+WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
+#ifdef __BLOCKS__
+typedef void (^WKPageRunJavaScriptBlock)(WKStringRef, 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
+
+#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 0000000..6c10014
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPageGroup.cpp
@@ -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.
+ */
+
+#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 0000000..705df08
--- /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 0000000..3bf50c3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPagePrivate.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 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
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKPagePrivate_h */
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
new file mode 100644
index 0000000..379859c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -0,0 +1,451 @@
+/*
+ * 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 "WKPreferences.h"
+#include "WKPreferencesPrivate.h"
+
+#include "WKAPICast.h"
+#include "WebPreferences.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().releaseRef());
+}
+
+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 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 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 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 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 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 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();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
new file mode 100644
index 0000000..8116575
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -0,0 +1,153 @@
+/*
+ * 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 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);
+
+// 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);
+
+#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 0000000..7408c8e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
@@ -0,0 +1,99 @@
+/*
+ * 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;
+
+// Defaults to kWKFontSmoothingLevelMedium.
+WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel);
+WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(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 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 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);
+
+#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 0000000..c72ee98
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WKProtectionSpace.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 "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 0000000..c77d93b
--- /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 0000000..fd1bd09
--- /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/WebKit2.h b/Source/WebKit2/UIProcess/API/C/WebKit2.h
new file mode 100644
index 0000000..02a339f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/WebKit2.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 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/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/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(__APPLE__) && __APPLE__) || (defined(__OBJC__) && __OBJC__)
+#include <WebKit2/WKView.h>
+#endif
+
+#endif /* WebKit2_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 0000000..78df4ac
--- /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 0000000..6acb1a6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKAPICastWin.h
@@ -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.
+ */
+
+#ifndef WKAPICastWin_h
+#define WKAPICastWin_h
+
+#ifndef WKAPICast_h
+#error "Please #include \"WKAPICast.h\" instead of this file directly."
+#endif
+
+namespace WebKit {
+
+class WebView;
+
+WK_ADD_API_MAPPING(WKViewRef, WebView)
+
+}
+
+#endif // WKAPICastWin_h
diff --git a/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h b/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h
new file mode 100644
index 0000000..e2ee9a7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKBaseWin.h
@@ -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.
+ */
+
+#ifndef WKBaseWin_h
+#define WKBaseWin_h
+
+#ifndef WKBase_h
+#error "Please #include \"WKBase.h\" instead of this file directly."
+#endif
+
+typedef const struct OpaqueWKView* WKViewRef;
+
+#endif /* WKBaseWin_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 0000000..c8a9c34
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextPrivateWin.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 WKContextPrivateWin_h
+#define WKContextPrivateWin_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKContext.h>
+
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Defaults to true.
+WK_EXPORT void WKContextSetShouldPaintNativeControls(WKContextRef, bool);
+
+#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 0000000..9906c81
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKContextWin.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 "WKContext.h"
+#include "WKContextPrivateWin.h"
+
+#include "WKAPICast.h"
+#include "WebContext.h"
+
+using namespace WebKit;
+
+void WKContextSetShouldPaintNativeControls(WKContextRef contextRef, bool b)
+{
+ toImpl(contextRef)->setShouldPaintNativeControls(b);
+}
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 0000000..612661e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.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 "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().releaseRef());
+}
+
+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)
+{
+ toImpl(viewRef)->setInitialFocus(forward);
+}
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 0000000..f4226cd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKView.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 WKView_h
+#define WKView_h
+
+#include <WebKit2/WKBase.h>
+#include <windows.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+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 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);
+
+#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 0000000..00c3595
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/C/win/WKViewPrivate.cpp
@@ -0,0 +1,36 @@
+/*
+ * 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 "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 0000000..5f89fd4
--- /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 0000000..cb2a63e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
@@ -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.
+ */
+
+#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);
+ }
+
+ ~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*);
+
+ 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> inline void WKRetainPtr<T>::adopt(PtrType optr)
+{
+ PtrType ptr = m_ptr;
+ m_ptr = optr;
+ if (ptr)
+ WKRelease(ptr);
+}
+
+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;
+}
+
+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();
+}
+
+} // namespace WebKit
+
+using WebKit::WKRetainPtr;
+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 0000000..0f2c946
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKStringQt.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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 "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 0000000..cc46e42
--- /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 0000000..74eca86
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/cpp/qt/WKURLQt.cpp
@@ -0,0 +1,42 @@
+/*
+ * 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 "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 0000000..2e41473
--- /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/mac/FindIndicatorWindow.h b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.h
new file mode 100644
index 0000000..e8889b6
--- /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 WKView;
+@class WebFindIndicatorWindowAnimation;
+
+namespace WebKit {
+
+class FindIndicator;
+
+class FindIndicatorWindow {
+ WTF_MAKE_NONCOPYABLE(FindIndicatorWindow);
+
+public:
+ static PassOwnPtr<FindIndicatorWindow> create(WKView *);
+ ~FindIndicatorWindow();
+
+ void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
+
+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<WebFindIndicatorWindowAnimation> m_bounceAnimation;
+
+ RunLoop::Timer<FindIndicatorWindow> m_startFadeOutTimer;
+ RetainPtr<WebFindIndicatorWindowAnimation> 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 0000000..5b93a9e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/FindIndicatorWindow.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.
+ */
+
+#include "FindIndicatorWindow.h"
+
+#include "FindIndicator.h"
+#include <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 WebFindIndicatorView : NSView {
+ RefPtr<WebKit::FindIndicator> _findIndicator;
+}
+
+- (id)_initWithFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator;
+@end
+
+@implementation WebFindIndicatorView
+
+- (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 WebFindIndicatorWindowAnimation : 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 WebFindIndicatorWindowAnimation
+
+- (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)
+{
+ 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<WebFindIndicatorView> findIndicatorView(AdoptNS, [[WebFindIndicatorView alloc] _initWithFindIndicator:m_findIndicator]);
+ [m_findIndicatorWindow.get() setContentView:findIndicatorView.get()];
+
+ [[m_wkView window] addChildWindow:m_findIndicatorWindow.get() ordered:NSWindowAbove];
+ [m_findIndicatorWindow.get() setReleasedWhenClosed:NO];
+
+ // Start the bounce animation.
+ m_bounceAnimationContext = WKWindowBounceAnimationContextCreate(m_findIndicatorWindow.get());
+ m_bounceAnimation.adoptNS([[WebFindIndicatorWindowAnimation 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([[WebFindIndicatorWindowAnimation 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 0000000..2c4a235
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.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 PDFViewController_h
+#define PDFViewController_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 PDFViewController {
+ WTF_MAKE_NONCOPYABLE(PDFViewController);
+
+public:
+ static PassOwnPtr<PDFViewController> create(WKView *);
+ ~PDFViewController();
+
+ WKView* wkView() const { return m_wkView; }
+ void setPDFDocumentData(const String& mimeType, const CoreIPC::DataReference&);
+
+ double zoomFactor() const;
+ void setZoomFactor(double);
+
+ static Class pdfPreviewViewClass();
+
+ NSPrintOperation *makePrintOperation(NSPrintInfo *);
+
+private:
+ explicit PDFViewController(WKView *wkView);
+
+ static Class pdfDocumentClass();
+ static NSBundle* pdfKitBundle();
+
+ WKView* m_wkView;
+ RetainPtr<WKPDFView> m_wkPDFView;
+ PDFView* m_pdfView;
+};
+
+} // 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 0000000..a92c2d4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PDFViewController.mm
@@ -0,0 +1,297 @@
+/*
+ * 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 "PDFViewController.h"
+
+#import "DataReference.h"
+#import "WKAPICast.h"
+#import "WKView.h"
+#import "WebPageGroup.h"
+#import "WebPageProxy.h"
+#import "WebPreferences.h"
+#import <PDFKit/PDFKit.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);
+
+@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;
+
+@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)];
+ }
+
+ 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 = toImpl([_pdfViewController->wkView() pageRef])->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 = toImpl([_pdfViewController->wkView() pageRef])->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)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];
+}
+
+@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_wkView addSubview:m_wkPDFView.get()];
+}
+
+PDFViewController::~PDFViewController()
+{
+ [m_wkPDFView.get() removeFromSuperview];
+ [m_wkPDFView.get() invalidate];
+ m_wkPDFView = nullptr;
+}
+
+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 CoreIPC::DataReference& dataReference)
+{
+ RetainPtr<CFDataRef> data;
+
+ if (equalIgnoringCase(mimeType, "application/postscript")) {
+ data = convertPostScriptDataSourceToPDF(dataReference);
+ if (!data)
+ return;
+ } else {
+ // Make sure to copy the data.
+ data.adoptCF(CFDataCreate(0, dataReference.data(), dataReference.size()));
+ }
+
+ RetainPtr<PDFDocument> pdfDocument(AdoptNS, [[pdfDocumentClass() alloc] initWithData:(NSData *)data.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];
+}
+
+} // 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 0000000..8322465
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -0,0 +1,103 @@
+/*
+ * 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 PageClientImpl_h
+#define PageClientImpl_h
+
+#include "PageClient.h"
+#include <wtf/RetainPtr.h>
+
+@class WKView;
+@class WebEditorUndoTargetObjC;
+
+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 WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+
+ virtual void processDidCrash();
+ virtual void didRelaunchProcess();
+ virtual void takeFocus(bool direction);
+ virtual void toolTipChanged(const String& oldToolTip, const String& newToolTip);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setViewportArguments(const WebCore::ViewportArguments&);
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual void setEditCommandState(const String& commandName, bool isEnabled, int state);
+ virtual void interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
+
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+
+ virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+
+ void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void pageDidEnterAcceleratedCompositing();
+ virtual void pageDidLeaveAcceleratedCompositing();
+#endif
+
+ virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&);
+ virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
+
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&);
+
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+
+ WKView* m_wkView;
+ RetainPtr<WebEditorUndoTargetObjC> m_undoTarget;
+};
+
+} // 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 0000000..c37b641
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -0,0 +1,350 @@
+/*
+ * 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 "NativeWebKeyboardEvent.h"
+#import "PageClientImpl.h"
+
+#import "DataReference.h"
+#import "FindIndicator.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/KeyboardEvent.h>
+#import <wtf/PassOwnPtr.h>
+#import <wtf/text/CString.h>
+#import <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+@interface WebEditCommandObjC : NSObject
+{
+ RefPtr<WebKit::WebEditCommandProxy> m_command;
+}
+
+- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command;
+- (WebKit::WebEditCommandProxy*)command;
+
+@end
+
+@implementation WebEditCommandObjC
+
+- (id)initWithWebEditCommandProxy:(PassRefPtr<WebKit::WebEditCommandProxy>)command
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ m_command = command;
+ return self;
+}
+
+- (WebKit::WebEditCommandProxy*)command
+{
+ return m_command.get();
+}
+
+@end
+
+@interface WebEditorUndoTargetObjC : NSObject
+
+- (void)undoEditing:(id)sender;
+- (void)redoEditing:(id)sender;
+
+@end
+
+@implementation WebEditorUndoTargetObjC
+
+- (void)undoEditing:(id)sender
+{
+ ASSERT([sender isKindOfClass:[WebEditCommandObjC class]]);
+ [sender command]->unapply();
+}
+
+- (void)redoEditing:(id)sender
+{
+ ASSERT([sender isKindOfClass:[WebEditCommandObjC 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, [[WebEditorUndoTargetObjC 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];
+}
+
+IntSize PageClientImpl::viewSize()
+{
+ return IntSize([m_wkView bounds].size);
+}
+
+bool PageClientImpl::isViewWindowActive()
+{
+ return [[m_wkView window] isKeyWindow];
+}
+
+bool PageClientImpl::isViewFocused()
+{
+ return [m_wkView _isFocused];
+}
+
+bool PageClientImpl::isViewVisible()
+{
+ if (![m_wkView window])
+ 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::didRelaunchProcess()
+{
+ [m_wkView _didRelaunchProcess];
+}
+
+void PageClientImpl::takeFocus(bool direction)
+{
+ [m_wkView _takeFocus:direction];
+}
+
+void PageClientImpl::toolTipChanged(const String& oldToolTip, const String& newToolTip)
+{
+ [m_wkView _toolTipChangedFrom:nsStringFromWebCoreString(oldToolTip) to:nsStringFromWebCoreString(newToolTip)];
+}
+
+void PageClientImpl::setCursor(const WebCore::Cursor& cursor)
+{
+ [m_wkView _setCursor:cursor.platformCursor()];
+}
+
+void PageClientImpl::setViewportArguments(const WebCore::ViewportArguments&)
+{
+
+}
+
+static NSString* nameForEditAction(EditAction editAction)
+{
+ // FIXME: Use localized strings.
+ // FIXME: Move this to a platform independent location.
+
+ switch (editAction) {
+ case EditActionUnspecified: return nil;
+ case EditActionSetColor: return @"Set Color";
+ case EditActionSetBackgroundColor: return @"Set Background Color";
+ case EditActionTurnOffKerning: return @"Turn Off Kerning";
+ case EditActionTightenKerning: return @"Tighten Kerning";
+ case EditActionLoosenKerning: return @"Loosen Kerning";
+ case EditActionUseStandardKerning: return @"Use Standard Kerning";
+ case EditActionTurnOffLigatures: return @"Turn Off Ligatures";
+ case EditActionUseStandardLigatures: return @"Use Standard Ligatures";
+ case EditActionUseAllLigatures: return @"Use All Ligatures";
+ case EditActionRaiseBaseline: return @"Raise Baseline";
+ case EditActionLowerBaseline: return @"Lower Baseline";
+ case EditActionSetTraditionalCharacterShape: return @"Set Traditional Character Shape";
+ case EditActionSetFont: return @"Set Font";
+ case EditActionChangeAttributes: return @"Change Attributes";
+ case EditActionAlignLeft: return @"Align Left";
+ case EditActionAlignRight: return @"Align Right";
+ case EditActionCenter: return @"Center";
+ case EditActionJustify: return @"Justify";
+ case EditActionSetWritingDirection: return @"Set Writing Direction";
+ case EditActionSubscript: return @"Subscript";
+ case EditActionSuperscript: return @"Superscript";
+ case EditActionUnderline: return @"Underline";
+ case EditActionOutline: return @"Outline";
+ case EditActionUnscript: return @"Unscript";
+ case EditActionDrag: return @"Drag";
+ case EditActionCut: return @"Cut";
+ case EditActionPaste: return @"Paste";
+ case EditActionPasteFont: return @"Paste Font";
+ case EditActionPasteRuler: return @"Paste Ruler";
+ case EditActionTyping: return @"Typing";
+ case EditActionCreateLink: return @"Create Link";
+ case EditActionUnlink: return @"Unlink";
+ case EditActionInsertList: return @"Insert List";
+ case EditActionFormatBlock: return @"Formatting";
+ case EditActionIndent: return @"Indent";
+ case EditActionOutdent: return @"Outdent";
+ }
+ return nil;
+}
+
+void PageClientImpl::registerEditCommand(PassRefPtr<WebEditCommandProxy> prpCommand, WebPageProxy::UndoOrRedo undoOrRedo)
+{
+ RefPtr<WebEditCommandProxy> command = prpCommand;
+
+ RetainPtr<WebEditCommandObjC> commandObjC(AdoptNS, [[WebEditCommandObjC alloc] initWithWebEditCommandProxy:command]);
+ NSString *actionName = 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)
+ [undoManager setActionName:actionName];
+}
+
+void PageClientImpl::clearAllEditCommands()
+{
+ [[m_wkView undoManager] removeAllActionsWithTarget:m_undoTarget.get()];
+}
+
+void PageClientImpl::setEditCommandState(const String& commandName, bool isEnabled, int newState)
+{
+ [m_wkView _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:newState];
+}
+
+void PageClientImpl::interceptKeyEvent(const NativeWebKeyboardEvent& event, Vector<WebCore::KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines)
+{
+ commandsList = [m_wkView _interceptKeyEvent:event.nativeEvent()];
+ [m_wkView _getTextInputState:selectionStart selectionEnd:selectionEnd underlines:underlines];
+}
+
+FloatRect PageClientImpl::convertToDeviceSpace(const FloatRect& rect)
+{
+ return [m_wkView _convertToDeviceSpace:rect];
+}
+
+FloatRect PageClientImpl::convertToUserSpace(const FloatRect& rect)
+{
+ return [m_wkView _convertToUserSpace:rect];
+}
+
+void PageClientImpl::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event)
+{
+ NSEvent* nativeEvent = event.nativeEvent();
+ if ([nativeEvent type] == NSKeyDown) {
+ [m_wkView _setEventBeingResent:nativeEvent];
+ [[NSApplication sharedApplication] sendEvent:nativeEvent];
+ }
+}
+
+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)
+{
+ [m_wkView _setFindIndicator:findIndicator fadeOut:fadeOut];
+}
+
+void PageClientImpl::accessibilityChildTokenReceived(const CoreIPC::DataReference& data)
+{
+ NSData* remoteToken = [NSData dataWithBytes:data.data() length:data.size()];
+ [m_wkView _setAccessibilityChildToken:remoteToken];
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void PageClientImpl::pageDidEnterAcceleratedCompositing()
+{
+ [m_wkView _pageDidEnterAcceleratedCompositing];
+}
+
+void PageClientImpl::pageDidLeaveAcceleratedCompositing()
+{
+ [m_wkView _pageDidLeaveAcceleratedCompositing];
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void PageClientImpl::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
+{
+ [m_wkView _setComplexTextInputEnabled:complexTextInputEnabled pluginComplexTextInputIdentifier:pluginComplexTextInputIdentifier];
+}
+
+void PageClientImpl::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+ [m_wkView _setPageHasCustomRepresentation:useCustomRepresentation];
+}
+
+void PageClientImpl::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference)
+{
+ [m_wkView _didFinishLoadingDataForCustomRepresentation:dataReference];
+}
+
+double PageClientImpl::customRepresentationZoomFactor()
+{
+ return [m_wkView _customRepresentationZoomFactor];
+}
+
+void PageClientImpl::setCustomRepresentationZoomFactor(double zoomFactor)
+{
+ [m_wkView _setCustomRepresentationZoomFactor:zoomFactor];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h
new file mode 100644
index 0000000..b2ad3b0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.h
@@ -0,0 +1,44 @@
+/*
+ * 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 string:(NSString **)string;
+
+- (void)keyboardInputSourceChanged;
+
+@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 0000000..b7dae31
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKTextInputWindowController.mm
@@ -0,0 +1,156 @@
+/*
+ * 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 "WKTextInputWindowController.h"
+
+#include <WebKitSystemInterface.h>
+
+@interface WKTextInputPanel : NSPanel {
+ NSTextView *_inputTextView;
+}
+
+- (NSTextInputContext *)_inputContext;
+- (BOOL)_interpretKeyEvent:(NSEvent *)event string:(NSString **)string;
+
+@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:[self.contentView frame]];
+ _inputTextView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable | NSViewMaxXMargin | NSViewMinXMargin | NSViewMaxYMargin | NSViewMinYMargin;
+
+ NSScrollView* scrollView = [[NSScrollView alloc] initWithFrame:[self.contentView frame]];
+ scrollView.documentView = _inputTextView;
+ self.contentView = scrollView;
+ [scrollView release];
+
+ [self setFloatingPanel:YES];
+
+ return self;
+}
+
+- (void)_keyboardInputSourceChanged
+{
+ [_inputTextView setString:@""];
+ [self orderOut:nil];
+}
+
+- (BOOL)_interpretKeyEvent:(NSEvent *)event string:(NSString **)string
+{
+ BOOL hadMarkedText = [_inputTextView hasMarkedText];
+
+ *string = nil;
+
+ 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;
+ }
+
+ if (hadMarkedText) {
+ [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];
+}
+
+@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)interpretKeyEvent:(NSEvent *)event string:(NSString **)string
+{
+ return [_panel _interpretKeyEvent:event string:string];
+}
+
+- (void)keyboardInputSourceChanged
+{
+ [_panel _keyboardInputSourceChanged];
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.h b/Source/WebKit2/UIProcess/API/mac/WKView.h
new file mode 100644
index 0000000..618bbc4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.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.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <WebKit2/WKBase.h>
+
+@class WKViewData;
+
+WK_EXPORT
+@interface WKView : NSView <NSTextInput> {
+ WKViewData *_data;
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef;
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef;
+
+- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef;
+- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef;
+
+@property(readonly) WKPageRef pageRef;
+
+@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 0000000..da9b7c9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -0,0 +1,1795 @@
+/*
+ * 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 "WKView.h"
+
+#import "ChunkedUpdateDrawingAreaProxy.h"
+#import "DataReference.h"
+#import "DrawingAreaProxyImpl.h"
+#import "FindIndicator.h"
+#import "FindIndicatorWindow.h"
+#import "LayerBackedDrawingAreaProxy.h"
+#import "Logging.h"
+#import "NativeWebKeyboardEvent.h"
+#import "PDFViewController.h"
+#import "PageClientImpl.h"
+#import "PrintInfo.h"
+#import "RunLoop.h"
+#import "TextChecker.h"
+#import "TextCheckerState.h"
+#import "WKAPICast.h"
+#import "WKStringCF.h"
+#import "WKTextInputWindowController.h"
+#import "WebContext.h"
+#import "WebEventFactory.h"
+#import "WebPage.h"
+#import "WebPageProxy.h"
+#import "WebProcessManager.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/FloatRect.h>
+#import <WebCore/IntRect.h>
+#import <WebCore/KeyboardEvent.h>
+#import <WebCore/PlatformMouseEvent.h>
+#import <WebCore/PlatformScreen.h>
+#import <WebKitSystemInterface.h>
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+
+// FIXME (WebKit2) <rdar://problem/8728860> WebKit2 needs to be localized
+#define UI_STRING(__str, __desc) [NSString stringWithUTF8String:__str]
+
+@interface NSApplication (Details)
+- (void)speakString:(NSString *)string;
+@end
+
+@interface NSView (Details)
+- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView;
+@end
+
+@interface NSWindow (Details)
+- (NSRect)_growBoxRect;
+- (BOOL)_updateGrowBoxForWindowFrameChange;
+@end
+
+extern "C" {
+ // Need to declare this attribute name because AppKit exports it but does not make it available in API or SPI headers.
+ // <rdar://problem/8631468> tracks the request to make it available. This code should be removed when the bug is closed.
+ extern NSString *NSTextInputReplacementRangeAttributeName;
+}
+
+using namespace WebKit;
+using namespace WebCore;
+
+namespace WebKit {
+
+typedef id <NSValidatedUserInterfaceItem> ValidationItem;
+typedef Vector<RetainPtr<ValidationItem> > ValidationVector;
+typedef HashMap<String, ValidationVector> ValidationMap;
+
+}
+
+@interface WKViewData : NSObject {
+@public
+ OwnPtr<PageClientImpl> _pageClient;
+ RefPtr<WebPageProxy> _page;
+
+ // For ToolTips.
+ NSToolTipTag _lastToolTipTag;
+ id _trackingRectOwner;
+ void* _trackingRectUserData;
+
+#if USE(ACCELERATED_COMPOSITING)
+ NSView *_layerHostingView;
+#endif
+
+ 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.
+ NSEvent *_keyDownEventBeingResent;
+ Vector<KeypressCommand> _commandsList;
+
+ // The identifier of the plug-in we want to send complex text input to, or 0 if there is none.
+ uint64_t _pluginComplexTextInputIdentifier;
+
+ Vector<CompositionUnderline> _underlines;
+ unsigned _selectionStart;
+ unsigned _selectionEnd;
+
+ Vector<IntRect> _printingPageRects;
+ double _totalScaleFactorForPrinting;
+
+ bool _inBecomeFirstResponder;
+ bool _inResignFirstResponder;
+}
+@end
+
+@implementation WKViewData
+@end
+
+@interface WebFrameWrapper : NSObject {
+@public
+ RefPtr<WebFrameProxy> _frame;
+}
+
+- (id)initWithFrameProxy:(WebFrameProxy*)frame;
+- (WebFrameProxy*)webFrame;
+@end
+
+@implementation WebFrameWrapper
+
+- (id)initWithFrameProxy:(WebFrameProxy*)frame
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _frame = frame;
+ return self;
+}
+
+- (WebFrameProxy*)webFrame
+{
+ return _frame.get();
+}
+
+@end
+
+NSString * const PrintedFrameKey = @"WebKitPrintedFrameKey";
+
+@interface NSObject (NSTextInputContextDetails)
+- (BOOL)wantsToHandleMouseEvents;
+- (BOOL)handleMouseEvent:(NSEvent *)event;
+@end
+
+@implementation WKView
+
+static bool useNewDrawingArea()
+{
+ static bool useNewDrawingArea = getenv("USE_NEW_DRAWING_AREA");
+
+ return useNewDrawingArea;
+}
+
+- (id)initWithFrame:(NSRect)frame
+{
+ return [self initWithFrame:frame contextRef:toAPI(WebContext::sharedProcessContext())];
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef
+{
+ return [self initWithFrame:frame contextRef:contextRef pageGroupRef:nil];
+}
+
+static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
+static NSString * const WebURLsWithTitlesPboardType = @"WebURLsWithTitlesPboardType";
+static NSString * const WebURLPboardType = @"public.url";
+static NSString * const WebURLNamePboardType = @"public.url-name";
+
+- (void)_registerDraggedTypes
+{
+ NSArray *editableTypes = [NSArray arrayWithObjects:WebArchivePboardType, NSHTMLPboardType, NSFilenamesPboardType, NSTIFFPboardType, NSPDFPboardType,
+#if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD)
+ NSPICTPboardType,
+#endif
+ NSURLPboardType, NSRTFDPboardType, NSRTFPboardType, NSStringPboardType, NSColorPboardType, kUTTypePNG, nil];
+ NSArray *URLTypes = [NSArray arrayWithObjects:WebURLsWithTitlesPboardType, NSURLPboardType, WebURLPboardType, WebURLNamePboardType, NSStringPboardType, NSFilenamesPboardType, nil];
+ NSMutableSet *types = [[NSMutableSet alloc] initWithArray:editableTypes];
+ [types addObjectsFromArray:URLTypes];
+ [self registerForDraggedTypes:[types allObjects]];
+ [types release];
+}
+
+- (id)initWithFrame:(NSRect)frame contextRef:(WKContextRef)contextRef pageGroupRef:(WKPageGroupRef)pageGroupRef
+{
+ self = [super initWithFrame:frame];
+ if (!self)
+ return nil;
+
+ InitWebCoreSystemInterface();
+ RunLoop::initializeMainRunLoop();
+
+ NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect:frame
+ options:(NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingInVisibleRect)
+ 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();
+
+ [self _registerDraggedTypes];
+
+ WebContext::statistics().wkViewCount++;
+
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ NSData *remoteToken = (NSData *)WKAXRemoteTokenForElement(self);
+ CoreIPC::DataReference dataToken = CoreIPC::DataReference(reinterpret_cast<const uint8_t*>([remoteToken bytes]), [remoteToken length]);
+ _data->_page->sendAccessibilityPresenterToken(dataToken);
+#endif
+
+ return self;
+}
+
+- (void)dealloc
+{
+ _data->_page->close();
+
+ [_data release];
+
+ WebContext::statistics().wkViewCount--;
+
+ [super dealloc];
+}
+
+- (WKPageRef)pageRef
+{
+ return toAPI(_data->_page.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;
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+ _data->_inBecomeFirstResponder = false;
+
+ if (direction != NSDirectSelection)
+ _data->_page->setInitialFocus(direction == NSSelectingNext);
+
+ return YES;
+}
+
+- (BOOL)resignFirstResponder
+{
+ _data->_inResignFirstResponder = true;
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsFocused);
+ _data->_inResignFirstResponder = false;
+
+ return YES;
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+ [super setFrameSize:size];
+
+ if (!_data->_page->drawingArea())
+ return;
+
+ _data->_page->drawingArea()->setSize(IntSize(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];
+}
+
+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");
+
+ 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(copy)
+WEBCORE_COMMAND(cut)
+WEBCORE_COMMAND(paste)
+WEBCORE_COMMAND(delete)
+WEBCORE_COMMAND(pasteAsPlainText)
+WEBCORE_COMMAND(selectAll)
+WEBCORE_COMMAND(takeFindStringFromSelection)
+
+#undef WEBCORE_COMMAND
+
+// 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;
+}
+
+- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
+{
+ SEL action = [item action];
+
+ if (action == @selector(showGuessPanel:)) {
+ if (NSMenuItem *menuItem = ::menuItem(item)) {
+ BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] spellingPanel] isVisible];
+ [menuItem setTitle:panelShowing
+ ? UI_STRING("Hide Spelling and Grammar", "menu item title")
+ : UI_STRING("Show Spelling and Grammar", "menu item title")];
+ }
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(checkSpelling:) || action == @selector(changeSpelling:))
+ return _data->_page->selectionState().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->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(orderFrontSubstitutionsPanel:)) {
+ if (NSMenuItem *menuItem = ::menuItem(item)) {
+ BOOL panelShowing = [[[NSSpellChecker sharedSpellChecker] substitutionsPanel] isVisible];
+ [menuItem setTitle:panelShowing
+ ? UI_STRING("Hide Substitutions", "menu item title")
+ : UI_STRING("Show Substitutions", "menu item title")];
+ }
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(toggleSmartInsertDelete:)) {
+ bool checked = _data->_page->isSmartInsertDeleteEnabled();
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticQuoteSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticQuoteSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticDashSubstitution:)) {
+ bool checked = TextChecker::state().isAutomaticDashSubstitutionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticLinkDetection:)) {
+ bool checked = TextChecker::state().isAutomaticLinkDetectionEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(toggleAutomaticTextReplacement:)) {
+ bool checked = TextChecker::state().isAutomaticTextReplacementEnabled;
+ [menuItem(item) setState:checked ? NSOnState : NSOffState];
+ return _data->_page->selectionState().isContentEditable;
+ }
+
+ if (action == @selector(uppercaseWord:) || action == @selector(lowercaseWord:) || action == @selector(capitalizeWord:))
+ return _data->_page->selectionState().selectedRangeLength && _data->_page->selectionState().isContentEditable;
+
+ if (action == @selector(stopSpeaking:))
+ return [NSApp isSpeaking];
+
+ // 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.
+ // FIXME: The function called here should be renamed validateCommand because it is not specific to menu items.
+ _data->_page->validateMenuItem(commandName);
+ }
+
+ // 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();
+
+ if (!spellCheckingEnabled)
+ _data->_page->unmarkAllMisspellings();
+}
+
+- (IBAction)toggleGrammarChecking:(id)sender
+{
+ bool grammarCheckingEnabled = !TextChecker::state().isGrammarCheckingEnabled;
+ TextChecker::setGrammarCheckingEnabled(grammarCheckingEnabled);
+
+ _data->_page->process()->updateTextCheckerState();
+
+ if (!grammarCheckingEnabled)
+ _data->_page->unmarkAllBadGrammar();
+}
+
+- (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();
+}
+
+// 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;
+}
+
+#define EVENT_HANDLER(Selector, Type) \
+ - (void)Selector:(NSEvent *)theEvent \
+ { \
+ Web##Type##Event webEvent = WebEventFactory::createWeb##Type##Event(theEvent, self); \
+ _data->_page->handle##Type##Event(webEvent); \
+ }
+
+EVENT_HANDLER(mouseEntered, Mouse)
+EVENT_HANDLER(mouseExited, Mouse)
+EVENT_HANDLER(mouseMoved, Mouse)
+EVENT_HANDLER(otherMouseDown, Mouse)
+EVENT_HANDLER(otherMouseDragged, Mouse)
+EVENT_HANDLER(otherMouseMoved, Mouse)
+EVENT_HANDLER(otherMouseUp, Mouse)
+EVENT_HANDLER(rightMouseDown, Mouse)
+EVENT_HANDLER(rightMouseDragged, Mouse)
+EVENT_HANDLER(rightMouseMoved, Mouse)
+EVENT_HANDLER(rightMouseUp, Mouse)
+EVENT_HANDLER(scrollWheel, Wheel)
+
+#undef EVENT_HANDLER
+
+#define MOUSE_EVENT_HANDLER(Selector) \
+ - (void)Selector:(NSEvent *)theEvent \
+ { \
+ NSInputManager *currentInputManager = [NSInputManager currentInputManager]; \
+ if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:theEvent]) \
+ return; \
+ WebMouseEvent webEvent = WebEventFactory::createWebMouseEvent(theEvent, self); \
+ _data->_page->handleMouseEvent(webEvent); \
+ }
+
+MOUSE_EVENT_HANDLER(mouseDown)
+MOUSE_EVENT_HANDLER(mouseDragged)
+MOUSE_EVENT_HANDLER(mouseUp)
+
+#undef MOUSE_EVENT_HANDLER
+
+- (void)doCommandBySelector:(SEL)selector
+{
+ if (selector != @selector(noop:))
+ _data->_commandsList.append(KeypressCommand(commandNameForSelector(selector)));
+}
+
+- (void)insertText:(id)string
+{
+ BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString
+
+ LOG(TextInput, "insertText:\"%@\"", isAttributedString ? [string string] : string);
+ NSString *text;
+ bool isFromInputMethod = _data->_page->selectionState().hasComposition;
+
+ if (isAttributedString) {
+ text = [string string];
+ // We deal with the NSTextInputReplacementRangeAttributeName attribute from NSAttributedString here
+ // simply because it is used by at least one Input Method -- it corresonds to the kEventParamTextInputSendReplaceRange
+ // event in TSM. This behaviour matches that of -[WebHTMLView setMarkedText:selectedRange:] when it receives an
+ // NSAttributedString
+ NSString *rangeString = [string attribute:NSTextInputReplacementRangeAttributeName atIndex:0 longestEffectiveRange:NULL inRange:NSMakeRange(0, [text length])];
+ LOG(TextInput, "ReplacementRange: %@", rangeString);
+ if (rangeString)
+ isFromInputMethod = YES;
+ } else
+ text = string;
+
+ String eventText = text;
+
+ if (!isFromInputMethod)
+ _data->_commandsList.append(KeypressCommand("insertText", text));
+ else {
+ eventText.replace(NSBackTabCharacter, NSTabCharacter); // same thing is done in KeyEventMac.mm in WebCore
+ _data->_commandsList.append(KeypressCommand("insertText", eventText));
+ }
+}
+
+- (BOOL)_handleStyleKeyEquivalent:(NSEvent *)event
+{
+ 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);
+
+ // 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->_keyDownEventBeingResent release];
+ _data->_keyDownEventBeingResent = nil;
+
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(event, self));
+ return YES;
+ }
+
+ return [self _handleStyleKeyEquivalent:event] || [super performKeyEquivalent:event];
+}
+
+- (void)_setEventBeingResent:(NSEvent *)event
+{
+ _data->_keyDownEventBeingResent = [event retain];
+}
+
+- (Vector<KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent
+{
+ _data->_commandsList.clear();
+ // interpretKeyEvents will trigger one or more calls to doCommandBySelector or setText
+ // that will populate the commandsList vector.
+ [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+ return _data->_commandsList;
+}
+
+- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines
+{
+ start = _data->_selectionStart;
+ end = _data->_selectionEnd;
+ lines = _data->_underlines;
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ if (_data->_pluginComplexTextInputIdentifier) {
+ // Try feeding the keyboard event directly to the plug-in.
+ NSString *string = nil;
+ if ([[WKTextInputWindowController sharedTextInputWindowController] interpretKeyEvent:theEvent string:&string]) {
+ if (string)
+ _data->_page->sendComplexTextInputToPlugin(_data->_pluginComplexTextInputIdentifier, string);
+ return;
+ }
+ }
+
+ _data->_underlines.clear();
+ _data->_selectionStart = 0;
+ _data->_selectionEnd = 0;
+ // 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) {
+ [_data->_keyDownEventBeingResent release];
+ _data->_keyDownEventBeingResent = nil;
+ [super keyDown:theEvent];
+ return;
+ }
+ _data->_page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent, self));
+}
+
+- (NSTextInputContext *)inputContext {
+ if (_data->_pluginComplexTextInputIdentifier)
+ return [[WKTextInputWindowController sharedTextInputWindowController] inputContext];
+
+ return [super inputContext];
+}
+
+- (NSRange)selectedRange
+{
+ if (_data->_page->selectionState().isNone || !_data->_page->selectionState().isContentEditable)
+ return NSMakeRange(NSNotFound, 0);
+
+ LOG(TextInput, "selectedRange -> (%u, %u)", _data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength);
+ return NSMakeRange(_data->_page->selectionState().selectedRangeStart, _data->_page->selectionState().selectedRangeLength);
+}
+
+- (BOOL)hasMarkedText
+{
+ LOG(TextInput, "hasMarkedText -> %u", _data->_page->selectionState().hasComposition);
+ return _data->_page->selectionState().hasComposition;
+}
+
+- (void)unmarkText
+{
+ LOG(TextInput, "unmarkText");
+
+ _data->_commandsList.append(KeypressCommand("unmarkText"));
+}
+
+- (NSArray *)validAttributesForMarkedText
+{
+ static NSArray *validAttributes;
+ if (!validAttributes) {
+ validAttributes = [[NSArray alloc] initWithObjects:
+ NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName,
+ NSMarkedClauseSegmentAttributeName, NSTextInputReplacementRangeAttributeName, 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
+{
+ BOOL isAttributedString = [string isKindOfClass:[NSAttributedString class]]; // Otherwise, NSString
+
+ LOG(TextInput, "setMarkedText:\"%@\" selectedRange:(%u, %u)", isAttributedString ? [string string] : string, newSelRange.location, newSelRange.length);
+
+ NSString *text = string;
+
+ if (isAttributedString) {
+ text = [string string];
+ extractUnderlines(string, _data->_underlines);
+ }
+
+ _data->_commandsList.append(KeypressCommand("setMarkedText", text));
+ _data->_selectionStart = newSelRange.location;
+ _data->_selectionEnd = NSMaxRange(newSelRange);
+}
+
+- (NSRange)markedRange
+{
+ uint64_t location;
+ uint64_t length;
+
+ _data->_page->getMarkedRange(location, length);
+ LOG(TextInput, "markedRange -> (%u, %u)", location, length);
+ return NSMakeRange(location, length);
+}
+
+- (NSAttributedString *)attributedSubstringFromRange:(NSRange)nsRange
+{
+ // This is not implemented for now. Need to figure out how to serialize the attributed string across processes.
+ LOG(TextInput, "attributedSubstringFromRange");
+ return nil;
+}
+
+- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
+{
+ 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
+{
+ // 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];
+
+ 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;
+}
+
+- (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->performDragControllerAction(DragControllerActionEntered, &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->performDragControllerAction(DragControllerActionUpdated, &dragData, [[draggingInfo draggingPasteboard] name]);
+ return _data->_page->dragOperation();
+}
+
+- (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->performDragControllerAction(DragControllerActionExited, &dragData, [[draggingInfo draggingPasteboard] name]);
+ _data->_page->resetDragOperation();
+}
+
+- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)draggingInfo
+{
+ return YES;
+}
+
+- (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]);
+ _data->_page->performDragControllerAction(DragControllerActionPerformDrag, &dragData, [[draggingInfo draggingPasteboard] name]);
+ return YES;
+}
+
+- (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];
+ [[self window] setShowsResizeIndicator:YES];
+
+ BOOL ownsGrowBox = [self _ownsWindowGrowBox];
+ _data->_page->setWindowResizerSize(ownsGrowBox ? enclosingIntRect([[self window] _growBoxRect]).size() : IntSize());
+
+ // Once WebCore can draw the window resizer, this should read:
+ // if (wasShowingIndicator)
+ // [[self window] setShowsResizeIndicator:!ownsGrowBox];
+ [[self window] setShowsResizeIndicator:wasShowingIndicator];
+
+ return ownsGrowBox;
+}
+
+- (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];
+ }
+}
+
+- (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];
+}
+
+- (void)viewWillMoveToWindow:(NSWindow *)window
+{
+ if (window != [self window]) {
+ [self removeWindowObservers];
+ [self addWindowObserversForWindow:window];
+ }
+}
+
+- (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];
+ } else {
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive | WebPageProxy::ViewIsInWindow);
+ }
+
+}
+
+- (void)_windowDidBecomeKey:(NSNotification *)notification
+{
+ NSWindow *keyWindow = [notification object];
+ if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet])
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+}
+
+- (void)_windowDidResignKey:(NSNotification *)notification
+{
+ NSWindow *formerKeyWindow = [notification object];
+ if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet])
+ _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive);
+}
+
+- (void)_windowDidMiniaturize:(NSNotification *)notification
+{
+ [self _updateWindowVisibility];
+}
+
+- (void)_windowDidDeminiaturize:(NSNotification *)notification
+{
+ [self _updateWindowVisibility];
+}
+
+- (void)_windowFrameDidChange:(NSNotification *)notification
+{
+ [self _updateWindowAndViewFrames];
+}
+
+- (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);
+ if (useNewDrawingArea()) {
+ if (DrawingAreaProxyImpl* drawingArea = static_cast<DrawingAreaProxyImpl*>(_data->_page->drawingArea())) {
+ CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+ drawingArea->paint(context, enclosingIntRect(rect));
+ } else if (_data->_page->drawsBackground()) {
+ [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set];
+ NSRectFill(rect);
+ }
+
+ _data->_page->didDraw();
+ return;
+ }
+
+ if (_data->_page->isValid() && _data->_page->drawingArea()) {
+ CGContextRef context = static_cast<CGContextRef>([[NSGraphicsContext currentContext] graphicsPort]);
+ _data->_page->drawingArea()->paint(IntRect(rect), context);
+ _data->_page->didDraw();
+ } else if (_data->_page->drawsBackground()) {
+ [_data->_page->drawsTransparentBackground() ? [NSColor clearColor] : [NSColor whiteColor] set];
+ NSRectFill(rect);
+ }
+}
+
+- (BOOL)isOpaque
+{
+ return _data->_page->drawsBackground();
+}
+
+- (void)viewDidHide
+{
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+- (void)viewDidUnhide
+{
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+}
+
+- (void)_setAccessibilityChildToken:(NSData *)data
+{
+#if !defined(BUILDING_ON_SNOW_LEOPARD)
+ _data->_remoteAccessibilityChild = WKAXRemoteElementForToken((CFDataRef)data);
+ WKAXInitializeRemoteElementWithWindow(_data->_remoteAccessibilityChild.get(), [self window]);
+#endif
+}
+
+- (BOOL)accessibilityIsIgnored
+{
+ return NO;
+}
+
+- (id)accessibilityHitTest:(NSPoint)point
+{
+ return _data->_remoteAccessibilityChild.get();
+}
+
+- (id)accessibilityAttributeValue:(NSString*)attribute
+{
+ if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
+ if (!_data->_remoteAccessibilityChild)
+ return nil;
+ return [NSArray arrayWithObject:_data->_remoteAccessibilityChild.get()];
+ }
+ 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 USE(ACCELERATED_COMPOSITING)
+ if (hitView && _data && hitView == _data->_layerHostingView)
+ hitView = self;
+#endif
+ return hitView;
+}
+
+- (NSInteger)conversationIdentifier
+{
+ return (NSInteger)self;
+}
+
+static void setFrameBeingPrinted(NSPrintOperation *printOperation, WebFrameProxy* frame)
+{
+ RetainPtr<WebFrameWrapper> frameWrapper(AdoptNS, [[WebFrameWrapper alloc] initWithFrameProxy:frame]);
+ [[[printOperation printInfo] dictionary] setObject:frameWrapper.get() forKey:PrintedFrameKey];
+}
+
+static WebFrameProxy* frameBeingPrinted()
+{
+ return [[[[[NSPrintOperation currentOperation] printInfo] dictionary] objectForKey:PrintedFrameKey] webFrame];
+}
+
+- (NSPrintOperation *)printOperationWithPrintInfo:(NSPrintInfo *)printInfo forFrame:(WKFrameRef)frameRef
+{
+ LOG(View, "Creating an NSPrintOperation for frame '%s'", toImpl(frameRef)->url().utf8().data());
+ NSPrintOperation *printOperation;
+
+ // Only the top frame can currently contain a PDF view.
+ if (_data->_pdfViewController) {
+ ASSERT(toImpl(frameRef)->isMainFrame());
+ printOperation = _data->_pdfViewController->makePrintOperation(printInfo);
+ } else
+ printOperation = [NSPrintOperation printOperationWithView:self printInfo:printInfo];
+
+ setFrameBeingPrinted(printOperation, toImpl(frameRef));
+ return printOperation;
+}
+
+- (BOOL)canChangeFrameLayout:(WKFrameRef)frameRef
+{
+ // PDF documents are already paginated, so we can't change them to add headers and footers.
+ return !toImpl(frameRef)->isMainFrame() || !_data->_pdfViewController;
+}
+
+// Return the number of pages available for printing
+- (BOOL)knowsPageRange:(NSRangePointer)range
+{
+ LOG(View, "knowsPageRange:");
+ WebFrameProxy* frame = frameBeingPrinted();
+ ASSERT(frame);
+
+ if (frame->isMainFrame() && _data->_pdfViewController)
+ return [super knowsPageRange:range];
+
+ _data->_page->computePagesForPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo]), _data->_printingPageRects, _data->_totalScaleFactorForPrinting);
+
+ *range = NSMakeRange(1, _data->_printingPageRects.size());
+ return YES;
+}
+
+// Take over printing. AppKit applies incorrect clipping, and doesn't print pages beyond the first one.
+- (void)_recursiveDisplayRectIfNeededIgnoringOpacity:(NSRect)rect isVisibleRect:(BOOL)isVisibleRect rectIsVisibleRectForView:(NSView *)visibleView topView:(BOOL)topView
+{
+ // FIXME: This check isn't right for some non-printing cases, such as capturing into a buffer using cacheDisplayInRect:toBitmapImageRep:.
+ if ([NSGraphicsContext currentContextDrawingToScreen]) {
+ _data->_page->endPrinting();
+ [super _recursiveDisplayRectIfNeededIgnoringOpacity:rect isVisibleRect:isVisibleRect rectIsVisibleRectForView:visibleView topView:topView];
+ return;
+ }
+
+ LOG(View, "Printing rect x:%g, y:%g, width:%g, height:%g", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+
+ ASSERT(self == visibleView);
+ ASSERT(frameBeingPrinted());
+
+ WebFrameProxy* frame = frameBeingPrinted();
+ ASSERT(frame);
+
+ _data->_page->beginPrinting(frame, PrintInfo([[NSPrintOperation currentOperation] printInfo]));
+
+ // FIXME: This is optimized for print preview. Get the whole document at once when actually printing.
+ Vector<uint8_t> pdfData;
+ _data->_page->drawRectToPDF(frame, IntRect(rect), pdfData);
+
+ RetainPtr<CGDataProviderRef> pdfDataProvider(AdoptCF, CGDataProviderCreateWithData(0, pdfData.data(), pdfData.size(), 0));
+ RetainPtr<CGPDFDocumentRef> pdfDocument(AdoptCF, CGPDFDocumentCreateWithProvider(pdfDataProvider.get()));
+ if (!pdfDocument) {
+ LOG_ERROR("Couldn't create a PDF document with data passed for printing");
+ return;
+ }
+
+ CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDocument.get(), 1);
+ if (!pdfPage) {
+ LOG_ERROR("Printing data doesn't have page 1");
+ return;
+ }
+
+ NSGraphicsContext *nsGraphicsContext = [NSGraphicsContext currentContext];
+ CGContextRef context = static_cast<CGContextRef>([nsGraphicsContext graphicsPort]);
+
+ CGContextSaveGState(context);
+ // Flip the destination.
+ CGContextScaleCTM(context, 1, -1);
+ CGContextTranslateCTM(context, 0, -rect.size.height);
+ CGContextDrawPDFPage(context, pdfPage);
+ CGContextRestoreGState(context);
+}
+
+// FIXME 3491344: This is an AppKit-internal method that we need to override in order
+// to get our shrink-to-fit to work with a custom pagination scheme. We can do this better
+// if AppKit makes it SPI/API.
+- (CGFloat)_provideTotalScaleFactorForPrintOperation:(NSPrintOperation *)printOperation
+{
+ return _data->_totalScaleFactorForPrinting;
+}
+
+// Return the drawing rectangle for a particular page number
+- (NSRect)rectForPage:(NSInteger)page
+{
+ WebFrameProxy* frame = frameBeingPrinted();
+ ASSERT(frame);
+
+ if (frame->isMainFrame() && _data->_pdfViewController)
+ return [super rectForPage:page];
+
+ LOG(View, "rectForPage:%d -> x %d, y %d, width %d, height %d\n", (int)page, _data->_printingPageRects[page - 1].x(), _data->_printingPageRects[page - 1].y(), _data->_printingPageRects[page - 1].width(), _data->_printingPageRects[page - 1].height());
+ return _data->_printingPageRects[page - 1];
+}
+
+@end
+
+@implementation WKView (Internal)
+
+- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy
+{
+ if (useNewDrawingArea())
+ return DrawingAreaProxyImpl::create(_data->_page.get());
+
+ return ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get());
+}
+
+- (BOOL)_isFocused
+{
+ if (_data->_inBecomeFirstResponder)
+ return YES;
+ if (_data->_inResignFirstResponder)
+ return NO;
+ return [[self window] firstResponder] == self;
+}
+
+- (void)_processDidCrash
+{
+ [self setNeedsDisplay:YES];
+}
+
+- (void)_didRelaunchProcess
+{
+ [self setNeedsDisplay:YES];
+}
+
+- (void)_takeFocus:(BOOL)forward
+{
+ if (forward)
+ [[self window] selectKeyViewFollowingView:self];
+ else
+ [[self window] selectKeyViewPrecedingView:self];
+}
+
+- (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.
+ }
+}
+
+- (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 (tag == 0)
+ return;
+
+ if (_data && (tag == TRACKING_RECT_TAG)) {
+ _data->_trackingRectOwner = nil;
+ return;
+ }
+
+ if (_data && (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
+{
+ if (!findIndicator) {
+ _data->_findIndicatorWindow = 0;
+ return;
+ }
+
+ if (!_data->_findIndicatorWindow)
+ _data->_findIndicatorWindow = FindIndicatorWindow::create(self);
+
+ _data->_findIndicatorWindow->setFindIndicator(findIndicator, fadeOut);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+- (void)_startAcceleratedCompositing:(CALayer *)rootLayer
+{
+ if (!_data->_layerHostingView) {
+ NSView *hostingView = [[NSView alloc] initWithFrame:[self bounds]];
+#if !defined(BUILDING_ON_LEOPARD)
+ [hostingView setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+#endif
+
+ [self addSubview:hostingView];
+ [hostingView release];
+ _data->_layerHostingView = hostingView;
+ }
+
+ // Make a container layer, which will get sized/positioned by AppKit and CA.
+ CALayer *viewLayer = [CALayer layer];
+
+#ifndef NDEBUG
+ [viewLayer setName:@"hosting layer"];
+#endif
+
+#if defined(BUILDING_ON_LEOPARD)
+ // Turn off default animations.
+ NSNull *nullValue = [NSNull null];
+ NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
+ nullValue, @"anchorPoint",
+ nullValue, @"bounds",
+ nullValue, @"contents",
+ nullValue, @"contentsRect",
+ nullValue, @"opacity",
+ nullValue, @"position",
+ nullValue, @"sublayerTransform",
+ nullValue, @"sublayers",
+ nullValue, @"transform",
+ nil];
+ [viewLayer setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
+#endif
+
+#if !defined(BUILDING_ON_LEOPARD)
+ // If we aren't in the window yet, we'll use the screen's scale factor now, and reset the scale
+ // via -viewDidMoveToWindow.
+ CGFloat scaleFactor = [self window] ? [[self window] userSpaceScaleFactor] : [[NSScreen mainScreen] userSpaceScaleFactor];
+ [viewLayer setTransform:CATransform3DMakeScale(scaleFactor, scaleFactor, 1)];
+#endif
+
+ [_data->_layerHostingView setLayer:viewLayer];
+ [_data->_layerHostingView setWantsLayer:YES];
+
+ // Parent our root layer in the container layer
+ [viewLayer addSublayer:rootLayer];
+}
+
+- (void)_stopAcceleratedCompositing
+{
+ if (_data->_layerHostingView) {
+ [_data->_layerHostingView setLayer:nil];
+ [_data->_layerHostingView setWantsLayer:NO];
+ [_data->_layerHostingView removeFromSuperview];
+ _data->_layerHostingView = nil;
+ }
+}
+
+- (void)_switchToDrawingAreaTypeIfNecessary:(DrawingAreaInfo::Type)type
+{
+ DrawingAreaInfo::Type existingDrawingAreaType = _data->_page->drawingArea() ? _data->_page->drawingArea()->info().type : DrawingAreaInfo::None;
+ if (existingDrawingAreaType == type)
+ return;
+
+ OwnPtr<DrawingAreaProxy> newDrawingArea;
+ switch (type) {
+ case DrawingAreaInfo::Impl:
+ case DrawingAreaInfo::None:
+ break;
+ case DrawingAreaInfo::ChunkedUpdate: {
+ newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(self, _data->_page.get());
+ break;
+ }
+ case DrawingAreaInfo::LayerBacked: {
+ newDrawingArea = LayerBackedDrawingAreaProxy::create(self, _data->_page.get());
+ break;
+ }
+ }
+
+ newDrawingArea->setSize(IntSize([self frame].size));
+
+ _data->_page->drawingArea()->detachCompositingContext();
+ _data->_page->setDrawingArea(newDrawingArea.release());
+}
+
+- (void)_pageDidEnterAcceleratedCompositing
+{
+ [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::LayerBacked];
+}
+
+- (void)_pageDidLeaveAcceleratedCompositing
+{
+ // FIXME: we may want to avoid flipping back to the non-layer-backed drawing area until the next page load, to avoid thrashing.
+ [self _switchToDrawingAreaTypeIfNecessary:DrawingAreaInfo::ChunkedUpdate];
+}
+#endif // USE(ACCELERATED_COMPOSITING)
+
+- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier
+{
+ BOOL inputSourceChanged = _data->_pluginComplexTextInputIdentifier;
+
+ if (complexTextInputEnabled) {
+ // 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 disable complex text input for a plug-in that is not the current plug-in.
+ if (pluginComplexTextInputIdentifier != _data->_pluginComplexTextInputIdentifier)
+ return;
+
+ _data->_pluginComplexTextInputIdentifier = 0;
+ }
+
+ if (inputSourceChanged) {
+ // Inform the out of line window that the input source changed.
+ [[WKTextInputWindowController sharedTextInputWindowController] keyboardInputSourceChanged];
+ }
+}
+
+- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation
+{
+ _data->_pdfViewController = nullptr;
+
+ if (pageHasCustomRepresentation)
+ _data->_pdfViewController = PDFViewController::create(self);
+}
+
+- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference
+{
+ ASSERT(_data->_pdfViewController);
+
+ _data->_pdfViewController->setPDFDocumentData(_data->_page->mainFrame()->mimeType(), dataReference);
+}
+
+- (double)_customRepresentationZoomFactor
+{
+ if (!_data->_pdfViewController)
+ return 1;
+
+ return _data->_pdfViewController->zoomFactor();
+}
+
+- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor
+{
+ if (!_data->_pdfViewController)
+ return;
+
+ _data->_pdfViewController->setZoomFactor(zoomFactor);
+}
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h
new file mode 100644
index 0000000..1c70b38
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/mac/WKViewInternal.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.
+ */
+
+#import "WKView.h"
+#import <WebCore/Editor.h>
+#import <WebCore/KeyboardEvent.h>
+
+namespace WebKit {
+ class DrawingAreaProxy;
+ class FindIndicator;
+}
+
+@interface WKView (Internal)
+- (PassOwnPtr<WebKit::DrawingAreaProxy>)_createDrawingAreaProxy;
+- (BOOL)_isFocused;
+- (void)_processDidCrash;
+- (void)_didRelaunchProcess;
+- (void)_takeFocus:(BOOL)direction;
+- (void)_toolTipChangedFrom:(NSString *)oldToolTip to:(NSString *)newToolTip;
+- (void)_setCursor:(NSCursor *)cursor;
+- (void)_setUserInterfaceItemState:(NSString *)commandName enabled:(BOOL)isEnabled state:(int)newState;
+- (Vector<WebCore::KeypressCommand>&)_interceptKeyEvent:(NSEvent *)theEvent;
+- (void)_getTextInputState:(unsigned)start selectionEnd:(unsigned)end underlines:(Vector<WebCore::CompositionUnderline>&)lines;
+- (void)_setEventBeingResent:(NSEvent *)event;
+- (NSRect)_convertToDeviceSpace:(NSRect)rect;
+- (NSRect)_convertToUserSpace:(NSRect)rect;
+- (void)_setFindIndicator:(PassRefPtr<WebKit::FindIndicator>)findIndicator fadeOut:(BOOL)fadeOut;
+
+#if USE(ACCELERATED_COMPOSITING)
+- (void)_startAcceleratedCompositing:(CALayer *)rootLayer;
+- (void)_stopAcceleratedCompositing;
+- (void)_pageDidEnterAcceleratedCompositing;
+- (void)_pageDidLeaveAcceleratedCompositing;
+#endif
+
+- (void)_setAccessibilityChildToken:(NSData *)data;
+- (void)_setComplexTextInputEnabled:(BOOL)complexTextInputEnabled pluginComplexTextInputIdentifier:(uint64_t)pluginComplexTextInputIdentifier;
+
+- (void)_setPageHasCustomRepresentation:(BOOL)pageHasCustomRepresentation;
+- (void)_didFinishLoadingDataForCustomRepresentation:(const CoreIPC::DataReference&)dataReference;
+- (double)_customRepresentationZoomFactor;
+- (void)_setCustomRepresentationZoomFactor:(double)zoomFactor;
+
+@end
diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp
new file mode 100644
index 0000000..642e529
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.cpp
@@ -0,0 +1,169 @@
+/*
+ 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.
+*/
+
+#include "ClientImpl.h"
+
+#include "WebFrameProxy.h"
+#include "WKAPICast.h"
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include <qwkpage.h>
+#include <qwkpage_p.h>
+#include <WKFrame.h>
+#include <WKType.h>
+
+using namespace WebKit;
+
+static QWKPage* toQWKPage(const void* clientInfo)
+{
+ if (clientInfo)
+ return reinterpret_cast<QWKPage*>(const_cast<void*>(clientInfo));
+ return 0;
+}
+
+static void loadFinished(WKFrameRef frame, const void* clientInfo, bool ok)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ emit toQWKPage(clientInfo)->loadFinished(ok);
+ QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions();
+}
+
+void qt_wk_didStartProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ emit toQWKPage(clientInfo)->loadStarted();
+ QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions();
+}
+
+void qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+}
+
+void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+ loadFinished(frame, clientInfo, false);
+}
+
+void qt_wk_didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ WebFrameProxy* wkframe = toImpl(frame);
+ QString urlStr(wkframe->url());
+ QUrl qUrl = urlStr;
+ emit toQWKPage(clientInfo)->urlChanged(qUrl);
+ QWKPagePrivate::get(toQWKPage(clientInfo))->updateNavigationActions();
+}
+
+void qt_wk_didFinishDocumentLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ // FIXME: Implement (bug #44934)
+}
+
+void qt_wk_didFinishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ loadFinished(frame, clientInfo, true);
+}
+
+void qt_wk_didFailLoadWithErrorForFrame(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo)
+{
+ loadFinished(frame, clientInfo, false);
+}
+
+void qt_wk_didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ QString qTitle = WKStringCopyQString(title);
+ emit toQWKPage(clientInfo)->titleChanged(qTitle);
+}
+
+void qt_wk_didFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ emit toQWKPage(clientInfo)->initialLayoutCompleted();
+}
+
+void qt_wk_didRemoveFrameFromHierarchy(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ // FIXME: Implement (bug #46432)
+}
+
+void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ // FIXME: emit toWKView(clientInfo)->initialLayoutCompleted();
+}
+
+void qt_wk_didStartProgress(WKPageRef page, const void* clientInfo)
+{
+ emit toQWKPage(clientInfo)->loadProgress(0);
+}
+
+void qt_wk_didChangeProgress(WKPageRef page, const void* clientInfo)
+{
+ emit toQWKPage(clientInfo)->loadProgress(WKPageGetEstimatedProgress(page) * 100);
+}
+
+void qt_wk_didFinishProgress(WKPageRef page, const void* clientInfo)
+{
+ emit toQWKPage(clientInfo)->loadProgress(100);
+}
+
+void qt_wk_didBecomeUnresponsive(WKPageRef page, const void* clientInfo)
+{
+}
+
+void qt_wk_didBecomeResponsive(WKPageRef page, const void* clientInfo)
+{
+}
+
+WKPageRef qt_wk_createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void* clientInfo)
+{
+ QWKPage* wkPage = toQWKPage(clientInfo);
+ QWKPagePrivate* d = QWKPagePrivate::get(wkPage);
+ QWKPage::CreateNewPageFn createNewPageFn = d->createNewPageFn;
+
+ if (!createNewPageFn)
+ return 0;
+
+ if (QWKPage* newPage = createNewPageFn(wkPage)) {
+ WKRetain(newPage->pageRef());
+ return newPage->pageRef();
+ }
+
+ return 0;
+}
+
+void qt_wk_showPage(WKPageRef page, const void* clientInfo)
+{
+}
+
+void qt_wk_close(WKPageRef page, const void* clientInfo)
+{
+ emit toQWKPage(clientInfo)->windowCloseRequested();
+}
+
+void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo)
+{
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/ClientImpl.h b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h
new file mode 100644
index 0000000..5d8c062
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/ClientImpl.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2008 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 DefaultClientCallbacksQt_h
+#define DefaultClientCallbacksQt_h
+
+#include <WebKit2/WKPage.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// loader client
+void qt_wk_didStartProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFailProvisionalLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFinishDocumentLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFailLoadWithErrorForFrame(WKPageRef, WKFrameRef, WKErrorRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didReceiveTitleForFrame(WKPageRef, WKStringRef title, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFirstLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didFirstVisuallyNonEmptyLayoutForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didRemoveFrameFromHierarchy(WKPageRef, WKFrameRef, WKTypeRef, const void* clientInfo);
+void qt_wk_didStartProgress(WKPageRef, const void* clientInfo);
+void qt_wk_didChangeProgress(WKPageRef, const void* clientInfo);
+void qt_wk_didFinishProgress(WKPageRef, const void* clientInfo);
+void qt_wk_didBecomeUnresponsive(WKPageRef, const void* clientInfo);
+void qt_wk_didBecomeResponsive(WKPageRef, const void* clientInfo);
+
+// ui client
+WKPageRef qt_wk_createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
+void qt_wk_showPage(WKPageRef page, const void *clientInfo);
+void qt_wk_close(WKPageRef page, const void *clientInfo);
+void qt_wk_runJavaScriptAlert(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void* clientInfo);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DefaultClientCallbacksQt_h */
+
diff --git a/Source/WebKit2/UIProcess/API/qt/WKView.h b/Source/WebKit2/UIProcess/API/qt/WKView.h
new file mode 100644
index 0000000..5bb95e8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/WKView.h
@@ -0,0 +1,28 @@
+/*
+ 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 WKView_h
+#define WKView_h
+
+#include <WebKit2/qgraphicswkview.h>
+#include <WebKit2/qwkcontext.h>
+#include <WebKit2/qwkpage.h>
+#include <WebKit2/qwkpreferences.h>
+
+#endif /* WKView_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
new file mode 100644
index 0000000..f01c5b2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.cpp
@@ -0,0 +1,442 @@
+/*
+ * 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 "qgraphicswkview.h"
+
+#include "ChunkedUpdateDrawingAreaProxy.h"
+#include "IntSize.h"
+#include "RunLoop.h"
+#include "TiledDrawingAreaProxy.h"
+#include "UpdateChunk.h"
+#include "WKAPICast.h"
+#include "qwkpage.h"
+#include "qwkpage_p.h"
+#include <QApplication>
+#include <QCursor>
+#include <QGraphicsSceneMouseEvent>
+#include <QGraphicsView>
+#include <QMenu>
+#include <QPainter>
+#include <QScrollBar>
+#include <QStyleOptionGraphicsItem>
+#include <QUrl>
+#include <QtDebug>
+#include <WebKit2/WKRetainPtr.h>
+#include <wtf/RefPtr.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+struct QGraphicsWKViewPrivate {
+ QGraphicsWKViewPrivate(QGraphicsWKView* view);
+ WKPageRef pageRef() const { return page->pageRef(); }
+
+ void onScaleChanged();
+ void commitScale();
+
+ QGraphicsWKView* q;
+ QWKPage* page;
+ QMenu* activeMenu;
+ RunLoop::Timer<QGraphicsWKViewPrivate> m_scaleCommitTimer;
+ bool m_isChangingScale;
+};
+
+QGraphicsWKView::QGraphicsWKView(QWKContext* context, BackingStoreType backingStoreType, QGraphicsItem* parent)
+ : QGraphicsWidget(parent)
+ , d(new QGraphicsWKViewPrivate(this))
+{
+ setFocusPolicy(Qt::StrongFocus);
+ setAcceptHoverEvents(true);
+
+ PassOwnPtr<DrawingAreaProxy> drawingAreaProxy;
+
+ d->page = new QWKPage(context);
+
+ switch (backingStoreType) {
+#if ENABLE(TILED_BACKING_STORE)
+ case Tiled:
+ drawingAreaProxy = TiledDrawingAreaProxy::create(this, toImpl(page()->pageRef()));
+ connect(this, SIGNAL(scaleChanged()), this, SLOT(onScaleChanged()));
+ break;
+#endif
+ case Simple:
+ default:
+ drawingAreaProxy = ChunkedUpdateDrawingAreaProxy::create(this, toImpl(page()->pageRef()));
+ break;
+ }
+
+ d->page->d->init(this, drawingAreaProxy);
+ connect(d->page, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(d->page, SIGNAL(loadStarted()), this, SIGNAL(loadStarted()));
+ connect(d->page, SIGNAL(loadFinished(bool)), this, SIGNAL(loadFinished(bool)));
+ connect(d->page, SIGNAL(loadProgress(int)), this, SIGNAL(loadProgress(int)));
+ connect(d->page, SIGNAL(initialLayoutCompleted()), this, SIGNAL(initialLayoutCompleted()));
+ connect(d->page, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&)));
+ connect(d->page, SIGNAL(cursorChanged(const QCursor&)), this, SLOT(updateCursor(const QCursor&)));
+ connect(d->page, SIGNAL(focusNextPrevChild(bool)), this, SLOT(focusNextPrevChildCallback(bool)));
+ connect(d->page, SIGNAL(showContextMenu(QMenu*)), this, SLOT(showContextMenu(QMenu*)));
+}
+
+QGraphicsWKView::~QGraphicsWKView()
+{
+ delete d->page;
+ delete d;
+}
+
+QWKPage* QGraphicsWKView::page() const
+{
+ return d->page;
+}
+
+void QGraphicsWKView::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget*)
+{
+ page()->d->paint(painter, option->exposedRect.toAlignedRect());
+}
+
+void QGraphicsWKView::setGeometry(const QRectF& rect)
+{
+ QSizeF oldSize = geometry().size();
+ QGraphicsWidget::setGeometry(rect);
+ if (geometry().size() == oldSize)
+ return;
+
+ // NOTE: call geometry() as setGeometry ensures that
+ // the geometry is within legal bounds (minimumSize, maximumSize)
+ page()->setViewportSize(geometry().size().toSize());
+}
+
+void QGraphicsWKView::load(const QUrl& url)
+{
+ page()->load(url);
+}
+
+void QGraphicsWKView::setUrl(const QUrl& url)
+{
+ page()->setUrl(url);
+}
+
+QUrl QGraphicsWKView::url() const
+{
+ return page()->url();
+}
+
+QString QGraphicsWKView::title() const
+{
+ return page()->title();
+}
+
+void QGraphicsWKView::triggerPageAction(QWKPage::WebAction action, bool checked)
+{
+ page()->triggerAction(action, checked);
+}
+
+void QGraphicsWKView::back()
+{
+ page()->triggerAction(QWKPage::Back);
+}
+
+void QGraphicsWKView::forward()
+{
+ page()->triggerAction(QWKPage::Forward);
+}
+
+void QGraphicsWKView::reload()
+{
+ page()->triggerAction(QWKPage::Reload);
+}
+
+void QGraphicsWKView::stop()
+{
+ page()->triggerAction(QWKPage::Stop);
+}
+
+void QGraphicsWKView::updateCursor(const QCursor& cursor)
+{
+ setCursor(cursor);
+}
+
+class FriendlyWidget : public QWidget
+{
+public:
+ bool focusNextPrevChild(bool next);
+};
+
+void QGraphicsWKView::focusNextPrevChildCallback(bool next)
+{
+ if (hasFocus()) {
+ // find the view which has the focus:
+ QList<QGraphicsView*> views = scene()->views();
+ const int viewCount = views.count();
+ QGraphicsView* focusedView = 0;
+ for (int i = 0; i < viewCount; ++i) {
+ if (views[i]->hasFocus()) {
+ focusedView = views[i];
+ break;
+ }
+ }
+
+ if (focusedView) {
+ QWidget* window = focusedView->window();
+ FriendlyWidget* friendlyWindow = static_cast<FriendlyWidget*>(window);
+ friendlyWindow->focusNextPrevChild(next);
+ }
+ }
+}
+
+/*! \reimp
+*/
+bool QGraphicsWKView::focusNextPrevChild(bool next)
+{
+ QKeyEvent ev(QEvent::KeyPress, Qt::Key_Tab, Qt::KeyboardModifiers(next ? Qt::NoModifier : Qt::ShiftModifier));
+ page()->d->keyPressEvent(&ev);
+ return true;
+}
+
+/*! \reimp
+*/
+QVariant QGraphicsWKView::itemChange(GraphicsItemChange change, const QVariant& value)
+{
+ // Here so that it can be reimplemented without breaking ABI.
+ return QGraphicsWidget::itemChange(change, value);
+}
+
+/*! \reimp
+*/
+bool QGraphicsWKView::event(QEvent* event)
+{
+ QEvent::Type eventType = event->type();
+ switch (eventType) {
+ case QEvent::TouchBegin:
+ case QEvent::TouchEnd:
+ case QEvent::TouchUpdate:
+ touchEvent(static_cast<QTouchEvent*>(event));
+ return true;
+ case QEvent::Show:
+ page()->d->page->drawingArea()->setPageIsVisible(true);
+ break;
+ case QEvent::Hide:
+ page()->d->page->drawingArea()->setPageIsVisible(false);
+ break;
+ default:
+ break;
+ }
+
+ // Here so that it can be reimplemented without breaking ABI.
+ return QGraphicsWidget::event(event);
+}
+
+/*! \reimp
+*/
+QSizeF QGraphicsWKView::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const
+{
+ if (which == Qt::PreferredSize)
+ return QSizeF(800, 600);
+ return QGraphicsWidget::sizeHint(which, constraint);
+}
+
+/*! \reimp
+*/
+QVariant QGraphicsWKView::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ // implement
+ return QVariant();
+}
+
+/*! \reimp
+*/
+void QGraphicsWKView::keyPressEvent(QKeyEvent* ev)
+{
+ page()->d->keyPressEvent(ev);
+}
+
+/*! \reimp
+*/
+void QGraphicsWKView::keyReleaseEvent(QKeyEvent* ev)
+{
+ page()->d->keyReleaseEvent(ev);
+}
+
+void QGraphicsWKView::hoverMoveEvent(QGraphicsSceneHoverEvent* ev)
+{
+ QGraphicsSceneMouseEvent me(QEvent::GraphicsSceneMouseMove);
+ me.setPos(ev->pos());
+ me.setScreenPos(ev->screenPos());
+
+ page()->d->mouseMoveEvent(&me);
+
+ if (!ev->isAccepted())
+ QGraphicsItem::hoverMoveEvent(ev);
+}
+
+void QGraphicsWKView::mouseMoveEvent(QGraphicsSceneMouseEvent* ev)
+{
+ page()->d->mouseMoveEvent(ev);
+ if (!ev->isAccepted())
+ QGraphicsItem::mouseMoveEvent(ev);
+}
+
+void QGraphicsWKView::mousePressEvent(QGraphicsSceneMouseEvent* ev)
+{
+ page()->d->mousePressEvent(ev);
+ if (!ev->isAccepted())
+ QGraphicsItem::mousePressEvent(ev);
+}
+
+void QGraphicsWKView::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
+{
+ page()->d->mouseReleaseEvent(ev);
+ if (!ev->isAccepted())
+ QGraphicsItem::mouseReleaseEvent(ev);
+}
+
+void QGraphicsWKView::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
+{
+ page()->d->mouseDoubleClickEvent(ev);
+ if (!ev->isAccepted())
+ QGraphicsItem::mouseReleaseEvent(ev);
+}
+
+void QGraphicsWKView::wheelEvent(QGraphicsSceneWheelEvent* ev)
+{
+ page()->d->wheelEvent(ev);
+ if (!ev->isAccepted())
+ QGraphicsItem::wheelEvent(ev);
+}
+
+void QGraphicsWKView::touchEvent(QTouchEvent* ev)
+{
+ page()->d->touchEvent(ev);
+}
+
+void QGraphicsWKView::focusInEvent(QFocusEvent*)
+{
+ page()->d->page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+}
+
+void QGraphicsWKView::focusOutEvent(QFocusEvent*)
+{
+ page()->d->page->viewStateDidChange(WebPageProxy::ViewIsFocused | WebPageProxy::ViewWindowIsActive);
+}
+
+void QGraphicsWKView::showContextMenu(QMenu* menu)
+{
+ // Remove the active menu in case this function is called twice.
+ if (d->activeMenu)
+ d->activeMenu->hide();
+
+ d->activeMenu = menu;
+
+ QWidget* view = 0;
+ if (QGraphicsScene* myScene = scene()) {
+ const QList<QGraphicsView*> views = myScene->views();
+ for (unsigned i = 0; i < views.size(); ++i) {
+ if (views.at(i) == QApplication::focusWidget()) {
+ view = views.at(i);
+ break;
+ }
+ }
+ if (!view)
+ view = views.value(0, 0);
+ }
+ if (view)
+ menu->setParent(view, menu->windowFlags());
+ menu->exec(view->mapToGlobal(menu->pos()));
+ if (d->activeMenu == menu)
+ d->activeMenu = 0;
+}
+
+void QGraphicsWKView::takeSnapshot(const QSize& size, const QRect& contentsRect)
+{
+#if ENABLE(TILED_BACKING_STORE)
+ DrawingAreaProxy* drawingArea = page()->d->page->drawingArea();
+ if (drawingArea->info().type != DrawingAreaInfo::Tiled)
+ return;
+ TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea);
+ tiledDrawingArea->takeSnapshot(size, contentsRect);
+#endif
+}
+
+QGraphicsWKViewPrivate::QGraphicsWKViewPrivate(QGraphicsWKView* view)
+ : q(view)
+ , activeMenu(0)
+ , m_scaleCommitTimer(RunLoop::current(), this, &QGraphicsWKViewPrivate::commitScale)
+ , m_isChangingScale(false)
+{
+}
+
+QRectF QGraphicsWKView::visibleRect() const
+{
+ if (!scene())
+ return QRectF();
+
+ QList<QGraphicsView*> views = scene()->views();
+ if (views.isEmpty())
+ return QRectF();
+
+ QGraphicsView* graphicsView = views.at(0);
+ int xOffset = graphicsView->horizontalScrollBar()->value();
+ int yOffset = graphicsView->verticalScrollBar()->value();
+ return mapRectFromScene(QRectF(QPointF(xOffset, yOffset), graphicsView->viewport()->size()));
+}
+
+void QGraphicsWKView::prepareScaleChange()
+{
+#if ENABLE(TILED_BACKING_STORE)
+ ASSERT(!d->m_isChangingScale);
+ d->m_isChangingScale = true;
+ d->m_scaleCommitTimer.stop();
+#endif
+}
+
+void QGraphicsWKView::commitScaleChange()
+{
+#if ENABLE(TILED_BACKING_STORE)
+ ASSERT(d->m_isChangingScale);
+ d->m_isChangingScale = false;
+ d->commitScale();
+#endif
+}
+
+void QGraphicsWKViewPrivate::onScaleChanged()
+{
+#if ENABLE(TILED_BACKING_STORE)
+ if (!m_isChangingScale)
+ m_scaleCommitTimer.startOneShot(0.1);
+#endif
+}
+
+void QGraphicsWKViewPrivate::commitScale()
+{
+#if ENABLE(TILED_BACKING_STORE)
+ DrawingAreaProxy* drawingArea = page->d->page->drawingArea();
+ float newScale = q->scale();
+ if (drawingArea->info().type == DrawingAreaInfo::Tiled) {
+ TiledDrawingAreaProxy* tiledDrawingArea = static_cast<TiledDrawingAreaProxy*>(drawingArea);
+ if (tiledDrawingArea->contentsScale() == newScale)
+ return;
+ tiledDrawingArea->setContentsScale(newScale);
+ // For now we block until complete.
+ tiledDrawingArea->waitUntilUpdatesComplete();
+ }
+#endif
+}
+
+#include "moc_qgraphicswkview.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h
new file mode 100644
index 0000000..caf8e0d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qgraphicswkview.h
@@ -0,0 +1,102 @@
+#ifndef qgraphicswkview_h
+#define qgraphicswkview_h
+
+#include "qwebkitglobal.h"
+
+#include <WebKit2/WKBase.h>
+#include <QGraphicsWidget>
+#include "qwkpage.h"
+
+QT_BEGIN_NAMESPACE
+class QCursor;
+QT_END_NAMESPACE
+
+class QWKContext;
+class QGraphicsWKViewPrivate;
+
+WKStringRef WKStringCreateWithQString(const QString& qString);
+QString WKStringCopyQString(WKStringRef stringRef);
+
+class QWEBKIT_EXPORT QGraphicsWKView : public QGraphicsWidget {
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+
+public:
+ enum BackingStoreType { Simple, Tiled };
+ QGraphicsWKView(QWKContext* context, BackingStoreType backingStoreType = Simple, QGraphicsItem* parent = 0);
+
+ virtual ~QGraphicsWKView();
+
+ QWKPage* page() const;
+
+ virtual void setGeometry(const QRectF&);
+
+ void load(const QUrl&);
+ void setUrl(const QUrl&);
+ QUrl url() const;
+
+ QString title() const;
+
+ void triggerPageAction(QWKPage::WebAction action, bool checked = false);
+
+ virtual void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
+ virtual QVariant itemChange(GraphicsItemChange, const QVariant&);
+ virtual bool event(QEvent*);
+ virtual QSizeF sizeHint(Qt::SizeHint, const QSizeF&) const;
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
+ void takeSnapshot(const QSize& size, const QRect& documentRect);
+
+ // FIXME: should not be public
+ virtual QRectF visibleRect() const;
+
+ void prepareScaleChange();
+ void commitScaleChange();
+
+public:
+ Q_SIGNAL void titleChanged(const QString& title);
+ Q_SIGNAL void loadStarted();
+ Q_SIGNAL void loadFinished(bool ok);
+ Q_SIGNAL void loadProgress(int progress);
+ Q_SIGNAL void initialLayoutCompleted();
+ Q_SIGNAL void urlChanged(const QUrl&);
+ Q_SIGNAL void snapshotTaken(const QImage&);
+
+public Q_SLOTS:
+ void back();
+ void forward();
+ void reload();
+ void stop();
+
+protected:
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void keyReleaseEvent(QKeyEvent*);
+ virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
+ virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
+ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
+ virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
+ virtual void wheelEvent(QGraphicsSceneWheelEvent*);
+ virtual void touchEvent(QTouchEvent*);
+
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent*);
+
+ Q_SLOT void updateCursor(const QCursor&);
+ Q_SLOT void focusNextPrevChildCallback(bool next);
+
+ virtual bool focusNextPrevChild(bool next);
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void focusOutEvent(QFocusEvent*);
+
+private Q_SLOTS:
+ void showContextMenu(QMenu*);
+
+private:
+ Q_PRIVATE_SLOT(d, void onScaleChanged());
+
+ QGraphicsWKViewPrivate* d;
+ friend class QGraphicsWKViewPrivate;
+ friend class TiledDrawingAreaProxy;
+};
+
+#endif /* qgraphicswkview_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp b/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp
new file mode 100644
index 0000000..b17c100
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "qwkcontext.h"
+#include "qwkcontext_p.h"
+
+#include "WebPlatformStrategies.h"
+
+using namespace WebKit;
+
+static inline void initializePlatformStrategiesIfNeeded()
+{
+ static bool initialized = false;
+ if (initialized)
+ return;
+
+ WebPlatformStrategies::initialize();
+ initialized = true;
+}
+
+QWKContextPrivate::QWKContextPrivate(QWKContext* qq)
+ : q(qq)
+{
+ initializePlatformStrategiesIfNeeded();
+}
+
+QWKContextPrivate::~QWKContextPrivate()
+{
+}
+
+QWKContext::QWKContext(QObject* parent)
+ : QObject(parent)
+ , d(new QWKContextPrivate(this))
+{
+ d->context = WebContext::create(String());
+}
+
+QWKContext::QWKContext(WKContextRef contextRef, QObject* parent)
+ : QObject(parent)
+ , d(new QWKContextPrivate(this))
+{
+ d->context = toImpl(contextRef);
+}
+
+QWKContext::~QWKContext()
+{
+ delete d;
+}
+
+#include "moc_qwkcontext.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext.h b/Source/WebKit2/UIProcess/API/qt/qwkcontext.h
new file mode 100644
index 0000000..384d629
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext.h
@@ -0,0 +1,44 @@
+/*
+ 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 qwkcontext_h
+#define qwkcontext_h
+
+#include "qwebkitglobal.h"
+#include <QObject>
+#include <WebKit2/WKContext.h>
+
+class QWKContextPrivate;
+
+class QWEBKIT_EXPORT QWKContext : public QObject {
+ Q_OBJECT
+public:
+ QWKContext(QObject* parent = 0);
+ virtual ~QWKContext();
+
+ // Bridge from the C API
+ QWKContext(WKContextRef contextRef, QObject* parent = 0);
+
+private:
+ QWKContextPrivate* d;
+
+ friend class QWKPagePrivate;
+};
+
+#endif /* qwkcontext_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h b/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h
new file mode 100644
index 0000000..625e87c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkcontext_p.h
@@ -0,0 +1,37 @@
+/*
+ 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 qwkcontext_p_h
+#define qwkcontext_p_h
+
+#include "WebContext.h"
+#include <wtf/RefPtr.h>
+
+class QWKContextPrivate {
+public:
+ QWKContextPrivate(QWKContext*);
+ ~QWKContextPrivate();
+
+ QWKContext* q;
+
+ RefPtr<WebKit::WebContext> context;
+};
+
+#endif /* qkcontext_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp b/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp
new file mode 100644
index 0000000..3f424b5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 "qwkhistory.h"
+
+#include <QSharedData>
+#include <QString>
+#include <QUrl>
+#include "qwkhistory_p.h"
+#include "WebBackForwardList.h"
+#include <WebKit2/WKArray.h>
+#include <WebKit2/WKRetainPtr.h>
+#include "WKBackForwardList.h"
+#include "WKStringQt.h"
+#include "WKURL.h"
+#include "WKURLQt.h"
+
+using namespace WebKit;
+
+QWKHistoryItemPrivate::QWKHistoryItemPrivate(WKBackForwardListItemRef listItem)
+ : m_backForwardListItem(listItem)
+{
+}
+
+QWKHistoryItemPrivate::~QWKHistoryItemPrivate()
+{
+}
+
+QWKHistoryItem::QWKHistoryItem(const QWKHistoryItem& other)
+ : d(other.d)
+{
+}
+
+QWKHistoryItem& QWKHistoryItem::QWKHistoryItem::operator=(const QWKHistoryItem& other)
+{
+ d = other.d;
+ return *this;
+}
+
+QWKHistoryItem::QWKHistoryItem(WKBackForwardListItemRef item)
+ : d(new QWKHistoryItemPrivate(item))
+{
+}
+
+QWKHistoryItem::~QWKHistoryItem()
+{
+}
+
+QString QWKHistoryItem::title() const
+{
+ if (!d->m_backForwardListItem)
+ return QString();
+ WKRetainPtr<WKStringRef> title = WKBackForwardListItemCopyTitle(d->m_backForwardListItem.get());
+ return WKStringCopyQString(title.get());
+}
+
+QUrl QWKHistoryItem::url() const
+{
+ if (!d->m_backForwardListItem)
+ return QUrl();
+ WKRetainPtr<WKURLRef> url = WKBackForwardListItemCopyURL(d->m_backForwardListItem.get());
+ return WKURLCopyQUrl(url.get());
+}
+
+QWKHistoryPrivate::QWKHistoryPrivate(WebKit::WebBackForwardList* list)
+ : m_backForwardList(list)
+{
+}
+
+QWKHistory* QWKHistoryPrivate::createHistory(WebKit::WebBackForwardList* list)
+{
+ QWKHistory* history = new QWKHistory();
+ history->d = new QWKHistoryPrivate(list);
+ return history;
+}
+
+QWKHistoryPrivate::~QWKHistoryPrivate()
+{
+}
+
+QWKHistory::QWKHistory()
+{
+}
+
+QWKHistory::~QWKHistory()
+{
+ delete d;
+}
+
+int QWKHistory::backListCount() const
+{
+ return WKBackForwardListGetBackListCount(toAPI(d->m_backForwardList));
+}
+
+int QWKHistory::forwardListCount() const
+{
+ return WKBackForwardListGetForwardListCount(toAPI(d->m_backForwardList));
+}
+
+int QWKHistory::count() const
+{
+ return backListCount() + forwardListCount();
+}
+
+QWKHistoryItem QWKHistory::currentItem() const
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetCurrentItem(toAPI(d->m_backForwardList));
+ QWKHistoryItem item(itemRef.get());
+ return item;
+}
+
+QWKHistoryItem QWKHistory::backItem() const
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetBackItem(toAPI(d->m_backForwardList));
+ QWKHistoryItem item(itemRef.get());
+ return item;
+}
+
+QWKHistoryItem QWKHistory::forwardItem() const
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetForwardItem(toAPI(d->m_backForwardList));
+ QWKHistoryItem item(itemRef.get());
+ return item;
+}
+
+QWKHistoryItem QWKHistory::itemAt(int index) const
+{
+ WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(toAPI(d->m_backForwardList), index);
+ QWKHistoryItem item(itemRef.get());
+ return item;
+}
+
+QList<QWKHistoryItem> QWKHistory::backItems(int maxItems) const
+{
+ WKArrayRef arrayRef = WKBackForwardListCopyBackListWithLimit(toAPI(d->m_backForwardList), maxItems);
+ int size = WKArrayGetSize(arrayRef);
+ QList<QWKHistoryItem> itemList;
+ for (int i = 0; i < size; ++i) {
+ WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i);
+ WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem);
+ QWKHistoryItem item(itemRef);
+ itemList.append(item);
+ }
+ return itemList;
+}
+
+QList<QWKHistoryItem> QWKHistory::forwardItems(int maxItems) const
+{
+ WKArrayRef arrayRef = WKBackForwardListCopyForwardListWithLimit(toAPI(d->m_backForwardList), maxItems);
+ int size = WKArrayGetSize(arrayRef);
+ QList<QWKHistoryItem> itemList;
+ for (int i = 0; i < size; ++i) {
+ WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i);
+ WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem);
+ QWKHistoryItem item(itemRef);
+ itemList.append(item);
+ }
+ return itemList;
+}
+
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory.h b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h
new file mode 100644
index 0000000..81081c9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 qwkhistory_h
+#define qwkhistory_h
+
+#include "qwebkitglobal.h"
+#include <QObject>
+#include <QSharedData>
+#include "WKBackForwardListItem.h"
+
+class QWKHistoryPrivate;
+class QWKHistoryItemPrivate;
+class QUrl;
+class QString;
+
+namespace WebKit {
+class WebBackForwardList;
+}
+
+class QWEBKIT_EXPORT QWKHistoryItem {
+public:
+ QWKHistoryItem(const QWKHistoryItem& other);
+ QWKHistoryItem &operator=(const QWKHistoryItem& other);
+
+ ~QWKHistoryItem();
+ QString title() const;
+ QUrl url() const;
+
+private:
+ QWKHistoryItem(WKBackForwardListItemRef item);
+
+ QExplicitlySharedDataPointer<QWKHistoryItemPrivate> d;
+
+ friend class QWKHistory;
+ friend class QWKHistoryItemPrivate;
+};
+
+class QWEBKIT_EXPORT QWKHistory : public QObject {
+ Q_OBJECT
+public:
+ int backListCount() const;
+ int forwardListCount() const;
+ int count() const;
+ QWKHistoryItem currentItem() const;
+ QWKHistoryItem backItem() const;
+ QWKHistoryItem forwardItem() const;
+ QWKHistoryItem itemAt(int index) const;
+ QList<QWKHistoryItem> backItems(int maxItems) const;
+ QList<QWKHistoryItem> forwardItems(int maxItems) const;
+
+private:
+ QWKHistory();
+ ~QWKHistory();
+
+ QWKHistoryPrivate* d;
+ friend class QWKHistoryPrivate;
+ friend class QWKPagePrivate;
+};
+#endif /* qwkhistory_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h b/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h
new file mode 100644
index 0000000..dd1d696
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkhistory_p.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Juha Savolainen (juha.savolainen@weego.fi)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 qwkhistory_p_h
+#define qwkhistory_p_h
+
+#include <QSharedData>
+#include "qwebkitglobal.h"
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+class WebBackForwardList;
+}
+
+class QWKHistory;
+
+class QWEBKIT_EXPORT QWKHistoryItemPrivate : public QSharedData {
+public:
+ ~QWKHistoryItemPrivate();
+private:
+ QWKHistoryItemPrivate(WKBackForwardListItemRef listItem);
+ WKRetainPtr<WKBackForwardListItemRef> m_backForwardListItem;
+
+ friend class QWKHistory;
+ friend class QWKHistoryItem;
+};
+
+class QWEBKIT_EXPORT QWKHistoryPrivate {
+public:
+ static QWKHistory* createHistory(WebKit::WebBackForwardList* list);
+
+private:
+ QWKHistoryPrivate(WebKit::WebBackForwardList* list);
+ ~QWKHistoryPrivate();
+
+ WebKit::WebBackForwardList* m_backForwardList;
+
+ friend class QWKHistory;
+};
+
+#endif /* qwkhistory_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
new file mode 100644
index 0000000..638d9e3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.cpp
@@ -0,0 +1,759 @@
+/*
+ * 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 "qwkpage.h"
+#include "qwkpage_p.h"
+
+#include "qwkpreferences_p.h"
+
+#include "ChunkedUpdateDrawingAreaProxy.h"
+#include "ClientImpl.h"
+#include "qgraphicswkview.h"
+#include "qwkcontext.h"
+#include "qwkcontext_p.h"
+#include "qwkhistory.h"
+#include "qwkhistory_p.h"
+#include "FindIndicator.h"
+#include "LocalizedStrings.h"
+#include "NativeWebKeyboardEvent.h"
+#include "TiledDrawingAreaProxy.h"
+#include "WebContext.h"
+#include "WebContextMenuProxyQt.h"
+#include "WebEventFactoryQt.h"
+#include "WebPopupMenuProxyQt.h"
+#include "WKStringQt.h"
+#include "WKURLQt.h"
+#include "ViewportArguments.h"
+#include <QAction>
+#include <QApplication>
+#include <QGraphicsSceneMouseEvent>
+#include <QStyle>
+#include <QTouchEvent>
+#include <QtDebug>
+#include <WebCore/Cursor.h>
+#include <WebCore/FloatRect.h>
+#include <WebKit2/WKFrame.h>
+#include <WebKit2/WKPageGroup.h>
+#include <WebKit2/WKRetainPtr.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+static WebCore::ContextMenuAction contextMenuActionForWebAction(QWKPage::WebAction action)
+{
+ switch (action) {
+ case QWKPage::OpenLink:
+ return WebCore::ContextMenuItemTagOpenLink;
+ case QWKPage::OpenLinkInNewWindow:
+ return WebCore::ContextMenuItemTagOpenLinkInNewWindow;
+ case QWKPage::CopyLinkToClipboard:
+ return WebCore::ContextMenuItemTagCopyLinkToClipboard;
+ case QWKPage::OpenImageInNewWindow:
+ return WebCore::ContextMenuItemTagOpenImageInNewWindow;
+ case QWKPage::Cut:
+ return WebCore::ContextMenuItemTagCut;
+ case QWKPage::Copy:
+ return WebCore::ContextMenuItemTagCopy;
+ case QWKPage::Paste:
+ return WebCore::ContextMenuItemTagPaste;
+ case QWKPage::SelectAll:
+ return WebCore::ContextMenuItemTagSelectAll;
+ default:
+ ASSERT(false);
+ break;
+ }
+ return WebCore::ContextMenuItemTagNoAction;
+}
+
+QWKPagePrivate::QWKPagePrivate(QWKPage* qq, QWKContext* c)
+ : q(qq)
+ , view(0)
+ , context(c)
+ , preferences(0)
+ , createNewPageFn(0)
+{
+ memset(actions, 0, sizeof(actions));
+ page = context->d->context->createWebPage(this, 0);
+ history = QWKHistoryPrivate::createHistory(page->backForwardList());
+}
+
+QWKPagePrivate::~QWKPagePrivate()
+{
+ page->close();
+ delete history;
+}
+
+void QWKPagePrivate::init(QGraphicsItem* view, PassOwnPtr<DrawingAreaProxy> proxy)
+{
+ this->view = view;
+ page->setDrawingArea(proxy);
+ page->initializeWebPage();
+}
+
+void QWKPagePrivate::setCursor(const WebCore::Cursor& cursor)
+{
+#ifndef QT_NO_CURSOR
+ emit q->cursorChanged(*cursor.platformCursor());
+#endif
+}
+
+void QWKPagePrivate::setViewportArguments(const ViewportArguments& args)
+{
+ viewportArguments = args;
+ emit q->viewportChangeRequested();
+}
+
+void QWKPagePrivate::takeFocus(bool direction)
+{
+ emit q->focusNextPrevChild(direction);
+}
+
+PassOwnPtr<DrawingAreaProxy> QWKPagePrivate::createDrawingAreaProxy()
+{
+ // FIXME: We should avoid this cast by decoupling the view from the page.
+ QGraphicsWKView* wkView = static_cast<QGraphicsWKView*>(view);
+
+#if ENABLE(TILED_BACKING_STORE)
+ if (page->drawingArea()->info().type == DrawingAreaInfo::Tiled)
+ return TiledDrawingAreaProxy::create(wkView, page.get());
+#endif
+ return ChunkedUpdateDrawingAreaProxy::create(wkView, page.get());
+}
+
+void QWKPagePrivate::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ view->update(QRect(rect));
+}
+
+void QWKPagePrivate::displayView()
+{
+ // FIXME: Implement.
+}
+
+WebCore::IntSize QWKPagePrivate::viewSize()
+{
+ // FIXME: Implement.
+ return WebCore::IntSize();
+}
+
+bool QWKPagePrivate::isViewWindowActive()
+{
+ // FIXME: Implement.
+ return true;
+}
+
+bool QWKPagePrivate::isViewFocused()
+{
+ // FIXME: Implement.
+ return true;
+}
+
+bool QWKPagePrivate::isViewVisible()
+{
+ // FIXME: Implement.
+ return true;
+}
+
+bool QWKPagePrivate::isViewInWindow()
+{
+ // FIXME: Implement.
+ return true;
+}
+
+void QWKPagePrivate::pageDidRequestScroll(const IntSize& delta)
+{
+ emit q->scrollRequested(delta.width(), delta.height());
+}
+
+void QWKPagePrivate::didChangeContentsSize(const IntSize& newSize)
+{
+ emit q->contentsSizeChanged(QSize(newSize));
+}
+
+void QWKPagePrivate::toolTipChanged(const String&, const String& newTooltip)
+{
+ emit q->statusBarMessage(QString(newTooltip));
+}
+
+void QWKPagePrivate::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+{
+}
+
+void QWKPagePrivate::clearAllEditCommands()
+{
+}
+
+FloatRect QWKPagePrivate::convertToDeviceSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+FloatRect QWKPagePrivate::convertToUserSpace(const FloatRect& rect)
+{
+ return rect;
+}
+
+void QWKPagePrivate::selectionChanged(bool, bool, bool, bool)
+{
+}
+
+void QWKPagePrivate::didNotHandleKeyEvent(const NativeWebKeyboardEvent&)
+{
+}
+
+PassRefPtr<WebPopupMenuProxy> QWKPagePrivate::createPopupMenuProxy(WebPageProxy*)
+{
+ return WebPopupMenuProxyQt::create();
+}
+
+PassRefPtr<WebContextMenuProxy> QWKPagePrivate::createContextMenuProxy(WebPageProxy*)
+{
+ return WebContextMenuProxyQt::create(q);
+}
+
+void QWKPagePrivate::setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut)
+{
+}
+
+void QWKPagePrivate::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+}
+
+void QWKPagePrivate::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&)
+{
+}
+
+void QWKPagePrivate::paint(QPainter* painter, QRect area)
+{
+ if (page->isValid() && page->drawingArea())
+ page->drawingArea()->paint(IntRect(area), painter);
+ else
+ painter->fillRect(area, Qt::white);
+}
+
+void QWKPagePrivate::keyPressEvent(QKeyEvent* ev)
+{
+ page->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
+}
+
+void QWKPagePrivate::keyReleaseEvent(QKeyEvent* ev)
+{
+ page->handleKeyboardEvent(NativeWebKeyboardEvent(ev));
+}
+
+void QWKPagePrivate::mouseMoveEvent(QGraphicsSceneMouseEvent* 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;
+ lastPos = ev->pos();
+
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0);
+ page->handleMouseEvent(mouseEvent);
+}
+
+void QWKPagePrivate::mousePressEvent(QGraphicsSceneMouseEvent* ev)
+{
+ if (tripleClickTimer.isActive() && (ev->pos() - tripleClick).manhattanLength() < QApplication::startDragDistance()) {
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 3);
+ page->handleMouseEvent(mouseEvent);
+ return;
+ }
+
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 1);
+ page->handleMouseEvent(mouseEvent);
+}
+
+void QWKPagePrivate::mouseReleaseEvent(QGraphicsSceneMouseEvent* ev)
+{
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 0);
+ page->handleMouseEvent(mouseEvent);
+}
+
+void QWKPagePrivate::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev)
+{
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(ev, 2);
+ page->handleMouseEvent(mouseEvent);
+
+ tripleClickTimer.start(QApplication::doubleClickInterval(), q);
+ tripleClick = ev->pos().toPoint();
+}
+
+void QWKPagePrivate::wheelEvent(QGraphicsSceneWheelEvent* ev)
+{
+ WebWheelEvent wheelEvent = WebEventFactory::createWebWheelEvent(ev);
+ page->handleWheelEvent(wheelEvent);
+}
+
+void QWKPagePrivate::setEditCommandState(const WTF::String&, bool, int)
+{
+}
+
+void QWKPagePrivate::updateAction(QWKPage::WebAction action)
+{
+#ifdef QT_NO_ACTION
+ Q_UNUSED(action)
+#else
+ QAction* a = actions[action];
+ if (!a)
+ return;
+
+ RefPtr<WebKit::WebFrameProxy> mainFrame = page->mainFrame();
+ if (!mainFrame)
+ return;
+
+ bool enabled = a->isEnabled();
+ bool checked = a->isChecked();
+
+ switch (action) {
+ case QWKPage::Back:
+ enabled = page->canGoBack();
+ break;
+ case QWKPage::Forward:
+ enabled = page->canGoForward();
+ break;
+ case QWKPage::Stop:
+ enabled = !(WebFrameProxy::LoadStateFinished == mainFrame->loadState());
+ break;
+ case QWKPage::Reload:
+ enabled = (WebFrameProxy::LoadStateFinished == mainFrame->loadState());
+ break;
+ default:
+ break;
+ }
+
+ a->setEnabled(enabled);
+
+ if (a->isCheckable())
+ a->setChecked(checked);
+#endif // QT_NO_ACTION
+}
+
+void QWKPagePrivate::updateNavigationActions()
+{
+ updateAction(QWKPage::Back);
+ updateAction(QWKPage::Forward);
+ updateAction(QWKPage::Stop);
+ updateAction(QWKPage::Reload);
+}
+
+#ifndef QT_NO_ACTION
+void QWKPagePrivate::_q_webActionTriggered(bool checked)
+{
+ QAction* a = qobject_cast<QAction*>(q->sender());
+ if (!a)
+ return;
+ QWKPage::WebAction action = static_cast<QWKPage::WebAction>(a->data().toInt());
+ q->triggerAction(action, checked);
+}
+#endif // QT_NO_ACTION
+
+void QWKPagePrivate::touchEvent(QTouchEvent* event)
+{
+#if ENABLE(TOUCH_EVENTS)
+ WebTouchEvent touchEvent = WebEventFactory::createWebTouchEvent(event);
+ page->handleTouchEvent(touchEvent);
+#else
+ event->ignore();
+#endif
+}
+
+QWKPage::QWKPage(QWKContext* context)
+ : d(new QWKPagePrivate(this, context))
+{
+ WKPageLoaderClient loadClient = {
+ 0, /* version */
+ this, /* clientInfo */
+ qt_wk_didStartProvisionalLoadForFrame,
+ qt_wk_didReceiveServerRedirectForProvisionalLoadForFrame,
+ qt_wk_didFailProvisionalLoadWithErrorForFrame,
+ qt_wk_didCommitLoadForFrame,
+ qt_wk_didFinishDocumentLoadForFrame,
+ qt_wk_didFinishLoadForFrame,
+ qt_wk_didFailLoadWithErrorForFrame,
+ 0, /* didSameDocumentNavigationForFrame */
+ qt_wk_didReceiveTitleForFrame,
+ qt_wk_didFirstLayoutForFrame,
+ qt_wk_didFirstVisuallyNonEmptyLayoutForFrame,
+ qt_wk_didRemoveFrameFromHierarchy,
+ 0, /* didDisplayInsecureContentForFrame */
+ 0, /* didRunInsecureContentForFrame */
+ 0, /* canAuthenticateAgainstProtectionSpaceInFrame */
+ 0, /* didReceiveAuthenticationChallengeInFrame */
+ qt_wk_didStartProgress,
+ qt_wk_didChangeProgress,
+ qt_wk_didFinishProgress,
+ qt_wk_didBecomeUnresponsive,
+ qt_wk_didBecomeResponsive,
+ 0, /* processDidCrash */
+ 0 /* didChangeBackForwardList */
+ };
+ WKPageSetPageLoaderClient(pageRef(), &loadClient);
+
+ WKPageUIClient uiClient = {
+ 0, /* version */
+ this, /* clientInfo */
+ qt_wk_createNewPage,
+ qt_wk_showPage,
+ qt_wk_close,
+ qt_wk_runJavaScriptAlert,
+ 0, /* runJavaScriptConfirm */
+ 0, /* runJavaScriptPrompt */
+ 0, /* setStatusText */
+ 0, /* mouseDidMoveOverElement */
+ 0, /* missingPluginButtonClicked */
+ 0, /* didNotHandleKeyEvent */
+ 0, /* toolbarsAreVisible */
+ 0, /* setToolbarsAreVisible */
+ 0, /* menuBarIsVisible */
+ 0, /* setMenuBarIsVisible */
+ 0, /* statusBarIsVisible */
+ 0, /* setStatusBarIsVisible */
+ 0, /* isResizable */
+ 0, /* setIsResizable */
+ 0, /* getWindowFrame */
+ 0, /* setWindowFrame */
+ 0, /* runBeforeUnloadConfirmPanel */
+ 0, /* didDraw */
+ 0, /* pageDidScroll */
+ 0, /* exceededDatabaseQuota */
+ 0, /* runOpenPanel */
+ 0 /* decidePolicyForGeolocationPermissionRequest */
+ };
+ WKPageSetPageUIClient(pageRef(), &uiClient);
+}
+
+QWKPage::~QWKPage()
+{
+ delete d;
+}
+
+QWKPage::ViewportAttributes::ViewportAttributes()
+ : d(0)
+ , m_initialScaleFactor(-1.0)
+ , m_minimumScaleFactor(-1.0)
+ , m_maximumScaleFactor(-1.0)
+ , m_devicePixelRatio(-1.0)
+ , m_isUserScalable(true)
+ , m_isValid(false)
+{
+
+}
+
+QWKPage::ViewportAttributes::ViewportAttributes(const QWKPage::ViewportAttributes& other)
+ : d(other.d)
+ , m_initialScaleFactor(other.m_initialScaleFactor)
+ , m_minimumScaleFactor(other.m_minimumScaleFactor)
+ , m_maximumScaleFactor(other.m_maximumScaleFactor)
+ , m_devicePixelRatio(other.m_devicePixelRatio)
+ , m_isUserScalable(other.m_isUserScalable)
+ , m_isValid(other.m_isValid)
+ , m_size(other.m_size)
+{
+
+}
+
+QWKPage::ViewportAttributes::~ViewportAttributes()
+{
+
+}
+
+QWKPage::ViewportAttributes& QWKPage::ViewportAttributes::operator=(const QWKPage::ViewportAttributes& other)
+{
+ if (this != &other) {
+ d = other.d;
+ m_initialScaleFactor = other.m_initialScaleFactor;
+ m_minimumScaleFactor = other.m_minimumScaleFactor;
+ m_maximumScaleFactor = other.m_maximumScaleFactor;
+ m_devicePixelRatio = other.m_devicePixelRatio;
+ m_isUserScalable = other.m_isUserScalable;
+ m_isValid = other.m_isValid;
+ m_size = other.m_size;
+ }
+
+ return *this;
+}
+
+QWKPage::ViewportAttributes QWKPage::viewportAttributesForSize(const QSize& availableSize) const
+{
+ static int desktopWidth = 980;
+ static int deviceDPI = 160;
+
+ ViewportAttributes result;
+
+ if (availableSize.isEmpty())
+ return result; // Returns an invalid instance.
+
+ // FIXME: Add a way to get these data via the platform plugin and fall back
+ // to the size of the view.
+ int deviceWidth = 480;
+ int deviceHeight = 864;
+
+ WebCore::ViewportAttributes conf = WebCore::computeViewportAttributes(d->viewportArguments, desktopWidth, deviceWidth, deviceHeight, deviceDPI, availableSize);
+
+ result.m_isValid = true;
+ result.m_size = conf.layoutSize;
+ result.m_initialScaleFactor = conf.initialScale;
+ result.m_minimumScaleFactor = conf.minimumScale;
+ result.m_maximumScaleFactor = conf.maximumScale;
+ result.m_devicePixelRatio = conf.devicePixelRatio;
+ result.m_isUserScalable = conf.userScalable;
+
+ return result;
+}
+
+void QWKPage::setActualVisibleContentsRect(const QRect& rect) const
+{
+#if ENABLE(TILED_BACKING_STORE)
+ d->page->setActualVisibleContentRect(rect);
+#endif
+}
+
+void QWKPage::timerEvent(QTimerEvent* ev)
+{
+ int timerId = ev->timerId();
+ if (timerId == d->tripleClickTimer.timerId())
+ d->tripleClickTimer.stop();
+ else
+ QObject::timerEvent(ev);
+}
+
+WKPageRef QWKPage::pageRef() const
+{
+ return toAPI(d->page.get());
+}
+
+QWKContext* QWKPage::context() const
+{
+ return d->context;
+}
+
+QWKPreferences* QWKPage::preferences() const
+{
+ if (!d->preferences) {
+ WKPageGroupRef pageGroupRef = WKPageGetPageGroup(pageRef());
+ d->preferences = QWKPreferencesPrivate::createPreferences(pageGroupRef);
+ }
+
+ return d->preferences;
+}
+
+void QWKPage::setCreateNewPageFunction(CreateNewPageFn function)
+{
+ d->createNewPageFn = function;
+}
+
+void QWKPage::setCustomUserAgent(const QString& userAgent)
+{
+ WKRetainPtr<WKStringRef> wkUserAgent(WKStringCreateWithQString(userAgent));
+ WKPageSetCustomUserAgent(pageRef(), wkUserAgent.get());
+}
+
+QString QWKPage::customUserAgent() const
+{
+ return WKStringCopyQString(WKPageCopyCustomUserAgent(pageRef()));
+}
+
+void QWKPage::load(const QUrl& url)
+{
+ WKRetainPtr<WKURLRef> wkurl(WKURLCreateWithQUrl(url));
+ WKPageLoadURL(pageRef(), wkurl.get());
+}
+
+void QWKPage::setUrl(const QUrl& url)
+{
+ load(url);
+}
+
+QUrl QWKPage::url() const
+{
+ WKRetainPtr<WKFrameRef> frame = WKPageGetMainFrame(pageRef());
+ if (!frame)
+ return QUrl();
+ return WKURLCopyQUrl(WKFrameCopyURL(frame.get()));
+}
+
+QString QWKPage::title() const
+{
+ return WKStringCopyQString(WKPageCopyTitle(pageRef()));
+}
+
+void QWKPage::setViewportSize(const QSize& size)
+{
+ if (d->page->drawingArea())
+ d->page->drawingArea()->setSize(IntSize(size));
+}
+
+qreal QWKPage::textZoomFactor() const
+{
+ return WKPageGetTextZoomFactor(pageRef());
+}
+
+void QWKPage::setTextZoomFactor(qreal zoomFactor)
+{
+ WKPageSetTextZoomFactor(pageRef(), zoomFactor);
+}
+
+qreal QWKPage::pageZoomFactor() const
+{
+ return WKPageGetPageZoomFactor(pageRef());
+}
+
+void QWKPage::setPageZoomFactor(qreal zoomFactor)
+{
+ WKPageSetPageZoomFactor(pageRef(), zoomFactor);
+}
+
+void QWKPage::setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor)
+{
+ WKPageSetPageAndTextZoomFactors(pageRef(), pageZoomFactor, textZoomFactor);
+}
+
+QWKHistory* QWKPage::history() const
+{
+ return d->history;
+}
+
+void QWKPage::setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize)
+{
+#if ENABLE(TILED_BACKING_STORE)
+ d->page->setResizesToContentsUsingLayoutSize(targetLayoutSize);
+#endif
+}
+
+#ifndef QT_NO_ACTION
+void QWKPage::triggerAction(WebAction webAction, bool)
+{
+ switch (webAction) {
+ case Back:
+ d->page->goBack();
+ return;
+ case Forward:
+ d->page->goForward();
+ return;
+ case Stop:
+ d->page->stopLoading();
+ return;
+ case Reload:
+ d->page->reload(/* reloadFromOrigin */ true);
+ return;
+ default:
+ break;
+ }
+
+ QAction* qtAction = action(webAction);
+ WebKit::WebContextMenuItemData menuItemData(ActionType, contextMenuActionForWebAction(webAction), qtAction->text(), qtAction->isEnabled(), qtAction->isChecked());
+ d->page->contextMenuItemSelected(menuItemData);
+}
+#endif // QT_NO_ACTION
+
+#ifndef QT_NO_ACTION
+QAction* QWKPage::action(WebAction action) const
+{
+ if (action == QWKPage::NoWebAction || action >= WebActionCount)
+ return 0;
+
+ if (d->actions[action])
+ return d->actions[action];
+
+ QString text;
+ QIcon icon;
+ QStyle* style = qobject_cast<QApplication*>(QCoreApplication::instance())->style();
+ bool checkable = false;
+
+ switch (action) {
+ case OpenLink:
+ text = contextMenuItemTagOpenLink();
+ break;
+ case OpenLinkInNewWindow:
+ text = contextMenuItemTagOpenLinkInNewWindow();
+ break;
+ case CopyLinkToClipboard:
+ text = contextMenuItemTagCopyLinkToClipboard();
+ break;
+ case OpenImageInNewWindow:
+ text = contextMenuItemTagOpenImageInNewWindow();
+ break;
+ case Back:
+ text = contextMenuItemTagGoBack();
+ icon = style->standardIcon(QStyle::SP_ArrowBack);
+ break;
+ case Forward:
+ text = contextMenuItemTagGoForward();
+ icon = style->standardIcon(QStyle::SP_ArrowForward);
+ break;
+ case Stop:
+ text = contextMenuItemTagStop();
+ icon = style->standardIcon(QStyle::SP_BrowserStop);
+ break;
+ case Reload:
+ text = contextMenuItemTagReload();
+ icon = style->standardIcon(QStyle::SP_BrowserReload);
+ break;
+ case Cut:
+ text = contextMenuItemTagCut();
+ break;
+ case Copy:
+ text = contextMenuItemTagCopy();
+ break;
+ case Paste:
+ text = contextMenuItemTagPaste();
+ break;
+ case SelectAll:
+ text = contextMenuItemTagSelectAll();
+ break;
+ default:
+ return 0;
+ break;
+ }
+
+ if (text.isEmpty())
+ return 0;
+
+ QAction* a = new QAction(d->q);
+ a->setText(text);
+ a->setData(action);
+ a->setCheckable(checkable);
+ a->setIcon(icon);
+
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool)));
+
+ d->actions[action] = a;
+ d->updateAction(action);
+ return a;
+}
+#endif // QT_NO_ACTION
+
+void QWKPage::findZoomableAreaForPoint(const QPoint& point)
+{
+ d->page->findZoomableAreaForPoint(point);
+}
+
+void QWKPagePrivate::didFindZoomableArea(const IntRect& area)
+{
+ emit q->zoomableAreaFound(QRect(area));
+}
+
+#include "moc_qwkpage.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage.h b/Source/WebKit2/UIProcess/API/qt/qwkpage.h
new file mode 100644
index 0000000..e0bb4c3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage.h
@@ -0,0 +1,151 @@
+#ifndef qwkpage_h
+#define qwkpage_h
+
+#include "qwebkitglobal.h"
+#include <QAction>
+#include <QObject>
+#include <QPoint>
+#include <QRect>
+#include <QSize>
+#include <QUrl>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKPage.h>
+
+class QCursor;
+class QGraphicsItem;
+class QWKContext;
+class QWKGraphicsWidget;
+class QWKPreferences;
+class QWKPagePrivate;
+class QtViewportAttributesPrivate;
+class QWKHistory;
+
+class QWEBKIT_EXPORT QWKPage : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QUrl url READ url WRITE setUrl)
+
+public:
+ enum WebAction {
+ NoWebAction = - 1,
+
+ OpenLink,
+ OpenLinkInNewWindow,
+ CopyLinkToClipboard,
+ OpenImageInNewWindow,
+
+ Back,
+ Forward,
+ Stop,
+ Reload,
+
+ Cut,
+ Copy,
+ Paste,
+ SelectAll,
+
+ WebActionCount
+ };
+
+ class ViewportAttributes {
+ public:
+ ViewportAttributes();
+ ViewportAttributes(const QWKPage::ViewportAttributes& other);
+
+ ~ViewportAttributes();
+
+ QWKPage::ViewportAttributes& operator=(const QWKPage::ViewportAttributes& other);
+
+ inline qreal initialScaleFactor() const { return m_initialScaleFactor; };
+ inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; };
+ inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; };
+ inline qreal devicePixelRatio() const { return m_devicePixelRatio; };
+ inline bool isUserScalable() const { return m_isUserScalable; };
+ inline bool isValid() const { return m_isValid; };
+ inline QSize size() const { return m_size; };
+
+ private:
+ QSharedDataPointer<QtViewportAttributesPrivate> d;
+ qreal m_initialScaleFactor;
+ qreal m_minimumScaleFactor;
+ qreal m_maximumScaleFactor;
+ qreal m_devicePixelRatio;
+ bool m_isUserScalable;
+ bool m_isValid;
+ QSize m_size;
+
+ friend class QWKPage;
+ };
+
+ QWKPage(QWKContext*);
+ virtual ~QWKPage();
+
+ WKPageRef pageRef() const;
+
+ QWKPreferences* preferences() const;
+
+ void load(const QUrl& url);
+ void setUrl(const QUrl& url);
+ QUrl url() const;
+
+ QString title() const;
+
+ void setViewportSize(const QSize&);
+ ViewportAttributes viewportAttributesForSize(const QSize& availableSize) const;
+
+ void setActualVisibleContentsRect(const QRect& rect) const;
+
+ void setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize);
+
+ QAction* action(WebAction action) const;
+ void triggerAction(WebAction action, bool checked = false);
+
+ typedef QWKPage* (*CreateNewPageFn)(QWKPage*);
+ void setCreateNewPageFunction(CreateNewPageFn function);
+
+ void setCustomUserAgent(const QString&);
+ QString customUserAgent() const;
+
+ qreal textZoomFactor() const;
+ qreal pageZoomFactor() const;
+ void setTextZoomFactor(qreal zoomFactor);
+ void setPageZoomFactor(qreal zoomFactor);
+ void setPageAndTextZoomFactors(qreal pageZoomFactor, qreal textZoomFactor);
+
+ QWKHistory* history() const;
+ QWKContext* context() const;
+
+ void findZoomableAreaForPoint(const QPoint&);
+
+public:
+ Q_SIGNAL void statusBarMessage(const QString&);
+ Q_SIGNAL void titleChanged(const QString&);
+ Q_SIGNAL void loadStarted();
+ Q_SIGNAL void loadFinished(bool ok);
+ Q_SIGNAL void loadProgress(int progress);
+ Q_SIGNAL void initialLayoutCompleted();
+ Q_SIGNAL void urlChanged(const QUrl&);
+ Q_SIGNAL void contentsSizeChanged(const QSize&);
+ Q_SIGNAL void scrollRequested(int dx, int dy);
+ Q_SIGNAL void cursorChanged(const QCursor&);
+ Q_SIGNAL void viewportChangeRequested();
+ Q_SIGNAL void windowCloseRequested();
+ Q_SIGNAL void zoomableAreaFound(const QRect&);
+ Q_SIGNAL void focusNextPrevChild(bool);
+ Q_SIGNAL void showContextMenu(QMenu*);
+
+protected:
+ void timerEvent(QTimerEvent*);
+
+private:
+#ifndef QT_NO_ACTION
+ Q_PRIVATE_SLOT(d, void _q_webActionTriggered(bool checked));
+#endif
+ QWKPagePrivate* d;
+
+ friend class QGraphicsWKView;
+ friend class QGraphicsWKViewPrivate;
+ friend class QWKPagePrivate;
+};
+
+#endif /* qwkpage_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
new file mode 100644
index 0000000..85135c2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpage_p.h
@@ -0,0 +1,134 @@
+/*
+ * 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 qwkpage_p_h
+#define qwkpage_p_h
+
+#include "DrawingAreaProxy.h"
+#include "PageClient.h"
+#include "qwkpage.h"
+#include "WebPageProxy.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefPtr.h>
+#include <QBasicTimer>
+#include <QGraphicsView>
+#include <QKeyEvent>
+
+class QGraphicsWKView;
+class QWKPreferences;
+
+class QWKPagePrivate : WebKit::PageClient {
+public:
+ QWKPagePrivate(QWKPage*, QWKContext*);
+ ~QWKPagePrivate();
+
+ static QWKPagePrivate* get(QWKPage* page) { return page->d; }
+
+ void init(QGraphicsItem*, WTF::PassOwnPtr<WebKit::DrawingAreaProxy>);
+
+ // PageClient
+ virtual PassOwnPtr<WebKit::DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual void displayView();
+
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+
+#if USE(ACCELERATED_COMPOSITING)
+ void pageDidEnterAcceleratedCompositing() { }
+ void pageDidLeaveAcceleratedCompositing() { }
+#endif // USE(ACCELERATED_COMPOSITING)
+ virtual void pageDidRequestScroll(const WebCore::IntSize&);
+ virtual void processDidCrash() { }
+ virtual void didRelaunchProcess() { }
+ virtual void didChangeContentsSize(const WebCore::IntSize&);
+ virtual void didFindZoomableArea(const WebCore::IntRect&);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setViewportArguments(const WebCore::ViewportArguments&);
+ virtual void takeFocus(bool direction);
+ virtual void toolTipChanged(const WTF::String&, const WTF::String&);
+ virtual void registerEditCommand(PassRefPtr<WebKit::WebEditCommandProxy>, WebKit::WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual void didNotHandleKeyEvent(const WebKit::NativeWebKeyboardEvent&);
+ virtual void selectionChanged(bool, bool, bool, bool);
+ virtual PassRefPtr<WebKit::WebPopupMenuProxy> createPopupMenuProxy(WebKit::WebPageProxy*);
+ virtual PassRefPtr<WebKit::WebContextMenuProxy> createContextMenuProxy(WebKit::WebPageProxy*);
+
+ virtual void setFindIndicator(PassRefPtr<WebKit::FindIndicator>, bool fadeOut);
+
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&);
+ virtual double customRepresentationZoomFactor() { return 1; }
+ virtual void setCustomRepresentationZoomFactor(double) { }
+
+ void paint(QPainter* painter, QRect);
+
+ void keyPressEvent(QKeyEvent*);
+ void keyReleaseEvent(QKeyEvent*);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent*);
+ void mousePressEvent(QGraphicsSceneMouseEvent*);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
+ void wheelEvent(QGraphicsSceneWheelEvent*);
+
+ void updateAction(QWKPage::WebAction action);
+ void updateNavigationActions();
+ void updateEditorActions();
+ void setEditCommandState(const WTF::String&, bool, int);
+
+ void _q_webActionTriggered(bool checked);
+
+ void touchEvent(QTouchEvent*);
+
+ QWKPage* q;
+
+ QGraphicsItem* view;
+ QWKContext* context;
+ QWKHistory* history;
+
+ QAction* actions[QWKPage::WebActionCount];
+ QWKPreferences* preferences;
+
+ RefPtr<WebKit::WebPageProxy> page;
+
+ WebCore::ViewportArguments viewportArguments;
+
+ QWKPage::CreateNewPageFn createNewPageFn;
+
+ QPoint tripleClick;
+ QBasicTimer tripleClickTimer;
+};
+
+class QtViewportAttributesPrivate : public QSharedData {
+public:
+ QtViewportAttributesPrivate(QWKPage::ViewportAttributes* qq)
+ : q(qq)
+ { }
+
+ QWKPage::ViewportAttributes* q;
+};
+
+
+#endif /* qkpage_p_h */
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp
new file mode 100644
index 0000000..dea18aa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.cpp
@@ -0,0 +1,185 @@
+/*
+ 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.
+*/
+
+#include "qwkpreferences.h"
+
+#include "WKPageGroup.h"
+#include "WKPreferences.h"
+#include "WKStringQt.h"
+#include "WKRetainPtr.h"
+#include "qwkpreferences_p.h"
+
+
+QWKPreferences* QWKPreferencesPrivate::createPreferences(WKPageGroupRef pageGroupRef)
+{
+ QWKPreferences* prefs = new QWKPreferences;
+ prefs->d->ref = WKPageGroupGetPreferences(pageGroupRef);
+ return prefs;
+}
+
+QWKPreferences* QWKPreferencesPrivate::createSharedPreferences()
+{
+ QWKPreferences* prefs = new QWKPreferences;
+ prefs->d->ref = WKPreferencesCreate();
+ return prefs;
+}
+
+QWKPreferences* QWKPreferences::sharedPreferences()
+{
+ static QWKPreferences* instance = 0;
+
+ if (!instance)
+ instance = QWKPreferencesPrivate::createSharedPreferences();
+ return instance;
+}
+
+QWKPreferences::QWKPreferences()
+ : d(new QWKPreferencesPrivate)
+{
+}
+
+QWKPreferences::~QWKPreferences()
+{
+ delete d;
+}
+
+void QWKPreferences::setFontFamily(FontFamily which, const QString& family)
+{
+ switch (which) {
+ case StandardFont:
+ WKPreferencesSetStandardFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ case FixedFont:
+ WKPreferencesSetFixedFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ case SerifFont:
+ WKPreferencesSetSerifFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ case SansSerifFont:
+ WKPreferencesSetSansSerifFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ case CursiveFont:
+ WKPreferencesSetCursiveFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ case FantasyFont:
+ WKPreferencesSetFantasyFontFamily(d->ref, WKStringCreateWithQString(family));
+ break;
+ default:
+ break;
+ }
+}
+
+QString QWKPreferences::fontFamily(FontFamily which) const
+{
+ switch (which) {
+ case StandardFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyStandardFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case FixedFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFixedFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case SerifFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySerifFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case SansSerifFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopySansSerifFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case CursiveFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyCursiveFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ case FantasyFont: {
+ WKRetainPtr<WKStringRef> stringRef(AdoptWK, WKPreferencesCopyFantasyFontFamily(d->ref));
+ return WKStringCopyQString(stringRef.get());
+ }
+ default:
+ return QString();
+ }
+}
+
+bool QWKPreferences::testAttribute(WebAttribute attr) const
+{
+ switch (attr) {
+ case AutoLoadImages:
+ return WKPreferencesGetLoadsImagesAutomatically(d->ref);
+ case JavascriptEnabled:
+ return WKPreferencesGetJavaScriptEnabled(d->ref);
+ case PluginsEnabled:
+ return WKPreferencesGetPluginsEnabled(d->ref);
+ case OfflineWebApplicationCacheEnabled:
+ return WKPreferencesGetOfflineWebApplicationCacheEnabled(d->ref);
+ case LocalStorageEnabled:
+ return WKPreferencesGetLocalStorageEnabled(d->ref);
+ case XSSAuditingEnabled:
+ return WKPreferencesGetXSSAuditorEnabled(d->ref);
+ case FrameFlatteningEnabled:
+ return WKPreferencesGetFrameFlatteningEnabled(d->ref);
+ case PrivateBrowsingEnabled:
+ return WKPreferencesGetPrivateBrowsingEnabled(d->ref);
+ case DeveloperExtrasEnabled:
+ return WKPreferencesGetDeveloperExtrasEnabled(d->ref);
+ case DnsPrefetchEnabled:
+ return WKPreferencesGetDNSPrefetchingEnabled(d->ref);
+ default:
+ ASSERT_NOT_REACHED();
+ return false;
+ }
+}
+
+void QWKPreferences::setAttribute(WebAttribute attr, bool on)
+{
+ switch (attr) {
+ case AutoLoadImages:
+ WKPreferencesSetLoadsImagesAutomatically(d->ref, on);
+ break;
+ case JavascriptEnabled:
+ WKPreferencesSetJavaScriptEnabled(d->ref, on);
+ break;
+ case PluginsEnabled:
+ WKPreferencesSetPluginsEnabled(d->ref, on);
+ break;
+ case OfflineWebApplicationCacheEnabled:
+ WKPreferencesSetOfflineWebApplicationCacheEnabled(d->ref, on);
+ break;
+ case LocalStorageEnabled:
+ WKPreferencesSetLocalStorageEnabled(d->ref, on);
+ break;
+ case XSSAuditingEnabled:
+ WKPreferencesSetXSSAuditorEnabled(d->ref, on);
+ break;
+ case FrameFlatteningEnabled:
+ WKPreferencesSetFrameFlatteningEnabled(d->ref, on);
+ break;
+ case PrivateBrowsingEnabled:
+ WKPreferencesSetPrivateBrowsingEnabled(d->ref, on);
+ break;
+ case DeveloperExtrasEnabled:
+ WKPreferencesSetDeveloperExtrasEnabled(d->ref, on);
+ break;
+ case DnsPrefetchEnabled:
+ WKPreferencesSetDNSPrefetchingEnabled(d->ref, on);
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h
new file mode 100644
index 0000000..d9f7bc0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences.h
@@ -0,0 +1,72 @@
+/*
+ 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 QWKPREFERENCES_H
+#define QWKPREFERENCES_H
+
+#include "qwebkitglobal.h"
+
+class QWKPage;
+class QWKPreferencesPrivate;
+
+class QWEBKIT_EXPORT QWKPreferences {
+public:
+ enum FontFamily {
+ StandardFont,
+ FixedFont,
+ SerifFont,
+ SansSerifFont,
+ CursiveFont,
+ FantasyFont
+ };
+
+ enum WebAttribute {
+ AutoLoadImages,
+ JavascriptEnabled,
+ PluginsEnabled,
+ OfflineWebApplicationCacheEnabled,
+ LocalStorageEnabled,
+ XSSAuditingEnabled,
+ FrameFlatteningEnabled,
+ PrivateBrowsingEnabled,
+ DeveloperExtrasEnabled,
+ DnsPrefetchEnabled
+ };
+
+ static QWKPreferences* sharedPreferences();
+
+ void setFontFamily(FontFamily which, const QString& family);
+ QString fontFamily(FontFamily which) const;
+
+ void setAttribute(WebAttribute attr, bool on);
+ bool testAttribute(WebAttribute attr) const;
+
+private:
+ Q_DISABLE_COPY(QWKPreferences)
+
+ QWKPreferences();
+ ~QWKPreferences();
+
+ QWKPreferencesPrivate *d;
+
+ friend class QWKPage;
+ friend class QWKPreferencesPrivate;
+};
+
+#endif // QWKPREFERENCES_H
diff --git a/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h
new file mode 100644
index 0000000..7fe2389
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qwkpreferences_p.h
@@ -0,0 +1,28 @@
+/*
+ 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.
+*/
+
+#include "WKPreferences.h"
+
+class QWKPreferencesPrivate {
+public:
+ static QWKPreferences* createPreferences(WKPageGroupRef);
+ static QWKPreferences* createSharedPreferences();
+
+ WKPreferencesRef ref;
+};
diff --git a/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp
new file mode 100644
index 0000000..07b39b2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.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 "AuthenticationChallengeProxy.h"
+
+#include "AuthenticationDecisionListener.h"
+#include "AuthenticationManagerMessages.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, WebPageProxy* page)
+ : m_coreAuthenticationChallenge(authenticationChallenge)
+ , m_challengeID(challengeID)
+ , m_page(page)
+{
+ 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_page->process())
+ m_page->process()->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), m_page->pageID());
+
+ if (m_listener)
+ m_listener->detachChallenge();
+}
+
+void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
+{
+ if (!m_challengeID)
+ return;
+
+ if (!credential)
+ m_page->process()->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), m_page->pageID());
+ else
+ m_page->process()->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core()), m_page->pageID());
+
+ m_challengeID = 0;
+}
+
+void AuthenticationChallengeProxy::cancel()
+{
+ if (!m_challengeID)
+ return;
+
+ m_page->process()->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), m_page->pageID());
+
+ 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 0000000..d4e76dd
--- /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 WebPageProxy;
+class WebProtectionSpace;
+
+class AuthenticationChallengeProxy : public APIObject {
+public:
+ static const Type APIType = TypeAuthenticationChallenge;
+
+ static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebPageProxy* page)
+ {
+ return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, page));
+ }
+
+ ~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, WebPageProxy* page);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
+ uint64_t m_challengeID;
+ RefPtr<WebPageProxy> m_page;
+ 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 0000000..ddcc6c6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/AuthenticationDecisionListener.cpp
@@ -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.
+ */
+
+#include "AuthenticationDecisionListener.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "AuthenticationManagerMessages.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 0000000..00af849
--- /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 0000000..b9a346e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.cpp
@@ -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.
+ */
+
+#include "WebCredential.h"
+
+namespace WebKit {
+
+WebCredential::WebCredential(const WebCore::Credential& credential)
+ : m_coreCredential(credential)
+{
+}
+
+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 0000000..7beac04
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebCredential.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 WebCredential_h
+#define WebCredential_h
+
+#include "APIObject.h"
+#include "WebString.h"
+
+#include <WebCore/Credential.h>
+#include <wtf/PassRefPtr.h>
+
+
+namespace WebKit {
+
+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)));
+ }
+
+ const WebCore::Credential& core();
+
+ const String& user() const;
+
+private:
+ WebCredential(const WebCore::Credential&);
+
+ virtual Type type() const { return APIType; }
+
+ WebCore::Credential m_coreCredential;
+};
+
+} // 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 0000000..1671371
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Authentication/WebProtectionSpace.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 "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 0000000..604236a
--- /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 0000000..06d66af
--- /dev/null
+++ b/Source/WebKit2/UIProcess/BackingStore.cpp
@@ -0,0 +1,51 @@
+/*
+ * 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 "BackingStore.h"
+
+using namespace WebCore;
+
+#if !PLATFORM(MAC)
+#error "This class is not ready for use by other ports yet."
+#endif
+
+namespace WebKit {
+
+PassOwnPtr<BackingStore> BackingStore::create(const IntSize& size)
+{
+ return adoptPtr(new BackingStore(size));
+}
+
+BackingStore::BackingStore(const IntSize& size)
+ : m_size(size)
+{
+ ASSERT(!m_size.isEmpty());
+}
+
+BackingStore::~BackingStore()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/BackingStore.h b/Source/WebKit2/UIProcess/BackingStore.h
new file mode 100644
index 0000000..e196a55
--- /dev/null
+++ b/Source/WebKit2/UIProcess/BackingStore.h
@@ -0,0 +1,74 @@
+/*
+ * 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>
+#endif
+
+namespace WebCore {
+ class IntRect;
+}
+
+namespace WebKit {
+
+class UpdateInfo;
+class WebPageProxy;
+
+class BackingStore {
+ WTF_MAKE_NONCOPYABLE(BackingStore);
+
+public:
+ static PassOwnPtr<BackingStore> create(const WebCore::IntSize&);
+ ~BackingStore();
+
+#if PLATFORM(MAC)
+ typedef CGContextRef PlatformGraphicsContext;
+#endif
+
+ void paint(PlatformGraphicsContext, const WebCore::IntRect&);
+ void incorporateUpdate(const UpdateInfo&);
+
+private:
+ explicit BackingStore(const WebCore::IntSize&);
+
+ void scroll(const WebCore::IntRect& scrollRect, const WebCore::IntSize& scrollDelta);
+
+ WebCore::IntSize m_size;
+
+#if PLATFORM(MAC)
+ RetainPtr<CGContextRef> m_bitmapContext;
+#endif
+};
+
+} // namespace WebKit
+
+#endif // BackingStore_h
diff --git a/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.cpp
new file mode 100644
index 0000000..22e9c84
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.cpp
@@ -0,0 +1,174 @@
+/*
+ * 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 "ChunkedUpdateDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "MessageID.h"
+#include "UpdateChunk.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<ChunkedUpdateDrawingAreaProxy> ChunkedUpdateDrawingAreaProxy::create(PlatformWebView* webView, WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new ChunkedUpdateDrawingAreaProxy(webView, webPageProxy));
+}
+
+ChunkedUpdateDrawingAreaProxy::ChunkedUpdateDrawingAreaProxy(PlatformWebView* webView, WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaInfo::ChunkedUpdate, webPageProxy)
+ , m_isWaitingForDidSetFrameNotification(false)
+ , m_isVisible(true)
+ , m_forceRepaintWhenResumingPainting(false)
+ , m_webView(webView)
+{
+}
+
+ChunkedUpdateDrawingAreaProxy::~ChunkedUpdateDrawingAreaProxy()
+{
+}
+
+bool ChunkedUpdateDrawingAreaProxy::paint(const IntRect& rect, PlatformDrawingContext context)
+{
+ if (m_isWaitingForDidSetFrameNotification) {
+ WebPageProxy* page = this->page();
+ if (!page->isValid())
+ return false;
+
+ if (page->process()->isLaunching())
+ return false;
+
+ OwnPtr<CoreIPC::ArgumentDecoder> arguments = page->process()->connection()->waitFor(DrawingAreaProxyLegacyMessage::DidSetSize, page->pageID(), 0.04);
+ if (arguments)
+ didReceiveMessage(page->process()->connection(), CoreIPC::MessageID(DrawingAreaProxyLegacyMessage::DidSetSize), arguments.get());
+ }
+
+ return platformPaint(rect, context);
+}
+
+void ChunkedUpdateDrawingAreaProxy::sizeDidChange()
+{
+ sendSetSize();
+}
+
+void ChunkedUpdateDrawingAreaProxy::setPageIsVisible(bool isVisible)
+{
+ WebPageProxy* page = this->page();
+
+ if (isVisible == m_isVisible)
+ return;
+
+ m_isVisible = isVisible;
+ if (!page->isValid())
+ return;
+
+ if (!m_isVisible) {
+ // Tell the web process that it doesn't need to paint anything for now.
+ page->process()->send(DrawingAreaLegacyMessage::SuspendPainting, page->pageID(), CoreIPC::In(info().identifier));
+ return;
+ }
+
+ // The page is now visible, resume painting.
+ page->process()->send(DrawingAreaLegacyMessage::ResumePainting, page->pageID(), CoreIPC::In(info().identifier, m_forceRepaintWhenResumingPainting));
+ m_forceRepaintWhenResumingPainting = false;
+}
+
+void ChunkedUpdateDrawingAreaProxy::didSetSize(UpdateChunk* updateChunk)
+{
+ ASSERT(m_isWaitingForDidSetFrameNotification);
+ m_isWaitingForDidSetFrameNotification = false;
+
+ IntSize viewSize = updateChunk->rect().size();
+
+ if (viewSize != m_size)
+ sendSetSize();
+
+ invalidateBackingStore();
+ if (!updateChunk->isEmpty())
+ drawUpdateChunkIntoBackingStore(updateChunk);
+
+ WebPageProxy* page = this->page();
+ page->process()->responsivenessTimer()->stop();
+}
+
+void ChunkedUpdateDrawingAreaProxy::update(UpdateChunk* updateChunk)
+{
+ if (!m_isVisible) {
+ // We got an update request that must have been sent before we told the web process to suspend painting.
+ // Don't paint this into the backing store, because that could leave the backing store in an inconsistent state.
+ // Instead, we will just tell the drawing area to repaint everything when we resume painting.
+ m_forceRepaintWhenResumingPainting = true;
+ } else {
+ // Just paint into backing store.
+ drawUpdateChunkIntoBackingStore(updateChunk);
+ }
+
+ WebPageProxy* page = this->page();
+ page->process()->send(DrawingAreaLegacyMessage::DidUpdate, page->pageID(), CoreIPC::In(info().identifier));
+}
+
+void ChunkedUpdateDrawingAreaProxy::sendSetSize()
+{
+ if (!m_webPageProxy->isValid())
+ return;
+
+ if (m_isWaitingForDidSetFrameNotification)
+ return;
+ m_isWaitingForDidSetFrameNotification = true;
+
+ m_webPageProxy->process()->responsivenessTimer()->start();
+ m_webPageProxy->process()->send(DrawingAreaLegacyMessage::SetSize, m_webPageProxy->pageID(), CoreIPC::In(info().identifier, m_size));
+}
+
+void ChunkedUpdateDrawingAreaProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ switch (messageID.get<DrawingAreaProxyLegacyMessage::Kind>()) {
+ case DrawingAreaProxyLegacyMessage::Update: {
+ UpdateChunk updateChunk;
+ if (!arguments->decode(updateChunk))
+ return;
+
+ update(&updateChunk);
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::DidSetSize: {
+ UpdateChunk updateChunk;
+ if (!arguments->decode(CoreIPC::Out(updateChunk)))
+ return;
+
+ didSetSize(&updateChunk);
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.h b/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.h
new file mode 100644
index 0000000..348d04f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ChunkedUpdateDrawingAreaProxy.h
@@ -0,0 +1,109 @@
+/*
+ * 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 DrawingAreaProxyUpdateChunk_h
+#define DrawingAreaProxyUpdateChunk_h
+
+#include "DrawingAreaProxy.h"
+#include <WebCore/IntSize.h>
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#ifdef __OBJC__
+@class WKView;
+#else
+class WKView;
+#endif
+#elif PLATFORM(QT)
+#include <QImage>
+class QGraphicsWKView;
+#endif
+
+namespace WebKit {
+
+class UpdateChunk;
+class WebPageProxy;
+
+#if PLATFORM(MAC)
+typedef WKView PlatformWebView;
+#elif PLATFORM(WIN)
+class WebView;
+typedef WebView PlatformWebView;
+#elif PLATFORM(QT)
+typedef QGraphicsWKView PlatformWebView;
+#endif
+
+class ChunkedUpdateDrawingAreaProxy : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<ChunkedUpdateDrawingAreaProxy> create(PlatformWebView*, WebPageProxy*);
+
+ virtual ~ChunkedUpdateDrawingAreaProxy();
+
+private:
+ ChunkedUpdateDrawingAreaProxy(PlatformWebView*, WebPageProxy*);
+
+ WebPageProxy* page();
+
+ // DrawingAreaProxy
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
+ virtual void sizeDidChange();
+ virtual void setPageIsVisible(bool isVisible);
+
+ void ensureBackingStore();
+ void invalidateBackingStore();
+ bool platformPaint(const WebCore::IntRect&, PlatformDrawingContext);
+ void drawUpdateChunkIntoBackingStore(UpdateChunk*);
+ void didSetSize(UpdateChunk*);
+ void update(UpdateChunk*);
+
+ void sendSetSize();
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void attachCompositingContext(uint32_t) { }
+ virtual void detachCompositingContext() { }
+#endif
+
+ bool m_isWaitingForDidSetFrameNotification;
+ bool m_isVisible;
+ bool m_forceRepaintWhenResumingPainting;
+
+#if PLATFORM(MAC)
+ // BackingStore
+ RetainPtr<CGContextRef> m_bitmapContext;
+#elif PLATFORM(WIN)
+ // BackingStore
+ OwnPtr<HDC> m_backingStoreDC;
+ OwnPtr<HBITMAP> m_backingStoreBitmap;
+#elif PLATFORM(QT)
+ QImage m_backingStoreImage;
+#endif
+
+ PlatformWebView* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // DrawingAreaProxyUpdateChunk_h
diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
new file mode 100644
index 0000000..fcc4a75
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
@@ -0,0 +1,179 @@
+/*
+ * 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 "DownloadProxy.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;
+
+ m_webContext->process()->send(Messages::WebProcess::CancelDownload(m_downloadID), 0);
+}
+
+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::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);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
new file mode 100644
index 0000000..a155d72
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.h
@@ -0,0 +1,90 @@
+/*
+ * 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 ResourceError;
+ class ResourceResponse;
+}
+
+namespace WebKit {
+
+class WebContext;
+class WebData;
+
+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*);
+ CoreIPC::SyncReplyMode didReceiveSyncDownloadProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+
+private:
+ explicit DownloadProxy(WebContext*);
+
+ virtual Type type() const { return APIType; }
+
+ // Message handlers.
+ void didStart(const WebCore::ResourceRequest&);
+ 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 0000000..999080b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Downloads/DownloadProxy.messages.in
@@ -0,0 +1,33 @@
+# 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)
+ 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 0000000..fa16641
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.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 "DrawingAreaProxy.h"
+
+#include "WebPageProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+DrawingAreaProxy::DrawingAreaProxy(DrawingAreaInfo::Type type, WebPageProxy* webPageProxy)
+ : m_info(type, nextIdentifier())
+ , m_webPageProxy(webPageProxy)
+ , m_size(webPageProxy->viewSize())
+{
+}
+
+DrawingAreaProxy::~DrawingAreaProxy()
+{
+}
+
+DrawingAreaInfo::Identifier DrawingAreaProxy::nextIdentifier()
+{
+ static DrawingAreaInfo::Identifier nextID = 1;
+ return ++nextID;
+}
+
+void DrawingAreaProxy::setSize(const IntSize& size)
+{
+ if (m_size == size)
+ return;
+
+ m_size = size;
+ sizeDidChange();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h
new file mode 100644
index 0000000..a58a0d9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.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 DrawingAreaProxy_h
+#define DrawingAreaProxy_h
+
+#include "DrawingAreaInfo.h"
+#include <WebCore/IntSize.h>
+
+#if PLATFORM(QT)
+class QPainter;
+#endif
+
+namespace WebKit {
+
+class WebPageProxy;
+struct UpdateInfo;
+
+#if PLATFORM(MAC)
+typedef CGContextRef PlatformDrawingContext;
+#elif PLATFORM(WIN)
+typedef HDC PlatformDrawingContext;
+#elif PLATFORM(QT)
+typedef QPainter* PlatformDrawingContext;
+#endif
+
+class DrawingAreaProxy {
+ WTF_MAKE_NONCOPYABLE(DrawingAreaProxy);
+
+public:
+ static DrawingAreaInfo::Identifier nextIdentifier();
+
+ virtual ~DrawingAreaProxy();
+
+#ifdef __APPLE__
+ void didReceiveDrawingAreaProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+#endif
+
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*) = 0;
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*) { ASSERT_NOT_REACHED(); }
+
+ // Returns true if painting was successful, false otherwise.
+ virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext) = 0;
+
+ virtual void sizeDidChange() = 0;
+ virtual void setPageIsVisible(bool isVisible) = 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void attachCompositingContext(uint32_t contextID) = 0;
+ virtual void detachCompositingContext() = 0;
+#endif
+
+ const DrawingAreaInfo& info() const { return m_info; }
+
+ const WebCore::IntSize& size() const { return m_size; }
+ void setSize(const WebCore::IntSize&);
+
+protected:
+ explicit DrawingAreaProxy(DrawingAreaInfo::Type, WebPageProxy*);
+
+ DrawingAreaInfo m_info;
+ WebPageProxy* m_webPageProxy;
+
+ WebCore::IntSize m_size;
+
+private:
+ // CoreIPC message handlers.
+ // FIXME: These should be pure virtual.
+ virtual void update(const UpdateInfo&) { }
+ virtual void didSetSize() { }
+};
+
+} // 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 0000000..7e340d4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in
@@ -0,0 +1,26 @@
+# 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(WebKit::UpdateInfo updateInfo)
+ DidSetSize()
+}
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
new file mode 100644
index 0000000..02b0dd2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
@@ -0,0 +1,137 @@
+/*
+ * 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 "DrawingAreaProxyImpl.h"
+
+#include "DrawingAreaMessages.h"
+#include "UpdateInfo.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+#ifndef __APPLE__
+#error "This drawing area is not ready for use by other ports yet."
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<DrawingAreaProxyImpl> DrawingAreaProxyImpl::create(WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new DrawingAreaProxyImpl(webPageProxy));
+}
+
+DrawingAreaProxyImpl::DrawingAreaProxyImpl(WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaInfo::Impl, webPageProxy)
+{
+}
+
+DrawingAreaProxyImpl::~DrawingAreaProxyImpl()
+{
+}
+
+void DrawingAreaProxyImpl::paint(BackingStore::PlatformGraphicsContext context, const IntRect& rect)
+{
+ if (!m_backingStore)
+ return;
+
+ m_backingStore->paint(context, rect);
+}
+
+void DrawingAreaProxyImpl::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void DrawingAreaProxyImpl::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*)
+{
+ ASSERT_NOT_REACHED();
+}
+
+bool DrawingAreaProxyImpl::paint(const WebCore::IntRect&, PlatformDrawingContext)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+void DrawingAreaProxyImpl::sizeDidChange()
+{
+ sendSetSize();
+}
+
+void DrawingAreaProxyImpl::setPageIsVisible(bool pageIsVisible)
+{
+ // FIXME: Implement.
+}
+
+void DrawingAreaProxyImpl::attachCompositingContext(uint32_t contextID)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void DrawingAreaProxyImpl::detachCompositingContext()
+{
+ ASSERT_NOT_REACHED();
+}
+
+void DrawingAreaProxyImpl::update(const UpdateInfo& updateInfo)
+{
+ // FIXME: Handle the case where the view is hidden.
+
+ incorporateUpdate(updateInfo);
+ m_webPageProxy->process()->send(Messages::DrawingArea::DidUpdate(), m_webPageProxy->pageID());
+}
+
+void DrawingAreaProxyImpl::didSetSize()
+{
+}
+
+void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
+{
+ // FIXME: Check for the update bounds being empty here.
+
+ if (!m_backingStore)
+ m_backingStore = BackingStore::create(updateInfo.viewSize);
+
+ m_backingStore->incorporateUpdate(updateInfo);
+
+ for (size_t i = 0; i < updateInfo.updateRects.size(); ++i)
+ m_webPageProxy->setViewNeedsDisplay(updateInfo.updateRects[i]);
+
+ if (!updateInfo.scrollRect.isEmpty()) {
+ m_webPageProxy->setViewNeedsDisplay(updateInfo.scrollRect);
+ m_webPageProxy->displayView();
+ }
+}
+
+void DrawingAreaProxyImpl::sendSetSize()
+{
+ if (!m_webPageProxy->isValid())
+ return;
+
+ m_webPageProxy->process()->send(Messages::DrawingArea::SetSize(m_size), m_webPageProxy->pageID());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
new file mode 100644
index 0000000..0de7ada
--- /dev/null
+++ b/Source/WebKit2/UIProcess/DrawingAreaProxyImpl.h
@@ -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.
+ */
+
+#ifndef DrawingAreaProxyImpl_h
+#define DrawingAreaProxyImpl_h
+
+#include "BackingStore.h"
+#include "DrawingAreaProxy.h"
+
+namespace WebKit {
+
+class DrawingAreaProxyImpl : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<DrawingAreaProxyImpl> create(WebPageProxy*);
+ virtual ~DrawingAreaProxyImpl();
+
+ void paint(BackingStore::PlatformGraphicsContext, const WebCore::IntRect&);
+
+private:
+ explicit DrawingAreaProxyImpl(WebPageProxy*);
+
+ // DrawingAreaProxy
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+ virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
+ virtual void sizeDidChange();
+ virtual void setPageIsVisible(bool);
+ virtual void attachCompositingContext(uint32_t contextID);
+ virtual void detachCompositingContext();
+
+ // CoreIPC message handlers
+ virtual void update(const UpdateInfo&);
+ virtual void didSetSize();
+
+ void incorporateUpdate(const UpdateInfo&);
+ void sendSetSize();
+
+ OwnPtr<BackingStore> m_backingStore;
+};
+
+} // namespace WebKit
+
+#endif // DrawingAreaProxyImpl_h
diff --git a/Source/WebKit2/UIProcess/FindIndicator.cpp b/Source/WebKit2/UIProcess/FindIndicator.cpp
new file mode 100644
index 0000000..f1357e7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/FindIndicator.cpp
@@ -0,0 +1,173 @@
+/*
+ * 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 "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& selectionRect, const Vector<FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle)
+{
+ RefPtr<ShareableBitmap> contentImage = ShareableBitmap::create(enclosingIntRect(selectionRect).size(), contentImageHandle);
+ if (!contentImage)
+ return 0;
+
+ return adoptRef(new FindIndicator(selectionRect, textRects, contentImage.release()));
+}
+
+FindIndicator::FindIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, PassRefPtr<ShareableBitmap> contentImage)
+ : m_selectionRect(selectionRect)
+ , m_textRects(textRects)
+ , m_contentImage(contentImage)
+{
+}
+
+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_selectionRect.x() - leftBorderThickness, m_selectionRect.y() - topBorderThickness,
+ m_selectionRect.width() + rightBorderThickness + leftBorderThickness,
+ m_selectionRect.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_textRects.size(); ++i) {
+ FloatRect textRect = m_textRects[i];
+ textRect.move(leftBorderThickness, topBorderThickness);
+
+ graphicsContext.save();
+ FloatRect outerPathRect = inflateRect(textRect, horizontalOutsetToCenterOfLightBorder, verticalOutsetToCenterOfLightBorder);
+ graphicsContext.setShadow(FloatSize(shadowOffsetX, shadowOffsetY), shadowBlurRadius, shadowColor(), ColorSpaceSRGB);
+ graphicsContext.setFillColor(lightBorderColor(), ColorSpaceDeviceRGB);
+ graphicsContext.fillPath(pathWithRoundedRect(outerPathRect, cornerRadius));
+ graphicsContext.restore();
+
+ graphicsContext.save();
+ FloatRect innerPathRect = inflateRect(textRect, horizontalPaddingInsideLightBorder, verticalPaddingInsideLightBorder);
+ graphicsContext.clip(pathWithRoundedRect(innerPathRect, cornerRadius));
+ RefPtr<Gradient> gradient = Gradient::create(FloatPoint(innerPathRect.x(), innerPathRect.y()), FloatPoint(innerPathRect.x(), innerPathRect.bottom()));
+ gradient->addColorStop(0, gradientLightColor());
+ gradient->addColorStop(1, gradientDarkColor());
+ graphicsContext.setFillGradient(gradient);
+ graphicsContext.fillRect(outerPathRect);
+ graphicsContext.restore();
+
+ graphicsContext.save();
+ graphicsContext.translate(FloatSize(roundf(leftBorderThickness), roundf(topBorderThickness)));
+ m_contentImage->paint(graphicsContext, IntPoint(0, 0), m_contentImage->bounds());
+ graphicsContext.restore();
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/FindIndicator.h b/Source/WebKit2/UIProcess/FindIndicator.h
new file mode 100644
index 0000000..997d537
--- /dev/null
+++ b/Source/WebKit2/UIProcess/FindIndicator.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 FindIndicator_h
+#define FindIndicator_h
+
+#include "SharedMemory.h"
+#include <WebCore/FloatRect.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+ class GraphicsContext;
+}
+
+namespace WebKit {
+
+class ShareableBitmap;
+
+class FindIndicator : public RefCounted<FindIndicator> {
+public:
+ static PassRefPtr<FindIndicator> create(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle);
+ ~FindIndicator();
+
+ WebCore::FloatRect frameRect() const;
+
+ const Vector<WebCore::FloatRect>& textRects() const { return m_textRects; }
+
+ 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, PassRefPtr<ShareableBitmap> contentImage);
+
+ WebCore::FloatRect m_selectionRect;
+ Vector<WebCore::FloatRect> m_textRects;
+ 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 0000000..b72314a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GenericCallback.h
@@ -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.
+ */
+
+#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 {
+
+template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType>
+class GenericCallback : public RefCounted<GenericCallback<APIReturnValueType, InternalReturnValueType> > {
+public:
+ typedef void (*CallbackFunction)(APIReturnValueType, WKErrorRef, void*);
+
+ static PassRefPtr<GenericCallback> create(void* context, CallbackFunction callback)
+ {
+ return adoptRef(new GenericCallback(context, callback));
+ }
+
+ ~GenericCallback()
+ {
+ ASSERT(!m_callback);
+ }
+
+ void performCallbackWithReturnValue(InternalReturnValueType returnValue)
+ {
+ ASSERT(m_callback);
+
+ m_callback(toAPI(returnValue), 0, m_context);
+
+ m_callback = 0;
+ }
+
+ void invalidate()
+ {
+ ASSERT(m_callback);
+
+ RefPtr<WebError> error = WebError::create();
+ m_callback(0, toAPI(error.get()), m_context);
+
+ m_callback = 0;
+ }
+
+ uint64_t callbackID() const { return m_callbackID; }
+
+private:
+ static uint64_t generateCallbackID()
+ {
+ static uint64_t uniqueCallbackID = 1;
+ return uniqueCallbackID++;
+ }
+
+ GenericCallback(void* context, CallbackFunction callback)
+ : m_context(context)
+ , m_callback(callback)
+ , m_callbackID(generateCallbackID())
+ {
+ }
+
+ void* m_context;
+ CallbackFunction m_callback;
+ uint64_t m_callbackID;
+};
+
+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 0000000..285e329
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestManagerProxy.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 "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 0000000..98885bf
--- /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 0000000..9766ad2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/GeolocationPermissionRequestProxy.cpp
@@ -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.
+ */
+
+#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 0000000..c34c3fd
--- /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 0000000..507edfa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
@@ -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.
+ */
+
+#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().scheduleWork(WorkItem::create(this, &ProcessLauncher::launchProcess));
+}
+
+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 0000000..31efd4d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ProcessLauncher.h
@@ -0,0 +1,99 @@
+/*
+ * 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 ThreadSafeShared<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;
+#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&);
+
+#if PLATFORM(QT)
+ friend class ProcessLauncherHelper;
+ static QLocalSocket* takePendingConnection();
+#endif
+
+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 0000000..69e4893
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/ThreadLauncher.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 "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()->scheduleWork(WorkItem::create(this, &ThreadLauncher::didFinishLaunchingThread, 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 0000000..9c90fbd
--- /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 ThreadSafeShared<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 0000000..2565a48
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
@@ -0,0 +1,86 @@
+/*
+ * 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 "ProcessLauncher.h"
+
+#include "Connection.h"
+#include "RunLoop.h"
+#include <WebCore/FileSystem.h>
+#include <WebCore/ResourceHandle.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const char* gWebKitWebProcessName = "WebKitWebProcess";
+
+void ProcessLauncher::launchProcess()
+{
+ pid_t pid = 0;
+
+ int sockets[2];
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) {
+ fprintf(stderr, "Creation of socket failed with errno %d.\n", errno);
+ ASSERT_NOT_REACHED();
+ return;
+ }
+
+ pid = fork();
+ if (!pid) { // child process
+ close(sockets[1]);
+ String socket = String::format("%d", sockets[0]);
+ GOwnPtr<gchar> binaryPath(g_build_filename(applicationDirectoryPath().data(), gWebKitWebProcessName, NULL));
+ execl(binaryPath.get(), gWebKitWebProcessName, socket.utf8().data(), NULL);
+ } else if (pid > 0) { // parent process
+ close(sockets[0]);
+ m_processIdentifier = pid;
+ // We've finished launching the process, message back to the main run loop.
+ RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, pid, sockets[1]));
+ } else {
+ fprintf(stderr, "Unable to fork a new WebProcess with errno: %d.\n", errno);
+ ASSERT_NOT_REACHED();
+ }
+}
+
+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 0000000..2841e0a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/gtk/ThreadLauncherGtk.cpp
@@ -0,0 +1,39 @@
+/*
+ * 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 "ThreadLauncher.h"
+
+#include "NotImplemented.h"
+
+namespace WebKit {
+
+CoreIPC::Connection::Identifier ThreadLauncher::createWebThread()
+{
+ notImplemented();
+ return -1;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
new file mode 100644
index 0000000..c285bae
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/ProcessLauncherMac.mm
@@ -0,0 +1,311 @@
+/*
+ * 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 "ProcessLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include "WebKitSystemInterface.h"
+#include <crt_externs.h>
+#include <mach-o/dyld.h>
+#include <mach/machine.h>
+#include <runtime/InitializeThreading.h>
+#include <servers/bootstrap.h>
+#include <spawn.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/text/CString.h>
+#include <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 {
+
+#if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD)
+static const char* processName()
+{
+ return [[[NSProcessInfo processInfo] processName] fileSystemRepresentation];
+}
+#else
+// -[NSProcessInfo processName] isn't thread-safe on Leopard and Snow Leopard so we have our own implementation.
+static const char* createProcessName()
+{
+ uint32_t bufferSize = MAXPATHLEN;
+ char executablePath[bufferSize];
+
+ if (_NSGetExecutablePath(executablePath, &bufferSize))
+ return "";
+
+ const char *processName = strrchr(executablePath, '/') + 1;
+ return strdup(processName);
+}
+
+static const char* processName()
+{
+ static const char* processName = createProcessName();
+ return processName;
+}
+#endif
+
+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
+}
+
+class EnvironmentVariables {
+ WTF_MAKE_NONCOPYABLE(EnvironmentVariables);
+
+public:
+ EnvironmentVariables()
+ : m_environmentPointer(*_NSGetEnviron())
+ {
+ }
+
+ ~EnvironmentVariables()
+ {
+ deleteAllValues(m_allocatedStrings);
+ }
+
+ void 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.
+ char* nameAndValue = createStringForVariable(name, value);
+
+ for (size_t i = 0; i < m_environmentVariables.size() - 1; ++i) {
+ char* environmentVariable = m_environmentVariables[i];
+
+ if (valueIfVariableHasName(environmentVariable, name)) {
+ // Just replace the environment variable.
+ m_environmentVariables[i] = nameAndValue;
+ return;
+ }
+ }
+
+ // Append the new string.
+ ASSERT(!m_environmentVariables.last());
+ m_environmentVariables.last() = nameAndValue;
+ m_environmentVariables.append(static_cast<char*>(0));
+
+ m_environmentPointer = m_environmentVariables.data();
+ }
+
+ char* get(const char* name) const
+ {
+ for (size_t i = 0; m_environmentPointer[i]; ++i) {
+ if (char* value = valueIfVariableHasName(m_environmentPointer[i], name))
+ return value;
+ }
+ return 0;
+ }
+
+ // 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* 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());
+ }
+
+ char** environmentPointer() const { return m_environmentPointer; }
+
+private:
+ char *valueIfVariableHasName(const char* environmentVariable, const char* name) const
+ {
+ // Find the environment variable name.
+ char* equalsLocation = strchr(environmentVariable, '=');
+ ASSERT(equalsLocation);
+
+ size_t nameLength = equalsLocation - environmentVariable;
+ if (strncmp(environmentVariable, name, nameLength))
+ return 0;
+
+ return equalsLocation + 1;
+ }
+
+ char* 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 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));
+ }
+
+ char** m_environmentPointer;
+ Vector<char*> m_environmentVariables;
+
+ // These allocated strings will be freed in the destructor.
+ Vector<char*> m_allocatedStrings;
+};
+
+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);
+
+ NSBundle *webKit2Bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebKit2"];
+ const char* bundlePath = [[webKit2Bundle executablePath] fileSystemRepresentation];
+
+ NSString *webProcessAppPath = [webKit2Bundle pathForAuxiliaryExecutable:@"WebProcess.app"];
+ NSString *webProcessAppExecutablePath = [[NSBundle bundleWithPath:webProcessAppPath] executablePath];
+
+ // 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* path = [webProcessAppExecutablePath fileSystemRepresentation];
+ const char* args[] = { path, bundlePath, "-type", processTypeAsString(m_launchOptions.processType), "-servicename", serviceName.data(), "-parentprocessname", processName(), 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;
+
+ posix_spawnattr_setflags(&attr, flags);
+
+ pid_t processIdentifier;
+
+ EnvironmentVariables environmentVariables;
+
+ if (m_launchOptions.processType == ProcessLauncher::PluginProcess) {
+ // We need to insert the plug-in process shim.
+ NSString *pluginProcessShimPathNSString = [[webProcessAppExecutablePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"PluginProcessShim.dylib"];
+ const char *pluginProcessShimPath = [pluginProcessShimPathNSString fileSystemRepresentation];
+
+ // Make sure that the file exists.
+ struct stat statBuf;
+ if (stat(pluginProcessShimPath, &statBuf) == 0 && (statBuf.st_mode & S_IFMT) == S_IFREG)
+ environmentVariables.appendValue("DYLD_INSERT_LIBRARIES", pluginProcessShimPath, ':');
+ }
+
+ int result = posix_spawn(&processIdentifier, path, 0, &attr, (char *const*)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;
+ }
+
+ // We've finished launching the process, message back to the main run loop.
+ RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, 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 0000000..8aac275
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/mac/ThreadLauncherMac.mm
@@ -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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include "WebSystemInterface.h"
+#include <runtime/InitializeThreading.h>
+#include <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 0000000..7dff894
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/qt/ProcessLauncherQt.cpp
@@ -0,0 +1,223 @@
+/*
+ * 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 "ProcessLauncher.h"
+
+#include "Connection.h"
+#include "CleanupHandler.h"
+#include "NotImplemented.h"
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <string>
+#include <wtf/HashSet.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Threading.h>
+#include <wtf/text/WTFString.h>
+
+#include <QApplication>
+#include <QDebug>
+#include <QFile>
+#include <QLocalServer>
+#include <QMetaType>
+#include <QProcess>
+#include <QString>
+
+#include <QtCore/qglobal.h>
+
+#include <sys/resource.h>
+#include <unistd.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+class ProcessLauncherHelper : public QObject {
+ Q_OBJECT
+public:
+ ~ProcessLauncherHelper();
+ void launch(WebKit::ProcessLauncher*);
+ QLocalSocket* takePendingConnection();
+ static ProcessLauncherHelper* instance();
+
+ const QString serverName() const { return m_server.serverName(); }
+
+private:
+ ProcessLauncherHelper();
+ QLocalServer m_server;
+ QList<WorkItem*> m_items;
+
+ Q_SLOT void newConnection();
+};
+
+Q_GLOBAL_STATIC(WTF::HashSet<QProcess*>, processes);
+
+static void cleanupAtExit()
+{
+ // Terminate our web process(es).
+ WTF::HashSet<QProcess*>::const_iterator end = processes()->end();
+ for (WTF::HashSet<QProcess*>::const_iterator it = processes()->begin(); it != end; ++it) {
+ QProcess* process = *it;
+ process->disconnect(process);
+ process->terminate();
+ if (!process->waitForFinished(200))
+ process->kill();
+ }
+
+ // Do not leave the socket file behind.
+ QLocalServer::removeServer(ProcessLauncherHelper::instance()->serverName());
+}
+
+class QtWebProcess : public QProcess
+{
+ Q_OBJECT
+public:
+ QtWebProcess(QObject* parent = 0)
+ : QProcess(parent)
+ {
+ static bool isRegistered = false;
+ if (!isRegistered) {
+ qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
+ isRegistered = true;
+ }
+
+ connect(this, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
+ }
+
+private slots:
+ void processStateChanged(QProcess::ProcessState state);
+};
+
+void QtWebProcess::processStateChanged(QProcess::ProcessState state)
+{
+ QProcess* process = qobject_cast<QProcess*>(sender());
+ if (!process)
+ return;
+
+ if (state == QProcess::Running)
+ processes()->add(process);
+ else if (state == QProcess::NotRunning)
+ processes()->remove(process);
+}
+
+void ProcessLauncherHelper::launch(WebKit::ProcessLauncher* launcher)
+{
+ QString applicationPath = "%1 %2";
+
+ if (QFile::exists(QCoreApplication::applicationDirPath() + "/QtWebProcess")) {
+ applicationPath = applicationPath.arg(QCoreApplication::applicationDirPath() + "/QtWebProcess");
+ } else {
+ applicationPath = applicationPath.arg("QtWebProcess");
+ }
+
+ QString program(applicationPath.arg(m_server.serverName()));
+
+ QProcess* webProcess = new QtWebProcess();
+ webProcess->setProcessChannelMode(QProcess::ForwardedChannels);
+ webProcess->start(program);
+
+ if (!webProcess->waitForStarted()) {
+ qDebug() << "Failed to start" << program;
+ ASSERT_NOT_REACHED();
+ delete webProcess;
+ return;
+ }
+
+ setpriority(PRIO_PROCESS, webProcess->pid(), 10);
+
+ m_items.append(WorkItem::create(launcher, &WebKit::ProcessLauncher::didFinishLaunchingProcess, webProcess, m_server.serverName()).leakPtr());
+}
+
+QLocalSocket* ProcessLauncherHelper::takePendingConnection()
+{
+ return m_server.nextPendingConnection();
+}
+
+ProcessLauncherHelper::~ProcessLauncherHelper()
+{
+ m_server.close();
+}
+
+ProcessLauncherHelper::ProcessLauncherHelper()
+{
+ srandom(time(0));
+ if (!m_server.listen("QtWebKit" + QString::number(random()))) {
+ qDebug() << "Failed to create server socket.";
+ ASSERT_NOT_REACHED();
+ }
+ connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
+}
+
+ProcessLauncherHelper* ProcessLauncherHelper::instance()
+{
+ static ProcessLauncherHelper* result = 0;
+ if (!result) {
+ result = new ProcessLauncherHelper();
+
+ // The purpose of the following line is to ensure that our static is initialized before the exit handler is installed.
+ processes()->clear();
+
+ atexit(cleanupAtExit);
+ }
+ return result;
+}
+
+void ProcessLauncherHelper::newConnection()
+{
+ ASSERT(!m_items.isEmpty());
+
+ m_items[0]->execute();
+ delete m_items[0];
+ m_items.pop_front();
+}
+
+void ProcessLauncher::launchProcess()
+{
+ ProcessLauncherHelper::instance()->launch(this);
+}
+
+void ProcessLauncher::terminateProcess()
+{
+ if (!m_processIdentifier)
+ return;
+
+ QObject::connect(m_processIdentifier, SIGNAL(finished(int)), m_processIdentifier, SLOT(deleteLater()), Qt::QueuedConnection);
+ m_processIdentifier->terminate();
+}
+
+QLocalSocket* ProcessLauncher::takePendingConnection()
+{
+ return ProcessLauncherHelper::instance()->takePendingConnection();
+}
+
+void ProcessLauncher::platformInvalidate()
+{
+ notImplemented();
+}
+
+} // 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 0000000..471a424
--- /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 "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.h>
+#include <wtf/Threading.h>
+
+#include <QApplication>
+#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("foo", 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;
+ }
+
+ QString serverIdentifier = QString::number(connectionIdentifier);
+ return serverIdentifier;
+}
+
+} // 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 0000000..7165a18
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/win/ProcessLauncherWin.cpp
@@ -0,0 +1,122 @@
+/*
+ * 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 "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, commandLine);
+ 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()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, 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 0000000..b8b2f64
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Launcher/win/ThreadLauncherWin.cpp
@@ -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.
+ */
+
+#include "ThreadLauncher.h"
+
+#include "RunLoop.h"
+#include "WebProcess.h"
+#include <runtime/InitializeThreading.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/LayerBackedDrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.cpp
new file mode 100644
index 0000000..ffa91de
--- /dev/null
+++ b/Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.cpp
@@ -0,0 +1,171 @@
+/*
+ * 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 USE(ACCELERATED_COMPOSITING)
+
+#include "LayerBackedDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "MessageID.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+PassOwnPtr<LayerBackedDrawingAreaProxy> LayerBackedDrawingAreaProxy::create(PlatformWebView* webView, WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new LayerBackedDrawingAreaProxy(webView, webPageProxy));
+}
+
+LayerBackedDrawingAreaProxy::LayerBackedDrawingAreaProxy(PlatformWebView* webView, WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaInfo::LayerBacked, webPageProxy)
+ , m_isWaitingForDidSetFrameNotification(false)
+ , m_isVisible(true)
+ , m_webView(webView)
+{
+}
+
+LayerBackedDrawingAreaProxy::~LayerBackedDrawingAreaProxy()
+{
+}
+
+#if !PLATFORM(WIN)
+bool LayerBackedDrawingAreaProxy::paint(const IntRect& rect, PlatformDrawingContext context)
+{
+ return true;
+}
+#endif
+
+void LayerBackedDrawingAreaProxy::sizeDidChange()
+{
+ WebPageProxy* page = this->page();
+ if (!page->isValid())
+ return;
+
+ if (m_size.isEmpty())
+ return;
+
+ m_lastSetViewSize = m_size;
+
+ platformSetSize();
+
+ if (m_isWaitingForDidSetFrameNotification)
+ return;
+
+ m_isWaitingForDidSetFrameNotification = true;
+
+ page->process()->responsivenessTimer()->start();
+ page->process()->send(DrawingAreaLegacyMessage::SetSize, page->pageID(), CoreIPC::In(info().identifier, m_size));
+}
+
+#if !PLATFORM(MAC) && !PLATFORM(WIN)
+void LayerBackedDrawingAreaProxy::platformSetSize()
+{
+}
+#endif
+
+void LayerBackedDrawingAreaProxy::setPageIsVisible(bool isVisible)
+{
+ WebPageProxy* page = this->page();
+
+ if (isVisible == m_isVisible)
+ return;
+
+ m_isVisible = isVisible;
+ if (!page->isValid())
+ return;
+
+ if (!m_isVisible) {
+ // Tell the web process that it doesn't need to paint anything for now.
+ page->process()->send(DrawingAreaLegacyMessage::SuspendPainting, page->pageID(), CoreIPC::In(info().identifier));
+ return;
+ }
+
+ // The page is now visible.
+ page->process()->send(DrawingAreaLegacyMessage::ResumePainting, page->pageID(), CoreIPC::In(info().identifier));
+
+ // FIXME: We should request a full repaint here if needed.
+}
+
+void LayerBackedDrawingAreaProxy::didSetSize(const IntSize& size)
+{
+ m_isWaitingForDidSetFrameNotification = false;
+
+ if (size != m_lastSetViewSize)
+ setSize(m_lastSetViewSize);
+
+ WebPageProxy* page = this->page();
+ page->process()->responsivenessTimer()->stop();
+}
+
+void LayerBackedDrawingAreaProxy::update()
+{
+ WebPageProxy* page = this->page();
+ page->process()->send(DrawingAreaLegacyMessage::DidUpdate, page->pageID(), CoreIPC::In(info().identifier));
+}
+
+void LayerBackedDrawingAreaProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ switch (messageID.get<DrawingAreaProxyLegacyMessage::Kind>()) {
+ case DrawingAreaProxyLegacyMessage::Update: {
+ update();
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::DidSetSize: {
+ IntSize size;
+ if (!arguments->decode(CoreIPC::Out(size)))
+ return;
+ didSetSize(size);
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void LayerBackedDrawingAreaProxy::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder*)
+{
+ switch (messageID.get<DrawingAreaProxyLegacyMessage::Kind>()) {
+#if USE(ACCELERATED_COMPOSITING)
+ case DrawingAreaProxyLegacyMessage::AttachCompositingContext: {
+ uint32_t contextID;
+ if (!arguments->decode(CoreIPC::Out(contextID)))
+ return;
+ attachCompositingContext(contextID);
+ break;
+ }
+#endif
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+} // namespace WebKit
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.h b/Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.h
new file mode 100644
index 0000000..bbaa643
--- /dev/null
+++ b/Source/WebKit2/UIProcess/LayerBackedDrawingAreaProxy.h
@@ -0,0 +1,98 @@
+/*
+ * 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 LayerBackedDrawingAreaProxy_h
+#define LayerBackedDrawingAreaProxy_h
+
+#if USE(ACCELERATED_COMPOSITING)
+
+#include "DrawingAreaProxy.h"
+#include <WebCore/IntSize.h>
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#ifdef __OBJC__
+@class CALayer;
+@class WKView;
+#else
+class CALayer;
+class WKView;
+#endif
+#endif
+
+namespace WebKit {
+
+class WebPageProxy;
+
+#if PLATFORM(MAC)
+typedef WKView PlatformWebView;
+#elif PLATFORM(WIN)
+class WebView;
+typedef WebView PlatformWebView;
+#endif
+
+class LayerBackedDrawingAreaProxy : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<LayerBackedDrawingAreaProxy> create(PlatformWebView*, WebPageProxy*);
+ virtual ~LayerBackedDrawingAreaProxy();
+
+private:
+ LayerBackedDrawingAreaProxy(PlatformWebView*, WebPageProxy*);
+
+ WebPageProxy* page();
+
+ // DrawingAreaProxy
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+
+ virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
+ virtual void sizeDidChange();
+ virtual void setPageIsVisible(bool isVisible);
+
+ virtual void attachCompositingContext(uint32_t contextID);
+ virtual void detachCompositingContext();
+
+ void didSetSize(const WebCore::IntSize&);
+ void update();
+
+ void platformSetSize();
+
+ bool m_isWaitingForDidSetFrameNotification;
+ bool m_isVisible;
+
+ WebCore::IntSize m_lastSetViewSize;
+
+#if PLATFORM(MAC)
+ RetainPtr<CALayer> m_compositingRootLayer;
+#endif
+
+ PlatformWebView* m_webView;
+};
+
+} // namespace WebKit
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+#endif // LayerBackedDrawingAreaProxy_h
diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h
new file mode 100644
index 0000000..5767b3c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/PageClient.h
@@ -0,0 +1,135 @@
+/*
+ * 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 PageClient_h
+#define PageClient_h
+
+#include "WebPageProxy.h"
+#include "WebPopupMenuProxy.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+ class Cursor;
+ struct ViewportArguments;
+}
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+class FindIndicator;
+class NativeWebKeyboardEvent;
+class NativeWebKeyboardEvent;
+class WebContextMenuProxy;
+class WebEditCommandProxy;
+class WebPopupMenuProxy;
+
+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;
+
+ // 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 takeFocus(bool direction) = 0;
+ virtual void toolTipChanged(const String&, const String&) = 0;
+
+#if ENABLE(TILED_BACKING_STORE)
+ virtual void pageDidRequestScroll(const WebCore::IntSize&) = 0;
+#endif
+#if PLATFORM(QT)
+ virtual void didChangeContentsSize(const WebCore::IntSize&) = 0;
+ virtual void didFindZoomableArea(const WebCore::IntRect&) = 0;
+#endif
+
+ virtual void setCursor(const WebCore::Cursor&) = 0;
+ virtual void setViewportArguments(const WebCore::ViewportArguments&) = 0;
+
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo) = 0;
+ virtual void clearAllEditCommands() = 0;
+ virtual void setEditCommandState(const String& commandName, bool isEnabled, int state) = 0;
+#if PLATFORM(MAC)
+ virtual void accessibilityChildTokenReceived(const CoreIPC::DataReference&) = 0;
+ virtual void interceptKeyEvent(const NativeWebKeyboardEvent&, Vector<WebCore::KeypressCommand>&, uint32_t, uint32_t, Vector<WebCore::CompositionUnderline>&) = 0;
+#endif
+#if PLATFORM(WIN)
+ virtual void compositionSelectionChanged(bool) = 0;
+#endif
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&) = 0;
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&) = 0;
+
+ virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&) = 0;
+
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*) = 0;
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*) = 0;
+
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut) = 0;
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void pageDidEnterAcceleratedCompositing() = 0;
+ virtual void pageDidLeaveAcceleratedCompositing() = 0;
+#endif
+
+#if PLATFORM(WIN)
+ virtual HWND nativeWindow() = 0;
+#endif
+
+#if PLATFORM(MAC)
+ virtual void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled) = 0;
+#endif
+
+ // Custom representations.
+ virtual void didCommitLoadForMainFrame(bool useCustomRepresentation) = 0;
+ virtual void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&) = 0;
+ virtual double customRepresentationZoomFactor() = 0;
+ virtual void setCustomRepresentationZoomFactor(double) = 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 0000000..f4fb5ad
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.cpp
@@ -0,0 +1,220 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#include <WebCore/KURL.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <algorithm>
+#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, typename V, typename W>
+static void addFromVector(HashSet<T, U, V>& hashSet, const W& vector)
+{
+ for (size_t i = 0; i < vector.size(); ++i)
+ hashSet.add(vector[i]);
+}
+
+#if OS(WINDOWS)
+typedef HashSet<String, CaseFoldingHash> PathHashSet;
+#else
+typedef HashSet<String> PathHashSet;
+#endif
+
+void PluginInfoStore::loadPluginsIfNecessary()
+{
+ if (m_pluginListIsUpToDate)
+ return;
+
+ m_plugins.clear();
+
+ 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());
+
+ PathHashSet::const_iterator end = uniquePluginPaths.end();
+ for (PathHashSet::const_iterator it = uniquePluginPaths.begin(); it != end; ++it)
+ loadPlugin(*it);
+
+ m_pluginListIsUpToDate = true;
+}
+
+void PluginInfoStore::loadPlugin(const String& pluginPath)
+{
+ Plugin plugin;
+
+ if (!getPluginInfo(pluginPath, plugin))
+ return;
+
+ if (!shouldUsePlugin(plugin))
+ return;
+
+ // Add the plug-in.
+ m_plugins.append(plugin);
+}
+
+void PluginInfoStore::getPlugins(Vector<PluginInfo>& plugins)
+{
+ loadPluginsIfNecessary();
+
+ for (size_t i = 0; i < m_plugins.size(); ++i)
+ plugins.append(m_plugins[i].info);
+}
+
+PluginInfoStore::Plugin PluginInfoStore::findPluginForMIMEType(const String& mimeType)
+{
+ ASSERT(!mimeType.isNull());
+
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ const Plugin& 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 Plugin();
+}
+
+PluginInfoStore::Plugin PluginInfoStore::findPluginForExtension(const String& extension, String& mimeType)
+{
+ ASSERT(!extension.isNull());
+
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ const Plugin& 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 Plugin();
+}
+
+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
+
+PluginInfoStore::Plugin 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()) {
+ Plugin 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()) {
+ Plugin 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()) {
+ Plugin plugin = findPluginForMIMEType(extensionMimeType);
+ if (!plugin.path.isNull()) {
+ mimeType = extensionMimeType;
+ return plugin;
+ }
+ }
+ }
+
+ return Plugin();
+}
+
+PluginInfoStore::Plugin PluginInfoStore::infoForPluginWithPath(const String& pluginPath)
+{
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ if (m_plugins[i].path == pluginPath)
+ return m_plugins[i];
+ }
+
+ ASSERT_NOT_REACHED();
+ return Plugin();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.h
new file mode 100644
index 0000000..b342203
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginInfoStore.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 PluginInfoStore_h
+#define PluginInfoStore_h
+
+#include <WebCore/PluginData.h>
+
+namespace WebCore {
+ class KURL;
+}
+
+namespace WebKit {
+
+class PluginInfoStore {
+public:
+ PluginInfoStore();
+
+ void setAdditionalPluginsDirectories(const Vector<String>&);
+
+ void refresh();
+ void getPlugins(Vector<WebCore::PluginInfo>& plugins);
+
+ // Represents a single plug-in.
+ struct Plugin {
+ String path;
+ WebCore::PluginInfo info;
+#if PLATFORM(MAC)
+ cpu_type_t pluginArchitecture;
+ String bundleIdentifier;
+ unsigned versionNumber;
+#elif PLATFORM(WIN)
+ uint64_t fileVersion;
+#endif
+ };
+
+ // 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.
+ Plugin findPlugin(String& mimeType, const WebCore::KURL& url);
+
+ // Returns the info for the plug-in with the given path.
+ Plugin infoForPluginWithPath(const String& pluginPath);
+
+private:
+
+ Plugin findPluginForMIMEType(const String& mimeType);
+ Plugin findPluginForExtension(const String& extension, String& mimeType);
+
+ void loadPluginsIfNecessary();
+ void loadPlugin(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();
+ static bool getPluginInfo(const String& pluginPath, Plugin& plugin);
+ bool shouldUsePlugin(const Plugin& plugin);
+ static String getMIMETypeForExtension(const String& extension);
+
+ Vector<String> m_additionalPluginsDirectories;
+ Vector<Plugin> 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 0000000..ff44e25
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.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.
+ */
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessManager.h"
+
+#include "PluginInfoStore.h"
+#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 String& pluginPath, WebProcessProxy* webProcessProxy, CoreIPC::ArgumentEncoder* reply)
+{
+ ASSERT(!pluginPath.isNull());
+
+ PluginInfoStore::Plugin plugin = webProcessProxy->context()->pluginInfoStore()->infoForPluginWithPath(pluginPath);
+
+ PluginProcessProxy* pluginProcess = 0;
+
+ for (size_t i = 0; i < m_pluginProcesses.size(); ++i) {
+ if (m_pluginProcesses[i]->pluginInfo().path == plugin.path) {
+ pluginProcess = m_pluginProcesses[i];
+ break;
+ }
+ }
+
+ if (!pluginProcess) {
+ pluginProcess = PluginProcessProxy::create(this, plugin).leakPtr();
+ m_pluginProcesses.append(pluginProcess);
+ }
+
+ pluginProcess->createWebProcessConnection(webProcessProxy, reply);
+}
+
+void PluginProcessManager::removePluginProcessProxy(PluginProcessProxy* pluginProcessProxy)
+{
+ size_t vectorIndex = m_pluginProcesses.find(pluginProcessProxy);
+ ASSERT(vectorIndex != notFound);
+
+ m_pluginProcesses.remove(vectorIndex);
+}
+
+} // 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 0000000..c265f2e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessManager.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 PluginProcessManager_h
+#define PluginProcessManager_h
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include <wtf/Forward.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Vector.h>
+
+namespace CoreIPC {
+ class ArgumentEncoder;
+}
+
+namespace WebKit {
+
+class PluginProcessProxy;
+class WebProcessProxy;
+
+class PluginProcessManager : Noncopyable {
+public:
+ static PluginProcessManager& shared();
+
+ void getPluginProcessConnection(const String& pluginPath, WebProcessProxy*, CoreIPC::ArgumentEncoder* reply);
+ void removePluginProcessProxy(PluginProcessProxy*);
+
+private:
+ PluginProcessManager();
+
+ 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 0000000..093a31f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.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.
+ */
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessProxy.h"
+
+#include "MachPort.h"
+#include "PluginProcessCreationParameters.h"
+#include "PluginProcessManager.h"
+#include "PluginProcessMessages.h"
+#include "RunLoop.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+PassOwnPtr<PluginProcessProxy> PluginProcessProxy::create(PluginProcessManager* PluginProcessManager, const PluginInfoStore::Plugin& pluginInfo)
+{
+ return adoptPtr(new PluginProcessProxy(PluginProcessManager, pluginInfo));
+}
+
+PluginProcessProxy::PluginProcessProxy(PluginProcessManager* PluginProcessManager, const PluginInfoStore::Plugin& pluginInfo)
+ : m_pluginProcessManager(PluginProcessManager)
+ , m_pluginInfo(pluginInfo)
+ , m_numPendingConnectionRequests(0)
+{
+ ProcessLauncher::LaunchOptions launchOptions;
+ launchOptions.processType = ProcessLauncher::PluginProcess;
+#if PLATFORM(MAC)
+ launchOptions.architecture = pluginInfo.pluginArchitecture;
+#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::createWebProcessConnection(WebProcessProxy* webProcessProxy, CoreIPC::ArgumentEncoder* reply)
+{
+ m_pendingConnectionReplies.append(make_pair(webProcessProxy, reply));
+
+ if (m_processLauncher->isLaunching()) {
+ m_numPendingConnectionRequests++;
+ return;
+ }
+
+ // Ask the plug-in process to create a connection.
+ m_connection->send(Messages::PluginProcess::CreateWebProcessConnection(), 0);
+}
+
+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<WebProcessProxy> replyWebProcessProxy = m_pendingConnectionReplies.first().first.release();
+ CoreIPC::ArgumentEncoder* reply = m_pendingConnectionReplies.first().second;
+ m_pendingConnectionReplies.removeFirst();
+
+ // FIXME: This is Mac specific.
+ reply->encode(CoreIPC::MachPort(0, MACH_MSG_TYPE_MOVE_SEND));
+ replyWebProcessProxy->connection()->sendSyncReply(reply);
+ }
+
+ // 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*)
+{
+ pluginProcessCrashedOrFailedToLaunch();
+}
+
+void PluginProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID)
+{
+}
+
+void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier connectionIdentifier)
+{
+ ASSERT(!m_connection);
+
+ if (!connectionIdentifier) {
+ pluginProcessCrashedOrFailedToLaunch();
+ return;
+ }
+
+ m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
+ m_connection->open();
+
+ PluginProcessCreationParameters parameters;
+
+ parameters.pluginPath = m_pluginInfo.path;
+
+ platformInitializePluginProcess(parameters);
+
+ // Initialize the plug-in host process.
+ m_connection->send(Messages::PluginProcess::Initialize(parameters), 0);
+
+ // Send all our pending requests.
+ for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i)
+ m_connection->send(Messages::PluginProcess::CreateWebProcessConnection(), 0);
+
+ m_numPendingConnectionRequests = 0;
+}
+
+void PluginProcessProxy::didCreateWebProcessConnection(const CoreIPC::MachPort& machPort)
+{
+ ASSERT(!m_pendingConnectionReplies.isEmpty());
+
+ // Grab the first pending connection reply.
+ RefPtr<WebProcessProxy> replyWebProcessProxy = m_pendingConnectionReplies.first().first.release();
+ CoreIPC::ArgumentEncoder* reply = m_pendingConnectionReplies.first().second;
+ m_pendingConnectionReplies.removeFirst();
+
+ // FIXME: This is Mac specific.
+ reply->encode(CoreIPC::MachPort(machPort.port(), MACH_MSG_TYPE_MOVE_SEND));
+ replyWebProcessProxy->connection()->sendSyncReply(reply);
+}
+
+} // 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 0000000..23a6df0
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.h
@@ -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.
+ */
+
+#ifndef PluginProcessProxy_h
+#define PluginProcessProxy_h
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "Connection.h"
+#include "PluginInfoStore.h"
+#include "ProcessLauncher.h"
+#include <wtf/Deque.h>
+
+// FIXME: This is platform specific.
+namespace CoreIPC {
+ class MachPort;
+}
+
+namespace WebKit {
+
+class PluginProcessManager;
+class WebProcessProxy;
+struct PluginProcessCreationParameters;
+
+class PluginProcessProxy : CoreIPC::Connection::Client, ProcessLauncher::Client {
+public:
+ static PassOwnPtr<PluginProcessProxy> create(PluginProcessManager*, const PluginInfoStore::Plugin&);
+ ~PluginProcessProxy();
+
+ const PluginInfoStore::Plugin& 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 createWebProcessConnection(WebProcessProxy*, CoreIPC::ArgumentEncoder* reply);
+
+private:
+ PluginProcessProxy(PluginProcessManager*, const PluginInfoStore::Plugin&);
+
+ 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);
+
+ // ProcessLauncher::Client
+ virtual void didFinishLaunching(ProcessLauncher*, CoreIPC::Connection::Identifier);
+
+ // Message handlers
+ void didReceivePluginProcessProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didCreateWebProcessConnection(const CoreIPC::MachPort&);
+
+ void platformInitializePluginProcess(PluginProcessCreationParameters& parameters);
+
+ // The plug-in host process manager.
+ PluginProcessManager* m_pluginProcessManager;
+
+ // Information about the plug-in.
+ PluginInfoStore::Plugin 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<std::pair<RefPtr<WebProcessProxy>, CoreIPC::ArgumentEncoder*> > m_pendingConnectionReplies;
+
+ // 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;
+
+};
+
+} // 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 0000000..cbd5abc
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/PluginProcessProxy.messages.in
@@ -0,0 +1,30 @@
+# 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 {
+ # FIXME: This is platform specific
+ DidCreateWebProcessConnection(CoreIPC::MachPort connectionIdentifier)
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoStoreGtk.cpp b/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoStoreGtk.cpp
new file mode 100644
index 0000000..8a6e86c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/gtk/PluginInfoStoreGtk.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#include "NotImplemented.h"
+#include "PluginDatabase.h"
+#include "PluginPackage.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Vector<String> PluginInfoStore::pluginsDirectories()
+{
+ notImplemented();
+ return Vector<String>();
+}
+
+Vector<String> PluginInfoStore::pluginPathsInDirectory(const String& directory)
+{
+ notImplemented();
+ return Vector<String>();
+}
+
+Vector<String> PluginInfoStore::individualPluginPaths()
+{
+ return Vector<String>();
+}
+
+bool PluginInfoStore::getPluginInfo(const String& pluginPath, Plugin& plugin)
+{
+ notImplemented();
+ return false;
+}
+
+bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin)
+{
+ notImplemented();
+ return false;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
new file mode 100644
index 0000000..b787101
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginInfoStoreMac.mm
@@ -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 "PluginInfoStore.h"
+
+#include "NetscapePluginModule.h"
+#include "WebKitSystemInterface.h"
+#include <WebCore/WebCoreNSStringExtras.h>
+#include <wtf/HashSet.h>
+#include <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, Plugin& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin)
+{
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ const Plugin& loadedPlugin = m_plugins[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 0000000..81c8620
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/mac/PluginProcessProxyMac.mm
@@ -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.
+ */
+
+#if ENABLE(PLUGIN_PROCESS)
+
+#include "PluginProcessProxy.h"
+
+#include "PluginProcessCreationParameters.h"
+#include "WebKitSystemInterface.h"
+
+namespace WebKit {
+
+void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters& parameters)
+{
+#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
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp b/Source/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.cpp
new file mode 100644
index 0000000..fc77663
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/qt/PluginInfoStoreQt.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.
+ */
+
+// Note: this file is only for UNIX. On other platforms we can reuse the native implementation.
+
+#include "PluginInfoStore.h"
+
+#include "NetscapePluginModule.h"
+#include "PluginDatabase.h"
+#include "PluginPackage.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+Vector<String> PluginInfoStore::pluginsDirectories()
+{
+ return PluginDatabase::defaultPluginDirectories();
+}
+
+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, Plugin& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+bool PluginInfoStore::shouldUsePlugin(const Plugin& 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 0000000..485f892
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Plugins/win/PluginInfoStoreWin.cpp
@@ -0,0 +1,417 @@
+/*
+ * 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 "PluginInfoStore.h"
+
+#include "NetscapePluginModule.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;
+}
+
+class PathWalker : public Noncopyable {
+public:
+ PathWalker(const String& directory)
+ {
+ String pattern = directory + "\\*";
+ m_handle = ::FindFirstFileW(pattern.charactersWithNullTermination(), &m_data);
+ }
+
+ ~PathWalker()
+ {
+ if (!isValid())
+ return;
+ ::FindClose(m_handle);
+ }
+
+ bool isValid() const { return m_handle != INVALID_HANDLE_VALUE; }
+ const WIN32_FIND_DATAW& data() const { return m_data; }
+
+ bool step() { return ::FindNextFileW(m_handle, &m_data); }
+
+private:
+ HANDLE m_handle;
+ WIN32_FIND_DATAW m_data;
+};
+
+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, Plugin& plugin)
+{
+ return NetscapePluginModule::getPluginInfo(pluginPath, plugin);
+}
+
+static bool isOldWindowsMediaPlayerPlugin(const PluginInfoStore::Plugin& plugin)
+{
+ return equalIgnoringCase(plugin.info.file, "npdsplay.dll");
+}
+
+static bool isNewWindowsMediaPlayerPlugin(const PluginInfoStore::Plugin& plugin)
+{
+ return equalIgnoringCase(plugin.info.file, "np-mswmp.dll");
+}
+
+bool PluginInfoStore::shouldUsePlugin(const Plugin& plugin)
+{
+ // FIXME: We should prefer a newer version of a plugin to an older version, rather than loading
+ // both. <http://webkit.org/b/49075>
+
+ 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 (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 < m_plugins.size(); ++i) {
+ if (!isNewWindowsMediaPlayerPlugin(m_plugins[i]))
+ continue;
+ return false;
+ }
+ return true;
+ }
+
+ if (isNewWindowsMediaPlayerPlugin(plugin)) {
+ // Unload the old Windows Media Player plugin if we've already loaded it.
+ for (size_t i = 0; i < m_plugins.size(); ++i) {
+ if (!isOldWindowsMediaPlayerPlugin(m_plugins[i]))
+ continue;
+ m_plugins.remove(i);
+ }
+ return true;
+ }
+
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/ProcessModel.h b/Source/WebKit2/UIProcess/ProcessModel.h
new file mode 100644
index 0000000..0e89c65
--- /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 0000000..da54a7e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/ResponsivenessTimer.cpp
@@ -0,0 +1,84 @@
+/*
+ * 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 "ResponsivenessTimer.h"
+
+#include "WorkItem.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 0000000..6591916
--- /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 0000000..7415da3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TextChecker.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 TextChecker_h
+#define TextChecker_h
+
+#include <WebCore/EditorClient.h>
+
+namespace WebKit {
+
+class 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);
+#endif
+
+ static int64_t uniqueSpellDocumentTag();
+ static void closeSpellDocumentWithTag(int64_t);
+
+ static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
+ static void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
+ static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
+ static void learnWord(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 0000000..b687192
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp
@@ -0,0 +1,624 @@
+/*
+ * 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 "TiledDrawingAreaProxy.h"
+
+#if ENABLE(TILED_BACKING_STORE)
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "MessageID.h"
+#include "UpdateChunk.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static const int defaultTileWidth = 1024;
+static const int defaultTileHeight = 1024;
+
+PassOwnPtr<TiledDrawingAreaProxy> TiledDrawingAreaProxy::create(PlatformWebView* webView, WebPageProxy* webPageProxy)
+{
+ return adoptPtr(new TiledDrawingAreaProxy(webView, webPageProxy));
+}
+
+TiledDrawingAreaProxy::TiledDrawingAreaProxy(PlatformWebView* webView, WebPageProxy* webPageProxy)
+ : DrawingAreaProxy(DrawingAreaInfo::Tiled, webPageProxy)
+ , m_isWaitingForDidSetFrameNotification(false)
+ , m_isVisible(true)
+ , m_webView(webView)
+ , m_tileBufferUpdateTimer(RunLoop::main(), this, &TiledDrawingAreaProxy::tileBufferUpdateTimerFired)
+ , m_tileCreationTimer(RunLoop::main(), this, &TiledDrawingAreaProxy::tileCreationTimerFired)
+ , m_tileSize(defaultTileWidth, defaultTileHeight)
+ , m_tileCreationDelay(0.01)
+ , m_keepAreaMultiplier(2.5, 4.5)
+ , m_coverAreaMultiplier(2, 3)
+ , m_contentsScale(1)
+{
+}
+
+TiledDrawingAreaProxy::~TiledDrawingAreaProxy()
+{
+}
+
+void TiledDrawingAreaProxy::sizeDidChange()
+{
+ WebPageProxy* page = this->page();
+ if (!page || !page->isValid())
+ return;
+
+ if (m_size.isEmpty())
+ return;
+
+ m_viewSize = m_size;
+ m_lastSetViewSize = m_size;
+
+ if (m_isWaitingForDidSetFrameNotification)
+ return;
+ m_isWaitingForDidSetFrameNotification = true;
+
+ page->process()->responsivenessTimer()->start();
+ page->process()->send(DrawingAreaLegacyMessage::SetSize, page->pageID(), CoreIPC::In(m_size));
+}
+
+void TiledDrawingAreaProxy::setPageIsVisible(bool isVisible)
+{
+ WebPageProxy* page = this->page();
+
+ if (isVisible == m_isVisible)
+ return;
+
+ m_isVisible = isVisible;
+ if (!page || !page->isValid())
+ return;
+
+ if (!m_isVisible) {
+ // Tell the web process that it doesn't need to paint anything for now.
+ page->process()->send(DrawingAreaLegacyMessage::SuspendPainting, page->pageID(), CoreIPC::In());
+ return;
+ }
+
+ // The page is now visible.
+ page->process()->send(DrawingAreaLegacyMessage::ResumePainting, page->pageID(), CoreIPC::In());
+
+ // FIXME: We should request a full repaint here if needed.
+}
+
+void TiledDrawingAreaProxy::didSetSize(const IntSize& viewSize)
+{
+ ASSERT(m_isWaitingForDidSetFrameNotification);
+ m_isWaitingForDidSetFrameNotification = false;
+
+ if (viewSize != m_lastSetViewSize)
+ setSize(m_lastSetViewSize);
+
+ WebPageProxy* page = this->page();
+ page->process()->responsivenessTimer()->stop();
+}
+
+void TiledDrawingAreaProxy::didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+ switch (messageID.get<DrawingAreaProxyLegacyMessage::Kind>()) {
+ case DrawingAreaProxyLegacyMessage::TileUpdated: {
+ int tileID;
+ UpdateChunk updateChunk;
+ float scale;
+ unsigned pendingUpdateCount;
+ if (!arguments->decode(CoreIPC::Out(tileID, updateChunk, scale, pendingUpdateCount)))
+ return;
+
+ TiledDrawingAreaTile* tile = m_tilesByID.get(tileID);
+ ASSERT(!tile || tile->ID() == tileID);
+ if (tile)
+ tile->updateFromChunk(&updateChunk, scale);
+ tileBufferUpdateComplete();
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::DidSetSize: {
+ IntSize size;
+ if (!arguments->decode(CoreIPC::Out(size)))
+ return;
+
+ didSetSize(size);
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::Invalidate: {
+ IntRect rect;
+ if (!arguments->decode(CoreIPC::Out(rect)))
+ return;
+
+ invalidate(rect);
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::AllTileUpdatesProcessed: {
+ tileBufferUpdateComplete();
+ break;
+ }
+ case DrawingAreaProxyLegacyMessage::SnapshotTaken: {
+ UpdateChunk chunk;
+ if (!arguments->decode(CoreIPC::Out(chunk)))
+ return;
+ snapshotTaken(chunk);
+ break;
+ }
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void TiledDrawingAreaProxy::didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void TiledDrawingAreaProxy::requestTileUpdate(int tileID, const IntRect& dirtyRect)
+{
+ page()->process()->connection()->send(DrawingAreaLegacyMessage::RequestTileUpdate, page()->pageID(), CoreIPC::In(tileID, dirtyRect, contentsScale()));
+}
+
+void TiledDrawingAreaProxy::waitUntilUpdatesComplete()
+{
+ while (hasPendingUpdates()) {
+ int tileID;
+ UpdateChunk updateChunk;
+ float scale;
+ unsigned pendingUpdateCount;
+ static const double tileUpdateTimeout = 10.0;
+ OwnPtr<CoreIPC::ArgumentDecoder> arguments = page()->process()->connection()->waitFor(DrawingAreaProxyLegacyMessage::TileUpdated, page()->pageID(), tileUpdateTimeout);
+ if (!arguments)
+ break;
+ if (!arguments->decode(CoreIPC::Out(tileID, updateChunk, scale, pendingUpdateCount)))
+ break;
+ TiledDrawingAreaTile* tile = m_tilesByID.get(tileID);
+ ASSERT(!tile || tile->ID() == tileID);
+ if (tile)
+ tile->updateFromChunk(&updateChunk, scale);
+ }
+ tileBufferUpdateComplete();
+}
+
+PassRefPtr<TiledDrawingAreaTile> TiledDrawingAreaProxy::createTile(const TiledDrawingAreaTile::Coordinate& coordinate)
+{
+ RefPtr<TiledDrawingAreaTile> tile = TiledDrawingAreaTile::create(this, coordinate);
+ setTile(coordinate, tile);
+ return tile;
+}
+
+void TiledDrawingAreaProxy::setTileSize(const IntSize& size)
+{
+ if (m_tileSize == size)
+ return;
+ m_tileSize = size;
+ removeAllTiles();
+ startTileCreationTimer();
+}
+
+void TiledDrawingAreaProxy::setTileCreationDelay(double delay)
+{
+ m_tileCreationDelay = delay;
+}
+
+void TiledDrawingAreaProxy::setKeepAndCoverAreaMultipliers(const FloatSize& keepMultiplier, const FloatSize& coverMultiplier)
+{
+ m_keepAreaMultiplier = keepMultiplier;
+ m_coverAreaMultiplier = coverMultiplier;
+ startTileCreationTimer();
+}
+
+void TiledDrawingAreaProxy::takeSnapshot(const IntSize& size, const IntRect& contentsRect)
+{
+ WebPageProxy* page = this->page();
+ page->process()->send(DrawingAreaLegacyMessage::TakeSnapshot, page->pageID(), CoreIPC::Out(size, contentsRect));
+}
+
+void TiledDrawingAreaProxy::invalidate(const IntRect& contentsDirtyRect)
+{
+ IntRect dirtyRect(mapFromContents(contentsDirtyRect));
+
+ TiledDrawingAreaTile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.topLeft());
+ TiledDrawingAreaTile::Coordinate bottomRight = tileCoordinateForPoint(dirtyRect.bottomRight());
+
+ IntRect coverRect = calculateCoverRect(m_previousVisibleRect);
+
+ Vector<TiledDrawingAreaTile::Coordinate> tilesToRemove;
+
+ for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ RefPtr<TiledDrawingAreaTile> currentTile = tileAt(TiledDrawingAreaTile::Coordinate(xCoordinate, yCoordinate));
+ if (!currentTile)
+ continue;
+ if (!currentTile->rect().intersects(dirtyRect))
+ continue;
+ // If a tile outside out current cover rect gets invalidated, just drop it instead of updating.
+ if (!currentTile->rect().intersects(coverRect)) {
+ tilesToRemove.append(currentTile->coordinate());
+ continue;
+ }
+ currentTile->invalidate(dirtyRect);
+ }
+ }
+
+ unsigned removeCount = tilesToRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ removeTile(tilesToRemove[n]);
+
+ startTileBufferUpdateTimer();
+}
+
+void TiledDrawingAreaProxy::updateTileBuffers()
+{
+ Vector<RefPtr<TiledDrawingAreaTile> > newDirtyTiles;
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ RefPtr<TiledDrawingAreaTile>& current = it->second;
+ if (!current->isDirty())
+ continue;
+ newDirtyTiles.append(it->second);
+ }
+
+ if (newDirtyTiles.isEmpty())
+ return;
+
+ unsigned size = newDirtyTiles.size();
+ for (unsigned n = 0; n < size; ++n)
+ newDirtyTiles[n]->updateBackBuffer();
+}
+
+void TiledDrawingAreaProxy::tileBufferUpdateComplete()
+{
+ // Bail out if all tile back buffers have not been updated.
+ Vector<TiledDrawingAreaTile*> tilesToFlip;
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ RefPtr<TiledDrawingAreaTile>& current = it->second;
+ if (current->isReadyToPaint() && (current->isDirty() || current->hasBackBufferUpdatePending()))
+ return;
+ if (current->hasReadyBackBuffer())
+ tilesToFlip.append(current.get());
+ }
+ // Everything done, move back buffers to front.
+ Vector<IntRect> paintedArea;
+ unsigned size = tilesToFlip.size();
+ for (unsigned n = 0; n < size; ++n) {
+ TiledDrawingAreaTile* tile = tilesToFlip[n];
+ tile->swapBackBufferToFront();
+ // FIXME: should not request system repaint for the full tile.
+ paintedArea.append(mapToContents(tile->rect()));
+ }
+ if (size)
+ updateWebView(paintedArea);
+
+ m_tileCreationTimer.startOneShot(0);
+}
+
+bool TiledDrawingAreaProxy::paint(const IntRect& rect, PlatformDrawingContext context)
+{
+ if (m_isWaitingForDidSetFrameNotification) {
+ WebPageProxy* page = this->page();
+ if (!page->isValid())
+ return false;
+
+ if (page->process()->isLaunching())
+ return false;
+ }
+
+ adjustVisibleRect();
+
+ GraphicsContext gc(context);
+ gc.save();
+
+ // Assumes the backing store is painted with the scale transform applied.
+ // Since tile content is already scaled, first revert the scaling from the painter.
+ gc.scale(FloatSize(1 / m_contentsScale, 1 / m_contentsScale));
+
+ IntRect dirtyRect = mapFromContents(rect);
+
+ TiledDrawingAreaTile::Coordinate topLeft = tileCoordinateForPoint(dirtyRect.topLeft());
+ TiledDrawingAreaTile::Coordinate bottomRight = tileCoordinateForPoint(dirtyRect.bottomRight());
+
+ for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ TiledDrawingAreaTile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
+ RefPtr<TiledDrawingAreaTile> currentTile = tileAt(currentCoordinate);
+ if (currentTile && currentTile->isReadyToPaint())
+ currentTile->paint(&gc, dirtyRect);
+ }
+ }
+
+ gc.restore();
+ return true;
+}
+
+void TiledDrawingAreaProxy::adjustVisibleRect()
+{
+ IntRect visibleRect = mapFromContents(webViewVisibleRect());
+ if (m_previousVisibleRect == visibleRect)
+ return;
+ m_previousVisibleRect = visibleRect;
+
+ startTileCreationTimer();
+}
+
+void TiledDrawingAreaProxy::setContentsScale(float scale)
+{
+ if (m_contentsScale == scale)
+ return;
+ m_contentsScale = scale;
+ removeAllTiles();
+ createTiles();
+}
+
+void TiledDrawingAreaProxy::removeAllTiles()
+{
+ Vector<RefPtr<TiledDrawingAreaTile> > tilesToRemove;
+ copyValuesToVector(m_tiles, tilesToRemove);
+ unsigned removeCount = tilesToRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ removeTile(tilesToRemove[n]->coordinate());
+}
+
+double TiledDrawingAreaProxy::tileDistance(const IntRect& viewport, const TiledDrawingAreaTile::Coordinate& tileCoordinate)
+{
+ if (viewport.intersects(tileRectForCoordinate(tileCoordinate)))
+ return 0;
+
+ IntPoint viewCenter = viewport.location() + IntSize(viewport.width() / 2, viewport.height() / 2);
+ TiledDrawingAreaTile::Coordinate centerCoordinate = tileCoordinateForPoint(viewCenter);
+
+ // Manhattan distance, biased so that vertical distances are shorter.
+ const double horizontalBias = 1.3;
+ return abs(centerCoordinate.y() - tileCoordinate.y()) + horizontalBias * abs(centerCoordinate.x() - tileCoordinate.x());
+}
+
+IntRect TiledDrawingAreaProxy::calculateKeepRect(const IntRect& visibleRect) const
+{
+ IntRect result = visibleRect;
+ result.inflateX(visibleRect.width() * (m_keepAreaMultiplier.width() - 1));
+ result.inflateY(visibleRect.height() * (m_keepAreaMultiplier.height() - 1));
+ result.intersect(contentsRect());
+ return result;
+}
+
+IntRect TiledDrawingAreaProxy::calculateCoverRect(const IntRect& visibleRect) const
+{
+ IntRect result = visibleRect;
+ result.inflateX(visibleRect.width() * (m_coverAreaMultiplier.width() - 1));
+ result.inflateY(visibleRect.height() * (m_coverAreaMultiplier.height() - 1));
+ result.intersect(contentsRect());
+ return result;
+}
+
+void TiledDrawingAreaProxy::createTiles()
+{
+ IntRect visibleRect = mapFromContents(webViewVisibleRect());
+ m_previousVisibleRect = visibleRect;
+
+ if (visibleRect.isEmpty())
+ return;
+
+ // Resize tiles on edges in case the contents size has changed.
+ bool didResizeTiles = resizeEdgeTiles();
+
+ // Remove tiles outside out current maximum keep rect.
+ dropTilesOutsideRect(calculateKeepRect(visibleRect));
+
+ // Cover the cover rect with tiles.
+ IntRect coverRect = calculateCoverRect(visibleRect);
+
+ // Search for the tile position closest to the viewport center that does not yet contain a tile.
+ // Which position is considered the closest depends on the tileDistance function.
+ double shortestDistance = std::numeric_limits<double>::infinity();
+ Vector<TiledDrawingAreaTile::Coordinate> tilesToCreate;
+ unsigned requiredTileCount = 0;
+ bool hasVisibleCheckers = false;
+ TiledDrawingAreaTile::Coordinate topLeft = tileCoordinateForPoint(coverRect.topLeft());
+ TiledDrawingAreaTile::Coordinate bottomRight = tileCoordinateForPoint(coverRect.bottomRight());
+ for (unsigned yCoordinate = topLeft.y(); yCoordinate <= bottomRight.y(); ++yCoordinate) {
+ for (unsigned xCoordinate = topLeft.x(); xCoordinate <= bottomRight.x(); ++xCoordinate) {
+ TiledDrawingAreaTile::Coordinate currentCoordinate(xCoordinate, yCoordinate);
+ // Distance is 0 for all currently visible tiles.
+ double distance = tileDistance(visibleRect, currentCoordinate);
+
+ RefPtr<TiledDrawingAreaTile> tile = tileAt(currentCoordinate);
+ if (!distance && (!tile || !tile->isReadyToPaint()))
+ hasVisibleCheckers = true;
+ if (tile)
+ continue;
+
+ ++requiredTileCount;
+
+ if (distance > shortestDistance)
+ continue;
+ if (distance < shortestDistance) {
+ tilesToCreate.clear();
+ shortestDistance = distance;
+ }
+ tilesToCreate.append(currentCoordinate);
+ }
+ }
+
+ if (hasVisibleCheckers && shortestDistance > 0)
+ return;
+
+ // Now construct the tile(s).
+ unsigned tilesToCreateCount = tilesToCreate.size();
+ for (unsigned n = 0; n < tilesToCreateCount; ++n)
+ createTile(tilesToCreate[n]);
+
+ requiredTileCount -= tilesToCreateCount;
+
+ // Paint the content of the newly created tiles.
+ if (tilesToCreateCount || didResizeTiles)
+ updateTileBuffers();
+
+ // Keep creating tiles until the whole coverRect is covered.
+ if (requiredTileCount)
+ m_tileCreationTimer.startOneShot(m_tileCreationDelay);
+}
+
+bool TiledDrawingAreaProxy::resizeEdgeTiles()
+{
+ IntRect contentsRect = this->contentsRect();
+ bool wasResized = false;
+
+ Vector<TiledDrawingAreaTile::Coordinate> tilesToRemove;
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ TiledDrawingAreaTile::Coordinate tileCoordinate = it->second->coordinate();
+ IntRect tileRect = it->second->rect();
+ IntRect expectedTileRect = tileRectForCoordinate(tileCoordinate);
+ if (!contentsRect.contains(tileRect))
+ tilesToRemove.append(tileCoordinate);
+ else if (expectedTileRect != tileRect) {
+ it->second->resize(expectedTileRect.size());
+ wasResized = true;
+ }
+ }
+ unsigned removeCount = tilesToRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ removeTile(tilesToRemove[n]);
+ return wasResized;
+}
+
+void TiledDrawingAreaProxy::dropTilesOutsideRect(const IntRect& keepRect)
+{
+ FloatRect keepRectF = keepRect;
+
+ Vector<TiledDrawingAreaTile::Coordinate> toRemove;
+ TileMap::iterator end = m_tiles.end();
+ for (TileMap::iterator it = m_tiles.begin(); it != end; ++it) {
+ TiledDrawingAreaTile::Coordinate coordinate = it->second->coordinate();
+ FloatRect tileRect = it->second->rect();
+ if (!tileRect.intersects(keepRectF))
+ toRemove.append(coordinate);
+ }
+ unsigned removeCount = toRemove.size();
+ for (unsigned n = 0; n < removeCount; ++n)
+ removeTile(toRemove[n]);
+}
+
+PassRefPtr<TiledDrawingAreaTile> TiledDrawingAreaProxy::tileAt(const TiledDrawingAreaTile::Coordinate& coordinate) const
+{
+ return m_tiles.get(coordinate);
+}
+
+void TiledDrawingAreaProxy::setTile(const TiledDrawingAreaTile::Coordinate& coordinate, RefPtr<TiledDrawingAreaTile> tile)
+{
+ m_tiles.set(coordinate, tile);
+ m_tilesByID.set(tile->ID(), tile.get());
+}
+
+void TiledDrawingAreaProxy::removeTile(const TiledDrawingAreaTile::Coordinate& coordinate)
+{
+ RefPtr<TiledDrawingAreaTile> tile = m_tiles.take(coordinate);
+
+ m_tilesByID.remove(tile->ID());
+
+ if (!tile->hasBackBufferUpdatePending())
+ return;
+ WebPageProxy* page = this->page();
+ page->process()->send(DrawingAreaLegacyMessage::CancelTileUpdate, page->pageID(), CoreIPC::In(tile->ID()));
+}
+
+IntRect TiledDrawingAreaProxy::mapToContents(const IntRect& rect) const
+{
+ return enclosingIntRect(FloatRect(rect.x() / m_contentsScale,
+ rect.y() / m_contentsScale,
+ rect.width() / m_contentsScale,
+ rect.height() / m_contentsScale));
+}
+
+IntRect TiledDrawingAreaProxy::mapFromContents(const IntRect& rect) const
+{
+ return enclosingIntRect(FloatRect(rect.x() * m_contentsScale,
+ rect.y() * m_contentsScale,
+ rect.width() * m_contentsScale,
+ rect.height() * m_contentsScale));
+}
+
+IntRect TiledDrawingAreaProxy::contentsRect() const
+{
+ return mapFromContents(IntRect(IntPoint(0, 0), m_viewSize));
+}
+
+IntRect TiledDrawingAreaProxy::tileRectForCoordinate(const TiledDrawingAreaTile::Coordinate& coordinate) const
+{
+ IntRect rect(coordinate.x() * m_tileSize.width(),
+ coordinate.y() * m_tileSize.height(),
+ m_tileSize.width(),
+ m_tileSize.height());
+
+ rect.intersect(contentsRect());
+ return rect;
+}
+
+TiledDrawingAreaTile::Coordinate TiledDrawingAreaProxy::tileCoordinateForPoint(const IntPoint& point) const
+{
+ int x = point.x() / m_tileSize.width();
+ int y = point.y() / m_tileSize.height();
+ return TiledDrawingAreaTile::Coordinate(std::max(x, 0), std::max(y, 0));
+}
+
+
+void TiledDrawingAreaProxy::startTileBufferUpdateTimer()
+{
+ if (m_tileBufferUpdateTimer.isActive())
+ return;
+ m_tileBufferUpdateTimer.startOneShot(0);
+}
+
+void TiledDrawingAreaProxy::tileBufferUpdateTimerFired()
+{
+ updateTileBuffers();
+}
+
+void TiledDrawingAreaProxy::startTileCreationTimer()
+{
+ if (m_tileCreationTimer.isActive())
+ return;
+ m_tileCreationTimer.startOneShot(0);
+}
+
+void TiledDrawingAreaProxy::tileCreationTimerFired()
+{
+ createTiles();
+}
+
+bool TiledDrawingAreaProxy::hasPendingUpdates() const
+{
+ TileMap::const_iterator end = m_tiles.end();
+ for (TileMap::const_iterator it = m_tiles.begin(); it != end; ++it) {
+ const RefPtr<TiledDrawingAreaTile>& current = it->second;
+ if (current->hasBackBufferUpdatePending())
+ return true;
+ }
+ return false;
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h
new file mode 100644
index 0000000..80bc20d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h
@@ -0,0 +1,189 @@
+/*
+ * 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 ENABLE(TILED_BACKING_STORE)
+
+#include "DrawingAreaProxy.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntSize.h>
+#include <WebCore/IntRect.h>
+#include <wtf/HashSet.h>
+
+#include "RunLoop.h"
+#include "TiledDrawingAreaTile.h"
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+#ifdef __OBJC__
+@class WKView;
+#else
+class WKView;
+#endif
+#elif PLATFORM(QT)
+class QGraphicsWKView;
+#include <QImage>
+#endif
+
+namespace WebKit {
+
+class UpdateChunk;
+class WebPageProxy;
+
+#if PLATFORM(MAC)
+typedef WKView PlatformWebView;
+#elif PLATFORM(WIN)
+class WebView;
+typedef WebView PlatformWebView;
+#elif PLATFORM(QT)
+typedef QGraphicsWKView PlatformWebView;
+#endif
+
+class TiledDrawingAreaProxy : public DrawingAreaProxy {
+public:
+ static PassOwnPtr<TiledDrawingAreaProxy> create(PlatformWebView* webView, WebPageProxy*);
+
+ TiledDrawingAreaProxy(PlatformWebView*, WebPageProxy*);
+ virtual ~TiledDrawingAreaProxy();
+
+ float contentsScale() const { return m_contentsScale; }
+ void setContentsScale(float);
+
+ void waitUntilUpdatesComplete();
+
+ void takeSnapshot(const WebCore::IntSize& size, const WebCore::IntRect& contentsRect);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void attachCompositingContext(uint32_t /* contextID */) { }
+ virtual void detachCompositingContext() { }
+#endif
+
+ void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+
+ WebCore::IntSize tileSize() { return m_tileSize; }
+ void setTileSize(const WebCore::IntSize&);
+
+ double tileCreationDelay() const { return m_tileCreationDelay; }
+ void setTileCreationDelay(double delay);
+
+ // Tiled are dropped outside the keep area, and created for cover area. The values a relative to the viewport size.
+ void getKeepAndCoverAreaMultipliers(WebCore::FloatSize& keepMultiplier, WebCore::FloatSize& coverMultiplier)
+ {
+ keepMultiplier = m_keepAreaMultiplier;
+ coverMultiplier = m_coverAreaMultiplier;
+ }
+ void setKeepAndCoverAreaMultipliers(const WebCore::FloatSize& keepMultiplier, const WebCore::FloatSize& coverMultiplier);
+
+ void tileBufferUpdateComplete();
+
+ WebCore::IntRect mapToContents(const WebCore::IntRect&) const;
+ WebCore::IntRect mapFromContents(const WebCore::IntRect&) const;
+
+ bool hasPendingUpdates() const;
+
+private:
+ WebPageProxy* page();
+ WebCore::IntRect webViewVisibleRect();
+ void updateWebView(const Vector<WebCore::IntRect>& paintedArea);
+
+ void snapshotTaken(UpdateChunk&);
+
+ // DrawingAreaProxy
+ virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder&);
+ virtual bool paint(const WebCore::IntRect&, PlatformDrawingContext);
+ virtual void sizeDidChange();
+ virtual void setPageIsVisible(bool isVisible);
+
+ void didSetSize(const WebCore::IntSize&);
+ void invalidate(const WebCore::IntRect& rect);
+ void adjustVisibleRect();
+
+ void requestTileUpdate(int tileID, const WebCore::IntRect& dirtyRect);
+
+ PassRefPtr<TiledDrawingAreaTile> createTile(const TiledDrawingAreaTile::Coordinate&);
+
+ void startTileBufferUpdateTimer();
+ void startTileCreationTimer();
+
+ void tileBufferUpdateTimerFired();
+ void tileCreationTimerFired();
+
+ void updateTileBuffers();
+ void createTiles();
+
+ bool resizeEdgeTiles();
+ void dropTilesOutsideRect(const WebCore::IntRect&);
+
+ PassRefPtr<TiledDrawingAreaTile> tileAt(const TiledDrawingAreaTile::Coordinate&) const;
+ void setTile(const TiledDrawingAreaTile::Coordinate& coordinate, RefPtr<TiledDrawingAreaTile> tile);
+ void removeTile(const TiledDrawingAreaTile::Coordinate& coordinate);
+ void removeAllTiles();
+
+ WebCore::IntRect contentsRect() const;
+
+ WebCore::IntRect calculateKeepRect(const WebCore::IntRect& visibleRect) const;
+ WebCore::IntRect calculateCoverRect(const WebCore::IntRect& visibleRect) const;
+
+ WebCore::IntRect tileRectForCoordinate(const TiledDrawingAreaTile::Coordinate&) const;
+ TiledDrawingAreaTile::Coordinate tileCoordinateForPoint(const WebCore::IntPoint&) const;
+ double tileDistance(const WebCore::IntRect& viewport, const TiledDrawingAreaTile::Coordinate&);
+
+private:
+ bool m_isWaitingForDidSetFrameNotification;
+ bool m_isVisible;
+
+ WebCore::IntSize m_viewSize; // Size of the BackingStore as well.
+ WebCore::IntSize m_lastSetViewSize;
+
+ PlatformWebView* m_webView;
+
+ typedef HashMap<TiledDrawingAreaTile::Coordinate, RefPtr<TiledDrawingAreaTile> > TileMap;
+ TileMap m_tiles;
+
+ WTF::HashMap<int, TiledDrawingAreaTile*> m_tilesByID;
+
+ typedef RunLoop::Timer<TiledDrawingAreaProxy> TileTimer;
+ TileTimer m_tileBufferUpdateTimer;
+ TileTimer m_tileCreationTimer;
+
+ WebCore::IntSize m_tileSize;
+ double m_tileCreationDelay;
+ WebCore::FloatSize m_keepAreaMultiplier;
+ WebCore::FloatSize m_coverAreaMultiplier;
+
+ WebCore::IntRect m_previousVisibleRect;
+ float m_contentsScale;
+
+ friend class TiledDrawingAreaTile;
+};
+
+} // namespace WebKit
+
+#endif // TILED_BACKING_STORE
+
+#endif // TiledDrawingAreaProxy_h
diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaTile.h b/Source/WebKit2/UIProcess/TiledDrawingAreaTile.h
new file mode 100644
index 0000000..c818a3f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/TiledDrawingAreaTile.h
@@ -0,0 +1,89 @@
+/*
+ * 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 TiledDrawingAreaTile_h
+#define TiledDrawingAreaTile_h
+
+#include "IntPoint.h"
+#include "IntPointHash.h"
+#include "IntRect.h"
+#include "GraphicsContext.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+#if PLATFORM(QT)
+#include <QPixmap>
+#include <QRegion>
+#endif
+
+namespace WebKit {
+
+class TiledDrawingAreaProxy;
+class UpdateChunk;
+
+class TiledDrawingAreaTile : public RefCounted<TiledDrawingAreaTile> {
+public:
+ typedef WebCore::IntPoint Coordinate;
+
+ static PassRefPtr<TiledDrawingAreaTile> create(TiledDrawingAreaProxy* proxy, const Coordinate& tileCoordinate) { return adoptRef(new TiledDrawingAreaTile(proxy, tileCoordinate)); }
+ ~TiledDrawingAreaTile();
+
+ bool isDirty() const;
+ void invalidate(const WebCore::IntRect&);
+ void updateBackBuffer();
+ bool hasReadyBackBuffer() const;
+ void swapBackBufferToFront();
+ bool isReadyToPaint() const;
+ void paint(WebCore::GraphicsContext*, const WebCore::IntRect&);
+ bool hasBackBufferUpdatePending() const { return m_hasUpdatePending; }
+
+ const TiledDrawingAreaTile::Coordinate& coordinate() const { return m_coordinate; }
+ const WebCore::IntRect& rect() const { return m_rect; }
+ void resize(const WebCore::IntSize&);
+
+ void updateFromChunk(UpdateChunk* updateChunk, float);
+
+ int ID() const { return m_ID; }
+
+private:
+ TiledDrawingAreaTile(TiledDrawingAreaProxy* proxy, const TiledDrawingAreaTile::Coordinate& tileCoordinate);
+
+ TiledDrawingAreaProxy* m_proxy;
+ Coordinate m_coordinate;
+ WebCore::IntRect m_rect;
+
+ int m_ID;
+ bool m_hasUpdatePending;
+
+#if PLATFORM(QT)
+ QPixmap m_buffer;
+ QPixmap m_backBuffer;
+ QRegion m_dirtyRegion;
+#endif
+};
+
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp
new file mode 100644
index 0000000..6beafff
--- /dev/null
+++ b/Source/WebKit2/UIProcess/VisitedLinkProvider.cpp
@@ -0,0 +1,179 @@
+/*
+ * 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 "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;
+
+ m_context->process()->send(Messages::WebProcess::SetVisitedLinkTable(handle), 0);
+ }
+
+ // We now need to let the web process know that we've added links.
+ if (m_webProcessHasVisitedLinkState && addedVisitedLinks.size() <= 20) {
+ m_context->process()->send(Messages::WebProcess::VisitedLinkStateChanged(addedVisitedLinks), 0);
+ return;
+ }
+
+ // Just recalculate all the visited links.
+ m_context->process()->send(Messages::WebProcess::AllVisitedLinkStateChanged(), 0);
+ m_webProcessHasVisitedLinkState = true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/VisitedLinkProvider.h b/Source/WebKit2/UIProcess/VisitedLinkProvider.h
new file mode 100644
index 0000000..015515c
--- /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>
+#include <wtf/Noncopyable.h>
+
+namespace WebKit {
+
+class WebContext;
+
+class VisitedLinkProvider : Noncopyable {
+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/WebBackForwardList.cpp b/Source/WebKit2/UIProcess/WebBackForwardList.cpp
new file mode 100644
index 0000000..b351418
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebBackForwardList.cpp
@@ -0,0 +1,208 @@
+/*
+ * 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 "WebBackForwardList.h"
+
+#include "WebPageProxy.h"
+
+namespace WebKit {
+
+static const unsigned DefaultCapacity = 100;
+static const unsigned NoCurrentItemIndex = UINT_MAX;
+
+WebBackForwardList::WebBackForwardList(WebPageProxy* page)
+ : m_page(page)
+ , m_current(NoCurrentItemIndex)
+ , m_capacity(DefaultCapacity)
+ , m_closed(true)
+ , m_enabled(true)
+{
+}
+
+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)
+{
+ if (m_capacity == 0 || !m_enabled)
+ return;
+
+ // Toss anything in the forward list
+ if (m_current != NoCurrentItemIndex) {
+ unsigned targetSize = m_current + 1;
+ while (m_entries.size() > targetSize) {
+ if (m_page)
+ m_page->backForwardRemovedItem(m_entries.last()->itemID());
+ 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());
+ m_entries.remove(0);
+ m_current--;
+ }
+
+ m_entries.insert(m_current + 1, newItem);
+ m_current++;
+
+ if (m_page)
+ m_page->didChangeBackForwardList();
+}
+
+void WebBackForwardList::goToItem(WebBackForwardListItem* item)
+{
+ 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();
+ }
+}
+
+WebBackForwardListItem* WebBackForwardList::currentItem()
+{
+ if (m_current != NoCurrentItemIndex)
+ return m_entries[m_current].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::backItem()
+{
+ if (m_current && m_current != NoCurrentItemIndex)
+ return m_entries[m_current - 1].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::forwardItem()
+{
+ if (m_entries.size() && m_current < m_entries.size() - 1)
+ return m_entries[m_current + 1].get();
+ return 0;
+}
+
+WebBackForwardListItem* WebBackForwardList::itemAtIndex(int index)
+{
+ // 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()
+{
+ return m_current == NoCurrentItemIndex ? 0 : m_current;
+}
+
+int WebBackForwardList::forwardListCount()
+{
+ return m_current == NoCurrentItemIndex ? 0 : static_cast<int>(m_entries.size()) - (m_current + 1);
+}
+
+PassRefPtr<ImmutableArray> WebBackForwardList::backListAsImmutableArrayWithLimit(unsigned limit)
+{
+ 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)
+{
+ 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()
+{
+ 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());
+ }
+ }
+
+ m_entries.shrink(1);
+ m_entries[0] = currentItem.release();
+
+ m_current = 0;
+
+ if (m_page)
+ m_page->didChangeBackForwardList();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebBackForwardList.h b/Source/WebKit2/UIProcess/WebBackForwardList.h
new file mode 100644
index 0000000..f51ab26
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebBackForwardList.h
@@ -0,0 +1,100 @@
+/*
+ * 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 PLATFORM(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 PLATFORM(CF)
+ CFDictionaryRef createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback, void* context) const;
+ bool restoreFromCFDictionaryRepresentation(CFDictionaryRef);
+#endif
+
+private:
+ 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/WebContext.cpp b/Source/WebKit2/UIProcess/WebContext.cpp
new file mode 100644
index 0000000..2c75cf2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.cpp
@@ -0,0 +1,602 @@
+/*
+ * 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 "WebContext.h"
+
+#include "DownloadProxy.h"
+#include "ImmutableArray.h"
+#include "InjectedBundleMessageKinds.h"
+#include "RunLoop.h"
+#include "SandboxExtension.h"
+#include "TextChecker.h"
+#include "WKContextPrivate.h"
+#include "WebContextMessageKinds.h"
+#include "WebContextUserMessageCoders.h"
+#include "WebCoreArgumentCoders.h"
+#include "WebDatabaseManagerProxy.h"
+#include "WebGeolocationManagerProxy.h"
+#include "WebPageGroup.h"
+#include "WebMemorySampler.h"
+#include "WebProcessCreationParameters.h"
+#include "WebProcessManager.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include <WebCore/Language.h>
+#include <WebCore/LinkHash.h>
+#include <wtf/CurrentTime.h>
+
+#ifndef NDEBUG
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#ifndef NDEBUG
+static WTF::RefCountedLeakCounter webContextCounter("WebContext");
+#endif
+
+WebContext* WebContext::sharedProcessContext()
+{
+ 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)
+{
+ WTF::initializeMainThread();
+ RunLoop::initializeMainRunLoop();
+ return adoptRef(new WebContext(ProcessModelSecondaryProcess, injectedBundlePath));
+}
+
+WebContext::WebContext(ProcessModel processModel, const String& injectedBundlePath)
+ : m_processModel(processModel)
+ , m_defaultPageGroup(WebPageGroup::create())
+ , m_injectedBundlePath(injectedBundlePath)
+ , m_visitedLinkProvider(this)
+ , m_alwaysUsesComplexTextCodePath(false)
+ , m_cacheModel(CacheModelDocumentViewer)
+ , m_clearResourceCachesForNewWebProcess(false)
+ , m_clearApplicationCacheForNewWebProcess(false)
+ , m_memorySamplerEnabled(false)
+ , m_memorySamplerInterval(1400.0)
+ , m_databaseManagerProxy(WebDatabaseManagerProxy::create(this))
+ , m_geolocationManagerProxy(WebGeolocationManagerProxy::create(this))
+#if PLATFORM(WIN)
+ , m_shouldPaintNativeControls(true)
+#endif
+{
+ addLanguageChangeObserver(this, languageChanged);
+
+#ifndef NDEBUG
+ webContextCounter.increment();
+#endif
+}
+
+WebContext::~WebContext()
+{
+ removeLanguageChangeObserver(this);
+
+ WebProcessManager::shared().contextWasDestroyed(this);
+
+ m_geolocationManagerProxy->invalidate();
+ m_geolocationManagerProxy->clearContext();
+
+#ifndef NDEBUG
+ webContextCounter.decrement();
+#endif
+}
+
+void WebContext::initializeInjectedBundleClient(const WKContextInjectedBundleClient* client)
+{
+ m_injectedBundleClient.initialize(client);
+}
+
+void WebContext::initializeHistoryClient(const WKContextHistoryClient* client)
+{
+ m_historyClient.initialize(client);
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::SetShouldTrackVisitedLinks(m_historyClient.shouldTrackVisitedLinks()), 0);
+}
+
+void WebContext::initializeDownloadClient(const WKContextDownloadClient* client)
+{
+ m_downloadClient.initialize(client);
+}
+
+void WebContext::languageChanged(void* context)
+{
+ static_cast<WebContext*>(context)->languageChanged();
+}
+
+void WebContext::languageChanged()
+{
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::LanguageChanged(defaultLanguage()), 0);
+}
+
+void WebContext::ensureWebProcess()
+{
+ if (m_process)
+ return;
+
+ m_process = WebProcessManager::shared().getWebProcess(this);
+
+ WebProcessCreationParameters parameters;
+
+ parameters.applicationCacheDirectory = applicationCacheDirectory();
+
+ 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.clearResourceCaches = m_clearResourceCachesForNewWebProcess;
+ parameters.clearApplicationCache = m_clearApplicationCacheForNewWebProcess;
+#if PLATFORM(MAC)
+ parameters.presenterApplicationPid = getpid();
+#endif
+
+ m_clearResourceCachesForNewWebProcess = false;
+ m_clearApplicationCacheForNewWebProcess = false;
+
+ copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument);
+ copyToVector(m_schemesToRegisterAsSecure, parameters.urlSchemesRegisteredAsSecure);
+ copyToVector(m_schemesToSetDomainRelaxationForbiddenFor, parameters.urlSchemesForWhichDomainRelaxationIsForbidden);
+
+ parameters.shouldAlwaysUseComplexTextCodePath = m_alwaysUsesComplexTextCodePath;
+
+ parameters.textCheckerState = TextChecker::state();
+
+ // 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->send(InjectedBundleMessage::PostMessage, 0, CoreIPC::In(message.first, WebContextUserMessageEncoder(message.second.get())));
+ }
+ m_pendingMessagesToPostToInjectedBundle.clear();
+}
+
+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<uint64_t>(now));
+ sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
+
+ m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, m_memorySamplerInterval), 0);
+ }
+}
+
+void WebContext::processDidClose(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_databaseManagerProxy->invalidate();
+ m_geolocationManagerProxy->invalidate();
+
+ m_process = 0;
+}
+
+WebPageProxy* WebContext::createWebPage(PageClient* pageClient, WebPageGroup* pageGroup)
+{
+ ensureWebProcess();
+
+ if (!pageGroup)
+ pageGroup = m_defaultPageGroup.get();
+
+ return m_process->createWebPage(pageClient, this, pageGroup);
+}
+
+void WebContext::relaunchProcessIfNecessary()
+{
+ ensureWebProcess();
+}
+
+void WebContext::download(WebPageProxy* initiatingPage, const ResourceRequest& request)
+{
+ uint64_t downloadID = createDownloadProxy();
+ uint64_t initiatingPageID = initiatingPage ? initiatingPage->pageID() : 0;
+
+ process()->send(Messages::WebProcess::DownloadRequest(downloadID, initiatingPageID, request), 0);
+}
+
+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->send(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)
+{
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ if (!frame->page())
+ return;
+
+ m_historyClient.didNavigateWithNavigationData(this, frame->page(), store, frame);
+}
+
+void WebContext::didPerformClientRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ if (!frame->page())
+ return;
+
+ m_historyClient.didPerformClientRedirect(this, frame->page(), sourceURLString, destinationURLString, frame);
+}
+
+void WebContext::didPerformServerRedirect(uint64_t pageID, const String& sourceURLString, const String& destinationURLString, uint64_t frameID)
+{
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ if (!frame->page())
+ return;
+
+ m_historyClient.didPerformServerRedirect(this, frame->page(), sourceURLString, destinationURLString, frame);
+}
+
+void WebContext::didUpdateHistoryTitle(uint64_t pageID, const String& title, const String& url, uint64_t frameID)
+{
+ WebFrameProxy* frame = m_process->webFrame(frameID);
+ if (!frame->page())
+ return;
+
+ m_historyClient.didUpdateHistoryTitle(this, frame->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;
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::SetAlwaysUsesComplexTextCodePath(alwaysUseComplexText), 0);
+}
+
+void WebContext::registerURLSchemeAsEmptyDocument(const String& urlScheme)
+{
+ m_schemesToRegisterAsEmptyDocument.add(urlScheme);
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::RegisterURLSchemeAsEmptyDocument(urlScheme), 0);
+}
+
+void WebContext::registerURLSchemeAsSecure(const String& urlScheme)
+{
+ m_schemesToRegisterAsSecure.add(urlScheme);
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme), 0);
+}
+
+void WebContext::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme)
+{
+ m_schemesToSetDomainRelaxationForbiddenFor.add(urlScheme);
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme), 0);
+}
+
+void WebContext::setCacheModel(CacheModel cacheModel)
+{
+ m_cacheModel = cacheModel;
+
+ if (!hasValidProcess())
+ return;
+ m_process->send(Messages::WebProcess::SetCacheModel(static_cast<uint32_t>(m_cacheModel)), 0);
+}
+
+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>& plugins)
+{
+ if (refresh)
+ pluginInfoStore()->refresh();
+ pluginInfoStore()->getPlugins(plugins);
+}
+
+void WebContext::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath)
+{
+ String newMimeType = mimeType.lower();
+
+ PluginInfoStore::Plugin plugin = pluginInfoStore()->findPlugin(newMimeType, KURL(ParsedURLString, urlString));
+ if (!plugin.path)
+ return;
+
+ pluginPath = plugin.path;
+}
+
+uint64_t WebContext::createDownloadProxy()
+{
+ RefPtr<DownloadProxy> downloadProxy = DownloadProxy::create(this);
+ uint64_t downloadID = downloadProxy->downloadID();
+
+ m_downloads.set(downloadID, downloadProxy.release());
+
+ return downloadID;
+}
+
+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::MessageClassWebDatabaseManagerProxy>()) {
+ m_databaseManagerProxy->didReceiveWebDatabaseManagerProxyMessage(connection, messageID, arguments);
+ return;
+ }
+
+ if (messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()) {
+ m_geolocationManagerProxy->didReceiveMessage(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();
+}
+
+CoreIPC::SyncReplyMode WebContext::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)
+{
+ if (messageID.is<CoreIPC::MessageClassWebContext>())
+ return didReceiveSyncWebContextMessage(connection, messageID, arguments, reply);
+
+ if (messageID.is<CoreIPC::MessageClassDownloadProxy>()) {
+ if (DownloadProxy* downloadProxy = m_downloads.get(arguments->destinationID()).get())
+ return downloadProxy->didReceiveSyncDownloadProxyMessage(connection, messageID, arguments, reply);
+
+ return CoreIPC::AutomaticReply;
+ }
+
+ 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 CoreIPC::AutomaticReply;
+
+ RefPtr<APIObject> returnData;
+ didReceiveSynchronousMessageFromInjectedBundle(messageName, messageBody.get(), returnData);
+ reply->encode(CoreIPC::In(WebContextUserMessageEncoder(returnData.get())));
+ return CoreIPC::AutomaticReply;
+ }
+ case WebContextLegacyMessage::PostMessage:
+ ASSERT_NOT_REACHED();
+ }
+
+ return CoreIPC::AutomaticReply;
+}
+
+void WebContext::clearResourceCaches()
+{
+ if (!hasValidProcess()) {
+ // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to
+ // clear the resource cache will be respected. But if the user quits the application before another WebProcess is created,
+ // their request will be ignored.
+ m_clearResourceCachesForNewWebProcess = true;
+ return;
+ }
+
+ m_process->send(Messages::WebProcess::ClearResourceCaches(), 0);
+}
+
+void WebContext::clearApplicationCache()
+{
+ if (!hasValidProcess()) {
+ // FIXME <rdar://problem/8727879>: Setting this flag ensures that the next time a WebProcess is created, this request to
+ // clear the application cache will be respected. But if the user quits the application before another WebProcess is created,
+ // their request will be ignored.
+ m_clearApplicationCacheForNewWebProcess = true;
+ return;
+ }
+
+ m_process->send(Messages::WebProcess::ClearApplicationCache(), 0);
+}
+
+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
+
+ if (!hasValidProcess())
+ return;
+
+ // For WebProcess
+ SandboxExtension::Handle sampleLogSandboxHandle;
+ double now = WTF::currentTime();
+ String sampleLogFilePath = String::format("WebProcess%llu", static_cast<uint64_t>(now));
+ sampleLogFilePath = SandboxExtension::createHandleForTemporaryFile(sampleLogFilePath, SandboxExtension::WriteOnly, sampleLogSandboxHandle);
+
+ m_process->send(Messages::WebProcess::StartMemorySampler(sampleLogSandboxHandle, sampleLogFilePath, interval), 0);
+}
+
+void WebContext::stopMemorySampler()
+{
+ // For WebProcess
+ m_memorySamplerEnabled = false;
+
+ // For UIProcess
+#if ENABLE(MEMORY_SAMPLER)
+ WebMemorySampler::shared()->stop();
+#endif
+
+ if (!hasValidProcess())
+ return;
+
+ m_process->send(Messages::WebProcess::StopMemorySampler(), 0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebContext.h b/Source/WebKit2/UIProcess/WebContext.h
new file mode 100644
index 0000000..9996198
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.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 WebContext_h
+#define WebContext_h
+
+#include "APIObject.h"
+#include "PluginInfoStore.h"
+#include "ProcessModel.h"
+#include "VisitedLinkProvider.h"
+#include "WebContextInjectedBundleClient.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 WebDatabaseManagerProxy;
+class WebGeolocationManagerProxy;
+class WebPageGroup;
+class WebPageProxy;
+struct WebProcessCreationParameters;
+
+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();
+
+ void initializeInjectedBundleClient(const WKContextInjectedBundleClient*);
+ void initializeHistoryClient(const WKContextHistoryClient*);
+ void initializeDownloadClient(const WKContextDownloadClient*);
+
+ ProcessModel processModel() const { return m_processModel; }
+ WebProcessProxy* process() const { return m_process.get(); }
+
+ void processDidFinishLaunching(WebProcessProxy*);
+ void processDidClose(WebProcessProxy*);
+
+ WebPageProxy* createWebPage(PageClient*, WebPageGroup*);
+
+ void relaunchProcessIfNecessary();
+
+ const String& injectedBundlePath() const { return m_injectedBundlePath; }
+
+ void 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 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*);
+ CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+
+ void setCacheModel(CacheModel);
+ CacheModel cacheModel() const { return m_cacheModel; }
+ void clearResourceCaches();
+ void clearApplicationCache();
+
+ void startMemorySampler(const double interval);
+ void stopMemorySampler();
+
+#if PLATFORM(WIN)
+ void setShouldPaintNativeControls(bool);
+#endif
+
+ // Downloads.
+ uint64_t createDownloadProxy();
+ WebDownloadClient& downloadClient() { return m_downloadClient; }
+ void downloadFinished(DownloadProxy*);
+
+ static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
+
+ WebDatabaseManagerProxy* databaseManagerProxy() const { return m_databaseManagerProxy.get(); }
+ WebGeolocationManagerProxy* geolocationManagerProxy() const { return m_geolocationManagerProxy.get(); }
+
+ struct Statistics {
+ unsigned wkViewCount;
+ unsigned wkPageCount;
+ unsigned wkFrameCount;
+ };
+ static Statistics& statistics();
+
+private:
+ WebContext(ProcessModel, const String& injectedBundlePath);
+
+ virtual Type type() const { return APIType; }
+
+ void ensureWebProcess();
+ bool hasValidProcess() const { return m_process && m_process->isValid(); }
+ void platformInitializeWebProcess(WebProcessCreationParameters&);
+
+ // 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>& plugins);
+ void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath);
+
+ // Implemented in generated WebContextMessageReceiver.cpp
+ void didReceiveWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ CoreIPC::SyncReplyMode didReceiveSyncWebContextMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+
+ static void languageChanged(void* context);
+ void languageChanged();
+
+ 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;
+
+ WebHistoryClient m_historyClient;
+
+ PluginInfoStore m_pluginInfoStore;
+ VisitedLinkProvider m_visitedLinkProvider;
+
+ HashSet<String> m_schemesToRegisterAsEmptyDocument;
+ HashSet<String> m_schemesToRegisterAsSecure;
+ HashSet<String> m_schemesToSetDomainRelaxationForbiddenFor;
+
+ bool m_alwaysUsesComplexTextCodePath;
+
+ Vector<pair<String, RefPtr<APIObject> > > m_pendingMessagesToPostToInjectedBundle;
+
+ CacheModel m_cacheModel;
+
+ WebDownloadClient m_downloadClient;
+ HashMap<uint64_t, RefPtr<DownloadProxy> > m_downloads;
+
+ bool m_clearResourceCachesForNewWebProcess;
+ bool m_clearApplicationCacheForNewWebProcess;
+
+ bool m_memorySamplerEnabled;
+ double m_memorySamplerInterval;
+
+ RefPtr<WebDatabaseManagerProxy> m_databaseManagerProxy;
+ RefPtr<WebGeolocationManagerProxy> m_geolocationManagerProxy;
+
+#if PLATFORM(WIN)
+ bool m_shouldPaintNativeControls;
+#endif
+};
+
+} // 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 0000000..dc15de2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContext.messages.in
@@ -0,0 +1,38 @@
+# 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)
+
+}
diff --git a/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.cpp
new file mode 100644
index 0000000..97613f8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextInjectedBundleClient.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 "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 0000000..d5eafc5
--- /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> {
+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 0000000..887a260
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebContextMenuProxy.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 "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 0000000..098552d
--- /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 0000000..bb2ba39
--- /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/WebDatabaseManagerProxy.cpp b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp
new file mode 100644
index 0000000..6f382b7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.cpp
@@ -0,0 +1,222 @@
+/*
+ * 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 "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);
+
+ m_webContext = 0;
+}
+
+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());
+ m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabasesByOrigin(callbackID), 0);
+}
+
+
+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());
+ m_webContext->process()->send(Messages::WebDatabaseManager::GetDatabaseOrigins(callbackID), 0);
+}
+
+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)
+{
+ m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabaseWithNameForOrigin(databaseIdentifier, origin->databaseIdentifier()), 0);
+}
+
+void WebDatabaseManagerProxy::deleteDatabasesForOrigin(WebSecurityOrigin* origin)
+{
+ m_webContext->process()->send(Messages::WebDatabaseManager::DeleteDatabasesForOrigin(origin->databaseIdentifier()), 0);
+}
+
+void WebDatabaseManagerProxy::deleteAllDatabases()
+{
+ m_webContext->process()->send(Messages::WebDatabaseManager::DeleteAllDatabases(), 0);
+}
+
+void WebDatabaseManagerProxy::setQuotaForOrigin(WebSecurityOrigin* origin, uint64_t quota)
+{
+ m_webContext->process()->send(Messages::WebDatabaseManager::SetQuotaForOrigin(origin->databaseIdentifier(), quota), 0);
+}
+
+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 0000000..9878232
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxy.h
@@ -0,0 +1,98 @@
+/*
+ * 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 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 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*);
+
+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 0000000..37a9b89
--- /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 0000000..8ba3a0e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDatabaseManagerProxyClient.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 "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 0000000..f02c130
--- /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> {
+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 0000000..d6a7bcb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDownloadClient.cpp
@@ -0,0 +1,117 @@
+/*
+ * 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 "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::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 0000000..902c870
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebDownloadClient.h
@@ -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.
+ */
+
+#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 DownloadProxy;
+class WebContext;
+
+class WebDownloadClient : public APIClient<WKContextDownloadClient> {
+public:
+ void didStart(WebContext*, DownloadProxy*);
+ 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 0000000..9a816e3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.cpp
@@ -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.
+ */
+
+#include "WebEditCommandProxy.h"
+
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.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());
+ m_page->registerEditCommand(this, WebPageProxy::Undo);
+}
+
+void WebEditCommandProxy::reapply()
+{
+ if (!m_page || !m_page->isValid())
+ return;
+
+ m_page->process()->send(Messages::WebPage::ReapplyEditCommand(m_commandID), m_page->pageID());
+ m_page->registerEditCommand(this, WebPageProxy::Redo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebEditCommandProxy.h b/Source/WebKit2/UIProcess/WebEditCommandProxy.h
new file mode 100644
index 0000000..2d21d3f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebEditCommandProxy.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 WebEditCommandProxy_h
+#define WebEditCommandProxy_h
+
+#include <WebCore/EditAction.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class WebEditCommandProxy : public RefCounted<WebEditCommandProxy> {
+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();
+
+private:
+ WebEditCommandProxy(uint64_t commandID, WebCore::EditAction, WebPageProxy*);
+
+ 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 0000000..e2e8de5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFindClient.cpp
@@ -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.
+ */
+
+#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 0000000..c659c5d
--- /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> {
+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 0000000..159a34c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormClient.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 "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 0000000..40bc685
--- /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> {
+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 0000000..10564a4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFormSubmissionListenerProxy.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 "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 0000000..53ba3b9
--- /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 0000000..c4e38ee
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameListenerProxy.cpp
@@ -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.
+ */
+
+#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 0000000..fd9ad71
--- /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 0000000..865d352
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFramePolicyListenerProxy.cpp
@@ -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.
+ */
+
+#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 0000000..779d2a5
--- /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 0000000..d3a36f9
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameProxy.cpp
@@ -0,0 +1,308 @@
+/*
+ * 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 "WebFrameProxy.h"
+
+#include "WebCertificateInfo.h"
+#include "WebContext.h"
+#include "WebFormSubmissionListenerProxy.h"
+#include "WebFramePolicyListenerProxy.h"
+#include "WebPageProxy.h"
+#include <WebCore/DOMImplementation.h>
+#include <WebCore/Image.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();
+}
+
+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 in the main frame.
+ if (isMainFrame() && !mimeType.isEmpty())
+ return WebContext::pdfAndPostScriptMIMETypes().contains(mimeType);
+#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);
+}
+
+void WebFrameProxy::didStartProvisionalLoad(const String& url)
+{
+ ASSERT(!url.isEmpty());
+ ASSERT(m_loadState == LoadStateFinished);
+ ASSERT(m_provisionalURL.isEmpty());
+ m_loadState = LoadStateProvisional;
+ m_provisionalURL = url;
+}
+
+void WebFrameProxy::didReceiveServerRedirectForProvisionalLoad(const String& url)
+{
+ ASSERT(!url.isEmpty());
+ ASSERT(m_loadState == LoadStateProvisional);
+ ASSERT(!m_provisionalURL.isEmpty());
+ m_provisionalURL = url;
+}
+
+void WebFrameProxy::didFailProvisionalLoad()
+{
+ ASSERT(m_loadState == LoadStateProvisional);
+ ASSERT(!m_provisionalURL.isEmpty());
+ m_loadState = LoadStateFinished;
+ m_provisionalURL = String();
+}
+
+void WebFrameProxy::didCommitLoad(const String& contentType, const PlatformCertificateInfo& certificateInfo)
+{
+ ASSERT(m_loadState == LoadStateProvisional);
+ ASSERT(!m_provisionalURL.isEmpty());
+ 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());
+ ASSERT(!m_url.isEmpty());
+ m_loadState = LoadStateFinished;
+}
+
+void WebFrameProxy::didFailLoad()
+{
+ ASSERT(m_loadState == LoadStateCommitted);
+ ASSERT(m_provisionalURL.isEmpty());
+ ASSERT(!m_url.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);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebFrameProxy.h b/Source/WebKit2/UIProcess/WebFrameProxy.h
new file mode 100644
index 0000000..84c1eb8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebFrameProxy.h
@@ -0,0 +1,159 @@
+/*
+ * 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() { 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; }
+
+ const String& url() const { return m_url; }
+ const String& provisionalURL() const { return m_provisionalURL; }
+
+ void setUnreachableURL(const String& unreachableURL) { m_unreachableURL = unreachableURL; }
+ 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;
+
+ void getWebArchive(PassRefPtr<DataCallback>);
+ void getMainResourceData(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_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/WebGeolocationManagerProxy.cpp b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.cpp
new file mode 100644
index 0000000..0842ca6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationManagerProxy.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 "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;
+
+ // FIXME: Should this check for a valid process?
+ m_context->process()->send(Messages::WebGeolocationManager::DidChangePosition(position->data()), 0);
+}
+
+void WebGeolocationManagerProxy::providerDidFailToDeterminePosition()
+{
+ if (!m_context)
+ return;
+
+ // FIXME: Should this check for a valid process?
+ m_context->process()->send(Messages::WebGeolocationManager::DidFailToDeterminePosition(), 0);
+}
+
+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 0000000..5091693
--- /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 0000000..fe5a273
--- /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 0000000..c48ee89
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebGeolocationProvider.cpp
@@ -0,0 +1,49 @@
+/*
+ * 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 "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 0000000..b5b8bd0
--- /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> {
+public:
+ void startUpdating(WebGeolocationManagerProxy*);
+ void stopUpdating(WebGeolocationManagerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebGeolocationProvider_h
diff --git a/Source/WebKit2/UIProcess/WebHistoryClient.cpp b/Source/WebKit2/UIProcess/WebHistoryClient.cpp
new file mode 100644
index 0000000..d0ca71b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebHistoryClient.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 "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 0000000..bf50748
--- /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> {
+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/WebInspectorProxy.cpp b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
new file mode 100644
index 0000000..dfeff6a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp
@@ -0,0 +1,194 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebInspectorMessages.h"
+#include "WebPageProxy.h"
+#include "WebPageCreationParameters.h"
+#include "WebProcessProxy.h"
+#include "WebPageGroup.h"
+
+#if PLATFORM(WIN)
+#include "WebView.h"
+#endif
+
+#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
+#include "NotImplemented.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageGroup* WebInspectorProxy::inspectorPageGroup()
+{
+ static WebPageGroup* pageGroup = WebPageGroup::create("__WebInspectorPageGroup__", false).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)
+#endif
+{
+}
+
+WebInspectorProxy::~WebInspectorProxy()
+{
+}
+
+void WebInspectorProxy::invalidate()
+{
+ platformClose();
+
+ 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()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::detach()
+{
+ notImplemented();
+}
+
+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;
+}
+
+// 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();
+
+ inspectorPage->loadURL(inspectorPageURL());
+}
+
+void WebInspectorProxy::didLoadInspectorPage()
+{
+ m_isVisible = true;
+
+ platformOpen();
+}
+
+void WebInspectorProxy::didClose()
+{
+ platformClose();
+
+ m_isVisible = false;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(INSPECTOR)
diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.h b/Source/WebKit2/UIProcess/WebInspectorProxy.h
new file mode 100644
index 0000000..cc0725a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.h
@@ -0,0 +1,159 @@
+/*
+ * 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 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>
+#ifdef __OBJC__
+@class NSWindow;
+@class WKView;
+@class WebInspectorProxyObjCAdapter;
+#else
+class NSWindow;
+class WKView;
+class WebInspectorProxyObjCAdapter;
+#endif
+#endif
+
+namespace WebKit {
+
+class WebPageGroup;
+class WebPageProxy;
+struct WebPageCreationParameters;
+
+#if PLATFORM(WIN)
+class WebView;
+#endif
+
+class WebInspectorProxy : public APIObject {
+public:
+ static const Type APIType = TypeInspector;
+
+ static PassRefPtr<WebInspectorProxy> create(WebPageProxy* page)
+ {
+ return adoptRef(new WebInspectorProxy(page));
+ }
+
+ ~WebInspectorProxy();
+
+ void invalidate();
+
+ // Public APIs
+ WebPageProxy* page() { return m_page; }
+
+ bool isVisible() const { return m_isVisible; }
+ void show();
+ void close();
+
+ void showConsole();
+
+ bool isAttached() const { return m_isAttached; }
+ void attach();
+ void detach();
+
+ 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*);
+ CoreIPC::SyncReplyMode didReceiveSyncWebInspectorProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+#endif
+
+private:
+ WebInspectorProxy(WebPageProxy* page);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageProxy* platformCreateInspectorPage();
+ void platformOpen();
+ void platformClose();
+
+ // Implemented the platform WebInspectorProxy file
+ String inspectorPageURL() const;
+
+ // Called by WebInspectorProxy messages
+ void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
+ void didLoadInspectorPage();
+ void didClose();
+
+ 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);
+#endif
+
+ static const unsigned minimumWindowWidth = 500;
+ static const unsigned minimumWindowHeight = 400;
+
+ static const unsigned initialWindowWidth = 750;
+ static const unsigned initialWindowHeight = 650;
+
+ WebPageProxy* m_page;
+
+ bool m_isVisible;
+ bool m_isAttached;
+ bool m_isDebuggingJavaScript;
+ bool m_isProfilingJavaScript;
+ bool m_isProfilingPage;
+
+#if PLATFORM(MAC)
+ RetainPtr<WKView> m_inspectorView;
+ RetainPtr<NSWindow> m_inspectorWindow;
+ RetainPtr<WebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter;
+#elif PLATFORM(WIN)
+ HWND m_inspectorWindow;
+ RefPtr<WebView> m_inspectorView;
+#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 0000000..cc10248
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
@@ -0,0 +1,31 @@
+# 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()
+}
+
+#endif
diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.cpp b/Source/WebKit2/UIProcess/WebLoaderClient.cpp
new file mode 100644
index 0000000..0b14a17
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebLoaderClient.cpp
@@ -0,0 +1,219 @@
+/*
+ * 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 "WebLoaderClient.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);
+}
+
+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)
+{
+ if (!m_client.didChangeBackForwardList)
+ return;
+
+ m_client.didChangeBackForwardList(toAPI(page), m_client.clientInfo);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebLoaderClient.h b/Source/WebKit2/UIProcess/WebLoaderClient.h
new file mode 100644
index 0000000..0c250fe
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebLoaderClient.h
@@ -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.
+ */
+
+#ifndef WebLoaderClient_h
+#define WebLoaderClient_h
+
+#include "APIClient.h"
+#include "SameDocumentNavigationType.h"
+#include "WKPage.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+class ResourceError;
+}
+
+namespace WebKit {
+
+class APIObject;
+class AuthenticationChallengeProxy;
+class AuthenticationDecisionListener;
+class WebFrameProxy;
+class WebPageProxy;
+class WebProtectionSpace;
+
+class WebLoaderClient : public APIClient<WKPageLoaderClient> {
+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*);
+
+ 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*);
+};
+
+} // namespace WebKit
+
+#endif // WebLoaderClient_h
diff --git a/Source/WebKit2/UIProcess/WebNavigationData.cpp b/Source/WebKit2/UIProcess/WebNavigationData.cpp
new file mode 100644
index 0000000..c4f17f3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebNavigationData.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 "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 0000000..e6b6c31
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebNavigationData.h
@@ -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.
+ */
+
+#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; }
+
+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 0000000..de2d174
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp
@@ -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.
+ */
+
+#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 0000000..ba931dc
--- /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 0000000..73220b2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp
@@ -0,0 +1,76 @@
+/*
+ * 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 "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);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageContextMenuClient.h b/Source/WebKit2/UIProcess/WebPageContextMenuClient.h
new file mode 100644
index 0000000..e0fff3d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageContextMenuClient.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 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> {
+public:
+ bool getContextMenuFromProposedMenu(WebPageProxy*, const Vector<WebContextMenuItemData>& proposedMenu, Vector<WebContextMenuItemData>& customMenu, APIObject* userData);
+ void customContextMenuItemSelected(WebPageProxy*, const WebContextMenuItemData&);
+};
+
+} // namespace WebKit
+
+#endif // WebPageContextMenuClient_h
diff --git a/Source/WebKit2/UIProcess/WebPageGroup.cpp b/Source/WebKit2/UIProcess/WebPageGroup.cpp
new file mode 100644
index 0000000..901b393
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageGroup.cpp
@@ -0,0 +1,120 @@
+/*
+ * 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 "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()
+{
+ static WebPageGroupMap map;
+ return map;
+}
+
+PassRefPtr<WebPageGroup> WebPageGroup::create(const String& identifier, bool visibleToInjectedBundle)
+{
+ RefPtr<WebPageGroup> pageGroup = adoptRef(new WebPageGroup(identifier, visibleToInjectedBundle));
+
+ 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)
+{
+ m_data.pageGroupID = generatePageGroupID();
+
+ if (!identifier.isNull()) {
+ m_data.identifer = identifier;
+ m_preferences = WebPreferences::create(identifier);
+ } else {
+ m_data.identifer = m_data.identifer = makeString("__uniquePageGroupID-", String::number(m_data.pageGroupID));
+ m_preferences = WebPreferences::create();
+ }
+ m_preferences->addPageGroup(this);
+
+ m_data.visibleToInjectedBundle = visibleToInjectedBundle;
+}
+
+WebPageGroup::~WebPageGroup()
+{
+ 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;
+
+ m_preferences->removePageGroup(this);
+ m_preferences = preferences;
+ m_preferences->addPageGroup(this);
+
+ preferencesDidChange();
+}
+
+WebPreferences* WebPageGroup::preferences() const
+{
+ 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 0000000..7859dfc
--- /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);
+ 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);
+
+ virtual Type type() const { return APIType; }
+
+ WebPageGroupData m_data;
+ 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 0000000..f433fbd
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -0,0 +1,2367 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include "AuthenticationChallengeProxy.h"
+#include "AuthenticationDecisionListener.h"
+#include "DataReference.h"
+#include "DrawingAreaProxy.h"
+#include "FindIndicator.h"
+#include "MessageID.h"
+#include "NativeWebKeyboardEvent.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 "WebOpenPanelResultListenerProxy.h"
+#include "WebPageCreationParameters.h"
+#include "WebPageGroup.h"
+#include "WebPageGroupData.h"
+#include "WebPageMessages.h"
+#include "WebPopupItem.h"
+#include "WebPopupMenuProxy.h"
+#include "WebPreferences.h"
+#include "WebProcessManager.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxy.h"
+#include "WebProtectionSpace.h"
+#include "WebSecurityOrigin.h"
+#include "WebURLRequest.h"
+#include <WebCore/DragData.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/MIMETypeRegistry.h>
+#include <WebCore/WindowFeatures.h>
+#include <stdio.h>
+
+#ifndef NDEBUG
+#include <wtf/RefCountedLeakCounter.h>
+#endif
+
+// This controls what strategy we use for mouse wheel coalesing.
+#define MERGE_WHEEL_EVENTS 0
+
+#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, process()->connection())
+
+using namespace WebCore;
+
+namespace WebKit {
+
+#ifndef NDEBUG
+static WTF::RefCountedLeakCounter webPageProxyCounter("WebPageProxy");
+#endif
+
+PassRefPtr<WebPageProxy> WebPageProxy::create(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup, uint64_t pageID)
+{
+ return adoptRef(new WebPageProxy(pageClient, context, pageGroup, pageID));
+}
+
+WebPageProxy::WebPageProxy(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup, uint64_t pageID)
+ : m_pageClient(pageClient)
+ , m_context(context)
+ , m_pageGroup(pageGroup)
+ , m_mainFrame(0)
+ , m_userAgent(standardUserAgent())
+ , m_geolocationPermissionRequestManager(this)
+ , m_estimatedProgress(0)
+ , m_isInWindow(m_pageClient->isViewInWindow())
+ , m_isVisible(m_pageClient->isViewVisible())
+ , m_backForwardList(WebBackForwardList::create(this))
+ , m_textZoomFactor(1)
+ , m_pageZoomFactor(1)
+ , m_viewScaleFactor(1)
+ , m_drawsBackground(true)
+ , m_drawsTransparentBackground(false)
+ , m_useFixedLayout(false)
+ , m_isValid(true)
+ , m_isClosed(false)
+ , m_isInPrintingMode(false)
+ , m_inDecidePolicyForMIMEType(false)
+ , m_syncMimeTypePolicyActionIsValid(false)
+ , m_syncMimeTypePolicyAction(PolicyUse)
+ , m_syncMimeTypePolicyDownloadID(0)
+ , m_processingWheelEvent(false)
+ , m_processingMouseMoveEvent(false)
+ , m_pageID(pageID)
+#if PLATFORM(MAC)
+ , m_isSmartInsertDeleteEnabled(TextChecker::isSmartInsertDeleteEnabled())
+#endif
+ , m_spellDocumentTag(0)
+ , m_hasSpellDocumentTag(false)
+ , m_pendingLearnOrIgnoreWordMessageCount(0)
+ , m_mainFrameHasCustomRepresentation(false)
+ , m_currentDragOperation(DragOperationNone)
+{
+#ifndef NDEBUG
+ webPageProxyCounter.increment();
+#endif
+
+ WebContext::statistics().wkPageCount++;
+
+ m_pageGroup->addPage(this);
+}
+
+WebPageProxy::~WebPageProxy()
+{
+ 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_context->process();
+}
+
+bool WebPageProxy::isValid()
+{
+ // A page that has been explicitly closed is never valid.
+ if (m_isClosed)
+ return false;
+
+ return m_isValid;
+}
+
+void WebPageProxy::setDrawingArea(PassOwnPtr<DrawingAreaProxy> drawingArea)
+{
+ if (drawingArea == m_drawingArea)
+ return;
+
+ m_drawingArea = drawingArea;
+}
+
+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)
+{
+ m_uiClient.initialize(client);
+}
+
+void WebPageProxy::initializeFindClient(const WKPageFindClient* client)
+{
+ m_findClient.initialize(client);
+}
+
+void WebPageProxy::initializeContextMenuClient(const WKPageContextMenuClient* client)
+{
+ m_contextMenuClient.initialize(client);
+}
+
+void WebPageProxy::reattachToWebProcess()
+{
+ m_isValid = true;
+
+ context()->relaunchProcessIfNecessary();
+ process()->addExistingWebPage(this, m_pageID);
+
+ initializeWebPage();
+
+ m_pageClient->didRelaunchProcess();
+}
+
+void WebPageProxy::reattachToWebProcessWithItem(WebBackForwardListItem* item)
+{
+ if (item && item != m_backForwardList->currentItem())
+ m_backForwardList->goToItem(item);
+
+ reattachToWebProcess();
+ process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
+}
+
+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();
+
+ process()->disconnectFramesFromPage(this);
+ m_mainFrame = 0;
+
+#if ENABLE(INSPECTOR)
+ if (m_inspector) {
+ m_inspector->invalidate();
+ m_inspector = 0;
+ }
+#endif
+
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+ }
+
+ m_geolocationPermissionRequestManager.invalidateRequests();
+
+ m_toolTip = String();
+
+ invalidateCallbackMap(m_dataCallbacks);
+ invalidateCallbackMap(m_stringCallbacks);
+
+ 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.clear();
+
+ 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);
+ return false;
+}
+
+static void initializeSandboxExtensionHandle(const KURL& url, SandboxExtension::Handle& sandboxExtensionHandle)
+{
+ if (!url.isLocalFile())
+ return;
+
+ SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle);
+}
+
+void WebPageProxy::loadURL(const String& url)
+{
+ if (!isValid())
+ reattachToWebProcess();
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ initializeSandboxExtensionHandle(KURL(KURL(), url), sandboxExtensionHandle);
+ process()->send(Messages::WebPage::LoadURL(url, sandboxExtensionHandle), m_pageID);
+}
+
+void WebPageProxy::loadURLRequest(WebURLRequest* urlRequest)
+{
+ if (!isValid())
+ reattachToWebProcess();
+
+ SandboxExtension::Handle sandboxExtensionHandle;
+ initializeSandboxExtensionHandle(urlRequest->resourceRequest().url(), sandboxExtensionHandle);
+ process()->send(Messages::WebPage::LoadURLRequest(urlRequest->resourceRequest(), sandboxExtensionHandle), m_pageID);
+}
+
+void WebPageProxy::loadHTMLString(const String& htmlString, const String& baseURL)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::LoadHTMLString(htmlString, baseURL), m_pageID);
+}
+
+void WebPageProxy::loadAlternateHTMLString(const String& htmlString, const String& baseURL, const String& unreachableURL)
+{
+ if (!isValid())
+ return;
+
+ if (!m_mainFrame)
+ return;
+
+ m_mainFrame->setUnreachableURL(unreachableURL);
+ process()->send(Messages::WebPage::LoadAlternateHTMLString(htmlString, baseURL, unreachableURL), m_pageID);
+}
+
+void WebPageProxy::loadPlainTextString(const String& string)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::LoadPlainTextString(string), m_pageID);
+}
+
+void WebPageProxy::stopLoading()
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::StopLoading(), m_pageID);
+}
+
+void WebPageProxy::reload(bool reloadFromOrigin)
+{
+ if (!isValid()) {
+ reattachToWebProcessWithItem(m_backForwardList->currentItem());
+ return;
+ }
+
+ process()->send(Messages::WebPage::Reload(reloadFromOrigin), m_pageID);
+}
+
+void WebPageProxy::goForward()
+{
+ if (!isValid()) {
+ reattachToWebProcessWithItem(m_backForwardList->forwardItem());
+ return;
+ }
+
+ if (!canGoForward())
+ return;
+
+ process()->send(Messages::WebPage::GoForward(m_backForwardList->forwardItem()->itemID()), m_pageID);
+}
+
+bool WebPageProxy::canGoForward() const
+{
+ return m_backForwardList->forwardItem();
+}
+
+void WebPageProxy::goBack()
+{
+ if (!isValid()) {
+ reattachToWebProcessWithItem(m_backForwardList->backItem());
+ return;
+ }
+
+ if (!canGoBack())
+ return;
+
+ process()->send(Messages::WebPage::GoBack(m_backForwardList->backItem()->itemID()), m_pageID);
+}
+
+bool WebPageProxy::canGoBack() const
+{
+ return m_backForwardList->backItem();
+}
+
+void WebPageProxy::goToBackForwardItem(WebBackForwardListItem* item)
+{
+ if (!isValid()) {
+ reattachToWebProcessWithItem(item);
+ return;
+ }
+
+ process()->send(Messages::WebPage::GoToBackForwardItem(item->itemID()), m_pageID);
+}
+
+void WebPageProxy::didChangeBackForwardList()
+{
+ m_loaderClient.didChangeBackForwardList(this);
+}
+
+
+bool WebPageProxy::canShowMIMEType(const String& mimeType) const
+{
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType))
+ return true;
+
+ if (MIMETypeRegistry::isSupportedImageMIMEType(mimeType))
+ return true;
+
+ String newMimeType = mimeType;
+ PluginInfoStore::Plugin plugin = 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::setViewNeedsDisplay(const IntRect& rect)
+{
+ m_pageClient->setViewNeedsDisplay(rect);
+}
+
+void WebPageProxy::displayView()
+{
+ m_pageClient->displayView();
+}
+
+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->setPageIsVisible(isVisible);
+ }
+ }
+
+ if (flags & ViewIsInWindow) {
+ bool isInWindow = m_pageClient->isViewInWindow();
+ if (m_isInWindow != isInWindow) {
+ m_isInWindow = isInWindow;
+ process()->send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
+ }
+ }
+}
+
+IntSize WebPageProxy::viewSize() const
+{
+ return m_pageClient->viewSize();
+}
+
+void WebPageProxy::setInitialFocus(bool forward)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetInitialFocus(forward), m_pageID);
+}
+
+void WebPageProxy::setWindowResizerSize(const IntSize& windowResizerSize)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::SetWindowResizerSize(windowResizerSize), m_pageID);
+}
+
+void WebPageProxy::validateMenuItem(const String& commandName)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::ValidateMenuItem(commandName), m_pageID);
+}
+
+void WebPageProxy::executeEditCommand(const String& commandName)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::ExecuteEditCommand(commandName), m_pageID);
+}
+
+#if PLATFORM(MAC)
+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::getMarkedRange(uint64_t& location, uint64_t& length)
+{
+ process()->sendSync(Messages::WebPage::GetMarkedRange(), Messages::WebPage::GetMarkedRange::Reply(location, length), m_pageID);
+}
+
+uint64_t WebPageProxy::characterIndexForPoint(const IntPoint point)
+{
+ uint64_t result;
+ process()->sendSync(Messages::WebPage::CharacterIndexForPoint(point), Messages::WebPage::CharacterIndexForPoint::Reply(result), m_pageID);
+ return result;
+}
+
+WebCore::IntRect WebPageProxy::firstRectForCharacterRange(uint64_t location, uint64_t length)
+{
+ IntRect resultRect;
+ process()->sendSync(Messages::WebPage::FirstRectForCharacterRange(location, length), Messages::WebPage::FirstRectForCharacterRange::Reply(resultRect), m_pageID);
+ return resultRect;
+}
+#elif PLATFORM(WIN)
+WebCore::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;
+}
+#endif
+
+#if ENABLE(TILED_BACKING_STORE)
+void WebPageProxy::setActualVisibleContentRect(const IntRect& rect)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SetActualVisibleContentRect(rect), m_pageID);
+}
+#endif
+
+void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags()), m_pageID);
+}
+
+void WebPageProxy::didPerformDragControllerAction(uint64_t resultOperation)
+{
+ m_currentDragOperation = static_cast<DragOperation>(resultOperation);
+}
+
+void WebPageProxy::handleMouseEvent(const WebMouseEvent& 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 WebMouseEvent(event));
+ return;
+ }
+
+ m_processingMouseMoveEvent = true;
+ }
+
+ process()->send(Messages::WebPage::MouseEvent(event), m_pageID);
+}
+
+static PassOwnPtr<WebWheelEvent> coalesceWheelEvents(WebWheelEvent* oldNextWheelEvent, const WebWheelEvent& newWheelEvent)
+{
+#if MERGE_WHEEL_EVENTS
+ // Merge model: Combine wheel event deltas (and wheel ticks) into a single wheel event.
+ if (!oldNextWheelEvent)
+ return adoptPtr(new WebWheelEvent(newWheelEvent));
+
+ if (oldNextWheelEvent->position() != newWheelEvent.position() || oldNextWheelEvent->modifiers() != newWheelEvent.modifiers() || oldNextWheelEvent->granularity() != newWheelEvent.granularity())
+ return adoptPtr(new WebWheelEvent(newWheelEvent));
+
+ FloatSize mergedDelta = oldNextWheelEvent->delta() + newWheelEvent.delta();
+ FloatSize mergedWheelTicks = oldNextWheelEvent->wheelTicks() + newWheelEvent.wheelTicks();
+
+ return adoptPtr(new WebWheelEvent(WebEvent::Wheel, newWheelEvent.position(), newWheelEvent.globalPosition(), mergedDelta, mergedWheelTicks, newWheelEvent.granularity(), newWheelEvent.modifiers(), newWheelEvent.timestamp()));
+#else
+ // Simple model: Just keep the last event, dropping all interim events.
+ return adoptPtr(new WebWheelEvent(newWheelEvent));
+#endif
+}
+
+void WebPageProxy::handleWheelEvent(const WebWheelEvent& event)
+{
+ if (!isValid())
+ return;
+
+ if (m_processingWheelEvent) {
+ m_nextWheelEvent = coalesceWheelEvents(m_nextWheelEvent.get(), event);
+ return;
+ }
+
+ process()->responsivenessTimer()->start();
+ process()->send(Messages::WebPage::WheelEvent(event), m_pageID);
+ m_processingWheelEvent = true;
+}
+
+void WebPageProxy::handleKeyboardEvent(const NativeWebKeyboardEvent& event)
+{
+ if (!isValid())
+ return;
+
+ m_keyEventQueue.append(event);
+
+ process()->responsivenessTimer()->start();
+ process()->send(Messages::WebPage::KeyEvent(event), m_pageID);
+}
+
+#if ENABLE(TOUCH_EVENTS)
+void WebPageProxy::handleTouchEvent(const WebTouchEvent& event)
+{
+ if (!isValid())
+ return;
+ process()->send(Messages::WebPage::TouchEvent(event), m_pageID);
+}
+#endif
+
+void WebPageProxy::receivedPolicyDecision(PolicyAction action, WebFrameProxy* frame, uint64_t listenerID)
+{
+ if (!isValid())
+ return;
+
+ uint64_t downloadID = 0;
+ if (action == PolicyDownload) {
+ // Create a download proxy.
+ downloadID = context()->createDownloadProxy();
+ }
+
+ // If we received a policy decision while in decidePolicyForMIMEType the decision will
+ // be sent back to the web process by decidePolicyForMIMEType.
+ if (m_inDecidePolicyForMIMEType) {
+ m_syncMimeTypePolicyActionIsValid = true;
+ m_syncMimeTypePolicyAction = action;
+ m_syncMimeTypePolicyDownloadID = 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()
+{
+ if (!isValid())
+ return;
+
+ process()->terminate();
+}
+
+#if !PLATFORM(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::scaleWebView(double scale, const IntPoint& origin)
+{
+ if (!isValid())
+ return;
+
+ if (m_viewScaleFactor == scale)
+ return;
+
+ m_viewScaleFactor = scale;
+ process()->send(Messages::WebPage::ScaleWebView(scale, origin), m_pageID);
+}
+
+void WebPageProxy::setUseFixedLayout(bool fixed)
+{
+ if (!isValid())
+ return;
+
+ 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::findString(const String& string, FindOptions options, unsigned maxMatchCount)
+{
+ 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)
+{
+ process()->send(Messages::WebPage::CountStringMatches(string, options, maxMatchCount), m_pageID);
+}
+
+void WebPageProxy::runJavaScriptInMainFrame(const String& script, PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_stringCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::RunJavaScriptInMainFrame(script, callbackID), m_pageID);
+}
+
+void WebPageProxy::getRenderTreeExternalRepresentation(PassRefPtr<StringCallback> prpCallback)
+{
+ RefPtr<StringCallback> callback = prpCallback;
+ 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;
+ uint64_t callbackID = callback->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;
+ uint64_t callbackID = callback->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;
+ 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;
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetMainResourceDataOfFrame(frame->frameID(), callbackID), m_pageID);
+}
+
+void WebPageProxy::getWebArchiveOfFrame(WebFrameProxy* frame, PassRefPtr<DataCallback> prpCallback)
+{
+ RefPtr<DataCallback> callback = prpCallback;
+ uint64_t callbackID = callback->callbackID();
+ m_dataCallbacks.set(callbackID, callback.get());
+ process()->send(Messages::WebPage::GetWebArchiveOfFrame(frame->frameID(), 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.
+ process()->send(Messages::WebPage::PreferencesDidChange(pageGroup()->preferences()->store()), m_pageID);
+}
+
+#if ENABLE(TILED_BACKING_STORE)
+void WebPageProxy::setResizesToContentsUsingLayoutSize(const WebCore::IntSize& targetLayoutSize)
+{
+ process()->send(Messages::WebPage::SetResizesToContentsUsingLayoutSize(targetLayoutSize), m_pageID);
+}
+#endif
+
+void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments)
+{
+#ifdef __APPLE__
+ if (messageID.is<CoreIPC::MessageClassDrawingAreaProxy>()) {
+ m_drawingArea->didReceiveDrawingAreaProxyMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
+ if (messageID.is<CoreIPC::MessageClassDrawingAreaProxyLegacy>()) {
+ m_drawingArea->didReceiveMessage(connection, messageID, arguments);
+ return;
+ }
+
+#if ENABLE(INSPECTOR)
+ if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
+ if (WebInspectorProxy* inspector = this->inspector())
+ inspector->didReceiveWebInspectorProxyMessage(connection, messageID, arguments);
+ return;
+ }
+#endif
+
+ didReceiveWebPageProxyMessage(connection, messageID, arguments);
+}
+
+void WebPageProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)
+{
+ if (messageID.is<CoreIPC::MessageClassDrawingAreaProxyLegacy>()) {
+ m_drawingArea->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return;
+ }
+
+#if ENABLE(INSPECTOR)
+ if (messageID.is<CoreIPC::MessageClassWebInspectorProxy>()) {
+ if (WebInspectorProxy* inspector = this->inspector())
+ inspector->didReceiveSyncWebInspectorProxyMessage(connection, messageID, arguments, reply);
+ return;
+ }
+#endif
+
+ // FIXME: Do something with reply.
+ didReceiveSyncWebPageProxyMessage(connection, messageID, arguments, reply);
+}
+
+#if PLATFORM(MAC)
+void WebPageProxy::interpretKeyEvent(uint32_t type, Vector<KeypressCommand>& commandsList, uint32_t selectionStart, uint32_t selectionEnd, Vector<CompositionUnderline>& underlines)
+{
+ m_pageClient->interceptKeyEvent(m_keyEventQueue.first(), commandsList, selectionStart, selectionEnd, underlines);
+}
+#endif
+
+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());
+}
+
+void WebPageProxy::didSaveFrameToPageCache(uint64_t frameID)
+{
+ MESSAGE_CHECK(m_mainFrame);
+
+ WebFrameProxy* subframe = process()->webFrame(frameID);
+ MESSAGE_CHECK(subframe);
+
+ if (!subframe->parentFrame())
+ 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);
+}
+
+void WebPageProxy::didStartProgress()
+{
+ m_estimatedProgress = 0.0;
+
+ 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, bool loadingSubstituteDataForUnreachableURL, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ if (!loadingSubstituteDataForUnreachableURL)
+ frame->setUnreachableURL(String());
+
+ 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, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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, 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::didCommitLoadForFrame(uint64_t frameID, const String& mimeType, bool frameHasCustomRepresentation, const PlatformCertificateInfo& certificateInfo, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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, 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, 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, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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, 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, 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, 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, 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, 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, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_loaderClient.didRunInsecureContentForFrame(this, frame, userData.get());
+}
+
+void WebPageProxy::didReceiveAccessibilityPageToken(const CoreIPC::DataReference& data)
+{
+#if PLATFORM(MAC)
+ m_pageClient->accessibilityChildTokenReceived(data);
+#endif
+}
+
+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 String& url, uint64_t listenerID)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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.decidePolicyForNavigationAction(this, navigationType, modifiers, mouseButton, url, frame, listener.get()))
+ listener->use();
+}
+
+void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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, navigationType, modifiers, mouseButton, url, frame, listener.get()))
+ listener->use();
+}
+
+void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
+
+ ASSERT(!m_inDecidePolicyForMIMEType);
+
+ m_inDecidePolicyForMIMEType = true;
+ m_syncMimeTypePolicyActionIsValid = false;
+
+ if (!m_policyClient.decidePolicyForMIMEType(this, MIMEType, url, frame, listener.get()))
+ listener->use();
+
+ m_inDecidePolicyForMIMEType = false;
+
+ // Check if we received a policy decision already. If we did, we can just pass it back.
+ if (m_syncMimeTypePolicyActionIsValid) {
+ receivedPolicyAction = true;
+ policyAction = m_syncMimeTypePolicyAction;
+ downloadID = m_syncMimeTypePolicyDownloadID;
+ }
+}
+
+// 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, 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)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_resourceLoadClient.didInitiateLoadForResource(this, frame, resourceIdentifier, request);
+}
+
+void WebPageProxy::didSendRequestForResource(uint64_t frameID, uint64_t resourceIdentifier, const ResourceRequest& request, const ResourceResponse& redirectResponse)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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);
+
+ 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 WindowFeatures& windowFeatures, uint32_t opaqueModifiers, int32_t opaqueMouseButton, uint64_t& newPageID, WebPageCreationParameters& newPageParameters)
+{
+ RefPtr<WebPageProxy> newPage = m_uiClient.createNewPage(this, 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()
+{
+ m_uiClient.close(this);
+}
+
+void WebPageProxy::runJavaScriptAlert(uint64_t frameID, const String& message)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ 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);
+
+ 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);
+
+ result = m_uiClient.runJavaScriptPrompt(this, message, defaultValue, frame);
+}
+
+void WebPageProxy::setStatusText(const String& text)
+{
+ m_uiClient.setStatusText(this, text);
+}
+
+void WebPageProxy::mouseDidMoveOverElement(uint32_t opaqueModifiers, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ WebEvent::Modifiers modifiers = static_cast<WebEvent::Modifiers>(opaqueModifiers);
+
+ m_uiClient.mouseDidMoveOverElement(this, modifiers, userData.get());
+}
+
+void WebPageProxy::missingPluginButtonClicked(const String& mimeType, const String& url)
+{
+ m_uiClient.missingPluginButtonClicked(this, mimeType, url);
+}
+
+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::canRunBeforeUnloadConfirmPanel(bool& canRun)
+{
+ canRun = m_uiClient.canRunBeforeUnloadConfirmPanel();
+}
+
+void WebPageProxy::runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ shouldClose = m_uiClient.runBeforeUnloadConfirmPanel(this, message, frame);
+}
+
+#if ENABLE(TILED_BACKING_STORE)
+void WebPageProxy::pageDidRequestScroll(const IntSize& delta)
+{
+ m_pageClient->pageDidRequestScroll(delta);
+}
+#endif
+
+void WebPageProxy::didChangeViewportData(const ViewportArguments& args)
+{
+ m_pageClient->setViewportArguments(args);
+}
+
+void WebPageProxy::pageDidScroll()
+{
+ m_uiClient.pageDidScroll(this);
+}
+
+void WebPageProxy::runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data& data)
+{
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+ }
+
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ m_openPanelResultListener = WebOpenPanelResultListenerProxy::create(this);
+
+ if (!m_uiClient.runOpenPanel(this, frame, data, m_openPanelResultListener.get()))
+ didCancelForOpenPanel();
+}
+
+#if PLATFORM(QT)
+void WebPageProxy::didChangeContentsSize(const WebCore::IntSize& size)
+{
+ m_pageClient->didChangeContentsSize(size);
+}
+
+void WebPageProxy::didFindZoomableArea(const WebCore::IntRect& area)
+{
+ m_pageClient->didFindZoomableArea(area);
+}
+
+void WebPageProxy::findZoomableAreaForPoint(const WebCore::IntPoint& point)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::FindZoomableAreaForPoint(point), m_pageID);
+}
+#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
+
+// 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::selectionStateChanged(const SelectionState& selectionState)
+{
+ m_selectionState = selectionState;
+}
+
+#if PLATFORM(MAC)
+// 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);
+}
+#endif
+
+#if PLATFORM(WIN)
+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<WebCore::CompositionUnderline>& underlines, int cursorPosition)
+{
+ process()->send(Messages::WebPage::SetComposition(compositionString, underlines, cursorPosition), m_pageID);
+}
+#endif
+
+// Undo management
+
+void WebPageProxy::registerEditCommandForUndo(uint64_t commandID, uint32_t editAction)
+{
+ registerEditCommand(WebEditCommandProxy::create(commandID, static_cast<EditAction>(editAction), this), Undo);
+}
+
+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& selectionRect, const Vector<FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle, bool fadeOut)
+{
+ RefPtr<FindIndicator> findIndicator = FindIndicator::create(selectionRect, textRects, contentImageHandle);
+ m_pageClient->setFindIndicator(findIndicator.release(), fadeOut);
+}
+
+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);
+}
+
+void WebPageProxy::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData& data)
+{
+ if (m_activePopupMenu)
+ m_activePopupMenu->hidePopupMenu();
+ else
+ m_activePopupMenu = m_pageClient->createPopupMenuProxy(this);
+
+#if PLATFORM(WIN)
+ // On Windows, we're about to run our own message pump in showPopupMenu(), so turn off the responsiveness timer.
+ process()->responsivenessTimer()->stop();
+#endif
+
+ m_activePopupMenu->showPopupMenu(rect, items, data, selectedIndex);
+ m_activePopupMenu = 0;
+}
+
+void WebPageProxy::hidePopupMenu()
+{
+ if (!m_activePopupMenu)
+ return;
+
+ m_activePopupMenu->hidePopupMenu();
+ m_activePopupMenu = 0;
+}
+
+void WebPageProxy::showContextMenu(const IntPoint& menuLocation, const ContextMenuState& contextMenuState, const Vector<WebContextMenuItemData>& proposedItems, CoreIPC::ArgumentDecoder* arguments)
+{
+ RefPtr<APIObject> userData;
+ WebContextUserMessageDecoder messageDecoder(userData, context());
+ if (!arguments->decode(messageDecoder))
+ return;
+
+ m_activeContextMenuState = contextMenuState;
+
+ if (m_activeContextMenu)
+ m_activeContextMenu->hideContextMenu();
+ else
+ m_activeContextMenu = m_pageClient->createContextMenuProxy(this);
+
+ // 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);
+ return;
+ }
+
+ if (items.size())
+ m_activeContextMenu->showContextMenu(menuLocation, items);
+}
+
+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;
+ }
+#endif
+ if (item.action() == ContextMenuItemTagDownloadImageToDisk) {
+ m_context->download(this, KURL(KURL(), m_activeContextMenuState.absoluteImageURLString));
+ return;
+ }
+ if (item.action() == ContextMenuItemTagDownloadLinkToDisk) {
+ m_context->download(this, KURL(KURL(), m_activeContextMenuState.absoluteLinkURLString));
+ 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;
+
+ // FIXME: This also needs to send a sandbox extension for these paths.
+ 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)
+{
+ process()->send(Messages::WebPage::AdvanceToNextMisspelling(startBeforeSelection), m_pageID);
+}
+
+void WebPageProxy::changeSpellingToWord(const String& word)
+{
+ if (word.isEmpty())
+ return;
+
+ process()->send(Messages::WebPage::ChangeSpellingToWord(word), m_pageID);
+}
+
+void WebPageProxy::unmarkAllMisspellings()
+{
+ process()->send(Messages::WebPage::UnmarkAllMisspellings(), m_pageID);
+}
+
+void WebPageProxy::unmarkAllBadGrammar()
+{
+ process()->send(Messages::WebPage::UnmarkAllBadGrammar(), m_pageID);
+}
+
+#if PLATFORM(MAC)
+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);
+}
+#endif
+
+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);
+}
+
+int64_t WebPageProxy::spellDocumentTag()
+{
+ if (!m_hasSpellDocumentTag) {
+ m_spellDocumentTag = TextChecker::uniqueSpellDocumentTag();
+ m_hasSpellDocumentTag = true;
+ }
+
+ return m_spellDocumentTag;
+}
+
+void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
+{
+ results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
+}
+
+void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord);
+}
+
+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(word);
+}
+
+void WebPageProxy::ignoreWord(const String& word)
+{
+ MESSAGE_CHECK(m_pendingLearnOrIgnoreWordMessageCount);
+ --m_pendingLearnOrIgnoreWordMessageCount;
+
+ TextChecker::ignoreWord(spellDocumentTag(), word);
+}
+
+// Other
+
+void WebPageProxy::takeFocus(bool direction)
+{
+ m_pageClient->takeFocus(direction);
+}
+
+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::didValidateMenuItem(const String& commandName, bool isEnabled, int32_t state)
+{
+ m_pageClient->setEditCommandState(commandName, isEnabled, state);
+}
+
+void WebPageProxy::didReceiveEvent(uint32_t opaqueType, bool handled)
+{
+ WebEvent::Type type = static_cast<WebEvent::Type>(opaqueType);
+
+ switch (type) {
+ 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:
+ process()->responsivenessTimer()->stop();
+ break;
+ }
+
+ switch (type) {
+ case WebEvent::MouseMove:
+ m_processingMouseMoveEvent = false;
+ if (m_nextMouseMoveEvent) {
+ handleMouseEvent(*m_nextMouseMoveEvent);
+ m_nextMouseMoveEvent = nullptr;
+ }
+ break;
+ case WebEvent::MouseDown:
+ case WebEvent::MouseUp:
+ break;
+
+ case WebEvent::Wheel: {
+ m_processingWheelEvent = false;
+ if (m_nextWheelEvent) {
+ handleWheelEvent(*m_nextWheelEvent);
+ m_nextWheelEvent = nullptr;
+ }
+ break;
+ }
+
+ case WebEvent::KeyDown:
+ case WebEvent::KeyUp:
+ case WebEvent::RawKeyDown:
+ case WebEvent::Char: {
+ NativeWebKeyboardEvent event = m_keyEventQueue.first();
+ MESSAGE_CHECK(type == event.type());
+
+ m_keyEventQueue.removeFirst();
+
+ if (handled)
+ break;
+
+ m_pageClient->didNotHandleKeyEvent(event);
+ m_uiClient.didNotHandleKeyEvent(this, event);
+ break;
+ }
+ }
+}
+
+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.
+ return;
+ }
+
+ callback->performCallbackWithReturnValue(resultString.impl());
+}
+
+#if PLATFORM(MAC)
+void WebPageProxy::sendAccessibilityPresenterToken(const CoreIPC::DataReference& token)
+{
+ if (!isValid())
+ return;
+
+ process()->send(Messages::WebPage::SendAccessibilityPresenterToken(token), m_pageID);
+}
+#endif
+
+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;
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void WebPageProxy::didChangeAcceleratedCompositing(bool compositing, DrawingAreaInfo& drawingAreaInfo)
+{
+ if (compositing)
+ didEnterAcceleratedCompositing();
+ else
+ didLeaveAcceleratedCompositing();
+
+ drawingAreaInfo = drawingArea()->info();
+}
+#endif
+
+void WebPageProxy::processDidBecomeUnresponsive()
+{
+ m_loaderClient.processDidBecomeUnresponsive(this);
+}
+
+void WebPageProxy::processDidBecomeResponsive()
+{
+ m_loaderClient.processDidBecomeResponsive(this);
+}
+
+void WebPageProxy::processDidCrash()
+{
+ ASSERT(m_pageClient);
+
+ m_isValid = false;
+
+ if (m_mainFrame)
+ m_urlAtProcessExit = m_mainFrame->url();
+
+ m_mainFrame = 0;
+
+ m_drawingArea = nullptr;
+
+#if ENABLE(INSPECTOR)
+ if (m_inspector) {
+ m_inspector->invalidate();
+ m_inspector = 0;
+ }
+#endif
+
+ if (m_openPanelResultListener) {
+ m_openPanelResultListener->invalidate();
+ m_openPanelResultListener = 0;
+ }
+
+ m_geolocationPermissionRequestManager.invalidateRequests();
+
+ m_toolTip = String();
+
+ invalidateCallbackMap(m_dataCallbacks);
+ invalidateCallbackMap(m_stringCallbacks);
+
+ 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);
+}
+
+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.drawingAreaInfo = m_drawingArea->info();
+ parameters.store = m_pageGroup->preferences()->store();
+ parameters.pageGroupData = m_pageGroup->data();
+ parameters.drawsBackground = m_drawsBackground;
+ parameters.drawsTransparentBackground = m_drawsTransparentBackground;
+ parameters.useFixedLayout = m_useFixedLayout;
+ parameters.fixedLayoutSize = m_fixedLayoutSize;
+ parameters.userAgent = userAgent();
+ parameters.sessionState = SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex());
+ parameters.highestUsedBackForwardItemID = WebBackForwardListItem::highedUsedItemID();
+
+#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::didEnterAcceleratedCompositing()
+{
+ m_pageClient->pageDidEnterAcceleratedCompositing();
+}
+
+void WebPageProxy::didLeaveAcceleratedCompositing()
+{
+ m_pageClient->pageDidLeaveAcceleratedCompositing();
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+void WebPageProxy::backForwardClear()
+{
+ m_backForwardList->clear();
+}
+
+void WebPageProxy::canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const WebCore::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 WebCore::AuthenticationChallenge& coreChallenge, uint64_t challengeID)
+{
+ WebFrameProxy* frame = process()->webFrame(frameID);
+ MESSAGE_CHECK(frame);
+
+ RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, this);
+
+ 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 currentUsage, 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, currentUsage, 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::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& dataReference)
+{
+ m_pageClient->didFinishLoadingDataForCustomRepresentation(dataReference);
+}
+
+#if PLATFORM(MAC)
+void WebPageProxy::setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
+{
+ m_pageClient->setComplexTextInputEnabled(pluginComplexTextInputIdentifier, complexTextInputEnabled);
+}
+#endif
+
+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);
+}
+
+void WebPageProxy::endPrinting()
+{
+ if (!m_isInPrintingMode)
+ return;
+
+ m_isInPrintingMode = false;
+ process()->send(Messages::WebPage::EndPrinting(), m_pageID);
+}
+
+void WebPageProxy::computePagesForPrinting(WebFrameProxy* frame, const PrintInfo& printInfo, Vector<WebCore::IntRect>& resultPageRects, double& resultTotalScaleFactorForPrinting)
+{
+ // Layout for printing can take a long time, but we need to have the answer.
+ process()->sendSync(Messages::WebPage::ComputePagesForPrinting(frame->frameID(), printInfo), Messages::WebPage::ComputePagesForPrinting::Reply(resultPageRects, resultTotalScaleFactorForPrinting), m_pageID);
+}
+
+#if PLATFORM(MAC)
+void WebPageProxy::drawRectToPDF(WebFrameProxy* frame, const IntRect& rect, Vector<uint8_t>& pdfData)
+{
+ // Printing can take a long time, but we need to have the answer.
+ process()->sendSync(Messages::WebPage::DrawRectToPDF(frame->frameID(), rect), Messages::WebPage::DrawRectToPDF::Reply(pdfData), m_pageID);
+}
+#endif
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h
new file mode 100644
index 0000000..4a9e478
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.h
@@ -0,0 +1,621 @@
+/*
+ * 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 WebPageProxy_h
+#define WebPageProxy_h
+
+#include "APIObject.h"
+#include "ContextMenuState.h"
+#include "DragControllerAction.h"
+#include "DrawingAreaProxy.h"
+#include "GeolocationPermissionRequestManagerProxy.h"
+#include "SelectionState.h"
+#include "SharedMemory.h"
+#include "WKBase.h"
+#include "WebContextMenuItemData.h"
+#include "WebEvent.h"
+#include "WebFindClient.h"
+#include "WebFindOptions.h"
+#include "WebFormClient.h"
+#include "WebFrameProxy.h"
+#include "WebHistoryClient.h"
+#include "WebInspectorProxy.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/EditAction.h>
+#include <WebCore/Editor.h>
+#include <WebCore/FrameLoaderTypes.h>
+#include <WebCore/KeyboardEvent.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/text/WTFString.h>
+
+namespace CoreIPC {
+ class ArgumentDecoder;
+ class Connection;
+ class MessageID;
+}
+
+namespace WebCore {
+ class AuthenticationChallenge;
+ class Cursor;
+ class DragData;
+ class FloatRect;
+ class IntSize;
+ class ProtectionSpace;
+ struct TextCheckingResult;
+ struct ViewportArguments;
+ struct WindowFeatures;
+}
+
+namespace WebKit {
+
+class ContextMenuState;
+class DrawingAreaProxy;
+class NativeWebKeyboardEvent;
+class PageClient;
+class PlatformCertificateInfo;
+class StringPairVector;
+class WebOpenPanelResultListenerProxy;
+class WebBackForwardList;
+class WebBackForwardListItem;
+class WebContextMenuProxy;
+class WebData;
+class WebEditCommandProxy;
+class WebKeyboardEvent;
+class WebMouseEvent;
+class WebPageGroup;
+class WebPopupMenuProxy;
+class WebProcessProxy;
+class WebURLRequest;
+class WebWheelEvent;
+struct PlatformPopupMenuData;
+struct PrintInfo;
+struct WebPageCreationParameters;
+struct WebPopupItem;
+
+typedef GenericCallback<WKStringRef, StringImpl*> StringCallback;
+
+class WebPageProxy : public APIObject, public WebPopupMenuProxy::Client {
+public:
+ static const Type APIType = TypePage;
+
+ static PassRefPtr<WebPageProxy> create(PageClient*, WebContext*, 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() { return m_drawingArea.get(); }
+ void setDrawingArea(PassOwnPtr<DrawingAreaProxy>);
+
+ WebBackForwardList* backForwardList() { return m_backForwardList.get(); }
+
+#if ENABLE(INSPECTOR)
+ WebInspectorProxy* inspector();
+#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 didChangeBackForwardList();
+
+ 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 setInitialFocus(bool);
+ void setWindowResizerSize(const WebCore::IntSize&);
+
+ void setViewNeedsDisplay(const WebCore::IntRect&);
+ void displayView();
+
+ enum {
+ ViewWindowIsActive = 1 << 0,
+ ViewIsFocused = 1 << 1,
+ ViewIsVisible = 1 << 2,
+ ViewIsInWindow = 1 << 3
+ };
+ typedef unsigned ViewStateFlags;
+ void viewStateDidChange(ViewStateFlags flags);
+
+ WebCore::IntSize viewSize() const;
+
+ void executeEditCommand(const String& commandName);
+ void validateMenuItem(const String& commandName);
+
+ const SelectionState& selectionState() const { return m_selectionState; }
+
+#if PLATFORM(MAC)
+ void updateWindowIsVisible(bool windowIsVisible);
+ void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates, const WebCore::IntPoint& accessibilityViewCoordinates);
+ void getMarkedRange(uint64_t& location, uint64_t& length);
+ uint64_t characterIndexForPoint(const WebCore::IntPoint);
+ WebCore::IntRect firstRectForCharacterRange(uint64_t, uint64_t);
+ void sendComplexTextInputToPlugin(uint64_t pluginComplexTextInputIdentifier, const String& textInput);
+#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();
+#endif
+#if ENABLE(TILED_BACKING_STORE)
+ void setActualVisibleContentRect(const WebCore::IntRect& rect);
+#endif
+
+ void handleMouseEvent(const WebMouseEvent&);
+ void handleWheelEvent(const WebWheelEvent&);
+ void handleKeyboardEvent(const NativeWebKeyboardEvent&);
+#if ENABLE(TOUCH_EVENTS)
+ void handleTouchEvent(const WebTouchEvent&);
+#endif
+
+ 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; }
+
+ bool supportsTextEncoding() const;
+ void setCustomTextEncodingName(const String&);
+ String customTextEncodingName() const { return m_customTextEncodingName; }
+
+ double estimatedProgress() const { return m_estimatedProgress; }
+
+ 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 scaleWebView(double scale, const WebCore::IntPoint& origin);
+ double viewScaleFactor() const { return m_viewScaleFactor; }
+
+ void setUseFixedLayout(bool);
+ void setFixedLayoutSize(const WebCore::IntSize&);
+ bool useFixedLayout() const { return m_useFixedLayout; };
+ const WebCore::IntSize& fixedLayoutSize() const { return m_fixedLayoutSize; };
+
+#if PLATFORM(MAC)
+ void sendAccessibilityPresenterToken(const CoreIPC::DataReference&);
+#endif
+
+ // Find.
+ void findString(const String&, FindOptions, unsigned maxMatchCount);
+ void hideFindUI();
+ void countStringMatches(const String&, FindOptions, unsigned maxMatchCount);
+
+ void getContentsAsString(PassRefPtr<StringCallback>);
+ void getMainResourceDataOfFrame(WebFrameProxy*, 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<StringCallback>);
+
+ void receivedPolicyDecision(WebCore::PolicyAction, WebFrameProxy*, uint64_t listenerID);
+
+ void backForwardRemovedItem(uint64_t itemID);
+
+ // Drag and drop support.
+ void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String&);
+ void didPerformDragControllerAction(uint64_t resultOperation);
+
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+
+ void processDidBecomeUnresponsive();
+ void processDidBecomeResponsive();
+ void processDidCrash();
+
+#if USE(ACCELERATED_COMPOSITING)
+ void didEnterAcceleratedCompositing();
+ void didLeaveAcceleratedCompositing();
+#endif
+
+ void didDraw();
+
+ enum UndoOrRedo { Undo, Redo };
+ void addEditCommand(WebEditCommandProxy*);
+ void removeEditCommand(WebEditCommandProxy*);
+ void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo);
+
+ WebProcessProxy* process() const;
+ WebContext* context() const { return m_context.get(); }
+
+ WebPageGroup* pageGroup() const { return m_pageGroup.get(); }
+
+ bool isValid();
+
+ WebCore::DragOperation dragOperation() { return m_currentDragOperation; }
+ void resetDragOperation() { m_currentDragOperation = WebCore::DragOperationNone; }
+
+ // REMOVE: For demo purposes only.
+ const String& urlAtProcessExit() const { return m_urlAtProcessExit; }
+
+ void preferencesDidChange();
+
+#if ENABLE(TILED_BACKING_STORE)
+ void setResizesToContentsUsingLayoutSize(const WebCore::IntSize&);
+#endif
+
+ // 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&);
+#endif
+
+ void advanceToNextMisspelling(bool startBeforeSelection);
+ void changeSpellingToWord(const String& word);
+ void unmarkAllMisspellings();
+ void unmarkAllBadGrammar();
+#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&, Vector<WebCore::IntRect>& resultPageRects, double& resultTotalScaleFactorForPrinting);
+#if PLATFORM(MAC)
+ void drawRectToPDF(WebFrameProxy*, const WebCore::IntRect&, Vector<uint8_t>& pdfData);
+#endif
+
+private:
+ WebPageProxy(PageClient*, WebContext*, 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);
+
+ // Implemented in generated WebPageProxyMessageReceiver.cpp
+ void didReceiveWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ CoreIPC::SyncReplyMode didReceiveSyncWebPageProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, 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&, bool loadingSubstituteDataForUnreachableURL, 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 frameDidBecomeFrameSet(uint64_t frameID, bool);
+ void didStartProgress();
+ void didChangeProgress(double);
+ void didFinishProgress();
+ void didReceiveAccessibilityPageToken(const CoreIPC::DataReference&);
+
+ void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID);
+ void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID);
+ void decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
+
+ 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&);
+ 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::WindowFeatures&, uint32_t modifiers, int32_t mouseButton, uint64_t& newPageID, WebPageCreationParameters&);
+ void showPage();
+ void closePage();
+ 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 setStatusText(const String&);
+ void mouseDidMoveOverElement(uint32_t modifiers, CoreIPC::ArgumentDecoder*);
+ void missingPluginButtonClicked(const String& mimeType, const String& url);
+ 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 canRunBeforeUnloadConfirmPanel(bool& canRun);
+ void runBeforeUnloadConfirmPanel(const String& message, uint64_t frameID, bool& shouldClose);
+ void didChangeViewportData(const WebCore::ViewportArguments&);
+ void pageDidScroll();
+ void runOpenPanel(uint64_t frameID, const WebOpenPanelParameters::Data&);
+ void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentUsage, uint64_t expectedUsage, uint64_t& newQuota);
+ void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
+
+ void reattachToWebProcess();
+ void reattachToWebProcessWithItem(WebBackForwardListItem*);
+
+#if ENABLE(TILED_BACKING_STORE)
+ void pageDidRequestScroll(const WebCore::IntSize&);
+#endif
+
+#if PLATFORM(QT)
+ void didChangeContentsSize(const WebCore::IntSize&);
+ void didFindZoomableArea(const WebCore::IntRect&);
+#endif
+
+ // Selection
+ void selectionStateChanged(const SelectionState&);
+
+ // 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();
+
+ // Keyboard handling
+#if PLATFORM(MAC)
+ void interpretKeyEvent(uint32_t eventType, Vector<WebCore::KeypressCommand>&, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline>& underlines);
+#endif
+
+ // Find.
+ void didCountStringMatches(const String&, uint32_t matchCount);
+ void setFindIndicator(const WebCore::FloatRect& selectionRect, const Vector<WebCore::FloatRect>& textRects, const SharedMemory::Handle& contentImageHandle, bool fadeOut);
+ void didFindString(const String&, uint32_t matchCount);
+ void didFailToFindString(const String&);
+
+ // Popup Menu.
+ void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, int32_t selectedIndex, const PlatformPopupMenuData&);
+ void hidePopupMenu();
+
+ // Context Menu.
+ void showContextMenu(const WebCore::IntPoint& menuLocation, const ContextMenuState&, const Vector<WebContextMenuItemData>&, CoreIPC::ArgumentDecoder*);
+
+ // Speech.
+#if PLATFORM(MAC)
+ void getIsSpeaking(bool&);
+ void speak(const String&);
+ void stopSpeaking();
+#endif
+
+ // Spelling and grammar.
+ int64_t spellDocumentTag();
+ void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
+ void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
+ void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
+ void learnWord(const String& word);
+ void ignoreWord(const String& word);
+
+ void takeFocus(bool direction);
+ void setToolTip(const String&);
+ void setCursor(const WebCore::Cursor&);
+ void didValidateMenuItem(const String& commandName, bool isEnabled, int32_t state);
+
+ void didReceiveEvent(uint32_t opaqueType, bool handled);
+
+ void dataCallback(const CoreIPC::DataReference&, uint64_t);
+ void stringCallback(const String&, uint64_t);
+
+ void focusedFrameChanged(uint64_t frameID);
+ void frameSetLargestFrameChanged(uint64_t frameID);
+
+#if USE(ACCELERATED_COMPOSITING)
+ void didChangeAcceleratedCompositing(bool compositing, DrawingAreaInfo&);
+#endif
+
+ void canAuthenticateAgainstProtectionSpaceInFrame(uint64_t frameID, const WebCore::ProtectionSpace&, bool& canAuthenticate);
+ void didReceiveAuthenticationChallenge(uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
+
+ void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference& data);
+
+#if PLATFORM(MAC)
+ void setComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled);
+#endif
+
+ static String standardUserAgent(const String& applicationName = String());
+
+ 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<WebContext> m_context;
+ 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
+
+ HashMap<uint64_t, RefPtr<DataCallback> > m_dataCallbacks;
+ HashMap<uint64_t, RefPtr<StringCallback> > m_stringCallbacks;
+
+ HashSet<WebEditCommandProxy*> m_editCommandSet;
+
+ RefPtr<WebPopupMenuProxy> m_activePopupMenu;
+ RefPtr<WebContextMenuProxy> m_activeContextMenu;
+ ContextMenuState m_activeContextMenuState;
+ RefPtr<WebOpenPanelResultListenerProxy> m_openPanelResultListener;
+ GeolocationPermissionRequestManagerProxy m_geolocationPermissionRequestManager;
+
+ 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;
+
+ String m_toolTip;
+
+ SelectionState m_selectionState;
+
+ // REMOVE: For demo purposes only.
+ String m_urlAtProcessExit;
+
+ double m_textZoomFactor;
+ double m_pageZoomFactor;
+ double m_viewScaleFactor;
+
+ bool m_drawsBackground;
+ bool m_drawsTransparentBackground;
+
+ bool m_useFixedLayout;
+ WebCore::IntSize m_fixedLayoutSize;
+
+ // 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_inDecidePolicyForMIMEType;
+ bool m_syncMimeTypePolicyActionIsValid;
+ WebCore::PolicyAction m_syncMimeTypePolicyAction;
+ uint64_t m_syncMimeTypePolicyDownloadID;
+
+ Deque<NativeWebKeyboardEvent> m_keyEventQueue;
+ bool m_processingWheelEvent;
+ OwnPtr<WebWheelEvent> m_nextWheelEvent;
+
+ bool m_processingMouseMoveEvent;
+ OwnPtr<WebMouseEvent> m_nextMouseMoveEvent;
+
+ 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::DragOperation m_currentDragOperation;
+};
+
+} // 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 0000000..2d576be
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in
@@ -0,0 +1,192 @@
+# 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 -> WebPageProxy {
+ # UI messages.
+ CreateNewPage(WebCore::WindowFeatures windowFeatures, uint32_t modifiers, int32_t mouseButton) -> (uint64_t newPageID, WebKit::WebPageCreationParameters newPageParameters)
+ ShowPage()
+ ClosePage()
+ 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)
+ MouseDidMoveOverElement(uint32_t modifiers, WebKit::InjectedBundleUserMessageEncoder userData);
+ MissingPluginButtonClicked(WTF::String mimeType, WTF::String url)
+ DidChangeViewportData(WebCore::ViewportArguments arguments)
+ DidReceiveEvent(uint32_t type, bool handled)
+ DidValidateMenuItem(WTF::String commandName, bool isEnabled, int32_t state)
+ SetCursor(WebCore::Cursor cursor)
+ SetStatusText(WTF::String statusText)
+ SetToolTip(WTF::String toolTip)
+ TakeFocus(bool direction)
+ FocusedFrameChanged(uint64_t frameID)
+ FrameSetLargestFrameChanged(uint64_t frameID)
+ 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)
+ CanRunBeforeUnloadConfirmPanel() -> (bool canRun)
+ RunBeforeUnloadConfirmPanel(WTF::String message, uint64_t frameID) -> (bool shouldClose)
+ PageDidScroll()
+ RunOpenPanel(uint64_t frameID, WebKit::WebOpenPanelParameters::Data parameters)
+
+#if ENABLE(TILED_BACKING_STORE)
+ PageDidRequestScroll(WebCore::IntSize delta)
+#endif
+#if PLATFORM(QT)
+ DidChangeContentsSize(WebCore::IntSize newSize)
+ DidFindZoomableArea(WebCore::IntRect area)
+#endif
+
+ # Policy messages.
+ DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
+ DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID)
+ DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID)
+
+ # 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, bool loadingSubstituteDataForUnreachableURL, 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)
+ 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)
+ 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)
+
+ # Custom representations
+ DidFinishLoadingDataForCustomRepresentation(CoreIPC::DataReference data)
+
+ # Forms messages.
+ WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, WebKit::StringPairVector textFieldValues, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
+
+ # Callback messages.
+ DataCallback(CoreIPC::DataReference resultData, uint64_t callbackID)
+ StringCallback(WTF::String resultString, uint64_t callbackID)
+
+ DidReceiveAccessibilityPageToken(CoreIPC::DataReference data)
+
+#if PLATFORM(MAC)
+ # Keyboard support messages.
+ InterpretKeyEvent(uint32_t type) -> (Vector<WebCore::KeypressCommand> commandName, uint32_t selectionStart, uint32_t selectionEnd, Vector<WebCore::CompositionUnderline> underlines)
+#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()
+
+ # Undo/Redo messages.
+ RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
+ ClearAllEditCommands()
+
+ # Selection messages.
+ SelectionStateChanged(WebKit::SelectionState selectionState)
+
+#if PLATFORM(WIN)
+ DidChangeCompositionSelection(bool hasChanged)
+#endif
+
+ # Find messages.
+ DidCountStringMatches(WTF::String string, uint32_t matchCount)
+ SetFindIndicator(WebCore::FloatRect selectionRect, Vector<WebCore::FloatRect> textRects, WebKit::SharedMemory::Handle contentImageHandle, bool fadeOut)
+ DidFindString(WTF::String string, uint32_t matchCount)
+ DidFailToFindString(WTF::String string)
+
+ # PopupMenu messages.
+ ShowPopupMenu(WebCore::IntRect rect, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, WebKit::PlatformPopupMenuData data)
+ HidePopupMenu()
+
+ # ContextMenu messages.
+ ShowContextMenu(WebCore::IntPoint menuLocation, WebKit::ContextMenuState state, Vector<WebKit::WebContextMenuItemData> items, WebKit::InjectedBundleUserMessageEncoder userData)
+
+#if USE(ACCELERATED_COMPOSITING)
+ # Accelerated compositing messages.
+ DidChangeAcceleratedCompositing(bool compositing) -> (WebKit::DrawingAreaInfo newDrawingArea)
+#endif
+
+ # 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 currentUsage, uint64_t expectedUsage) -> (uint64_t newQuota)
+
+ # Geolocation messages.
+ RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier)
+
+ # Plug-in complex text input support messages.
+#if PLATFORM(MAC)
+ SetComplexTextInputEnabled(uint64_t pluginComplexTextInputIdentifier, bool complexTextInputEnabled)
+#endif
+
+ # Speech messages.
+#if PLATFORM(MAC)
+ GetIsSpeaking() -> (bool isSpeaking)
+ Speak(WTF::String string)
+ StopSpeaking()
+#endif
+
+ # Spelling and grammar.
+ CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
+ UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
+ GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
+ LearnWord(WTF::String word);
+ IgnoreWord(WTF::String word);
+
+ # Drag and drop.
+ DidPerformDragControllerAction(uint64_t resultOperation)
+}
diff --git a/Source/WebKit2/UIProcess/WebPolicyClient.cpp b/Source/WebKit2/UIProcess/WebPolicyClient.cpp
new file mode 100644
index 0000000..e7a8239
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPolicyClient.cpp
@@ -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.
+ */
+
+#include "WebPolicyClient.h"
+
+#include "WKAPICast.h"
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
+{
+ if (!m_client.decidePolicyForNavigationAction)
+ return false;
+
+ m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
+ return true;
+}
+
+bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
+{
+ if (!m_client.decidePolicyForNewWindowAction)
+ return false;
+
+ m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
+ return true;
+}
+
+bool WebPolicyClient::decidePolicyForMIMEType(WebPageProxy* page, const String& MIMEType, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
+{
+ if (!m_client.decidePolicyForMIMEType)
+ return false;
+
+ m_client.decidePolicyForMIMEType(toAPI(page), toAPI(MIMEType.impl()), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
+ return true;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebPolicyClient.h b/Source/WebKit2/UIProcess/WebPolicyClient.h
new file mode 100644
index 0000000..797bc37
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPolicyClient.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 WebPolicyClient_h
+#define WebPolicyClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include "WebEvent.h"
+#include <WebCore/FrameLoaderTypes.h>
+#include <wtf/Forward.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+class WebFrameProxy;
+class WebFramePolicyListenerProxy;
+
+class WebPolicyClient : public APIClient<WKPagePolicyClient> {
+public:
+ bool decidePolicyForNavigationAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
+ bool decidePolicyForNewWindowAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
+ bool decidePolicyForMIMEType(WebPageProxy*, const String&, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebPolicyClient_h
diff --git a/Source/WebKit2/UIProcess/WebPopupMenuProxy.h b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
new file mode 100644
index 0000000..fd84928
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPopupMenuProxy.h
@@ -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.
+ */
+
+#ifndef WebPopupMenuProxy_h
+#define WebPopupMenuProxy_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+ class IntRect;
+}
+
+namespace WebKit {
+
+struct PlatformPopupMenuData;
+struct WebPopupItem;
+
+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 ~WebPopupMenuProxy()
+ {
+ }
+
+ virtual void showPopupMenu(const WebCore::IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex) = 0;
+ virtual void hidePopupMenu() = 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 0000000..e33ebb2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebPreferences.cpp
@@ -0,0 +1,105 @@
+/*
+ * 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 "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 0000000..0f4943a
--- /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/WebProcessManager.cpp b/Source/WebKit2/UIProcess/WebProcessManager.cpp
new file mode 100644
index 0000000..94556f8
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessManager.cpp
@@ -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.
+ */
+
+#include "WebProcessManager.h"
+
+#include "WebContext.h"
+
+namespace WebKit {
+
+WebProcessManager& WebProcessManager::shared()
+{
+ static WebProcessManager& manager = *new WebProcessManager;
+ return manager;
+}
+
+WebProcessManager::WebProcessManager()
+{
+}
+
+WebProcessProxy* WebProcessManager::getWebProcess(WebContext* context)
+{
+ switch (context->processModel()) {
+ case ProcessModelSharedSecondaryProcess: {
+ if (!m_sharedProcess)
+ m_sharedProcess = WebProcessProxy::create(context);
+ return m_sharedProcess.get();
+ }
+ case ProcessModelSharedSecondaryThread: {
+ if (!m_sharedThread)
+ m_sharedThread = WebProcessProxy::create(context);
+ return m_sharedThread.get();
+ }
+ case ProcessModelSecondaryProcess: {
+ std::pair<ProcessMap::iterator, bool> result = m_processMap.add(context, 0);
+ if (result.second) {
+ ASSERT(!result.first->second);
+ result.first->second = WebProcessProxy::create(context);
+ }
+
+ ASSERT(result.first->second);
+ return result.first->second.get();
+ }
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+void WebProcessManager::processDidClose(WebProcessProxy* process, WebContext* context)
+{
+ if (process == m_sharedProcess) {
+ ASSERT(context->processModel() == ProcessModelSharedSecondaryProcess);
+ m_sharedProcess = 0;
+ return;
+ }
+
+ ProcessMap::iterator it = m_processMap.find(context);
+ if (it != m_processMap.end()) {
+ ASSERT(it->second == process);
+ m_processMap.remove(it);
+ return;
+ }
+
+ // The shared thread connection should never be closed.
+ ASSERT_NOT_REACHED();
+}
+
+void WebProcessManager::contextWasDestroyed(WebContext* context)
+{
+ m_processMap.remove(context);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebProcessManager.h b/Source/WebKit2/UIProcess/WebProcessManager.h
new file mode 100644
index 0000000..320829e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessManager.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 WebProcessManager_h
+#define WebProcessManager_h
+
+#include "WebProcessProxy.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class WebProcessManager {
+public:
+ static WebProcessManager& shared();
+
+ WebProcessProxy* getWebProcess(WebContext*);
+ void processDidClose(WebProcessProxy*, WebContext*);
+
+ void contextWasDestroyed(WebContext*);
+
+private:
+ WebProcessManager();
+
+ RefPtr<WebProcessProxy> m_sharedThread;
+ RefPtr<WebProcessProxy> m_sharedProcess;
+
+ typedef HashMap<WebContext*, RefPtr<WebProcessProxy> > ProcessMap;
+ ProcessMap m_processMap;
+};
+
+} // namespace WebKit
+
+#endif // WebProcessManager_h
diff --git a/Source/WebKit2/UIProcess/WebProcessProxy.cpp b/Source/WebKit2/UIProcess/WebProcessProxy.cpp
new file mode 100644
index 0000000..c7e9382
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.cpp
@@ -0,0 +1,415 @@
+/*
+ * 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 "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 "WebPageProxy.h"
+#include "WebProcessManager.h"
+#include "WebProcessMessages.h"
+#include "WebProcessProxyMessages.h"
+#include "WebProcessProxyMessageKinds.h"
+#include <WebCore/KURL.h>
+#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
+
+using namespace WebCore;
+
+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(WebContext* context)
+{
+ return adoptRef(new WebProcessProxy(context));
+}
+
+WebProcessProxy::WebProcessProxy(WebContext* context)
+ : m_responsivenessTimer(this)
+ , m_context(context)
+{
+ connect();
+}
+
+WebProcessProxy::~WebProcessProxy()
+{
+ if (m_connection)
+ m_connection->invalidate();
+
+ for (size_t i = 0; i < m_pendingMessages.size(); ++i)
+ m_pendingMessages[i].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;
+#endif
+ m_processLauncher = ProcessLauncher::create(this, launchOptions);
+ }
+}
+
+bool WebProcessProxy::sendMessage(CoreIPC::MessageID messageID, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)
+{
+ // 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(CoreIPC::Connection::OutgoingMessage(messageID, arguments));
+ return true;
+ }
+
+ // If the web process has exited, m_connection will be null here.
+ if (!m_connection)
+ return false;
+
+ return m_connection->sendMessage(messageID, arguments);
+}
+
+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).get();
+}
+
+WebPageProxy* WebProcessProxy::createWebPage(PageClient* pageClient, WebContext* context, WebPageGroup* pageGroup)
+{
+ ASSERT(context->process() == this);
+
+ unsigned pageID = generatePageID();
+ RefPtr<WebPageProxy> webPage = WebPageProxy::create(pageClient, context, pageGroup, pageID);
+ m_pageMap.set(pageID, webPage);
+ return webPage.get();
+}
+
+void WebProcessProxy::addExistingWebPage(WebPageProxy* webPage, uint64_t pageID)
+{
+ m_pageMap.set(pageID, webPage);
+}
+
+void WebProcessProxy::removeWebPage(uint64_t pageID)
+{
+ m_pageMap.remove(pageID);
+}
+
+WebProcessProxy::pages_const_iterator WebProcessProxy::pages_begin()
+{
+ return m_pageMap.begin().values();
+}
+
+WebProcessProxy::pages_const_iterator WebProcessProxy::pages_end()
+{
+ return m_pageMap.end().values();
+}
+
+size_t WebProcessProxy::numberOfPages()
+{
+ return m_pageMap.size();
+}
+
+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::addBackForwardItem(uint64_t itemID, const String& originalURL, const String& url, const String& title, const CoreIPC::DataReference& backForwardData)
+{
+ 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, CoreIPC::ArgumentEncoder* reply)
+{
+ PluginProcessManager::shared().getPluginProcessConnection(pluginPath, this, reply);
+}
+#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::MessageClassWebDatabaseManagerProxy>()
+ || messageID.is<CoreIPC::MessageClassWebGeolocationManagerProxy>()) {
+ 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);
+}
+
+CoreIPC::SyncReplyMode WebProcessProxy::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, CoreIPC::ArgumentEncoder* reply)
+{
+#if ENABLE(PLUGIN_PROCESS)
+ if (messageID.is<CoreIPC::MessageClassWebProcessProxyLegacy>()) {
+ switch (messageID.get<WebProcessProxyLegacyMessage::Kind>()) {
+ case WebProcessProxyLegacyMessage::GetPluginProcessConnection: {
+ String pluginPath;
+
+ if (!arguments->decode(CoreIPC::Out(pluginPath)))
+ return CoreIPC::AutomaticReply;
+
+ getPluginProcessConnection(pluginPath, reply);
+ return CoreIPC::ManualReply;
+ }
+ }
+ }
+#endif
+
+ if (messageID.is<CoreIPC::MessageClassWebContext>() || messageID.is<CoreIPC::MessageClassWebContextLegacy>() || messageID.is<CoreIPC::MessageClassDownloadProxy>())
+ return m_context->didReceiveSyncMessage(connection, messageID, arguments, reply);
+
+ uint64_t pageID = arguments->destinationID();
+ if (!pageID)
+ return CoreIPC::AutomaticReply;
+
+ WebPageProxy* pageProxy = webPage(pageID);
+ if (!pageProxy)
+ return CoreIPC::AutomaticReply;
+
+ pageProxy->didReceiveSyncMessage(connection, messageID, arguments, reply);
+ return CoreIPC::AutomaticReply;
+}
+
+void WebProcessProxy::didClose(CoreIPC::Connection*)
+{
+ // Protect ourselves, as the call to the shared WebProcessManager's processDidClose()
+ // below may otherwise cause us to be deleted before we can finish our work.
+ RefPtr<WebProcessProxy> protect(this);
+
+ 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();
+
+ Vector<RefPtr<WebPageProxy> > pages;
+ copyValuesToVector(m_pageMap, pages);
+
+ m_context->processDidClose(this);
+
+ WebProcessManager::shared().processDidClose(this, m_context);
+
+ for (size_t i = 0, size = pages.size(); i < size; ++i)
+ pages[i]->processDidCrash();
+}
+
+void WebProcessProxy::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID)
+{
+ // We received an invalid message from the web process, invalidate our connection and kill it.
+ m_connection->invalidate();
+
+ terminate();
+}
+
+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 = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
+#if PLATFORM(MAC)
+ m_connection->setShouldCloseConnectionOnMachExceptions();
+#endif
+
+ m_connection->open();
+
+ for (size_t i = 0; i < m_pendingMessages.size(); ++i) {
+ CoreIPC::Connection::OutgoingMessage& outgoingMessage = m_pendingMessages[i];
+ m_connection->sendMessage(outgoingMessage.messageID(), adoptPtr(outgoingMessage.arguments()));
+ }
+
+ 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::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 0000000..531d7fe
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.h
@@ -0,0 +1,183 @@
+/*
+ * 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 "Connection.h"
+#include "PlatformProcessIdentifier.h"
+#include "PluginInfoStore.h"
+#include "ProcessLauncher.h"
+#include "ProcessModel.h"
+#include "ResponsivenessTimer.h"
+#include "ThreadLauncher.h"
+#include "WebPageProxy.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 {
+
+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<WebPageProxy> > WebPageProxyMap;
+ typedef WebPageProxyMap::const_iterator::Values pages_const_iterator;
+ typedef HashMap<uint64_t, RefPtr<WebFrameProxy> > WebFrameProxyMap;
+ typedef HashMap<uint64_t, RefPtr<WebBackForwardListItem> > WebBackForwardListItemMap;
+
+ static PassRefPtr<WebProcessProxy> create(WebContext*);
+ ~WebProcessProxy();
+
+ void terminate();
+
+ template<typename E, typename T> bool send(E messageID, uint64_t destinationID, const T& arguments);
+ template<typename T> bool send(const T& message, uint64_t destinationID);
+ 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.get();
+ }
+
+ WebContext* context() const { return m_context; }
+
+ PlatformProcessIdentifier processIdentifier() const { return m_processLauncher->processIdentifier(); }
+
+ WebPageProxy* webPage(uint64_t pageID) const;
+ WebPageProxy* createWebPage(PageClient*, WebContext*, WebPageGroup*);
+ void addExistingWebPage(WebPageProxy*, uint64_t pageID);
+ void removeWebPage(uint64_t pageID);
+
+ pages_const_iterator pages_begin();
+ pages_const_iterator pages_end();
+ size_t numberOfPages();
+
+ 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 didDestroyFrame(uint64_t);
+ void disconnectFramesFromPage(WebPageProxy*); // Including main frame.
+ size_t frameCountInPage(WebPageProxy*) const; // Including main frame.
+
+ void updateTextCheckerState();
+
+ void registerNewWebBackForwardListItem(WebBackForwardListItem*);
+
+private:
+ explicit WebProcessProxy(WebContext*);
+
+ void connect();
+
+ bool sendMessage(CoreIPC::MessageID, PassOwnPtr<CoreIPC::ArgumentEncoder>);
+
+ void addBackForwardItem(uint64_t itemID, const String& originalURLString, const String& urlString, const String& title, const CoreIPC::DataReference& backForwardData);
+
+#if ENABLE(PLUGIN_PROCESS)
+ void getPluginProcessConnection(const String& pluginPath, CoreIPC::ArgumentEncoder* reply);
+#endif
+
+ // CoreIPC::Connection::Client
+ void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
+ CoreIPC::SyncReplyMode didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*, CoreIPC::ArgumentEncoder*);
+ void didClose(CoreIPC::Connection*);
+ void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::MessageID);
+
+ // 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*);
+
+ ResponsivenessTimer m_responsivenessTimer;
+ RefPtr<CoreIPC::Connection> m_connection;
+
+ Vector<CoreIPC::Connection::OutgoingMessage> m_pendingMessages;
+ RefPtr<ProcessLauncher> m_processLauncher;
+ RefPtr<ThreadLauncher> m_threadLauncher;
+
+ WebContext* m_context;
+
+ WebPageProxyMap m_pageMap;
+ WebFrameProxyMap m_frameMap;
+ WebBackForwardListItemMap m_backForwardListItemMap;
+};
+
+template<typename E, typename T>
+bool WebProcessProxy::send(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());
+}
+
+template<typename T>
+bool WebProcessProxy::send(const T& message, uint64_t destinationID)
+{
+ OwnPtr<CoreIPC::ArgumentEncoder> argumentEncoder = CoreIPC::ArgumentEncoder::create(destinationID);
+ argumentEncoder->encode(message);
+
+ return sendMessage(CoreIPC::MessageID(T::messageID), argumentEncoder.release());
+}
+
+template<typename U>
+bool WebProcessProxy::sendSync(const U& message, const typename U::Reply& reply, uint64_t destinationID, double timeout)
+{
+ return m_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 0000000..86bc9e2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebProcessProxy.messages.in
@@ -0,0 +1,28 @@
+# 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)
+
+}
diff --git a/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp b/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp
new file mode 100644
index 0000000..675890f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebResourceLoadClient.cpp
@@ -0,0 +1,90 @@
+/*
+ * 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 "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)
+{
+ if (!m_client.didInitiateLoadForResource)
+ return;
+
+ RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
+ return m_client.didInitiateLoadForResource(toAPI(page), toAPI(frame), resourceIdentifier, toAPI(request.get()), 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 0000000..e2e322f
--- /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> {
+public:
+ void didInitiateLoadForResource(WebPageProxy*, WebFrameProxy*, uint64_t resourceIdentifier, const WebCore::ResourceRequest&);
+ 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/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp
new file mode 100644
index 0000000..e95af34
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebUIClient.cpp
@@ -0,0 +1,276 @@
+/*
+ * 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 "WebUIClient.h"
+
+#include "ImmutableDictionary.h"
+#include "NativeWebKeyboardEvent.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 WindowFeatures& windowFeatures, WebEvent::Modifiers modifiers, WebMouseEvent::Button button)
+{
+ if (!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("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);
+
+ return adoptRef(toImpl(m_client.createNewPage(toAPI(page), 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::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, WebEvent::Modifiers modifiers, APIObject* userData)
+{
+ if (!m_client.mouseDidMoveOverElement)
+ return;
+
+ m_client.mouseDidMoveOverElement(toAPI(page), toAPI(modifiers), toAPI(userData), m_client.clientInfo);
+}
+
+void WebUIClient::missingPluginButtonClicked(WebPageProxy* page, const String& mimeType, const String& url)
+{
+ if (!m_client.missingPluginButtonClicked)
+ return;
+
+ m_client.missingPluginButtonClicked(toAPI(page), toAPI(mimeType.impl()), toAPI(url.impl()), m_client.clientInfo);
+}
+
+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::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()
+{
+ 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 currentUsage, 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, currentUsage, expectedUsage, m_client.clientInfo);
+}
+
+bool WebUIClient::runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, const WebOpenPanelParameters::Data& parameterData, WebOpenPanelResultListenerProxy* listener)
+{
+ if (!m_client.runOpenPanel)
+ return false;
+
+ RefPtr<WebOpenPanelParameters> parameters = WebOpenPanelParameters::create(parameterData);
+ m_client.runOpenPanel(toAPI(page), toAPI(frame), toAPI(parameters.get()), 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;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h
new file mode 100644
index 0000000..a25b37f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/WebUIClient.h
@@ -0,0 +1,93 @@
+/*
+ * 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 WebUIClient_h
+#define WebUIClient_h
+
+#include "APIClient.h"
+#include "WKPage.h"
+#include "WebEvent.h"
+#include "WebOpenPanelParameters.h"
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+ class FloatRect;
+ class IntSize;
+ struct WindowFeatures;
+}
+
+namespace WebKit {
+
+class APIObject;
+class GeolocationPermissionRequestProxy;
+class NativeWebKeyboardEvent;
+class WebFrameProxy;
+class WebPageProxy;
+class WebSecurityOrigin;
+class WebOpenPanelResultListenerProxy;
+
+class WebUIClient : public APIClient<WKPageUIClient> {
+public:
+ PassRefPtr<WebPageProxy> createNewPage(WebPageProxy*, const WebCore::WindowFeatures&, WebEvent::Modifiers, WebMouseEvent::Button);
+ void showPage(WebPageProxy*);
+ void close(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*, WebEvent::Modifiers, APIObject*);
+ void missingPluginButtonClicked(WebPageProxy*, const String& mimeType, const String& url);
+ void didNotHandleKeyEvent(WebPageProxy*, const NativeWebKeyboardEvent&);
+
+ 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();
+ 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 currentUsage, unsigned long long expectedUsage);
+
+ bool runOpenPanel(WebPageProxy*, WebFrameProxy*, const WebOpenPanelParameters::Data&, WebOpenPanelResultListenerProxy*);
+ bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy*);
+};
+
+} // namespace WebKit
+
+#endif // WebUIClient_h
diff --git a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
new file mode 100644
index 0000000..3f03980
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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 "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
+{
+ RetainPtr<CFNumberRef> currentIndex(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &m_current));
+ RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks));
+
+ const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() };
+ const void* values[2] = { currentIndex.get(), entries.get() };
+
+ RetainPtr<CFDictionaryRef> dictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+
+ for (size_t i = 0; i < m_entries.size(); ++i) {
+ RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url());
+ if (!filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context))
+ 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());
+ 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());
+ }
+
+ return dictionary.leakRef();
+}
+
+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);
+ 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_current = currentIndex;
+ m_entries = newEntries;
+ 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 0000000..c1b7971
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebPageProxyCF.cpp
@@ -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.
+ */
+
+#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")));
+
+static const UInt32 CurrentSessionStateDataVersion = 2;
+
+PassRefPtr<WebData> WebPageProxy::sessionStateData(WebPageProxySessionStateFilterCallback filter, void* context) const
+{
+ RetainPtr<CFDictionaryRef> sessionHistoryDictionary(AdoptCF, m_backForwardList->createCFDictionaryRepresentation(filter, context));
+
+ // For now we're only serializing the back/forward list. If that object is null, then the entire sessionState can be null.
+ if (!sessionHistoryDictionary)
+ return 0;
+
+ const void* keys[1] = { SessionHistoryKey() };
+ const void* values[1] = { sessionHistoryDictionary.get() };
+
+ RetainPtr<CFDictionaryRef> stateDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 1, &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;
+ }
+
+ CFTypeRef sessionHistoryRef = CFDictionaryGetValue(static_cast<CFDictionaryRef>(propertyList.get()), SessionHistoryKey());
+ if (!sessionHistoryRef || CFGetTypeID(sessionHistoryRef) != CFDictionaryGetTypeID()) {
+ LOG(SessionState, "SessionState dictionary does not contain a SessionHistoryDictionary key, it is of the wrong type");
+ return;
+ }
+
+ CFDictionaryRef sessionHistoryDictionary = static_cast<CFDictionaryRef>(sessionHistoryRef);
+ if (!m_backForwardList->restoreFromCFDictionaryRepresentation(sessionHistoryDictionary)) {
+ LOG(SessionState, "Failed to restore back/forward list from SessionHistoryDictionary");
+ return;
+ }
+
+ const BackForwardListItemVector& entries = m_backForwardList->entries();
+ size_t size = entries.size();
+ for (size_t i = 0; i < size; ++i)
+ process()->registerNewWebBackForwardListItem(entries[i].get());
+
+ process()->send(Messages::WebPage::RestoreSessionAndNavigateToCurrentItem(SessionState(m_backForwardList->entries(), m_backForwardList->currentIndex())), m_pageID);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.cpp
new file mode 100644
index 0000000..7b89d04
--- /dev/null
+++ b/Source/WebKit2/UIProcess/cf/WebPreferencesCF.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 "WebPreferences.h"
+
+#if !PLATFORM(MAC)
+
+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
+
+#endif // !PLATFORM(MAC)
diff --git a/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp
new file mode 100644
index 0000000..3d7ba2d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp
@@ -0,0 +1,97 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "NotImplemented.h"
+#include "TextCheckerState.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();
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ notImplemented();
+ return Vector<WebCore::TextCheckingResult>();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
+void TextChecker::learnWord(const String& word)
+{
+ notImplemented();
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp
new file mode 100644
index 0000000..86ae636
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebInspectorGtk.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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <wtf/text/WTFString.h>
+
+#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
+#include "NotImplemented.h"
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformClose()
+{
+ notImplemented();
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ notImplemented();
+ return String();
+}
+
+} // 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 0000000..71befa4
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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 "WebPageProxy.h"
+
+namespace WebKit {
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ // FIXME: This should not be hard coded.
+ return "Mozilla/5.0 (X11; U; Linux i686; en-us) AppleWebKit/534.7 (KHTML, like Gecko) Version/5.0 Safari/534.7";
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp b/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
new file mode 100644
index 0000000..3da7323
--- /dev/null
+++ b/Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include "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 0000000..979f755
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/BackingStoreMac.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.
+ */
+
+#include "BackingStore.h"
+
+#include "CGUtilities.h"
+#include "ShareableBitmap.h"
+#include "UpdateInfo.h"
+#include <WebCore/GraphicsContext.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void BackingStore::paint(PlatformGraphicsContext context, const IntRect& rect)
+{
+ ASSERT(m_bitmapContext);
+
+ paintBitmapContext(context, m_bitmapContext.get(), rect.location(), rect);
+}
+
+void BackingStore::incorporateUpdate(const UpdateInfo& updateInfo)
+{
+ ASSERT(m_size == updateInfo.viewSize);
+
+ RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.updateRectBounds.size(), updateInfo.bitmapHandle);
+ if (!bitmap)
+ return;
+
+ 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));
+
+ // 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);
+ }
+
+ scroll(updateInfo.scrollRect, updateInfo.scrollDelta);
+
+ IntPoint updateRectLocation = updateInfo.updateRectBounds.location();
+
+ GraphicsContext graphicsContext(m_bitmapContext.get());
+
+ // 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& scrollDelta)
+{
+ if (scrollDelta.isZero())
+ return;
+
+ CGContextSaveGState(m_bitmapContext.get());
+
+ CGContextClipToRect(m_bitmapContext.get(), scrollRect);
+
+ CGPoint destination = CGPointMake(scrollRect.x() + scrollDelta.width(), scrollRect.y() + scrollDelta.height());
+ paintBitmapContext(m_bitmapContext.get(), m_bitmapContext.get(), destination, scrollRect);
+
+ CGContextRestoreGState(m_bitmapContext.get());
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm b/Source/WebKit2/UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm
new file mode 100644
index 0000000..909745b
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/ChunkedUpdateDrawingAreaProxyMac.mm
@@ -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 "ChunkedUpdateDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "UpdateChunk.h"
+#include "WKAPICast.h"
+#include "WKView.h"
+#include "WebPageProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageProxy* ChunkedUpdateDrawingAreaProxy::page()
+{
+ return toImpl([m_webView pageRef]);
+}
+
+void ChunkedUpdateDrawingAreaProxy::ensureBackingStore()
+{
+ if (m_bitmapContext)
+ return;
+
+ RetainPtr<CGColorSpaceRef> colorSpace(AdoptCF, CGColorSpaceCreateDeviceRGB());
+ const IntSize& viewSize = size();
+ m_bitmapContext.adoptCF(CGBitmapContextCreate(0, viewSize.width(), viewSize.height(), 8, viewSize.width() * 4, colorSpace.get(), kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host));
+
+ // Flip the bitmap context coordinate system.
+ CGContextTranslateCTM(m_bitmapContext.get(), 0, viewSize.height());
+ CGContextScaleCTM(m_bitmapContext.get(), 1, -1);
+}
+
+void ChunkedUpdateDrawingAreaProxy::invalidateBackingStore()
+{
+ m_bitmapContext = 0;
+}
+
+bool ChunkedUpdateDrawingAreaProxy::platformPaint(const IntRect& rect, CGContextRef context)
+{
+ if (!m_bitmapContext)
+ return false;
+
+ CGContextSaveGState(context);
+
+ // Use the copy blend mode when drawing a background.
+ if (page()->drawsBackground())
+ CGContextSetBlendMode(context, kCGBlendModeCopy);
+
+ // Flip the destination.
+ CGContextScaleCTM(context, 1, -1);
+ CGContextTranslateCTM(context, 0, -m_size.height());
+
+ RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(m_bitmapContext.get()));
+ CGContextDrawImage(context, CGRectMake(0, 0, CGImageGetWidth(image.get()), CGImageGetHeight(image.get())), image.get());
+
+ CGContextRestoreGState(context);
+ return true;
+}
+
+void ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore(UpdateChunk* updateChunk)
+{
+ ensureBackingStore();
+
+ RetainPtr<CGImageRef> image(updateChunk->createImage());
+ IntRect updateChunkRect = updateChunk->rect();
+
+ CGContextSaveGState(m_bitmapContext.get());
+
+ // Use the copy blend mode to replace existing content.
+ CGContextSetBlendMode(m_bitmapContext.get(), kCGBlendModeCopy);
+
+ // Flip the destination.
+ CGContextScaleCTM(m_bitmapContext.get(), 1, -1);
+ CGContextTranslateCTM(m_bitmapContext.get(), 0, -(updateChunkRect.y() + updateChunkRect.bottom()));
+
+ CGContextDrawImage(m_bitmapContext.get(), updateChunkRect, image.get());
+
+ CGContextRestoreGState(m_bitmapContext.get());
+
+ [m_webView setNeedsDisplayInRect:NSRectFromCGRect(updateChunkRect)];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/LayerBackedDrawingAreaProxyMac.mm b/Source/WebKit2/UIProcess/mac/LayerBackedDrawingAreaProxyMac.mm
new file mode 100644
index 0000000..846eb25
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/LayerBackedDrawingAreaProxyMac.mm
@@ -0,0 +1,92 @@
+/*
+ * 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 "LayerBackedDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include <QuartzCore/QuartzCore.h>
+#include "WKAPICast.h"
+#include "WKView.h"
+#include "WKViewInternal.h"
+#include "WebKitSystemInterface.h"
+#include "WebPageProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageProxy* LayerBackedDrawingAreaProxy::page()
+{
+ return toImpl([m_webView pageRef]);
+}
+
+void LayerBackedDrawingAreaProxy::platformSetSize()
+{
+ [m_compositingRootLayer.get() setBounds:CGRectMake(0, 0, size().width(), size().height())];
+}
+
+void LayerBackedDrawingAreaProxy::attachCompositingContext(uint32_t contextID)
+{
+#if HAVE(HOSTED_CORE_ANIMATION)
+ m_compositingRootLayer = WKMakeRenderLayer(contextID);
+
+ // Turn off default animations.
+ NSNull *nullValue = [NSNull null];
+ NSDictionary *actions = [NSDictionary dictionaryWithObjectsAndKeys:
+ nullValue, @"anchorPoint",
+ nullValue, @"bounds",
+ nullValue, @"contents",
+ nullValue, @"contentsRect",
+ nullValue, @"opacity",
+ nullValue, @"position",
+ nullValue, @"sublayerTransform",
+ nullValue, @"sublayers",
+ nullValue, @"transform",
+ nil];
+ [m_compositingRootLayer.get() setStyle:[NSDictionary dictionaryWithObject:actions forKey:@"actions"]];
+
+ [m_compositingRootLayer.get() setAnchorPoint:CGPointZero];
+ [m_compositingRootLayer.get() setBounds:CGRectMake(0, 0, size().width(), size().height())];
+
+ // FIXME: this fixes the layer jiggle when resizing the window, but breaks layer flipping because
+ // CA doesn't propagate the kCALayerFlagFlippedAbove through the remote layer.
+ // [m_compositingRootLayer.get() setGeometryFlipped:YES];
+
+#ifndef NDEBUG
+ [m_compositingRootLayer.get() setName:@"Compositing root layer"];
+#endif
+
+ [m_webView _startAcceleratedCompositing:m_compositingRootLayer.get()];
+#endif
+}
+
+void LayerBackedDrawingAreaProxy::detachCompositingContext()
+{
+ [m_webView _stopAcceleratedCompositing];
+ m_compositingRootLayer = 0;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
new file mode 100644
index 0000000..c89011e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
@@ -0,0 +1,328 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "TextCheckerState.h"
+#include <wtf/RetainPtr.h>
+
+#ifndef BUILDING_ON_SNOW_LEOPARD
+#import <AppKit/NSTextChecker.h>
+#endif
+
+static const NSString * const WebAutomaticSpellingCorrectionEnabled = @"WebAutomaticSpellingCorrectionEnabled";
+static const NSString * const WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckingEnabled";
+static const NSString * const WebGrammarCheckingEnabled = @"WebGrammarCheckingEnabled";
+static const NSString * const WebSmartInsertDeleteEnabled = @"WebSmartInsertDeleteEnabled";
+static const NSString * const WebAutomaticQuoteSubstitutionEnabled = @"WebAutomaticQuoteSubstitutionEnabled";
+static const NSString * const WebAutomaticDashSubstitutionEnabled = @"WebAutomaticDashSubstitutionEnabled";
+static const NSString * const WebAutomaticLinkDetectionEnabled = @"WebAutomaticLinkDetectionEnabled";
+static const 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] boolForKey:WebSmartInsertDeleteEnabled];
+
+ readSmartInsertDeleteEnabledDefault = true;
+ }
+
+ return smartInsertDeleteEnabled;
+}
+
+void TextChecker::setSmartInsertDeleteEnabled(bool flag)
+{
+ if (flag == isSmartInsertDeleteEnabled())
+ return;
+
+ smartInsertDeleteEnabled = flag;
+
+ [[NSUserDefaults standardUserDefaults] setBool:flag forKey:WebSmartInsertDeleteEnabled];
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ return [NSSpellChecker uniqueSpellDocumentTag];
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
+{
+ [[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag];
+}
+
+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;
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
+}
+
+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(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/WebContextMac.mm b/Source/WebKit2/UIProcess/mac/WebContextMac.mm
new file mode 100644
index 0000000..ce4c3e6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMac.mm
@@ -0,0 +1,93 @@
+/*
+ * 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 "WebContext.h"
+
+#include "WebKitSystemInterface.h"
+#include "WebProcessCreationParameters.h"
+#include <WebCore/FileSystem.h>
+#include <sys/param.h>
+
+using namespace WebCore;
+
+NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
+
+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]]) {
+#ifdef BUILDING_ON_TIGER
+ cacheDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
+#else
+ char cacheDirectory[MAXPATHLEN];
+ size_t cacheDirectoryLen = confstr(_CS_DARWIN_USER_CACHE_DIR, cacheDirectory, MAXPATHLEN);
+
+ if (cacheDirectoryLen)
+ cacheDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:cacheDirectory length:cacheDirectoryLen - 1];
+#endif
+ }
+
+ return [cacheDir stringByAppendingPathComponent:appName];
+}
+
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
+{
+ // 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.nsURLCachePath = fileSystemRepresentation([(NSString *)cachePath.get() stringByStandardizingPath]);
+ parameters.nsURLCacheMemoryCapacity = [urlCache memoryCapacity];
+ parameters.nsURLCacheDiskCapacity = [urlCache diskCapacity];
+
+#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 = fileSystemRepresentation([[NSBundle mainBundle] resourcePath]);
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h
new file mode 100644
index 0000000..ee4fa3d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.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 WebContextMenuProxyMac_h
+#define WebContextMenuProxyMac_h
+
+#include "WebContextMenuProxy.h"
+#include <wtf/RetainPtr.h>
+
+#ifdef __OBJC__
+@class NSPopUpButtonCell;
+@class WKView;
+#else
+class NSPopUpButtonCell;
+class WKView;
+#endif
+
+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 0000000..d76b997
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm
@@ -0,0 +1,232 @@
+/*
+ * 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 "WebContextMenuProxyMac.h"
+
+#include "PageClientImpl.h"
+#include "WebContextMenuItemData.h"
+#include "WKView.h"
+
+#include <WebCore/IntRect.h>
+#include <WebKitSystemInterface.h>
+
+using namespace WebCore;
+
+@interface WebUserDataWrapper : NSObject {
+ RefPtr<WebKit::APIObject> _webUserData;
+}
+- (id)initWithUserData:(WebKit::APIObject*)userData;
+- (WebKit::APIObject*)userData;
+@end
+
+@implementation WebUserDataWrapper
+
+- (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:[WebUserDataWrapper class]]);
+ item.setUserData([static_cast<WebUserDataWrapper *>(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()) {
+ WebUserDataWrapper *wrapper = [[WebUserDataWrapper 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)
+{
+ 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);
+
+ RetainPtr<NSView> dummyView(AdoptNS, [[NSView alloc] initWithFrame:menuRect]);
+ [m_webView addSubview:dummyView.get()];
+ location = [dummyView.get() convertPoint:location fromView:m_webView];
+
+ WKPopupMenu(menu, location, roundf(NSWidth(menuRect)), dummyView.get(), -1, nil);
+
+ [m_popup.get() dismissPopUp];
+ [dummyView.get() removeFromSuperview];
+}
+
+void WebContextMenuProxyMac::hideContextMenu()
+{
+ [m_popup.get() dismissPopUp];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
new file mode 100644
index 0000000..e129094
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
@@ -0,0 +1,142 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#import "WKAPICast.h"
+#import "WKView.h"
+#import "WebPageProxy.h"
+#import <WebKitSystemInterface.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;
+
+// WebInspectorProxyObjCAdapter 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 WebInspectorProxyObjCAdapter : NSObject <NSWindowDelegate> {
+ WebInspectorProxy* _inspectorProxy; // Not retained to prevent cycles
+}
+
+- (id)initWithWebInspectorProxy:(WebInspectorProxy*)inspectorProxy;
+
+@end
+
+@implementation WebInspectorProxyObjCAdapter
+
+- (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();
+}
+
+@end
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(m_page);
+ ASSERT(!m_inspectorView);
+
+ m_inspectorView.adoptNS([[WKView alloc] initWithFrame:NSZeroRect contextRef:toAPI(page()->context()) pageGroupRef:toAPI(inspectorPageGroup())]);
+ ASSERT(m_inspectorView);
+
+ return toImpl(m_inspectorView.get().pageRef);
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ ASSERT(!m_inspectorWindow);
+
+ m_inspectorProxyObjCAdapter.adoptNS([[WebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
+
+ // FIXME: support opening in docked mode here.
+
+ NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSTexturedBackgroundWindowMask);
+ NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
+ [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
+ [window setContentBorderThickness:windowContentBorderThickness forEdge:NSMaxYEdge];
+ [window setDelegate:m_inspectorProxyObjCAdapter.get()];
+ [window setMinSize:NSMakeSize(minimumWindowWidth, minimumWindowHeight)];
+ [window setReleasedWhenClosed:NO];
+
+ // 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"];
+
+ WKNSWindowMakeBottomCornersSquare(window);
+
+ NSView *contentView = [window contentView];
+ [m_inspectorView.get() setFrame:[contentView bounds]];
+ [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
+ [contentView addSubview:m_inspectorView.get()];
+
+ [window makeKeyAndOrderFront:nil];
+
+ m_inspectorWindow.adoptNS(window);
+}
+
+void WebInspectorProxy::platformClose()
+{
+ // FIXME: support closing in docked mode here.
+
+ [m_inspectorWindow.get() setDelegate:nil];
+ [m_inspectorWindow.get() orderOut:nil];
+
+ m_inspectorWindow = 0;
+ m_inspectorView = 0;
+ m_inspectorProxyObjCAdapter = 0;
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.WebCore"] pathForResource:@"inspector" ofType:@"html" inDirectory:@"inspector"];
+ ASSERT(path);
+
+ 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 0000000..36905fb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm
@@ -0,0 +1,113 @@
+/*
+ * 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 "WebPageProxy.h"
+
+#include <WebCore/Language.h>
+#include <wtf/text/StringConcatenate.h>
+
+@interface NSApplication (Details)
+- (void)speakString:(NSString *)string;
+@end
+
+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
+
+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);
+}
+
+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()));
+
+ // FIXME: We should upate the user agent if the default language changes.
+ String language = defaultLanguage();
+
+ if (applicationNameForUserAgent.isEmpty())
+ return makeString("Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)");
+ return makeString("Mozilla/5.0 (Macintosh; U; " PROCESSOR " Mac OS X ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent);
+}
+
+void WebPageProxy::getIsSpeaking(bool& isSpeaking)
+{
+ isSpeaking = [NSApp isSpeaking];
+}
+
+void WebPageProxy::speak(const String& string)
+{
+ NSString *convertedString = string;
+ [NSApp speakString:convertedString];
+}
+
+void WebPageProxy::stopSpeaking()
+{
+ [NSApp stopSpeaking:nil];
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.h
new file mode 100644
index 0000000..85339d6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.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 WebPopupMenuProxyMac_h
+#define WebPopupMenuProxyMac_h
+
+#include "WebPopupMenuProxy.h"
+#include <wtf/RetainPtr.h>
+
+#ifdef __OBJC__
+@class NSPopUpButtonCell;
+@class WKView;
+#else
+class NSPopUpButtonCell;
+class WKView;
+#endif
+
+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&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+private:
+ WebPopupMenuProxyMac(WKView*, WebPopupMenuProxy::Client* client);
+
+ void populate(const Vector<WebPopupItem>&);
+
+ 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 0000000..481e8c5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPopupMenuProxyMac.mm
@@ -0,0 +1,109 @@
+/*
+ * 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 "WebPopupMenuProxyMac.h"
+
+#include "PageClientImpl.h"
+#include "PlatformPopupMenuData.h"
+#include "WKView.h"
+#include "WebPopupItem.h"
+#include <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)
+{
+ 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::Seperator)
+ [[m_popup.get() menu] addItem:[NSMenuItem separatorItem]];
+ else {
+ [m_popup.get() addItemWithTitle:nsStringFromWebCoreString(items[i].m_text)];
+ NSMenuItem* menuItem = [m_popup.get() lastItem];
+ [menuItem setEnabled:items[i].m_isEnabled];
+ [menuItem setToolTip:nsStringFromWebCoreString(items[i].m_toolTip)];
+ }
+ }
+}
+
+void WebPopupMenuProxyMac::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
+{
+ populate(items);
+
+ [m_popup.get() attachPopUpWithFrame:rect inView:m_webView];
+ [m_popup.get() selectItemAtIndex:selectedIndex];
+
+ NSMenu* menu = [m_popup.get() menu];
+
+ // These values were borrowed from AppKit to match their placement of the menu.
+ const int popOverHorizontalAdjust = -10;
+ 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));
+ NSPoint location = NSMakePoint(NSMinX(rect) + popOverHorizontalAdjust, NSMaxY(rect) - vertOffset);
+
+ 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, [NSFont menuFontOfSize:0]);
+
+ [m_popup.get() dismissPopUp];
+ [dummyView.get() removeFromSuperview];
+
+ m_client->valueChangedForPopupMenu(this, [m_popup.get() indexOfSelectedItem]);
+}
+
+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 0000000..b954bd2
--- /dev/null
+++ b/Source/WebKit2/UIProcess/mac/WebPreferencesMac.mm
@@ -0,0 +1,127 @@
+/*
+ * 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 "WebPreferences.h"
+
+#include "PageClientImpl.h"
+#include <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/qt/ChunkedUpdateDrawingAreaProxyQt.cpp b/Source/WebKit2/UIProcess/qt/ChunkedUpdateDrawingAreaProxyQt.cpp
new file mode 100644
index 0000000..06ce7c6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/ChunkedUpdateDrawingAreaProxyQt.cpp
@@ -0,0 +1,81 @@
+/*
+ * 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 "ChunkedUpdateDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "UpdateChunk.h"
+#include "WKAPICast.h"
+#include "WebPageProxy.h"
+#include "qgraphicswkview.h"
+#include <QPainter>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageProxy* ChunkedUpdateDrawingAreaProxy::page()
+{
+ return toImpl(m_webView->page()->pageRef());
+}
+
+void ChunkedUpdateDrawingAreaProxy::ensureBackingStore()
+{
+ if (!m_backingStoreImage.isNull())
+ return;
+
+ m_backingStoreImage = QImage(size().width(), size().height(), QImage::Format_RGB32);
+}
+
+void ChunkedUpdateDrawingAreaProxy::invalidateBackingStore()
+{
+ m_backingStoreImage = QImage();
+}
+
+bool ChunkedUpdateDrawingAreaProxy::platformPaint(const IntRect& rect, QPainter* painter)
+{
+ if (m_backingStoreImage.isNull())
+ return false;
+
+ painter->drawImage(QPoint(0, 0), m_backingStoreImage);
+ return true;
+}
+
+void ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore(UpdateChunk* updateChunk)
+{
+ ensureBackingStore();
+
+ QImage image(updateChunk->createImage());
+ const IntRect& updateChunkRect = updateChunk->rect();
+
+ QPainter painter(&m_backingStoreImage);
+ painter.drawImage(updateChunkRect.topLeft(), image);
+
+ m_webView->update(QRect(updateChunkRect));
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp
new file mode 100644
index 0000000..9ab6297
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp
@@ -0,0 +1,98 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "NotImplemented.h"
+#include "TextCheckerState.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();
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ notImplemented();
+ return Vector<WebCore::TextCheckingResult>();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
+void TextChecker::learnWord(const String& word)
+{
+ 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 0000000..59faa1e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp
@@ -0,0 +1,71 @@
+/*
+ * 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 "TiledDrawingAreaProxy.h"
+
+#if ENABLE(TILED_BACKING_STORE)
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "UpdateChunk.h"
+#include "WKAPICast.h"
+#include "WebPageProxy.h"
+
+#include "qgraphicswkview.h"
+
+using namespace WebCore;
+
+#define TILE_DEBUG_LOG
+
+namespace WebKit {
+
+void TiledDrawingAreaProxy::updateWebView(const Vector<IntRect>& paintedArea)
+{
+ if (!page() || !page()->isValid())
+ return;
+
+ unsigned size = paintedArea.size();
+ for (unsigned n = 0; n < size; ++n)
+ m_webView->update(QRect(paintedArea[n]));
+}
+
+IntRect TiledDrawingAreaProxy::webViewVisibleRect()
+{
+ return enclosingIntRect(FloatRect(m_webView->visibleRect()));
+}
+
+WebPageProxy* TiledDrawingAreaProxy::page()
+{
+ return toImpl(m_webView->page()->pageRef());
+}
+
+void TiledDrawingAreaProxy::snapshotTaken(UpdateChunk& chunk)
+{
+ emit m_webView->snapshotTaken(chunk.createImage());
+}
+
+} // namespace WebKit
+
+#endif
diff --git a/Source/WebKit2/UIProcess/qt/TiledDrawingAreaTileQt.cpp b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaTileQt.cpp
new file mode 100644
index 0000000..2b631ca
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaTileQt.cpp
@@ -0,0 +1,160 @@
+/*
+ * 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 "TiledDrawingAreaTile.h"
+
+#if ENABLE(TILED_BACKING_STORE)
+
+#include "GraphicsContext.h"
+#include "TiledDrawingAreaProxy.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+#include "UpdateChunk.h"
+#include <QApplication>
+#include <QObject>
+#include <QPainter>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+TiledDrawingAreaTile::TiledDrawingAreaTile(TiledDrawingAreaProxy* proxy, const Coordinate& tileCoordinate)
+ : m_proxy(proxy)
+ , m_coordinate(tileCoordinate)
+ , m_rect(proxy->tileRectForCoordinate(tileCoordinate))
+ , m_hasUpdatePending(false)
+ , m_dirtyRegion(m_rect)
+{
+ static int id = 0;
+ m_ID = ++id;
+#ifdef TILE_DEBUG_LOG
+ qDebug() << "deleting tile id=" << m_ID;
+#endif
+}
+
+TiledDrawingAreaTile::~TiledDrawingAreaTile()
+{
+#ifdef TILE_DEBUG_LOG
+ qDebug() << "deleting tile id=" << m_ID;
+#endif
+}
+
+bool TiledDrawingAreaTile::isDirty() const
+{
+ return !m_dirtyRegion.isEmpty();
+}
+
+bool TiledDrawingAreaTile::isReadyToPaint() const
+{
+ return !m_buffer.isNull();
+}
+
+bool TiledDrawingAreaTile::hasReadyBackBuffer() const
+{
+ return !m_backBuffer.isNull() && !m_hasUpdatePending;
+}
+
+void TiledDrawingAreaTile::invalidate(const IntRect& dirtyRect)
+{
+ IntRect tileDirtyRect = intersection(dirtyRect, m_rect);
+ if (tileDirtyRect.isEmpty())
+ return;
+
+ m_dirtyRegion += tileDirtyRect;
+}
+
+void TiledDrawingAreaTile::resize(const IntSize& newSize)
+{
+ IntRect oldRect = m_rect;
+ m_rect = IntRect(m_rect.topLeft(), newSize);
+ if (m_rect.right() > oldRect.right())
+ invalidate(IntRect(oldRect.right(), oldRect.y(), m_rect.right() - oldRect.right(), m_rect.height()));
+ if (m_rect.bottom() > oldRect.bottom())
+ invalidate(IntRect(oldRect.x(), oldRect.bottom(), m_rect.width(), m_rect.bottom() - oldRect.bottom()));
+}
+
+void TiledDrawingAreaTile::swapBackBufferToFront()
+{
+ ASSERT(!m_backBuffer.isNull());
+
+ m_buffer = m_backBuffer;
+ m_backBuffer = QPixmap();
+}
+
+void TiledDrawingAreaTile::paint(GraphicsContext* context, const IntRect& rect)
+{
+ ASSERT(!m_buffer.isNull());
+
+ IntRect target = intersection(rect, m_rect);
+ IntRect source((target.x() - m_rect.x()),
+ (target.y() - m_rect.y()),
+ target.width(),
+ target.height());
+
+ context->platformContext()->drawPixmap(target, m_buffer, source);
+}
+
+void TiledDrawingAreaTile::updateFromChunk(UpdateChunk* updateChunk, float)
+{
+ QImage image(updateChunk->createImage());
+ const IntRect& updateChunkRect = updateChunk->rect();
+
+#ifdef TILE_DEBUG_LOG
+ qDebug() << "tile updated id=" << ID() << " rect=" << QRect(updateChunkRect);
+#endif
+ if (updateChunkRect.size() == m_proxy->tileSize()) {
+ // Make a deep copy of the image since it's in shared memory.
+ m_backBuffer = QPixmap::fromImage(image.copy());
+ } else {
+ if (m_backBuffer.isNull())
+ m_backBuffer = m_buffer.isNull() ? QPixmap(m_proxy->tileSize()) : m_buffer;
+ QPainter painter(&m_backBuffer);
+ IntSize drawPoint = updateChunkRect.topLeft() - m_rect.topLeft();
+ painter.drawImage(QPoint(drawPoint.width(), drawPoint.height()), image);
+ }
+ m_hasUpdatePending = false;
+}
+
+void TiledDrawingAreaTile::updateBackBuffer()
+{
+ if (isReadyToPaint() && !isDirty())
+ return;
+
+ // FIXME: individual rects
+ IntRect dirtyRect = m_dirtyRegion.boundingRect();
+ m_dirtyRegion = QRegion();
+
+#ifdef TILE_DEBUG_LOG
+ qDebug() << "requesting tile update id=" << m_ID << " rect=" << QRect(dirtyRect) << " scale=" << m_proxy->contentsScale();
+#endif
+ if (!m_proxy->page()->process()->isValid())
+ return;
+ m_proxy->requestTileUpdate(m_ID, dirtyRect);
+
+ m_hasUpdatePending = true;
+}
+
+}
+#endif
diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp
new file mode 100644
index 0000000..566a22e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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 "WebContextMenuProxyQt.h"
+
+#include <IntPoint.h>
+#include <WebContextMenuItemData.h>
+#include <qmenu.h>
+#include <qwkpage.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static QWKPage::WebAction webActionForContextMenuAction(WebCore::ContextMenuAction action)
+{
+ switch (action) {
+ case WebCore::ContextMenuItemTagOpenLink:
+ return QWKPage::OpenLink;
+ case WebCore::ContextMenuItemTagOpenLinkInNewWindow:
+ return QWKPage::OpenLinkInNewWindow;
+ case WebCore::ContextMenuItemTagCopyLinkToClipboard:
+ return QWKPage::CopyLinkToClipboard;
+ case WebCore::ContextMenuItemTagOpenImageInNewWindow:
+ return QWKPage::OpenImageInNewWindow;
+ case WebCore::ContextMenuItemTagGoBack:
+ return QWKPage::Back;
+ case WebCore::ContextMenuItemTagGoForward:
+ return QWKPage::Forward;
+ case WebCore::ContextMenuItemTagStop:
+ return QWKPage::Stop;
+ case WebCore::ContextMenuItemTagReload:
+ return QWKPage::Reload;
+ case WebCore::ContextMenuItemTagCut:
+ return QWKPage::Cut;
+ case WebCore::ContextMenuItemTagCopy:
+ return QWKPage::Copy;
+ case WebCore::ContextMenuItemTagPaste:
+ return QWKPage::Paste;
+ case WebCore::ContextMenuItemTagSelectAll:
+ return QWKPage::SelectAll;
+ default:
+ break;
+ }
+ return QWKPage::NoWebAction;
+}
+
+WebContextMenuProxyQt::WebContextMenuProxyQt(QWKPage* page)
+ : m_page(page)
+{
+}
+
+PassRefPtr<WebContextMenuProxyQt> WebContextMenuProxyQt::create(QWKPage* page)
+{
+ return adoptRef(new WebContextMenuProxyQt(page));
+}
+
+void WebContextMenuProxyQt::showContextMenu(const IntPoint& position, const Vector<WebContextMenuItemData>& items)
+{
+ if (QMenu* menu = createContextMenu(items)) {
+ menu->move(position);
+ emit m_page->showContextMenu(menu);
+ }
+}
+
+void WebContextMenuProxyQt::hideContextMenu()
+{
+}
+
+QMenu* WebContextMenuProxyQt::createContextMenu(const Vector<WebContextMenuItemData>& items)
+{
+ QMenu* menu = new QMenu;
+ for (int i = 0; i < items.size(); ++i) {
+ const WebContextMenuItemData& item = items.at(i);
+ switch (item.type()) {
+ case WebCore::CheckableActionType: /* fall through */
+ case WebCore::ActionType: {
+ QWKPage::WebAction action = webActionForContextMenuAction(item.action());
+ QAction* qtAction = m_page->action(action);
+ if (qtAction) {
+ qtAction->setEnabled(item.enabled());
+ qtAction->setChecked(item.checked());
+ qtAction->setCheckable(item.type() == WebCore::CheckableActionType);
+
+ menu->addAction(qtAction);
+ }
+ break;
+ }
+ case WebCore::SeparatorType:
+ menu->addSeparator();
+ break;
+ case WebCore::SubmenuType:
+ if (QMenu *subMenu = createContextMenu(item.submenu())) {
+ subMenu->setTitle(item.title());
+ menu->addAction(subMenu->menuAction());
+ }
+
+ break;
+ }
+ }
+
+ // Do not show sub-menus with just disabled actions.
+ if (menu->isEmpty()) {
+ delete menu;
+ return 0;
+ }
+ bool isAnyActionEnabled = false;
+ QList<QAction *> actions = menu->actions();
+ for (int i = 0; i < actions.count(); ++i) {
+ if (actions.at(i)->isVisible())
+ isAnyActionEnabled |= actions.at(i)->isEnabled();
+ }
+ if (!isAnyActionEnabled) {
+ delete menu;
+ return 0;
+ }
+
+ return menu;
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h
new file mode 100644
index 0000000..435204f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextMenuProxyQt.h
@@ -0,0 +1,55 @@
+/*
+ * 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"
+
+class QMenu;
+class QWKPage;
+class WebContextMenuItemData;
+
+namespace WebKit {
+
+class WebContextMenuProxyQt : public WebContextMenuProxy {
+public:
+ static PassRefPtr<WebContextMenuProxyQt> create(QWKPage*);
+
+private:
+ WebContextMenuProxyQt(QWKPage*);
+
+ virtual void showContextMenu(const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ virtual void hideContextMenu();
+
+ QMenu* createContextMenu(const Vector<WebContextMenuItemData>& items);
+
+ QWKPage* const m_page;
+};
+
+} // 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 0000000..5b2cd88
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebContextQt.cpp
@@ -0,0 +1,47 @@
+/*
+ * 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 "WebContext.h"
+
+#include "ApplicationCacheStorage.h"
+#include "WebProcessCreationParameters.h"
+
+namespace WebKit {
+
+String WebContext::applicationCacheDirectory()
+{
+#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+ return WebCore::cacheStorage().cacheDirectory();
+#else
+ return QString();
+#endif
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters&)
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
new file mode 100644
index 0000000..c04bd99
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
@@ -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.
+ */
+
+#include "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include <wtf/text/WTFString.h>
+
+#define DISABLE_NOT_IMPLEMENTED_WARNINGS 1
+#include "NotImplemented.h"
+
+namespace WebKit {
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ notImplemented();
+ return 0;
+}
+
+void WebInspectorProxy::platformOpen()
+{
+ notImplemented();
+}
+
+void WebInspectorProxy::platformClose()
+{
+ notImplemented();
+}
+
+String WebInspectorProxy::inspectorPageURL() 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 0000000..baf765a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPageProxyQt.cpp
@@ -0,0 +1,36 @@
+/*
+ * 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 "WebPageProxy.h"
+
+namespace WebKit {
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ // FIXME: This should not be hard coded.
+ return "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6; en-us) AppleWebKit/531.4 (KHTML, like Gecko) Version/4.0.3 Safari/531.4";
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
new file mode 100644
index 0000000..5e13499
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.cpp
@@ -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.
+ */
+
+#include "WebPopupMenuProxyQt.h"
+
+#include "PlatformPopupMenuData.h"
+#include "WebPopupItem.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPopupMenuProxyQt::WebPopupMenuProxyQt()
+ : WebPopupMenuProxy(0)
+{
+}
+
+WebPopupMenuProxyQt::~WebPopupMenuProxyQt()
+{
+}
+
+void WebPopupMenuProxyQt::showPopupMenu(const IntRect& rect, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex)
+{
+}
+
+void WebPopupMenuProxyQt::hidePopupMenu()
+{
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.h
new file mode 100644
index 0000000..e6c7a1e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPopupMenuProxyQt.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 WebPopupMenuProxyQt_h
+#define WebPopupMenuProxyQt_h
+
+#include "WebPopupMenuProxy.h"
+
+namespace WebKit {
+
+class WebPopupMenuProxyQt : public WebPopupMenuProxy {
+public:
+ static PassRefPtr<WebPopupMenuProxyQt> create()
+ {
+ return adoptRef(new WebPopupMenuProxyQt());
+ }
+ ~WebPopupMenuProxyQt();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+private:
+ WebPopupMenuProxyQt();
+};
+
+} // 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 0000000..173cfd5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/qt/WebPreferencesQt.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 "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/ChunkedUpdateDrawingAreaProxyWin.cpp b/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp
new file mode 100644
index 0000000..6a1ee36
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/ChunkedUpdateDrawingAreaProxyWin.cpp
@@ -0,0 +1,106 @@
+/*
+ * 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 "ChunkedUpdateDrawingAreaProxy.h"
+
+#include "UpdateChunk.h"
+#include "WebProcessProxy.h"
+#include "WebView.h"
+#include <WebCore/BitmapInfo.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageProxy* ChunkedUpdateDrawingAreaProxy::page()
+{
+ return m_webView->page();
+}
+
+void ChunkedUpdateDrawingAreaProxy::ensureBackingStore()
+{
+ if (m_backingStoreBitmap)
+ return;
+
+ BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(size());
+
+ void* pixels = 0;
+ m_backingStoreBitmap.set(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, 0, 0));
+
+ if (!m_backingStoreDC) {
+ // Create a DC for the backing store.
+ HDC screenDC = ::GetDC(0);
+ m_backingStoreDC.set(::CreateCompatibleDC(screenDC));
+ ::ReleaseDC(0, screenDC);
+ }
+
+ ::SelectObject(m_backingStoreDC.get(), m_backingStoreBitmap.get());
+}
+
+void ChunkedUpdateDrawingAreaProxy::invalidateBackingStore()
+{
+ m_backingStoreBitmap.clear();
+}
+
+bool ChunkedUpdateDrawingAreaProxy::platformPaint(const IntRect& rect, HDC hdc)
+{
+ if (!m_backingStoreBitmap)
+ return false;
+
+ // BitBlt from the backing-store to the passed in hdc.
+ ::BitBlt(hdc, rect.x(), rect.y(), rect.width(), rect.height(), m_backingStoreDC.get(), rect.x(), rect.y(), SRCCOPY);
+ return true;
+}
+
+void ChunkedUpdateDrawingAreaProxy::drawUpdateChunkIntoBackingStore(UpdateChunk* updateChunk)
+{
+ ensureBackingStore();
+
+ OwnPtr<HDC> updateChunkBitmapDC(::CreateCompatibleDC(m_backingStoreDC.get()));
+
+ // Create a bitmap.
+ BitmapInfo bitmapInfo = BitmapInfo::createBottomUp(updateChunk->rect().size());
+
+ // Duplicate the update chunk handle.
+ HANDLE updateChunkHandle;
+ BOOL result = ::DuplicateHandle(m_webView->page()->process()->processIdentifier(), updateChunk->memory(),
+ ::GetCurrentProcess(), &updateChunkHandle, STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, false, DUPLICATE_CLOSE_SOURCE);
+
+ void* pixels = 0;
+ OwnPtr<HBITMAP> hBitmap(::CreateDIBSection(0, &bitmapInfo, DIB_RGB_COLORS, &pixels, updateChunkHandle, 0));
+ ::SelectObject(updateChunkBitmapDC.get(), hBitmap.get());
+
+ // BitBlt from the UpdateChunk to the backing store.
+ ::BitBlt(m_backingStoreDC.get(), updateChunk->rect().x(), updateChunk->rect().y(), updateChunk->rect().width(), updateChunk->rect().height(), updateChunkBitmapDC.get(), 0, 0, SRCCOPY);
+
+ // FIXME: We should not do this here.
+ ::CloseHandle(updateChunkHandle);
+
+ // Invalidate the WebView's HWND.
+ RECT rect = updateChunk->rect();
+ ::InvalidateRect(m_webView->window(), &rect, false);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp b/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp
new file mode 100644
index 0000000..8259272
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/LayerBackedDrawingAreaProxyWin.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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 USE(ACCELERATED_COMPOSITING)
+
+#include "LayerBackedDrawingAreaProxy.h"
+
+#include "DrawingAreaMessageKinds.h"
+#include "DrawingAreaProxyMessageKinds.h"
+#include "WebView.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebPageProxy* LayerBackedDrawingAreaProxy::page()
+{
+ return m_webView->page();
+}
+
+void LayerBackedDrawingAreaProxy::platformSetSize()
+{
+}
+
+void LayerBackedDrawingAreaProxy::attachCompositingContext(uint32_t contextID)
+{
+
+}
+
+void LayerBackedDrawingAreaProxy::detachCompositingContext()
+{
+}
+
+bool LayerBackedDrawingAreaProxy::paint(const IntRect&, PlatformDrawingContext)
+{
+ return false;
+}
+
+} // namespace WebKit
+
+#endif // USE(ACCELERATED_COMPOSITING)
diff --git a/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp
new file mode 100644
index 0000000..3c4b1eb
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/TextCheckerWin.cpp
@@ -0,0 +1,98 @@
+/*
+ * 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 "TextChecker.h"
+
+#include "NotImplemented.h"
+#include "TextCheckerState.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();
+}
+
+int64_t TextChecker::uniqueSpellDocumentTag()
+{
+ notImplemented();
+ return 0;
+}
+
+void TextChecker::closeSpellDocumentWithTag(int64_t)
+{
+ notImplemented();
+}
+
+Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
+{
+ notImplemented();
+ return Vector<WebCore::TextCheckingResult>();
+}
+
+void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
+{
+ notImplemented();
+}
+
+void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
+{
+ notImplemented();
+}
+
+void TextChecker::learnWord(const String& word)
+{
+ notImplemented();
+}
+
+void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
+{
+ notImplemented();
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp
new file mode 100644
index 0000000..090598f
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebContextMenuProxyWin.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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 "WebContextMenuProxyWin.h"
+
+#include "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)
+{
+ // 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 0000000..a843b26
--- /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 0000000..83b586d
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebContextWin.cpp
@@ -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.
+ */
+
+#include "WebContext.h"
+
+#include "WebProcessCreationParameters.h"
+#include "WebProcessMessages.h"
+#include <WebCore/FileSystem.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+String WebContext::applicationCacheDirectory()
+{
+ return localUserSpecificStorageDirectory();
+}
+
+void WebContext::setShouldPaintNativeControls(bool b)
+{
+ m_shouldPaintNativeControls = b;
+
+ if (!hasValidProcess())
+ return;
+ m_process->send(Messages::WebProcess::SetShouldPaintNativeControls(m_shouldPaintNativeControls), 0);
+}
+
+void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
+{
+ parameters.shouldPaintNativeControls = m_shouldPaintNativeControls;
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp
new file mode 100644
index 0000000..7637429
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp
@@ -0,0 +1,194 @@
+/*
+ * 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 "WebInspectorProxy.h"
+
+#if ENABLE(INSPECTOR)
+
+#include "WebPageProxy.h"
+#include "WebView.h"
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RetainPtr.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);
+}
+
+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;
+}
+
+WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
+{
+ ASSERT(!m_inspectorView);
+ ASSERT(!m_inspectorWindow);
+
+ RECT emptyRect = { 0 };
+ m_inspectorView = WebView::create(emptyRect, m_page->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);
+ ::ShowWindow(m_inspectorWindow, SW_SHOW);
+}
+
+void WebInspectorProxy::platformClose()
+{
+ ASSERT(m_inspectorWindow);
+ ASSERT(m_inspectorView);
+
+ ::DestroyWindow(m_inspectorWindow);
+
+ m_inspectorWindow = 0;
+ m_inspectorView = 0;
+}
+
+String WebInspectorProxy::inspectorPageURL() const
+{
+ RetainPtr<CFURLRef> htmlURLRef(AdoptCF, CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")), CFSTR("inspector"), CFSTR("html"), CFSTR("inspector")));
+ 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 0000000..6b0efd1
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPageProxyWin.cpp
@@ -0,0 +1,113 @@
+/*
+* 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 "WebPageProxy.h"
+
+#include <tchar.h>
+#include <WebCore/Language.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <wtf/StdLibExtras.h>
+#include <wtf/text/StringConcatenate.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static String windowsVersion()
+{
+ String osVersion;
+ OSVERSIONINFO versionInfo = { 0 };
+ versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
+ ::GetVersionEx(&versionInfo);
+
+ if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+ if (versionInfo.dwMajorVersion == 4) {
+ if (versionInfo.dwMinorVersion == 0)
+ osVersion = "Windows 95";
+ else if (versionInfo.dwMinorVersion == 10)
+ osVersion = "Windows 98";
+ else if (versionInfo.dwMinorVersion == 90)
+ osVersion = "Windows 98; Win 9x 4.90";
+ }
+ } else if (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
+ osVersion = makeString("Windows NT ", String::number(versionInfo.dwMajorVersion), '.', String::number(versionInfo.dwMinorVersion));
+
+ if (!osVersion.length())
+ osVersion = makeString("Windows ", String::number(versionInfo.dwMajorVersion), '.', String::number(versionInfo.dwMinorVersion));
+ return osVersion;
+}
+
+static String userVisibleWebKitVersionString()
+{
+ String versionStr = "420+";
+ void* data = 0;
+
+ struct LANGANDCODEPAGE {
+ WORD wLanguage;
+ WORD wCodePage;
+ } *lpTranslate;
+
+ TCHAR path[MAX_PATH];
+ ::GetModuleFileName(instanceHandle(), path, WTF_ARRAY_LENGTH(path));
+ DWORD handle;
+ DWORD versionSize = ::GetFileVersionInfoSize(path, &handle);
+ if (!versionSize)
+ goto exit;
+ data = fastMalloc(versionSize);
+ if (!data)
+ goto exit;
+ if (!::GetFileVersionInfo(path, 0, versionSize, data))
+ goto exit;
+ UINT cbTranslate;
+ if (!::VerQueryValue(data, TEXT("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &cbTranslate))
+ goto exit;
+ TCHAR key[256];
+ _stprintf_s(key, WTF_ARRAY_LENGTH(key), TEXT("\\StringFileInfo\\%04x%04x\\ProductVersion"), lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
+ LPCTSTR productVersion;
+ UINT productVersionLength;
+ if (!::VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&productVersion, &productVersionLength))
+ goto exit;
+ versionStr = String(productVersion, productVersionLength - 1);
+
+exit:
+ if (data)
+ fastFree(data);
+ return versionStr;
+}
+
+String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
+{
+ DEFINE_STATIC_LOCAL(String, osVersion, (windowsVersion()));
+ DEFINE_STATIC_LOCAL(String, webKitVersion, (userVisibleWebKitVersionString()));
+
+ // FIXME: We should upate the user agent if the default language changes.
+ String language = defaultLanguage();
+
+ if (applicationNameForUserAgent.isEmpty())
+ return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko)");
+ return makeString("Mozilla/5.0 (Windows; U; ", osVersion, "; ", language, ") AppleWebKit/", webKitVersion, " (KHTML, like Gecko) ", applicationNameForUserAgent);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
new file mode 100644
index 0000000..64b9fb5
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.cpp
@@ -0,0 +1,937 @@
+/*
+ * 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 "WebPopupMenuProxyWin.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, 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);
+
+ m_client->valueChangedForPopupMenu(this, m_newSelectedIndex);
+}
+
+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::nativeTheme()->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.bottom(), 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.bottom() > 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);
+}
+
+// ScrollbarClient
+
+int WebPopupMenuProxyWin::scrollSize(ScrollbarOrientation orientation) const
+{
+ return ((orientation == VerticalScrollbar) && m_scrollbar) ? (m_scrollbar->totalSize() - m_scrollbar->visibleSize()) : 0;
+}
+
+void WebPopupMenuProxyWin::setScrollOffsetFromAnimation(const IntPoint& offset)
+{
+ if (m_scrollbar)
+ m_scrollbar->setValue(offset.y(), Scrollbar::FromScrollAnimator);
+}
+
+void WebPopupMenuProxyWin::valueChanged(Scrollbar* scrollBar)
+{
+ ASSERT(m_scrollbar);
+
+ if (!m_popup)
+ return;
+
+ int offset = scrollBar->value();
+
+ 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();
+ // 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;
+ }
+ scrollbar()->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)
+ 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) {
+ m_scrollbar->setValue(index, Scrollbar::NotFromScrollAnimator);
+ return true;
+ }
+
+ if (index >= m_scrollOffset + visibleItems()) {
+ m_scrollbar->setValue(index - visibleItems() + 1, Scrollbar::NotFromScrollAnimator);
+ 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 0000000..7a53c2c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebPopupMenuProxyWin.h
@@ -0,0 +1,136 @@
+/*
+ * 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/ScrollbarClient.h>
+
+typedef struct HWND__* HWND;
+typedef struct HDC__* HDC;
+typedef struct HBITMAP__* HBITMAP;
+
+namespace WebKit {
+
+class WebView;
+
+class WebPopupMenuProxyWin : public WebPopupMenuProxy, private WebCore::ScrollbarClient {
+public:
+ static PassRefPtr<WebPopupMenuProxyWin> create(WebView* webView, WebPopupMenuProxy::Client* client)
+ {
+ return adoptRef(new WebPopupMenuProxyWin(webView, client));
+ }
+ ~WebPopupMenuProxyWin();
+
+ virtual void showPopupMenu(const WebCore::IntRect&, const Vector<WebPopupItem>&, const PlatformPopupMenuData&, int32_t selectedIndex);
+ virtual void hidePopupMenu();
+
+ void hide() { hidePopupMenu(); }
+
+private:
+ WebPopupMenuProxyWin(WebView*, WebPopupMenuProxy::Client*);
+
+ WebCore::Scrollbar* scrollbar() const { return m_scrollbar.get(); }
+
+ // ScrollBarClient
+ virtual int scrollSize(WebCore::ScrollbarOrientation orientation) const;
+ virtual void setScrollOffsetFromAnimation(const WebCore::IntPoint&);
+ virtual void valueChanged(WebCore::Scrollbar*);
+ virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&);
+ virtual bool isActive() const { return true; }
+ virtual bool scrollbarCornerPresent() const { return false; }
+
+ 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;
+ bool setFocusedIndex(int index, bool hotTracking = false);
+ 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/WebView.cpp b/Source/WebKit2/UIProcess/win/WebView.cpp
new file mode 100644
index 0000000..4b3992c
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebView.cpp
@@ -0,0 +1,1085 @@
+/*
+ * 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 "WebView.h"
+
+#include "ChunkedUpdateDrawingAreaProxy.h"
+#include "FindIndicator.h"
+#include "LayerBackedDrawingAreaProxy.h"
+#include "Logging.h"
+#include "RunLoop.h"
+#include "NativeWebKeyboardEvent.h"
+#include "WebContext.h"
+#include "WebContextMenuProxyWin.h"
+#include "WebEditCommandProxy.h"
+#include "WebEventFactory.h"
+#include "WebPageProxy.h"
+#include "WebPopupMenuProxyWin.h"
+#include <Commctrl.h>
+#include <WebCore/Cursor.h>
+#include <WebCore/FloatRect.h>
+#include <WebCore/IntRect.h>
+#include <WebCore/SoftLinking.h>
+#include <WebCore/WebCoreInstanceHandle.h>
+#include <WebCore/WindowMessageBroadcaster.h>
+#include <wtf/text/WTFString.h>
+
+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))
+};
+
+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_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)
+{
+ registerWebViewWindowClass();
+
+ m_page = context->createWebPage(this, pageGroup);
+
+ m_window = ::CreateWindowEx(0, kWebKit2WebViewWindowClassName, 0, WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ rect.top, rect.left, rect.right - rect.left, rect.bottom - rect.top, parentWindow ? parentWindow : HWND_MESSAGE, 0, instanceHandle(), this);
+ ASSERT(::IsWindow(m_window));
+
+ m_page->initializeWebPage();
+
+ ::ShowWindow(m_window, SW_SHOW);
+
+ // 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();
+}
+
+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::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)
+{
+ WebMouseEvent mouseEvent = WebEventFactory::createWebMouseEvent(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)
+{
+ WebWheelEvent wheelEvent = WebEventFactory::createWebWheelEvent(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::onKeyEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, bool& handled)
+{
+ 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;
+}
+
+LRESULT WebView::onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled)
+{
+ PAINTSTRUCT paintStruct;
+ HDC hdc = ::BeginPaint(m_window, &paintStruct);
+
+ if (m_page->isValid() && m_page->drawingArea() && m_page->drawingArea()->paint(IntRect(paintStruct.rcPaint), hdc))
+ m_page->didDraw();
+ else {
+ // Mac checks WebPageProxy::drawsBackground and
+ // WebPageProxy::drawsTransparentBackground here, but those are always false on Windows
+ // currently (see <http://webkit.org/b/52009>).
+ ::FillRect(hdc, &paintStruct.rcPaint, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1));
+ }
+
+ ::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);
+ IntRect rect = winRect;
+
+ m_page->drawingArea()->paint(rect, hdc);
+
+ 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->drawingArea())
+ m_page->drawingArea()->setSize(IntSize(width, height));
+
+ 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: Is WM_SHOWWINDOW sent when ShowWindow is called on an ancestor of our window?
+ if (!lParam) {
+ m_isVisible = wParam;
+ m_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
+
+ handled = true;
+ }
+
+ 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);
+}
+
+void WebView::close()
+{
+ setParentWindow(0);
+ m_page->close();
+}
+
+// PageClient
+
+PassOwnPtr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
+{
+ return ChunkedUpdateDrawingAreaProxy::create(this, m_page.get());
+}
+
+void WebView::setViewNeedsDisplay(const WebCore::IntRect& rect)
+{
+ RECT r = rect;
+ ::InvalidateRect(m_window, &r, false);
+}
+
+void WebView::displayView()
+{
+ ::UpdateWindow(m_window);
+}
+
+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::processDidCrash()
+{
+ updateNativeCursor();
+ ::InvalidateRect(m_window, 0, TRUE);
+}
+
+void WebView::didRelaunchProcess()
+{
+ updateNativeCursor();
+ ::InvalidateRect(m_window, 0, TRUE);
+}
+
+void WebView::takeFocus(bool)
+{
+}
+
+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::setOverrideCursor(HCURSOR overrideCursor)
+{
+ m_overrideCursor = overrideCursor;
+ updateNativeCursor();
+}
+
+void WebView::setInitialFocus(bool forward)
+{
+ m_page->setInitialFocus(forward);
+}
+
+void WebView::setViewportArguments(const WebCore::ViewportArguments&)
+{
+}
+
+void WebView::registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo)
+{
+}
+
+void WebView::clearAllEditCommands()
+{
+}
+
+void WebView::setEditCommandState(const String&, bool, int)
+{
+}
+
+FloatRect WebView::convertToDeviceSpace(const FloatRect& 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.bottom();
+ form.rcArea.top = caret.y();
+ form.rcArea.bottom = caret.bottom();
+ form.rcArea.left = caret.x();
+ form.rcArea.right = caret.right();
+ 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->selectionState().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->selectionState().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->selectionState().hasComposition)
+ m_page->confirmComposition(String());
+
+ if (m_inIMEComposition)
+ m_inIMEComposition--;
+
+ return true;
+}
+
+LRESULT WebView::onIMERequestCharPosition(IMECHARPOSITION* charPos)
+{
+ if (charPos->dwCharPos && !m_page->selectionState().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->selectionState().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::didNotHandleKeyEvent(const NativeWebKeyboardEvent& event)
+{
+ // Calling ::DefWindowProcW will ensure that pressing the Alt key will generate a WM_SYSCOMMAND
+ // event, e.g. See <http://webkit.org/b/47671>.
+ ::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>, bool fadeOut)
+{
+ // FIXME: Implement.
+}
+
+void WebView::didCommitLoadForMainFrame(bool useCustomRepresentation)
+{
+}
+
+void WebView::didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&)
+{
+}
+
+double WebView::customRepresentationZoomFactor()
+{
+ return 1;
+}
+
+void WebView::setCustomRepresentationZoomFactor(double)
+{
+}
+
+void WebView::setIsInWindow(bool isInWindow)
+{
+ m_isInWindow = isInWindow;
+ m_page->viewStateDidChange(WebPageProxy::ViewIsInWindow);
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+
+void WebView::pageDidEnterAcceleratedCompositing()
+{
+ switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::LayerBacked);
+}
+
+void WebView::pageDidLeaveAcceleratedCompositing()
+{
+ switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::ChunkedUpdate);
+}
+
+void WebView::switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::Type type)
+{
+ DrawingAreaInfo::Type existingDrawingAreaType = m_page->drawingArea() ? m_page->drawingArea()->info().type : DrawingAreaInfo::None;
+ if (existingDrawingAreaType == type)
+ return;
+
+ OwnPtr<DrawingAreaProxy> newDrawingArea;
+ switch (type) {
+ case DrawingAreaInfo::None:
+ break;
+ case DrawingAreaInfo::ChunkedUpdate:
+ newDrawingArea = ChunkedUpdateDrawingAreaProxy::create(this, m_page.get());
+ break;
+ case DrawingAreaInfo::LayerBacked:
+ newDrawingArea = LayerBackedDrawingAreaProxy::create(this, m_page.get());
+ break;
+ }
+
+ if (m_page->drawingArea())
+ newDrawingArea->setSize(m_page->drawingArea()->size());
+
+ m_page->drawingArea()->detachCompositingContext();
+ m_page->setDrawingArea(newDrawingArea.release());
+}
+
+#endif // USE(ACCELERATED_COMPOSITING)
+
+HWND WebView::nativeWindow()
+{
+ return m_window;
+}
+
+// WebCore::WindowMessageListener
+
+void WebView::windowReceivedMessage(HWND, UINT message, WPARAM wParam, LPARAM)
+{
+ switch (message) {
+ case WM_NCACTIVATE:
+ updateActiveStateSoon();
+ break;
+ case WM_SETTINGCHANGE:
+ // systemParameterChanged(wParam);
+ break;
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/win/WebView.h b/Source/WebKit2/UIProcess/win/WebView.h
new file mode 100644
index 0000000..c80334e
--- /dev/null
+++ b/Source/WebKit2/UIProcess/win/WebView.h
@@ -0,0 +1,170 @@
+/*
+ * 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 "PageClient.h"
+#include "WebPageProxy.h"
+#include <WebCore/WindowMessageListener.h>
+#include <wtf/Forward.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class DrawingAreaProxy;
+
+class WebView : public APIObject, public PageClient, WebCore::WindowMessageListener {
+public:
+ static PassRefPtr<WebView> create(RECT rect, WebContext* context, WebPageGroup* pageGroup, HWND parentWindow)
+ {
+ return adoptRef(new WebView(rect, context, pageGroup, parentWindow));
+ }
+ ~WebView();
+
+ HWND window() const { return m_window; }
+ void setParentWindow(HWND);
+ void windowAncestryDidChange();
+ void setIsInWindow(bool);
+ void setOverrideCursor(HCURSOR overrideCursor);
+ void setInitialFocus(bool forward);
+
+ WebPageProxy* page() const { return m_page.get(); }
+
+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);
+
+ void setWasActivatedByMouseEvent(bool flag) { m_wasActivatedByMouseEvent = flag; }
+ LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled);
+ LRESULT onWheelEvent(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);
+ 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();
+
+ void close();
+
+ HCURSOR cursorToShow() const;
+ void updateNativeCursor();
+
+ // PageClient
+ virtual PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy();
+ virtual void setViewNeedsDisplay(const WebCore::IntRect&);
+ virtual void displayView();
+
+ virtual WebCore::IntSize viewSize();
+ virtual bool isViewWindowActive();
+ virtual bool isViewFocused();
+ virtual bool isViewVisible();
+ virtual bool isViewInWindow();
+ virtual void processDidCrash();
+ virtual void didRelaunchProcess();
+ virtual void takeFocus(bool direction);
+ virtual void toolTipChanged(const WTF::String&, const WTF::String&);
+ virtual void setCursor(const WebCore::Cursor&);
+ virtual void setViewportArguments(const WebCore::ViewportArguments&);
+ virtual void registerEditCommand(PassRefPtr<WebEditCommandProxy>, WebPageProxy::UndoOrRedo);
+ virtual void clearAllEditCommands();
+ virtual void setEditCommandState(const WTF::String&, bool, int);
+ virtual WebCore::FloatRect convertToDeviceSpace(const WebCore::FloatRect&);
+ virtual WebCore::FloatRect convertToUserSpace(const WebCore::FloatRect&);
+ virtual void didNotHandleKeyEvent(const NativeWebKeyboardEvent&);
+ virtual void compositionSelectionChanged(bool);
+ virtual PassRefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy*);
+ virtual PassRefPtr<WebContextMenuProxy> createContextMenuProxy(WebPageProxy*);
+ virtual void setFindIndicator(PassRefPtr<FindIndicator>, bool fadeOut);
+
+#if USE(ACCELERATED_COMPOSITING)
+ virtual void pageDidEnterAcceleratedCompositing();
+ virtual void pageDidLeaveAcceleratedCompositing();
+ void switchToDrawingAreaTypeIfNecessary(DrawingAreaInfo::Type);
+#endif
+
+ void didCommitLoadForMainFrame(bool useCustomRepresentation);
+ void didFinishLoadingDataForCustomRepresentation(const CoreIPC::DataReference&);
+ virtual double customRepresentationZoomFactor();
+ virtual void setCustomRepresentationZoomFactor(double);
+
+ virtual HWND nativeWindow();
+
+ // WebCore::WindowMessageListener
+ virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM);
+
+ HWND m_window;
+ HWND m_topLevelParentWindow;
+ HWND m_toolTipWindow;
+
+ 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;
+};
+
+} // namespace WebKit
+
+#endif // WebView_h