1/* 2 * Copyright (C) 2011, 2013 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 "WebOriginDataManager.h" 28 29#include "DatabaseProcess.h" 30#include "SecurityOriginData.h" 31#include "WebCoreArgumentCoders.h" 32#include "WebOriginDataManagerMessages.h" 33#include "WebOriginDataManagerProxyMessages.h" 34#include <WebCore/SecurityOrigin.h> 35#include <WebCore/SecurityOriginHash.h> 36 37#include <wtf/HashSet.h> 38 39using namespace WebCore; 40 41namespace WebKit { 42 43const char* WebOriginDataManager::supplementName() 44{ 45 return "WebOriginDataManager"; 46} 47 48WebOriginDataManager::WebOriginDataManager(ChildProcess* childProcess) 49 : m_childProcess(childProcess) 50{ 51 m_childProcess->addMessageReceiver(Messages::WebOriginDataManager::messageReceiverName(), *this); 52} 53 54void WebOriginDataManager::getOrigins(WKOriginDataTypes types, uint64_t callbackID) 55{ 56 // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data. 57 // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests 58 // for multiple types into the one callback. 59 if (types & kWKIndexedDatabaseData) { 60 DatabaseProcess::shared().getIndexedDatabaseOrigins(callbackID); 61 return; 62 } 63 64 Vector<SecurityOriginData> results; 65 m_childProcess->send(Messages::WebOriginDataManagerProxy::DidGetOrigins(results, callbackID), 0); 66} 67 68void WebOriginDataManager::deleteEntriesForOrigin(WKOriginDataTypes types, const SecurityOriginData& originData, uint64_t callbackID) 69{ 70 // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data. 71 // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests 72 // for multiple types into the one callback. 73 if (types & kWKIndexedDatabaseData) { 74 DatabaseProcess::shared().deleteIndexedDatabaseEntriesForOrigin(originData, callbackID); 75 return; 76 } 77 78 m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0); 79} 80 81void WebOriginDataManager::deleteEntriesModifiedBetweenDates(WKOriginDataTypes types, double startTime, double endTime, uint64_t callbackID) 82{ 83 // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data. 84 // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests 85 // for multiple types into the one callback. 86 if (types & kWKIndexedDatabaseData) { 87 DatabaseProcess::shared().deleteIndexedDatabaseEntriesModifiedBetweenDates(startTime, endTime, callbackID); 88 return; 89 } 90 m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteEntries(callbackID), 0); 91} 92 93void WebOriginDataManager::deleteAllEntries(WKOriginDataTypes types, uint64_t callbackID) 94{ 95 // FIXME: For now, the DatabaseProcess only handles IndexedDatabase origin data. 96 // If it ever starts handling other data types (e.g. WebSQL) then it will have to aggregrate requests 97 // for multiple types into the one callback. 98 if (types & kWKIndexedDatabaseData) { 99 DatabaseProcess::shared().deleteAllIndexedDatabaseEntries(callbackID); 100 return; 101 } 102 m_childProcess->send(Messages::WebOriginDataManagerProxy::DidDeleteAllEntries(callbackID), 0); 103} 104 105} // namespace WebKit 106