${BASE_SRCDIR}/common/application_data.cc
${BASE_SRCDIR}/common/app_control.cc
${BASE_SRCDIR}/common/locale_manager.cc
+ ${BASE_SRCDIR}/common/app_db.cc
)
INCLUDE_DIRECTORIES(${TARGET_COMMON_STATIC_INCS})
--- /dev/null
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "common/app_db.h"
+
+#include <app_preference.h>
+#include <memory>
+
+#include "common/string_utils.h"
+
+namespace wrt {
+
+namespace {
+ const char* kSectionPrefix = "_SECT_";
+ const char* kSectionSuffix = "_SECT_";
+
+} // namespace
+
+class PreferenceAppDB : public AppDB {
+ public:
+ PreferenceAppDB();
+ virtual bool HasKey(const std::string& section,
+ const std::string& key) const;
+ virtual std::string Get(const std::string& section,
+ const std::string& key) const;
+ virtual void Set(const std::string& section,
+ const std::string& key,
+ const std::string& value);
+ virtual void GetKeys(const std::string& section,
+ std::list<std::string>* keys) const;
+ virtual void Remove(const std::string& section,
+ const std::string& key);
+};
+
+PreferenceAppDB::PreferenceAppDB() {
+}
+
+bool PreferenceAppDB::HasKey(const std::string& section,
+ const std::string& key) const {
+ bool existed = false;
+ std::string combined_key = kSectionPrefix + section + kSectionSuffix + key;
+ return preference_is_existing(combined_key.c_str(), &existed) == 0 && existed;
+}
+
+std::string PreferenceAppDB::Get(const std::string& section,
+ const std::string& key) const {
+ std::string combined_key = kSectionPrefix + section + kSectionSuffix + key;
+ char* value;
+ if (preference_get_string(combined_key.c_str(), &value) == 0) {
+ std::unique_ptr<char, decltype(std::free)*> ptr {value, std::free};
+ return std::string(value);
+ }
+ return std::string();
+}
+
+void PreferenceAppDB::Set(const std::string& section,
+ const std::string& key,
+ const std::string& value) {
+ std::string combined_key = kSectionPrefix + section + kSectionSuffix + key;
+ preference_set_string(combined_key.c_str(), value.c_str());
+}
+
+void PreferenceAppDB::GetKeys(const std::string& section,
+ std::list<std::string>* keys) const {
+ auto callback = [](const char* key, void *user_data) {
+ auto list = static_cast<std::list<std::string>*>(user_data);
+ if (utils::StartsWith(key, list->front())) {
+ list->push_back(key);
+ }
+ return true;
+ };
+ std::string key_prefix = kSectionPrefix + section + kSectionSuffix;
+ keys->push_front(key_prefix);
+ preference_foreach_item(callback, keys);
+ keys->pop_front();
+}
+
+void PreferenceAppDB::Remove(const std::string& section,
+ const std::string& key) {
+ std::string combined_key = kSectionPrefix + section + kSectionSuffix + key;
+ preference_remove(combined_key.c_str());
+}
+
+
+AppDB* AppDB::GetInstance() {
+ static PreferenceAppDB instance;
+ return &instance;
+}
+
+
+
+} // namespace wrt
--- /dev/null
+// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WRT_RUNTIME_APPDB_H_
+#define WRT_RUNTIME_APPDB_H_
+
+#include <string>
+#include <list>
+
+namespace wrt {
+class AppDB {
+ public:
+ static AppDB* GetInstance();
+ virtual bool HasKey(const std::string& section,
+ const std::string& key) const = 0;
+ virtual std::string Get(const std::string& section,
+ const std::string& key) const = 0;
+ virtual void Set(const std::string& section,
+ const std::string& key,
+ const std::string& value) = 0;
+ virtual void GetKeys(const std::string& section,
+ std::list<std::string>* keys) const = 0;
+ virtual void Remove(const std::string& section,
+ const std::string& key) = 0;
+};
+} // namespace wrt
+#endif // WRT_RUNTIME_APPDB_H_
${BASE_SRCDIR}/runtime/web_view.cc
${BASE_SRCDIR}/runtime/web_view_impl.cc
${BASE_SRCDIR}/runtime/vibration_manager.cc
- ${BASE_SRCDIR}/runtime/app_db.cc
${BASE_SRCDIR}/runtime/notification_manager.cc
)
+++ /dev/null
-// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "runtime/app_db.h"
-
-#include <app_preference.h>
-#include <memory>
-
-namespace wrt {
-
-class PreferenceAppDB : public AppDB {
- public:
- PreferenceAppDB();
- virtual bool HasKey(const std::string& key) const;
- virtual std::string Get(const std::string& key) const;
- virtual void Set(const std::string& key, const std::string& value);
- virtual void GetKeys(std::list<std::string>* keys) const;
-};
-
-PreferenceAppDB::PreferenceAppDB() {
-}
-
-bool PreferenceAppDB::HasKey(const std::string& key) const {
- bool existed = false;
- return preference_is_existing(key.c_str(), &existed) == 0 && existed;
-}
-
-std::string PreferenceAppDB::Get(const std::string& key) const {
- char* value;
- if (preference_get_string(key.c_str(), &value) == 0) {
- std::unique_ptr<char, decltype(std::free)*> ptr {value, std::free};
- return std::string(value);
- }
- return std::string();
-}
-
-void PreferenceAppDB::Set(const std::string& key, const std::string& value) {
- preference_set_string(key.c_str(), value.c_str());
-}
-
-void PreferenceAppDB::GetKeys(std::list<std::string>* keys) const {
- auto callback = [](const char* key, void *user_data) {
- auto list = static_cast<std::list<std::string>*>(user_data);
- list->push_back(key);
- return true;
- };
- preference_foreach_item(callback, keys);
-}
-
-AppDB* AppDB::GetInstance() {
- static PreferenceAppDB instance;
- return &instance;
-}
-
-
-
-} // namespace wrt
+++ /dev/null
-// Copyright 2015 Samsung Electronics Co, Ltd. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WRT_RUNTIME_APPDB_H_
-#define WRT_RUNTIME_APPDB_H_
-
-#include <string>
-#include <list>
-
-namespace wrt {
-class AppDB {
- public:
- static AppDB* GetInstance();
- virtual bool HasKey(const std::string& key) const = 0;
- virtual std::string Get(const std::string& key) const = 0;
- virtual void Set(const std::string& key, const std::string& value) = 0;
- virtual void GetKeys(std::list<std::string>* keys) const = 0;
-};
-} // namespace wrt
-#endif // WRT_RUNTIME_APPDB_H_
#include "common/locale_manager.h"
#include "common/application_data.h"
#include "common/resource_manager.h"
-#include "runtime/app_db.h"
+#include "common/app_db.h"
#include "runtime/notification_manager.h"
namespace wrt {
const char* kNotificationPermissionPrefix = "__WRT_NOTIPERM_";
const char* kQuotaPermissionPrefix = "__WRT_QUOTAPERM_";
const char* kCertificateAllowPrefix = "__WRT_CERTIPERM_";
+const char* kDBPrivateSection = "private";
bool FindPrivilege(wrt::ApplicationData* app_data,
const std::string& url,
std::function<void(bool)> result_handler) {
auto db = AppDB::GetInstance();
- std::string reminder = db->Get(kNotificationPermissionPrefix + url);
+ std::string reminder = db->Get(kDBPrivateSection,
+ kNotificationPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
} else if (reminder == "denied") {
const std::string& url,
std::function<void(bool)> result_handler) {
auto db = AppDB::GetInstance();
- std::string reminder = db->Get(kGeolocationPermissionPrefix + url);
+ std::string reminder = db->Get(kDBPrivateSection,
+ kGeolocationPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
} else if (reminder == "denied") {
const std::string& url,
std::function<void(bool)> result_handler) {
auto db = AppDB::GetInstance();
- std::string reminder = db->Get(kQuotaPermissionPrefix + url);
+ std::string reminder = db->Get(kDBPrivateSection,
+ kQuotaPermissionPrefix + url);
if (reminder == "allowed") {
result_handler(true);
} else if (reminder == "denied") {
const std::string& pem,
std::function<void(bool allow)> result_handler) {
auto db = AppDB::GetInstance();
- std::string reminder = db->Get(kCertificateAllowPrefix + pem);
+ std::string reminder = db->Get(kDBPrivateSection,
+ kCertificateAllowPrefix + pem);
if (reminder == "allowed") {
result_handler(true);
} else if (reminder == "denied") {