Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / storage / browser / quota / special_storage_policy.h
blob5c97806a0b8d0beb4cb9cb1ec6ca296ea41bd30d
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
3 // found in the LICENSE file.
5 #ifndef STORAGE_BROWSER_QUOTA_SPECIAL_STORAGE_POLICY_H_
6 #define STORAGE_BROWSER_QUOTA_SPECIAL_STORAGE_POLICY_H_
8 #include <string>
10 #include "base/memory/ref_counted.h"
11 #include "base/observer_list.h"
12 #include "storage/browser/storage_browser_export.h"
14 class GURL;
16 namespace storage {
18 // Special rights are granted to 'extensions' and 'applications'. The
19 // storage subsystems query this interface to determine which origins
20 // have these rights. Chrome provides an impl that is cognizant of what
21 // is currently installed in the extensions system.
22 // The IsSomething() methods must be thread-safe, however Observers should
23 // only be notified, added, and removed on the IO thead.
24 class STORAGE_EXPORT SpecialStoragePolicy
25 : public base::RefCountedThreadSafe<SpecialStoragePolicy> {
26 public:
27 typedef int StoragePolicy;
28 enum ChangeFlags {
29 STORAGE_PROTECTED = 1 << 0,
30 STORAGE_UNLIMITED = 1 << 1,
33 class STORAGE_EXPORT Observer {
34 public:
35 virtual void OnGranted(const GURL& origin, int change_flags) = 0;
36 virtual void OnRevoked(const GURL& origin, int change_flags) = 0;
37 virtual void OnCleared() = 0;
39 protected:
40 virtual ~Observer();
43 SpecialStoragePolicy();
45 // Protected storage is not subject to removal by the browsing data remover.
46 virtual bool IsStorageProtected(const GURL& origin) = 0;
48 // Unlimited storage is not subject to quota or storage pressure eviction.
49 virtual bool IsStorageUnlimited(const GURL& origin) = 0;
51 // Durable storage is not subject to storage pressure eviction.
52 virtual bool IsStorageDurable(const GURL& origin) = 0;
54 // Some origins (e.g. installed apps) have access to the size of the remaining
55 // disk capacity.
56 virtual bool CanQueryDiskSize(const GURL& origin) = 0;
58 // Checks if the origin contains per-site isolated storage.
59 virtual bool HasIsolatedStorage(const GURL& origin) = 0;
61 // Some origins are only allowed to store session-only data which is deleted
62 // when the session ends.
63 virtual bool IsStorageSessionOnly(const GURL& origin) = 0;
65 // Returns true if some origins are only allowed session-only storage.
66 virtual bool HasSessionOnlyOrigins() = 0;
68 // Adds/removes an observer, the policy does not take
69 // ownership of the observer. Should only be called on the IO thread.
70 void AddObserver(Observer* observer);
71 void RemoveObserver(Observer* observer);
73 protected:
74 friend class base::RefCountedThreadSafe<SpecialStoragePolicy>;
75 virtual ~SpecialStoragePolicy();
76 void NotifyGranted(const GURL& origin, int change_flags);
77 void NotifyRevoked(const GURL& origin, int change_flags);
78 void NotifyCleared();
80 base::ObserverList<Observer> observers_;
83 } // namespace storage
85 #endif // STORAGE_BROWSER_QUOTA_SPECIAL_STORAGE_POLICY_H_