Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 10 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 callback.Run(); | 121 callback.Run(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // Another convenience method to turn a callback without arguments into one that | 124 // Another convenience method to turn a callback without arguments into one that |
| 125 // accepts (and ignores) a single argument. | 125 // accepts (and ignores) a single argument. |
| 126 template <typename T> | 126 template <typename T> |
| 127 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { | 127 base::Callback<void(T)> IgnoreArgument(const base::Closure& callback) { |
| 128 return base::Bind(&IgnoreArgumentHelper<T>, callback); | 128 return base::Bind(&IgnoreArgumentHelper<T>, callback); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool ForwardPrimaryPatternCallback( | 131 bool WebsiteSettingsFilterAdapter( |
| 132 const base::Callback<bool(const ContentSettingsPattern&)> predicate, | 132 const base::Callback<bool(const GURL&)> predicate, |
| 133 const ContentSettingsPattern& primary_pattern, | 133 const ContentSettingsPattern& primary_pattern, |
| 134 const ContentSettingsPattern& secondary_pattern) { | 134 const ContentSettingsPattern& secondary_pattern) { |
| 135 return predicate.Run(primary_pattern); | 135 // Ignore the default setting. |
| 136 if (primary_pattern == ContentSettingsPattern::Wildcard()) | |
| 137 return false; | |
| 138 | |
| 139 // Website settings only use origin-scoped patterns. The only content setting | |
| 140 // currently supported by ChromeBrowsingDataRemoverDelegate is | |
| 141 // DURABLE_STORAGE, which also only uses origin-scoped patterns. Such patterns | |
| 142 // can be directly translated to a GURL. | |
| 143 GURL url(primary_pattern.ToString()); | |
| 144 DCHECK(url.is_valid()); | |
|
Mike West
2017/01/09 08:53:48
What happens if this DCHECK fails in Release? Will
msramek
2017/01/09 09:39:43
An invalid URL will be passed to the filter, where
| |
| 145 return predicate.Run(url); | |
| 136 } | 146 } |
| 137 | 147 |
| 138 #if !defined(DISABLE_NACL) | 148 #if !defined(DISABLE_NACL) |
| 139 void ClearNaClCacheOnIOThread(const base::Closure& callback) { | 149 void ClearNaClCacheOnIOThread(const base::Closure& callback) { |
| 140 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 150 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 141 | 151 |
| 142 nacl::NaClBrowser::GetInstance()->ClearValidationCache(callback); | 152 nacl::NaClBrowser::GetInstance()->ClearValidationCache(callback); |
| 143 } | 153 } |
| 144 | 154 |
| 145 void ClearPnaclCacheOnIOThread(base::Time begin, | 155 void ClearPnaclCacheOnIOThread(base::Time begin, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 ////////////////////////////////////////////////////////////////////////////// | 255 ////////////////////////////////////////////////////////////////////////////// |
| 246 // INITIALIZATION | 256 // INITIALIZATION |
| 247 synchronous_clear_operations_.Start(); | 257 synchronous_clear_operations_.Start(); |
| 248 callback_ = callback; | 258 callback_ = callback; |
| 249 | 259 |
| 250 delete_begin_ = delete_begin; | 260 delete_begin_ = delete_begin; |
| 251 delete_end_ = delete_end; | 261 delete_end_ = delete_end; |
| 252 | 262 |
| 253 base::Callback<bool(const GURL& url)> filter = | 263 base::Callback<bool(const GURL& url)> filter = |
| 254 filter_builder.BuildGeneralFilter(); | 264 filter_builder.BuildGeneralFilter(); |
| 255 base::Callback<bool(const ContentSettingsPattern& url)> same_pattern_filter = | |
| 256 filter_builder.BuildWebsiteSettingsPatternMatchesFilter(); | |
| 257 | 265 |
| 258 // Some backends support a filter that |is_null()| to make complete deletion | 266 // Some backends support a filter that |is_null()| to make complete deletion |
| 259 // more efficient. | 267 // more efficient. |
| 260 base::Callback<bool(const GURL&)> nullable_filter = | 268 base::Callback<bool(const GURL&)> nullable_filter = |
| 261 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() | 269 filter_builder.IsEmptyBlacklist() ? base::Callback<bool(const GURL&)>() |
| 262 : filter; | 270 : filter; |
| 263 | 271 |
| 264 // Managed devices and supervised users can have restrictions on history | 272 // Managed devices and supervised users can have restrictions on history |
| 265 // deletion. | 273 // deletion. |
| 266 PrefService* prefs = profile_->GetPrefs(); | 274 PrefService* prefs = profile_->GetPrefs(); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 533 | 541 |
| 534 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); | 542 MediaDeviceIDSalt::Reset(profile_->GetPrefs()); |
| 535 } | 543 } |
| 536 | 544 |
| 537 ////////////////////////////////////////////////////////////////////////////// | 545 ////////////////////////////////////////////////////////////////////////////// |
| 538 // REMOVE_DURABLE_PERMISSION | 546 // REMOVE_DURABLE_PERMISSION |
| 539 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { | 547 if (remove_mask & BrowsingDataRemover::REMOVE_DURABLE_PERMISSION) { |
| 540 HostContentSettingsMapFactory::GetForProfile(profile_) | 548 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 541 ->ClearSettingsForOneTypeWithPredicate( | 549 ->ClearSettingsForOneTypeWithPredicate( |
| 542 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, | 550 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, |
| 543 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 551 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 544 } | 552 } |
| 545 | 553 |
| 546 ////////////////////////////////////////////////////////////////////////////// | 554 ////////////////////////////////////////////////////////////////////////////// |
| 547 // REMOVE_SITE_USAGE_DATA | 555 // REMOVE_SITE_USAGE_DATA |
| 548 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { | 556 if (remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) { |
| 549 HostContentSettingsMapFactory::GetForProfile(profile_) | 557 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 550 ->ClearSettingsForOneTypeWithPredicate( | 558 ->ClearSettingsForOneTypeWithPredicate( |
| 551 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 559 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 552 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 560 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 553 } | 561 } |
| 554 | 562 |
| 555 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || | 563 if ((remove_mask & BrowsingDataRemover::REMOVE_SITE_USAGE_DATA) || |
| 556 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { | 564 (remove_mask & BrowsingDataRemover::REMOVE_HISTORY)) { |
| 557 HostContentSettingsMapFactory::GetForProfile(profile_) | 565 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 558 ->ClearSettingsForOneTypeWithPredicate( | 566 ->ClearSettingsForOneTypeWithPredicate( |
| 559 CONTENT_SETTINGS_TYPE_APP_BANNER, | 567 CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 560 base::Bind(&ForwardPrimaryPatternCallback, same_pattern_filter)); | 568 base::Bind(&WebsiteSettingsFilterAdapter, filter)); |
| 561 | 569 |
| 562 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); | 570 PermissionDecisionAutoBlocker::RemoveCountsByUrl(profile_, filter); |
| 563 } | 571 } |
| 564 | 572 |
| 565 ////////////////////////////////////////////////////////////////////////////// | 573 ////////////////////////////////////////////////////////////////////////////// |
| 566 // Password manager | 574 // Password manager |
| 567 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { | 575 if (remove_mask & BrowsingDataRemover::REMOVE_PASSWORDS) { |
| 568 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); | 576 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords")); |
| 569 password_manager::PasswordStore* password_store = | 577 password_manager::PasswordStore* password_store = |
| 570 PasswordStoreFactory::GetForProfile( | 578 PasswordStoreFactory::GetForProfile( |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 857 | 865 |
| 858 #if defined(OS_CHROMEOS) | 866 #if defined(OS_CHROMEOS) |
| 859 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( | 867 void ChromeBrowsingDataRemoverDelegate::OnClearPlatformKeys( |
| 860 chromeos::DBusMethodCallStatus call_status, | 868 chromeos::DBusMethodCallStatus call_status, |
| 861 bool result) { | 869 bool result) { |
| 862 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) | 870 LOG_IF(ERROR, call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) |
| 863 << "Failed to clear platform keys."; | 871 << "Failed to clear platform keys."; |
| 864 clear_platform_keys_.GetCompletionCallback().Run(); | 872 clear_platform_keys_.GetCompletionCallback().Run(); |
| 865 } | 873 } |
| 866 #endif | 874 #endif |
| OLD | NEW |