Index: chrome/browser/browsing_data/browsing_data_remover.cc |
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc |
index cf73ad4c134a14fae4fa4b4093eef0c4b7799baa..241969842bb12a8aa9b11177be9a9348666395df 100644 |
--- a/chrome/browser/browsing_data/browsing_data_remover.cc |
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc |
@@ -114,6 +114,10 @@ |
#include "chrome/browser/media/webrtc_log_util.h" |
#endif |
+#if defined(ENABLE_PLUGINS) |
Bernhard Bauer
2016/08/18 18:35:59
Move this between ENABLE_EXTENSIONS and ENABLE_SES
msramek
2016/08/19 11:16:46
Done. Also moved the "OS_CHROMEOS" section down. I
|
+#include "chrome/browser/browsing_data/browsing_data_flash_lso_helper.h" |
+#endif |
+ |
using base::UserMetricsAction; |
using content::BrowserContext; |
using content::BrowserThread; |
@@ -289,9 +293,12 @@ BrowsingDataRemover::TimeRange BrowsingDataRemover::Period( |
BrowsingDataRemover::BrowsingDataRemover( |
content::BrowserContext* browser_context) |
: profile_(Profile::FromBrowserContext(browser_context)), |
- is_removing_(false), |
remove_mask_(-1), |
origin_type_mask_(-1), |
+ is_removing_(false), |
+#if defined(ENABLE_PLUGINS) |
+ flash_lso_helper_(BrowsingDataFlashLSOHelper::Create(profile_)), |
+#endif |
#if BUILDFLAG(ANDROID_JAVA_UI) |
webapp_registry_(new WebappRegistry()), |
#endif |
@@ -773,17 +780,26 @@ void BrowsingDataRemover::RemoveImpl( |
if (remove_mask & REMOVE_PLUGIN_DATA && |
origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) { |
content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData")); |
+ waiting_for_clear_plugin_data_count_ = 1; |
- waiting_for_clear_plugin_data_ = true; |
- DCHECK(!plugin_data_remover_); |
- plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); |
- base::WaitableEvent* event = |
- plugin_data_remover_->StartRemoving(delete_begin_); |
+ if (filter_builder.IsEmptyBlacklist()) { |
+ DCHECK(!plugin_data_remover_); |
+ plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_)); |
+ base::WaitableEvent* event = |
+ plugin_data_remover_->StartRemoving(delete_begin_); |
- base::WaitableEventWatcher::EventCallback watcher_callback = |
- base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, |
- weak_ptr_factory_.GetWeakPtr()); |
- watcher_.StartWatching(event, watcher_callback); |
+ base::WaitableEventWatcher::EventCallback watcher_callback = |
+ base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled, |
+ weak_ptr_factory_.GetWeakPtr()); |
+ watcher_.StartWatching(event, watcher_callback); |
+ } else { |
+ // TODO(msramek): Store filters from the currently executed task on the |
+ // object to avoid having to copy them to callback methods. |
+ flash_lso_helper_->StartFetching(base::Bind( |
+ &BrowsingDataRemover::OnSitesWithFlashDataFetched, |
+ weak_ptr_factory_.GetWeakPtr(), |
+ filter_builder.BuildPluginFilter())); |
+ } |
} |
#endif |
@@ -1108,6 +1124,13 @@ void BrowsingDataRemover::OverrideWebappRegistryForTesting( |
} |
#endif |
+#if defined(ENABLE_PLUGINS) |
+void BrowsingDataRemover::OverrideFlashLSOHelperForTesting( |
+ scoped_refptr<BrowsingDataFlashLSOHelper> flash_lso_helper) { |
+ flash_lso_helper_ = flash_lso_helper; |
+} |
+#endif |
+ |
const base::Time& BrowsingDataRemover::GetLastUsedBeginTime() { |
return delete_begin_; |
} |
@@ -1169,7 +1192,8 @@ bool BrowsingDataRemover::AllDone() { |
!waiting_for_clear_network_predictor_ && |
!waiting_for_clear_networking_history_ && |
!waiting_for_clear_passwords_ && !waiting_for_clear_passwords_stats_ && |
- !waiting_for_clear_platform_keys_ && !waiting_for_clear_plugin_data_ && |
+ !waiting_for_clear_platform_keys_ && |
+ !waiting_for_clear_plugin_data_count_ && |
!waiting_for_clear_pnacl_cache_ && |
#if BUILDFLAG(ANDROID_JAVA_UI) |
!waiting_for_clear_precache_history_ && |
@@ -1298,12 +1322,44 @@ void BrowsingDataRemover::ClearedPnaclCache() { |
void BrowsingDataRemover::OnWaitableEventSignaled( |
base::WaitableEvent* waitable_event) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- waiting_for_clear_plugin_data_ = false; |
+ |
+ --waiting_for_clear_plugin_data_count_; |
Bernhard Bauer
2016/08/18 18:35:59
I would use post-increment – the compiler should b
msramek
2016/08/19 11:16:46
I replaced this part, but changed it in OnFlashDat
Bernhard Bauer
2016/08/19 16:29:39
Yeah, if you think about it, C++ means incremental
|
+ DCHECK(!waiting_for_clear_plugin_data_count_); |
Bernhard Bauer
2016/08/18 18:35:59
So really, you are transitioning from 1 to 0? Why
msramek
2016/08/19 11:16:46
Changed to DCHECK that it's 1, then set it to 0.
|
+ |
plugin_data_remover_.reset(); |
watcher_.StopWatching(); |
NotifyIfDone(); |
} |
+void BrowsingDataRemover::OnSitesWithFlashDataFetched( |
+ base::Callback<bool(const std::string&)> plugin_filter, |
+ const std::vector<std::string>& sites) { |
+ --waiting_for_clear_plugin_data_count_; |
+ DCHECK(!waiting_for_clear_plugin_data_count_); |
+ |
+ std::vector<std::string> sites_to_delete; |
+ for (const std::string& site : sites) { |
+ if (plugin_filter.Run(site)) |
+ sites_to_delete.push_back(site); |
+ } |
+ |
+ waiting_for_clear_plugin_data_count_ = sites_to_delete.size(); |
+ |
+ for (const std::string& site : sites_to_delete) { |
+ flash_lso_helper_->DeleteFlashLSOsForSite( |
+ site, |
+ base::Bind(&BrowsingDataRemover::OnFlashDataDeleted, |
+ weak_ptr_factory_.GetWeakPtr())); |
+ } |
+ |
+ NotifyIfDone(); |
+} |
+ |
+void BrowsingDataRemover::OnFlashDataDeleted() { |
+ --waiting_for_clear_plugin_data_count_; |
+ NotifyIfDone(); |
+} |
+ |
void BrowsingDataRemover::OnDeauthorizeFlashContentLicensesCompleted( |
uint32_t request_id, |
bool /* success */) { |