Source/WebKit2/ChangeLog

 12011-02-08 Sam Weinig <sam@webkit.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 WK2: Add ability to pass context to policy delegate methods
 6 https://bugs.webkit.org/show_bug.cgi?id=54031
 7
 8 * Platform/CoreIPC/HandleMessage.h:
 9 (CoreIPC::callMemberFunction):
 10 (CoreIPC::handleMessageVariadic):
 11 * Scripts/webkit2/messages.py:
 12 Add ability to pass variadic messages to sync messages.
 13
 14 * Shared/API/c/WKBase.h:
 15 * Shared/APIObject.h:
 16 Add WKBundleNavigation type.
 17
 18 * UIProcess/API/C/WKPage.h:
 19 * UIProcess/WebPageProxy.cpp:
 20 (WebKit::WebPageProxy::decidePolicyForNavigationAction):
 21 (WebKit::WebPageProxy::decidePolicyForNewWindowAction):
 22 (WebKit::WebPageProxy::decidePolicyForMIMEType):
 23 * UIProcess/WebPageProxy.h:
 24 * UIProcess/WebPageProxy.messages.in:
 25 * UIProcess/WebPolicyClient.cpp:
 26 (WebKit::WebPolicyClient::decidePolicyForNavigationAction):
 27 (WebKit::WebPolicyClient::decidePolicyForNewWindowAction):
 28 (WebKit::WebPolicyClient::decidePolicyForMIMEType):
 29 * UIProcess/WebPolicyClient.h:
 30 Update policy client for new data.
 31
 32 * WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
 33 * WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp: Added.
 34 (WKBundleNavigationActionGetTypeID):
 35 (WKBundleNavigationActionGetNavigationType):
 36 (WKBundleNavigationActionGetEventModifiers):
 37 (WKBundleNavigationActionGetEventMouseButton):
 38 (WKBundleNavigationActionCopyHitTestResult):
 39 (WKBundleNavigationActionCopyFormElement):
 40 * WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h: Added.
 41 * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
 42 (WKBundlePageSetPolicyClient):
 43 * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
 44 * WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp: Added.
 45 (WebKit::mouseEventForNavigationAction):
 46 (WebKit::mouseButtonForMouseEvent):
 47 (WebKit::InjectedBundleNavigationAction::modifiersForNavigationAction):
 48 (WebKit::InjectedBundleNavigationAction::mouseButtonForNavigationAction):
 49 (WebKit::InjectedBundleNavigationAction::create):
 50 (WebKit::InjectedBundleNavigationAction::InjectedBundleNavigationAction):
 51 * WebProcess/InjectedBundle/InjectedBundleNavigationAction.h: Added.
 52 (WebKit::InjectedBundleNavigationAction::navigationType):
 53 (WebKit::InjectedBundleNavigationAction::modifiers):
 54 (WebKit::InjectedBundleNavigationAction::mouseButton):
 55 (WebKit::InjectedBundleNavigationAction::hitTestResult):
 56 (WebKit::InjectedBundleNavigationAction::formElement):
 57 (WebKit::InjectedBundleNavigationAction::type):
 58 * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp: Added.
 59 (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNavigationAction):
 60 (WebKit::InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction):
 61 (WebKit::InjectedBundlePagePolicyClient::decidePolicyForMIMEType):
 62 * WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h: Added.
 63 * WebProcess/WebCoreSupport/WebChromeClient.cpp:
 64 (WebKit::WebChromeClient::createWindow):
 65 * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
 66 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForMIMEType):
 67 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
 68 (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
 69 * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
 70 * WebProcess/WebPage/WebPage.cpp:
 71 (WebKit::WebPage::initializeInjectedBundlePolicyClient):
 72 * WebProcess/WebPage/WebPage.h:
 73 (WebKit::WebPage::injectedBundlePolicyClient):
 74 Pipe the policy client through the bundle to allow setting user data.
 75
 76 * WebKit2.xcodeproj/project.pbxproj:
 77 Add new data.
 78
 79
1802011-02-08 Adam Barth <abarth@webkit.org>
281
382 Reviewed by Eric Seidel.
77967

Source/WebKit2/Platform/CoreIPC/HandleMessage.h

@@void callMemberFunction(const Arguments6
215215 (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, args.argument5, args.argument6, argumentDecoder);
216216}
217217
 218template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename P7>
 219void callMemberFunction(const Arguments7<P1, P2, P3, P4, P5, P6, P7>& args, ArgumentDecoder* argumentDecoder, C* object, MF function)
 220{
 221 (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, args.argument5, args.argument6, args.argument7, argumentDecoder);
 222}
 223
 224// Variadic dispatch functions with non-variadic reply arguments.
 225
 226template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename R1, typename R2, typename R3>
 227void callMemberFunction(const Arguments4<P1, P2, P3, P4>& args, ArgumentDecoder* argumentDecoder, Arguments3<R1, R2, R3>& replyArgs, C* object, MF function)
 228{
 229 (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, argumentDecoder, replyArgs.argument1, replyArgs.argument2, replyArgs.argument3);
 230}
 231
 232template<typename C, typename MF, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6, typename R1, typename R2>
 233void callMemberFunction(const Arguments6<P1, P2, P3, P4, P5, P6>& args, ArgumentDecoder* argumentDecoder, Arguments2<R1, R2>& replyArgs, C* object, MF function)
 234{
 235 (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, args.argument5, args.argument6, argumentDecoder, replyArgs.argument1, replyArgs.argument2);
 236}
218237
219238// Main dispatch functions
220239

@@void handleMessageVariadic(ArgumentDecod
248267 callMemberFunction(arguments, argumentDecoder, object, function);
249268}
250269
 270
 271template<typename T, typename C, typename MF>
 272void handleMessageVariadic(ArgumentDecoder* argumentDecoder, ArgumentEncoder* replyEncoder, C* object, MF function)
 273{
 274 typename T::DecodeType::ValueType arguments;
 275 if (!argumentDecoder->decode(arguments))
 276 return;
 277
 278 typename T::Reply::ValueType replyArguments;
 279 callMemberFunction(arguments, argumentDecoder, replyArguments, object, function);
 280 replyEncoder->encode(replyArguments);
 281}
 282
251283} // namespace CoreIPC
252284
253285#endif // HandleMessage_h
77962

Source/WebKit2/Scripts/webkit2/messages.py

