summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_quota.h
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 09:52:07 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-08 09:52:07 +0000
commit70c6c0434d1d02f3994ec65054a0860ee20e7d43 (patch)
treea5bb9840ebeda22497f5e98cff7c6f34087d6e0b /webkit/fileapi/file_system_quota.h
parentda8f24a7eb62b20a29413c8b1bd1ccd156cfb593 (diff)
downloadchromium_src-70c6c0434d1d02f3994ec65054a0860ee20e7d43.zip
chromium_src-70c6c0434d1d02f3994ec65054a0860ee20e7d43.tar.gz
chromium_src-70c6c0434d1d02f3994ec65054a0860ee20e7d43.tar.bz2
Allow unlimited quota for apps for FileSystem access
- allow unlimited access for apps/extensions that have "unlimited_storage" permission. - disallow any write access that may increase the filesystem usage (i.e. copy/move/create/write). for others. - allow unlimit access for file:/// URIs only if --allow-file-from-files flag is given. BUG=57211 TEST=FileSystemQuota.* TEST=Load a remote test page and verify that it throws QUOTA_EXCEEDED_ERR (22) for any write access. TEST=Load an app/extension page that has "unlimited_storage" permission and verify that any write access is allowed. TEST=Disable or uninstall the app/extension and do the same. Verify that it throws QUOTA_EXCEEDED_ERR (22) for any write access. TEST=Launch chromium without --allow-file-from-files flag, load a local test page (with file:/// URI) and verify that it throws SECURITY_ERR (18) for requesetFileSystem. TEST=Launch chromium with --allow-file-from-files flag and do the same. Verify that requestFileSystem returns a valid filesystem and any write access is allowed. Review URL: http://codereview.chromium.org/3561016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61934 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_quota.h')
-rw-r--r--webkit/fileapi/file_system_quota.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_quota.h b/webkit/fileapi/file_system_quota.h
new file mode 100644
index 0000000..80888ed1
--- /dev/null
+++ b/webkit/fileapi/file_system_quota.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_
+#define WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "googleurl/src/gurl.h"
+
+namespace fileapi {
+
+// A quota manager for FileSystem. For now it has little implementation
+// and just allows unlimited quota for apps.
+class FileSystemQuota {
+ public:
+ FileSystemQuota() { }
+ static const int64 kUnknownSize;
+
+ // Checks if the origin can grow its usage by |growth| bytes.
+ // This only performs in-memory check and returns immediately.
+ // For now it just returns false for any origins (regardless of the size)
+ // that are not in the in-memory unlimited_quota_origins map.
+ bool CheckOriginQuota(const GURL& origin, int64 growth);
+
+ // Maintains origins in memory that are allowed to have unlimited quota.
+ void SetOriginQuotaUnlimited(const GURL& origin);
+ void ResetOriginQuotaUnlimited(const GURL& origin);
+ bool CheckIfOriginGrantedUnlimitedQuota(const GURL& origin);
+
+ private:
+ // For some extensions/apps we allow unlimited quota.
+ std::set<GURL> unlimited_quota_origins_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileSystemQuota);
+};
+
+} // namespace fileapi
+
+#endif // WEBKIT_FILEAPI_FILE_SYSTEM_QUOTA_H_