Move QDataStream functions into HistoryItemQt.cpp
https://bugs.webkit.org/show_bug.cgi?id=99203

Reviewed by Andreas Kling.

Source/WebCore:

It seems like the QDataStream stream operators are only used from HistoryItemQt.cpp
inside WebCore, so move them there. If in the future they are required elsewhere, they should
be moved into a separate header instead of polluting headers unnecessarily.

* history/qt/HistoryItemQt.cpp:
(operator<<):
(operator>>):
* platform/FractionalLayoutUnit.h:
* platform/graphics/IntPoint.h:

Source/WebKit2:

Forward declare QTransform.

* Shared/qt/WebEventFactoryQt.h:

Source/WTF:

It seems like the QDataStream stream operators are only used from HistoryItemQt.cpp
inside WebCore, so move them there. If in the future they are required elsewhere, they should
be moved into a separate header instead of polluting headers unnecessarily.

* wtf/Vector.h:
* wtf/qt/StringQt.cpp:
* wtf/text/WTFString.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131279 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Allow notification origin permission request when no js callback is provided
https://bugs.webkit.org/show_bug.cgi?id=63615
<rdar://problem/11059590>

Reviewed by Sam Weinig.

Source/WebCore:

Instead of throwing a type error when no callback is provided, we pass a null callback.

Test: http/tests/notifications/legacy/request-no-callback.html

* bindings/js/JSDesktopNotificationsCustom.cpp:
(WebCore::JSNotificationCenter::requestPermission):

Source/WebKit/mac:

Introduce a boolean to determine whether the request was using the legacy or standard API. This way,
we do not fall through to calling the standard API's callback if the legacy API's callback is null.

* WebCoreSupport/WebNotificationClient.mm:
(WebCore):
(-[WebNotificationPolicyListener initWithVoidCallback:]):
(-[WebNotificationPolicyListener allow]):
(-[WebNotificationPolicyListener deny]):

Source/WebKit2:

Null checks already exist for both standard and legacy API callbacks, so no changes are needed here
like there are in WebKit 1. The checks existed because the callbacks are held in a hash map used to keep
track of pending requests.

Also, add a check for a null callback when short circuiting.

* WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
(WebKit::NotificationPermissionRequestManager::startRequest):

Tools:

Teach DRT to look at the existing entries in the permission hash map when permission is requested.

* DumpRenderTree/mac/MockWebNotificationProvider.h: Expose policyForOrigin.
* DumpRenderTree/mac/MockWebNotificationProvider.mm:
(-[MockWebNotificationProvider setWebNotificationOrigin:permission:]):
* DumpRenderTree/mac/UIDelegate.mm:
(-[UIDelegate webView:decidePolicyForNotificationRequestFromOrigin:listener:]): Look at whether a
policy for the origin already exists. If so, accept or deny the request as appropriate. Otherwise,
accept by default.

LayoutTests:

* http/tests/notifications/legacy/request-expected.txt:
* http/tests/notifications/legacy/request-no-callback-expected.txt: Added.
* http/tests/notifications/legacy/request-no-callback.html: Calls webkitNotifications.requestPermission()
with no callback, with default and denied permission. For WebKit2, if the permission is not default, it
will short circuit instead of creating a pending request.
* http/tests/notifications/legacy/request.html: The test mistakenly uses the standard API instead of
the legacy API. The results don't change, but we make sure that we call
webkitNotifications.requestPermission() with a callback to test full coverage of the legacy API. We also
expand the test to cover both default and denied permissions.
* http/tests/notifications/request-expected.txt:
* http/tests/notifications/request.html: Expand test to cover both default and denied permissions.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131280 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Simplify user content in WebKit2 by using WebCore::UserStyleSheet and WebCore::UserScript directly
https://bugs.webkit.org/show_bug.cgi?id=99276

Reviewed by Anders Carlsson.

Source/WebCore:

Add default constructors for UserScript and UserStyleSheet so they can be used in CoreIPC encoding/decoding.

* page/UserScript.h:
(WebCore::UserScript::UserScript):
(UserScript):
* page/UserStyleSheet.h:
(WebCore::UserStyleSheet::UserStyleSheet):
(UserStyleSheet):

Source/WebKit2:

- Removes UserContentContainer in favor of Vector<UserStyleSheet> and Vector<UserScript> right on WebPageGroupData.
- Adds support for UserScripts, but does not expose API for it just yet.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebKit2.xcodeproj/project.pbxproj:
* win/WebKit2.vcproj:
* Shared/UserContentContainer.cpp: Removed.
* Shared/UserContentContainer.h: Removed.
Remove UserContentContainer.h/cpp.

