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/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 "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 234 |
235 //////////////////////////////////////////////////////////////////////////////// | 235 //////////////////////////////////////////////////////////////////////////////// |
236 // ClearBrowsingDataView, views::DialogDelegate implementation: | 236 // ClearBrowsingDataView, views::DialogDelegate implementation: |
237 | 237 |
238 int ClearBrowsingDataView::GetDefaultDialogButton() const { | 238 int ClearBrowsingDataView::GetDefaultDialogButton() const { |
239 return MessageBoxFlags::DIALOGBUTTON_NONE; | 239 return MessageBoxFlags::DIALOGBUTTON_NONE; |
240 } | 240 } |
241 | 241 |
242 std::wstring ClearBrowsingDataView::GetDialogButtonLabel( | 242 std::wstring ClearBrowsingDataView::GetDialogButtonLabel( |
243 MessageBoxFlags::DialogButton button) const { | 243 MessageBoxFlags::DialogButton button) const { |
244 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 244 DCHECK((button == MessageBoxFlags::DIALOGBUTTON_OK) || |
245 return l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_COMMIT); | 245 (button == MessageBoxFlags::DIALOGBUTTON_CANCEL)); |
246 } else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) { | 246 return l10n_util::GetString((button == MessageBoxFlags::DIALOGBUTTON_OK) ? |
247 return l10n_util::GetString(IDS_CLOSE); | 247 IDS_CLEAR_BROWSING_DATA_COMMIT : IDS_CANCEL); |
248 } else { | |
249 return std::wstring(); | |
250 } | |
251 } | 248 } |
252 | 249 |
253 bool ClearBrowsingDataView::IsDialogButtonEnabled( | 250 bool ClearBrowsingDataView::IsDialogButtonEnabled( |
254 MessageBoxFlags::DialogButton button) const { | 251 MessageBoxFlags::DialogButton button) const { |
255 if (delete_in_progress_) | 252 if (delete_in_progress_) |
256 return false; | 253 return false; |
257 | 254 |
258 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { | 255 if (button == MessageBoxFlags::DIALOGBUTTON_OK) { |
259 return del_history_checkbox_->checked() || | 256 return del_history_checkbox_->checked() || |
260 del_downloads_checkbox_->checked() || | 257 del_downloads_checkbox_->checked() || |
(...skipping 28 matching lines...) Expand all Loading... |
289 | 286 |
290 std::wstring ClearBrowsingDataView::GetWindowTitle() const { | 287 std::wstring ClearBrowsingDataView::GetWindowTitle() const { |
291 return l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TITLE); | 288 return l10n_util::GetString(IDS_CLEAR_BROWSING_DATA_TITLE); |
292 } | 289 } |
293 | 290 |
294 bool ClearBrowsingDataView::Accept() { | 291 bool ClearBrowsingDataView::Accept() { |
295 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { | 292 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { |
296 return false; | 293 return false; |
297 } | 294 } |
298 | 295 |
| 296 PrefService* prefs = profile_->GetPrefs(); |
| 297 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, |
| 298 del_history_checkbox_->checked()); |
| 299 prefs->SetBoolean(prefs::kDeleteDownloadHistory, |
| 300 del_downloads_checkbox_->checked()); |
| 301 prefs->SetBoolean(prefs::kDeleteCache, |
| 302 del_cache_checkbox_->checked()); |
| 303 prefs->SetBoolean(prefs::kDeleteCookies, |
| 304 del_cookies_checkbox_->checked()); |
| 305 prefs->SetBoolean(prefs::kDeletePasswords, |
| 306 del_passwords_checkbox_->checked()); |
| 307 prefs->SetBoolean(prefs::kDeleteFormData, |
| 308 del_form_data_checkbox_->checked()); |
299 OnDelete(); | 309 OnDelete(); |
300 return false; // We close the dialog in OnBrowsingDataRemoverDone(). | 310 return false; // We close the dialog in OnBrowsingDataRemoverDone(). |
301 } | 311 } |
302 | 312 |
303 views::View* ClearBrowsingDataView::GetContentsView() { | 313 views::View* ClearBrowsingDataView::GetContentsView() { |
304 return this; | 314 return this; |
305 } | 315 } |
306 | 316 |
307 views::View* ClearBrowsingDataView::GetInitiallyFocusedView() { | 317 views::View* ClearBrowsingDataView::GetInitiallyFocusedView() { |
308 return GetDialogClientView()->cancel_button(); | 318 return GetDialogClientView()->cancel_button(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 | 366 |
357 void ClearBrowsingDataView::ItemChanged(views::Combobox* sender, | 367 void ClearBrowsingDataView::ItemChanged(views::Combobox* sender, |
358 int prev_index, int new_index) { | 368 int prev_index, int new_index) { |
359 if (sender == time_period_combobox_ && prev_index != new_index) | 369 if (sender == time_period_combobox_ && prev_index != new_index) |
360 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index); | 370 profile_->GetPrefs()->SetInteger(prefs::kDeleteTimePeriod, new_index); |
361 } | 371 } |
362 | 372 |
363 //////////////////////////////////////////////////////////////////////////////// | 373 //////////////////////////////////////////////////////////////////////////////// |
364 // ClearBrowsingDataView, views::ButtonListener implementation: | 374 // ClearBrowsingDataView, views::ButtonListener implementation: |
365 | 375 |
366 void ClearBrowsingDataView::ButtonPressed( | 376 void ClearBrowsingDataView::ButtonPressed(views::Button* sender, |
367 views::Button* sender, const views::Event& event) { | 377 const views::Event& event) { |
368 if (sender == del_history_checkbox_) | |
369 profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory, | |
370 del_history_checkbox_->checked() ? true : false); | |
371 else if (sender == del_downloads_checkbox_) | |
372 profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory, | |
373 del_downloads_checkbox_->checked() ? true : false); | |
374 else if (sender == del_cache_checkbox_) | |
375 profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache, | |
376 del_cache_checkbox_->checked() ? true : false); | |
377 else if (sender == del_cookies_checkbox_) | |
378 profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies, | |
379 del_cookies_checkbox_->checked() ? true : false); | |
380 else if (sender == del_passwords_checkbox_) | |
381 profile_->GetPrefs()->SetBoolean(prefs::kDeletePasswords, | |
382 del_passwords_checkbox_->checked() ? true : false); | |
383 else if (sender == del_form_data_checkbox_) | |
384 profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData, | |
385 del_form_data_checkbox_->checked() ? true : false); | |
386 | |
387 // When no checkbox is checked we should not have the action button enabled. | 378 // When no checkbox is checked we should not have the action button enabled. |
388 // This forces the button to evaluate what state they should be in. | 379 // This forces the button to evaluate what state they should be in. |
389 GetDialogClientView()->UpdateDialogButtons(); | 380 GetDialogClientView()->UpdateDialogButtons(); |
390 } | 381 } |
391 | 382 |
392 void ClearBrowsingDataView::LinkActivated(views::Link* source, | 383 void ClearBrowsingDataView::LinkActivated(views::Link* source, |
393 int event_flags) { | 384 int event_flags) { |
394 Browser* browser = Browser::Create(profile_); | 385 Browser* browser = Browser::Create(profile_); |
395 browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_FLASH_STORAGE_URL)), | 386 browser->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_FLASH_STORAGE_URL)), |
396 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 387 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 remover_->AddObserver(this); | 455 remover_->AddObserver(this); |
465 remover_->Remove(remove_mask); | 456 remover_->Remove(remove_mask); |
466 } | 457 } |
467 | 458 |
468 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { | 459 void ClearBrowsingDataView::OnBrowsingDataRemoverDone() { |
469 // No need to remove ourselves as an observer as BrowsingDataRemover deletes | 460 // No need to remove ourselves as an observer as BrowsingDataRemover deletes |
470 // itself after we return. | 461 // itself after we return. |
471 remover_ = NULL; | 462 remover_ = NULL; |
472 window()->Close(); | 463 window()->Close(); |
473 } | 464 } |
OLD | NEW |