Index: chrome/browser/ui/views/clear_browsing_data.cc |
diff --git a/chrome/browser/ui/views/clear_browsing_data.cc b/chrome/browser/ui/views/clear_browsing_data.cc |
index 0f9a331d10567c6ab87889d4bce26910bec0d64f..dd2e61d5518f7c4934ecbee2ebe6593a1ab4509b 100644 |
--- a/chrome/browser/ui/views/clear_browsing_data.cc |
+++ b/chrome/browser/ui/views/clear_browsing_data.cc |
@@ -7,14 +7,13 @@ |
#include "app/l10n_util.h" |
#include "base/string16.h" |
#include "base/utf_string_conversions.h" |
+#include "chrome/browser/browser_process.h" |
#include "chrome/browser/browser_window.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/search_engines/template_url_model.h" |
#include "chrome/browser/ui/browser.h" |
-#if defined(OS_WIN) |
-#include "chrome/browser/views/clear_browsing_data_view.h" |
-#endif |
+#include "chrome/common/notification_details.h" |
#include "chrome/common/pref_names.h" |
#include "gfx/insets.h" |
#include "grit/generated_resources.h" |
@@ -31,6 +30,10 @@ |
#include "views/window/dialog_client_view.h" |
#include "views/window/window.h" |
+#if defined(OS_WIN) |
+#include "chrome/browser/views/clear_browsing_data_view.h" |
+#endif |
+ |
using views::GridLayout; |
// The combo box is vertically aligned to the 'time-period' label, which makes |
@@ -60,6 +63,7 @@ ClearBrowsingDataView::ClearBrowsingDataView(Profile* profile) |
del_cache_checkbox_(NULL), |
del_cookies_checkbox_(NULL), |
del_passwords_checkbox_(NULL), |
+ del_lso_data_checkbox_(NULL), |
del_form_data_checkbox_(NULL), |
time_period_label_(NULL), |
time_period_combobox_(NULL), |
@@ -80,6 +84,10 @@ ClearBrowsingDataView::~ClearBrowsingDataView(void) { |
} |
void ClearBrowsingDataView::Init() { |
+ del_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled, |
+ g_browser_process->local_state(), |
+ this); |
+ |
// Views we will add to the *parent* of this dialog, since it will display |
// next to the buttons which we don't draw ourselves. |
throbber_ = new views::Throbber(50, true); |
@@ -95,28 +103,33 @@ void ClearBrowsingDataView::Init() { |
AddChildView(delete_all_label_); |
// Add all the check-boxes. |
- del_history_checkbox_ = |
- AddCheckbox(l10n_util::GetString(IDS_DEL_BROWSING_HISTORY_CHKBOX), |
+ del_history_checkbox_ = 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), |
+ del_downloads_checkbox_ = 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), |
+ del_cache_checkbox_ = AddCheckbox( |
+ l10n_util::GetString(IDS_DEL_CACHE_CHKBOX), |
profile_->GetPrefs()->GetBoolean(prefs::kDeleteCache)); |
- del_cookies_checkbox_ = |
- AddCheckbox(l10n_util::GetString(IDS_DEL_COOKIES_CHKBOX), |
+ del_cookies_checkbox_ = AddCheckbox( |
+ l10n_util::GetString(IDS_DEL_COOKIES_CHKBOX), |
profile_->GetPrefs()->GetBoolean(prefs::kDeleteCookies)); |
- del_passwords_checkbox_ = |
- AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), |
+ del_passwords_checkbox_ = AddCheckbox( |
+ l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), |
profile_->GetPrefs()->GetBoolean(prefs::kDeletePasswords)); |
- del_form_data_checkbox_ = |
- AddCheckbox(l10n_util::GetString(IDS_DEL_FORM_DATA_CHKBOX), |
+ del_lso_data_checkbox_ = AddCheckbox( |
+ l10n_util::GetString(IDS_DEL_FLASH_DATA_CHKBOX), |
+ false); |
+ UpdateDelLSODataState(); |
+ |
+ del_form_data_checkbox_ = AddCheckbox( |
+ l10n_util::GetString(IDS_DEL_FORM_DATA_CHKBOX), |
profile_->GetPrefs()->GetBoolean(prefs::kDeleteFormData)); |
// Add a label which appears before the combo box for the time period. |
@@ -208,10 +221,17 @@ void ClearBrowsingDataView::Layout() { |
kRelatedControlVerticalSpacing, |
sz.width(), sz.height()); |
+ sz = del_lso_data_checkbox_->GetPreferredSize(); |
+ del_lso_data_checkbox_->SetBounds(2 * kPanelHorizMargin, |
+ del_passwords_checkbox_->y() + |
+ del_passwords_checkbox_->height() + |
+ kRelatedControlVerticalSpacing, |
+ sz.width(), sz.height()); |
+ |
sz = del_form_data_checkbox_->GetPreferredSize(); |
del_form_data_checkbox_->SetBounds(2 * kPanelHorizMargin, |
- del_passwords_checkbox_->y() + |
- del_passwords_checkbox_->height() + |
+ del_lso_data_checkbox_->y() + |
+ del_lso_data_checkbox_->height() + |
kRelatedControlVerticalSpacing, |
sz.width(), sz.height()); |
@@ -262,6 +282,7 @@ bool ClearBrowsingDataView::IsDialogButtonEnabled( |
del_cache_checkbox_->checked() || |
del_cookies_checkbox_->checked() || |
del_passwords_checkbox_->checked() || |
+ del_lso_data_checkbox_->checked() || |
del_form_data_checkbox_->checked(); |
} |
@@ -308,6 +329,10 @@ bool ClearBrowsingDataView::Accept() { |
del_cookies_checkbox_->checked()); |
prefs->SetBoolean(prefs::kDeletePasswords, |
del_passwords_checkbox_->checked()); |
+ if (del_lso_data_enabled_.GetValue()) { |
+ prefs->SetBoolean(prefs::kDeleteLSOData, |
+ del_lso_data_checkbox_->checked()); |
+ } |
prefs->SetBoolean(prefs::kDeleteFormData, |
del_form_data_checkbox_->checked()); |
OnDelete(); |
@@ -384,6 +409,9 @@ void ClearBrowsingDataView::ButtonPressed(views::Button* sender, |
GetDialogClientView()->UpdateDialogButtons(); |
} |
+//////////////////////////////////////////////////////////////////////////////// |
+// ClearBrowsingDataView, views::LinkController implementation: |
+ |
void ClearBrowsingDataView::LinkActivated(views::Link* source, |
int event_flags) { |
Browser* browser = Browser::Create(profile_); |
@@ -393,6 +421,20 @@ void ClearBrowsingDataView::LinkActivated(views::Link* source, |
} |
//////////////////////////////////////////////////////////////////////////////// |
+// ClearBrowsingDataView, NotificationObserver implementation: |
+ |
+void ClearBrowsingDataView::Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) { |
+ if (type == NotificationType::PREF_CHANGED) { |
+ const std::string& pref = *(Details<std::string>(details).ptr()); |
+ if (pref == prefs::kClearPluginLSODataEnabled) { |
+ UpdateControlState(); |
+ } |
+ } |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
// ClearBrowsingDataView, private: |
views::Checkbox* ClearBrowsingDataView::AddCheckbox(const std::wstring& text, |
@@ -404,9 +446,21 @@ views::Checkbox* ClearBrowsingDataView::AddCheckbox(const std::wstring& text, |
return checkbox; |
} |
-void ClearBrowsingDataView::UpdateControlEnabledState() { |
+void ClearBrowsingDataView::UpdateDelLSODataState() { |
+ bool enabled = del_lso_data_enabled_.GetValue(); |
+ del_lso_data_checkbox_->SetChecked( |
+ enabled && |
+ profile_->GetPrefs()->GetBoolean(prefs::kDeleteLSOData)); |
+ del_lso_data_checkbox_->SetTooltipText( |
+ enabled ? std::wstring() |
+ : l10n_util::GetString(IDS_LSO_CLEAR_MESSAGE).c_str()); |
+ del_lso_data_checkbox_->SetEnabled(enabled && !delete_in_progress_); |
+} |
+ |
+void ClearBrowsingDataView::UpdateControlState() { |
window()->EnableClose(!delete_in_progress_); |
+ UpdateDelLSODataState(); |
del_history_checkbox_->SetEnabled(!delete_in_progress_); |
del_downloads_checkbox_->SetEnabled(!delete_in_progress_); |
del_cache_checkbox_->SetEnabled(!delete_in_progress_); |
@@ -444,13 +498,15 @@ void ClearBrowsingDataView::OnDelete() { |
remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; |
if (IsCheckBoxEnabledAndSelected(del_passwords_checkbox_)) |
remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
+ if (IsCheckBoxEnabledAndSelected(del_lso_data_checkbox_)) |
+ remove_mask |= BrowsingDataRemover::REMOVE_LSO_DATA; |
if (IsCheckBoxEnabledAndSelected(del_form_data_checkbox_)) |
remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
if (IsCheckBoxEnabledAndSelected(del_cache_checkbox_)) |
remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
delete_in_progress_ = true; |
- UpdateControlEnabledState(); |
+ UpdateControlState(); |
// BrowsingDataRemover deletes itself when done. |
remover_ = new BrowsingDataRemover(profile_, |