* Shared/API/c/WKBase.h:
* Shared/API/c/WKSharedAPICast.h:
(WebKit::toUserScriptInjectionTime):
(WebKit::toUserContentInjectedFrames):
* WebProcess/InjectedBundle/API/c/WKBundleAPICast.h:
* WebProcess/InjectedBundle/API/c/WKBundlePrivate.h:
Move UserContent enums to WKBase.h so they can be used from both processes, and move the
casts to WKSharedAPICast.

* Shared/WebCoreArgumentCoders.cpp:
* Shared/WebCoreArgumentCoders.h:
Add coders for UserStyleSheet and UserScript.

* Shared/WebPageGroupData.cpp:
(WebKit::WebPageGroupData::encode):
(WebKit::WebPageGroupData::decode):
* Shared/WebPageGroupData.h:
(WebPageGroupData):
Replace UserContentContainer with Vector<UserStyleSheet> and Vector<UserScript>. Stop using
CoreIPC::In() and CoreIPC::Out(), and instead just call encode/decode multiple times.

* UIProcess/API/C/WKPageGroup.cpp:
(WKPageGroupAddUserStyleSheet):
Pass the parameters with as little conversion as possible to the C++ to avoid doing too much
work in the API layer.

* UIProcess/WebPageGroup.cpp:
(WebKit::toStringVector):
(WebKit::WebPageGroup::addUserStyleSheet):
(WebKit::WebPageGroup::addUserScript):
(WebKit::WebPageGroup::removeAllUserStyleSheets):
(WebKit::WebPageGroup::removeAllUserScripts):
(WebKit::WebPageGroup::removeAllUserContent):
* UIProcess/WebPageGroup.h:
* WebProcess/WebPage/WebPageGroupProxy.cpp:
(WebKit::WebPageGroupProxy::WebPageGroupProxy):
(WebKit::WebPageGroupProxy::addUserStyleSheet):
(WebKit::WebPageGroupProxy::addUserScript):
(WebKit::WebPageGroupProxy::removeAllUserScripts):
(WebKit::WebPageGroupProxy::removeAllUserContent):
* WebProcess/WebPage/WebPageGroupProxy.h:
(WebPageGroupProxy):
* WebProcess/WebPage/WebPageGroupProxy.messages.in:
Add support for user scripts and update to use UserScript and UserStyleSheet directly.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131281 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebPage::PostInjectedBundleMessage should be a variadic message
https://bugs.webkit.org/show_bug.cgi?id=99277

Reviewed by Sam Weinig.

Don't use a data reference for messages posted to the injected bundle; they could contain data that requires attachments
(such as shared memory).

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::postMessageToInjectedBundle):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::postInjectedBundleMessage):
* WebProcess/WebPage/WebPage.h:
(WebPage):
* WebProcess/WebPage/WebPage.messages.in:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131282 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Re-land of "WebContext should be a MessageReceiver"
https://bugs.webkit.org/show_bug.cgi?id=98958

Patch by Anders Carlsson <andersca@apple.com> on 2012-10-14
Reviewed by Sam Weinig.

Make WebContext be a MessageReceiver that lives in its own map. This allows us to get rid of the
knowsHowToHandleMessage functions on MessageReceiverMap and WebContext.

* Platform/CoreIPC/Connection.h:
(CoreIPC::Connection::client):
(Connection):
* Platform/CoreIPC/MessageReceiverMap.cpp:
(CoreIPC::MessageReceiverMap::addMessageReceiver):
(CoreIPC::MessageReceiverMap::invalidate):
(CoreIPC::MessageReceiverMap::knowsHowToHandleMessage):
(CoreIPC::MessageReceiverMap::dispatchMessage):
(CoreIPC::MessageReceiverMap::dispatchSyncMessage):
* Platform/CoreIPC/MessageReceiverMap.h:
(MessageReceiverMap):
* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext):
(WebKit::WebContext::~WebContext):
(WebKit::WebContext::dispatchMessage):
(WebKit::WebContext::dispatchSyncMessage):
(WebKit::WebContext::didReceiveMessage):
(WebKit::WebContext::didReceiveSyncMessage):
* UIProcess/WebContext.h:
(WebContext):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::fromConnection):
(WebKit):
(WebKit::WebProcessProxy::didReceiveMessage):
(WebKit::WebProcessProxy::didReceiveSyncMessage):
* UIProcess/WebProcessProxy.h:
(WebProcessProxy):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@131283 268f45cc-cd09-0410-ab3c-d52691b4dbfc