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_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 5 #ifndef WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 6 #define WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/file_path.h" | 13 #include "base/file_path.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 | 15 |
16 class Extension; | |
17 | |
18 namespace chromeos { | 16 namespace chromeos { |
19 | 17 |
20 class FileAccessPermissions { | 18 class FileAccessPermissions { |
21 public: | 19 public: |
22 FileAccessPermissions(); | 20 FileAccessPermissions(); |
23 virtual ~FileAccessPermissions(); | 21 virtual ~FileAccessPermissions(); |
24 | 22 |
25 // Grants |extension_id| access to |path|. | 23 // Grants |extension_id| access to |path|. |
26 void GrantAccessPermission(const std::string& extension_id, | 24 void GrantAccessPermission(const std::string& extension_id, |
27 const FilePath& path); | 25 const FilePath& path); |
28 // Checks id |extension_id| has permission to access to |path|. | 26 // Checks id |extension_id| has permission to access to |path|. |
29 bool HasAccessPermission(const std::string& extension_id, | 27 bool HasAccessPermission(const std::string& extension_id, |
30 const FilePath& path); | 28 const FilePath& path); |
31 // Revokes all file permissions for |extension_id|. | 29 // Revokes all file permissions for |extension_id|. |
32 void RevokePermissions(const std::string& extension_id); | 30 void RevokePermissions(const std::string& extension_id); |
33 | 31 |
34 private: | 32 private: |
35 typedef std::set<FilePath> PathSet; | 33 typedef std::set<FilePath> PathSet; |
36 typedef std::map<std::string, PathSet> PathAccessMap; | 34 typedef std::map<std::string, PathSet> PathAccessMap; |
37 | 35 |
38 base::Lock lock_; // Synchronize all access to path_map_. | 36 base::Lock lock_; // Synchronize all access to path_map_. |
39 PathAccessMap path_map_; | 37 PathAccessMap path_map_; |
40 }; | 38 }; |
41 | 39 |
42 }; | 40 } // namespace chromeos |
43 | 41 |
44 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ | 42 #endif // WEBKIT_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ |
OLD | NEW |