OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_remover.h" | 5 #include "chrome/browser/browsing_data_remover.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
12 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
13 #include "chrome/browser/autofill/personal_data_manager.h" | 14 #include "chrome/browser/autofill/personal_data_manager.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/download/download_manager.h" | 16 #include "chrome/browser/download/download_manager.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 18 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
18 #include "chrome/browser/history/history.h" | 19 #include "chrome/browser/history/history.h" |
19 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | 72 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( |
72 this, &BrowsingDataRemover::OnAppCacheDeleted)), | 73 this, &BrowsingDataRemover::OnAppCacheDeleted)), |
73 appcaches_to_be_deleted_count_(0), | 74 appcaches_to_be_deleted_count_(0), |
74 next_cache_state_(STATE_NONE), | 75 next_cache_state_(STATE_NONE), |
75 cache_(NULL), | 76 cache_(NULL), |
76 main_context_getter_(profile->GetRequestContext()), | 77 main_context_getter_(profile->GetRequestContext()), |
77 media_context_getter_(profile->GetRequestContextForMedia()), | 78 media_context_getter_(profile->GetRequestContextForMedia()), |
78 waiting_for_clear_databases_(false), | 79 waiting_for_clear_databases_(false), |
79 waiting_for_clear_history_(false), | 80 waiting_for_clear_history_(false), |
80 waiting_for_clear_networking_history_(false), | 81 waiting_for_clear_networking_history_(false), |
82 waiting_for_clear_cookies_(false), | |
81 waiting_for_clear_cache_(false), | 83 waiting_for_clear_cache_(false), |
82 waiting_for_clear_appcache_(false), | 84 waiting_for_clear_appcache_(false), |
83 waiting_for_clear_gears_data_(false), | 85 waiting_for_clear_gears_data_(false), |
84 waiting_for_clear_file_systems_(false) { | 86 waiting_for_clear_file_systems_(false) { |
85 DCHECK(profile); | 87 DCHECK(profile); |
86 } | 88 } |
87 | 89 |
88 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 90 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
89 TimePeriod time_period, | 91 TimePeriod time_period, |
90 base::Time delete_end) | 92 base::Time delete_end) |
(...skipping 10 matching lines...) Expand all Loading... | |
101 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | 103 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( |
102 this, &BrowsingDataRemover::OnAppCacheDeleted)), | 104 this, &BrowsingDataRemover::OnAppCacheDeleted)), |
103 appcaches_to_be_deleted_count_(0), | 105 appcaches_to_be_deleted_count_(0), |
104 next_cache_state_(STATE_NONE), | 106 next_cache_state_(STATE_NONE), |
105 cache_(NULL), | 107 cache_(NULL), |
106 main_context_getter_(profile->GetRequestContext()), | 108 main_context_getter_(profile->GetRequestContext()), |
107 media_context_getter_(profile->GetRequestContextForMedia()), | 109 media_context_getter_(profile->GetRequestContextForMedia()), |
108 waiting_for_clear_databases_(false), | 110 waiting_for_clear_databases_(false), |
109 waiting_for_clear_history_(false), | 111 waiting_for_clear_history_(false), |
110 waiting_for_clear_networking_history_(false), | 112 waiting_for_clear_networking_history_(false), |
113 waiting_for_clear_cookies_(false), | |
111 waiting_for_clear_cache_(false), | 114 waiting_for_clear_cache_(false), |
112 waiting_for_clear_appcache_(false), | 115 waiting_for_clear_appcache_(false), |
113 waiting_for_clear_lso_data_(false), | 116 waiting_for_clear_lso_data_(false), |
114 waiting_for_clear_gears_data_(false), | 117 waiting_for_clear_gears_data_(false), |
115 waiting_for_clear_file_systems_(false) { | 118 waiting_for_clear_file_systems_(false) { |
116 DCHECK(profile); | 119 DCHECK(profile); |
117 } | 120 } |
118 | 121 |
119 BrowsingDataRemover::~BrowsingDataRemover() { | 122 BrowsingDataRemover::~BrowsingDataRemover() { |
120 DCHECK(all_done()); | 123 DCHECK(all_done()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 199 |
197 if (remove_mask & REMOVE_COOKIES) { | 200 if (remove_mask & REMOVE_COOKIES) { |
198 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); | 201 UserMetrics::RecordAction(UserMetricsAction("ClearBrowsingData_Cookies")); |
199 // Since we are running on the UI thread don't call GetURLRequestContext(). | 202 // Since we are running on the UI thread don't call GetURLRequestContext(). |
200 net::CookieMonster* cookie_monster = NULL; | 203 net::CookieMonster* cookie_monster = NULL; |
201 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); | 204 net::URLRequestContextGetter* rq_context = profile_->GetRequestContext(); |
202 if (rq_context) { | 205 if (rq_context) { |
203 cookie_monster = rq_context->DONTUSEME_GetCookieStore()-> | 206 cookie_monster = rq_context->DONTUSEME_GetCookieStore()-> |
204 GetCookieMonster(); | 207 GetCookieMonster(); |
205 } | 208 } |
206 if (cookie_monster) | 209 if (cookie_monster) { |
207 cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); | 210 waiting_for_clear_cookies_ = true; |
211 cookie_monster->DeleteAllCreatedBetween( | |
212 delete_begin_, delete_end_, true, | |
213 base::Bind(&BrowsingDataRemover::OnCookiesDeleted, | |
214 base::Unretained(this))); | |
215 } | |
208 | 216 |
209 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure | 217 // REMOVE_COOKIES is actually "cookies and other site data" so we make sure |
210 // to remove other data such local databases, STS state, etc. These only can | 218 // to remove other data such local databases, STS state, etc. These only can |
211 // be removed if a WEBKIT thread exists, so check that first: | 219 // be removed if a WEBKIT thread exists, so check that first: |
212 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { | 220 if (BrowserThread::IsMessageLoopValid(BrowserThread::WEBKIT)) { |
213 // We assume the end time is now. | 221 // We assume the end time is now. |
214 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); | 222 profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); |
215 } | 223 } |
216 | 224 |
217 database_tracker_ = profile_->GetDatabaseTracker(); | 225 database_tracker_ = profile_->GetDatabaseTracker(); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 | 645 |
638 ClearGearsData(profile_dir); | 646 ClearGearsData(profile_dir); |
639 OnClearedGearsData(); | 647 OnClearedGearsData(); |
640 } | 648 } |
641 | 649 |
642 void BrowsingDataRemover::OnWaitableEventSignaled( | 650 void BrowsingDataRemover::OnWaitableEventSignaled( |
643 base::WaitableEvent* waitable_event) { | 651 base::WaitableEvent* waitable_event) { |
644 waiting_for_clear_lso_data_ = false; | 652 waiting_for_clear_lso_data_ = false; |
645 NotifyAndDeleteIfDone(); | 653 NotifyAndDeleteIfDone(); |
646 } | 654 } |
655 | |
656 void BrowsingDataRemover::OnCookiesDeleted(int num_deleted) { | |
657 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | |
erikwright (departed)
2011/07/04 16:47:33
The CookieStore guarantees invocation of callbacks
| |
658 bool result = BrowserThread::PostTask( | |
659 BrowserThread::UI, FROM_HERE, | |
660 NewRunnableMethod(this, &BrowsingDataRemover::OnCookiesDeleted, | |
661 num_deleted)); | |
662 DCHECK(result); | |
663 return; | |
664 } | |
665 waiting_for_clear_cookies_ = false; | |
666 NotifyAndDeleteIfDone(); | |
667 } | |
OLD | NEW |