| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
| 6 #define WEBKIT_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 14 #include "webkit/browser/webkit_storage_browser_export.h" | 15 #include "webkit/browser/webkit_storage_browser_export.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 class WEBKIT_STORAGE_BROWSER_EXPORT FileAccessPermissions { | 19 class FileAccessPermissions { |
| 19 public: | 20 public: |
| 20 FileAccessPermissions(); | 21 FileAccessPermissions(); |
| 21 virtual ~FileAccessPermissions(); | 22 virtual ~FileAccessPermissions(); |
| 22 | 23 |
| 23 // Grants |extension_id| access to |path|. | 24 // Grants |extension_id| access to |path|. |
| 24 void GrantAccessPermission(const std::string& extension_id, | 25 void GrantAccessPermission(const std::string& extension_id, |
| 25 const base::FilePath& path); | 26 const base::FilePath& path); |
| 26 // Checks id |extension_id| has permission to access to |path|. | 27 // Checks id |extension_id| has permission to access to |path|. |
| 27 bool HasAccessPermission(const std::string& extension_id, | 28 bool HasAccessPermission(const std::string& extension_id, |
| 28 const base::FilePath& path) const; | 29 const base::FilePath& path) const; |
| 29 // Revokes all file permissions for |extension_id|. | 30 // Revokes all file permissions for |extension_id|. |
| 30 void RevokePermissions(const std::string& extension_id); | 31 void RevokePermissions(const std::string& extension_id); |
| 31 | 32 |
| 32 private: | 33 private: |
| 33 typedef std::set<base::FilePath> PathSet; | 34 typedef std::set<base::FilePath> PathSet; |
| 34 typedef std::map<std::string, PathSet> PathAccessMap; | 35 typedef std::map<std::string, PathSet> PathAccessMap; |
| 35 | 36 |
| 36 mutable base::Lock lock_; // Synchronize all access to path_map_. | 37 mutable base::Lock lock_; // Synchronize all access to path_map_. |
| 37 PathAccessMap path_map_; | 38 PathAccessMap path_map_; |
| 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(FileAccessPermissions); |
| 38 }; | 41 }; |
| 39 | 42 |
| 40 } // namespace chromeos | 43 } // namespace chromeos |
| 41 | 44 |
| 42 #endif // WEBKIT_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 45 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
| OLD | NEW |