| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk/clear_browsing_data_dialog_gtk.h" | 5 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 profile_(profile), remover_(NULL) { | 38 profile_(profile), remover_(NULL) { |
| 39 // Build the dialog. | 39 // Build the dialog. |
| 40 std::string dialog_name = l10n_util::GetStringUTF8( | 40 std::string dialog_name = l10n_util::GetStringUTF8( |
| 41 IDS_CLEAR_BROWSING_DATA_TITLE); | 41 IDS_CLEAR_BROWSING_DATA_TITLE); |
| 42 dialog_ = gtk_dialog_new_with_buttons( | 42 dialog_ = gtk_dialog_new_with_buttons( |
| 43 dialog_name.c_str(), | 43 dialog_name.c_str(), |
| 44 parent, | 44 parent, |
| 45 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), | 45 (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
| 46 NULL); | 46 NULL); |
| 47 | 47 |
| 48 GtkWidget* close_button = gtk_dialog_add_button(GTK_DIALOG(dialog_), | 48 GtkWidget* cancel_button = gtk_dialog_add_button(GTK_DIALOG(dialog_), |
| 49 GTK_STOCK_CLOSE, GTK_RESPONSE_REJECT); | 49 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT); |
| 50 gtk_widget_grab_focus(close_button); | 50 gtk_widget_grab_focus(cancel_button); |
| 51 | 51 |
| 52 accessible_widget_helper_.reset(new AccessibleWidgetHelper(dialog_, profile)); | 52 accessible_widget_helper_.reset(new AccessibleWidgetHelper(dialog_, profile)); |
| 53 accessible_widget_helper_->SendOpenWindowNotification(dialog_name); | 53 accessible_widget_helper_->SendOpenWindowNotification(dialog_name); |
| 54 | 54 |
| 55 gtk_util::AddButtonToDialog(dialog_, | 55 gtk_util::AddButtonToDialog(dialog_, |
| 56 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), | 56 l10n_util::GetStringUTF8(IDS_CLEAR_BROWSING_DATA_COMMIT).c_str(), |
| 57 GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); | 57 GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT); |
| 58 | 58 |
| 59 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; | 59 GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox; |
| 60 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); | 60 gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 gtk_util::ShowModalDialogWithMinLocalizedWidth(dialog_, | 181 gtk_util::ShowModalDialogWithMinLocalizedWidth(dialog_, |
| 182 IDS_CLEARDATA_DIALOG_WIDTH_CHARS); | 182 IDS_CLEARDATA_DIALOG_WIDTH_CHARS); |
| 183 } | 183 } |
| 184 | 184 |
| 185 ClearBrowsingDataDialogGtk::~ClearBrowsingDataDialogGtk() { | 185 ClearBrowsingDataDialogGtk::~ClearBrowsingDataDialogGtk() { |
| 186 } | 186 } |
| 187 | 187 |
| 188 void ClearBrowsingDataDialogGtk::OnDialogResponse(GtkWidget* widget, | 188 void ClearBrowsingDataDialogGtk::OnDialogResponse(GtkWidget* widget, |
| 189 int response) { | 189 int response) { |
| 190 if (response == GTK_RESPONSE_ACCEPT) { | 190 if (response == GTK_RESPONSE_ACCEPT) { |
| 191 PrefService* prefs = profile_->GetPrefs(); |
| 192 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, |
| 193 IsChecked(del_history_checkbox_)); |
| 194 prefs->SetBoolean(prefs::kDeleteDownloadHistory, |
| 195 IsChecked(del_downloads_checkbox_)); |
| 196 prefs->SetBoolean(prefs::kDeleteCache, |
| 197 IsChecked(del_cache_checkbox_)); |
| 198 prefs->SetBoolean(prefs::kDeleteCookies, |
| 199 IsChecked(del_cookies_checkbox_)); |
| 200 prefs->SetBoolean(prefs::kDeletePasswords, |
| 201 IsChecked(del_passwords_checkbox_)); |
| 202 prefs->SetBoolean(prefs::kDeleteFormData, |
| 203 IsChecked(del_form_data_checkbox_)); |
| 204 prefs->SetInteger(prefs::kDeleteTimePeriod, |
| 205 gtk_combo_box_get_active(GTK_COMBO_BOX(time_period_combobox_))); |
| 206 |
| 191 int period_selected = gtk_combo_box_get_active( | 207 int period_selected = gtk_combo_box_get_active( |
| 192 GTK_COMBO_BOX(time_period_combobox_)); | 208 GTK_COMBO_BOX(time_period_combobox_)); |
| 193 | 209 |
| 194 // BrowsingDataRemover deletes itself when done. | 210 // BrowsingDataRemover deletes itself when done. |
| 195 remover_ = new BrowsingDataRemover(profile_, | 211 remover_ = new BrowsingDataRemover(profile_, |
| 196 static_cast<BrowsingDataRemover::TimePeriod>(period_selected), | 212 static_cast<BrowsingDataRemover::TimePeriod>(period_selected), |
| 197 base::Time()); | 213 base::Time()); |
| 198 remover_->Remove(GetCheckedItems()); | 214 remover_->Remove(GetCheckedItems()); |
| 199 } | 215 } |
| 200 | 216 |
| 201 delete this; | 217 delete this; |
| 202 gtk_widget_destroy(GTK_WIDGET(widget)); | 218 gtk_widget_destroy(GTK_WIDGET(widget)); |
| 203 } | 219 } |
| 204 | 220 |
| 205 void ClearBrowsingDataDialogGtk::OnDialogWidgetClicked(GtkWidget* widget) { | 221 void ClearBrowsingDataDialogGtk::OnDialogWidgetClicked(GtkWidget* widget) { |
| 206 if (widget == del_history_checkbox_) { | |
| 207 profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory, | |
| 208 IsChecked(widget)); | |
| 209 } else if (widget == del_downloads_checkbox_) { | |
| 210 profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory, | |
| 211 IsChecked(widget)); | |
| 212 } else if (widget == del_cache_checkbox_) { | |
| 213 profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache, | |
| 214 IsChecked(widget)); | |
| 215 } else if (widget == del_cookies_checkbox_) { | |
| 216 profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies, | |
| 217 IsChecked(widget)); | |
| 218 } else if (widget == del_passwords_checkbox_) { | |
| 219 profile_->GetPrefs()->SetBoolean(prefs::kDeletePasswords, | |
| 220 IsChecked(widget)); | |
| 221 } else if (widget == del_form_data_checkbox_) { | |
| 222 profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData, | |
| 223 IsChecked(widget)); | |
| 224 } else if (widget == time_period_combobox_) { | |
| 225 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, | |
| 226 gtk_combo_box_get_active(GTK_COMBO_BOX(widget))); | |
| 227 } | |
| 228 UpdateDialogButtons(); | 222 UpdateDialogButtons(); |
| 229 } | 223 } |
| 230 | 224 |
| 231 void ClearBrowsingDataDialogGtk::OnFlashLinkClicked(GtkWidget* button) { | 225 void ClearBrowsingDataDialogGtk::OnFlashLinkClicked(GtkWidget* button) { |
| 232 // We open a new browser window so the Options dialog doesn't get lost | 226 // We open a new browser window so the Options dialog doesn't get lost |
| 233 // behind other windows. | 227 // behind other windows. |
| 234 Browser* browser = Browser::Create(profile_); | 228 Browser* browser = Browser::Create(profile_); |
| 235 browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_FLASH_STORAGE_URL)), | 229 browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_FLASH_STORAGE_URL)), |
| 236 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 230 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 237 browser->window()->Show(); | 231 browser->window()->Show(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 251 if (IsChecked(del_cookies_checkbox_)) | 245 if (IsChecked(del_cookies_checkbox_)) |
| 252 items |= BrowsingDataRemover::REMOVE_COOKIES; | 246 items |= BrowsingDataRemover::REMOVE_COOKIES; |
| 253 if (IsChecked(del_passwords_checkbox_)) | 247 if (IsChecked(del_passwords_checkbox_)) |
| 254 items |= BrowsingDataRemover::REMOVE_PASSWORDS; | 248 items |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 255 if (IsChecked(del_form_data_checkbox_)) | 249 if (IsChecked(del_form_data_checkbox_)) |
| 256 items |= BrowsingDataRemover::REMOVE_FORM_DATA; | 250 items |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 257 if (IsChecked(del_cache_checkbox_)) | 251 if (IsChecked(del_cache_checkbox_)) |
| 258 items |= BrowsingDataRemover::REMOVE_CACHE; | 252 items |= BrowsingDataRemover::REMOVE_CACHE; |
| 259 return items; | 253 return items; |
| 260 } | 254 } |
| OLD | NEW |