@@def async_case_statement(receiver, messa
375375
376376
377377def sync_case_statement(receiver, message):
 378 dispatch_function = 'handleMessage'
 379 if message.is_variadic:
 380 dispatch_function += 'Variadic'
 381
378382 result = []
379383 result.append(' case Messages::%s::%s:\n' % (receiver.name, message.id()))
380  result.append(' CoreIPC::handleMessage<Messages::%s::%s>(arguments, reply, this, &%s);\n' % (receiver.name, message.name, handler_function(receiver, message)))
 384 result.append(' CoreIPC::%s<Messages::%s::%s>(arguments, reply, this, &%s);\n' % (dispatch_function, receiver.name, message.name, handler_function(receiver, message)))
381385 # FIXME: Handle delayed replies
382386 result.append(' return CoreIPC::AutomaticReply;\n')
383387 return surround_in_condition(''.join(result), message.condition)
77962

Source/WebKit2/Shared/APIObject.h

@@public:
8787 TypeBundleFrame,
8888 TypeBundleHitTestResult,
8989 TypeBundleInspector,
 90 TypeBundleNavigationAction,
9091 TypeBundleNodeHandle,
9192 TypeBundlePage,
9293 TypeBundlePageGroup,
77962

Source/WebKit2/Shared/API/c/WKBase.h

11/*
2  * Copyright (C) 2010 Apple Inc. All rights reserved.
 2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
33 *
44 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions

@@typedef const struct OpaqueWKBundleDOMCS
9494typedef const struct OpaqueWKBundleFrame* WKBundleFrameRef;
9595typedef const struct OpaqueWKBundleHitTestResult* WKBundleHitTestResultRef;
9696typedef const struct OpaqueWKBundleInspector* WKBundleInspectorRef;
 97typedef const struct OpaqueWKBundleNavigationAction* WKBundleNavigationActionRef;
9798typedef const struct OpaqueWKBundleNodeHandle* WKBundleNodeHandleRef;
9899typedef const struct OpaqueWKBundlePage* WKBundlePageRef;
99100typedef const struct OpaqueWKBundlePageGroup* WKBundlePageGroupRef;

@@typedef const struct OpaqueWKBundlePageO
101102typedef const struct OpaqueWKBundleRangeHandle* WKBundleRangeHandleRef;
102103typedef const struct OpaqueWKBundleScriptWorld* WKBundleScriptWorldRef;
103104
104 /* These rules should stay the same as in JavaScriptCore/API/JSBase.h */
105 
106105#undef WK_EXPORT
107106#if defined(WK_NO_EXPORT)
108107#define WK_EXPORT
77962

Source/WebKit2/UIProcess/WebPageProxy.cpp

@@void WebPageProxy::frameDidBecomeFrameSe
15361536}
15371537
15381538// PolicyClient
1539 void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction)
 1539void WebPageProxy::decidePolicyForNavigationAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction)
15401540{
1541  if (url != pendingAPIRequestURL())
 1541 RefPtr<APIObject> userData;
 1542 WebContextUserMessageDecoder messageDecoder(userData, context());
 1543 if (!arguments->decode(messageDecoder))
 1544 return;
 1545
 1546 if (request.url() != pendingAPIRequestURL())
15421547 clearPendingAPIRequestURL();
15431548
15441549 WebFrameProxy* frame = process()->webFrame(frameID);

@@void WebPageProxy::decidePolicyForNaviga
15551560 m_inDecidePolicyForNavigationAction = true;
15561561 m_syncNavigationActionPolicyActionIsValid = false;
15571562
1558  if (!m_policyClient.decidePolicyForNavigationAction(this, navigationType, modifiers, mouseButton, url, frame, listener.get()))
 1563 if (!m_policyClient.decidePolicyForNavigationAction(this, frame, navigationType, modifiers, mouseButton, request, listener.get(), userData.get()))
15591564 listener->use();
15601565
15611566 m_inDecidePolicyForNavigationAction = false;

@@void WebPageProxy::decidePolicyForNaviga
15671572 }
15681573}
15691574
1570 void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const String& url, uint64_t listenerID)
 1575void WebPageProxy::decidePolicyForNewWindowAction(uint64_t frameID, uint32_t opaqueNavigationType, uint32_t opaqueModifiers, int32_t opaqueMouseButton, const ResourceRequest& request, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments)
15711576{
 1577 RefPtr<APIObject> userData;
 1578 WebContextUserMessageDecoder messageDecoder(userData, context());
 1579 if (!arguments->decode(messageDecoder))
 1580 return;
 1581
15721582 WebFrameProxy* frame = process()->webFrame(frameID);
15731583 MESSAGE_CHECK(frame);
15741584

@@void WebPageProxy::decidePolicyForNewWin
15771587 WebMouseEvent::Button mouseButton = static_cast<WebMouseEvent::Button>(opaqueMouseButton);
15781588
15791589 RefPtr<WebFramePolicyListenerProxy> listener = frame->setUpPolicyListenerProxy(listenerID);
1580  if (!m_policyClient.decidePolicyForNewWindowAction(this, navigationType, modifiers, mouseButton, url, frame, listener.get()))
 1590 if (!m_policyClient.decidePolicyForNewWindowAction(this, frame, navigationType, modifiers, mouseButton, request, frameName, listener.get(), userData.get()))
15811591 listener->use();
15821592}
15831593
1584 void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
 1594void WebPageProxy::decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const ResourceRequest& request, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID)
15851595{
 1596 RefPtr<APIObject> userData;
 1597 WebContextUserMessageDecoder messageDecoder(userData, context());
 1598 if (!arguments->decode(messageDecoder))
 1599 return;
 1600
15861601 WebFrameProxy* frame = process()->webFrame(frameID);
15871602 MESSAGE_CHECK(frame);
15881603

@@void WebPageProxy::decidePolicyForMIMETy
15931608 m_inDecidePolicyForMIMEType = true;
15941609 m_syncMimeTypePolicyActionIsValid = false;
15951610
1596  if (!m_policyClient.decidePolicyForMIMEType(this, MIMEType, url, frame, listener.get()))
 1611 if (!m_policyClient.decidePolicyForMIMEType(this, frame, MIMEType, request, listener.get(), 0 /*userData*/))
15971612 listener->use();
15981613
15991614 m_inDecidePolicyForMIMEType = false;
77962

Source/WebKit2/UIProcess/WebPageProxy.h

@@private:
430430 void didFinishProgress();
431431 void didReceiveAccessibilityPageToken(const CoreIPC::DataReference&);
432432
433  void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction);
434  void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const String& url, uint64_t listenerID);
435  void decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const String& url, uint64_t listenerID, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
 433 void decidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder*, bool& receivedPolicyAction, uint64_t& policyAction);
 434 void decidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, const WebCore::ResourceRequest&, const String& frameName, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
 435 void decidePolicyForMIMEType(uint64_t frameID, const String& MIMEType, const WebCore::ResourceRequest&, uint64_t listenerID, CoreIPC::ArgumentDecoder* arguments, bool& receivedPolicyAction, uint64_t& policyAction, uint64_t& downloadID);
436436
437437 void willSubmitForm(uint64_t frameID, uint64_t sourceFrameID, const StringPairVector& textFieldValues, uint64_t listenerID, CoreIPC::ArgumentDecoder*);
438438
77962

Source/WebKit2/UIProcess/WebPageProxy.messages.in

@@messages -> WebPageProxy {
6767#endif
6868
6969 # Policy messages
70  DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
71  DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID) -> (bool receivedPolicyAction, uint64_t policyAction)
72  DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WTF::String url, uint64_t listenerID)
 70 DecidePolicyForMIMEType(uint64_t frameID, WTF::String MIMEType, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction, uint64_t downloadID)
 71 DecidePolicyForNavigationAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData) -> (bool receivedPolicyAction, uint64_t policyAction)
 72 DecidePolicyForNewWindowAction(uint64_t frameID, uint32_t navigationType, uint32_t modifiers, int32_t mouseButton, WebCore::ResourceRequest request, WTF::String frameName, uint64_t listenerID, WebKit::InjectedBundleUserMessageEncoder userData)
7373
7474 # Progress messages
7575 DidChangeProgress(double value)
77962

Source/WebKit2/UIProcess/WebPolicyClient.cpp

2727#include "WebPolicyClient.h"
2828
2929#include "WKAPICast.h"
30 #include <wtf/text/WTFString.h>
 30#include "WebURLRequest.h"
