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/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/file_util.h" |
11 #include "chrome/browser/autofill/personal_data_manager.h" | 12 #include "chrome/browser/autofill/personal_data_manager.h" |
12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/download/download_manager.h" | 14 #include "chrome/browser/download/download_manager.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 16 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
16 #include "chrome/browser/history/history.h" | 17 #include "chrome/browser/history/history.h" |
17 #include "chrome/browser/io_thread.h" | 18 #include "chrome/browser/io_thread.h" |
18 #include "chrome/browser/net/chrome_net_log.h" | 19 #include "chrome/browser/net/chrome_net_log.h" |
19 #include "chrome/browser/net/chrome_url_request_context.h" | 20 #include "chrome/browser/net/chrome_url_request_context.h" |
20 #include "chrome/browser/password_manager/password_store.h" | 21 #include "chrome/browser/password_manager/password_store.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 this, &BrowsingDataRemover::OnAppCacheDeleted)), | 66 this, &BrowsingDataRemover::OnAppCacheDeleted)), |
66 appcaches_to_be_deleted_count_(0), | 67 appcaches_to_be_deleted_count_(0), |
67 next_cache_state_(STATE_NONE), | 68 next_cache_state_(STATE_NONE), |
68 cache_(NULL), | 69 cache_(NULL), |
69 main_context_getter_(profile->GetRequestContext()), | 70 main_context_getter_(profile->GetRequestContext()), |
70 media_context_getter_(profile->GetRequestContextForMedia()), | 71 media_context_getter_(profile->GetRequestContextForMedia()), |
71 waiting_for_clear_databases_(false), | 72 waiting_for_clear_databases_(false), |
72 waiting_for_clear_history_(false), | 73 waiting_for_clear_history_(false), |
73 waiting_for_clear_networking_history_(false), | 74 waiting_for_clear_networking_history_(false), |
74 waiting_for_clear_cache_(false), | 75 waiting_for_clear_cache_(false), |
75 waiting_for_clear_appcache_(false) { | 76 waiting_for_clear_appcache_(false), |
| 77 waiting_for_clear_gears_data_(false) { |
76 DCHECK(profile); | 78 DCHECK(profile); |
77 } | 79 } |
78 | 80 |
79 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, | 81 BrowsingDataRemover::BrowsingDataRemover(Profile* profile, |
80 TimePeriod time_period, | 82 TimePeriod time_period, |
81 base::Time delete_end) | 83 base::Time delete_end) |
82 : profile_(profile), | 84 : profile_(profile), |
83 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), | 85 special_storage_policy_(profile->GetExtensionSpecialStoragePolicy()), |
84 delete_begin_(CalculateBeginDeleteTime(time_period)), | 86 delete_begin_(CalculateBeginDeleteTime(time_period)), |
85 delete_end_(delete_end), | 87 delete_end_(delete_end), |
86 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( | 88 ALLOW_THIS_IN_INITIALIZER_LIST(database_cleared_callback_( |
87 this, &BrowsingDataRemover::OnClearedDatabases)), | 89 this, &BrowsingDataRemover::OnClearedDatabases)), |
88 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( | 90 ALLOW_THIS_IN_INITIALIZER_LIST(cache_callback_( |
89 this, &BrowsingDataRemover::DoClearCache)), | 91 this, &BrowsingDataRemover::DoClearCache)), |
90 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( | 92 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_got_info_callback_( |
91 this, &BrowsingDataRemover::OnGotAppCacheInfo)), | 93 this, &BrowsingDataRemover::OnGotAppCacheInfo)), |
92 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( | 94 ALLOW_THIS_IN_INITIALIZER_LIST(appcache_deleted_callback_( |
93 this, &BrowsingDataRemover::OnAppCacheDeleted)), | 95 this, &BrowsingDataRemover::OnAppCacheDeleted)), |
94 appcaches_to_be_deleted_count_(0), | 96 appcaches_to_be_deleted_count_(0), |
95 next_cache_state_(STATE_NONE), | 97 next_cache_state_(STATE_NONE), |
96 cache_(NULL), | 98 cache_(NULL), |
97 main_context_getter_(profile->GetRequestContext()), | 99 main_context_getter_(profile->GetRequestContext()), |
98 media_context_getter_(profile->GetRequestContextForMedia()), | 100 media_context_getter_(profile->GetRequestContextForMedia()), |
99 waiting_for_clear_databases_(false), | 101 waiting_for_clear_databases_(false), |
100 waiting_for_clear_history_(false), | 102 waiting_for_clear_history_(false), |
101 waiting_for_clear_networking_history_(false), | 103 waiting_for_clear_networking_history_(false), |
102 waiting_for_clear_cache_(false), | 104 waiting_for_clear_cache_(false), |
103 waiting_for_clear_appcache_(false), | 105 waiting_for_clear_appcache_(false), |
104 waiting_for_clear_lso_data_(false) { | 106 waiting_for_clear_lso_data_(false), |
| 107 waiting_for_clear_gears_data_(false) { |
105 DCHECK(profile); | 108 DCHECK(profile); |
106 } | 109 } |
107 | 110 |
108 BrowsingDataRemover::~BrowsingDataRemover() { | 111 BrowsingDataRemover::~BrowsingDataRemover() { |
109 DCHECK(all_done()); | 112 DCHECK(all_done()); |
110 } | 113 } |
111 | 114 |
112 void BrowsingDataRemover::Remove(int remove_mask) { | 115 void BrowsingDataRemover::Remove(int remove_mask) { |
113 DCHECK(!removing_); | 116 DCHECK(!removing_); |
114 removing_ = true; | 117 removing_ = true; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); | 197 &BrowsingDataRemover::ClearDatabasesOnFILEThread)); |
195 } | 198 } |
196 | 199 |
197 waiting_for_clear_appcache_ = true; | 200 waiting_for_clear_appcache_ = true; |
198 BrowserThread::PostTask( | 201 BrowserThread::PostTask( |
199 BrowserThread::IO, FROM_HERE, | 202 BrowserThread::IO, FROM_HERE, |
200 NewRunnableMethod( | 203 NewRunnableMethod( |
201 this, | 204 this, |
202 &BrowsingDataRemover::ClearAppCacheOnIOThread)); | 205 &BrowsingDataRemover::ClearAppCacheOnIOThread)); |
203 | 206 |
| 207 waiting_for_clear_gears_data_ = true; |
| 208 BrowserThread::PostTask( |
| 209 BrowserThread::FILE, FROM_HERE, |
| 210 NewRunnableMethod( |
| 211 this, |
| 212 &BrowsingDataRemover::ClearGearsDataOnFILEThread, |
| 213 profile_->GetPath())); |
| 214 |
204 // TODO(michaeln): delete temporary file system data too | 215 // TODO(michaeln): delete temporary file system data too |
205 | 216 |
206 BrowserThread::PostTask( | 217 BrowserThread::PostTask( |
207 BrowserThread::IO, FROM_HERE, | 218 BrowserThread::IO, FROM_HERE, |
208 NewRunnableMethod( | 219 NewRunnableMethod( |
209 profile_->GetTransportSecurityState(), | 220 profile_->GetTransportSecurityState(), |
210 &net::TransportSecurityState::DeleteSince, | 221 &net::TransportSecurityState::DeleteSince, |
211 delete_begin_)); | 222 delete_begin_)); |
212 } | 223 } |
213 | 224 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 519 |
509 ChromeAppCacheService* BrowsingDataRemover::GetAppCacheService() { | 520 ChromeAppCacheService* BrowsingDataRemover::GetAppCacheService() { |
510 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 521 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
511 ChromeURLRequestContext* request_context = | 522 ChromeURLRequestContext* request_context = |
512 reinterpret_cast<ChromeURLRequestContext*>( | 523 reinterpret_cast<ChromeURLRequestContext*>( |
513 main_context_getter_->GetURLRequestContext()); | 524 main_context_getter_->GetURLRequestContext()); |
514 return request_context ? request_context->appcache_service() | 525 return request_context ? request_context->appcache_service() |
515 : NULL; | 526 : NULL; |
516 } | 527 } |
517 | 528 |
| 529 // static |
| 530 void BrowsingDataRemover::ClearGearsData(const FilePath& profile_dir) { |
| 531 FilePath plugin_data = profile_dir.AppendASCII("Plugin Data"); |
| 532 if (file_util::DirectoryExists(plugin_data)) |
| 533 file_util::Delete(plugin_data, true); |
| 534 } |
| 535 |
| 536 void BrowsingDataRemover::OnClearedGearsData() { |
| 537 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 538 bool result = BrowserThread::PostTask( |
| 539 BrowserThread::UI, FROM_HERE, |
| 540 NewRunnableMethod(this, &BrowsingDataRemover::OnClearedGearsData)); |
| 541 DCHECK(result); |
| 542 return; |
| 543 } |
| 544 waiting_for_clear_gears_data_ = false; |
| 545 NotifyAndDeleteIfDone(); |
| 546 } |
| 547 |
| 548 void BrowsingDataRemover::ClearGearsDataOnFILEThread( |
| 549 const FilePath& profile_dir) { |
| 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 551 DCHECK(waiting_for_clear_gears_data_); |
| 552 |
| 553 ClearGearsData(profile_dir); |
| 554 OnClearedGearsData(); |
| 555 } |
| 556 |
518 void BrowsingDataRemover::OnWaitableEventSignaled( | 557 void BrowsingDataRemover::OnWaitableEventSignaled( |
519 base::WaitableEvent* waitable_event) { | 558 base::WaitableEvent* waitable_event) { |
520 waiting_for_clear_lso_data_ = false; | 559 waiting_for_clear_lso_data_ = false; |
521 NotifyAndDeleteIfDone(); | 560 NotifyAndDeleteIfDone(); |
522 } | 561 } |
OLD | NEW |