Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WebKit2 WKView client hook for Safari 5.1
//
// STWKClientHook.m
#import "STWKClientHook.h"
#import <objc/message.h>
struct STWKOrderedClientCluster{
struct WKPageLoaderClient loader;
struct WKPagePolicyClient policy;
struct WKPageFormClient form;
struct WKPageResourceLoadClient resourceLoad;
struct WKPageUIClient ui;
struct WKPageFindClient find;
struct WKPageContextMenuClient contextMenu;
};
typedef struct STWKOrderedClientCluster STWKOrderedClientCluster;
// オリジナル関数の保管場所
static STWKOrderedClientCluster* savedClients=nil;
// WKPageRef から WKView を取得
// client 関数内から WKView が欲しい場合はこれを使うといい
// 内部構造あまり把握できてないけど、とりあえずこれで取得できた
static WKView* STWK_WKPageRefGetWKView(WKPageRef page){
// PageClientImpl(だと思う) を取得
void* pageClient = *(void **)((void **)page + 3);
// WKView を取得
WKView* wkView= *(WKView **)((void **)pageClient + 1);
return wkView;
}
// 置き換え関数の例
static void STWK_loader_didFinishProgress(WKPageRef page, const void* clientInfo){
LOG(@"STWK_loader_didFinishProgress");
// オリジナルを呼ぶときは NULL の可能性も否定はできないので(実装してないかもしれない)、一応チェックが必要
// 開発段階で NULL じゃないと確認してればまあ大丈夫だけど
if(savedClients->loader.didFinishProgress)savedClients->loader.didFinishProgress(page, clientInfo);
}
static void STWK_loader_didReceiveTitleForFrame(WKPageRef page, WKStringRef title,
WKFrameRef frame, WKTypeRef userData, const void *clientInfo){
LOG(@"STWK_loader_didReceiveTitleForFrame");
savedClients->loader.didReceiveTitleForFrame(page, title, frame, userData, clientInfo);
}
static void STWK_ui_setStatusText(WKPageRef page, WKStringRef text, const void *clientInfo){
LOG(@"STWK_ui_setStatusText");
savedClients->ui.setStatusText(page, text, clientInfo);
}
// 置き換えを行う関数
// WKView (BrowserWKView) が生成されたらその都度実行する。
// 各 Client が設定済みでないと意味がないのでタイミングは重要
void STWKTryClientHook(id wkView){
// Safari のメイン WKView は BrowserWKView
if (![[wkView className]isEqualToString:@"BrowserWKView"])return;
// WKViewData クラスを取得
id webData;
object_getInstanceVariable(wkView, "_data", (void **)&webData);
// RefPtr<WebPageProxy> を取得
void* webPageProxy;
object_getInstanceVariable(webData, "_page", (void **)&webPageProxy);
/*
//WKPageRef と webPageProxy は同じものなので単純に↓でもOK
void* webPageProxy=(void*)[wkView pageRef];
*/
// WebPageProxy の中に目当ての構造体が並んでいる。
// キャストの表現これで正しいのかよく分からん、、
STWKOrderedClientCluster* clients = (void *)((void **)webPageProxy + 4);
if (!savedClients) {
//オリジナルをごっそりコピーして取っておく
savedClients=malloc(sizeof(STWKOrderedClientCluster));
memcpy(savedClients, clients, sizeof(STWKOrderedClientCluster));
}
// 置き換える
clients->loader.didFinishProgress=STWK_loader_didFinishProgress;
clients->loader.didReceiveTitleForFrame=STWK_loader_didReceiveTitleForFrame;
clients->ui.setStatusText=STWK_ui_setStatusText;
}
//
// STWKClientHook.h
//
// http://nightly.webkit.org/ から取ってきた WKBase.h やら WKPage.h から抜粋
// framework に public header をコピーした方がいいかもしれない。
//
#import <Foundation/Foundation.h>
#ifdef __cplusplus
extern "C" {
#endif
struct WKPoint {
double x;
double y;
};
typedef struct WKPoint WKPoint;
struct WKSize {
double width;
double height;
};
typedef struct WKSize WKSize;
struct WKRect {
WKPoint origin;
WKSize size;
};
typedef struct WKRect WKRect;
#ifdef __cplusplus
}
#endif
/* WebKit2 shared types */
typedef uint32_t WKTypeID;
typedef const void* WKTypeRef;
typedef const struct OpaqueWKArray* WKArrayRef;
typedef struct OpaqueWKArray* WKMutableArrayRef;
typedef const struct OpaqueWKDictionary* WKDictionaryRef;
typedef struct OpaqueWKDictionary* WKMutableDictionaryRef;
typedef const struct OpaqueWKBoolean* WKBooleanRef;
typedef const struct OpaqueWKCertificateInfo* WKCertificateInfoRef;
typedef const struct OpaqueWKContextMenuItem* WKContextMenuItemRef;
typedef const struct OpaqueWKData* WKDataRef;
typedef const struct OpaqueWKDouble* WKDoubleRef;
typedef const struct OpaqueWKError* WKErrorRef;
typedef const struct OpaqueWKGraphicsContext* WKGraphicsContextRef;
typedef const struct OpaqueWKImage* WKImageRef;
typedef const struct OpaqueWKSecurityOrigin* WKSecurityOriginRef;
typedef const struct OpaqueWKSerializedScriptValue* WKSerializedScriptValueRef;
typedef const struct OpaqueWKString* WKStringRef;
typedef const struct OpaqueWKUInt64* WKUInt64Ref;
typedef const struct OpaqueWKURL* WKURLRef;
typedef const struct OpaqueWKURLRequest* WKURLRequestRef;
typedef const struct OpaqueWKURLResponse* WKURLResponseRef;
typedef const struct OpaqueWKUserContentURLPattern* WKUserContentURLPatternRef;
/* WebKit2 main API types */
typedef const struct OpaqueWKApplicationCacheManager* WKApplicationCacheManagerRef;
typedef const struct OpaqueWKAuthenticationChallenge* WKAuthenticationChallengeRef;
typedef const struct OpaqueWKAuthenticationDecisionListener* WKAuthenticationDecisionListenerRef;
typedef const struct OpaqueWKBackForwardList* WKBackForwardListRef;
typedef const struct OpaqueWKBackForwardListItem* WKBackForwardListItemRef;
typedef const struct OpaqueWKResourceCacheManager* WKResourceCacheManagerRef;
typedef const struct OpaqueWKContext* WKContextRef;
typedef const struct OpaqueWKCookieManager* WKCookieManagerRef;
typedef const struct OpaqueWKCredential* WKCredentialRef;
typedef const struct OpaqueWKDatabaseManager* WKDatabaseManagerRef;
typedef const struct OpaqueWKDownload* WKDownloadRef;
typedef const struct OpaqueWKFormSubmissionListener* WKFormSubmissionListenerRef;
typedef const struct OpaqueWKFrame* WKFrameRef;
typedef const struct OpaqueWKFramePolicyListener* WKFramePolicyListenerRef;
typedef const struct OpaqueWKGeolocationManager* WKGeolocationManagerRef;
typedef const struct OpaqueWKGeolocationPermissionRequest* WKGeolocationPermissionRequestRef;
typedef const struct OpaqueWKGeolocationPosition* WKGeolocationPositionRef;
typedef const struct OpaqueWKIconDatabase* WKIconDatabaseRef;
typedef const struct OpaqueWKInspector* WKInspectorRef;
typedef const struct OpaqueWKKeyValueStorageManager* WKKeyValueStorageManagerRef;
typedef const struct OpaqueWKMediaCacheManager* WKMediaCacheManagerRef;
typedef const struct OpaqueWKNavigationData* WKNavigationDataRef;
typedef const struct OpaqueWKOpenPanelParameters* WKOpenPanelParametersRef;
typedef const struct OpaqueWKOpenPanelResultListener* WKOpenPanelResultListenerRef;
typedef const struct OpaqueWKPage* WKPageRef;
typedef const struct OpaqueWKPageGroup* WKPageGroupRef;
typedef const struct OpaqueWKPluginSiteDataManager* WKPluginSiteDataManagerRef;
typedef const struct OpaqueWKPreferences* WKPreferencesRef;
typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
/* WebKit2 Bundle types */
typedef const struct OpaqueWKBundle* WKBundleRef;
typedef const struct OpaqueWKBundleBackForwardList* WKBundleBackForwardListRef;
typedef const struct OpaqueWKBundleBackForwardListItem* WKBundleBackForwardListItemRef;
typedef const struct OpaqueWKBundleDOMCSSStyleDeclaration* WKBundleCSSStyleDeclarationRef;
typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef;
typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
typedef const struct OpaqueWKBundlePage* WKBundlePageRef;
typedef const struct OpaqueWKBundlePageGroup* WKBundlePageGroupRef;
typedef const struct OpaqueWKBundlePageOverlay* WKBundlePageOverlayRef;
typedef const struct OpaqueWKBundleRangeHandle* WKBundleRangeHandleRef;
typedef const struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef;
typedef NSEvent *WKNativeEventPtr;
enum {
kWKFocusDirectionBackward = 0,
kWKFocusDirectionForward = 1
};
typedef uint32_t WKFocusDirection;
enum {
kWKFrameNavigationTypeLinkClicked = 0,
kWKFrameNavigationTypeFormSubmitted = 1,
kWKFrameNavigationTypeBackForward = 2,
kWKFrameNavigationTypeReload = 3,
kWKFrameNavigationTypeFormResubmitted = 4,
kWKFrameNavigationTypeOther = 5
};
typedef uint32_t WKFrameNavigationType;
enum {
kWKSameDocumentNavigationAnchorNavigation,
kWKSameDocumentNavigationSessionStatePush,
kWKSameDocumentNavigationSessionStateReplace,
kWKSameDocumentNavigationSessionStatePop
};
typedef uint32_t WKSameDocumentNavigationType;
enum {
kWKEventModifiersShiftKey = 1 << 0,
kWKEventModifiersControlKey = 1 << 1,
kWKEventModifiersAltKey = 1 << 2,
kWKEventModifiersMetaKey = 1 << 3
};
typedef uint32_t WKEventModifiers;
enum {
kWKEventMouseButtonNoButton = -1,
kWKEventMouseButtonLeftButton = 0,
kWKEventMouseButtonMiddleButton = 1,
kWKEventMouseButtonRightButton = 2,
};
typedef int32_t WKEventMouseButton;
typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
// FrameLoad Client
typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
typedef void (*WKPageDidFailToInitializePluginCallback)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
struct WKPageLoaderClient {
int version;
const void * clientInfo;
WKPageDidStartProvisionalLoadForFrameCallback didStartProvisionalLoadForFrame;
WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback didReceiveServerRedirectForProvisionalLoadForFrame;
WKPageDidFailProvisionalLoadWithErrorForFrameCallback didFailProvisionalLoadWithErrorForFrame;
WKPageDidCommitLoadForFrameCallback didCommitLoadForFrame;
WKPageDidFinishDocumentLoadForFrameCallback didFinishDocumentLoadForFrame;
WKPageDidFinishLoadForFrameCallback didFinishLoadForFrame;
WKPageDidFailLoadWithErrorForFrameCallback didFailLoadWithErrorForFrame;
WKPageDidSameDocumentNavigationForFrameCallback didSameDocumentNavigationForFrame;
WKPageDidReceiveTitleForFrameCallback didReceiveTitleForFrame;
WKPageDidFirstLayoutForFrameCallback didFirstLayoutForFrame;
WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback didFirstVisuallyNonEmptyLayoutForFrame;
WKPageDidRemoveFrameFromHierarchyCallback didRemoveFrameFromHierarchy;
WKPageDidDisplayInsecureContentForFrameCallback didDisplayInsecureContentForFrame;
WKPageDidRunInsecureContentForFrameCallback didRunInsecureContentForFrame;
WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback canAuthenticateAgainstProtectionSpaceInFrame;
WKPageDidReceiveAuthenticationChallengeInFrameCallback didReceiveAuthenticationChallengeInFrame;
// FIXME: Move to progress client.
WKPageCallback didStartProgress;
WKPageCallback didChangeProgress;
WKPageCallback didFinishProgress;
// FIXME: These three functions should not be part of this client.
WKPageCallback processDidBecomeUnresponsive;
WKPageCallback processDidBecomeResponsive;
WKPageCallback processDidCrash;
WKPageDidChangeBackForwardListCallback didChangeBackForwardList;
WKPageShouldGoToBackForwardListItemCallback shouldGoToBackForwardListItem;
WKPageDidFailToInitializePluginCallback didFailToInitializePlugin;
};
typedef struct WKPageLoaderClient WKPageLoaderClient;
// Policy Client.
typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);
struct WKPagePolicyClient {
int version;
const void * clientInfo;
WKPageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
WKPageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
WKPageDecidePolicyForResponseCallback decidePolicyForResponse;
WKPageUnableToImplementPolicyCallback unableToImplementPolicy;
};
typedef struct WKPagePolicyClient WKPagePolicyClient;
// 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, bool pageIsProvisionallyLoading, const void* clientInfo);
typedef void (*WKPageDidSendRequestForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo);
typedef void (*WKPageDidReceiveResponseForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLResponseRef response, const void* clientInfo);
typedef void (*WKPageDidReceiveContentLengthForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo);
typedef void (*WKPageDidFinishLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo);
typedef void (*WKPageDidFailLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo);
struct WKPageResourceLoadClient {
int version;
const void * clientInfo;
WKPageDidInitiateLoadForResourceCallback didInitiateLoadForResource;
WKPageDidSendRequestForResourceCallback didSendRequestForResource;
WKPageDidReceiveResponseForResourceCallback didReceiveResponseForResource;
WKPageDidReceiveContentLengthForResourceCallback didReceiveContentLengthForResource;
WKPageDidFinishLoadForResourceCallback didFinishLoadForResource;
WKPageDidFailLoadForResourceCallback didFailLoadForResource;
};
typedef struct WKPageResourceLoadClient WKPageResourceLoadClient;
// UI Client
typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
typedef void (*WKPageDidNotHandleWheelEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo);
typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo);
typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo);
typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo);
typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo);
typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
typedef void (*WKPageDidCompleteRubberBandForMainFrameCallback)(WKPageRef page, WKSize initialOverhang, const void* clientInfo);
typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
typedef bool (*WKPageShouldInterruptJavaScriptCallback)(WKPageRef page, const void *clientInfo);
struct WKPageUIClient {
int version;
const void * clientInfo;
WKPageCreateNewPageCallback createNewPage;
WKPageCallback showPage;
WKPageCallback close;
WKPageTakeFocusCallback takeFocus;
WKPageFocusCallback focus;
WKPageUnfocusCallback unfocus;
WKPageRunJavaScriptAlertCallback runJavaScriptAlert;
WKPageRunJavaScriptConfirmCallback runJavaScriptConfirm;
WKPageRunJavaScriptPromptCallback runJavaScriptPrompt;
WKPageSetStatusTextCallback setStatusText;
WKPageMouseDidMoveOverElementCallback mouseDidMoveOverElement;
WKPageMissingPluginButtonClickedCallback missingPluginButtonClicked;
WKPageDidNotHandleKeyEventCallback didNotHandleKeyEvent;
WKPageDidNotHandleWheelEventCallback didNotHandleWheelEvent;
WKPageGetToolbarsAreVisibleCallback toolbarsAreVisible;
WKPageSetToolbarsAreVisibleCallback setToolbarsAreVisible;
WKPageGetMenuBarIsVisibleCallback menuBarIsVisible;
WKPageSetMenuBarIsVisibleCallback setMenuBarIsVisible;
WKPageGetStatusBarIsVisibleCallback statusBarIsVisible;
WKPageSetStatusBarIsVisibleCallback setStatusBarIsVisible;
WKPageGetIsResizableCallback isResizable;
WKPageSetIsResizableCallback setIsResizable;
WKPageGetWindowFrameCallback getWindowFrame;
WKPageSetWindowFrameCallback setWindowFrame;
WKPageRunBeforeUnloadConfirmPanelCallback runBeforeUnloadConfirmPanel;
WKPageCallback didDraw;
WKPageCallback pageDidScroll;
WKPageExceededDatabaseQuotaCallback exceededDatabaseQuota;
WKPageRunOpenPanelCallback runOpenPanel;
WKPageDecidePolicyForGeolocationPermissionRequestCallback decidePolicyForGeolocationPermissionRequest;
WKPageHeaderHeightCallback headerHeight;
WKPageFooterHeightCallback footerHeight;
WKPageDrawHeaderCallback drawHeader;
WKPageDrawFooterCallback drawFooter;
WKPagePrintFrameCallback printFrame;
WKPageCallback runModal;
WKPageDidCompleteRubberBandForMainFrameCallback didCompleteRubberBandForMainFrame;
WKPageSaveDataToFileInDownloadsFolderCallback saveDataToFileInDownloadsFolder;
WKPageShouldInterruptJavaScriptCallback shouldInterruptJavaScript;
};
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;
void STWKTryClientHook(id wkView);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment