OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "chrome/browser/browsing_data/browsing_data_helper.h" | |
19 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" |
20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
22 #include "components/browsing_data/content/storage_partition_http_cache_data_rem over.h" | 21 #include "components/browsing_data/content/storage_partition_http_cache_data_rem over.h" |
23 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
24 #include "components/web_cache/browser/web_cache_manager.h" | 23 #include "components/web_cache/browser/web_cache_manager.h" |
25 #include "content/public/browser/browser_context.h" | 24 #include "content/public/browser/browser_context.h" |
26 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/browsing_data_filter_builder.h" | 26 #include "content/public/browser/browsing_data_filter_builder.h" |
28 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
56 callback.Run(); | 55 callback.Run(); |
57 } | 56 } |
58 | 57 |
59 // Another convenience method to turn a callback without arguments into one that | 58 // Another convenience method to turn a callback without arguments into one that |
60 // accepts (and ignores) a single argument. | 59 // accepts (and ignores) a single argument. |
61 template <typename T> | 60 template <typename T> |
62 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { | 61 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { |
63 return base::Bind(&IgnoreArgumentHelper<T>, callback); | 62 return base::Bind(&IgnoreArgumentHelper<T>, callback); |
64 } | 63 } |
65 | 64 |
66 // Helper to create callback for BrowsingDataRemoverImpl::DoesOriginMatchMask. | |
67 bool DoesOriginMatchMaskAndUrls( | 65 bool DoesOriginMatchMaskAndUrls( |
66 const base::WeakPtr<BrowsingDataRemoverImpl>& remover_weak_ptr, | |
68 int origin_type_mask, | 67 int origin_type_mask, |
69 const base::Callback<bool(const GURL&)>& predicate, | 68 const base::Callback<bool(const GURL&)>& predicate, |
70 const GURL& origin, | 69 const GURL& origin, |
71 storage::SpecialStoragePolicy* special_storage_policy) { | 70 storage::SpecialStoragePolicy* special_storage_policy) { |
72 return predicate.Run(origin) && | 71 // We only consider origins matched by the |predicate|. |
73 BrowsingDataHelper::DoesOriginMatchMask(origin, origin_type_mask, | 72 if (!predicate.Run(origin)) |
74 special_storage_policy); | 73 return false; |
74 | |
75 if (remover_weak_ptr) { | |
76 return remover_weak_ptr->DoesOriginMatchMask( | |
77 origin_type_mask, origin, special_storage_policy); | |
78 } | |
79 | |
80 // If BrowsingDataRemoverImpl is null, it is not possible to determine which | |
Bernhard Bauer
2017/03/09 17:35:48
Nit: I would maybe move this first and return in t
msramek
2017/03/13 17:57:33
Done.
| |
81 // origins should have their data deleted, and so we do not delete | |
82 // anything. This is not a problem, because this can only happen shortly | |
83 // before shutdown and thus the deletion would likely not be able to | |
84 // finish anyway. | |
85 return false; | |
75 } | 86 } |
76 | 87 |
77 void ClearHttpAuthCacheOnIOThread( | 88 void ClearHttpAuthCacheOnIOThread( |
78 scoped_refptr<net::URLRequestContextGetter> context_getter, | 89 scoped_refptr<net::URLRequestContextGetter> context_getter, |
79 base::Time delete_begin) { | 90 base::Time delete_begin) { |
80 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 91 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
81 | 92 |
82 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() | 93 net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext() |
83 ->http_transaction_factory() | 94 ->http_transaction_factory() |
84 ->GetSession(); | 95 ->GetSession(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 void BrowsingDataRemoverImpl::SetEmbedderDelegate( | 208 void BrowsingDataRemoverImpl::SetEmbedderDelegate( |
198 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) { | 209 std::unique_ptr<BrowsingDataRemoverDelegate> embedder_delegate) { |
199 embedder_delegate_ = std::move(embedder_delegate); | 210 embedder_delegate_ = std::move(embedder_delegate); |
200 } | 211 } |
201 | 212 |
202 BrowsingDataRemoverDelegate* | 213 BrowsingDataRemoverDelegate* |
203 BrowsingDataRemoverImpl::GetEmbedderDelegate() const { | 214 BrowsingDataRemoverImpl::GetEmbedderDelegate() const { |
204 return embedder_delegate_.get(); | 215 return embedder_delegate_.get(); |
205 } | 216 } |
206 | 217 |
218 bool BrowsingDataRemoverImpl::DoesOriginMatchMask( | |
219 int origin_type_mask, | |
220 const GURL& origin, | |
221 storage::SpecialStoragePolicy* policy) const { | |
222 const std::vector<std::string>& schemes = url::GetWebStorageSchemes(); | |
223 bool is_web_scheme = | |
224 (std::find(schemes.begin(), schemes.end(), origin.GetOrigin().scheme()) != | |
225 schemes.end()); | |
226 | |
227 // If a websafe origin is unprotected, it matches iff UNPROTECTED_WEB. | |
228 if ((!policy || !policy->IsStorageProtected(origin.GetOrigin())) && | |
229 is_web_scheme && (origin_type_mask & ORIGIN_TYPE_UNPROTECTED_WEB)) { | |
230 return true; | |
231 } | |
232 origin_type_mask &= ~ORIGIN_TYPE_UNPROTECTED_WEB; | |
233 | |
234 // Hosted applications (protected and websafe origins) iff PROTECTED_WEB. | |
235 if (policy && policy->IsStorageProtected(origin.GetOrigin()) && | |
236 is_web_scheme && (origin_type_mask & ORIGIN_TYPE_PROTECTED_WEB)) { | |
237 return true; | |
238 } | |
239 origin_type_mask &= ~ORIGIN_TYPE_PROTECTED_WEB; | |
240 | |
241 DCHECK(embedder_delegate_ || !origin_type_mask) | |
242 << "The mask contains embedder-defined origin types, but there is no " | |
243 << "embedder delegate to process them."; | |
244 | |
245 if (embedder_delegate_) { | |
246 return embedder_delegate_->DoesOriginMatchEmbedderMask( | |
247 origin_type_mask, origin, policy); | |
248 } | |
249 | |
250 return false; | |
251 } | |
252 | |
207 void BrowsingDataRemoverImpl::Remove(const base::Time& delete_begin, | 253 void BrowsingDataRemoverImpl::Remove(const base::Time& delete_begin, |
208 const base::Time& delete_end, | 254 const base::Time& delete_end, |
209 int remove_mask, | 255 int remove_mask, |
210 int origin_type_mask) { | 256 int origin_type_mask) { |
211 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, | 257 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, |
212 std::unique_ptr<BrowsingDataFilterBuilder>(), nullptr); | 258 std::unique_ptr<BrowsingDataFilterBuilder>(), nullptr); |
213 } | 259 } |
214 | 260 |
215 void BrowsingDataRemoverImpl::RemoveAndReply( | 261 void BrowsingDataRemoverImpl::RemoveAndReply( |
216 const base::Time& delete_begin, | 262 const base::Time& delete_begin, |
217 const base::Time& delete_end, | 263 const base::Time& delete_end, |
218 int remove_mask, | 264 int remove_mask, |
219 int origin_type_mask, | 265 int origin_type_mask, |
220 Observer* observer) { | 266 Observer* observer) { |
221 DCHECK(observer); | 267 DCHECK(observer); |
222 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, | 268 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, |
223 std::unique_ptr<BrowsingDataFilterBuilder>(), observer); | 269 std::unique_ptr<BrowsingDataFilterBuilder>(), observer); |
224 } | 270 } |
225 | 271 |
226 void BrowsingDataRemoverImpl::RemoveWithFilter( | 272 void BrowsingDataRemoverImpl::RemoveWithFilter( |
227 const base::Time& delete_begin, | 273 const base::Time& delete_begin, |
228 const base::Time& delete_end, | 274 const base::Time& delete_end, |
229 int remove_mask, | 275 int remove_mask, |
230 int origin_type_mask, | 276 int origin_type_mask, |
231 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { | 277 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { |
232 DCHECK_EQ(0, remove_mask & ~FILTERABLE_DATATYPES); | |
233 DCHECK(filter_builder); | 278 DCHECK(filter_builder); |
234 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, | 279 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, |
235 std::move(filter_builder), nullptr); | 280 std::move(filter_builder), nullptr); |
236 } | 281 } |
237 | 282 |
238 void BrowsingDataRemoverImpl::RemoveWithFilterAndReply( | 283 void BrowsingDataRemoverImpl::RemoveWithFilterAndReply( |
239 const base::Time& delete_begin, | 284 const base::Time& delete_begin, |
240 const base::Time& delete_end, | 285 const base::Time& delete_end, |
241 int remove_mask, | 286 int remove_mask, |
242 int origin_type_mask, | 287 int origin_type_mask, |
243 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, | 288 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder, |
244 Observer* observer) { | 289 Observer* observer) { |
245 DCHECK_EQ(0, remove_mask & ~FILTERABLE_DATATYPES); | |
246 DCHECK(filter_builder); | 290 DCHECK(filter_builder); |
247 DCHECK(observer); | 291 DCHECK(observer); |
248 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, | 292 RemoveInternal(delete_begin, delete_end, remove_mask, origin_type_mask, |
249 std::move(filter_builder), observer); | 293 std::move(filter_builder), observer); |
250 } | 294 } |
251 | 295 |
252 void BrowsingDataRemoverImpl::RemoveInternal( | 296 void BrowsingDataRemoverImpl::RemoveInternal( |
253 const base::Time& delete_begin, | 297 const base::Time& delete_begin, |
254 const base::Time& delete_end, | 298 const base::Time& delete_end, |
255 int remove_mask, | 299 int remove_mask, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
316 | 360 |
317 // crbug.com/140910: Many places were calling this with base::Time() as | 361 // crbug.com/140910: Many places were calling this with base::Time() as |
318 // delete_end, even though they should've used base::Time::Max(). | 362 // delete_end, even though they should've used base::Time::Max(). |
319 DCHECK_NE(base::Time(), delete_end); | 363 DCHECK_NE(base::Time(), delete_end); |
320 | 364 |
321 delete_begin_ = delete_begin; | 365 delete_begin_ = delete_begin; |
322 delete_end_ = delete_end; | 366 delete_end_ = delete_end; |
323 remove_mask_ = remove_mask; | 367 remove_mask_ = remove_mask; |
324 origin_type_mask_ = origin_type_mask; | 368 origin_type_mask_ = origin_type_mask; |
325 | 369 |
326 if (origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | |
327 content::RecordAction( | |
328 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb")); | |
329 } | |
330 if (origin_type_mask_ & BrowsingDataHelper::PROTECTED_WEB) { | |
331 content::RecordAction( | |
332 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb")); | |
333 } | |
334 if (origin_type_mask_ & BrowsingDataHelper::EXTENSION) { | |
335 content::RecordAction( | |
336 UserMetricsAction("ClearBrowsingData_MaskContainsExtension")); | |
337 } | |
338 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without | |
339 // updating the user metrics above. | |
340 static_assert( | |
341 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | | |
342 BrowsingDataHelper::PROTECTED_WEB | | |
343 BrowsingDataHelper::EXTENSION), | |
344 "OriginTypeMask has been updated without updating user metrics"); | |
345 | |
346 // Record the combined deletion of cookies and cache. | 370 // Record the combined deletion of cookies and cache. |
347 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; | 371 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; |
348 if (remove_mask & REMOVE_COOKIES && | 372 if (remove_mask & DATA_TYPE_COOKIES && |
349 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 373 origin_type_mask_ & ORIGIN_TYPE_UNPROTECTED_WEB) { |
350 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE | 374 choice = remove_mask & DATA_TYPE_CACHE ? BOTH_COOKIES_AND_CACHE |
351 : ONLY_COOKIES; | 375 : ONLY_COOKIES; |
352 } else if (remove_mask & REMOVE_CACHE) { | 376 } else if (remove_mask & DATA_TYPE_CACHE) { |
353 choice = ONLY_CACHE; | 377 choice = ONLY_CACHE; |
354 } | 378 } |
355 | 379 |
356 UMA_HISTOGRAM_ENUMERATION( | 380 UMA_HISTOGRAM_ENUMERATION( |
357 "History.ClearBrowsingData.UserDeletedCookieOrCache", | 381 "History.ClearBrowsingData.UserDeletedCookieOrCache", |
358 choice, MAX_CHOICE_VALUE); | 382 choice, MAX_CHOICE_VALUE); |
359 | 383 |
360 // Managed devices and supervised users can have restrictions on history | 384 // Managed devices and supervised users can have restrictions on history |
361 // deletion. | 385 // deletion. |
362 // TODO(crbug.com/668114): This should be provided via ContentBrowserClient | 386 // TODO(crbug.com/668114): This should be provided via ContentBrowserClient |
363 // once BrowsingDataRemoverImpl moves to content. | 387 // once BrowsingDataRemoverImpl moves to content. |
364 PrefService* prefs = | 388 PrefService* prefs = |
365 Profile::FromBrowserContext(browser_context_)->GetPrefs(); | 389 Profile::FromBrowserContext(browser_context_)->GetPrefs(); |
366 bool may_delete_history = | 390 bool may_delete_history = |
367 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); | 391 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory); |
368 | 392 |
369 ////////////////////////////////////////////////////////////////////////////// | 393 ////////////////////////////////////////////////////////////////////////////// |
370 // INITIALIZATION | 394 // INITIALIZATION |
371 base::Callback<bool(const GURL& url)> filter = | 395 base::Callback<bool(const GURL& url)> filter = |
372 filter_builder.BuildGeneralFilter(); | 396 filter_builder.BuildGeneralFilter(); |
373 | 397 |
374 ////////////////////////////////////////////////////////////////////////////// | 398 ////////////////////////////////////////////////////////////////////////////// |
375 // REMOVE_DOWNLOADS | 399 // DATA_TYPE_DOWNLOADS |
376 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) { | 400 if ((remove_mask & DATA_TYPE_DOWNLOADS) && may_delete_history) { |
377 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); | 401 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads")); |
378 content::DownloadManager* download_manager = | 402 content::DownloadManager* download_manager = |
379 BrowserContext::GetDownloadManager(browser_context_); | 403 BrowserContext::GetDownloadManager(browser_context_); |
380 download_manager->RemoveDownloadsByURLAndTime(filter, | 404 download_manager->RemoveDownloadsByURLAndTime(filter, |
381 delete_begin_, delete_end_); | 405 delete_begin_, delete_end_); |
382 } | 406 } |
383 | 407 |
384 ////////////////////////////////////////////////////////////////////////////// | 408 ////////////////////////////////////////////////////////////////////////////// |
385 // REMOVE_CHANNEL_IDS | 409 // DATA_TYPE_CHANNEL_IDS |
386 // Channel IDs are not separated for protected and unprotected web | 410 // Channel IDs are not separated for protected and unprotected web |
387 // origins. We check the origin_type_mask_ to prevent unintended deletion. | 411 // origins. We check the origin_type_mask_ to prevent unintended deletion. |
388 if (remove_mask & REMOVE_CHANNEL_IDS && | 412 if (remove_mask & DATA_TYPE_CHANNEL_IDS && |
389 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 413 origin_type_mask_ & ORIGIN_TYPE_UNPROTECTED_WEB) { |
390 content::RecordAction( | 414 content::RecordAction( |
391 UserMetricsAction("ClearBrowsingData_ChannelIDs")); | 415 UserMetricsAction("ClearBrowsingData_ChannelIDs")); |
392 // Since we are running on the UI thread don't call GetURLRequestContext(). | 416 // Since we are running on the UI thread don't call GetURLRequestContext(). |
393 scoped_refptr<net::URLRequestContextGetter> rq_context = | 417 scoped_refptr<net::URLRequestContextGetter> rq_context = |
394 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> | 418 content::BrowserContext::GetDefaultStoragePartition(browser_context_)-> |
395 GetURLRequestContext(); | 419 GetURLRequestContext(); |
396 clear_channel_ids_.Start(); | 420 clear_channel_ids_.Start(); |
397 BrowserThread::PostTask( | 421 BrowserThread::PostTask( |
398 BrowserThread::IO, FROM_HERE, | 422 BrowserThread::IO, FROM_HERE, |
399 base::Bind(&ClearChannelIDsOnIOThread, | 423 base::Bind(&ClearChannelIDsOnIOThread, |
400 filter_builder.BuildChannelIDFilter(), | 424 filter_builder.BuildChannelIDFilter(), |
401 delete_begin_, delete_end_, std::move(rq_context), | 425 delete_begin_, delete_end_, std::move(rq_context), |
402 clear_channel_ids_.GetCompletionCallback())); | 426 clear_channel_ids_.GetCompletionCallback())); |
403 } | 427 } |
404 | 428 |
405 ////////////////////////////////////////////////////////////////////////////// | 429 ////////////////////////////////////////////////////////////////////////////// |
406 // STORAGE PARTITION DATA | 430 // STORAGE PARTITION DATA |
407 uint32_t storage_partition_remove_mask = 0; | 431 uint32_t storage_partition_remove_mask = 0; |
408 | 432 |
409 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set, | 433 // We ignore the DATA_TYPE_COOKIES request if UNPROTECTED_WEB is not set, |
410 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB | 434 // so that callers who request DATA_TYPE_SITE_DATA with another origin type |
411 // don't accidentally remove the cookies that are associated with the | 435 // don't accidentally remove the cookies that are associated with the |
412 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated | 436 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated |
413 // between UNPROTECTED_WEB and PROTECTED_WEB. | 437 // between UNPROTECTED_WEB and other origin types. |
414 if (remove_mask & REMOVE_COOKIES && | 438 if (remove_mask & DATA_TYPE_COOKIES && |
415 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 439 origin_type_mask_ & ORIGIN_TYPE_UNPROTECTED_WEB) { |
416 storage_partition_remove_mask |= | 440 storage_partition_remove_mask |= |
417 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; | 441 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; |
418 } | 442 } |
419 if (remove_mask & REMOVE_LOCAL_STORAGE) { | 443 if (remove_mask & DATA_TYPE_LOCAL_STORAGE) { |
420 storage_partition_remove_mask |= | 444 storage_partition_remove_mask |= |
421 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; | 445 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE; |
422 } | 446 } |
423 if (remove_mask & REMOVE_INDEXEDDB) { | 447 if (remove_mask & DATA_TYPE_INDEXED_DB) { |
424 storage_partition_remove_mask |= | 448 storage_partition_remove_mask |= |
425 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; | 449 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB; |
426 } | 450 } |
427 if (remove_mask & REMOVE_WEBSQL) { | 451 if (remove_mask & DATA_TYPE_WEB_SQL) { |
428 storage_partition_remove_mask |= | 452 storage_partition_remove_mask |= |
429 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL; | 453 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL; |
430 } | 454 } |
431 if (remove_mask & REMOVE_APPCACHE) { | 455 if (remove_mask & DATA_TYPE_APP_CACHE) { |
432 storage_partition_remove_mask |= | 456 storage_partition_remove_mask |= |
433 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE; | 457 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE; |
434 } | 458 } |
435 if (remove_mask & REMOVE_SERVICE_WORKERS) { | 459 if (remove_mask & DATA_TYPE_SERVICE_WORKERS) { |
436 storage_partition_remove_mask |= | 460 storage_partition_remove_mask |= |
437 content::StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS; | 461 content::StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS; |
438 } | 462 } |
439 if (remove_mask & REMOVE_CACHE_STORAGE) { | 463 if (remove_mask & DATA_TYPE_CACHE_STORAGE) { |
440 storage_partition_remove_mask |= | 464 storage_partition_remove_mask |= |
441 content::StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE; | 465 content::StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE; |
442 } | 466 } |
443 if (remove_mask & REMOVE_FILE_SYSTEMS) { | 467 if (remove_mask & DATA_TYPE_FILE_SYSTEMS) { |
444 storage_partition_remove_mask |= | 468 storage_partition_remove_mask |= |
445 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; | 469 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS; |
446 } | 470 } |
447 | 471 |
448 // Content Decryption Modules used by Encrypted Media store licenses in a | 472 // Content Decryption Modules used by Encrypted Media store licenses in a |
449 // private filesystem. These are different than content licenses used by | 473 // private filesystem. These are different than content licenses used by |
450 // Flash (which are deleted father down in this method). | 474 // Flash (which are deleted father down in this method). |
451 if (remove_mask & REMOVE_MEDIA_LICENSES) { | 475 if (remove_mask & DATA_TYPE_MEDIA_LICENSES) { |
452 storage_partition_remove_mask |= | 476 storage_partition_remove_mask |= |
453 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; | 477 content::StoragePartition::REMOVE_DATA_MASK_PLUGIN_PRIVATE_DATA; |
454 } | 478 } |
455 | 479 |
456 if (storage_partition_remove_mask) { | 480 if (storage_partition_remove_mask) { |
457 clear_storage_partition_data_.Start(); | 481 clear_storage_partition_data_.Start(); |
458 | 482 |
459 content::StoragePartition* storage_partition; | 483 content::StoragePartition* storage_partition; |
460 if (storage_partition_for_testing_) { | 484 if (storage_partition_for_testing_) { |
461 storage_partition = storage_partition_for_testing_; | 485 storage_partition = storage_partition_for_testing_; |
462 } else { | 486 } else { |
463 storage_partition = | 487 storage_partition = |
464 BrowserContext::GetDefaultStoragePartition(browser_context_); | 488 BrowserContext::GetDefaultStoragePartition(browser_context_); |
465 } | 489 } |
466 | 490 |
467 uint32_t quota_storage_remove_mask = | 491 uint32_t quota_storage_remove_mask = |
468 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 492 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
469 | 493 |
470 if (delete_begin_ == base::Time() || | 494 if (delete_begin_ == base::Time() || |
471 origin_type_mask_ & | 495 ((origin_type_mask_ & ~ORIGIN_TYPE_UNPROTECTED_WEB) != 0)) { |
472 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | |
473 // If we're deleting since the beginning of time, or we're removing | 496 // If we're deleting since the beginning of time, or we're removing |
474 // protected origins, then remove persistent quota data. | 497 // protected origins, then remove persistent quota data. |
475 quota_storage_remove_mask |= | 498 quota_storage_remove_mask |= |
476 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 499 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
477 } | 500 } |
478 | 501 |
479 // If cookies are supposed to be conditionally deleted from the storage | 502 // If cookies are supposed to be conditionally deleted from the storage |
480 // partition, create a cookie matcher function. | 503 // partition, create a cookie matcher function. |
481 content::StoragePartition::CookieMatcherFunction cookie_matcher; | 504 content::StoragePartition::CookieMatcherFunction cookie_matcher; |
482 if (!filter_builder.IsEmptyBlacklist() && | 505 if (!filter_builder.IsEmptyBlacklist() && |
483 (storage_partition_remove_mask & | 506 (storage_partition_remove_mask & |
484 content::StoragePartition::REMOVE_DATA_MASK_COOKIES)) { | 507 content::StoragePartition::REMOVE_DATA_MASK_COOKIES)) { |
485 cookie_matcher = filter_builder.BuildCookieFilter(); | 508 cookie_matcher = filter_builder.BuildCookieFilter(); |
486 } | 509 } |
487 | 510 |
488 storage_partition->ClearData( | 511 storage_partition->ClearData( |
489 storage_partition_remove_mask, quota_storage_remove_mask, | 512 storage_partition_remove_mask, quota_storage_remove_mask, |
490 base::Bind(&DoesOriginMatchMaskAndUrls, origin_type_mask_, filter), | 513 base::Bind(&DoesOriginMatchMaskAndUrls, |
514 weak_ptr_factory_.GetWeakPtr(), origin_type_mask_, filter), | |
491 cookie_matcher, delete_begin_, delete_end_, | 515 cookie_matcher, delete_begin_, delete_end_, |
492 clear_storage_partition_data_.GetCompletionCallback()); | 516 clear_storage_partition_data_.GetCompletionCallback()); |
493 } | 517 } |
494 | 518 |
495 ////////////////////////////////////////////////////////////////////////////// | 519 ////////////////////////////////////////////////////////////////////////////// |
496 // CACHE | 520 // CACHE |
497 if (remove_mask & REMOVE_CACHE) { | 521 if (remove_mask & DATA_TYPE_CACHE) { |
498 // Tell the renderers to clear their cache. | 522 // Tell the renderers to clear their cache. |
499 web_cache::WebCacheManager::GetInstance()->ClearCache(); | 523 web_cache::WebCacheManager::GetInstance()->ClearCache(); |
500 | 524 |
501 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); | 525 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache")); |
502 | 526 |
503 clear_cache_.Start(); | 527 clear_cache_.Start(); |
504 // StoragePartitionHttpCacheDataRemover deletes itself when it is done. | 528 // StoragePartitionHttpCacheDataRemover deletes itself when it is done. |
505 if (filter_builder.IsEmptyBlacklist()) { | 529 if (filter_builder.IsEmptyBlacklist()) { |
506 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( | 530 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( |
507 BrowserContext::GetDefaultStoragePartition(browser_context_), | 531 BrowserContext::GetDefaultStoragePartition(browser_context_), |
508 delete_begin_, delete_end_) | 532 delete_begin_, delete_end_) |
509 ->Remove(clear_cache_.GetCompletionCallback()); | 533 ->Remove(clear_cache_.GetCompletionCallback()); |
510 } else { | 534 } else { |
511 browsing_data::StoragePartitionHttpCacheDataRemover:: | 535 browsing_data::StoragePartitionHttpCacheDataRemover:: |
512 CreateForURLsAndRange( | 536 CreateForURLsAndRange( |
513 BrowserContext::GetDefaultStoragePartition(browser_context_), | 537 BrowserContext::GetDefaultStoragePartition(browser_context_), |
514 filter, delete_begin_, delete_end_) | 538 filter, delete_begin_, delete_end_) |
515 ->Remove(clear_cache_.GetCompletionCallback()); | 539 ->Remove(clear_cache_.GetCompletionCallback()); |
516 } | 540 } |
517 | 541 |
518 // Tell the shader disk cache to clear. | 542 // Tell the shader disk cache to clear. |
519 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); | 543 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache")); |
520 storage_partition_remove_mask |= | 544 storage_partition_remove_mask |= |
521 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; | 545 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE; |
522 } | 546 } |
523 | 547 |
524 ////////////////////////////////////////////////////////////////////////////// | 548 ////////////////////////////////////////////////////////////////////////////// |
525 // Auth cache. | 549 // Auth cache. |
526 if (remove_mask & REMOVE_COOKIES) { | 550 if (remove_mask & DATA_TYPE_COOKIES) { |
527 scoped_refptr<net::URLRequestContextGetter> request_context = | 551 scoped_refptr<net::URLRequestContextGetter> request_context = |
528 BrowserContext::GetDefaultStoragePartition(browser_context_) | 552 BrowserContext::GetDefaultStoragePartition(browser_context_) |
529 ->GetURLRequestContext(); | 553 ->GetURLRequestContext(); |
530 clear_http_auth_cache_.Start(); | 554 clear_http_auth_cache_.Start(); |
531 BrowserThread::PostTaskAndReply( | 555 BrowserThread::PostTaskAndReply( |
532 BrowserThread::IO, FROM_HERE, | 556 BrowserThread::IO, FROM_HERE, |
533 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), | 557 base::Bind(&ClearHttpAuthCacheOnIOThread, std::move(request_context), |
534 delete_begin_), | 558 delete_begin_), |
535 clear_http_auth_cache_.GetCompletionCallback()); | 559 clear_http_auth_cache_.GetCompletionCallback()); |
536 } | 560 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
653 | 677 |
654 if (completion_inhibitor_) { | 678 if (completion_inhibitor_) { |
655 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( | 679 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete( |
656 this, base::Bind(&BrowsingDataRemoverImpl::Notify, | 680 this, base::Bind(&BrowsingDataRemoverImpl::Notify, |
657 weak_ptr_factory_.GetWeakPtr())); | 681 weak_ptr_factory_.GetWeakPtr())); |
658 return; | 682 return; |
659 } | 683 } |
660 | 684 |
661 Notify(); | 685 Notify(); |
662 } | 686 } |
OLD | NEW |