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

Side by Side Diff: chrome/browser/extensions/extension_special_storage_policy.h

Issue 6810037: File API changes needed for safely passing user selected file entities from the file browser comp... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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 (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 CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set>
10 #include <string> 11 #include <string>
11 12
13 #include "base/file_path.h"
12 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
13 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
14 #include "webkit/quota/special_storage_policy.h" 16 #include "webkit/quota/special_storage_policy.h"
15 17
16 class Extension; 18 class Extension;
17 19
18 // Special rights are granted to 'extensions' and 'applications'. The 20 // Special rights are granted to 'extensions' and 'applications'. The
19 // storage subsystems and the browsing data remover query this interface 21 // storage subsystems and the browsing data remover query this interface
20 // to determine which origins have these rights. 22 // to determine which origins have these rights.
21 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy { 23 class ExtensionSpecialStoragePolicy : public quota::SpecialStoragePolicy {
22 public: 24 public:
23 ExtensionSpecialStoragePolicy(); 25 ExtensionSpecialStoragePolicy();
24 26
25 // SpecialStoragePolicy methods used by storage subsystems and the browsing 27 // SpecialStoragePolicy methods used by storage subsystems and the browsing
26 // data remover. These methods are safe to call on any thread. 28 // data remover. These methods are safe to call on any thread.
27 virtual bool IsStorageProtected(const GURL& origin); 29 virtual bool IsStorageProtected(const GURL& origin);
28 virtual bool IsStorageUnlimited(const GURL& origin); 30 virtual bool IsStorageUnlimited(const GURL& origin);
29 virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin); 31 virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin,
32 const FilePath& virtual_path);
33 virtual void GrantLocalFileSystemAccess(const GURL& origin,
ericu 2011/04/13 20:12:46 Just looked at this again, and it doesn't look rig
zel 2011/04/13 20:38:55 The only reason I went with virtual part of the fi
ericu 2011/04/13 22:51:27 While I put the comment here, it's more of a big d
34 const FilePath& virtual_path);
30 35
31 // Methods used by the ExtensionService to populate this class. 36 // Methods used by the ExtensionService to populate this class.
32 void GrantRightsForExtension(const Extension* extension); 37 void GrantRightsForExtension(const Extension* extension);
33 void RevokeRightsForExtension(const Extension* extension); 38 void RevokeRightsForExtension(const Extension* extension);
34 void RevokeRightsForAllExtensions(); 39 void RevokeRightsForAllExtensions();
35 40
36 private: 41 private:
37 class SpecialCollection { 42 class SpecialCollection {
38 public: 43 public:
39 SpecialCollection(); 44 SpecialCollection();
40 ~SpecialCollection(); 45 virtual ~SpecialCollection();
41 46
42 bool Contains(const GURL& origin); 47 bool Contains(const GURL& origin);
43 void Add(const Extension* extension); 48 void Add(const Extension* extension);
44 void Remove(const Extension* extension); 49 virtual void Remove(const Extension* extension);
45 void Clear(); 50 virtual void Clear();
46 51
47 private: 52 protected:
48 typedef std::map<GURL, bool> CachedResults; 53 typedef std::map<GURL, bool> CachedResults;
49 typedef std::map<std::string, scoped_refptr<const Extension> > Extensions; 54 typedef std::map<std::string, scoped_refptr<const Extension> > Extensions;
50 Extensions extensions_; 55 Extensions extensions_;
51 CachedResults cached_resuts_; 56 CachedResults cached_results_;
57 };
58
59 class SpecialPathCollection : public SpecialCollection {
60 public:
61 SpecialPathCollection();
62 virtual ~SpecialPathCollection();
63
64 // SpecialCollection overrides.
65 virtual void Remove(const Extension* extension);
66 virtual void Clear();
67
68 void AddPath(const GURL& origin, const FilePath& path);
69 bool ContainsPath(const GURL& origin, const FilePath& path);
70
71 private:
72 typedef std::set<FilePath> PathSet;
73 typedef std::map<const Extension*, PathSet> PathAccessMap;
74 scoped_refptr<const Extension> GetExtension(const GURL& origin);
75 PathAccessMap path_map_;
52 }; 76 };
53 77
54 virtual ~ExtensionSpecialStoragePolicy(); 78 virtual ~ExtensionSpecialStoragePolicy();
55 79
56 base::Lock lock_; // Synchronize all access to the collections. 80 base::Lock lock_; // Synchronize all access to the collections.
57 SpecialCollection protected_apps_; 81 SpecialCollection protected_apps_;
58 SpecialCollection unlimited_extensions_; 82 SpecialCollection unlimited_extensions_;
59 SpecialCollection local_filesystem_extensions_; 83 SpecialPathCollection local_filesystem_extensions_;
60 }; 84 };
61 85
62 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_ 86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SPECIAL_STORAGE_POLICY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698