| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include "base/callback_forward.h" | 9 #include "base/callback_forward.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // } | 47 // } |
| 48 // } | 48 // } |
| 49 // | 49 // |
| 50 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 51 // | 51 // |
| 52 // TODO(crbug.com/668114): BrowsingDataRemover does not currently support plugin | 52 // TODO(crbug.com/668114): BrowsingDataRemover does not currently support plugin |
| 53 // data deletion. Use PluginDataRemover instead. | 53 // data deletion. Use PluginDataRemover instead. |
| 54 class BrowsingDataRemover : public KeyedService { | 54 class BrowsingDataRemover : public KeyedService { |
| 55 public: | 55 public: |
| 56 // Mask used for Remove. | 56 // Mask used for Remove. |
| 57 enum RemoveDataMask { | 57 enum DataType { |
| 58 REMOVE_APPCACHE = 1 << 0, | 58 // Storage datatypes. |
| 59 REMOVE_CACHE = 1 << 1, | 59 DATA_TYPE_APP_CACHE = 1 << 0, |
| 60 REMOVE_COOKIES = 1 << 2, | 60 DATA_TYPE_FILE_SYSTEMS = 1 << 1, |
| 61 REMOVE_DOWNLOADS = 1 << 3, | 61 DATA_TYPE_INDEXED_DB = 1 << 2, |
| 62 REMOVE_FILE_SYSTEMS = 1 << 4, | 62 DATA_TYPE_LOCAL_STORAGE = 1 << 3, |
| 63 REMOVE_FORM_DATA = 1 << 5, | 63 DATA_TYPE_WEB_SQL = 1 << 4, |
| 64 // In addition to visits, REMOVE_HISTORY removes keywords, last session and | 64 DATA_TYPE_SERVICE_WORKERS = 1 << 5, |
| 65 // passwords UI statistics. | 65 DATA_TYPE_CACHE_STORAGE = 1 << 6, |
| 66 REMOVE_HISTORY = 1 << 6, | 66 |
| 67 REMOVE_INDEXEDDB = 1 << 7, | 67 // Other datatypes. |
| 68 REMOVE_LOCAL_STORAGE = 1 << 8, | 68 DATA_TYPE_COOKIES = 1 << 7, |
| 69 REMOVE_PLUGIN_DATA = 1 << 9, | 69 DATA_TYPE_CHANNEL_IDS = 1 << 8, |
| 70 REMOVE_PASSWORDS = 1 << 10, | 70 DATA_TYPE_CACHE = 1 << 9, |
| 71 REMOVE_WEBSQL = 1 << 11, | 71 DATA_TYPE_DOWNLOADS = 1 << 10, |
| 72 REMOVE_CHANNEL_IDS = 1 << 12, | 72 DATA_TYPE_MEDIA_LICENSES = 1 << 11, |
| 73 REMOVE_MEDIA_LICENSES = 1 << 13, | 73 |
| 74 REMOVE_SERVICE_WORKERS = 1 << 14, | |
| 75 REMOVE_SITE_USAGE_DATA = 1 << 15, | |
| 76 // REMOVE_NOCHECKS intentionally does not check if the browser context is | 74 // REMOVE_NOCHECKS intentionally does not check if the browser context is |
| 77 // prohibited from deleting history or downloads. | 75 // prohibited from deleting history or downloads. |
| 78 REMOVE_NOCHECKS = 1 << 16, | 76 DATA_TYPE_NO_CHECKS = 1 << 12, |
| 79 REMOVE_CACHE_STORAGE = 1 << 17, | |
| 80 #if defined(OS_ANDROID) | |
| 81 REMOVE_WEBAPP_DATA = 1 << 18, | |
| 82 #endif | |
| 83 REMOVE_DURABLE_PERMISSION = 1 << 19, | |
| 84 REMOVE_EXTERNAL_PROTOCOL_DATA = 1 << 20, | |
| 85 | 77 |
| 86 // The following flag is used only in tests. In normal usage, hosted app | 78 // Embedders can add more datatypes beyond this point. |
| 87 // data is controlled by the REMOVE_COOKIES flag, applied to the | 79 DATA_TYPE_CONTENT_END = DATA_TYPE_NO_CHECKS, |
| 88 // protected-web origin. | |
| 89 REMOVE_HOSTED_APP_DATA_TESTONLY = 1 << 31, | |
| 90 | |
| 91 // "Site data" includes cookies, appcache, file systems, indexedDBs, local | |
| 92 // storage, webSQL, service workers, cache storage, plugin data, web app | |
| 93 // data (on Android) and statistics about passwords. | |
| 94 REMOVE_SITE_DATA = REMOVE_APPCACHE | REMOVE_COOKIES | REMOVE_FILE_SYSTEMS | | |
| 95 REMOVE_INDEXEDDB | | |
| 96 REMOVE_LOCAL_STORAGE | | |
| 97 REMOVE_PLUGIN_DATA | | |
| 98 REMOVE_SERVICE_WORKERS | | |
| 99 REMOVE_CACHE_STORAGE | | |
| 100 REMOVE_WEBSQL | | |
| 101 REMOVE_CHANNEL_IDS | | |
| 102 #if defined(OS_ANDROID) | |
| 103 REMOVE_WEBAPP_DATA | | |
| 104 #endif | |
| 105 REMOVE_SITE_USAGE_DATA | | |
| 106 REMOVE_DURABLE_PERMISSION | | |
| 107 REMOVE_EXTERNAL_PROTOCOL_DATA, | |
| 108 | |
| 109 // Datatypes protected by Important Sites. | |
| 110 IMPORTANT_SITES_DATATYPES = REMOVE_SITE_DATA | REMOVE_CACHE, | |
| 111 | |
| 112 // Datatypes that can be deleted partially per URL / origin / domain, | |
| 113 // whichever makes sense. | |
| 114 FILTERABLE_DATATYPES = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS, | |
| 115 | |
| 116 // Includes all the available remove options. Meant to be used by clients | |
| 117 // that wish to wipe as much data as possible from a Profile, to make it | |
| 118 // look like a new Profile. | |
| 119 REMOVE_ALL = REMOVE_SITE_DATA | REMOVE_CACHE | REMOVE_DOWNLOADS | | |
| 120 REMOVE_FORM_DATA | | |
| 121 REMOVE_HISTORY | | |
| 122 REMOVE_PASSWORDS | | |
| 123 REMOVE_MEDIA_LICENSES, | |
| 124 | |
| 125 // Includes all available remove options. Meant to be used when the Profile | |
| 126 // is scheduled to be deleted, and all possible data should be wiped from | |
| 127 // disk as soon as possible. | |
| 128 REMOVE_WIPE_PROFILE = REMOVE_ALL | REMOVE_NOCHECKS, | |
| 129 }; | 80 }; |
| 130 | 81 |
| 131 // Important sites protect a small set of sites from the deletion of certain | 82 enum OriginType { |
| 132 // datatypes. Therefore, those datatypes must be filterable by | 83 // Web storage origins that StoragePartition recognizes as NOT protected |
| 133 // url/origin/domain. | 84 // according to its special storage policy. |
| 134 static_assert(0 == (IMPORTANT_SITES_DATATYPES & ~FILTERABLE_DATATYPES), | 85 ORIGIN_TYPE_UNPROTECTED_WEB = 1 << 0, |
| 135 "All important sites datatypes must be filterable."); | 86 |
| 87 // Web storage origins that StoragePartition recognizes as protected |
| 88 // according to its special storage policy. |
| 89 ORIGIN_TYPE_PROTECTED_WEB = 1 << 1, |
| 90 |
| 91 // Embedders can add more origin types beyond this point. |
| 92 ORIGIN_TYPE_CONTENT_END = ORIGIN_TYPE_PROTECTED_WEB, |
| 93 }; |
| 136 | 94 |
| 137 // A helper enum to report the deletion of cookies and/or cache. Do not | 95 // A helper enum to report the deletion of cookies and/or cache. Do not |
| 138 // reorder the entries, as this enum is passed to UMA. | 96 // reorder the entries, as this enum is passed to UMA. |
| 139 enum CookieOrCacheDeletionChoice { | 97 enum CookieOrCacheDeletionChoice { |
| 140 NEITHER_COOKIES_NOR_CACHE, | 98 NEITHER_COOKIES_NOR_CACHE, |
| 141 ONLY_COOKIES, | 99 ONLY_COOKIES, |
| 142 ONLY_CACHE, | 100 ONLY_CACHE, |
| 143 BOTH_COOKIES_AND_CACHE, | 101 BOTH_COOKIES_AND_CACHE, |
| 144 MAX_CHOICE_VALUE | 102 MAX_CHOICE_VALUE |
| 145 }; | 103 }; |
| 146 | 104 |
| 147 // Observer is notified when its own removal task is done. | 105 // Observer is notified when its own removal task is done. |
| 148 class Observer { | 106 class Observer { |
| 149 public: | 107 public: |
| 150 // Called when a removal task is finished. Note that every removal task can | 108 // Called when a removal task is finished. Note that every removal task can |
| 151 // only have one observer attached to it, and only that one is called. | 109 // only have one observer attached to it, and only that one is called. |
| 152 virtual void OnBrowsingDataRemoverDone() = 0; | 110 virtual void OnBrowsingDataRemoverDone() = 0; |
| 153 | 111 |
| 154 protected: | 112 protected: |
| 155 virtual ~Observer() {} | 113 virtual ~Observer() {} |
| 156 }; | 114 }; |
| 157 | 115 |
| 158 // Called by the embedder to provide the delegate that will take care of | 116 // Called by the embedder to provide the delegate that will take care of |
| 159 // deleting embedder-specific data. | 117 // deleting embedder-specific data. |
| 160 virtual void SetEmbedderDelegate( | 118 virtual void SetEmbedderDelegate( |
| 161 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) = 0; | 119 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) = 0; |
| 162 virtual BrowsingDataRemoverDelegate* GetEmbedderDelegate() const = 0; | 120 virtual BrowsingDataRemoverDelegate* GetEmbedderDelegate() const = 0; |
| 163 | 121 |
| 122 // Determines whether |origin| matches the |origin_type_mask| according to |
| 123 // the |special_storage_policy|. |
| 124 virtual bool DoesOriginMatchMask( |
| 125 int origin_type_mask, |
| 126 const GURL& origin, |
| 127 storage::SpecialStoragePolicy* special_storage_policy) const = 0; |
| 128 |
| 164 // Removes browsing data within the given |time_range|, with datatypes being | 129 // Removes browsing data within the given |time_range|, with datatypes being |
| 165 // specified by |remove_mask| and origin types by |origin_type_mask|. | 130 // specified by |remove_mask| and origin types by |origin_type_mask|. |
| 166 virtual void Remove(const base::Time& delete_begin, | 131 virtual void Remove(const base::Time& delete_begin, |
| 167 const base::Time& delete_end, | 132 const base::Time& delete_end, |
| 168 int remove_mask, | 133 int remove_mask, |
| 169 int origin_type_mask) = 0; | 134 int origin_type_mask) = 0; |
| 170 | 135 |
| 171 // A version of the above that in addition informs the |observer| when the | 136 // A version of the above that in addition informs the |observer| when the |
| 172 // removal task is finished. | 137 // removal task is finished. |
| 173 virtual void RemoveAndReply(const base::Time& delete_begin, | 138 virtual void RemoveAndReply(const base::Time& delete_begin, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // consider returning them in OnBrowsingDataRemoverDone() callback. If not, | 171 // consider returning them in OnBrowsingDataRemoverDone() callback. If not, |
| 207 // consider simplifying this interface by removing these methods and changing | 172 // consider simplifying this interface by removing these methods and changing |
| 208 // the tests to record the parameters using GMock instead. | 173 // the tests to record the parameters using GMock instead. |
| 209 virtual const base::Time& GetLastUsedBeginTime() = 0; | 174 virtual const base::Time& GetLastUsedBeginTime() = 0; |
| 210 virtual const base::Time& GetLastUsedEndTime() = 0; | 175 virtual const base::Time& GetLastUsedEndTime() = 0; |
| 211 virtual int GetLastUsedRemovalMask() = 0; | 176 virtual int GetLastUsedRemovalMask() = 0; |
| 212 virtual int GetLastUsedOriginTypeMask() = 0; | 177 virtual int GetLastUsedOriginTypeMask() = 0; |
| 213 }; | 178 }; |
| 214 | 179 |
| 215 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ | 180 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_REMOVER_H_ |
| OLD | NEW |