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_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
6 #define CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/synchronization/waitable_event_watcher.h" | 13 #include "base/synchronization/waitable_event_watcher.h" |
14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
16 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" |
17 #include "chrome/common/features.h" | 17 #include "chrome/common/features.h" |
18 #include "components/browsing_data/core/browsing_data_utils.h" | 18 #include "components/browsing_data/core/browsing_data_utils.h" |
19 #include "components/offline_pages/core/offline_page_model.h" | 19 #include "components/offline_pages/core/offline_page_model.h" |
20 #include "components/search_engines/template_url_service.h" | 20 #include "components/search_engines/template_url_service.h" |
21 #include "extensions/features/features.h" | |
21 #include "media/media_features.h" | 22 #include "media/media_features.h" |
22 #include "ppapi/features/features.h" | 23 #include "ppapi/features/features.h" |
23 | 24 |
24 #if BUILDFLAG(ENABLE_PLUGINS) | 25 #if BUILDFLAG(ENABLE_PLUGINS) |
25 #include "chrome/browser/pepper_flash_settings_manager.h" | 26 #include "chrome/browser/pepper_flash_settings_manager.h" |
26 #endif | 27 #endif |
27 | 28 |
28 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
29 #include "chromeos/dbus/dbus_method_call_status.h" | 30 #include "chromeos/dbus/dbus_method_call_status.h" |
30 #endif | 31 #endif |
31 | 32 |
32 class BrowsingDataFlashLSOHelper; | 33 class BrowsingDataFlashLSOHelper; |
33 class Profile; | 34 class Profile; |
34 class WebappRegistry; | 35 class WebappRegistry; |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 class BrowserContext; | 38 class BrowserContext; |
38 class PluginDataRemover; | 39 class PluginDataRemover; |
39 } | 40 } |
40 | 41 |
41 // A delegate used by BrowsingDataRemover to delete data specific to Chrome | 42 // A delegate used by BrowsingDataRemover to delete data specific to Chrome |
42 // as the embedder. | 43 // as the embedder. |
43 class ChromeBrowsingDataRemoverDelegate : public BrowsingDataRemoverDelegate | 44 class ChromeBrowsingDataRemoverDelegate : public BrowsingDataRemoverDelegate |
44 #if BUILDFLAG(ENABLE_PLUGINS) | 45 #if BUILDFLAG(ENABLE_PLUGINS) |
45 , public PepperFlashSettingsManager::Client | 46 , public PepperFlashSettingsManager::Client |
46 #endif | 47 #endif |
47 { | 48 { |
48 public: | 49 public: |
50 // This is an extension of BrowsingDataRemover::RemoveDataMask which includes | |
51 // all datatypes therefrom and adds additional Chrome-specific ones. | |
52 // TODO(crbug.com/668114): Extend this to uint64_t to ensure that we won't | |
53 // run out of space anytime soon. | |
54 enum DataType { | |
55 // Inherited from BrowsingDataRemover. | |
56 DATA_TYPE_APP_CACHE = BrowsingDataRemover::DATA_TYPE_APP_CACHE, | |
jam
2017/03/10 16:13:42
why do you duplicate the list in content here? Now
| |
57 DATA_TYPE_FILE_SYSTEMS = BrowsingDataRemover::DATA_TYPE_FILE_SYSTEMS, | |
58 DATA_TYPE_INDEXED_DB = BrowsingDataRemover::DATA_TYPE_INDEXED_DB, | |
59 DATA_TYPE_LOCAL_STORAGE = BrowsingDataRemover::DATA_TYPE_LOCAL_STORAGE, | |
60 DATA_TYPE_WEB_SQL = BrowsingDataRemover::DATA_TYPE_WEB_SQL, | |
61 DATA_TYPE_SERVICE_WORKERS = BrowsingDataRemover::DATA_TYPE_SERVICE_WORKERS, | |
62 DATA_TYPE_CACHE_STORAGE = BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE, | |
63 DATA_TYPE_COOKIES = BrowsingDataRemover::DATA_TYPE_COOKIES, | |
64 DATA_TYPE_CHANNEL_IDS = BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS, | |
65 DATA_TYPE_CACHE = BrowsingDataRemover::DATA_TYPE_CACHE, | |
66 DATA_TYPE_DOWNLOADS = BrowsingDataRemover::DATA_TYPE_DOWNLOADS, | |
67 DATA_TYPE_MEDIA_LICENSES = BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES, | |
68 DATA_TYPE_NO_CHECKS = BrowsingDataRemover::DATA_TYPE_NO_CHECKS, | |
69 | |
70 // Embedder can start adding datatypes after the last platform datatype. | |
71 DATA_TYPE_EMBEDDER_BEGIN = BrowsingDataRemover::DATA_TYPE_CONTENT_END << 1, | |
72 | |
73 // Chrome-specific datatypes. | |
74 DATA_TYPE_HISTORY = DATA_TYPE_EMBEDDER_BEGIN, | |
75 DATA_TYPE_FORM_DATA = DATA_TYPE_EMBEDDER_BEGIN << 1, | |
76 DATA_TYPE_PASSWORDS = DATA_TYPE_EMBEDDER_BEGIN << 2, | |
77 DATA_TYPE_PLUGIN_DATA = DATA_TYPE_EMBEDDER_BEGIN << 3, | |
78 #if defined(OS_ANDROID) | |
79 DATA_TYPE_WEB_APP_DATA = DATA_TYPE_EMBEDDER_BEGIN << 4, | |
80 #endif | |
81 DATA_TYPE_SITE_USAGE_DATA = DATA_TYPE_EMBEDDER_BEGIN << 5, | |
82 DATA_TYPE_DURABLE_PERMISSION = DATA_TYPE_EMBEDDER_BEGIN << 6, | |
83 DATA_TYPE_EXTERNAL_PROTOCOL_DATA = DATA_TYPE_EMBEDDER_BEGIN << 7, | |
84 DATA_TYPE_HOSTED_APP_DATA_TEST_ONLY = DATA_TYPE_EMBEDDER_BEGIN << 8, | |
85 | |
86 // Group datatypes. | |
87 | |
88 // "Site data" includes storage backend accessible to websites and some | |
89 // additional metadata kept by the browser (e.g. site usage data). | |
90 DATA_TYPE_SITE_DATA = DATA_TYPE_APP_CACHE | | |
91 DATA_TYPE_COOKIES | | |
92 DATA_TYPE_FILE_SYSTEMS | | |
93 DATA_TYPE_INDEXED_DB | | |
94 DATA_TYPE_LOCAL_STORAGE | | |
95 DATA_TYPE_PLUGIN_DATA | | |
96 DATA_TYPE_SERVICE_WORKERS | | |
97 DATA_TYPE_CACHE_STORAGE | | |
98 DATA_TYPE_WEB_SQL | | |
99 DATA_TYPE_CHANNEL_IDS | | |
100 #if defined(OS_ANDROID) | |
101 DATA_TYPE_WEB_APP_DATA | | |
102 #endif | |
103 DATA_TYPE_SITE_USAGE_DATA | | |
104 DATA_TYPE_DURABLE_PERMISSION | | |
105 DATA_TYPE_EXTERNAL_PROTOCOL_DATA, | |
106 | |
107 // Datatypes protected by Important Sites. | |
108 IMPORTANT_SITES_DATA_TYPES = DATA_TYPE_SITE_DATA | DATA_TYPE_CACHE, | |
109 | |
110 // Datatypes that can be deleted partially per URL / origin / domain, | |
111 // whichever makes sense. | |
112 FILTERABLE_DATA_TYPES = DATA_TYPE_SITE_DATA | | |
113 DATA_TYPE_CACHE | | |
114 DATA_TYPE_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 ALL_DATA_TYPES = DATA_TYPE_SITE_DATA | | |
120 DATA_TYPE_CACHE | | |
121 DATA_TYPE_DOWNLOADS | | |
122 DATA_TYPE_FORM_DATA | | |
123 DATA_TYPE_HISTORY | | |
124 DATA_TYPE_PASSWORDS | | |
125 DATA_TYPE_MEDIA_LICENSES, | |
126 | |
127 // Includes all available remove options. Meant to be used when the Profile | |
128 // is scheduled to be deleted, and all possible data should be wiped from | |
129 // disk as soon as possible. | |
130 WIPE_PROFILE = ALL_DATA_TYPES | DATA_TYPE_NO_CHECKS, | |
131 }; | |
132 | |
133 // This is an extension of BrowsingDataRemover::OriginType which includes all | |
134 // origin types therefrom and adds additional Chrome-specific ones. | |
135 enum OriginType { | |
136 // Types inherited from BrowsingDataRemover::OriginType. | |
137 | |
138 // Origins not protected by a special storage policy; this is most of | |
139 // the web. | |
140 ORIGIN_TYPE_UNPROTECTED_WEB = | |
141 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, | |
142 | |
143 // Origins that are protected by a special storage policy; in Chrome's case, | |
144 // these are origins for which there is a hosted application installed. | |
145 ORIGIN_TYPE_PROTECTED_WEB = | |
146 BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, | |
147 | |
148 // Embedder can start adding origin types after the last | |
149 // platform origin type. | |
150 ORIGIN_TYPE_EMBEDDER_BEGIN = | |
151 BrowsingDataRemover::ORIGIN_TYPE_CONTENT_END << 1, | |
152 | |
153 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
154 // Packaged apps and extensions (chrome-extension://*). | |
155 ORIGIN_TYPE_EXTENSION = ORIGIN_TYPE_EMBEDDER_BEGIN, | |
156 #endif | |
157 | |
158 // All origin types. | |
159 ALL_ORIGIN_TYPES = ORIGIN_TYPE_UNPROTECTED_WEB | | |
160 #if BUILDFLAG(ENABLE_EXTENSIONS) | |
161 ORIGIN_TYPE_EXTENSION | | |
162 #endif | |
163 ORIGIN_TYPE_PROTECTED_WEB, | |
164 }; | |
165 | |
166 // Important sites protect a small set of sites from the deletion of certain | |
167 // datatypes. Therefore, those datatypes must be filterable by | |
168 // url/origin/domain. | |
169 static_assert(0 == (IMPORTANT_SITES_DATA_TYPES & ~FILTERABLE_DATA_TYPES), | |
Bernhard Bauer
2017/03/09 17:35:48
Nit: Can you flip the condition around so it reads
msramek
2017/03/13 17:57:33
Done.
| |
170 "All important sites datatypes must be filterable."); | |
171 | |
49 // Used to track the deletion of a single data storage backend. | 172 // Used to track the deletion of a single data storage backend. |
50 class SubTask { | 173 class SubTask { |
51 public: | 174 public: |
52 // Creates a SubTask that calls |forward_callback| when completed. | 175 // Creates a SubTask that calls |forward_callback| when completed. |
53 // |forward_callback| is only kept as a reference and must outlive SubTask. | 176 // |forward_callback| is only kept as a reference and must outlive SubTask. |
54 explicit SubTask(const base::Closure& forward_callback); | 177 explicit SubTask(const base::Closure& forward_callback); |
55 ~SubTask(); | 178 ~SubTask(); |
56 | 179 |
57 // Indicate that the task is in progress and we're waiting. | 180 // Indicate that the task is in progress and we're waiting. |
58 void Start(); | 181 void Start(); |
59 | 182 |
60 // Returns a callback that should be called to indicate that the task | 183 // Returns a callback that should be called to indicate that the task |
61 // has been finished. | 184 // has been finished. |
62 base::Closure GetCompletionCallback(); | 185 base::Closure GetCompletionCallback(); |
63 | 186 |
64 // Whether the task is still in progress. | 187 // Whether the task is still in progress. |
65 bool is_pending() const { return is_pending_; } | 188 bool is_pending() const { return is_pending_; } |
66 | 189 |
67 private: | 190 private: |
68 void CompletionCallback(); | 191 void CompletionCallback(); |
69 | 192 |
70 bool is_pending_; | 193 bool is_pending_; |
71 const base::Closure& forward_callback_; | 194 const base::Closure& forward_callback_; |
72 base::WeakPtrFactory<SubTask> weak_ptr_factory_; | 195 base::WeakPtrFactory<SubTask> weak_ptr_factory_; |
73 }; | 196 }; |
74 | 197 |
75 ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); | 198 ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); |
76 ~ChromeBrowsingDataRemoverDelegate() override; | 199 ~ChromeBrowsingDataRemoverDelegate() override; |
77 | 200 |
78 // Removes Chrome-specific data. | 201 // BrowsingDataRemoverDelegate: |
202 bool DoesOriginMatchEmbedderMask( | |
203 int origin_type_mask, | |
204 const GURL& origin, | |
205 storage::SpecialStoragePolicy* special_storage_policy) const override; | |
79 void RemoveEmbedderData( | 206 void RemoveEmbedderData( |
80 const base::Time& delete_begin, | 207 const base::Time& delete_begin, |
81 const base::Time& delete_end, | 208 const base::Time& delete_end, |
82 int remove_mask, | 209 int remove_mask, |
83 const content::BrowsingDataFilterBuilder& filter_builder, | 210 const content::BrowsingDataFilterBuilder& filter_builder, |
84 int origin_type_mask, | 211 int origin_type_mask, |
85 const base::Closure& callback) override; | 212 const base::Closure& callback) override; |
86 | 213 |
87 #if defined(OS_ANDROID) | 214 #if defined(OS_ANDROID) |
88 void OverrideWebappRegistryForTesting( | 215 void OverrideWebappRegistryForTesting( |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 // not initialised, so the registry must be mocked out. | 330 // not initialised, so the registry must be mocked out. |
204 std::unique_ptr<WebappRegistry> webapp_registry_; | 331 std::unique_ptr<WebappRegistry> webapp_registry_; |
205 #endif | 332 #endif |
206 | 333 |
207 base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; | 334 base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; |
208 | 335 |
209 DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); | 336 DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); |
210 }; | 337 }; |
211 | 338 |
212 #endif // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 339 #endif // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
OLD | NEW |