| 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); | 295 return TimeRange(CalculateBeginDeleteTime(period), base::Time::Max()); |
| 296 } | 296 } |
| 297 | 297 |
| 298 BrowsingDataRemover::BrowsingDataRemover( | 298 BrowsingDataRemover::BrowsingDataRemover( |
| 299 content::BrowserContext* browser_context) | 299 content::BrowserContext* browser_context) |
| 300 : profile_(Profile::FromBrowserContext(browser_context)), | 300 : profile_(Profile::FromBrowserContext(browser_context)), |
| 301 is_removing_(false), | 301 is_removing_(false), |
| 302 main_context_getter_(browser_context->GetRequestContext()), | 302 main_context_getter_(browser_context->GetRequestContext()), |
| 303 media_context_getter_(browser_context->GetMediaRequestContext()), | 303 media_context_getter_(browser_context->GetMediaRequestContext()), |
| 304 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 305 webapp_registry_(new WebappRegistry()), |
| 306 #endif |
| 304 weak_ptr_factory_(this) { | 307 weak_ptr_factory_(this) { |
| 305 DCHECK(browser_context); | 308 DCHECK(browser_context); |
| 306 } | 309 } |
| 307 | 310 |
| 308 BrowsingDataRemover::~BrowsingDataRemover() { | 311 BrowsingDataRemover::~BrowsingDataRemover() { |
| 309 // If we are still removing data, notify observers so they can remove | 312 // If we are still removing data, notify observers so they can remove |
| 310 // themselves from the observer list. | 313 // themselves from the observer list. |
| 311 // TODO(bauerb): If it becomes a problem that browsing data might not actually | 314 // TODO(bauerb): If it becomes a problem that browsing data might not actually |
| 312 // be fully cleared when an observer is notified, add a success flag. | 315 // be fully cleared when an observer is notified, add a success flag. |
| 313 if (is_removing_) | 316 if (is_removing_) |
| (...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 service->ClearBrowsingData( | 923 service->ClearBrowsingData( |
| 921 mode, | 924 mode, |
| 922 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor, | 925 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor, |
| 923 weak_ptr_factory_.GetWeakPtr())); | 926 weak_ptr_factory_.GetWeakPtr())); |
| 924 } | 927 } |
| 925 } | 928 } |
| 926 | 929 |
| 927 #if BUILDFLAG(ANDROID_JAVA_UI) | 930 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 928 if (remove_mask & REMOVE_WEBAPP_DATA) { | 931 if (remove_mask & REMOVE_WEBAPP_DATA) { |
| 929 waiting_for_clear_webapp_data_ = true; | 932 waiting_for_clear_webapp_data_ = true; |
| 930 WebappRegistry::UnregisterWebapps( | 933 webapp_registry_->UnregisterWebapps( |
| 931 base::Bind(&BrowsingDataRemover::OnClearedWebappData, | 934 base::Bind(&BrowsingDataRemover::OnClearedWebappData, |
| 932 weak_ptr_factory_.GetWeakPtr())); | 935 weak_ptr_factory_.GetWeakPtr())); |
| 933 } | 936 } |
| 934 | 937 |
| 935 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && | 938 if ((remove_mask & REMOVE_OFFLINE_PAGE_DATA) && |
| 936 offline_pages::IsOfflinePagesEnabled()) { | 939 offline_pages::IsOfflinePagesEnabled()) { |
| 937 waiting_for_clear_offline_page_data_ = true; | 940 waiting_for_clear_offline_page_data_ = true; |
| 938 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) | 941 offline_pages::OfflinePageModelFactory::GetForBrowserContext(profile_) |
| 939 ->ClearAll(base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, | 942 ->ClearAll(base::Bind(&BrowsingDataRemover::OnClearedOfflinePageData, |
| 940 weak_ptr_factory_.GetWeakPtr())); | 943 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 962 | 965 |
| 963 void BrowsingDataRemover::RemoveObserver(Observer* observer) { | 966 void BrowsingDataRemover::RemoveObserver(Observer* observer) { |
| 964 observer_list_.RemoveObserver(observer); | 967 observer_list_.RemoveObserver(observer); |
| 965 } | 968 } |
| 966 | 969 |
| 967 void BrowsingDataRemover::OverrideStoragePartitionForTesting( | 970 void BrowsingDataRemover::OverrideStoragePartitionForTesting( |
| 968 content::StoragePartition* storage_partition) { | 971 content::StoragePartition* storage_partition) { |
| 969 storage_partition_for_testing_ = storage_partition; | 972 storage_partition_for_testing_ = storage_partition; |
| 970 } | 973 } |
| 971 | 974 |
| 975 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 976 void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
| 977 scoped_ptr<WebappRegistry> webapp_registry) { |
| 978 webapp_registry_.reset(webapp_registry.release()); |
| 979 } |
| 980 #endif |
| 981 |
| 972 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( | 982 base::Time BrowsingDataRemover::CalculateBeginDeleteTime( |
| 973 TimePeriod time_period) { | 983 TimePeriod time_period) { |
| 974 base::TimeDelta diff; | 984 base::TimeDelta diff; |
| 975 base::Time delete_begin_time = base::Time::Now(); | 985 base::Time delete_begin_time = base::Time::Now(); |
| 976 switch (time_period) { | 986 switch (time_period) { |
| 977 case LAST_HOUR: | 987 case LAST_HOUR: |
| 978 diff = base::TimeDelta::FromHours(1); | 988 diff = base::TimeDelta::FromHours(1); |
| 979 break; | 989 break; |
| 980 case LAST_DAY: | 990 case LAST_DAY: |
| 981 diff = base::TimeDelta::FromHours(24); | 991 diff = base::TimeDelta::FromHours(24); |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 waiting_for_clear_domain_reliability_monitor_ = false; | 1230 waiting_for_clear_domain_reliability_monitor_ = false; |
| 1221 NotifyIfDone(); | 1231 NotifyIfDone(); |
| 1222 } | 1232 } |
| 1223 | 1233 |
| 1224 // static | 1234 // static |
| 1225 BrowsingDataRemover::CallbackSubscription | 1235 BrowsingDataRemover::CallbackSubscription |
| 1226 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 1236 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
| 1227 const BrowsingDataRemover::Callback& callback) { | 1237 const BrowsingDataRemover::Callback& callback) { |
| 1228 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); | 1238 return GetOnBrowsingDataRemovedCallbacks()->Add(callback); |
| 1229 } | 1239 } |
| OLD | NEW |