3131
3232using namespace WebCore;
3333
3434namespace WebKit {
3535
36 bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
 36bool WebPolicyClient::decidePolicyForNavigationAction(WebPageProxy* page, WebFrameProxy* frame, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const ResourceRequest& resourceRequest, WebFramePolicyListenerProxy* listener, APIObject* userData)
3737{
3838 if (!m_client.decidePolicyForNavigationAction)
3939 return false;
4040
41  m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
 41 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 42
 43 m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toAPI(request.get()), toAPI(listener), toAPI(userData), m_client.clientInfo);
4244 return true;
4345}
4446
45 bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
 47bool WebPolicyClient::decidePolicyForNewWindowAction(WebPageProxy* page, WebFrameProxy* frame, NavigationType type, WebEvent::Modifiers modifiers, WebMouseEvent::Button mouseButton, const ResourceRequest& resourceRequest, const String& frameName, WebFramePolicyListenerProxy* listener, APIObject* userData)
4648{
4749 if (!m_client.decidePolicyForNewWindowAction)
4850 return false;
4951
50  m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
 52 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 53
 54 m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(type), toAPI(modifiers), toAPI(mouseButton), toAPI(request.get()), toAPI(frameName.impl()), toAPI(listener), toAPI(userData), m_client.clientInfo);
5155 return true;
5256}
5357
54 bool WebPolicyClient::decidePolicyForMIMEType(WebPageProxy* page, const String& MIMEType, const String& url, WebFrameProxy* frame, WebFramePolicyListenerProxy* listener)
 58bool WebPolicyClient::decidePolicyForMIMEType(WebPageProxy* page, WebFrameProxy* frame, const String& MIMEType, const ResourceRequest& resourceRequest, WebFramePolicyListenerProxy* listener, APIObject* userData)
5559{
5660 if (!m_client.decidePolicyForMIMEType)
5761 return false;
5862
59  m_client.decidePolicyForMIMEType(toAPI(page), toAPI(MIMEType.impl()), toURLRef(url.impl()), toAPI(frame), toAPI(listener), m_client.clientInfo);
 63 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 64
 65 m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), toAPI(listener), toAPI(userData), m_client.clientInfo);
6066 return true;
6167}
6268
77962

Source/WebKit2/UIProcess/WebPolicyClient.h

2727#define WebPolicyClient_h
2828
2929#include "APIClient.h"
 30#include "APIObject.h"
3031#include "WKPage.h"
3132#include "WebEvent.h"
3233#include <WebCore/FrameLoaderTypes.h>
3334#include <wtf/Forward.h>
3435
 36namespace WebCore {
 37 class ResourceRequest;
 38}
 39
3540namespace WebKit {
3641
3742class WebPageProxy;

@@class WebFramePolicyListenerProxy;
4045
4146class WebPolicyClient : public APIClient<WKPagePolicyClient> {
4247public:
43  bool decidePolicyForNavigationAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
44  bool decidePolicyForNewWindowAction(WebPageProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
45  bool decidePolicyForMIMEType(WebPageProxy*, const String&, const String& url, WebFrameProxy*, WebFramePolicyListenerProxy*);
 48 bool decidePolicyForNavigationAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
 49 bool decidePolicyForNewWindowAction(WebPageProxy*, WebFrameProxy*, WebCore::NavigationType, WebEvent::Modifiers, WebMouseEvent::Button, const WebCore::ResourceRequest&, const String& frameName, WebFramePolicyListenerProxy*, APIObject* userData);
 50 bool decidePolicyForMIMEType(WebPageProxy*, WebFrameProxy*, const String& MIMEType, const WebCore::ResourceRequest&, WebFramePolicyListenerProxy*, APIObject* userData);
4651};
4752
4853} // namespace WebKit
77962

Source/WebKit2/UIProcess/API/C/WKPage.h

@@struct WKPageLoaderClient {
9696typedef struct WKPageLoaderClient WKPageLoaderClient;
9797
9898// Policy Client.
99 typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
100 typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
101 typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
 99typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
 100typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
 101typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
102102
103103struct WKPagePolicyClient {
104104 int version;
77962

Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

503503 BC646C1C11DD399F006455B0 /* WKBackForwardListItem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC646C1811DD399F006455B0 /* WKBackForwardListItem.cpp */; };
504504 BC646C1D11DD399F006455B0 /* WKBackForwardListItem.h in Headers */ = {isa = PBXBuildFile; fileRef = BC646C1911DD399F006455B0 /* WKBackForwardListItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
505505 BC6EDAA6111271C600E7678B /* PageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6EDAA5111271C600E7678B /* PageClient.h */; };
 506 BC7043CC12F75EE0006472B9 /* WKBundleNavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7043CA12F75EE0006472B9 /* WKBundleNavigationAction.h */; };
 507 BC7043CD12F75EE0006472B9 /* WKBundleNavigationAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7043CB12F75EE0006472B9 /* WKBundleNavigationAction.cpp */; };
506508 BC72B9FA11E6476B001EB4EA /* WebBackForwardListProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC72B9F811E6476B001EB4EA /* WebBackForwardListProxy.cpp */; };
507509 BC72B9FB11E6476B001EB4EA /* WebBackForwardListProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = BC72B9F911E6476B001EB4EA /* WebBackForwardListProxy.h */; };
508510 BC72BA1D11E64907001EB4EA /* WebBackForwardList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC72BA1B11E64907001EB4EA /* WebBackForwardList.cpp */; };

517519 BC7B633812A45ABA00D174A4 /* WKPageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7B633612A45ABA00D174A4 /* WKPageGroup.cpp */; };
518520 BC7B633D12A45D1200D174A4 /* WKBundlePageGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7B633B12A45D1200D174A4 /* WKBundlePageGroup.h */; settings = {ATTRIBUTES = (Public, ); }; };
519521 BC7B633E12A45D1200D174A4 /* WKBundlePageGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC7B633C12A45D1200D174A4 /* WKBundlePageGroup.cpp */; };
 522 BC8147A912F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8147A712F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h */; };
 523 BC8147AA12F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8147A812F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp */; };
 524 BC8147D512F66D31007B2C32 /* InjectedBundleNavigationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8147D312F66D31007B2C32 /* InjectedBundleNavigationAction.h */; };
 525 BC8147D612F66D31007B2C32 /* InjectedBundleNavigationAction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */; };
520526 BC8452A71162C80900CAB9B5 /* DrawingArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8452A51162C80900CAB9B5 /* DrawingArea.cpp */; };
521527 BC8452A81162C80900CAB9B5 /* DrawingArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8452A61162C80900CAB9B5 /* DrawingArea.h */; };
522528 BC84EB1812A7100C0083F2DA /* WebPreferencesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */; };

