summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browsing_data_remover.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:37:19 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-22 01:37:19 +0000
commit25364e14c155d8eb3015f6be95af264a82ea2158 (patch)
tree4c5048d9ba7f979894d1e9c4d1723cc8e85759db /chrome/browser/browsing_data_remover.cc
parent3af08941db12e58b76361cda8cf313d529471b35 (diff)
downloadchromium_src-25364e14c155d8eb3015f6be95af264a82ea2158.zip
chromium_src-25364e14c155d8eb3015f6be95af264a82ea2158.tar.gz
chromium_src-25364e14c155d8eb3015f6be95af264a82ea2158.tar.bz2
Implement clear browsing data dialog in linux
As well, refactored code on the windows side to reuse some functionality for the deletion range specified by its time period. BUG=11192 (http://crbug.com/11192) TEST=Looks pretty Review URL: http://codereview.chromium.org/113558 Patch from Mohamed Mansour <m0.interactive@gmail.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16694 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browsing_data_remover.cc')
-rw-r--r--chrome/browser/browsing_data_remover.cc47
1 files changed, 41 insertions, 6 deletions
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 33a0c6d..0929238 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -21,8 +21,6 @@
#include "net/url_request/url_request_context.h"
#include "webkit/glue/password_form.h"
-using base::Time;
-
// Done so that we can use invokeLater on BrowsingDataRemovers and not have
// BrowsingDataRemover implement RefCounted.
template<>
@@ -36,8 +34,9 @@ void RunnableMethodTraits<BrowsingDataRemover>::ReleaseCallee(
bool BrowsingDataRemover::removing_ = false;
-BrowsingDataRemover::BrowsingDataRemover(Profile* profile, Time delete_begin,
- Time delete_end)
+BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
+ base::Time delete_begin,
+ base::Time delete_end)
: profile_(profile),
delete_begin_(delete_begin),
delete_end_(delete_end),
@@ -47,6 +46,18 @@ BrowsingDataRemover::BrowsingDataRemover(Profile* profile, Time delete_begin,
DCHECK(profile);
}
+BrowsingDataRemover::BrowsingDataRemover(Profile* profile,
+ TimePeriod time_period,
+ base::Time delete_end)
+ : profile_(profile),
+ delete_begin_(CalculateBeginDeleteTime(time_period)),
+ delete_end_(delete_end),
+ waiting_for_keywords_(false),
+ waiting_for_clear_history_(false),
+ waiting_for_clear_cache_(false) {
+ DCHECK(profile);
+}
+
BrowsingDataRemover::~BrowsingDataRemover() {
DCHECK(all_done());
}
@@ -154,6 +165,30 @@ void BrowsingDataRemover::OnHistoryDeletionDone() {
NotifyAndDeleteIfDone();
}
+base::Time BrowsingDataRemover::CalculateBeginDeleteTime(
+ TimePeriod time_period) {
+ base::TimeDelta diff;
+ base::Time delete_begin_time = base::Time::Now();
+ switch (time_period) {
+ case LAST_DAY:
+ diff = base::TimeDelta::FromHours(24);
+ break;
+ case LAST_WEEK:
+ diff = base::TimeDelta::FromHours(7*24);
+ break;
+ case FOUR_WEEKS:
+ diff = base::TimeDelta::FromHours(4*7*24);
+ break;
+ case EVERYTHING:
+ delete_begin_time = base::Time();
+ break;
+ default:
+ NOTREACHED() << L"Missing item";
+ break;
+ }
+ return delete_begin_time - diff;
+}
+
void BrowsingDataRemover::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -195,8 +230,8 @@ void BrowsingDataRemover::ClearedCache() {
NotifyAndDeleteIfDone();
}
-void BrowsingDataRemover::ClearCacheOnIOThread(Time delete_begin,
- Time delete_end,
+void BrowsingDataRemover::ClearCacheOnIOThread(base::Time delete_begin,
+ base::Time delete_end,
MessageLoop* ui_loop) {
// This function should be called on the IO thread.
DCHECK(MessageLoop::current() ==