Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / browsing_data / browsing_data_remover.cc
blob4b255eaeb4e9a38d46033299172d0b80f2e8bf91
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
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
7 #include <map>
8 #include <set>
9 #include <string>
11 #include "base/bind.h"
12 #include "base/bind_helpers.h"
13 #include "base/callback.h"
14 #include "base/logging.h"
15 #include "base/metrics/histogram_macros.h"
16 #include "base/prefs/pref_service.h"
17 #include "chrome/browser/autofill/personal_data_manager_factory.h"
18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/browsing_data/browsing_data_helper.h"
20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/domain_reliability/service_factory.h"
22 #include "chrome/browser/download/download_prefs.h"
23 #include "chrome/browser/download/download_service_factory.h"
24 #include "chrome/browser/history/history_service_factory.h"
25 #include "chrome/browser/history/web_history_service_factory.h"
26 #include "chrome/browser/io_thread.h"
27 #include "chrome/browser/media/media_device_id_salt.h"
28 #include "chrome/browser/net/predictor.h"
29 #include "chrome/browser/password_manager/password_store_factory.h"
30 #include "chrome/browser/prerender/prerender_manager.h"
31 #include "chrome/browser/prerender/prerender_manager_factory.h"
32 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
34 #include "chrome/browser/search_engines/template_url_service_factory.h"
35 #include "chrome/browser/sessions/session_service.h"
36 #include "chrome/browser/sessions/session_service_factory.h"
37 #include "chrome/browser/sessions/tab_restore_service.h"
38 #include "chrome/browser/sessions/tab_restore_service_factory.h"
39 #include "chrome/browser/web_data_service_factory.h"
40 #include "chrome/common/pref_names.h"
41 #include "chrome/common/url_constants.h"
42 #include "components/autofill/core/browser/personal_data_manager.h"
43 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
44 #include "components/browsing_data/storage_partition_http_cache_data_remover.h"
45 #include "components/content_settings/core/browser/host_content_settings_map.h"
46 #include "components/domain_reliability/service.h"
47 #include "components/history/core/browser/history_service.h"
48 #include "components/nacl/browser/nacl_browser.h"
49 #include "components/nacl/browser/pnacl_host.h"
50 #include "components/omnibox/browser/omnibox_pref_names.h"
51 #include "components/password_manager/core/browser/password_store.h"
52 #include "components/power/origin_power_map.h"
53 #include "components/power/origin_power_map_factory.h"
54 #include "components/search_engines/template_url_service.h"
55 #include "components/web_cache/browser/web_cache_manager.h"
56 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/download_manager.h"
58 #include "content/public/browser/notification_service.h"
59 #include "content/public/browser/plugin_data_remover.h"
60 #include "content/public/browser/ssl_host_state_delegate.h"
61 #include "content/public/browser/storage_partition.h"
62 #include "content/public/browser/user_metrics.h"
63 #include "net/base/net_errors.h"
64 #include "net/cookies/cookie_store.h"
65 #include "net/http/transport_security_state.h"
66 #include "net/ssl/channel_id_service.h"
67 #include "net/ssl/channel_id_store.h"
68 #include "net/url_request/url_request_context.h"
69 #include "net/url_request/url_request_context_getter.h"
70 #include "storage/browser/quota/special_storage_policy.h"
71 #include "url/origin.h"
73 #if defined(OS_ANDROID)
74 #include "chrome/browser/precache/precache_manager_factory.h"
75 #include "components/precache/content/precache_manager.h"
76 #endif
78 #if defined(OS_CHROMEOS)
79 #include "chrome/browser/chromeos/profiles/profile_helper.h"
80 #include "chromeos/attestation/attestation_constants.h"
81 #include "chromeos/dbus/cryptohome_client.h"
82 #include "chromeos/dbus/dbus_thread_manager.h"
83 #include "components/user_manager/user.h"
84 #endif
86 #if defined(ENABLE_EXTENSIONS)
87 #include "chrome/browser/apps/ephemeral_app_service.h"
88 #include "chrome/browser/extensions/activity_log/activity_log.h"
89 #include "chrome/browser/extensions/extension_service.h"
90 #include "chrome/browser/extensions/extension_special_storage_policy.h"
91 #include "extensions/browser/extension_prefs.h"
92 #endif
94 #if defined(ENABLE_WEBRTC)
95 #include "chrome/browser/media/webrtc_log_list.h"
96 #include "chrome/browser/media/webrtc_log_util.h"
97 #endif
99 using base::UserMetricsAction;
100 using content::BrowserContext;
101 using content::BrowserThread;
102 using content::DOMStorageContext;
104 namespace {
106 using CallbackList =
107 base::CallbackList<void(const BrowsingDataRemover::NotificationDetails&)>;
109 // Contains all registered callbacks for browsing data removed notifications.
110 CallbackList* g_on_browsing_data_removed_callbacks = nullptr;
112 // Accessor for |*g_on_browsing_data_removed_callbacks|. Creates a new object
113 // the first time so that it always returns a valid object.
114 CallbackList* GetOnBrowsingDataRemovedCallbacks() {
115 if (!g_on_browsing_data_removed_callbacks)
116 g_on_browsing_data_removed_callbacks = new CallbackList();
117 return g_on_browsing_data_removed_callbacks;
120 // A helper enum to report the deletion of cookies and/or cache. Do not reorder
121 // the entries, as this enum is passed to UMA.
122 enum CookieOrCacheDeletionChoice {
123 NEITHER_COOKIES_NOR_CACHE,
124 ONLY_COOKIES,
125 ONLY_CACHE,
126 BOTH_COOKIES_AND_CACHE,
127 MAX_CHOICE_VALUE
130 } // namespace
132 bool BrowsingDataRemover::is_removing_ = false;
134 BrowsingDataRemover::CompletionInhibitor*
135 BrowsingDataRemover::completion_inhibitor_ = NULL;
137 // Helper to create callback for BrowsingDataRemover::DoesOriginMatchMask.
138 // Static.
139 bool DoesOriginMatchMask(
140 int origin_type_mask,
141 const GURL& origin,
142 storage::SpecialStoragePolicy* special_storage_policy) {
143 return BrowsingDataHelper::DoesOriginMatchMask(
144 origin, origin_type_mask, special_storage_policy);
147 BrowsingDataRemover::NotificationDetails::NotificationDetails()
148 : removal_begin(base::Time()),
149 removal_mask(-1),
150 origin_type_mask(-1) {
153 BrowsingDataRemover::NotificationDetails::NotificationDetails(
154 const BrowsingDataRemover::NotificationDetails& details)
155 : removal_begin(details.removal_begin),
156 removal_mask(details.removal_mask),
157 origin_type_mask(details.origin_type_mask) {
160 BrowsingDataRemover::NotificationDetails::NotificationDetails(
161 base::Time removal_begin,
162 int removal_mask,
163 int origin_type_mask)
164 : removal_begin(removal_begin),
165 removal_mask(removal_mask),
166 origin_type_mask(origin_type_mask) {
169 BrowsingDataRemover::NotificationDetails::~NotificationDetails() {}
171 // Static.
172 BrowsingDataRemover* BrowsingDataRemover::CreateForUnboundedRange(
173 Profile* profile) {
174 return new BrowsingDataRemover(profile, base::Time(), base::Time::Max());
177 // Static.
178 BrowsingDataRemover* BrowsingDataRemover::CreateForRange(Profile* profile,
179 base::Time start, base::Time end) {
180 return new BrowsingDataRemover(profile, start, end);
183 // Static.
184 BrowsingDataRemover* BrowsingDataRemover::CreateForPeriod(Profile* profile,
185 TimePeriod period) {
186 switch (period) {
187 case LAST_HOUR:
188 content::RecordAction(
189 UserMetricsAction("ClearBrowsingData_LastHour"));
190 break;
191 case LAST_DAY:
192 content::RecordAction(
193 UserMetricsAction("ClearBrowsingData_LastDay"));
194 break;
195 case LAST_WEEK:
196 content::RecordAction(
197 UserMetricsAction("ClearBrowsingData_LastWeek"));
198 break;
199 case FOUR_WEEKS:
200 content::RecordAction(
201 UserMetricsAction("ClearBrowsingData_LastMonth"));
202 break;
203 case EVERYTHING:
204 content::RecordAction(
205 UserMetricsAction("ClearBrowsingData_Everything"));
206 break;
208 return new BrowsingDataRemover(profile,
209 BrowsingDataRemover::CalculateBeginDeleteTime(period),
210 base::Time::Max());
213 BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
214 base::Time delete_begin,
215 base::Time delete_end)
216 : profile_(profile),
217 delete_begin_(delete_begin),
218 delete_end_(delete_end),
219 main_context_getter_(profile->GetRequestContext()),
220 media_context_getter_(profile->GetMediaRequestContext()),
221 deauthorize_content_licenses_request_id_(0),
222 waiting_for_clear_autofill_origin_urls_(false),
223 waiting_for_clear_cache_(false),
224 waiting_for_clear_channel_ids_(false),
225 waiting_for_clear_content_licenses_(false),
226 waiting_for_clear_cookies_count_(0),
227 waiting_for_clear_domain_reliability_monitor_(false),
228 waiting_for_clear_form_(false),
229 waiting_for_clear_history_(false),
230 waiting_for_clear_hostname_resolution_cache_(false),
231 waiting_for_clear_keyword_data_(false),
232 waiting_for_clear_nacl_cache_(false),
233 waiting_for_clear_network_predictor_(false),
234 waiting_for_clear_networking_history_(false),
235 waiting_for_clear_passwords_(false),
236 waiting_for_clear_platform_keys_(false),
237 waiting_for_clear_plugin_data_(false),
238 waiting_for_clear_pnacl_cache_(false),
239 #if defined(OS_ANDROID)
240 waiting_for_clear_precache_history_(false),
241 #endif
242 waiting_for_clear_storage_partition_data_(false),
243 #if defined(ENABLE_WEBRTC)
244 waiting_for_clear_webrtc_logs_(false),
245 #endif
246 remove_mask_(0),
247 origin_type_mask_(0),
248 storage_partition_for_testing_(NULL) {
249 DCHECK(profile);
250 // crbug.com/140910: Many places were calling this with base::Time() as
251 // delete_end, even though they should've used base::Time::Max(). Work around
252 // it here. New code should use base::Time::Max().
253 DCHECK(delete_end_ != base::Time());
254 if (delete_end_ == base::Time())
255 delete_end_ = base::Time::Max();
258 BrowsingDataRemover::~BrowsingDataRemover() {
259 DCHECK(AllDone());
262 // Static.
263 void BrowsingDataRemover::set_removing(bool is_removing) {
264 DCHECK(is_removing_ != is_removing);
265 is_removing_ = is_removing;
268 void BrowsingDataRemover::Remove(int remove_mask, int origin_type_mask) {
269 RemoveImpl(remove_mask, GURL(), origin_type_mask);
272 void BrowsingDataRemover::RemoveImpl(int remove_mask,
273 const GURL& remove_url,
274 int origin_type_mask) {
275 DCHECK_CURRENTLY_ON(BrowserThread::UI);
276 set_removing(true);
277 remove_mask_ = remove_mask;
278 origin_type_mask_ = origin_type_mask;
279 url::Origin remove_origin(remove_url);
281 PrefService* prefs = profile_->GetPrefs();
282 bool may_delete_history = prefs->GetBoolean(
283 prefs::kAllowDeletingBrowserHistory);
285 // All the UI entry points into the BrowsingDataRemover should be disabled,
286 // but this will fire if something was missed or added.
287 DCHECK(may_delete_history || (remove_mask & REMOVE_NOCHECKS) ||
288 (!(remove_mask & REMOVE_HISTORY) && !(remove_mask & REMOVE_DOWNLOADS)));
290 if (origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
291 content::RecordAction(
292 UserMetricsAction("ClearBrowsingData_MaskContainsUnprotectedWeb"));
294 if (origin_type_mask_ & BrowsingDataHelper::PROTECTED_WEB) {
295 content::RecordAction(
296 UserMetricsAction("ClearBrowsingData_MaskContainsProtectedWeb"));
298 if (origin_type_mask_ & BrowsingDataHelper::EXTENSION) {
299 content::RecordAction(
300 UserMetricsAction("ClearBrowsingData_MaskContainsExtension"));
302 // If this fires, we added a new BrowsingDataHelper::OriginTypeMask without
303 // updating the user metrics above.
304 static_assert(
305 BrowsingDataHelper::ALL == (BrowsingDataHelper::UNPROTECTED_WEB |
306 BrowsingDataHelper::PROTECTED_WEB |
307 BrowsingDataHelper::EXTENSION),
308 "OriginTypeMask has been updated without updating user metrics");
310 if ((remove_mask & REMOVE_HISTORY) && may_delete_history) {
311 history::HistoryService* history_service =
312 HistoryServiceFactory::GetForProfile(
313 profile_, ServiceAccessType::EXPLICIT_ACCESS);
314 if (history_service) {
315 std::set<GURL> restrict_urls;
316 if (!remove_url.is_empty())
317 restrict_urls.insert(remove_url);
318 content::RecordAction(UserMetricsAction("ClearBrowsingData_History"));
319 waiting_for_clear_history_ = true;
321 history_service->ExpireLocalAndRemoteHistoryBetween(
322 WebHistoryServiceFactory::GetForProfile(profile_),
323 restrict_urls, delete_begin_, delete_end_,
324 base::Bind(&BrowsingDataRemover::OnHistoryDeletionDone,
325 base::Unretained(this)),
326 &history_task_tracker_);
328 #if defined(ENABLE_EXTENSIONS)
329 // The extension activity contains details of which websites extensions
330 // were active on. It therefore indirectly stores details of websites a
331 // user has visited so best clean from here as well.
332 extensions::ActivityLog::GetInstance(profile_)->RemoveURLs(restrict_urls);
333 #endif
336 #if defined(ENABLE_EXTENSIONS)
337 // Clear launch times as they are a form of history.
338 extensions::ExtensionPrefs* extension_prefs =
339 extensions::ExtensionPrefs::Get(profile_);
340 extension_prefs->ClearLastLaunchTimes();
341 #endif
343 // The power consumption history by origin contains details of websites
344 // that were visited.
345 power::OriginPowerMap* origin_power_map =
346 power::OriginPowerMapFactory::GetForBrowserContext(profile_);
347 if (origin_power_map)
348 origin_power_map->ClearOriginMap();
350 // Need to clear the host cache and accumulated speculative data, as it also
351 // reveals some history: we have no mechanism to track when these items were
352 // created, so we'll clear them all. Better safe than sorry.
353 if (g_browser_process->io_thread()) {
354 waiting_for_clear_hostname_resolution_cache_ = true;
355 BrowserThread::PostTask(
356 BrowserThread::IO, FROM_HERE,
357 base::Bind(
358 &BrowsingDataRemover::ClearHostnameResolutionCacheOnIOThread,
359 base::Unretained(this),
360 g_browser_process->io_thread()));
362 if (profile_->GetNetworkPredictor()) {
363 waiting_for_clear_network_predictor_ = true;
364 BrowserThread::PostTask(
365 BrowserThread::IO, FROM_HERE,
366 base::Bind(&BrowsingDataRemover::ClearNetworkPredictorOnIOThread,
367 base::Unretained(this),
368 profile_->GetNetworkPredictor()));
371 // As part of history deletion we also delete the auto-generated keywords.
372 TemplateURLService* keywords_model =
373 TemplateURLServiceFactory::GetForProfile(profile_);
374 if (keywords_model && !keywords_model->loaded()) {
375 template_url_sub_ = keywords_model->RegisterOnLoadedCallback(
376 base::Bind(&BrowsingDataRemover::OnKeywordsLoaded,
377 base::Unretained(this)));
378 keywords_model->Load();
379 waiting_for_clear_keyword_data_ = true;
380 } else if (keywords_model) {
381 keywords_model->RemoveAutoGeneratedForOriginBetween(
382 remove_url, delete_begin_, delete_end_);
385 // The PrerenderManager keeps history of prerendered pages, so clear that.
386 // It also may have a prerendered page. If so, the page could be
387 // considered to have a small amount of historical information, so delete
388 // it, too.
389 prerender::PrerenderManager* prerender_manager =
390 prerender::PrerenderManagerFactory::GetForProfile(profile_);
391 if (prerender_manager) {
392 prerender_manager->ClearData(
393 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS |
394 prerender::PrerenderManager::CLEAR_PRERENDER_HISTORY);
397 // If the caller is removing history for all hosts, then clear ancillary
398 // historical information.
399 if (remove_url.is_empty()) {
400 // We also delete the list of recently closed tabs. Since these expire,
401 // they can't be more than a day old, so we can simply clear them all.
402 TabRestoreService* tab_service =
403 TabRestoreServiceFactory::GetForProfile(profile_);
404 if (tab_service) {
405 tab_service->ClearEntries();
406 tab_service->DeleteLastSession();
409 #if defined(ENABLE_SESSION_SERVICE)
410 // We also delete the last session when we delete the history.
411 SessionService* session_service =
412 SessionServiceFactory::GetForProfile(profile_);
413 if (session_service)
414 session_service->DeleteLastSession();
415 #endif
418 // The saved Autofill profiles and credit cards can include the origin from
419 // which these profiles and credit cards were learned. These are a form of
420 // history, so clear them as well.
421 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
422 WebDataServiceFactory::GetAutofillWebDataForProfile(
423 profile_, ServiceAccessType::EXPLICIT_ACCESS);
424 if (web_data_service.get()) {
425 waiting_for_clear_autofill_origin_urls_ = true;
426 web_data_service->RemoveOriginURLsModifiedBetween(
427 delete_begin_, delete_end_);
428 // The above calls are done on the UI thread but do their work on the DB
429 // thread. So wait for it.
430 BrowserThread::PostTaskAndReply(
431 BrowserThread::DB, FROM_HERE,
432 base::Bind(&base::DoNothing),
433 base::Bind(&BrowsingDataRemover::OnClearedAutofillOriginURLs,
434 base::Unretained(this)));
436 autofill::PersonalDataManager* data_manager =
437 autofill::PersonalDataManagerFactory::GetForProfile(profile_);
438 if (data_manager)
439 data_manager->Refresh();
442 #if defined(ENABLE_WEBRTC)
443 waiting_for_clear_webrtc_logs_ = true;
444 BrowserThread::PostTaskAndReply(
445 BrowserThread::FILE,
446 FROM_HERE,
447 base::Bind(
448 &WebRtcLogUtil::DeleteOldAndRecentWebRtcLogFiles,
449 WebRtcLogList::GetWebRtcLogDirectoryForProfile(profile_->GetPath()),
450 delete_begin_),
451 base::Bind(&BrowsingDataRemover::OnClearedWebRtcLogs,
452 base::Unretained(this)));
453 #endif
455 // The SSL Host State that tracks SSL interstitial "proceed" decisions may
456 // include origins that the user has visited, so it must be cleared.
457 if (profile_->GetSSLHostStateDelegate())
458 profile_->GetSSLHostStateDelegate()->Clear();
460 #if defined(OS_ANDROID)
461 precache::PrecacheManager* precache_manager =
462 precache::PrecacheManagerFactory::GetForBrowserContext(profile_);
463 // |precache_manager| could be NULL if the profile is off the record.
464 if (!precache_manager) {
465 waiting_for_clear_precache_history_ = true;
466 precache_manager->ClearHistory();
467 // The above calls are done on the UI thread but do their work on the DB
468 // thread. So wait for it.
469 BrowserThread::PostTaskAndReply(
470 BrowserThread::DB, FROM_HERE,
471 base::Bind(&base::DoNothing),
472 base::Bind(&BrowsingDataRemover::OnClearedPrecacheHistory,
473 base::Unretained(this)));
475 #endif
478 if ((remove_mask & REMOVE_DOWNLOADS) && may_delete_history) {
479 content::RecordAction(UserMetricsAction("ClearBrowsingData_Downloads"));
480 content::DownloadManager* download_manager =
481 BrowserContext::GetDownloadManager(profile_);
482 if (remove_origin.unique())
483 download_manager->RemoveDownloadsBetween(delete_begin_, delete_end_);
484 else
485 download_manager->RemoveDownloadsByOriginAndTime(
486 remove_origin, delete_begin_, delete_end_);
487 DownloadPrefs* download_prefs = DownloadPrefs::FromDownloadManager(
488 download_manager);
489 download_prefs->SetSaveFilePath(download_prefs->DownloadPath());
492 uint32 storage_partition_remove_mask = 0;
494 // We ignore the REMOVE_COOKIES request if UNPROTECTED_WEB is not set,
495 // so that callers who request REMOVE_SITE_DATA with PROTECTED_WEB
496 // don't accidentally remove the cookies that are associated with the
497 // UNPROTECTED_WEB origin. This is necessary because cookies are not separated
498 // between UNPROTECTED_WEB and PROTECTED_WEB.
499 if (remove_mask & REMOVE_COOKIES &&
500 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
501 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies"));
503 storage_partition_remove_mask |=
504 content::StoragePartition::REMOVE_DATA_MASK_COOKIES;
506 #if defined(SAFE_BROWSING_SERVICE)
507 // Clear the safebrowsing cookies only if time period is for "all time". It
508 // doesn't make sense to apply the time period of deleting in the last X
509 // hours/days to the safebrowsing cookies since they aren't the result of
510 // any user action.
511 if (delete_begin_ == base::Time()) {
512 SafeBrowsingService* sb_service =
513 g_browser_process->safe_browsing_service();
514 if (sb_service) {
515 net::URLRequestContextGetter* sb_context =
516 sb_service->url_request_context();
517 ++waiting_for_clear_cookies_count_;
518 BrowserThread::PostTask(
519 BrowserThread::IO, FROM_HERE,
520 base::Bind(&BrowsingDataRemover::ClearCookiesOnIOThread,
521 base::Unretained(this), base::Unretained(sb_context)));
524 #endif
525 MediaDeviceIDSalt::Reset(profile_->GetPrefs());
527 // TODO(mkwst): If we're not removing passwords, then clear the 'zero-click'
528 // flag for all credentials in the password store.
531 // Channel IDs are not separated for protected and unprotected web
532 // origins. We check the origin_type_mask_ to prevent unintended deletion.
533 if (remove_mask & REMOVE_CHANNEL_IDS &&
534 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
535 content::RecordAction(
536 UserMetricsAction("ClearBrowsingData_ChannelIDs"));
537 // Since we are running on the UI thread don't call GetURLRequestContext().
538 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext();
539 if (rq_context) {
540 waiting_for_clear_channel_ids_ = true;
541 BrowserThread::PostTask(
542 BrowserThread::IO, FROM_HERE,
543 base::Bind(&BrowsingDataRemover::ClearChannelIDsOnIOThread,
544 base::Unretained(this), base::Unretained(rq_context)));
548 if (remove_mask & REMOVE_LOCAL_STORAGE) {
549 storage_partition_remove_mask |=
550 content::StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE;
553 if (remove_mask & REMOVE_INDEXEDDB) {
554 storage_partition_remove_mask |=
555 content::StoragePartition::REMOVE_DATA_MASK_INDEXEDDB;
557 if (remove_mask & REMOVE_WEBSQL) {
558 storage_partition_remove_mask |=
559 content::StoragePartition::REMOVE_DATA_MASK_WEBSQL;
561 if (remove_mask & REMOVE_APPCACHE) {
562 storage_partition_remove_mask |=
563 content::StoragePartition::REMOVE_DATA_MASK_APPCACHE;
565 if (remove_mask & REMOVE_SERVICE_WORKERS) {
566 storage_partition_remove_mask |=
567 content::StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS;
569 if (remove_mask & REMOVE_FILE_SYSTEMS) {
570 storage_partition_remove_mask |=
571 content::StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS;
574 #if defined(ENABLE_PLUGINS)
575 // Plugin is data not separated for protected and unprotected web origins. We
576 // check the origin_type_mask_ to prevent unintended deletion.
577 if (remove_mask & REMOVE_PLUGIN_DATA &&
578 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
579 content::RecordAction(UserMetricsAction("ClearBrowsingData_LSOData"));
581 waiting_for_clear_plugin_data_ = true;
582 if (!plugin_data_remover_.get())
583 plugin_data_remover_.reset(content::PluginDataRemover::Create(profile_));
584 base::WaitableEvent* event =
585 plugin_data_remover_->StartRemoving(delete_begin_);
587 base::WaitableEventWatcher::EventCallback watcher_callback =
588 base::Bind(&BrowsingDataRemover::OnWaitableEventSignaled,
589 base::Unretained(this));
590 watcher_.StartWatching(event, watcher_callback);
592 #endif
594 if (remove_mask & REMOVE_SITE_USAGE_DATA || remove_mask & REMOVE_HISTORY) {
595 profile_->GetHostContentSettingsMap()->ClearSettingsForOneType(
596 CONTENT_SETTINGS_TYPE_APP_BANNER);
597 profile_->GetHostContentSettingsMap()->ClearSettingsForOneType(
598 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT);
601 if (remove_mask & REMOVE_PASSWORDS) {
602 content::RecordAction(UserMetricsAction("ClearBrowsingData_Passwords"));
603 password_manager::PasswordStore* password_store =
604 PasswordStoreFactory::GetForProfile(
605 profile_, ServiceAccessType::EXPLICIT_ACCESS).get();
607 if (password_store) {
608 waiting_for_clear_passwords_ = true;
609 password_store->RemoveLoginsCreatedBetween(
610 delete_begin_, delete_end_,
611 base::Bind(&BrowsingDataRemover::OnClearedPasswords,
612 base::Unretained(this)));
616 if (remove_mask & REMOVE_FORM_DATA) {
617 content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
618 scoped_refptr<autofill::AutofillWebDataService> web_data_service =
619 WebDataServiceFactory::GetAutofillWebDataForProfile(
620 profile_, ServiceAccessType::EXPLICIT_ACCESS);
622 if (web_data_service.get()) {
623 waiting_for_clear_form_ = true;
624 web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
625 delete_end_);
626 web_data_service->RemoveAutofillDataModifiedBetween(
627 delete_begin_, delete_end_);
628 // The above calls are done on the UI thread but do their work on the DB
629 // thread. So wait for it.
630 BrowserThread::PostTaskAndReply(
631 BrowserThread::DB, FROM_HERE,
632 base::Bind(&base::DoNothing),
633 base::Bind(&BrowsingDataRemover::OnClearedFormData,
634 base::Unretained(this)));
636 autofill::PersonalDataManager* data_manager =
637 autofill::PersonalDataManagerFactory::GetForProfile(profile_);
638 if (data_manager)
639 data_manager->Refresh();
643 if (remove_mask & REMOVE_CACHE) {
644 // Tell the renderers to clear their cache.
645 web_cache::WebCacheManager::GetInstance()->ClearCache();
647 content::RecordAction(UserMetricsAction("ClearBrowsingData_Cache"));
649 waiting_for_clear_cache_ = true;
650 // StoragePartitionHttpCacheDataRemover deletes itself when it is done.
651 browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange(
652 BrowserContext::GetDefaultStoragePartition(profile_), delete_begin_,
653 delete_end_)
654 ->Remove(base::Bind(&BrowsingDataRemover::ClearedCache,
655 base::Unretained(this)));
657 #if !defined(DISABLE_NACL)
658 waiting_for_clear_nacl_cache_ = true;
660 BrowserThread::PostTask(
661 BrowserThread::IO, FROM_HERE,
662 base::Bind(&BrowsingDataRemover::ClearNaClCacheOnIOThread,
663 base::Unretained(this)));
665 waiting_for_clear_pnacl_cache_ = true;
666 BrowserThread::PostTask(
667 BrowserThread::IO, FROM_HERE,
668 base::Bind(&BrowsingDataRemover::ClearPnaclCacheOnIOThread,
669 base::Unretained(this), delete_begin_, delete_end_));
670 #endif
672 // The PrerenderManager may have a page actively being prerendered, which
673 // is essentially a preemptively cached page.
674 prerender::PrerenderManager* prerender_manager =
675 prerender::PrerenderManagerFactory::GetForProfile(profile_);
676 if (prerender_manager) {
677 prerender_manager->ClearData(
678 prerender::PrerenderManager::CLEAR_PRERENDER_CONTENTS);
681 // Tell the shader disk cache to clear.
682 content::RecordAction(UserMetricsAction("ClearBrowsingData_ShaderCache"));
683 storage_partition_remove_mask |=
684 content::StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE;
686 storage_partition_remove_mask |=
687 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY;
689 #if defined(ENABLE_EXTENSIONS)
690 // Clear the ephemeral apps cache. This is NULL while testing. OTR Profile
691 // has neither apps nor an ExtensionService, so ClearCachedApps fails.
692 EphemeralAppService* ephemeral_app_service =
693 EphemeralAppService::Get(profile_);
694 if (ephemeral_app_service && !profile_->IsOffTheRecord())
695 ephemeral_app_service->ClearCachedApps();
696 #endif
699 if (remove_mask & REMOVE_WEBRTC_IDENTITY) {
700 storage_partition_remove_mask |=
701 content::StoragePartition::REMOVE_DATA_MASK_WEBRTC_IDENTITY;
704 if (storage_partition_remove_mask) {
705 waiting_for_clear_storage_partition_data_ = true;
707 content::StoragePartition* storage_partition;
708 if (storage_partition_for_testing_)
709 storage_partition = storage_partition_for_testing_;
710 else
711 storage_partition = BrowserContext::GetDefaultStoragePartition(profile_);
713 uint32 quota_storage_remove_mask =
714 ~content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
716 if (delete_begin_ == base::Time() ||
717 origin_type_mask_ &
718 (BrowsingDataHelper::PROTECTED_WEB | BrowsingDataHelper::EXTENSION)) {
719 // If we're deleting since the beginning of time, or we're removing
720 // protected origins, then remove persistent quota data.
721 quota_storage_remove_mask |=
722 content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
725 storage_partition->ClearData(
726 storage_partition_remove_mask, quota_storage_remove_mask, remove_url,
727 base::Bind(&DoesOriginMatchMask, origin_type_mask_), delete_begin_,
728 delete_end_,
729 base::Bind(&BrowsingDataRemover::OnClearedStoragePartitionData,
730 base::Unretained(this)));
733 #if defined(ENABLE_PLUGINS)
734 if (remove_mask & REMOVE_CONTENT_LICENSES) {
735 content::RecordAction(
736 UserMetricsAction("ClearBrowsingData_ContentLicenses"));
738 waiting_for_clear_content_licenses_ = true;
739 if (!pepper_flash_settings_manager_.get()) {
740 pepper_flash_settings_manager_.reset(
741 new PepperFlashSettingsManager(this, profile_));
743 deauthorize_content_licenses_request_id_ =
744 pepper_flash_settings_manager_->DeauthorizeContentLicenses(prefs);
745 #if defined(OS_CHROMEOS)
746 // On Chrome OS, also delete any content protection platform keys.
747 const user_manager::User* user =
748 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
749 if (!user) {
750 LOG(WARNING) << "Failed to find user for current profile.";
751 } else {
752 chromeos::DBusThreadManager::Get()->GetCryptohomeClient()->
753 TpmAttestationDeleteKeys(
754 chromeos::attestation::KEY_USER,
755 user->email(),
756 chromeos::attestation::kContentProtectionKeyPrefix,
757 base::Bind(&BrowsingDataRemover::OnClearPlatformKeys,
758 base::Unretained(this)));
759 waiting_for_clear_platform_keys_ = true;
761 #endif
763 #endif
765 // Remove omnibox zero-suggest cache results.
766 if ((remove_mask & (REMOVE_CACHE | REMOVE_COOKIES)))
767 prefs->SetString(omnibox::kZeroSuggestCachedResults, std::string());
769 // Always wipe accumulated network related data (TransportSecurityState and
770 // HttpServerPropertiesManager data).
771 waiting_for_clear_networking_history_ = true;
772 profile_->ClearNetworkingHistorySince(
773 delete_begin_,
774 base::Bind(&BrowsingDataRemover::OnClearedNetworkingHistory,
775 base::Unretained(this)));
777 if (remove_mask & (REMOVE_COOKIES | REMOVE_HISTORY)) {
778 domain_reliability::DomainReliabilityService* service =
779 domain_reliability::DomainReliabilityServiceFactory::
780 GetForBrowserContext(profile_);
781 if (service) {
782 domain_reliability::DomainReliabilityClearMode mode;
783 if (remove_mask & REMOVE_COOKIES)
784 mode = domain_reliability::CLEAR_CONTEXTS;
785 else
786 mode = domain_reliability::CLEAR_BEACONS;
788 waiting_for_clear_domain_reliability_monitor_ = true;
789 service->ClearBrowsingData(
790 mode,
791 base::Bind(&BrowsingDataRemover::OnClearedDomainReliabilityMonitor,
792 base::Unretained(this)));
796 // Record the combined deletion of cookies and cache.
797 CookieOrCacheDeletionChoice choice = NEITHER_COOKIES_NOR_CACHE;
798 if (remove_mask & REMOVE_COOKIES &&
799 origin_type_mask_ & BrowsingDataHelper::UNPROTECTED_WEB) {
800 choice = remove_mask & REMOVE_CACHE ? BOTH_COOKIES_AND_CACHE
801 : ONLY_COOKIES;
802 } else if (remove_mask & REMOVE_CACHE) {
803 choice = ONLY_CACHE;
806 UMA_HISTOGRAM_ENUMERATION(
807 "ClearBrowsingData.UserDeletedCookieOrCache", choice, MAX_CHOICE_VALUE);
810 void BrowsingDataRemover::AddObserver(Observer* observer) {
811 observer_list_.AddObserver(observer);
814 void BrowsingDataRemover::RemoveObserver(Observer* observer) {
815 observer_list_.RemoveObserver(observer);
818 void BrowsingDataRemover::OnHistoryDeletionDone() {
819 waiting_for_clear_history_ = false;
820 NotifyAndDeleteIfDone();
823 void BrowsingDataRemover::OverrideStoragePartitionForTesting(
824 content::StoragePartition* storage_partition) {
825 storage_partition_for_testing_ = storage_partition;
828 base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
829 TimePeriod time_period) {
830 base::TimeDelta diff;
831 base::Time delete_begin_time = base::Time::Now();
832 switch (time_period) {
833 case LAST_HOUR:
834 diff = base::TimeDelta::FromHours(1);
835 break;
836 case LAST_DAY:
837 diff = base::TimeDelta::FromHours(24);
838 break;
839 case LAST_WEEK:
840 diff = base::TimeDelta::FromHours(7*24);
841 break;
842 case FOUR_WEEKS:
843 diff = base::TimeDelta::FromHours(4*7*24);
844 break;
845 case EVERYTHING:
846 delete_begin_time = base::Time();
847 break;
848 default:
849 NOTREACHED() << L"Missing item";
850 break;
852 return delete_begin_time - diff;
855 bool BrowsingDataRemover::AllDone() {
856 return !waiting_for_clear_autofill_origin_urls_ &&
857 !waiting_for_clear_cache_ &&
858 !waiting_for_clear_content_licenses_ &&
859 !waiting_for_clear_channel_ids_ &&
860 !waiting_for_clear_cookies_count_ &&
861 !waiting_for_clear_domain_reliability_monitor_ &&
862 !waiting_for_clear_form_ &&
863 !waiting_for_clear_history_ &&
864 !waiting_for_clear_hostname_resolution_cache_ &&
865 !waiting_for_clear_keyword_data_ &&
866 !waiting_for_clear_nacl_cache_ &&
867 !waiting_for_clear_network_predictor_ &&
868 !waiting_for_clear_networking_history_ &&
869 !waiting_for_clear_passwords_ &&
870 !waiting_for_clear_platform_keys_ &&
871 !waiting_for_clear_plugin_data_ &&
872 !waiting_for_clear_pnacl_cache_ &&
873 #if defined(OS_ANDROID)
874 !waiting_for_clear_precache_history_ &&
875 #endif
876 #if defined(ENABLE_WEBRTC)
877 !waiting_for_clear_webrtc_logs_ &&
878 #endif
879 !waiting_for_clear_storage_partition_data_;
882 void BrowsingDataRemover::OnKeywordsLoaded() {
883 // Deletes the entries from the model, and if we're not waiting on anything
884 // else notifies observers and deletes this BrowsingDataRemover.
885 TemplateURLService* model =
886 TemplateURLServiceFactory::GetForProfile(profile_);
887 model->RemoveAutoGeneratedBetween(delete_begin_, delete_end_);
888 waiting_for_clear_keyword_data_ = false;
889 template_url_sub_.reset();
890 NotifyAndDeleteIfDone();
893 void BrowsingDataRemover::NotifyAndDelete() {
894 set_removing(false);
896 // Notify observers.
897 BrowsingDataRemover::NotificationDetails details(delete_begin_, remove_mask_,
898 origin_type_mask_);
900 GetOnBrowsingDataRemovedCallbacks()->Notify(details);
902 FOR_EACH_OBSERVER(Observer, observer_list_, OnBrowsingDataRemoverDone());
904 // History requests aren't happy if you delete yourself from the callback.
905 // As such, we do a delete later.
906 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
909 void BrowsingDataRemover::NotifyAndDeleteIfDone() {
910 // TODO(brettw) http://crbug.com/305259: This should also observe session
911 // clearing (what about other things such as passwords, etc.?) and wait for
912 // them to complete before continuing.
914 if (!AllDone())
915 return;
917 if (completion_inhibitor_) {
918 completion_inhibitor_->OnBrowsingDataRemoverWouldComplete(
919 this,
920 base::Bind(&BrowsingDataRemover::NotifyAndDelete,
921 base::Unretained(this)));
922 } else {
923 NotifyAndDelete();
927 void BrowsingDataRemover::OnClearedHostnameResolutionCache() {
928 DCHECK_CURRENTLY_ON(BrowserThread::UI);
929 waiting_for_clear_hostname_resolution_cache_ = false;
930 NotifyAndDeleteIfDone();
933 void BrowsingDataRemover::ClearHostnameResolutionCacheOnIOThread(
934 IOThread* io_thread) {
935 DCHECK_CURRENTLY_ON(BrowserThread::IO);
937 io_thread->ClearHostCache();
939 // Notify the UI thread that we are done.
940 BrowserThread::PostTask(
941 BrowserThread::UI,
942 FROM_HERE,
943 base::Bind(&BrowsingDataRemover::OnClearedHostnameResolutionCache,
944 base::Unretained(this)));
947 void BrowsingDataRemover::OnClearedNetworkPredictor() {
948 DCHECK_CURRENTLY_ON(BrowserThread::UI);
949 waiting_for_clear_network_predictor_ = false;
950 NotifyAndDeleteIfDone();
953 void BrowsingDataRemover::ClearNetworkPredictorOnIOThread(
954 chrome_browser_net::Predictor* predictor) {
955 DCHECK_CURRENTLY_ON(BrowserThread::IO);
956 DCHECK(predictor);
958 predictor->DiscardInitialNavigationHistory();
959 predictor->DiscardAllResults();
961 // Notify the UI thread that we are done.
962 BrowserThread::PostTask(
963 BrowserThread::UI,
964 FROM_HERE,
965 base::Bind(&BrowsingDataRemover::OnClearedNetworkPredictor,
966 base::Unretained(this)));
969 void BrowsingDataRemover::OnClearedNetworkingHistory() {
970 DCHECK_CURRENTLY_ON(BrowserThread::UI);
971 waiting_for_clear_networking_history_ = false;
972 NotifyAndDeleteIfDone();
975 void BrowsingDataRemover::ClearedCache() {
976 waiting_for_clear_cache_ = false;
978 NotifyAndDeleteIfDone();
981 #if !defined(DISABLE_NACL)
982 void BrowsingDataRemover::ClearedNaClCache() {
983 // This function should be called on the UI thread.
984 DCHECK_CURRENTLY_ON(BrowserThread::UI);
986 waiting_for_clear_nacl_cache_ = false;
988 NotifyAndDeleteIfDone();
991 void BrowsingDataRemover::ClearedNaClCacheOnIOThread() {
992 // This function should be called on the IO thread.
993 DCHECK_CURRENTLY_ON(BrowserThread::IO);
995 // Notify the UI thread that we are done.
996 BrowserThread::PostTask(
997 BrowserThread::UI, FROM_HERE,
998 base::Bind(&BrowsingDataRemover::ClearedNaClCache,
999 base::Unretained(this)));
1002 void BrowsingDataRemover::ClearNaClCacheOnIOThread() {
1003 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1005 nacl::NaClBrowser::GetInstance()->ClearValidationCache(
1006 base::Bind(&BrowsingDataRemover::ClearedNaClCacheOnIOThread,
1007 base::Unretained(this)));
1010 void BrowsingDataRemover::ClearedPnaclCache() {
1011 // This function should be called on the UI thread.
1012 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1014 waiting_for_clear_pnacl_cache_ = false;
1016 NotifyAndDeleteIfDone();
1019 void BrowsingDataRemover::ClearedPnaclCacheOnIOThread() {
1020 // This function should be called on the IO thread.
1021 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1023 // Notify the UI thread that we are done.
1024 BrowserThread::PostTask(
1025 BrowserThread::UI, FROM_HERE,
1026 base::Bind(&BrowsingDataRemover::ClearedPnaclCache,
1027 base::Unretained(this)));
1030 void BrowsingDataRemover::ClearPnaclCacheOnIOThread(base::Time begin,
1031 base::Time end) {
1032 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1034 pnacl::PnaclHost::GetInstance()->ClearTranslationCacheEntriesBetween(
1035 begin, end,
1036 base::Bind(&BrowsingDataRemover::ClearedPnaclCacheOnIOThread,
1037 base::Unretained(this)));
1039 #endif
1041 void BrowsingDataRemover::OnWaitableEventSignaled(
1042 base::WaitableEvent* waitable_event) {
1043 waiting_for_clear_plugin_data_ = false;
1044 NotifyAndDeleteIfDone();
1047 #if defined(ENABLE_PLUGINS)
1048 void BrowsingDataRemover::OnDeauthorizeContentLicensesCompleted(
1049 uint32 request_id,
1050 bool /* success */) {
1051 DCHECK(waiting_for_clear_content_licenses_);
1052 DCHECK_EQ(request_id, deauthorize_content_licenses_request_id_);
1054 waiting_for_clear_content_licenses_ = false;
1055 NotifyAndDeleteIfDone();
1057 #endif
1059 #if defined(OS_CHROMEOS)
1060 void BrowsingDataRemover::OnClearPlatformKeys(
1061 chromeos::DBusMethodCallStatus call_status,
1062 bool result) {
1063 DCHECK(waiting_for_clear_platform_keys_);
1064 if (call_status != chromeos::DBUS_METHOD_CALL_SUCCESS || !result) {
1065 LOG(ERROR) << "Failed to clear platform keys.";
1067 waiting_for_clear_platform_keys_ = false;
1068 NotifyAndDeleteIfDone();
1070 #endif
1073 void BrowsingDataRemover::OnClearedPasswords() {
1074 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1075 waiting_for_clear_passwords_ = false;
1076 NotifyAndDeleteIfDone();
1079 void BrowsingDataRemover::OnClearedCookies(int num_deleted) {
1080 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
1081 BrowserThread::PostTask(
1082 BrowserThread::UI, FROM_HERE,
1083 base::Bind(&BrowsingDataRemover::OnClearedCookies,
1084 base::Unretained(this), num_deleted));
1085 return;
1088 DCHECK_GT(waiting_for_clear_cookies_count_, 0);
1089 --waiting_for_clear_cookies_count_;
1090 NotifyAndDeleteIfDone();
1093 void BrowsingDataRemover::ClearCookiesOnIOThread(
1094 net::URLRequestContextGetter* rq_context) {
1095 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1096 net::CookieStore* cookie_store = rq_context->
1097 GetURLRequestContext()->cookie_store();
1098 cookie_store->DeleteAllCreatedBetweenAsync(
1099 delete_begin_, delete_end_,
1100 base::Bind(&BrowsingDataRemover::OnClearedCookies,
1101 base::Unretained(this)));
1104 void BrowsingDataRemover::ClearChannelIDsOnIOThread(
1105 net::URLRequestContextGetter* rq_context) {
1106 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1107 net::ChannelIDService* channel_id_service =
1108 rq_context->GetURLRequestContext()->channel_id_service();
1109 channel_id_service->GetChannelIDStore()->DeleteAllCreatedBetween(
1110 delete_begin_, delete_end_,
1111 base::Bind(&BrowsingDataRemover::OnClearedChannelIDsOnIOThread,
1112 base::Unretained(this), base::Unretained(rq_context)));
1115 void BrowsingDataRemover::OnClearedChannelIDsOnIOThread(
1116 net::URLRequestContextGetter* rq_context) {
1117 // Need to close open SSL connections which may be using the channel ids we
1118 // are deleting.
1119 // TODO(mattm): http://crbug.com/166069 Make the server bound cert
1120 // service/store have observers that can notify relevant things directly.
1121 rq_context->GetURLRequestContext()->ssl_config_service()->
1122 NotifySSLConfigChange();
1123 BrowserThread::PostTask(
1124 BrowserThread::UI, FROM_HERE,
1125 base::Bind(&BrowsingDataRemover::OnClearedChannelIDs,
1126 base::Unretained(this)));
1129 void BrowsingDataRemover::OnClearedChannelIDs() {
1130 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1131 waiting_for_clear_channel_ids_ = false;
1132 NotifyAndDeleteIfDone();
1135 void BrowsingDataRemover::OnClearedFormData() {
1136 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1137 waiting_for_clear_form_ = false;
1138 NotifyAndDeleteIfDone();
1141 void BrowsingDataRemover::OnClearedAutofillOriginURLs() {
1142 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1143 waiting_for_clear_autofill_origin_urls_ = false;
1144 NotifyAndDeleteIfDone();
1147 void BrowsingDataRemover::OnClearedStoragePartitionData() {
1148 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1149 waiting_for_clear_storage_partition_data_ = false;
1150 NotifyAndDeleteIfDone();
1153 #if defined(ENABLE_WEBRTC)
1154 void BrowsingDataRemover::OnClearedWebRtcLogs() {
1155 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1156 waiting_for_clear_webrtc_logs_ = false;
1157 NotifyAndDeleteIfDone();
1159 #endif
1161 #if defined(OS_ANDROID)
1162 void BrowsingDataRemover::OnClearedPrecacheHistory() {
1163 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1164 waiting_for_clear_precache_history_ = false;
1165 NotifyAndDeleteIfDone();
1167 #endif
1169 void BrowsingDataRemover::OnClearedDomainReliabilityMonitor() {
1170 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1171 waiting_for_clear_domain_reliability_monitor_ = false;
1172 NotifyAndDeleteIfDone();
1175 // static
1176 BrowsingDataRemover::CallbackSubscription
1177 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
1178 const BrowsingDataRemover::Callback& callback) {
1179 return GetOnBrowsingDataRemovedCallbacks()->Add(callback);