1 #include "wrt/src/browser/wrt_quota_permission_context.h"
3 #if BUILDFLAG(IS_TIZEN_TV)
4 #include <tzplatform_config.h>
6 #include "base/files/file_path.h"
7 #include "base/system/sys_info.h"
8 #include "wrt/src/base/platform_info.h"
9 #include "wrt/src/common/privilege.h"
16 #if BUILDFLAG(IS_TIZEN_TV)
17 const char* kStoragePrivilege = "http://tizen.org/privilege/unlimitedstorage";
19 bool IsOverThanHalfFreeSpace(
20 int64_t requested_size) {
21 base::FilePath tz_sys_user(tzplatform_getenv(TZ_SYS_USER));
22 int64_t available = base::SysInfo::AmountOfFreeDiskSpace(tz_sys_user);
25 LOG(INFO) << "requested_size : " << requested_size
26 << ", available : " << available;
27 if (requested_size > available)
36 WRTQuotaPermissionContext::WRTQuotaPermissionContext() {}
38 WRTQuotaPermissionContext::~WRTQuotaPermissionContext() {}
40 void WRTQuotaPermissionContext::RequestQuotaPermission(
41 const content::StorageQuotaParams& params,
42 int render_process_id,
43 PermissionCallback callback) {
44 #if BUILDFLAG(IS_TIZEN_TV)
45 if (privilege::FindPrivilegeFromConfig(kStoragePrivilege)) {
46 if (HasLimitQuotaPermission() &&
47 IsOverThanHalfFreeSpace(params.requested_size))
48 std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_DISALLOW);
50 std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_ALLOW);
53 std::move(callback).Run(QUOTA_PERMISSION_RESPONSE_CANCELLED);