| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 #include "net/http/transport_security_state.h" | 75 #include "net/http/transport_security_state.h" |
| 76 #include "net/ssl/channel_id_service.h" | 76 #include "net/ssl/channel_id_service.h" |
| 77 #include "net/ssl/channel_id_store.h" | 77 #include "net/ssl/channel_id_store.h" |
| 78 #include "net/url_request/url_request_context.h" | 78 #include "net/url_request/url_request_context.h" |
| 79 #include "net/url_request/url_request_context_getter.h" | 79 #include "net/url_request/url_request_context_getter.h" |
| 80 #include "storage/browser/quota/special_storage_policy.h" | 80 #include "storage/browser/quota/special_storage_policy.h" |
| 81 #include "url/origin.h" | 81 #include "url/origin.h" |
| 82 | 82 |
| 83 #if BUILDFLAG(ANDROID_JAVA_UI) | 83 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 84 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 84 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 85 #include "chrome/browser/android/webapps/webapp_registry.h" | |
| 86 #include "chrome/browser/precache/precache_manager_factory.h" | 85 #include "chrome/browser/precache/precache_manager_factory.h" |
| 87 #include "components/offline_pages/offline_page_feature.h" | 86 #include "components/offline_pages/offline_page_feature.h" |
| 88 #include "components/offline_pages/offline_page_model.h" | 87 #include "components/offline_pages/offline_page_model.h" |
| 89 #include "components/precache/content/precache_manager.h" | 88 #include "components/precache/content/precache_manager.h" |
| 89 #include "content/public/browser/android/java_interfaces.h" |
| 90 #include "services/shell/public/cpp/interface_provider.h" |
| 90 #endif | 91 #endif |
| 91 | 92 |
| 92 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
| 93 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 94 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 94 #include "chromeos/attestation/attestation_constants.h" | 95 #include "chromeos/attestation/attestation_constants.h" |
| 95 #include "chromeos/cryptohome/cryptohome_parameters.h" | 96 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 96 #include "chromeos/dbus/cryptohome_client.h" | 97 #include "chromeos/dbus/cryptohome_client.h" |
| 97 #include "chromeos/dbus/dbus_thread_manager.h" | 98 #include "chromeos/dbus/dbus_thread_manager.h" |
| 98 #include "components/user_manager/user.h" | 99 #include "components/user_manager/user.h" |
| 99 #endif | 100 #endif |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 const base::Closure& callback) { | 241 const base::Closure& callback) { |
| 241 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 242 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 242 net::ChannelIDService* channel_id_service = | 243 net::ChannelIDService* channel_id_service = |
| 243 rq_context->GetURLRequestContext()->channel_id_service(); | 244 rq_context->GetURLRequestContext()->channel_id_service(); |
| 244 channel_id_service->GetChannelIDStore()->DeleteForDomainsCreatedBetween( | 245 channel_id_service->GetChannelIDStore()->DeleteForDomainsCreatedBetween( |
| 245 domain_predicate, delete_begin, delete_end, | 246 domain_predicate, delete_begin, delete_end, |
| 246 base::Bind(&OnClearedChannelIDsOnIOThread, | 247 base::Bind(&OnClearedChannelIDsOnIOThread, |
| 247 base::RetainedRef(std::move(rq_context)), callback)); | 248 base::RetainedRef(std::move(rq_context)), callback)); |
| 248 } | 249 } |
| 249 | 250 |
| 251 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 252 mojom::WebappRegistryPtr GetDefaultWebappRegistryPtr() { |
| 253 mojom::WebappRegistryPtr webapp_registry; |
| 254 content::GetGlobalJavaInterfaces()->GetInterface(&webapp_registry); |
| 255 return webapp_registry; |
| 256 } |
| 257 #endif |
| 258 |
| 250 } // namespace | 259 } // namespace |
| 251 | 260 |
| 252 BrowsingDataRemover::CompletionInhibitor* | 261 BrowsingDataRemover::CompletionInhibitor* |
| 253 BrowsingDataRemover::completion_inhibitor_ = nullptr; | 262 BrowsingDataRemover::completion_inhibitor_ = nullptr; |
| 254 | 263 |
| 255 bool BrowsingDataRemover::TimeRange::operator==( | 264 bool BrowsingDataRemover::TimeRange::operator==( |
| 256 const BrowsingDataRemover::TimeRange& other) const { | 265 const BrowsingDataRemover::TimeRange& other) const { |
| 257 return begin == other.begin && end == other.end; | 266 return begin == other.begin && end == other.end; |
| 258 } | 267 } |
| 259 | 268 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 285 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | 294 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); |
| 286 } | 295 } |
| 287 | 296 |
| 288 BrowsingDataRemover::BrowsingDataRemover( | 297 BrowsingDataRemover::BrowsingDataRemover( |
| 289 content::BrowserContext* browser_context) | 298 content::BrowserContext* browser_context) |
| 290 : profile_(Profile::FromBrowserContext(browser_context)), | 299 : profile_(Profile::FromBrowserContext(browser_context)), |
| 291 is_removing_(false), | 300 is_removing_(false), |
| 292 remove_mask_(-1), | 301 remove_mask_(-1), |
| 293 origin_type_mask_(-1), | 302 origin_type_mask_(-1), |
| 294 #if BUILDFLAG(ANDROID_JAVA_UI) | 303 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 295 webapp_registry_(new WebappRegistry()), | 304 webapp_registry_(GetDefaultWebappRegistryPtr()), |
| 296 #endif | 305 #endif |
| 297 weak_ptr_factory_(this) { | 306 weak_ptr_factory_(this) { |
| 298 DCHECK(browser_context); | 307 DCHECK(browser_context); |
| 299 } | 308 } |
| 300 | 309 |
| 301 BrowsingDataRemover::~BrowsingDataRemover() { | 310 BrowsingDataRemover::~BrowsingDataRemover() { |
| 302 // If we are still removing data, notify observers so they can remove | 311 // If we are still removing data, notify observers so they can remove |
| 303 // themselves from the observer list. | 312 // themselves from the observer list. |
| 304 // TODO(bauerb): If it becomes a problem that browsing data might not actually | 313 // TODO(bauerb): If it becomes a problem that browsing data might not actually |
| 305 // be fully cleared when an observer is notified, add a success flag. | 314 // be fully cleared when an observer is notified, add a success flag. |
| (...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor, | 979 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor, |
| 971 weak_ptr_factory_.GetWeakPtr())); | 980 weak_ptr_factory_.GetWeakPtr())); |
| 972 } | 981 } |
| 973 } | 982 } |
| 974 | 983 |
| 975 #if BUILDFLAG(ANDROID_JAVA_UI) | 984 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 976 if (remove_mask & REMOVE_WEBAPP_DATA) { | 985 if (remove_mask & REMOVE_WEBAPP_DATA) { |
| 977 // Clear all data associated with registered webapps. The webapp_registry | 986 // Clear all data associated with registered webapps. The webapp_registry |
| 978 // makes a JNI call into a Java-side AsyncTask, so don't wait for the reply. | 987 // makes a JNI call into a Java-side AsyncTask, so don't wait for the reply. |
| 979 waiting_for_clear_webapp_data_ = true; | 988 waiting_for_clear_webapp_data_ = true; |
| 980 webapp_registry_->UnregisterWebapps( | 989 webapp_registry_->UnregisterAllWebapps( |
| 981 base::Bind(&BrowsingDataRemover::OnClearedWebappData, | 990 base::Bind(&BrowsingDataRemover::OnClearedWebappData, |
| 982 weak_ptr_factory_.GetWeakPtr())); | 991 weak_ptr_factory_.GetWeakPtr())); |
| 983 } | 992 } |
| 984 | 993 |
| 985 // For now we're considering offline pages as cache, so if we're removing | 994 // For now we're considering offline pages as cache, so if we're removing |
| 986 // cache we should remove offline pages as well. | 995 // cache we should remove offline pages as well. |
| 987 if ((remove_mask & REMOVE_CACHE) && offline_pages::IsOfflinePagesEnabled()) { | 996 if ((remove_mask & REMOVE_CACHE) && offline_pages::IsOfflinePagesEnabled()) { |
| 988 waiting_for_clear_offline_page_data_ = true; | 997 waiting_for_clear_offline_page_data_ = true; |
| 989 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 998 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 990 ->DeletePagesByURLPredicate( | 999 ->DeletePagesByURLPredicate( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1021 observer_list_.RemoveObserver(observer); | 1030 observer_list_.RemoveObserver(observer); |
| 1022 } | 1031 } |
| 1023 | 1032 |
| 1024 void BrowsingDataRemover::OverrideStoragePartitionForTesting( | 1033 void BrowsingDataRemover::OverrideStoragePartitionForTesting( |
| 1025 content::StoragePartition* storage_partition) { | 1034 content::StoragePartition* storage_partition) { |
| 1026 storage_partition_for_testing_ = storage_partition; | 1035 storage_partition_for_testing_ = storage_partition; |
| 1027 } | 1036 } |
| 1028 | 1037 |
| 1029 #if BUILDFLAG(ANDROID_JAVA_UI) | 1038 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 1030 void BrowsingDataRemover::OverrideWebappRegistryForTesting( | 1039 void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
| 1031 std::unique_ptr<WebappRegistry> webapp_registry) { | 1040 mojom::WebappRegistryPtr webapp_registry) { |
| 1032 webapp_registry_.reset(webapp_registry.release()); | 1041 webapp_registry_ = std::move(webapp_registry); |
| 1033 } | 1042 } |
| 1034 #endif | 1043 #endif |
| 1035 | 1044 |
| 1036 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { | 1045 const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { |
| 1037 return delete_begin_; | 1046 return delete_begin_; |
| 1038 } | 1047 } |
| 1039 | 1048 |
| 1040 const base::Time& BrowsingDataRemover::GetLastUsedEndTime() { | 1049 const base::Time& BrowsingDataRemover::GetLastUsedEndTime() { |
| 1041 return delete_end_; | 1050 return delete_end_; |
| 1042 } | 1051 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1291 waiting_for_clear_offline_page_data_ = false; | 1300 waiting_for_clear_offline_page_data_ = false; |
| 1292 NotifyIfDone(); | 1301 NotifyIfDone(); |
| 1293 } | 1302 } |
| 1294 #endif | 1303 #endif |
| 1295 | 1304 |
| 1296 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { | 1305 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() { |
| 1297 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 1306 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 1298 waiting_for_clear_domain_reliability_monitor_ = false; | 1307 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1299 NotifyIfDone(); | 1308 NotifyIfDone(); |
| 1300 } | 1309 } |
| OLD | NEW |