11391145 BC111A54112F4FBB00337BAB /* WebContextMenuClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuClient.cpp; sourceTree = "<group>"; };
11401146 BC111A56112F4FBB00337BAB /* WebDragClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDragClient.cpp; sourceTree = "<group>"; };
11411147 BC111A57112F4FBB00337BAB /* WebEditorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebEditorClient.cpp; sourceTree = "<group>"; };
1142  BC111A58112F4FBB00337BAB /* WebFrameLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFrameLoaderClient.cpp; sourceTree = "<group>"; };
 1148 BC111A58112F4FBB00337BAB /* WebFrameLoaderClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFrameLoaderClient.cpp; sourceTree = "<group>"; wrapsLines = 0; };
11431149 BC111A59112F4FBB00337BAB /* WebInspectorClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebInspectorClient.cpp; sourceTree = "<group>"; };
11441150 BC111ADC112F5B9300337BAB /* WebFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebFrame.cpp; sourceTree = "<group>"; };
11451151 BC111ADF112F5BC200337BAB /* WebErrorsMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebErrorsMac.mm; sourceTree = "<group>"; };

11811187 BC204EEA11C83EC8008F3375 /* WKBundle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundle.h; sourceTree = "<group>"; };
11821188 BC204EEB11C83EC8008F3375 /* WKBundleAPICast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleAPICast.h; sourceTree = "<group>"; };
11831189 BC204EED11C83EC8008F3375 /* WKBundleInitialize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleInitialize.h; sourceTree = "<group>"; };
1184  BC20527F11C94284008F3375 /* WKBundlePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePage.h; sourceTree = "<group>"; };
 1190 BC20527F11C94284008F3375 /* WKBundlePage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePage.h; sourceTree = "<group>"; wrapsLines = 0; };
11851191 BC20528011C94284008F3375 /* WKBundlePage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundlePage.cpp; sourceTree = "<group>"; };
11861192 BC2651F511825EF800243E12 /* ChunkedUpdateDrawingAreaProxyMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ChunkedUpdateDrawingAreaProxyMac.mm; sourceTree = "<group>"; };
11871193 BC2652121182608100243E12 /* DrawingAreaProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DrawingAreaProxy.cpp; sourceTree = "<group>"; };

12781284 BC646C1811DD399F006455B0 /* WKBackForwardListItem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBackForwardListItem.cpp; sourceTree = "<group>"; };
12791285 BC646C1911DD399F006455B0 /* WKBackForwardListItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBackForwardListItem.h; sourceTree = "<group>"; };
12801286 BC6EDAA5111271C600E7678B /* PageClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageClient.h; sourceTree = "<group>"; };
 1287 BC7043CA12F75EE0006472B9 /* WKBundleNavigationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundleNavigationAction.h; sourceTree = "<group>"; };
 1288 BC7043CB12F75EE0006472B9 /* WKBundleNavigationAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleNavigationAction.cpp; sourceTree = "<group>"; };
12811289 BC72B9F811E6476B001EB4EA /* WebBackForwardListProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebBackForwardListProxy.cpp; sourceTree = "<group>"; };
12821290 BC72B9F911E6476B001EB4EA /* WebBackForwardListProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListProxy.h; sourceTree = "<group>"; };
12831291 BC72BA1B11E64907001EB4EA /* WebBackForwardList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebBackForwardList.cpp; sourceTree = "<group>"; };

12921300 BC7B633612A45ABA00D174A4 /* WKPageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKPageGroup.cpp; sourceTree = "<group>"; };
12931301 BC7B633B12A45D1200D174A4 /* WKBundlePageGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBundlePageGroup.h; sourceTree = "<group>"; };
12941302 BC7B633C12A45D1200D174A4 /* WKBundlePageGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundlePageGroup.cpp; sourceTree = "<group>"; };
 1303 BC8147A712F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePagePolicyClient.h; sourceTree = "<group>"; wrapsLines = 0; };
 1304 BC8147A812F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePagePolicyClient.cpp; sourceTree = "<group>"; wrapsLines = 0; };
 1305 BC8147D312F66D31007B2C32 /* InjectedBundleNavigationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundleNavigationAction.h; sourceTree = "<group>"; };
 1306 BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleNavigationAction.cpp; sourceTree = "<group>"; };
12951307 BC8452A51162C80900CAB9B5 /* DrawingArea.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DrawingArea.cpp; sourceTree = "<group>"; };
12961308 BC8452A61162C80900CAB9B5 /* DrawingArea.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DrawingArea.h; sourceTree = "<group>"; };
12971309 BC84EB1712A7100C0083F2DA /* WebPreferencesMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPreferencesMac.mm; sourceTree = "<group>"; };

24292441 isa = PBXGroup;
24302442 children = (
24312443 BC204EE711C83EAD008F3375 /* API */,
2432  BC204EE411C83E9C008F3375 /* mac */,
24332444 BC4BEE96120A091700FBA0C7 /* DOM */,
 2445 BC204EE411C83E9C008F3375 /* mac */,
24342446 BC204EE011C83E98008F3375 /* InjectedBundle.cpp */,
24352447 BC204EE111C83E98008F3375 /* InjectedBundle.h */,
2436  BCEE7DC4128B645D009827DA /* InjectedBundleClient.cpp */,
2437  BCEE7DC3128B645D009827DA /* InjectedBundleClient.h */,
24382448 935EEB8F1277615D003322B8 /* InjectedBundleBackForwardList.cpp */,
24392449 935EEB901277615D003322B8 /* InjectedBundleBackForwardList.h */,
24402450 935EEB911277615D003322B8 /* InjectedBundleBackForwardListItem.cpp */,
24412451 935EEB921277615D003322B8 /* InjectedBundleBackForwardListItem.h */,
 2452 BCEE7DC4128B645D009827DA /* InjectedBundleClient.cpp */,
 2453 BCEE7DC3128B645D009827DA /* InjectedBundleClient.h */,
24422454 BC498617124D10E200D834E1 /* InjectedBundleHitTestResult.cpp */,
24432455 BC498616124D10E200D834E1 /* InjectedBundleHitTestResult.h */,
 2456 BC8147D412F66D31007B2C32 /* InjectedBundleNavigationAction.cpp */,
 2457 BC8147D312F66D31007B2C32 /* InjectedBundleNavigationAction.h */,
24442458 512935E11288D97800A4B695 /* InjectedBundlePageContextMenuClient.cpp */,
24452459 512935E21288D97800A4B695 /* InjectedBundlePageContextMenuClient.h */,
24462460 E1EE53E611F8CFFB00CCBEE4 /* InjectedBundlePageEditorClient.cpp */,

24492463 BC14E108120B905E00826C0C /* InjectedBundlePageFormClient.h */,
24502464 BCA8C6A611E3BA5F00812FB7 /* InjectedBundlePageLoaderClient.cpp */,
24512465 BCA8C6A711E3BA5F00812FB7 /* InjectedBundlePageLoaderClient.h */,
 2466 BC8147A812F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp */,
 2467 BC8147A712F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h */,
24522468 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */,
24532469 6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */,
24542470 BCA8C6AD11E3C08700812FB7 /* InjectedBundlePageUIClient.cpp */,

24942510 BC204EED11C83EC8008F3375 /* WKBundleInitialize.h */,
24952511 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */,
24962512 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */,
 2513 BC7043CB12F75EE0006472B9 /* WKBundleNavigationAction.cpp */,
 2514 BC7043CA12F75EE0006472B9 /* WKBundleNavigationAction.h */,
24972515 BC4BEFE0120A1A4C00FBA0C7 /* WKBundleNodeHandle.cpp */,
24982516 BC4BEFDF120A1A4C00FBA0C7 /* WKBundleNodeHandle.h */,
24992517 BC57450B1263B155006F0F12 /* WKBundleNodeHandlePrivate.h */,

31503168 1A9636BD12F348490078A062 /* ShareableSurface.h in Headers */,
31513169 1A9639F712F38ECD0078A062 /* CoreAnimationRenderer.h in Headers */,
31523170 1A690D1712F39E3300ECD289 /* LayerTreeHostMac.h in Headers */,
 3171 BC8147A912F64CDA007B2C32 /* InjectedBundlePagePolicyClient.h in Headers */,
 3172 BC8147D512F66D31007B2C32 /* InjectedBundleNavigationAction.h in Headers */,
 3173 BC7043CC12F75EE0006472B9 /* WKBundleNavigationAction.h in Headers */,
31533174 1A92DC1112F8BA460017AF65 /* LayerTreeContext.h in Headers */,
31543175 BCA56A1C12F9028E00C566C7 /* WebGraphicsContext.h in Headers */,
31553176 BCA56A6512F9C8F900C566C7 /* WKGraphicsContext.h in Headers */,

36233644 6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */,
36243645 1A9636BC12F348490078A062 /* ShareableSurface.cpp in Sources */,
36253646 1A9639F812F38ECD0078A062 /* CoreAnimationRenderer.mm in Sources */,
 3647 BC8147AA12F64CDA007B2C32 /* InjectedBundlePagePolicyClient.cpp in Sources */,
 3648 BC8147D612F66D31007B2C32 /* InjectedBundleNavigationAction.cpp in Sources */,
 3649 BC7043CD12F75EE0006472B9 /* WKBundleNavigationAction.cpp in Sources */,
36263650 1A92DC1312F8BAB90017AF65 /* LayerTreeContextMac.mm in Sources */,
36273651 BCA56A1D12F9028E00C566C7 /* WebGraphicsContext.cpp in Sources */,
36283652 BCA56A6612F9C8F900C566C7 /* WKGraphicsContext.cpp in Sources */,
77962

Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.cpp

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "InjectedBundleNavigationAction.h"
 28
 29#include "WebFrame.h"
 30#include <WebCore/Frame.h>
 31#include <WebCore/HTMLFormElement.h>
 32#include <WebCore/MouseEvent.h>
 33#include <WebCore/NavigationAction.h>
 34#include <WebCore/UIEventWithKeyState.h>
 35
 36using namespace WebCore;
 37
 38namespace WebKit {
 39
 40static const MouseEvent* mouseEventForNavigationAction(const NavigationAction& navigationAction)
 41{
 42 for (const Event* e = navigationAction.event(); e; e = e->underlyingEvent()) {
 43 if (e->isMouseEvent())
 44 return static_cast<const MouseEvent*>(e);
 45 }
 46 return 0;
 47}
 48
 49static WebMouseEvent::Button mouseButtonForMouseEvent(const MouseEvent* mouseEvent)
 50{
 51 if (!mouseEvent)
 52 return WebMouseEvent::NoButton;
 53
 54 if (!mouseEvent->buttonDown())
 55 return WebMouseEvent::NoButton;
 56
 57 return static_cast<WebMouseEvent::Button>(mouseEvent->button());
 58}
 59
 60WebEvent::Modifiers InjectedBundleNavigationAction::modifiersForNavigationAction(const NavigationAction& navigationAction)
 61{
 62 uint32_t modifiers = 0;
 63 if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) {
 64 if (keyStateEvent->shiftKey())
 65 modifiers |= WebEvent::ShiftKey;
 66 if (keyStateEvent->ctrlKey())
 67 modifiers |= WebEvent::ControlKey;
 68 if (keyStateEvent->altKey())
 69 modifiers |= WebEvent::AltKey;
 70 if (keyStateEvent->metaKey())
 71 modifiers |= WebEvent::MetaKey;
 72 }
 73
 74 return static_cast<WebEvent::Modifiers>(modifiers);
 75}
 76
 77WebMouseEvent::Button InjectedBundleNavigationAction::mouseButtonForNavigationAction(const NavigationAction& navigationAction)
 78{
 79 return mouseButtonForMouseEvent(mouseEventForNavigationAction(navigationAction));
 80}
 81
 82
 83PassRefPtr<InjectedBundleNavigationAction> InjectedBundleNavigationAction::create(WebFrame* frame, const NavigationAction& action, PassRefPtr<FormState> formState)
 84{
 85 return adoptRef(new InjectedBundleNavigationAction(frame, action, formState));
 86}
 87
 88InjectedBundleNavigationAction::InjectedBundleNavigationAction(WebFrame* frame, const NavigationAction& navigationAction, PassRefPtr<FormState> prpFormState)
 89{
 90 m_navigationType = navigationAction.type();
 91 m_modifiers = modifiersForNavigationAction(navigationAction);
 92
 93 if (const MouseEvent* mouseEvent = mouseEventForNavigationAction(navigationAction)) {
 94 m_hitTestResult = InjectedBundleHitTestResult::create(frame->coreFrame()->eventHandler()->hitTestResultAtPoint(mouseEvent->absoluteLocation(), false));
 95 m_mouseButton = mouseButtonForMouseEvent(mouseEvent);
 96 }
 97
 98 RefPtr<FormState> formState = prpFormState;
 99 if (formState) {
 100 ASSERT(formState->form());
 101 m_formElement = InjectedBundleNodeHandle::getOrCreate(formState->form());
 102 }
 103}
 104
 105} // namespace WebKit
0

Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleNavigationAction.h

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef InjectedBundleNavigationAction_h
 27#define InjectedBundleNavigationAction_h
 28
 29#include "APIObject.h"
 30#include "InjectedBundleHitTestResult.h"
 31#include "InjectedBundleNodeHandle.h"
 32#include "WebEvent.h"
 33#include <WebCore/FrameLoaderTypes.h>
 34#include <wtf/PassRefPtr.h>
 35#include <wtf/RefPtr.h>
 36
 37namespace WebCore {
 38 class FormState;
 39 class NavigationAction;
 40}
 41
 42namespace WebKit {
 43
 44class WebFrame;
 45
 46class InjectedBundleNavigationAction : public APIObject {
 47public:
 48 static const Type APIType = TypeBundleNavigationAction;
 49
 50 static PassRefPtr<InjectedBundleNavigationAction> create(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>);
 51
 52 static WebEvent::Modifiers modifiersForNavigationAction(const WebCore::NavigationAction&);
 53 static WebMouseEvent::Button mouseButtonForNavigationAction(const WebCore::NavigationAction&);
 54
 55 WebCore::NavigationType navigationType() const { return m_navigationType; }
 56 WebEvent::Modifiers modifiers() const { return m_modifiers; }
 57 WebMouseEvent::Button mouseButton() const { return m_mouseButton; }
 58 InjectedBundleHitTestResult* hitTestResult() const { return m_hitTestResult.get(); }
 59 InjectedBundleNodeHandle* formElement() const { return m_formElement.get(); }
 60
 61private:
 62 InjectedBundleNavigationAction(WebFrame*, const WebCore::NavigationAction&, PassRefPtr<WebCore::FormState>);
 63
 64 virtual Type type() const { return APIType; }
 65
 66 WebCore::NavigationType m_navigationType;
 67 WebEvent::Modifiers m_modifiers;
 68 WebMouseEvent::Button m_mouseButton;
 69 RefPtr<InjectedBundleHitTestResult> m_hitTestResult;
 70 RefPtr<InjectedBundleNodeHandle> m_formElement;
 71};
 72
 73} // namespace WebKit
 74
 75#endif // InjectedBundleNavigationAction_h
