Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/chromeos/fileapi/file_access_permissions.h

Issue 148233008: Grant Files.app access for mount points added after its launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_
6 #define CHROME_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/basictypes.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "webkit/browser/webkit_storage_browser_export.h"
16 15
17 namespace chromeos { 16 namespace chromeos {
18 17
18 // In a thread safe manner maintains the set of paths allowed to access for
19 // each extension.
19 class FileAccessPermissions { 20 class FileAccessPermissions {
20 public: 21 public:
21 FileAccessPermissions(); 22 FileAccessPermissions();
22 virtual ~FileAccessPermissions(); 23 virtual ~FileAccessPermissions();
23 24
25 // Grants |extension_id| full access to all paths.
26 void GrantFullAccessPermission(const std::string& extension_id);
24 // Grants |extension_id| access to |path|. 27 // Grants |extension_id| access to |path|.
25 void GrantAccessPermission(const std::string& extension_id, 28 void GrantAccessPermission(const std::string& extension_id,
26 const base::FilePath& path); 29 const base::FilePath& path);
27 // Checks id |extension_id| has permission to access to |path|. 30 // Checks id |extension_id| has permission to access to |path|.
28 bool HasAccessPermission(const std::string& extension_id, 31 bool HasAccessPermission(const std::string& extension_id,
29 const base::FilePath& path) const; 32 const base::FilePath& path) const;
30 // Revokes all file permissions for |extension_id|. 33 // Revokes all file permissions for |extension_id|.
31 void RevokePermissions(const std::string& extension_id); 34 void RevokePermissions(const std::string& extension_id);
32 35
33 private: 36 private:
34 typedef std::set<base::FilePath> PathSet; 37 typedef std::set<base::FilePath> PathSet;
35 typedef std::map<std::string, PathSet> PathAccessMap; 38 typedef std::map<std::string, PathSet> PathAccessMap;
36 39
37 mutable base::Lock lock_; // Synchronize all access to path_map_. 40 mutable base::Lock lock_; // Synchronize all access to path_map_.
38 PathAccessMap path_map_; 41 PathAccessMap path_map_;
39 42
40 DISALLOW_COPY_AND_ASSIGN(FileAccessPermissions); 43 DISALLOW_COPY_AND_ASSIGN(FileAccessPermissions);
41 }; 44 };
42 45
43 } // namespace chromeos 46 } // namespace chromeos
44 47
45 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_ 48 #endif // CHROME_BROWSER_CHROMEOS_FILEAPI_FILE_ACCESS_PERMISSIONS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698