Commit d08dc073 authored by andersca@apple.com's avatar andersca@apple.com
Browse files

2011-02-15 Anders Carlsson <andersca@apple.com>

        Reviewed by Darin Adler.

        Implement WKPluginSiteDataManagerClearSiteData
        https://bugs.webkit.org/show_bug.cgi?id=54512
        <rdar://problem/8689312>

        * UIProcess/API/C/WKPluginSiteDataManager.cpp:
        (WKPluginSiteDataManagerGetTypeID):
        Implement this.

        (toNPClearSiteDataFlags):
        Convert WKClearSiteDataFlags to NPP_ClearSiteData flags.
        
        (WKPluginSiteDataManagerClearSiteData):
        (WKPluginSiteDataManagerClearAllSiteData):
        Call through to WebPluginSiteDataManager::clearSiteData.

        * UIProcess/API/C/WKPluginSiteDataManager.h:
        Change the clear functions to take a completion callback.

        * UIProcess/Plugins/WebPluginSiteDataManager.cpp:
        (WebKit::WebPluginSiteDataManager::clearSiteData):
        Ask the plug-in info store for all plug-in paths and send a
        ClearPluginSiteData message to the web process.
        
        (WebKit::WebPluginSiteDataManager::didClearSiteData):
        call the callback.

        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::didClearPluginSiteData):
        Call through to the plug-in site data manager.

        * UIProcess/WebContext.messages.in:
        Add ClearPluginSiteData message.

        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::clearPluginSiteData):
        Iterate over all the plug-in paths, creating plug-in modules and calling
        clearSiteData for each one.

        * WebProcess/WebProcess.h:
        * WebProcess/WebProcess.messages.in:
        Add DidClearPluginSiteData message.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78663 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c36f7499
2011-02-15 Anders Carlsson <andersca@apple.com>
Reviewed by Darin Adler.
Implement WKPluginSiteDataManagerClearSiteData
https://bugs.webkit.org/show_bug.cgi?id=54512
<rdar://problem/8689312>
* UIProcess/API/C/WKPluginSiteDataManager.cpp:
(WKPluginSiteDataManagerGetTypeID):
Implement this.
(toNPClearSiteDataFlags):
Convert WKClearSiteDataFlags to NPP_ClearSiteData flags.
(WKPluginSiteDataManagerClearSiteData):
(WKPluginSiteDataManagerClearAllSiteData):
Call through to WebPluginSiteDataManager::clearSiteData.
* UIProcess/API/C/WKPluginSiteDataManager.h:
Change the clear functions to take a completion callback.
* UIProcess/Plugins/WebPluginSiteDataManager.cpp:
(WebKit::WebPluginSiteDataManager::clearSiteData):
Ask the plug-in info store for all plug-in paths and send a
ClearPluginSiteData message to the web process.
(WebKit::WebPluginSiteDataManager::didClearSiteData):
call the callback.
* UIProcess/WebContext.cpp:
(WebKit::WebContext::didClearPluginSiteData):
Call through to the plug-in site data manager.
* UIProcess/WebContext.messages.in:
Add ClearPluginSiteData message.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::clearPluginSiteData):
Iterate over all the plug-in paths, creating plug-in modules and calling
clearSiteData for each one.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:
Add DidClearPluginSiteData message.
2011-02-15 Anders Carlsson <andersca@apple.com>
 
