Reviewed by Adam.
[WebKit-https.git] / WebKit / win / WebDatabaseManager.cpp
index 76674d2d171a6e59b117b9f1a5125f9451cf029e..d6e77b891e72a8b1df04e24f76d12ab15a499231 100644 (file)
  */\r
 #include "config.h"\r
 #include "WebDatabaseManager.h"\r
+#include "WebKitDLL.h"\r
 \r
 #include <WebCore/DatabaseTracker.h>\r
 #include <WebCore/FileSystem.h>\r
+#include <WebCore/COMPtr.h>\r
+\r
+using namespace WebCore;\r
+\r
+static COMPtr<WebDatabaseManager> s_sharedWebDatabaseManager;
+\r
+// WebDatabaseManager --------------------------------------------------------------\r
+WebDatabaseManager* WebDatabaseManager::createInstance()\r
+{\r
+    WebDatabaseManager* manager = new WebDatabaseManager();\r
+    manager->AddRef();\r
+    return manager;    \r
+}\r
+\r
+WebDatabaseManager::WebDatabaseManager()\r
+    : m_refCount(0)\r
+{\r
+    gClassCount++;\r
+}\r
+\r
+WebDatabaseManager::~WebDatabaseManager()\r
+{\r
+    gClassCount--;\r
+}\r
+\r
+// IUnknown ------------------------------------------------------------------------\r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::QueryInterface(REFIID riid, void** ppvObject)\r
+{\r
+    *ppvObject = 0;\r
+    if (IsEqualGUID(riid, IID_IUnknown))\r
+        *ppvObject = static_cast<WebDatabaseManager*>(this);\r
+    else if (IsEqualGUID(riid, IID_IWebDatabaseManager))\r
+        *ppvObject = static_cast<WebDatabaseManager*>(this);\r
+    else\r
+        return E_NOINTERFACE;\r
+\r
+    AddRef();\r
+    return S_OK;\r
+}\r
+\r
+ULONG STDMETHODCALLTYPE WebDatabaseManager::AddRef()\r
+{\r
+    return ++m_refCount;\r
+}\r
+\r
+ULONG STDMETHODCALLTYPE WebDatabaseManager::Release()\r
+{\r
+    ULONG newRef = --m_refCount;\r
+    if (!newRef)\r
+        delete this;\r
+\r
+    return newRef;\r
+}\r
+\r
+// IWebDatabaseManager -------------------------------------------------------------\r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::sharedWebDatabaseManager( \r
+    /* [retval][out] */ IWebDatabaseManager** result)\r
+{\r
+    if (!s_sharedWebDatabaseManager)\r
+        s_sharedWebDatabaseManager.adoptRef(WebDatabaseManager::createInstance());\r
+\r
+    return s_sharedWebDatabaseManager.copyRefTo(result);\r
+}\r
+\r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::origins( \r
+    /* [retval][out] */ IEnumVARIANT** result)\r
+{\r
+    if (!result)\r
+        return E_POINTER;\r
+\r
+    *result = 0;\r
+\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
+    \r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::databasesWithOrigin( \r
+    /* [in] */ IWebSecurityOrigin* origin,\r
+    /* [retval][out] */ IEnumVARIANT** result)\r
+{\r
+    if (!origin || !result)\r
+        return E_POINTER;\r
+\r
+    *result = 0;\r
+\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
+    \r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::detailsForDatabaseWithOrigin( \r
+    /* [in] */ BSTR* database,\r
+    /* [in] */ IWebSecurityOrigin* origin,\r
+    /* [retval][out] */ IPropertyBag** result)\r
+{\r
+    if (!database || !origin || !result)\r
+        return E_POINTER;\r
+\r
+    *result = 0;\r
+\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
+    \r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteAllDatabases()\r
+{\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
+   \r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteDatabasesWithOrigin( \r
+    /* [in] */ IWebSecurityOrigin* origin)\r
+{\r
+    if (!origin)\r
+        return E_POINTER;\r
+\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
+    \r
+HRESULT STDMETHODCALLTYPE WebDatabaseManager::deleteDatabaseWithOrigin( \r
+    /* [in] */ BSTR* databaseName,\r
+    /* [in] */ IWebSecurityOrigin* origin)\r
+{\r
+    if (!databaseName || !origin)\r
+        return E_POINTER;\r
+\r
+    if (this != s_sharedWebDatabaseManager)\r
+        return E_FAIL;\r
+\r
+    return E_NOTIMPL;\r
+}\r
 \r
 void WebKitSetWebDatabasesPathIfNecessary()\r
 {\r