0

Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.cpp

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "InjectedBundlePagePolicyClient.h"
 28
 29#include "WKBundleAPICast.h"
 30#include "WebURLRequest.h"
 31
 32using namespace WebCore;
 33
 34namespace WebKit {
 35
 36void InjectedBundlePagePolicyClient::decidePolicyForNavigationAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
 37{
 38 if (!m_client.decidePolicyForNavigationAction)
 39 return;
 40
 41 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 42
 43 WKTypeRef userDataToPass = 0;
 44 m_client.decidePolicyForNavigationAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
 45 userData = adoptRef(toImpl(userDataToPass));
 46}
 47
 48void InjectedBundlePagePolicyClient::decidePolicyForNewWindowAction(WebPage* page, WebFrame* frame, InjectedBundleNavigationAction* action, const ResourceRequest& resourceRequest, const String& frameName, RefPtr<APIObject>& userData)
 49{
 50 if (!m_client.decidePolicyForNewWindowAction)
 51 return;
 52
 53 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 54
 55 WKTypeRef userDataToPass = 0;
 56 m_client.decidePolicyForNewWindowAction(toAPI(page), toAPI(frame), toAPI(action), toAPI(request.get()), toAPI(frameName.impl()), &userDataToPass, m_client.clientInfo);
 57 userData = adoptRef(toImpl(userDataToPass));
 58}
 59
 60void InjectedBundlePagePolicyClient::decidePolicyForMIMEType(WebPage* page, WebFrame* frame, const String& MIMEType, const ResourceRequest& resourceRequest, RefPtr<APIObject>& userData)
 61{
 62 if (!m_client.decidePolicyForMIMEType)
 63 return;
 64
 65 RefPtr<WebURLRequest> request = WebURLRequest::create(resourceRequest);
 66
 67 WKTypeRef userDataToPass = 0;
 68 m_client.decidePolicyForMIMEType(toAPI(page), toAPI(frame), toAPI(MIMEType.impl()), toAPI(request.get()), &userDataToPass, m_client.clientInfo);
 69 userData = adoptRef(toImpl(userDataToPass));
 70}
 71
 72} // namespace WebKit
0

Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePagePolicyClient.h

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef InjectedBundlePagePolicyClient_h
 27#define InjectedBundlePagePolicyClient_h
 28
 29#include "APIClient.h"
 30#include "APIObject.h"
 31#include "WKBundlePage.h"
 32#include <wtf/Forward.h>
 33
 34namespace WebCore {
 35 class ResourceRequest;
 36}
 37
 38namespace WebKit {
 39
 40class InjectedBundleNavigationAction;
 41class WebFrame;
 42class WebPage;
 43
 44class InjectedBundlePagePolicyClient : public APIClient<WKBundlePagePolicyClient> {
 45public:
 46 void decidePolicyForNavigationAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
 47 void decidePolicyForNewWindowAction(WebPage*, WebFrame*, InjectedBundleNavigationAction*, const WebCore::ResourceRequest&, const String& frameName, RefPtr<APIObject>& userData);
 48 void decidePolicyForMIMEType(WebPage*, WebFrame*, const String& MIMEType, const WebCore::ResourceRequest&, RefPtr<APIObject>& userData);
 49};
 50
 51} // namespace WebKit
 52
 53#endif // InjectedBundlePagePolicyClient_h
0

Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleAPICast.h

@@class InjectedBundle;
4545class InjectedBundleBackForwardList;
4646class InjectedBundleBackForwardListItem;
4747class InjectedBundleHitTestResult;
 48class InjectedBundleNavigationAction;
4849class InjectedBundleNodeHandle;
4950class InjectedBundleRangeHandle;
5051class InjectedBundleScriptWorld;

@@WK_ADD_API_MAPPING(WKBundleCSSStyleDecla
6061WK_ADD_API_MAPPING(WKBundleFrameRef, WebFrame)
6162WK_ADD_API_MAPPING(WKBundleHitTestResultRef, InjectedBundleHitTestResult)
6263WK_ADD_API_MAPPING(WKBundleInspectorRef, WebInspector)
 64WK_ADD_API_MAPPING(WKBundleNavigationActionRef, InjectedBundleNavigationAction)
6365WK_ADD_API_MAPPING(WKBundleNodeHandleRef, InjectedBundleNodeHandle)
6466WK_ADD_API_MAPPING(WKBundlePageGroupRef, WebPageGroupProxy)
6567WK_ADD_API_MAPPING(WKBundlePageOverlayRef, PageOverlay)
77962

Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.cpp

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WKBundleNavigationAction.h"
 28
 29#include "InjectedBundleHitTestResult.h"
 30#include "InjectedBundleNavigationAction.h"
 31#include "InjectedBundleNodeHandle.h"
 32#include "WKAPICast.h"
 33#include "WKBundleAPICast.h"
 34
 35using namespace WebKit;
 36
 37WKTypeID WKBundleNavigationActionGetTypeID()
 38{
 39 return toAPI(InjectedBundleNavigationAction::APIType);
 40}
 41
 42WKFrameNavigationType WKBundleNavigationActionGetNavigationType(WKBundleNavigationActionRef navigationActionRef)
 43{
 44 return toAPI(toImpl(navigationActionRef)->navigationType());
 45}
 46
 47WKEventModifiers WKBundleNavigationActionGetEventModifiers(WKBundleNavigationActionRef navigationActionRef)
 48{
 49 return toAPI(toImpl(navigationActionRef)->modifiers());
 50}
 51
 52WKEventMouseButton WKBundleNavigationActionGetEventMouseButton(WKBundleNavigationActionRef navigationActionRef)
 53{
 54 return toAPI(toImpl(navigationActionRef)->mouseButton());
 55}
 56
 57WKBundleHitTestResultRef WKBundleNavigationActionCopyHitTestResult(WKBundleNavigationActionRef navigationActionRef)
 58{
 59 RefPtr<InjectedBundleHitTestResult> hitTestResult = toImpl(navigationActionRef)->hitTestResult();
 60 return toAPI(hitTestResult.release().leakRef());
 61}
 62
 63WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigationActionRef navigationActionRef)
 64{
 65 RefPtr<InjectedBundleNodeHandle> formElement = toImpl(navigationActionRef)->formElement();
 66 return toAPI(formElement.release().leakRef());
 67}
0

Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNavigationAction.h

 1/*
 2 * Copyright (C) 2011 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WKBundleNavigationAction_h
 27#define WKBundleNavigationAction_h
 28
 29#include <WebKit2/WKBase.h>
 30#include <WebKit2/WKEvent.h>
 31#include <WebKit2/WKPageLoadTypes.h>
 32
 33#ifdef __cplusplus
 34extern "C" {
 35#endif
 36
 37WK_EXPORT WKTypeID WKBundleNavigationActionGetTypeID();
 38
 39WK_EXPORT WKFrameNavigationType WKBundleNavigationActionGetNavigationType(WKBundleNavigationActionRef navigationAction);
 40WK_EXPORT WKEventModifiers WKBundleNavigationActionGetEventModifiers(WKBundleNavigationActionRef navigationAction);
 41WK_EXPORT WKEventMouseButton WKBundleNavigationActionGetEventMouseButton(WKBundleNavigationActionRef navigationAction);
 42WK_EXPORT WKBundleHitTestResultRef WKBundleNavigationActionCopyHitTestResult(WKBundleNavigationActionRef navigationAction);
 43WK_EXPORT WKBundleNodeHandleRef WKBundleNavigationActionCopyFormElement(WKBundleNavigationActionRef navigationAction);
 44
 45#ifdef __cplusplus
 46}
 47#endif
 48
 49#endif /* WKBundleNavigationAction_h */
0

Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp

@@void WKBundlePageSetResourceLoadClient(W
7979 toImpl(pageRef)->initializeInjectedBundleResourceLoadClient(wkClient);
8080}
8181
 82void WKBundlePageSetPolicyClient(WKBundlePageRef pageRef, WKBundlePagePolicyClient* wkClient)
 83{
 84 if (wkClient && wkClient->version)
 85 return;
 86 toImpl(pageRef)->initializeInjectedBundlePolicyClient(wkClient);
 87}
 88
8289void WKBundlePageSetUIClient(WKBundlePageRef pageRef, WKBundlePageUIClient* wkClient)
8390{
8491 if (wkClient && wkClient->version)
77962

Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

@@struct WKBundlePageLoaderClient {
114114};
115115typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
116116
 117// Policy Client
 118typedef void (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
 119typedef void (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
 120typedef void (*WKBundlePageDecidePolicyForMIMETypeCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
 121
 122struct WKBundlePagePolicyClient {
 123 int version;
 124 const void * clientInfo;
 125 WKBundlePageDecidePolicyForNavigationActionCallback decidePolicyForNavigationAction;
 126 WKBundlePageDecidePolicyForNewWindowActionCallback decidePolicyForNewWindowAction;
 127 WKBundlePageDecidePolicyForMIMETypeCallback decidePolicyForMIMEType;
 128};
 129typedef struct WKBundlePagePolicyClient WKBundlePagePolicyClient;
 130
117131// Resource Load Client
118132typedef void (*WKBundlePageDidInitiateLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, bool pageIsProvisionallyLoading, const void* clientInfo);
119133typedef WKURLRequestRef (*WKBundlePageWillSendRequestForFrameCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, WKURLResponseRef redirectResponse, const void *clientInfo);

@@WK_EXPORT void WKBundlePageSetEditorClie
222236WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client);
223237WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client);
224238WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClient* client);
 239WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClient* client);
225240WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client);
226241
227242WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page);
77962

Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

3131#include "NotImplemented.h"
3232
3333#include "DrawingArea.h"
 34#include "InjectedBundleNavigationAction.h"
3435#include "InjectedBundleUserMessageCoders.h"
3536#include "WebContextMenu.h"
3637#include "WebCoreArgumentCoders.h"

@@void WebChromeClient::focusedFrameChange
153154
154155Page* WebChromeClient::createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures& windowFeatures, const NavigationAction& navigationAction)
155156{
156  uint32_t modifiers = modifiersForNavigationAction(navigationAction);
157  int32_t mouseButton = mouseButtonForNavigationAction(navigationAction);
 157 uint32_t modifiers = static_cast<uint32_t>(InjectedBundleNavigationAction::modifiersForNavigationAction(navigationAction));
 158 int32_t mouseButton = static_cast<int32_t>(InjectedBundleNavigationAction::mouseButtonForNavigationAction(navigationAction));
158159
159160 uint64_t newPageID = 0;
160161 WebPageCreationParameters parameters;
77962

Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

3131
3232#include "AuthenticationManager.h"
3333#include "DataReference.h"
 34#include "InjectedBundleNavigationAction.h"
3435#include "InjectedBundleUserMessageCoders.h"
3536#include "PlatformCertificateInfo.h"
3637#include "PluginView.h"

@@void WebFrameLoaderClient::dispatchShow(
575576 webPage->show();
576577}
577578
578 uint32_t modifiersForNavigationAction(const NavigationAction& navigationAction)
579 {
580  uint32_t modifiers = 0;
581  if (const UIEventWithKeyState* keyStateEvent = findEventWithKeyState(const_cast<Event*>(navigationAction.event()))) {
582  if (keyStateEvent->shiftKey())
583  modifiers |= WebEvent::ShiftKey;
584  if (keyStateEvent->ctrlKey())
585  modifiers |= WebEvent::ControlKey;
586  if (keyStateEvent->altKey())
587  modifiers |= WebEvent::AltKey;
588  if (keyStateEvent->metaKey())
589  modifiers |= WebEvent::MetaKey;
590  }
591 
592  return modifiers;
593 }
594 
595 static const MouseEvent* findMouseEvent(const Event* event)
596 {
597  for (const Event* e = event; e; e = e->underlyingEvent()) {
598  if (e->isMouseEvent())
599  return static_cast<const MouseEvent*>(e);
600  }
601  return 0;
602 }
603 
604 int32_t mouseButtonForNavigationAction(const NavigationAction& navigationAction)
605 {
606  const MouseEvent* mouseEvent = findMouseEvent(navigationAction.event());
607  if (!mouseEvent)
608  return -1;
609 
610  if (!mouseEvent->buttonDown())
611  return -1;
612 
613  return mouseEvent->button();
614 }
615 
616579void WebFrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest& request)
617580{
618581 if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) {

@@void WebFrameLoaderClient::dispatchDecid
626589 if (!webPage)
627590 return;
628591
629  uint64_t listenerID = m_frame->setUpPolicyListener(function);
630  const String& url = request.url().string(); // FIXME: Pass entire request.
631  if (!url)
 592 if (!request.url().string())
632593 return;
633594
 595 RefPtr<APIObject> userData;
 596
 597 // Notify the bundle client.
 598 webPage->injectedBundlePolicyClient().decidePolicyForMIMEType(webPage, m_frame, MIMEType, request, userData);
 599
 600 uint64_t listenerID = m_frame->setUpPolicyListener(function);
634601 bool receivedPolicyAction;
635602 uint64_t policyAction;
636603 uint64_t downloadID;
637  if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, url, listenerID), Messages::WebPageProxy::DecidePolicyForMIMEType::Reply(receivedPolicyAction, policyAction, downloadID)))
 604
 605 // Notify the UIProcess.
 606 if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForMIMEType(m_frame->frameID(), MIMEType, request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForMIMEType::Reply(receivedPolicyAction, policyAction, downloadID)))
638607 return;
639608
640609 // We call this synchronously because CFNetwork can only convert a loading connection to a download from its didReceiveResponse callback.

@@void WebFrameLoaderClient::dispatchDecid
642611 m_frame->didReceivePolicyDecision(listenerID, static_cast<PolicyAction>(policyAction), downloadID);
643612}
644613
645 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>, const String& frameName)
 614void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName)
646615{
647616 WebPage* webPage = m_frame->page();
648617 if (!webPage)
649618 return;
650619
651  uint64_t listenerID = m_frame->setUpPolicyListener(function);
 620 RefPtr<APIObject> userData;
 621
 622 RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
 623
 624 // Notify the bundle client.
 625 webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.get(), request, frameName, userData);
652626
653  // FIXME: Pass more than just the navigation action type.
654  // FIXME: Pass the frame name.
655  const String& url = request.url().string(); // FIXME: Pass entire request.
656627
657  uint32_t navigationType = static_cast<uint32_t>(navigationAction.type());
658  uint32_t modifiers = modifiersForNavigationAction(navigationAction);
659  int32_t mouseButton = mouseButtonForNavigationAction(navigationAction);
 628 uint64_t listenerID = m_frame->setUpPolicyListener(function);
660629
661  webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID));
 630 // Notify the UIProcess.
 631 webPage->send(Messages::WebPageProxy::DecidePolicyForNewWindowAction(m_frame->frameID(), action->navigationType(), action->modifiers(), action->mouseButton(), request, frameName, listenerID, InjectedBundleUserMessageEncoder(userData.get())));
