| 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/profile.h" | 8 #include "chrome/browser/profile.h" |
| 9 #include "chrome/browser/search_engines/template_url_model.h" | 9 #include "chrome/browser/search_engines/template_url_model.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 del_form_data_checkbox_ = | 106 del_form_data_checkbox_ = |
| 107 AddCheckbox(l10n_util::GetString(IDS_DEL_FORM_DATA_CHKBOX), | 107 AddCheckbox(l10n_util::GetString(IDS_DEL_FORM_DATA_CHKBOX), |
| 108 profile_->GetPrefs()->GetBoolean(prefs::kDeleteFormData)); | 108 profile_->GetPrefs()->GetBoolean(prefs::kDeleteFormData)); |
| 109 | 109 |
| 110 // Add a label which appears before the combo box for the time period. | 110 // Add a label which appears before the combo box for the time period. |
| 111 time_period_label_ = new views::Label( | 111 time_period_label_ = new views::Label( |
| 112 l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TIME_LABEL)); | 112 l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TIME_LABEL)); |
| 113 AddChildView(time_period_label_); | 113 AddChildView(time_period_label_); |
| 114 | 114 |
| 115 // Add the combo box showing how far back in time we want to delete. | 115 // Add the combo box showing how far back in time we want to delete. |
| 116 time_period_combobox_ = new views::ComboBox(this); | 116 time_period_combobox_ = new views::Combobox(this); |
| 117 time_period_combobox_->SetSelectedItem(profile_->GetPrefs()->GetInteger( | 117 time_period_combobox_->SetSelectedItem(profile_->GetPrefs()->GetInteger( |
| 118 prefs::kDeleteTimePeriod)); | 118 prefs::kDeleteTimePeriod)); |
| 119 time_period_combobox_->SetListener(this); | 119 time_period_combobox_->set_listener(this); |
| 120 AddChildView(time_period_combobox_); | 120 AddChildView(time_period_combobox_); |
| 121 } | 121 } |
| 122 | 122 |
| 123 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 124 // ClearBrowsingDataView, views::View implementation: | 124 // ClearBrowsingDataView, views::View implementation: |
| 125 | 125 |
| 126 gfx::Size ClearBrowsingDataView::GetPreferredSize() { | 126 gfx::Size ClearBrowsingDataView::GetPreferredSize() { |
| 127 return gfx::Size(views::Window::GetLocalizedContentsSize( | 127 return gfx::Size(views::Window::GetLocalizedContentsSize( |
| 128 IDS_CLEARDATA_DIALOG_WIDTH_CHARS, | 128 IDS_CLEARDATA_DIALOG_WIDTH_CHARS, |
| 129 IDS_CLEARDATA_DIALOG_HEIGHT_LINES)); | 129 IDS_CLEARDATA_DIALOG_HEIGHT_LINES)); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 | 304 |
| 305 OnDelete(); | 305 OnDelete(); |
| 306 return false; // We close the dialog in OnBrowsingDataRemoverDone(). | 306 return false; // We close the dialog in OnBrowsingDataRemoverDone(). |
| 307 } | 307 } |
| 308 | 308 |
| 309 views::View* ClearBrowsingDataView::GetContentsView() { | 309 views::View* ClearBrowsingDataView::GetContentsView() { |
| 310 return this; | 310 return this; |
| 311 } | 311 } |
| 312 | 312 |
| 313 //////////////////////////////////////////////////////////////////////////////// | 313 //////////////////////////////////////////////////////////////////////////////// |
| 314 // ClearBrowsingDataView, views::ComboBox::Model implementation: | 314 // ClearBrowsingDataView, views::Combobox::Model implementation: |
| 315 | 315 |
| 316 int ClearBrowsingDataView::GetItemCount(views::ComboBox* source) { | 316 int ClearBrowsingDataView::GetItemCount(views::Combobox* source) { |
| 317 DCHECK(source == time_period_combobox_); | 317 DCHECK(source == time_period_combobox_); |
| 318 return 4; | 318 return 4; |
| 319 } | 319 } |
| 320 | 320 |
| 321 std::wstring ClearBrowsingDataView::GetItemAt(views::ComboBox* source, | 321 std::wstring ClearBrowsingDataView::GetItemAt(views::Combobox* source, |
| 322 int index) { | 322 int index) { |
| 323 DCHECK(source == time_period_combobox_); | 323 DCHECK(source == time_period_combobox_); |
| 324 switch (index) { | 324 switch (index) { |
| 325 case 0: return l10n_util::GetString(IDS_CLEAR_DATA_DAY); | 325 case 0: return l10n_util::GetString(IDS_CLEAR_DATA_DAY); |
| 326 case 1: return l10n_util::GetString(IDS_CLEAR_DATA_WEEK); | 326 case 1: return l10n_util::GetString(IDS_CLEAR_DATA_WEEK); |
| 327 case 2: return l10n_util::GetString(IDS_CLEAR_DATA_4WEEKS); | 327 case 2: return l10n_util::GetString(IDS_CLEAR_DATA_4WEEKS); |
| 328 case 3: return l10n_util::GetString(IDS_CLEAR_DATA_EVERYTHING); | 328 case 3: return l10n_util::GetString(IDS_CLEAR_DATA_EVERYTHING); |
| 329 default: NOTREACHED() << L"Missing item"; | 329 default: NOTREACHED() << L"Missing item"; |
| 330 return L"?"; | 330 return L"?"; |
| 331 } | 331 } |
| 332 } | 332 } |
| 333 | 333 |
| 334 //////////////////////////////////////////////////////////////////////////////// | 334 //////////////////////////////////////////////////////////////////////////////// |
| 335 // ClearBrowsingDataView, views::ComboBoxListener implementation: | 335 // ClearBrowsingDataView, views::ComboBoxListener implementation: |
| 336 | 336 |
| 337 void ClearBrowsingDataView::ItemChanged(views::ComboBox* sender, | 337 void ClearBrowsingDataView::ItemChanged(views::Combobox* sender, |
| 338 int prev_index, int new_index) { | 338 int prev_index, int new_index) { |
| 339 if (sender == time_period_combobox_ && prev_index != new_index) | 339 if (sender == time_period_combobox_ && prev_index != new_index) |
| 340 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index); | 340 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index); |
| 341 } | 341 } |
| 342 | 342 |
| 343 //////////////////////////////////////////////////////////////////////////////// | 343 //////////////////////////////////////////////////////////////////////////////// |
| 344 // ClearBrowsingDataView, views::ButtonListener implementation: | 344 // ClearBrowsingDataView, views::ButtonListener implementation: |
| 345 | 345 |
| 346 void ClearBrowsingDataView::ButtonPressed(views::Button* sender) { | 346 void ClearBrowsingDataView::ButtonPressed(views::Button* sender) { |
| 347 if (sender == del_history_checkbox_) | 347 if (sender == del_history_checkbox_) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 GetDialogClientView()->UpdateDialogButtons(); | 402 GetDialogClientView()->UpdateDialogButtons(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 // Convenience method that returns true if the supplied checkbox is selected | 405 // Convenience method that returns true if the supplied checkbox is selected |
| 406 // and enabled. | 406 // and enabled. |
| 407 static bool IsCheckBoxEnabledAndSelected(views::Checkbox* cb) { | 407 static bool IsCheckBoxEnabledAndSelected(views::Checkbox* cb) { |
| 408 return (cb->IsEnabled() && cb->checked()); | 408 return (cb->IsEnabled() && cb->checked()); |
| 409 } | 409 } |
| 410 | 410 |
| 411 void ClearBrowsingDataView::OnDelete() { | 411 void ClearBrowsingDataView::OnDelete() { |
| 412 int period_selected = time_period_combobox_->GetSelectedItem(); | 412 int period_selected = time_period_combobox_->selected_item(); |
| 413 | 413 |
| 414 int remove_mask = 0; | 414 int remove_mask = 0; |
| 415 if (IsCheckBoxEnabledAndSelected(del_history_checkbox_)) | 415 if (IsCheckBoxEnabledAndSelected(del_history_checkbox_)) |
| 416 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; | 416 remove_mask |= BrowsingDataRemover::REMOVE_HISTORY; |
| 417 if (IsCheckBoxEnabledAndSelected(del_downloads_checkbox_)) | 417 if (IsCheckBoxEnabledAndSelected(del_downloads_checkbox_)) |
| 418 remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; | 418 remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS; |
| 419 if (IsCheckBoxEnabledAndSelected(del_cookies_checkbox_)) | 419 if (IsCheckBoxEnabledAndSelected(del_cookies_checkbox_)) |
| 420 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; | 420 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; |
| 421 if (IsCheckBoxEnabledAndSelected(del_passwords_checkbox_)) | 421 if (IsCheckBoxEnabledAndSelected(del_passwords_checkbox_)) |
| 422 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 422 remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 435 remover_->AddObserver(this); | 435 remover_->AddObserver(this); |
| 436 remover_->Remove(remove_mask); | 436 remover_->Remove(remove_mask); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { | 439 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { |
| 440 // No need to remove ourselves as an observer as BrowsingDataRemover deletes | 440 // No need to remove ourselves as an observer as BrowsingDataRemover deletes |
| 441 // itself after we return. | 441 // itself after we return. |
| 442 remover_ = NULL; | 442 remover_ = NULL; |
| 443 window()->Close(); | 443 window()->Close(); |
| 444 } | 444 } |
| OLD | NEW |