Reviewed by Jon Honeycutt.
......@@ -31,11 +31,11 @@
#include <WebCore/npapi.h>
using namespace WebKit;
using namespace std;
WKTypeID WKPluginSiteDataManagerGetTypeID()
{
// FIXME: Implement.
return 0;
return toAPI(WebPluginSiteDataManager::APIType);
}
void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerGetSitesWithDataFunction callback)
......@@ -43,12 +43,23 @@ void WKPluginSiteDataManagerGetSitesWithData(WKPluginSiteDataManagerRef managerR
toImpl(managerRef)->getSitesWithData(ArrayCallback::create(context, callback));
}
void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef manager, WKArrayRef sites, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds)
static uint64_t toNPClearSiteDataFlags(WKClearSiteDataFlags flags)
{
// FIXME: Implement.
if (flags == kWKClearSiteDataFlagsClearAll)
return NP_CLEAR_ALL;
uint64_t result = 0;
if (flags & kWKClearSiteDataFlagsClearCache)
result |= NP_CLEAR_CACHE;
return result;
}
void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef managerRef, WKArrayRef sitesRef, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
{
toImpl(managerRef)->clearSiteData(toImpl(sitesRef), toNPClearSiteDataFlags(flags), maxAgeInSeconds, VoidCallback::create(context, function));
}
void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef manager)
void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef managerRef, void* context, WKPluginSiteDataManagerClearSiteDataFunction function)
{
// FIXME: Implement.
toImpl(managerRef)->clearSiteData(0, NP_CLEAR_ALL, numeric_limits<uint64_t>::max(), VoidCallback::create(context, function));
}
......@@ -42,9 +42,11 @@ enum {
kWKClearSiteDataFlagsClearCache = 1 << 0,
};
typedef uint64_t WKClearSiteDataFlags;
WK_EXPORT void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef manager, WKArrayRef sites, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds);
WK_EXPORT void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef manager);
typedef void (*WKPluginSiteDataManagerClearSiteDataFunction)(WKErrorRef, void*);
WK_EXPORT void WKPluginSiteDataManagerClearSiteData(WKPluginSiteDataManagerRef manager, WKArrayRef sites, WKClearSiteDataFlags flags, uint64_t maxAgeInSeconds, void* context, WKPluginSiteDataManagerClearSiteDataFunction function);
WK_EXPORT void WKPluginSiteDataManagerClearAllSiteData(WKPluginSiteDataManagerRef manager, void* context, WKPluginSiteDataManagerClearSiteDataFunction function);
#ifdef __cplusplus
}
......
......@@ -79,7 +79,7 @@ void WebPluginSiteDataManager::getSitesWithData(PassRefPtr<ArrayCallback> prpCal
#endif
}
void WebPluginSiteDataManager::didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID)
void WebPluginSiteDataManager::didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID)
{
RefPtr<ArrayCallback> callback = m_arrayCallbacks.take(callbackID);
if (!callback) {
......@@ -96,5 +96,55 @@ void WebPluginSiteDataManager::didGetSitesWithPluginData(const Vector<String>& s
callback->performCallbackWithReturnValue(resultArray.get());
}
void WebPluginSiteDataManager::clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback> prpCallback)
{
RefPtr<VoidCallback> callback = prpCallback;
if (!m_webContext) {
callback->invalidate();
return;
}
// If the array is empty, don't do anything.
if (sites && !sites->size()) {
callback->performCallback();
return;
}
#if ENABLE(PLUGIN_PROCESS)
// FIXME: Implement.
callback->invalidate();
#else
if (!m_webContext->hasValidProcess()) {
callback->invalidate();
return;
}
uint64_t callbackID = callback->callbackID();
m_voidCallbacks.set(callbackID, callback.release());
Vector<String> sitesVector;
if (sites) {
for (size_t i = 0; i < sites->size(); ++i) {
if (WebString* site = sites->at<WebString>(i))
sitesVector.append(site->string());
}
}
Vector<String> pluginPaths;
m_webContext->pluginInfoStore()->getPluginPaths(pluginPaths);
m_webContext->process()->send(Messages::WebProcess::ClearPluginSiteData(pluginPaths, sitesVector, flags, maxAgeInSeconds, callbackID), 0);
#endif
}
void WebPluginSiteDataManager::didClearSiteData(uint64_t callbackID)
{
RefPtr<VoidCallback> callback = m_voidCallbacks.take(callbackID);
if (!callback) {
// FIXME: Log error or assert.
return;
}
callback->performCallback();
}
} // namespace WebKit
......@@ -32,12 +32,6 @@
#include <wtf/HashMap.h>
#include <wtf/PassRefPtr.h>
namespace CoreIPC {
class ArgumentDecoder;
class Connection;
class MessageID;
}
namespace WebKit {
class WebContext;
......@@ -55,7 +49,10 @@ public:
void clearContext() { m_webContext = 0; }
void getSitesWithData(PassRefPtr<ArrayCallback>);
void didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID);
void didGetSitesWithData(const Vector<String>& sites, uint64_t callbackID);
void clearSiteData(ImmutableArray* sites, uint64_t flags, uint64_t maxAgeInSeconds, PassRefPtr<VoidCallback>);
void didClearSiteData(uint64_t callbackID);
private:
explicit WebPluginSiteDataManager(WebContext*);
......@@ -64,6 +61,7 @@ private:
WebContext* m_webContext;
HashMap<uint64_t, RefPtr<ArrayCallback> > m_arrayCallbacks;
HashMap<uint64_t, RefPtr<VoidCallback> > m_voidCallbacks;
};
} // namespace WebKit
......
......@@ -448,7 +448,12 @@ void WebContext::getPluginPath(const String& mimeType, const String& urlString,
#if !ENABLE(PLUGIN_PROCESS)
void WebContext::didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID)
{
m_pluginSiteDataManager->didGetSitesWithPluginData(sites, callbackID);
m_pluginSiteDataManager->didGetSitesWithData(sites, callbackID);
}
void WebContext::didClearPluginSiteData(uint64_t callbackID)
{
m_pluginSiteDataManager->didClearSiteData(callbackID);
}
#endif
......
......@@ -159,6 +159,7 @@ private:
void getPluginPath(const String& mimeType, const String& urlString, String& pluginPath);
#if !ENABLE(PLUGIN_PROCESS)
void didGetSitesWithPluginData(const Vector<String>& sites, uint64_t callbackID);
void didClearPluginSiteData(uint64_t callbackID);
#endif
// Implemented in generated WebContextMessageReceiver.cpp
......
......@@ -37,6 +37,7 @@ messages -> WebContext {
#if !ENABLE(PLUGIN_PROCESS)
void DidGetSitesWithPluginData(Vector<WTF::String> sites, uint64_t callbackID)
void DidClearPluginSiteData(uint64_t callbackID)
#endif
}
......@@ -659,6 +659,26 @@ void WebProcess::getSitesWithPluginData(const Vector<String>& pluginPaths, uint6
m_connection->send(Messages::WebContext::DidGetSitesWithPluginData(sites, callbackID), 0);
}
void WebProcess::clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
{
for (size_t i = 0; i < pluginPaths.size(); ++i) {
RefPtr<NetscapePluginModule> netscapePluginModule = NetscapePluginModule::getOrCreate(pluginPaths[i]);
if (!netscapePluginModule)
continue;
if (sites.isEmpty()) {
// Clear everything.
netscapePluginModule->clearSiteData(String(), flags, maxAgeInSeconds);
continue;
}
for (size_t i = 0; i < sites.size(); ++i)
netscapePluginModule->clearSiteData(sites[i], flags, maxAgeInSeconds);
}
m_connection->send(Messages::WebContext::DidClearPluginSiteData(callbackID), 0);
}
#endif
void WebProcess::downloadRequest(uint64_t downloadID, uint64_t initiatingPageID, const ResourceRequest& request)
......
......@@ -145,6 +145,7 @@ private:
#if !ENABLE(PLUGIN_PROCESS)
void getSitesWithPluginData(const Vector<String>& pluginPaths, uint64_t callbackID);
void clearPluginSiteData(const Vector<String>& pluginPaths, const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
#endif
void startMemorySampler(const SandboxExtension::Handle&, const String&, const double);
......
......@@ -47,6 +47,7 @@ messages -> WebProcess {
#if !ENABLE(PLUGIN_PROCESS)
# Plug-ins.
GetSitesWithPluginData(Vector<WTF::String> pluginPaths, uint64_t callbackID)
ClearPluginSiteData(Vector<WTF::String> pluginPaths, Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
#endif
ClearResourceCaches();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment