Reviewed by Darin.
[WebKit-https.git] / WebKit / win / WebDatabaseManager.cpp
index d6e77b891e72a8b1df04e24f76d12ab15a499231..16653406aa2bd845be9eba77bca13c58c43d44fa 100644 (file)
 #include "WebDatabaseManager.h"\r
 #include "WebKitDLL.h"\r
 \r
+#include "COMEnumVariant.h"\r
+#include "WebSecurityOrigin.h"\r
+\r
+#include <WebCore/BString.h>\r
+#include <WebCore/COMPtr.h>\r
 #include <WebCore/DatabaseTracker.h>\r
 #include <WebCore/FileSystem.h>\r
-#include <WebCore/COMPtr.h>\r
+#include <WebCore/SecurityOriginData.h>\r
 \r
 using namespace WebCore;\r
 \r
-static COMPtr<WebDatabaseManager> s_sharedWebDatabaseManager;
+static COMPtr<WebDatabaseManager> s_sharedWebDatabaseManager;\r
 \r
 // WebDatabaseManager --------------------------------------------------------------\r
 WebDatabaseManager* WebDatabaseManager::createInstance()\r
@@ -85,6 +90,8 @@ ULONG STDMETHODCALLTYPE WebDatabaseManager::Release()
     return newRef;\r
 }\r
 \r
+template<> struct COMVariantSetter<SecurityOriginData> : COMIUnknownVariantSetter<WebSecurityOrigin, SecurityOriginData> {};\r
+\r
 // IWebDatabaseManager -------------------------------------------------------------\r
 HRESULT STDMETHODCALLTYPE WebDatabaseManager::sharedWebDatabaseManager( \r
     /* [retval][out] */ IWebDatabaseManager** result)\r
@@ -106,7 +113,12 @@ HRESULT STDMETHODCALLTYPE WebDatabaseManager::origins(
     if (this != s_sharedWebDatabaseManager)\r
         return E_FAIL;\r
 \r
-    return E_NOTIMPL;\r
+    Vector<SecurityOriginData> origins;\r
+    DatabaseTracker::tracker().origins(origins);\r
+    COMPtr<COMEnumVariant<Vector<SecurityOriginData> > > enumVariant(AdoptCOM, COMEnumVariant<Vector<SecurityOriginData> >::adopt(origins));\r
+\r
+    *result = enumVariant.releaseRef();\r
+    return S_OK;\r
 }\r
     \r
 HRESULT STDMETHODCALLTYPE WebDatabaseManager::databasesWithOrigin( \r
@@ -121,9 +133,19 @@ HRESULT STDMETHODCALLTYPE WebDatabaseManager::databasesWithOrigin(
     if (this != s_sharedWebDatabaseManager)\r
         return E_FAIL;\r
 \r
-    return E_NOTIMPL;\r
+    COMPtr<WebSecurityOrigin> webSecurityOrigin(Query, origin);\r
+    if (!webSecurityOrigin)\r
+        return E_FAIL;\r
+\r
+    Vector<String> databaseNames;\r
+    DatabaseTracker::tracker().databaseNamesForOrigin(webSecurityOrigin->securityOriginData(), databaseNames);\r
+\r
+    COMPtr<COMEnumVariant<Vector<String> > > enumVariant(AdoptCOM, COMEnumVariant<Vector<String> >::adopt(databaseNames));\r
+\r
+    *result = enumVariant.releaseRef();\r
+    return S_OK;\r
 }\r
-    \r
+\r
 HRESULT STDMETHODCALLTYPE WebDatabaseManager::detailsForDatabaseWithOrigin( \r
     /* [in] */ BSTR* database,\r
     /* [in] */ IWebSecurityOrigin* origin,\r