diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 05:05:24 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 05:05:24 +0000 |
commit | 8f51d68fb92cd74f374edc44347abe5000cbd2ec (patch) | |
tree | 48f8820cfc3019d421286cc2f70e9877696a7d86 /chrome/browser | |
parent | bd92c3aee82e619df3526b4d971b706ab070167c (diff) | |
download | chromium_src-8f51d68fb92cd74f374edc44347abe5000cbd2ec.zip chromium_src-8f51d68fb92cd74f374edc44347abe5000cbd2ec.tar.gz chromium_src-8f51d68fb92cd74f374edc44347abe5000cbd2ec.tar.bz2 |
Adds "Delete Local Storage" option to "Clear Browsing Data" for Windows and GTK.
NOTE: This change does not contain src/chrome/app/nibs/ClearBrowsingData.xib. It'll be edited by someone who knows about Mac.
BUG=none
TEST=The clear browser data dialog box should have a new option: Delete local storage"
Landing for Marcus
Original CL: http://codereview.chromium.org/524026
Review URL: http://codereview.chromium.org/542048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.cc | 4 | ||||
-rw-r--r-- | chrome/browser/browsing_data_remover.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/clear_browsing_data_controller.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/clear_browsing_data_controller.mm | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm | 6 | ||||
-rw-r--r-- | chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc | 18 | ||||
-rw-r--r-- | chrome/browser/gtk/clear_browsing_data_dialog_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.cc | 23 | ||||
-rw-r--r-- | chrome/browser/views/clear_browsing_data.h | 1 |
10 files changed, 60 insertions, 2 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 5d928de..0cfbe13 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1394,6 +1394,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, true); prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory, true); prefs->RegisterBooleanPref(prefs::kDeleteCache, true); + prefs->RegisterBooleanPref(prefs::kDeleteLocalStorage, true); prefs->RegisterBooleanPref(prefs::kDeleteCookies, true); prefs->RegisterBooleanPref(prefs::kDeletePasswords, false); prefs->RegisterBooleanPref(prefs::kDeleteFormData, true); diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc index 11581b9..958d298 100644 --- a/chrome/browser/browsing_data_remover.cc +++ b/chrome/browser/browsing_data_remover.cc @@ -112,6 +112,10 @@ void BrowsingDataRemover::Remove(int remove_mask) { profile_->GetRequestContext()->GetCookieStore()->GetCookieMonster(); if (cookie_monster) cookie_monster->DeleteAllCreatedBetween(delete_begin_, delete_end_, true); + } + + if (remove_mask & REMOVE_LOCAL_STORAGE) { + UserMetrics::RecordAction("ClearBrowsingData_LocalStorage", profile_); profile_->GetWebKitContext()->DeleteDataModifiedSince(delete_begin_); } diff --git a/chrome/browser/browsing_data_remover.h b/chrome/browser/browsing_data_remover.h index 8fccfe0..a635c69 100644 --- a/chrome/browser/browsing_data_remover.h +++ b/chrome/browser/browsing_data_remover.h @@ -35,6 +35,7 @@ class BrowsingDataRemover : public NotificationObserver { static const int REMOVE_PASSWORDS = 1 << 3; static const int REMOVE_FORM_DATA = 1 << 4; static const int REMOVE_CACHE = 1 << 5; + static const int REMOVE_LOCAL_STORAGE = 1 << 6; // Observer is notified when the removal is done. Done means keywords have // been deleted, cache cleared and all other tasks scheduled. diff --git a/chrome/browser/cocoa/clear_browsing_data_controller.h b/chrome/browser/cocoa/clear_browsing_data_controller.h index 4b75024..8cded9f 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller.h +++ b/chrome/browser/cocoa/clear_browsing_data_controller.h @@ -33,6 +33,7 @@ class Profile; BOOL clearBrowsingHistory_; BOOL clearDownloadHistory_; BOOL emptyCache_; + BOOL deleteLocalStorage_; BOOL deleteCookies_; BOOL clearSavedPasswords_; BOOL clearFormData_; @@ -57,6 +58,7 @@ class Profile; @property BOOL clearBrowsingHistory; @property BOOL clearDownloadHistory; @property BOOL emptyCache; +@property BOOL deleteLocalStorage; @property BOOL deleteCookies; @property BOOL clearSavedPasswords; @property BOOL clearFormData; diff --git a/chrome/browser/cocoa/clear_browsing_data_controller.mm b/chrome/browser/cocoa/clear_browsing_data_controller.mm index 28ad931..00f2260 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller.mm +++ b/chrome/browser/cocoa/clear_browsing_data_controller.mm @@ -38,6 +38,7 @@ typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; @synthesize clearBrowsingHistory = clearBrowsingHistory_; @synthesize clearDownloadHistory = clearDownloadHistory_; @synthesize emptyCache = emptyCache_; +@synthesize deleteLocalStorage = deleteLocalStorage_; @synthesize deleteCookies = deleteCookies_; @synthesize clearSavedPasswords = clearSavedPasswords_; @synthesize clearFormData = clearFormData_; @@ -112,6 +113,8 @@ typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; if (emptyCache_) removeMask |= BrowsingDataRemover::REMOVE_CACHE; + if (deleteLocalStorage_) + removeMask |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE; if (deleteCookies_) removeMask |= BrowsingDataRemover::REMOVE_COOKIES; if (clearSavedPasswords_) @@ -164,6 +167,7 @@ typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; [self setClearDownloadHistory: prefs->GetBoolean(prefs::kDeleteDownloadHistory)]; [self setEmptyCache:prefs->GetBoolean(prefs::kDeleteCache)]; + [self setDeleteLocalStorage:prefs->GetBoolean(prefs::kDeleteLocalStorage)]; [self setDeleteCookies:prefs->GetBoolean(prefs::kDeleteCookies)]; [self setClearSavedPasswords:prefs->GetBoolean(prefs::kDeletePasswords)]; [self setClearFormData:prefs->GetBoolean(prefs::kDeleteFormData)]; @@ -178,6 +182,7 @@ typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; prefs->SetBoolean(prefs::kDeleteDownloadHistory, [self clearDownloadHistory]); prefs->SetBoolean(prefs::kDeleteCache, [self emptyCache]); + prefs->SetBoolean(prefs::kDeleteLocalStorage, [self deleteLocalStorage]); prefs->SetBoolean(prefs::kDeleteCookies, [self deleteCookies]); prefs->SetBoolean(prefs::kDeletePasswords, [self clearSavedPasswords]); prefs->SetBoolean(prefs::kDeleteFormData, [self clearFormData]); diff --git a/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm b/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm index 15b2ee0..7c53e19 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm +++ b/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm @@ -26,6 +26,7 @@ class ClearBrowsingDataControllerTest : public CocoaTest { prefs->SetBoolean(prefs::kDeleteBrowsingHistory, true); prefs->SetBoolean(prefs::kDeleteDownloadHistory, false); prefs->SetBoolean(prefs::kDeleteCache, true); + prefs->SetBoolean(prefs::kDeleteLocalStorage, true); prefs->SetBoolean(prefs::kDeleteCookies, false); prefs->SetBoolean(prefs::kDeletePasswords, true); prefs->SetBoolean(prefs::kDeleteFormData, false); @@ -49,6 +50,7 @@ TEST_F(ClearBrowsingDataControllerTest, InitialState) { EXPECT_TRUE([controller_ clearBrowsingHistory]); EXPECT_FALSE([controller_ clearDownloadHistory]); EXPECT_TRUE([controller_ emptyCache]); + EXPECT_TRUE([controller_ deleteLocalStorage]); EXPECT_FALSE([controller_ deleteCookies]); EXPECT_TRUE([controller_ clearSavedPasswords]); EXPECT_FALSE([controller_ clearFormData]); @@ -60,6 +62,7 @@ TEST_F(ClearBrowsingDataControllerTest, InitialRemoveMask) { // Check that the remove-mask matches the initial properties: EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_CACHE | + BrowsingDataRemover::REMOVE_LOCAL_STORAGE | BrowsingDataRemover::REMOVE_PASSWORDS, [controller_ removeMask]); } @@ -69,6 +72,7 @@ TEST_F(ClearBrowsingDataControllerTest, ModifiedRemoveMask) { [controller_ setClearBrowsingHistory:false]; [controller_ setClearDownloadHistory:true]; [controller_ setEmptyCache:false]; + [controller_ setDeleteLocalStorage:false]; [controller_ setDeleteCookies:true]; [controller_ setClearSavedPasswords:false]; [controller_ setClearFormData:true]; @@ -84,6 +88,7 @@ TEST_F(ClearBrowsingDataControllerTest, EmptyRemoveMask) { [controller_ setClearBrowsingHistory:false]; [controller_ setClearDownloadHistory:false]; [controller_ setEmptyCache:false]; + [controller_ setDeleteLocalStorage:false]; [controller_ setDeleteCookies:false]; [controller_ setClearSavedPasswords:false]; [controller_ setClearFormData:false]; @@ -105,6 +110,7 @@ TEST_F(ClearBrowsingDataControllerTest, PersistToPrefs) { // Make sure the rest of the prefs didn't change: EXPECT_TRUE(prefs->GetBoolean(prefs::kDeleteCache)); + EXPECT_TRUE(prefs->GetBoolean(prefs::kDeleteLocalStorage)); EXPECT_FALSE(prefs->GetBoolean(prefs::kDeleteCookies)); EXPECT_TRUE(prefs->GetBoolean(prefs::kDeletePasswords)); EXPECT_FALSE(prefs->GetBoolean(prefs::kDeleteFormData)); diff --git a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc index b85d86b..6259923 100644 --- a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc +++ b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc @@ -77,6 +77,16 @@ ClearBrowsingDataDialogGtk::ClearBrowsingDataDialogGtk(GtkWindow* parent, g_signal_connect(del_cache_checkbox_, "toggled", G_CALLBACK(HandleOnClickedWidget), this); + // Local Storage checkbox. + del_local_storage_checkbox_ = gtk_check_button_new_with_label( + l10n_util::GetStringUTF8(IDS_DEL_LOCAL_STORAGE_CHKBOX).c_str()); + gtk_box_pack_start(GTK_BOX(vbox), del_local_storage_checkbox_, + FALSE, FALSE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(del_local_storage_checkbox_), + profile_->GetPrefs()->GetBoolean(prefs::kDeleteLocalStorage)); + g_signal_connect(del_local_storage_checkbox_, "toggled", + G_CALLBACK(HandleOnClickedWidget), this); + // Cookies checkbox. del_cookies_checkbox_ = gtk_check_button_new_with_label( l10n_util::GetStringUTF8(IDS_DEL_COOKIES_CHKBOX).c_str()); @@ -160,6 +170,10 @@ void ClearBrowsingDataDialogGtk::OnDialogResponse(GtkWidget* widget, } if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(del_cache_checkbox_))) items |= BrowsingDataRemover::REMOVE_CACHE; + if (gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(del_local_storage_checkbox_))) { + items |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE; + } // BrowsingDataRemover deletes itself when done. remover_ = new BrowsingDataRemover(profile_, @@ -185,6 +199,10 @@ void ClearBrowsingDataDialogGtk::OnDialogWidgetClicked(GtkWidget* widget) { profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? true : false); + } else if (widget == del_local_storage_checkbox_) { + profile_->GetPrefs()->SetBoolean(prefs::kDeleteLocalStorage, + gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? + true : false); } else if (widget == del_cookies_checkbox_) { profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? diff --git a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.h b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.h index 46a3c73..50da842 100644 --- a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.h +++ b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.h @@ -41,6 +41,7 @@ class ClearBrowsingDataDialogGtk { GtkWidget* del_history_checkbox_; GtkWidget* del_downloads_checkbox_; GtkWidget* del_cache_checkbox_; + GtkWidget* del_local_storage_checkbox_; GtkWidget* del_cookies_checkbox_; GtkWidget* del_passwords_checkbox_; GtkWidget* del_form_data_checkbox_; diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc index 8b94636..54bb6e7 100644 --- a/chrome/browser/views/clear_browsing_data.cc +++ b/chrome/browser/views/clear_browsing_data.cc @@ -44,6 +44,7 @@ ClearBrowsingDataView::ClearBrowsingDataView(Profile* profile) : del_history_checkbox_(NULL), del_downloads_checkbox_(NULL), del_cache_checkbox_(NULL), + del_local_storage_checkbox_(NULL), del_cookies_checkbox_(NULL), del_passwords_checkbox_(NULL), del_form_data_checkbox_(NULL), @@ -94,6 +95,10 @@ void ClearBrowsingDataView::Init() { AddCheckbox(l10n_util::GetString(IDS_DEL_CACHE_CHKBOX), profile_->GetPrefs()->GetBoolean(prefs::kDeleteCache)); + del_local_storage_checkbox_ = + AddCheckbox(l10n_util::GetString(IDS_DEL_LOCAL_STORAGE_CHKBOX), + profile_->GetPrefs()->GetBoolean(prefs::kDeleteLocalStorage)); + del_cookies_checkbox_ = AddCheckbox(l10n_util::GetString(IDS_DEL_COOKIES_CHKBOX), profile_->GetPrefs()->GetBoolean(prefs::kDeleteCookies)); @@ -158,10 +163,17 @@ void ClearBrowsingDataView::Layout() { kRelatedControlVerticalSpacing, sz.width(), sz.height()); + sz = del_local_storage_checkbox_->GetPreferredSize(); + del_local_storage_checkbox_->SetBounds(2 * kPanelHorizMargin, + del_cache_checkbox_->y() + + del_cache_checkbox_->height() + + kRelatedControlVerticalSpacing, + sz.width(), sz.height()); + sz = del_cookies_checkbox_->GetPreferredSize(); del_cookies_checkbox_->SetBounds(2 * kPanelHorizMargin, - del_cache_checkbox_->y() + - del_cache_checkbox_->height() + + del_local_storage_checkbox_->y() + + del_local_storage_checkbox_->height() + kRelatedControlVerticalSpacing, sz.width(), sz.height()); @@ -268,6 +280,7 @@ bool ClearBrowsingDataView::IsDialogButtonEnabled( return del_history_checkbox_->checked() || del_downloads_checkbox_->checked() || del_cache_checkbox_->checked() || + del_local_storage_checkbox_->checked() || del_cookies_checkbox_->checked() || del_passwords_checkbox_->checked() || del_form_data_checkbox_->checked(); @@ -354,6 +367,9 @@ void ClearBrowsingDataView::ButtonPressed( else if (sender == del_cache_checkbox_) profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache, del_cache_checkbox_->checked() ? true : false); + else if (sender == del_local_storage_checkbox_) + profile_->GetPrefs()->SetBoolean(prefs::kDeleteLocalStorage, + del_local_storage_checkbox_->checked() ? true : false); else if (sender == del_cookies_checkbox_) profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies, del_cookies_checkbox_->checked() ? true : false); @@ -387,6 +403,7 @@ void ClearBrowsingDataView::UpdateControlEnabledState() { del_history_checkbox_->SetEnabled(!delete_in_progress_); del_downloads_checkbox_->SetEnabled(!delete_in_progress_); del_cache_checkbox_->SetEnabled(!delete_in_progress_); + del_local_storage_checkbox_->SetEnabled(!delete_in_progress_); del_cookies_checkbox_->SetEnabled(!delete_in_progress_); del_passwords_checkbox_->SetEnabled(!delete_in_progress_); del_form_data_checkbox_->SetEnabled(!delete_in_progress_); @@ -425,6 +442,8 @@ void ClearBrowsingDataView::OnDelete() { remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; if (IsCheckBoxEnabledAndSelected(del_cache_checkbox_)) remove_mask |= BrowsingDataRemover::REMOVE_CACHE; + if (IsCheckBoxEnabledAndSelected(del_local_storage_checkbox_)) + remove_mask |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE; delete_in_progress_ = true; UpdateControlEnabledState(); diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h index cf0df5f..310b487 100644 --- a/chrome/browser/views/clear_browsing_data.h +++ b/chrome/browser/views/clear_browsing_data.h @@ -99,6 +99,7 @@ class ClearBrowsingDataView : public views::View, views::Checkbox* del_history_checkbox_; views::Checkbox* del_downloads_checkbox_; views::Checkbox* del_cache_checkbox_; + views::Checkbox* del_local_storage_checkbox_; views::Checkbox* del_cookies_checkbox_; views::Checkbox* del_passwords_checkbox_; views::Checkbox* del_form_data_checkbox_; |