HTTP Authentication should be directly between the NetworkProcess and the UIProcess
<rdar://problem/13074829> and https://bugs.webkit.org/show_bug.cgi?id=107974

Reviewed by Alexey Proskuryakov.

Some of this patch is refactoring to enable more flexibility in the authentication mechanism
and the rest is actually implementing Network->UI process authentication.

Expose the same AuthenticationManager to anyone in the NetworkProcess asking for it:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::authenticationManager):
(WebKit::NetworkProcess::downloadsAuthenticationManager):
* NetworkProcess/NetworkProcess.h:

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::didReceiveAuthenticationChallenge): Instead of messaging to
  the WebProcess, tell the NetworkProcess AuthenticationManager.

Add WebPageID and WebFrameID members to SchedulableLoader that they receive from
* NetworkProcess/SchedulableLoader.cpp:
* NetworkProcess/SchedulableLoader.h:
(WebKit::SchedulableLoader::webPageID):
(WebKit::SchedulableLoader::webFrameID):

Add a 3rd form of "didReceiveAuthenticationChallenge" for NetworkProcess use:
* Shared/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::mapChallengeToIdentifier):
(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
* Shared/Authentication/AuthenticationManager.h:
* Shared/Authentication/mac/AuthenticationManager.mac.mm:
(WebKit::AuthenticationManager::tryUsePlatformCertificateInfoForChallenge): Remove a now obsolete comment

Include the WebPage and WebFrame ID for the originator of this request in case it results in a challenge:
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:
(WebKit::NetworkResourceLoadParameters::webPageID):
(WebKit::NetworkResourceLoadParameters::webFrameID):

Create a AuthenticationChallengeProxy pointing back to the NetworkProcess (instead of a WebProcess),
and send the challenge to the appropriate WebPageProxy:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didReceiveAuthenticationChallenge):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:

Refactor didReceiveAuthenticationChallenge so an outsider can directly hand over an AuthenticationChallengeProxy:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveAuthenticationChallenge):
(WebKit::WebPageProxy::didReceiveAuthenticationChallengeProxy):
* UIProcess/WebPageProxy.h:

Add a global WebPageID -> WebPageProxy map so parties with an ID don't need to know which process it belongs to:
* UIProcess/WebProcessProxy.cpp:
(WebKit::globalPageMap):
(WebKit::WebProcessProxy::webPage):
(WebKit::WebProcessProxy::createWebPage):
(WebKit::WebProcessProxy::addExistingWebPage):
(WebKit::WebProcessProxy::removeWebPage):
* UIProcess/WebProcessProxy.h:

* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):

* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::loadResourceSynchronously): Pass 0 for WebFrameID and WebPageID since synchronous
  loads don't go through "normal" authentication channels and don't need them. Yet.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@140874 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Wrap content filtering code in an object
https://bugs.webkit.org/show_bug.cgi?id=107914

Reviewed by Alexey Proskuryakov.

Source/WebCore:

Content filtering code currently requires explicit and somewhat complex
lifetime management of the WebFilterEvaluator object for correct
behavior. Simplify this by wrapping WebFilterEvaluator in an object and
have MainResourceLoader implicitly manage its lifetime by holding it in
an OwnPtr.

This change has benefits other than the simplified lifetime management.
It removes direct calls into WebKitSystemInterface from the loader, and
it allows us to keep a strong reference to the replacement data
returned from wkFilterAddData() and wkFilterDataComplete() rather than
relying on it being autoreleased.

* WebCore.exp.in: Updated to match changes in WebCoreSystemInterface.
* WebCore.xcodeproj/project.pbxproj: Added new files.
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::MainResourceLoader): Removed unneeded initialization.
(WebCore::MainResourceLoader::~MainResourceLoader): Removed an unneeded ASSERT().
(WebCore::MainResourceLoader::cancel): Removed unneeded wkFilterRelease().
(WebCore::MainResourceLoader::responseReceived): Created a
ContentFilter object rather than calling wkFilterCreateInstance().
(WebCore::MainResourceLoader::dataReceived): Rewrote content filtering
logic in terms of the wrapper object. Removed any explicit lifetime
management.
(WebCore::MainResourceLoader::didFinishLoading): Ditto.
(WebCore::MainResourceLoader::notifyFinished): Removed unneeded wkFilterRelease().
* loader/MainResourceLoader.h:
* platform/ContentFilter.h: Added.
* platform/mac/ContentFilterMac.mm: Added.
(WebCore::ContentFilter::create):
(WebCore::ContentFilter::ContentFilter):
(WebCore::ContentFilter::isEnabled): Returned the result of wkFilterIsManagedSession().
(WebCore::ContentFilter::addData): Called wkFilterAddData() and stored
the resulting NSData in m_replacementData.
(WebCore::ContentFilter::finishedAddingData): Called wkFilterDataComplete()
and stored the resulting NSData in m_replacementData.
(WebCore::ContentFilter::needsMoreData): Returned the result of wkFilterIsBuffering().
(WebCore::ContentFilter::didBlockData): Returned the result of wkFilterWasBlocked().
(WebCore::ContentFilter::getReplacementData): Returned the data stored in m_replacementData.
* platform/mac/WebCoreSystemInterface.h: Updated to reflect changes in WKSI.
* platform/mac/WebCoreSystemInterface.mm: Ditto.

* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* loader/MainResourceLoader.cpp:
(WebCore::MainResourceLoader::MainResourceLoader):
(WebCore::MainResourceLoader::~MainResourceLoader):
(WebCore::MainResourceLoader::cancel):
(WebCore::MainResourceLoader::responseReceived):
(WebCore::MainResourceLoader::dataReceived):
(WebCore::MainResourceLoader::didFinishLoading):
(WebCore::MainResourceLoader::notifyFinished):
* loader/MainResourceLoader.h:
(MainResourceLoader):
* platform/ContentFilter.h: Added.
(WebCore):
(ContentFilter):
* platform/mac/ContentFilterMac.mm: Added.
(WebCore):
(WebCore::ContentFilter::create):
(WebCore::ContentFilter::ContentFilter):
(WebCore::ContentFilter::isEnabled):
(WebCore::ContentFilter::addData):
(WebCore::ContentFilter::finishedAddingData):
(WebCore::ContentFilter::needsMoreData):
(WebCore::ContentFilter::didBlockData):
(WebCore::ContentFilter::getReplacementData):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Updated to reflect changes in WKSI.

Source/WebKit2:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface): Updated to reflect changes in WKSI.

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