| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/clear_browsing_data.h" | 5 #include "chrome/browser/views/clear_browsing_data.h" |
| 6 | 6 |
| 7 #include "chrome/app/locales/locale_settings.h" | 7 #include "chrome/app/locales/locale_settings.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/template_url_model.h" | 9 #include "chrome/browser/template_url_model.h" |
| 10 #include "chrome/browser/views/standard_layout.h" | 10 #include "chrome/browser/views/standard_layout.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), | 91 AddCheckbox(l10n_util::GetString(IDS_DEL_PASSWORDS_CHKBOX), |
| 92 profile_->GetPrefs()->GetBoolean(prefs::kDeletePasswords)); | 92 profile_->GetPrefs()->GetBoolean(prefs::kDeletePasswords)); |
| 93 | 93 |
| 94 // Add a label which appears before the combo box for the time period. | 94 // Add a label which appears before the combo box for the time period. |
| 95 time_period_label_ = new views::Label( | 95 time_period_label_ = new views::Label( |
| 96 l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TIME_LABEL)); | 96 l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TIME_LABEL)); |
| 97 AddChildView(time_period_label_); | 97 AddChildView(time_period_label_); |
| 98 | 98 |
| 99 // Add the combo box showing how far back in time we want to delete. | 99 // Add the combo box showing how far back in time we want to delete. |
| 100 time_period_combobox_ = new views::ComboBox(this); | 100 time_period_combobox_ = new views::ComboBox(this); |
| 101 time_period_combobox_->SetSelectedItem(profile_->GetPrefs()->GetInteger( |
| 102 prefs::kDeleteTimePeriod)); |
| 103 time_period_combobox_->SetListener(this); |
| 101 AddChildView(time_period_combobox_); | 104 AddChildView(time_period_combobox_); |
| 102 } | 105 } |
| 103 | 106 |
| 104 //////////////////////////////////////////////////////////////////////////////// | 107 //////////////////////////////////////////////////////////////////////////////// |
| 105 // ClearBrowsingDataView, views::View implementation: | 108 // ClearBrowsingDataView, views::View implementation: |
| 106 | 109 |
| 107 gfx::Size ClearBrowsingDataView::GetPreferredSize() { | 110 gfx::Size ClearBrowsingDataView::GetPreferredSize() { |
| 108 return gfx::Size(views::Window::GetLocalizedContentsSize( | 111 return gfx::Size(views::Window::GetLocalizedContentsSize( |
| 109 IDS_CLEARDATA_DIALOG_WIDTH_CHARS, | 112 IDS_CLEARDATA_DIALOG_WIDTH_CHARS, |
| 110 IDS_CLEARDATA_DIALOG_HEIGHT_LINES)); | 113 IDS_CLEARDATA_DIALOG_HEIGHT_LINES)); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 case 0: return l10n_util::GetString(IDS_CLEAR_DATA_DAY); | 298 case 0: return l10n_util::GetString(IDS_CLEAR_DATA_DAY); |
| 296 case 1: return l10n_util::GetString(IDS_CLEAR_DATA_WEEK); | 299 case 1: return l10n_util::GetString(IDS_CLEAR_DATA_WEEK); |
| 297 case 2: return l10n_util::GetString(IDS_CLEAR_DATA_4WEEKS); | 300 case 2: return l10n_util::GetString(IDS_CLEAR_DATA_4WEEKS); |
| 298 case 3: return l10n_util::GetString(IDS_CLEAR_DATA_EVERYTHING); | 301 case 3: return l10n_util::GetString(IDS_CLEAR_DATA_EVERYTHING); |
| 299 default: NOTREACHED() << L"Missing item"; | 302 default: NOTREACHED() << L"Missing item"; |
| 300 return L"?"; | 303 return L"?"; |
| 301 } | 304 } |
| 302 } | 305 } |
| 303 | 306 |
| 304 //////////////////////////////////////////////////////////////////////////////// | 307 //////////////////////////////////////////////////////////////////////////////// |
| 308 // ClearBrowsingDataView, views::ComboBoxListener implementation: |
| 309 |
| 310 void ClearBrowsingDataView::ItemChanged(views::ComboBox* sender, |
| 311 int prev_index, int new_index) { |
| 312 if (sender == time_period_combobox_ && prev_index != new_index) |
| 313 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index); |
| 314 } |
| 315 |
| 316 //////////////////////////////////////////////////////////////////////////////// |
| 305 // ClearBrowsingDataView, views::ButtonListener implementation: | 317 // ClearBrowsingDataView, views::ButtonListener implementation: |
| 306 | 318 |
| 307 void ClearBrowsingDataView::ButtonPressed(views::NativeButton* sender) { | 319 void ClearBrowsingDataView::ButtonPressed(views::NativeButton* sender) { |
| 308 if (sender == del_history_checkbox_) | 320 if (sender == del_history_checkbox_) |
| 309 profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory, | 321 profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory, |
| 310 del_history_checkbox_->IsSelected() ? true : false); | 322 del_history_checkbox_->IsSelected() ? true : false); |
| 311 else if (sender == del_downloads_checkbox_) | 323 else if (sender == del_downloads_checkbox_) |
| 312 profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory, | 324 profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory, |
| 313 del_downloads_checkbox_->IsSelected() ? true : false); | 325 del_downloads_checkbox_->IsSelected() ? true : false); |
| 314 else if (sender == del_cache_checkbox_) | 326 else if (sender == del_cache_checkbox_) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 remover_->Remove(remove_mask); | 414 remover_->Remove(remove_mask); |
| 403 } | 415 } |
| 404 | 416 |
| 405 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { | 417 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { |
| 406 // No need to remove ourselves as an observer as BrowsingDataRemover deletes | 418 // No need to remove ourselves as an observer as BrowsingDataRemover deletes |
| 407 // itself after we return. | 419 // itself after we return. |
| 408 remover_ = NULL; | 420 remover_ = NULL; |
| 409 window()->Close(); | 421 window()->Close(); |
| 410 } | 422 } |
| 411 | 423 |
| OLD | NEW |