m_securityOriginDBInterface.DetachFromThread();
}
+SecurityOriginDataList SecurityOriginDAO::getSecurityOriginDataList(void)
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ SecurityOriginDataList list;
+ SECURITY_ORIGIN_DB_SELECT(select, SecurityOriginInfo, &m_securityOriginDBInterface);
+ typedef std::list<SecurityOriginInfo::Row> RowList;
+ RowList rowList = select->GetRowList();
+
+ FOREACH(it, rowList) {
+ Origin origin(it->Get_scheme(), it->Get_host(), it->Get_port());
+ list.push_back(
+ SecurityOriginDataPtr(
+ new SecurityOriginData(
+ static_cast<Feature>(it->Get_feature()), origin)));
+ }
+ return list;
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Failed to get data list")
+}
+
Result SecurityOriginDAO::getResult(const SecurityOriginData &securityOriginData)
{
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to set security origin data")
}
+void SecurityOriginDAO::removeSecurityOriginData(
+ const SecurityOriginData &securityOriginData)
+{
+ SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
+ {
+ ScopedTransaction transaction(&m_securityOriginDBInterface);
+
+ if (true == hasResult(securityOriginData)) {
+ SECURITY_ORIGIN_DB_DELETE(del, SecurityOriginInfo, &m_securityOriginDBInterface)
+ del->Where(
+ And(And(And(Equals<SecurityOriginInfo::feature>(securityOriginData.feature),
+ Equals<SecurityOriginInfo::scheme>(securityOriginData.origin.scheme)),
+ Equals<SecurityOriginInfo::host>(securityOriginData.origin.host)),
+ Equals<SecurityOriginInfo::port>(securityOriginData.origin.port)));
+ del->Execute();
+ transaction.Commit();
+ }
+ }
+ SQL_CONNECTION_EXCEPTION_HANDLER_END("Fail to set security origin data")
+}
+
bool SecurityOriginDAO::hasResult(const SecurityOriginData &securityOriginData)
{
SQL_CONNECTION_EXCEPTION_HANDLER_BEGIN
explicit SecurityOriginDAO(int handle);
virtual ~SecurityOriginDAO();
+ SecurityOriginDataList getSecurityOriginDataList();
Result getResult(const SecurityOriginData &securityOriginData);
void setSecurityOriginData(const SecurityOriginData &securityOriginData,
const Result result);
+ void removeSecurityOriginData(const SecurityOriginData &securityOriginData);
private:
std::string m_securityOriginDBPath;
DPL::DB::ThreadDatabaseSupport m_securityOriginDBInterface;
bool hasResult(const SecurityOriginData &securityOriginData);
};
+typedef std::shared_ptr<SecurityOriginDAO> SecurityOriginDAOPtr;
+
} // namespace SecurityOriginDB
#endif // _SECURITY_ORIGIN_DAO_H_
#define _SECURITY_ORIGIN_DAO_TYPES_H_
#include <list>
+#include <memory>
#include <dpl/string.h>
namespace SecurityOriginDB {
enum Feature
{
+ FEATURE_START = 0,
FEATURE_GEOLOCATION = 0,
- FEATURE_FILESYSTEM,
- FEATURE_WEB_NOTIFICATION
+ FEATURE_WEB_NOTIFICATION,
+ FEATURE_WEB_DATABASE,
+ FEATURE_FILE_SYSTEM_ACCESS,
+ FEATURE_END = FEATURE_FILE_SYSTEM_ACCESS
};
enum Result
{
RESULT_UNKNOWN = 0,
- RESULT_USER_ALLOWED,
- RESULT_USER_DENIED,
- RESULT_EXCEPTION_ALLOWED,
- RESULT_EXCEPTION_DENIED
+ RESULT_ALLOW_ONCE,
+ RESULT_DENY_ONCE,
+ RESULT_ALLOW_ALWAYS,
+ RESULT_DENY_ALWAYS
};
struct Origin
}
};
+typedef std::shared_ptr<SecurityOriginData> SecurityOriginDataPtr;
+typedef std::list<SecurityOriginDataPtr> SecurityOriginDataList;
+
} // namespace SecurityOriginDB
#endif // _SECURITY_ORIGIN_DAO_TYPES_H_