Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Commit

Permalink
Add preferences for the clear browsing data dialog so that
Browse files Browse the repository at this point in the history
the user choices are persistent.

Patch by Arthur Lussos <developer0420@gmail.com>
Original issue at http://codereview.chromium.org/3014

Review URL: http://codereview.chromium.org/3059

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2222 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tc@google.com committed Sep 15, 2008
1 parent 81265c4 commit 6758b3e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -12,3 +12,4 @@ James Vega <vega.james@gmail.com>
Marco Rodrigues <gothicx@gmail.com>
Matthias Reitinger <reimarvin@gmail.com>
Peter Bright <drpizza@quiscalusmexicanus.org>
Arthur Lussos <developer0420@gmail.com>
5 changes: 5 additions & 0 deletions chrome/browser/browser.cc
Expand Up @@ -179,6 +179,11 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
net::CookiePolicy::ALLOW_ALL_COOKIES);
prefs->RegisterBooleanPref(prefs::kShowHomeButton, false);
prefs->RegisterStringPref(prefs::kRecentlySelectedEncoding, L"");
prefs->RegisterBooleanPref(prefs::kDeleteBrowsingHistory, true);
prefs->RegisterBooleanPref(prefs::kDeleteDownloadHistory, true);
prefs->RegisterBooleanPref(prefs::kDeleteCache, true);
prefs->RegisterBooleanPref(prefs::kDeleteCookies, true);
prefs->RegisterBooleanPref(prefs::kDeletePasswords, false);
}

Browser::Browser(const gfx::Rect& initial_bounds,
Expand Down
33 changes: 28 additions & 5 deletions chrome/browser/views/clear_browsing_data.cc
Expand Up @@ -15,6 +15,8 @@
#include "chrome/views/native_button.h"
#include "chrome/views/throbber.h"
#include "chrome/views/window.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "net/url_request/url_request_context.h"

#include "generated_resources.h"
Expand Down Expand Up @@ -70,19 +72,24 @@ void ClearBrowsingDataView::Init() {

// Add all the check-boxes.
del_history_checkbox_ =
AddCheckbox(l10n_util::GetString(IDS_DEL_BROWSING_HISTORY_CHKBOX), true);
AddCheckbox(l10n_util::GetString(IDS_DEL_BROWSING_HISTORY_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kDeleteBrowsingHistory));

del_downloads_checkbox_ =
AddCheckbox(l10n_util::GetString(IDS_DEL_DOWNLOAD_HISTORY_CHKBOX), true);
AddCheckbox(l10n_util::GetString(IDS_DEL_DOWNLOAD_HISTORY_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kDeleteDownloadHistory));

del_cache_checkbox_ =
AddCheckbox(l10n_util::GetString(IDS_DEL_CACHE_CHKBOX), true);
AddCheckbox(l10n_util::GetString(IDS_DEL_CACHE_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kDeleteCache));

del_cookies_checkbox_ =
AddCheckbox(l10n_util::GetString(IDS_DEL_COOKIES_CHKBOX), true);
AddCheckbox(l10n_util::GetString(IDS_DEL_COOKIES_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kDeleteCookies));

del_passwords_checkbox_ =
AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), false);
AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kDeletePasswords));

// Add a label which appears before the combo box for the time period.
time_period_label_ = new ChromeViews::Label(
Expand Down Expand Up @@ -302,6 +309,22 @@ std::wstring ClearBrowsingDataView::GetItemAt(ChromeViews::ComboBox* source,
// ClearBrowsingDataView, ChromeViews::ButtonListener implementation:

void ClearBrowsingDataView::ButtonPressed(ChromeViews::NativeButton* sender) {
if (sender == del_history_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory,
del_history_checkbox_->IsSelected() ? true : false);
else if (sender == del_downloads_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory,
del_downloads_checkbox_->IsSelected() ? true : false);
else if (sender == del_cache_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache,
del_cache_checkbox_->IsSelected() ? true : false);
else if (sender == del_cookies_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies,
del_cookies_checkbox_->IsSelected() ? true : false);
else if (sender == del_passwords_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeletePasswords,
del_passwords_checkbox_->IsSelected() ? true : false);

// When no checkbox is checked we should not have the action button enabled.
// This forces the button to evaluate what state they should be in.
GetDialogClientView()->UpdateDialogButtons();
Expand Down
9 changes: 9 additions & 0 deletions chrome/common/pref_names.cc
Expand Up @@ -193,6 +193,15 @@ const wchar_t kShowHomeButton[] = L"browser.show_home_button";
const wchar_t kRecentlySelectedEncoding[] =
L"profile.recently_selected_encodings";

// Boolean prefs that define the default values for the check boxes in the Clear
// Browsing Data dialog.
const wchar_t kDeleteBrowsingHistory[] = L"browser.clear_data.browsing_history";
const wchar_t kDeleteDownloadHistory[] =
L"browser.clear_data.download_history";
const wchar_t kDeleteCache[] = L"browser.clear_data.cache";
const wchar_t kDeleteCookies[] = L"browser.clear_data.cookies";
const wchar_t kDeletePasswords[] = L"browser.clear_data.passwords";


// *************** LOCAL STATE ***************
// These are attached to the machine/installation
Expand Down
5 changes: 5 additions & 0 deletions chrome/common/pref_names.h
Expand Up @@ -63,6 +63,11 @@ extern const wchar_t kDnsStartupPrefetchList[];
extern const wchar_t kIpcDisabledMessages[];
extern const wchar_t kShowHomeButton[];
extern const wchar_t kRecentlySelectedEncoding[];
extern const wchar_t kDeleteBrowsingHistory[];
extern const wchar_t kDeleteDownloadHistory[];
extern const wchar_t kDeleteCache[];
extern const wchar_t kDeleteCookies[];
extern const wchar_t kDeletePasswords[];

// Local state
extern const wchar_t kAvailableProfiles[];
Expand Down

0 comments on commit 6758b3e

Please sign in to comment.