662632}
663633
664 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState>)
 634void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction& navigationAction, const ResourceRequest& request, PassRefPtr<FormState> formState)
665635{
666636 if (m_frame->coreFrame()->loader()->documentLoader()->url().isEmpty() && request.url() == blankURL()) {
667637 // WebKit2 loads initial about:blank documents synchronously, without consulting the policy delegate

@@void WebFrameLoaderClient::dispatchDecid
675645 (m_frame->coreFrame()->loader()->policyChecker()->*function)(PolicyIgnore);
676646 return;
677647 }
678 
 648
679649 WebPage* webPage = m_frame->page();
680650 if (!webPage)
681651 return;
682652
683  uint64_t listenerID = m_frame->setUpPolicyListener(function);
 653 RefPtr<APIObject> userData;
684654
685  // FIXME: Pass more than just the navigation action type.
686  const String& url = request.url().string(); // FIXME: Pass entire request.
 655 RefPtr<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
687656
688  uint32_t navigationType = static_cast<uint32_t>(navigationAction.type());
689  uint32_t modifiers = modifiersForNavigationAction(navigationAction);
690  int32_t mouseButton = mouseButtonForNavigationAction(navigationAction);
691 
 657 // Notify the bundle client.
 658 webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.get(), request, userData);
 659
 660 uint64_t listenerID = m_frame->setUpPolicyListener(function);
692661 bool receivedPolicyAction;
693662 uint64_t policyAction;
694  if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), navigationType, modifiers, mouseButton, url, listenerID), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction)))
 663
 664 // Notify the UIProcess.
 665 if (!webPage->sendSync(Messages::WebPageProxy::DecidePolicyForNavigationAction(m_frame->frameID(), action->navigationType(), action->modifiers(), action->mouseButton(), request, listenerID, InjectedBundleUserMessageEncoder(userData.get())), Messages::WebPageProxy::DecidePolicyForNavigationAction::Reply(receivedPolicyAction, policyAction)))
695666 return;
696667
697668 // We call this synchronously because WebCore cannot gracefully handle a frame load without a synchronous navigation policy reply.
77962

Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h

@@private:
222222 bool m_frameHasCustomRepresentation;
223223};
224224
225 uint32_t modifiersForNavigationAction(const WebCore::NavigationAction&);
226 int32_t mouseButtonForNavigationAction(const WebCore::NavigationAction&);
227 
228225} // namespace WebKit
229226
230227#endif // WebFrameLoaderClient_h
77962

Source/WebKit2/WebProcess/WebPage/WebPage.cpp

@@void WebPage::initializeInjectedBundleLo
255255 m_loaderClient.initialize(client);
256256}
257257
 258void WebPage::initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient* client)
 259{
 260 m_policyClient.initialize(client);
 261}
 262
258263void WebPage::initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient* client)
259264{
260265 m_resourceLoadClient.initialize(client);
77962

Source/WebKit2/WebProcess/WebPage/WebPage.h

3535#include "InjectedBundlePageEditorClient.h"
3636#include "InjectedBundlePageFormClient.h"
3737#include "InjectedBundlePageLoaderClient.h"
 38#include "InjectedBundlePagePolicyClient.h"
3839#include "InjectedBundlePageResourceLoadClient.h"
3940#include "InjectedBundlePageUIClient.h"
4041#include "MessageSender.h"

@@public:
171172 void initializeInjectedBundleEditorClient(WKBundlePageEditorClient*);
172173 void initializeInjectedBundleFormClient(WKBundlePageFormClient*);
173174 void initializeInjectedBundleLoaderClient(WKBundlePageLoaderClient*);
 175 void initializeInjectedBundlePolicyClient(WKBundlePagePolicyClient*);
174176 void initializeInjectedBundleResourceLoadClient(WKBundlePageResourceLoadClient*);
175177 void initializeInjectedBundleUIClient(WKBundlePageUIClient*);
176178

@@public:
178180 InjectedBundlePageEditorClient& injectedBundleEditorClient() { return m_editorClient; }
179181 InjectedBundlePageFormClient& injectedBundleFormClient() { return m_formClient; }
180182 InjectedBundlePageLoaderClient& injectedBundleLoaderClient() { return m_loaderClient; }
 183 InjectedBundlePagePolicyClient& injectedBundlePolicyClient() { return m_policyClient; }
181184 InjectedBundlePageResourceLoadClient& injectedBundleResourceLoadClient() { return m_resourceLoadClient; }
182185 InjectedBundlePageUIClient& injectedBundleUIClient() { return m_uiClient; }
183186

@@private:
500503 InjectedBundlePageEditorClient m_editorClient;
501504 InjectedBundlePageFormClient m_formClient;
502505 InjectedBundlePageLoaderClient m_loaderClient;
 506 InjectedBundlePagePolicyClient m_policyClient;
503507 InjectedBundlePageResourceLoadClient m_resourceLoadClient;
504508 InjectedBundlePageUIClient m_uiClient;
505509
77962

Tools/ChangeLog

 12011-02-08 Sam Weinig <sam@webkit.org>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 WK2: Add ability to pass context to policy delegate methods
 6 https://bugs.webkit.org/show_bug.cgi?id=54031
 7
 8 * MiniBrowser/mac/BrowserWindowController.m:
 9 (decidePolicyForNavigationAction):
 10 (decidePolicyForNewWindowAction):
 11 (decidePolicyForMIMEType):
 12 * TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp:
 13 (TestWebKitAPI::decidePolicyForNavigationAction):
 14 (TestWebKitAPI::decidePolicyForNewWindowAction):
 15 (TestWebKitAPI::decidePolicyForMIMEType):
 16 Update policy client for new API.
 17
1182011-02-08 Kundu Suchismita <suchi.kundu@nokia.com>
219
320 Reviewed by Laszlo Gombos.
77967

Tools/MiniBrowser/mac/BrowserWindowController.m

@@static void didChangeBackForwardList(WKP
358358
359359// MARK: Policy Client Callbacks
360360
361 static void decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 361static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
362362{
363363 LOG(@"decidePolicyForNavigationAction");
364364 WKFramePolicyListenerUse(listener);
365365}
366366
367 static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 367static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
368368{
369369 LOG(@"decidePolicyForNewWindowAction");
370370 WKFramePolicyListenerUse(listener);
371371}
372372
373 static void decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo)
 373static void decidePolicyForMIMEType(WKPageRef page, WKFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
374374{
375375 WKFramePolicyListenerUse(listener);
376376}
77962

Tools/TestWebKitAPI/Tests/WebKit2/PageLoadBasic.cpp

@@static void didFinishLoadForFrame(WKPage
8787 test1Done = true;
8888}
8989
90 static void decidePolicyForNavigationAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
 90static void decidePolicyForNavigationAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
9191{
9292 State* state = reinterpret_cast<State*>(const_cast<void*>(clientInfo));
9393 TEST_ASSERT(!state->didStartProvisionalLoadForFrame);

@@static void decidePolicyForNavigationAct
9898 WKFramePolicyListenerUse(listener);
9999}
100100
101 static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
 101static void decidePolicyForNewWindowAction(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
102102{
103103 WKFramePolicyListenerUse(listener);
104104}
105105
106 static void decidePolicyForMIMEType(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void* clientInfo)
 106static void decidePolicyForMIMEType(WKPageRef page, WKFrameRef frame, WKStringRef MIMEType, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo)
107107{
108108 WKFramePolicyListenerUse(listener);
109109}
77962