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.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 } | 149 } |
150 | 150 |
151 // Another convenience method to turn a callback without arguments into one that | 151 // Another convenience method to turn a callback without arguments into one that |
152 // accepts (and ignores) a single argument. | 152 // accepts (and ignores) a single argument. |
153 template <typename T> | 153 template <typename T> |
154 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { | 154 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { |
155 return base::Bind(&IgnoreArgumentHelper<T>, callback); | 155 return base::Bind(&IgnoreArgumentHelper<T>, callback); |
156 } | 156 } |
157 | 157 |
158 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. | 158 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask. |
159 bool DoesOriginMatchMask( | 159 bool DoesOriginMatchMask( |
msramek
2016/02/29 17:46:07
nit: DoesOriginMatchMaskAndUrls?
dmurph
2016/03/01 00:09:59
Done.
| |
160 int origin_type_mask, | 160 int origin_type_mask, |
161 const base::Callback<bool(const GURL&)>& predicate, | |
msramek
2016/02/29 17:46:07
nit: Can you please generally refer to this as |ur
dmurph
2016/03/01 00:10:00
Predicate implies that if you return true, then th
msramek
2016/03/01 17:24:09
I don't particularly mind the word 'predicate', bu
michaeln
2016/03/09 20:25:51
naming nit: How about origin_matcher_fn? Also if t
msramek
2016/03/10 20:10:08
Origin matching is also not exact, since sometimes
| |
161 const GURL& origin, | 162 const GURL& origin, |
162 storage::SpecialStoragePolicy* special_storage_policy) { | 163 storage::SpecialStoragePolicy* special_storage_policy) { |
163 return BrowsingDataHelper::DoesOriginMatchMask( | 164 return predicate.Run(origin) && |
164 origin, origin_type_mask, special_storage_policy); | 165 BrowsingDataHelper::DoesOriginMatchMask(origin, origin_type_mask, |
166 special_storage_policy); | |
167 } | |
168 | |
169 bool PrimaryPatternGURLPredicate( | |
Timo Reimann
2016/02/29 22:38:15
I think the function name could be improved. Prefi
dmurph
2016/03/01 00:09:59
Done.
| |
170 const base::Callback<bool(const GURL&)> predicate, | |
171 const ContentSettingsPattern& primary_pattern, | |
172 const ContentSettingsPattern& secondary_pattern) { | |
Timo Reimann
2016/02/29 22:38:15
|secondary_pattern| doesn't seem to be used in thi
dmurph
2016/03/01 00:09:59
Nope. I need to convert from the two patterns to t
| |
173 GURL url(primary_pattern.ToString()); | |
174 return !url.is_valid() || predicate.Run(url); | |
Mike West
2016/02/29 09:27:38
When can an invalid URL appear here? Why would an
msramek
2016/02/29 17:46:07
Heh, this is quite tricky - if I have a content se
dmurph
2016/03/01 00:10:00
Unfortunately, I can't use |Matches|, as I'm not g
| |
165 } | 175 } |
166 | 176 |
167 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { | 177 void ClearHostnameResolutionCacheOnIOThread(IOThread* io_thread) { |
168 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 178 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
169 | 179 |
170 io_thread->ClearHostCache(); | 180 io_thread->ClearHostCache(); |
171 } | 181 } |
172 | 182 |
173 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { | 183 void ClearNetworkPredictorOnIOThread(chrome_browser_net::Predictor* predictor) { |
174 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 184 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 } | 329 } |
320 | 330 |
321 void BrowsingDataRemover::SetRemoving(bool is_removing) { | 331 void BrowsingDataRemover::SetRemoving(bool is_removing) { |
322 DCHECK_NE(is_removing_, is_removing); | 332 DCHECK_NE(is_removing_, is_removing); |
323 is_removing_ = is_removing; | 333 is_removing_ = is_removing; |
324 } | 334 } |
325 | 335 |
326 void BrowsingDataRemover::Remove(const TimeRange& time_range, | 336 void BrowsingDataRemover::Remove(const TimeRange& time_range, |
327 int remove_mask, | 337 int remove_mask, |
328 int origin_type_mask) { | 338 int origin_type_mask) { |
329 RemoveImpl(time_range, remove_mask, GURL(), origin_type_mask); | 339 OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST); |
340 RemoveImpl(time_range, remove_mask, builder, origin_type_mask); | |
341 } | |
342 | |
343 void BrowsingDataRemover::RemoveWithFilter(const TimeRange& time_range, | |
344 int remove_mask, | |
345 int origin_type_mask, | |
346 const OriginFilterBuilder& origin_filter) { | |
msramek
2016/02/29 17:46:07
This is actually a filter builder, not a filter. I
dmurph
2016/03/01 00:10:00
I understand. For now I was just passing the build
msramek
2016/03/01 17:24:09
Acknowledged. Yes, after adding ContentSettingPatt
| |
347 RemoveImpl(time_range, remove_mask, origin_filter, | |
348 origin_type_mask); | |
330 } | 349 } |
331 | 350 |
332 void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range, | 351 void BrowsingDataRemover::RemoveImpl(const TimeRange& time_range, |
333 int remove_mask, | 352 int remove_mask, |
334 const GURL& remove_url, | 353 const OriginFilterBuilder& origin_filter, |
335 int origin_type_mask) { | 354 int origin_type_mask) { |
336 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 355 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
337 | 356 |
338 // 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 |
339 // delete_end, even though they should've used base::Time::Max(). | 358 // delete_end, even though they should've used base::Time::Max(). |
340 DCHECK_NE(base::Time(), time_range.end); | 359 DCHECK_NE(base::Time(), time_range.end); |
341 | 360 |
342 SetRemoving(true); | 361 SetRemoving(true); |
343 delete_begin_ = time_range.begin; | 362 delete_begin_ = time_range.begin; |
344 delete_end_ = time_range.end; | 363 delete_end_ = time_range.end; |
345 remove_mask_ = remove_mask; | 364 remove_mask_ = remove_mask; |
346 origin_type_mask_ = origin_type_mask; | 365 origin_type_mask_ = origin_type_mask; |
347 | 366 |
348 // TODO(msramek): Replace |remove_origin| with |filter| in all backends. | |
349 const url::Origin remove_origin(remove_url); | |
350 OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST); | |
351 if (!remove_url.is_empty()) { | |
352 // Make sure that only URLs representing origins, with no extra components, | |
353 // are passed to this class. | |
354 DCHECK_EQ(remove_url, remove_url.GetOrigin()); | |
355 builder.SetMode(OriginFilterBuilder::WHITELIST); | |
356 builder.AddOrigin(url::Origin(remove_origin)); | |
357 } | |
358 base::Callback<bool(const GURL& url)> same_origin_filter = | 367 base::Callback<bool(const GURL& url)> same_origin_filter = |
359 builder.BuildSameOriginFilter(); | 368 origin_filter.BuildSameOriginFilter(); |
360 | 369 |
361 PrefService* prefs = profile_->GetPrefs(); | 370 PrefService* prefs = profile_->GetPrefs(); |
362 bool may_delete_history = prefs->GetBoolean( | 371 bool may_delete_history = prefs->GetBoolean( |
363 prefs::kAllowDeletingBrowserHistory); | 372 prefs::kAllowDeletingBrowserHistory); |
364 | 373 |
365 // All the UI entry points into the BrowsingDataRemover should be disabled, | 374 // All the UI entry points into the BrowsingDataRemover should be disabled, |
366 // but this will fire if something was missed or added. | 375 // but this will fire if something was missed or added. |
367 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || | 376 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) || |
368 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); | 377 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS))); |
369 | 378 |
(...skipping 15 matching lines...) Expand all Loading... | |
385 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | | 394 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB | |
386 BrowsingDataHelper::PROTECTED_WEB | | 395 BrowsingDataHelper::PROTECTED_WEB | |
387 BrowsingDataHelper::EXTENSION), | 396 BrowsingDataHelper::EXTENSION), |
388 "OriginTypeMask has been updated without updating user metrics"); | 397 "OriginTypeMask has been updated without updating user metrics"); |
389 | 398 |
390 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { | 399 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) { |
391 history::HistoryService* history_service = | 400 history::HistoryService* history_service = |
392 HistoryServiceFactory::GetForProfile( | 401 HistoryServiceFactory::GetForProfile( |
393 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 402 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
394 if (history_service) { | 403 if (history_service) { |
395 // Selective history deletion is currently done through HistoryUI -> | 404 // TODO(dmurph): Support all backends with filter (crbug.com/589586). |
396 // HistoryBackend -> HistoryService, and that is for individual URLs, | |
397 // not origins. The code below is currently unused, as the only callsite | |
398 // supplying |remove_url| is the unittest. | |
399 // TODO(msramek): Make it possible to delete history per origin, not just | |
400 // per URL, and use that functionality here. | |
401 std::set<GURL> restrict_urls; | |
402 if (!remove_url.is_empty()) | |
403 restrict_urls.insert(remove_url); | |
404 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); | 405 content::RecordAction(UserMetricsAction("ClearBrowsingData_History")); |
405 waiting_for_clear_history_ = true; | 406 waiting_for_clear_history_ = true; |
406 | |
407 history_service->ExpireLocalAndRemoteHistoryBetween( | 407 history_service->ExpireLocalAndRemoteHistoryBetween( |
408 WebHistoryServiceFactory::GetForProfile(profile_), restrict_urls, | 408 WebHistoryServiceFactory::GetForProfile(profile_), std::set<GURL>(), |
Mike West
2016/02/29 09:27:38
If you're going to remove this mechanism in favor
dmurph
2016/03/01 00:10:00
See the bug. This API is NOT in use anywhere excep
| |
409 delete_begin_, delete_end_, | 409 delete_begin_, delete_end_, |
410 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, | 410 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone, |
411 weak_ptr_factory_.GetWeakPtr()), | 411 weak_ptr_factory_.GetWeakPtr()), |
412 &history_task_tracker_); | 412 &history_task_tracker_); |
413 | 413 |
414 #if defined(ENABLE_EXTENSIONS) | 414 #if defined(ENABLE_EXTENSIONS) |
415 // The extension activity contains details of which websites extensions | 415 // The extension activity contains details of which websites extensions |
416 // were active on. It therefore indirectly stores details of websites a | 416 // were active on. It therefore indirectly stores details of websites a |
417 // user has visited so best clean from here as well. | 417 // user has visited so best clean from here as well. |
418 extensions::ActivityLog::GetInstance(profile_)->RemoveURLs(restrict_urls); | 418 extensions::ActivityLog::GetInstance(profile_)->RemoveURLs( |
419 std::set<GURL>()); | |
Mike West
2016/02/29 09:27:38
Ditto.
dmurph
2016/03/01 00:09:59
See above.
| |
419 #endif | 420 #endif |
420 } | 421 } |
421 | 422 |
422 #if defined(ENABLE_EXTENSIONS) | 423 #if defined(ENABLE_EXTENSIONS) |
423 // Clear launch times as they are a form of history. | 424 // Clear launch times as they are a form of history. |
424 extensions::ExtensionPrefs* extension_prefs = | 425 extensions::ExtensionPrefs* extension_prefs = |
425 extensions::ExtensionPrefs::Get(profile_); | 426 extensions::ExtensionPrefs::Get(profile_); |
426 extension_prefs->ClearLastLaunchTimes(); | 427 extension_prefs->ClearLastLaunchTimes(); |
427 #endif | 428 #endif |
428 | 429 |
429 // The power consumption history by origin contains details of websites | 430 // The power consumption history by origin contains details of websites |
430 // that were visited. | 431 // that were visited. |
432 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
431 power::OriginPowerMap* origin_power_map = | 433 power::OriginPowerMap* origin_power_map = |
432 power::OriginPowerMapFactory::GetForBrowserContext(profile_); | 434 power::OriginPowerMapFactory::GetForBrowserContext(profile_); |
433 if (origin_power_map) | 435 if (origin_power_map) |
434 origin_power_map->ClearOriginMap(); | 436 origin_power_map->ClearOriginMap(); |
435 | 437 |
436 // Need to clear the host cache and accumulated speculative data, as it also | 438 // Need to clear the host cache and accumulated speculative data, as it also |
437 // reveals some history: we have no mechanism to track when these items were | 439 // reveals some history: we have no mechanism to track when these items were |
438 // created, so we'll clear them all. Better safe than sorry. | 440 // created, so we'll clear them all. Better safe than sorry. |
439 if (g_browser_process->io_thread()) { | 441 if (g_browser_process->io_thread()) { |
442 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
440 waiting_for_clear_hostname_resolution_cache_ = true; | 443 waiting_for_clear_hostname_resolution_cache_ = true; |
441 BrowserThread::PostTaskAndReply( | 444 BrowserThread::PostTaskAndReply( |
442 BrowserThread::IO, FROM_HERE, | 445 BrowserThread::IO, FROM_HERE, |
443 base::Bind(&ClearHostnameResolutionCacheOnIOThread, | 446 base::Bind(&ClearHostnameResolutionCacheOnIOThread, |
444 g_browser_process->io_thread()), | 447 g_browser_process->io_thread()), |
445 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, | 448 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache, |
446 weak_ptr_factory_.GetWeakPtr())); | 449 weak_ptr_factory_.GetWeakPtr())); |
447 } | 450 } |
448 if (profile_->GetNetworkPredictor()) { | 451 if (profile_->GetNetworkPredictor()) { |
452 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
449 waiting_for_clear_network_predictor_ = true; | 453 waiting_for_clear_network_predictor_ = true; |
450 BrowserThread::PostTaskAndReply( | 454 BrowserThread::PostTaskAndReply( |
451 BrowserThread::IO, FROM_HERE, | 455 BrowserThread::IO, FROM_HERE, |
452 base::Bind(&ClearNetworkPredictorOnIOThread, | 456 base::Bind(&ClearNetworkPredictorOnIOThread, |
453 profile_->GetNetworkPredictor()), | 457 profile_->GetNetworkPredictor()), |
454 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor, | 458 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor, |
455 weak_ptr_factory_.GetWeakPtr())); | 459 weak_ptr_factory_.GetWeakPtr())); |
456 } | 460 } |
457 | 461 |
458 // As part of history deletion we also delete the auto-generated keywords. | 462 // As part of history deletion we also delete the auto-generated keywords. |
459 TemplateURLService* keywords_model = | 463 TemplateURLService* keywords_model = |
460 TemplateURLServiceFactory::GetForProfile(profile_); | 464 TemplateURLServiceFactory::GetForProfile(profile_); |
465 | |
461 if (keywords_model && !keywords_model->loaded()) { | 466 if (keywords_model && !keywords_model->loaded()) { |
462 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( | 467 template_url_sub_ = keywords_model->RegisterOnLoadedCallback( |
463 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, | 468 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded, |
464 weak_ptr_factory_.GetWeakPtr())); | 469 weak_ptr_factory_.GetWeakPtr())); |
465 keywords_model->Load(); | 470 keywords_model->Load(); |
466 waiting_for_clear_keyword_data_ = true; | 471 waiting_for_clear_keyword_data_ = true; |
467 } else if (keywords_model) { | 472 } else if (keywords_model) { |
468 keywords_model->RemoveAutoGeneratedForOriginBetween( | 473 keywords_model->RemoveAutoGeneratedForOriginBetween( |
469 remove_url, delete_begin_, delete_end_); | 474 GURL(), delete_begin_, delete_end_); |
Mike West
2016/02/29 09:27:38
Ditto.
dmurph
2016/03/01 00:09:59
See above.
| |
470 } | 475 } |
471 | 476 |
472 // The PrerenderManager keeps history of prerendered pages, so clear that. | 477 // The PrerenderManager keeps history of prerendered pages, so clear that. |
473 // It also may have a prerendered page. If so, the page could be | 478 // It also may have a prerendered page. If so, the page could be |
474 // considered to have a small amount of historical information, so delete | 479 // considered to have a small amount of historical information, so delete |
475 // it, too. | 480 // it, too. |
476 prerender::PrerenderManager* prerender_manager = | 481 prerender::PrerenderManager* prerender_manager = |
477 prerender::PrerenderManagerFactory::GetForProfile(profile_); | 482 prerender::PrerenderManagerFactory::GetForProfile(profile_); |
478 if (prerender_manager) { | 483 if (prerender_manager) { |
484 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
479 prerender_manager->ClearData( | 485 prerender_manager->ClearData( |
480 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | | 486 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS | |
481 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); | 487 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY); |
482 } | 488 } |
483 | 489 |
484 // If the caller is removing history for all hosts, then clear ancillary | 490 // If the caller is removing history for all hosts, then clear ancillary |
485 // historical information. | 491 // historical information. |
486 if (remove_url.is_empty()) { | 492 if (origin_filter.IsEmptyBlacklist()) { |
msramek
2016/02/29 17:46:07
optional: Remove or RemoveWithFilter could remembe
| |
487 // We also delete the list of recently closed tabs. Since these expire, | 493 // We also delete the list of recently closed tabs. Since these expire, |
488 // they can't be more than a day old, so we can simply clear them all. | 494 // they can't be more than a day old, so we can simply clear them all. |
489 sessions::TabRestoreService* tab_service = | 495 sessions::TabRestoreService* tab_service = |
490 TabRestoreServiceFactory::GetForProfile(profile_); | 496 TabRestoreServiceFactory::GetForProfile(profile_); |
491 if (tab_service) { | 497 if (tab_service) { |
492 tab_service->ClearEntries(); | 498 tab_service->ClearEntries(); |
493 tab_service->DeleteLastSession(); | 499 tab_service->DeleteLastSession(); |
494 } | 500 } |
495 | 501 |
496 #if defined(ENABLE_SESSION_SERVICE) | 502 #if defined(ENABLE_SESSION_SERVICE) |
497 // We also delete the last session when we delete the history. | 503 // We also delete the last session when we delete the history. |
498 SessionService* session_service = | 504 SessionService* session_service = |
499 SessionServiceFactory::GetForProfile(profile_); | 505 SessionServiceFactory::GetForProfile(profile_); |
500 if (session_service) | 506 if (session_service) |
501 session_service->DeleteLastSession(); | 507 session_service->DeleteLastSession(); |
502 #endif | 508 #endif |
503 } | 509 } |
504 | 510 |
505 // The saved Autofill profiles and credit cards can include the origin from | 511 // The saved Autofill profiles and credit cards can include the origin from |
506 // which these profiles and credit cards were learned. These are a form of | 512 // which these profiles and credit cards were learned. These are a form of |
507 // history, so clear them as well. | 513 // history, so clear them as well. |
514 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
508 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 515 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
509 WebDataServiceFactory::GetAutofillWebDataForProfile( | 516 WebDataServiceFactory::GetAutofillWebDataForProfile( |
510 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 517 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
511 if (web_data_service.get()) { | 518 if (web_data_service.get()) { |
512 waiting_for_clear_autofill_origin_urls_ = true; | 519 waiting_for_clear_autofill_origin_urls_ = true; |
513 web_data_service->RemoveOriginURLsModifiedBetween( | 520 web_data_service->RemoveOriginURLsModifiedBetween( |
514 delete_begin_, delete_end_); | 521 delete_begin_, delete_end_); |
515 // The above calls are done on the UI thread but do their work on the DB | 522 // The above calls are done on the UI thread but do their work on the DB |
516 // thread. So wait for it. | 523 // thread. So wait for it. |
517 BrowserThread::PostTaskAndReply( | 524 BrowserThread::PostTaskAndReply( |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 603 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
597 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 604 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
598 | 605 |
599 storage_partition_remove_mask |= | 606 storage_partition_remove_mask |= |
600 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; | 607 content::StoragePartition::REMOVE_DATA_MASK_COOKIES; |
601 | 608 |
602 // Clear the safebrowsing cookies only if time period is for "all time". It | 609 // Clear the safebrowsing cookies only if time period is for "all time". It |
603 // doesn't make sense to apply the time period of deleting in the last X | 610 // doesn't make sense to apply the time period of deleting in the last X |
604 // hours/days to the safebrowsing cookies since they aren't the result of | 611 // hours/days to the safebrowsing cookies since they aren't the result of |
605 // any user action. | 612 // any user action. |
613 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
606 if (delete_begin_ == base::Time()) { | 614 if (delete_begin_ == base::Time()) { |
607 safe_browsing::SafeBrowsingService* sb_service = | 615 safe_browsing::SafeBrowsingService* sb_service = |
608 g_browser_process->safe_browsing_service(); | 616 g_browser_process->safe_browsing_service(); |
609 if (sb_service) { | 617 if (sb_service) { |
610 scoped_refptr<net::URLRequestContextGetter> sb_context = | 618 scoped_refptr<net::URLRequestContextGetter> sb_context = |
611 sb_service->url_request_context(); | 619 sb_service->url_request_context(); |
612 ++waiting_for_clear_cookies_count_; | 620 ++waiting_for_clear_cookies_count_; |
621 // TODONOW | |
Mike West
2016/02/29 09:27:38
?
dmurph
2016/03/01 00:10:00
Haha I need to impl this still.
| |
613 BrowserThread::PostTask( | 622 BrowserThread::PostTask( |
614 BrowserThread::IO, FROM_HERE, | 623 BrowserThread::IO, FROM_HERE, |
615 base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, | 624 base::Bind(&ClearCookiesOnIOThread, delete_begin_, delete_end_, |
616 std::move(sb_context), | 625 std::move(sb_context), |
617 UIThreadTrampoline( | 626 UIThreadTrampoline( |
618 base::Bind(&BrowsingDataRemover::OnClearedCookies, | 627 base::Bind(&BrowsingDataRemover::OnClearedCookies, |
619 weak_ptr_factory_.GetWeakPtr())))); | 628 weak_ptr_factory_.GetWeakPtr())))); |
620 } | 629 } |
621 } | 630 } |
622 | 631 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 | 700 |
692 base::WaitableEventWatcher::EventCallback watcher_callback = | 701 base::WaitableEventWatcher::EventCallback watcher_callback = |
693 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, | 702 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, |
694 weak_ptr_factory_.GetWeakPtr()); | 703 weak_ptr_factory_.GetWeakPtr()); |
695 watcher_.StartWatching(event, watcher_callback); | 704 watcher_.StartWatching(event, watcher_callback); |
696 } | 705 } |
697 #endif | 706 #endif |
698 | 707 |
699 if (remove_mask & REMOVE_SITE_USAGE_DATA) { | 708 if (remove_mask & REMOVE_SITE_USAGE_DATA) { |
700 HostContentSettingsMapFactory::GetForProfile(profile_) | 709 HostContentSettingsMapFactory::GetForProfile(profile_) |
701 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT); | 710 ->ClearSettingsForOneTypeWithPredicate( |
711 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | |
712 base::Bind(&PrimaryPatternGURLPredicate, same_origin_filter)); | |
702 } | 713 } |
703 | 714 |
704 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { | 715 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) { |
705 HostContentSettingsMapFactory::GetForProfile(profile_) | 716 HostContentSettingsMapFactory::GetForProfile(profile_) |
706 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_APP_BANNER); | 717 ->ClearSettingsForOneTypeWithPredicate( |
718 CONTENT_SETTINGS_TYPE_APP_BANNER, | |
719 base::Bind(&PrimaryPatternGURLPredicate, same_origin_filter)); | |
707 } | 720 } |
708 | 721 |
722 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
709 if (remove_mask & REMOVE_PASSWORDS) { | 723 if (remove_mask & REMOVE_PASSWORDS) { |
710 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 724 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
711 password_manager::PasswordStore* password_store = | 725 password_manager::PasswordStore* password_store = |
712 PasswordStoreFactory::GetForProfile( | 726 PasswordStoreFactory::GetForProfile( |
713 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 727 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
714 | 728 |
715 if (password_store) { | 729 if (password_store) { |
716 waiting_for_clear_passwords_ = true; | 730 waiting_for_clear_passwords_ = true; |
717 auto on_cleared_passwords = | 731 auto on_cleared_passwords = |
718 base::Bind(&BrowsingDataRemover::OnClearedPasswords, | 732 base::Bind(&BrowsingDataRemover::OnClearedPasswords, |
719 weak_ptr_factory_.GetWeakPtr()); | 733 weak_ptr_factory_.GetWeakPtr()); |
720 if (remove_url.is_empty()) { | 734 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_, |
721 password_store->RemoveLoginsCreatedBetween(delete_begin_, delete_end_, | 735 on_cleared_passwords); |
722 on_cleared_passwords); | |
723 } else { | |
724 password_store->RemoveLoginsByOriginAndTime( | |
Mike West
2016/02/29 09:27:38
Ditto.
dmurph
2016/03/01 00:09:59
See above comment.
| |
725 remove_origin, delete_begin_, delete_end_, on_cleared_passwords); | |
726 } | |
727 } | 736 } |
728 } | 737 } |
729 | 738 |
730 if (remove_mask & REMOVE_HISTORY) { | 739 if (remove_mask & REMOVE_HISTORY) { |
731 password_manager::PasswordStore* password_store = | 740 password_manager::PasswordStore* password_store = |
732 PasswordStoreFactory::GetForProfile( | 741 PasswordStoreFactory::GetForProfile( |
733 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); | 742 profile_, ServiceAccessType::EXPLICIT_ACCESS).get(); |
734 | 743 |
735 if (password_store) { | 744 if (password_store) { |
736 waiting_for_clear_passwords_stats_ = true; | 745 waiting_for_clear_passwords_stats_ = true; |
737 password_store->RemoveStatisticsCreatedBetween( | 746 password_store->RemoveStatisticsCreatedBetween( |
738 delete_begin_, delete_end_, | 747 delete_begin_, delete_end_, |
739 base::Bind(&BrowsingDataRemover::OnClearedPasswordsStats, | 748 base::Bind(&BrowsingDataRemover::OnClearedPasswordsStats, |
740 weak_ptr_factory_.GetWeakPtr())); | 749 weak_ptr_factory_.GetWeakPtr())); |
741 } | 750 } |
742 } | 751 } |
743 | 752 |
753 // TODO(dmurph): Support all backends with filter (crbug.com/589586). | |
744 if (remove_mask & REMOVE_FORM_DATA) { | 754 if (remove_mask & REMOVE_FORM_DATA) { |
745 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); | 755 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill")); |
746 scoped_refptr<autofill::AutofillWebDataService> web_data_service = | 756 scoped_refptr<autofill::AutofillWebDataService> web_data_service = |
747 WebDataServiceFactory::GetAutofillWebDataForProfile( | 757 WebDataServiceFactory::GetAutofillWebDataForProfile( |
748 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 758 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
749 | 759 |
750 if (web_data_service.get()) { | 760 if (web_data_service.get()) { |
751 waiting_for_clear_form_ = true; | 761 waiting_for_clear_form_ = true; |
752 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, | 762 web_data_service->RemoveFormElementsAddedBetween(delete_begin_, |
753 delete_end_); | 763 delete_end_); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 if (delete_begin_ == base::Time() || | 848 if (delete_begin_ == base::Time() || |
839 origin_type_mask_ & | 849 origin_type_mask_ & |
840 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { | 850 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) { |
841 // If we're deleting since the beginning of time, or we're removing | 851 // If we're deleting since the beginning of time, or we're removing |
842 // protected origins, then remove persistent quota data. | 852 // protected origins, then remove persistent quota data. |
843 quota_storage_remove_mask |= | 853 quota_storage_remove_mask |= |
844 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 854 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
845 } | 855 } |
846 | 856 |
847 storage_partition->ClearData( | 857 storage_partition->ClearData( |
848 storage_partition_remove_mask, quota_storage_remove_mask, remove_url, | 858 storage_partition_remove_mask, quota_storage_remove_mask, GURL(), |
Mike West
2016/02/29 09:27:38
It looks like you're passing in the filter below,
dmurph
2016/03/01 00:09:59
I can do that, it hits a couple other areas in the
| |
849 base::Bind(&DoesOriginMatchMask, origin_type_mask_), delete_begin_, | 859 base::Bind(&DoesOriginMatchMask, origin_type_mask_, same_origin_filter), |
850 delete_end_, | 860 delete_begin_, delete_end_, |
851 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, | 861 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData, |
852 weak_ptr_factory_.GetWeakPtr())); | 862 weak_ptr_factory_.GetWeakPtr())); |
853 } | 863 } |
854 | 864 |
855 #if defined(ENABLE_PLUGINS) | 865 #if defined(ENABLE_PLUGINS) |
856 if (remove_mask & REMOVE_CONTENT_LICENSES) { | 866 if (remove_mask & REMOVE_CONTENT_LICENSES) { |
857 content::RecordAction( | 867 content::RecordAction( |
858 UserMetricsAction("ClearBrowsingData_ContentLicenses")); | 868 UserMetricsAction("ClearBrowsingData_ContentLicenses")); |
859 | 869 |
860 waiting_for_clear_content_licenses_ = true; | 870 waiting_for_clear_content_licenses_ = true; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
920 waiting_for_clear_webapp_data_ = true; | 930 waiting_for_clear_webapp_data_ = true; |
921 WebappRegistry::UnregisterWebapps( | 931 WebappRegistry::UnregisterWebapps( |
922 base::Bind(&BrowsingDataRemover::OnClearedWebappData, | 932 base::Bind(&BrowsingDataRemover::OnClearedWebappData, |
923 weak_ptr_factory_.GetWeakPtr())); | 933 weak_ptr_factory_.GetWeakPtr())); |
924 } | 934 } |
925 | 935 |
926 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && | 936 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && |
927 offline_pages::IsOfflinePagesEnabled()) { | 937 offline_pages::IsOfflinePagesEnabled()) { |
928 waiting_for_clear_offline_page_data_ = true; | 938 waiting_for_clear_offline_page_data_ = true; |
929 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 939 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
930 ->ClearAll(base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, | 940 ->ClearWithURLPredicate( |
931 weak_ptr_factory_.GetWeakPtr())); | 941 same_origin_filter, |
942 base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, | |
943 weak_ptr_factory_.GetWeakPtr())); | |
932 } | 944 } |
933 #endif | 945 #endif |
934 | 946 |
935 // Record the combined deletion of cookies and cache. | 947 // Record the combined deletion of cookies and cache. |
936 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; | 948 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE; |
937 if (remove_mask & REMOVE_COOKIES && | 949 if (remove_mask & REMOVE_COOKIES && |
938 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { | 950 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
939 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE | 951 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE |
940 : ONLY_COOKIES; | 952 : ONLY_COOKIES; |
941 } else if (remove_mask & REMOVE_CACHE) { | 953 } else if (remove_mask & REMOVE_CACHE) { |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1210 waiting_for_clear_domain_reliability_monitor_ = false; | 1222 waiting_for_clear_domain_reliability_monitor_ = false; |
1211 NotifyIfDone(); | 1223 NotifyIfDone(); |
1212 } | 1224 } |
1213 | 1225 |
1214 // static | 1226 // static |
1215 BrowsingDataRemover::CallbackSubscription | 1227 BrowsingDataRemover::CallbackSubscription |
1216 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1228 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
1217 const BrowsingDataRemover::Callback& callback) { | 1229 const BrowsingDataRemover::Callback& callback) { |
1218 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1230 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
1219 } | 1231 } |
OLD | NEW |