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