diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 14:40:38 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 14:40:38 +0000 |
commit | e86ea64fa7841e2affe68a8d078c87ad5ea76ca9 (patch) | |
tree | 16364d6a30c304e54752d3d4652803b42dccf381 /chrome | |
parent | b13439c303823dec983400462f4eb22ad547deb5 (diff) | |
download | chromium_src-e86ea64fa7841e2affe68a8d078c87ad5ea76ca9.zip chromium_src-e86ea64fa7841e2affe68a8d078c87ad5ea76ca9.tar.gz chromium_src-e86ea64fa7841e2affe68a8d078c87ad5ea76ca9.tar.bz2 |
Added unit tests for ClearBrowsingDataController.
Fixed a bug in ClearBrowsingDataController: checking Delete Form Data would end
up deleting passwords instead. Patch from Jens Alfke (snej@google.com).
BUG=12902
TEST=deleting form data should actually delete the form data.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
3 files changed, 23 insertions, 13 deletions
diff --git a/chrome/browser/cocoa/clear_browsing_data_controller.h b/chrome/browser/cocoa/clear_browsing_data_controller.h index 78ef39c..d954981 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller.h +++ b/chrome/browser/cocoa/clear_browsing_data_controller.h @@ -28,7 +28,7 @@ class Profile; scoped_ptr<ClearBrowsingObserver> observer_; BOOL isClearing_; // YES while clearing data is ongoing. IBOutlet ThrobberView* progress_; - + // Values for checkboxes, kept in sync with bindings. These values get // persisted into prefs if the user accepts the dialog. BOOL clearBrowsingHistory_; @@ -64,4 +64,10 @@ class Profile; @end + +@interface ClearBrowsingDataController (ExposedForUnitTests) +@property (readonly) int removeMask; +- (void)persistToPrefs; +@end + #endif // CHROME_BROWSER_COCOA_CLEAR_BROWSING_DATA_CONTROLLER_ diff --git a/chrome/browser/cocoa/clear_browsing_data_controller.mm b/chrome/browser/cocoa/clear_browsing_data_controller.mm index f8ca39a..9910d28 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller.mm +++ b/chrome/browser/cocoa/clear_browsing_data_controller.mm @@ -78,16 +78,7 @@ class ClearBrowsingObserver : public BrowsingDataRemover::Observer { [[NSApplication sharedApplication] runModalForWindow:[self window]]; } -// Called when the user clicks the "clear" button. Do the work and persist -// the prefs for next time. We don't stop the modal session until we get -// the callback from the BrowsingDataRemover so the window stays on the screen. -// While we're working, dim the buttons so the user can't click them. -- (IBAction)clearData:(id)sender { - // Set that we're working so that the buttons disable. - [self setIsClearing:YES]; - - [self persistToPrefs]; - +- (int)removeMask { int removeMask = 0L; if (clearBrowsingHistory_) removeMask |= BrowsingDataRemover::REMOVE_HISTORY; @@ -100,14 +91,26 @@ class ClearBrowsingObserver : public BrowsingDataRemover::Observer { if (clearSavedPasswords_) removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; if (clearFormData_) - removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; + removeMask |= BrowsingDataRemover::REMOVE_FORM_DATA; + return removeMask; +} + +// Called when the user clicks the "clear" button. Do the work and persist +// the prefs for next time. We don't stop the modal session until we get +// the callback from the BrowsingDataRemover so the window stays on the screen. +// While we're working, dim the buttons so the user can't click them. +- (IBAction)clearData:(id)sender { + // Set that we're working so that the buttons disable. + [self setIsClearing:YES]; + + [self persistToPrefs]; // BrowsingDataRemover deletes itself when done. remover_ = new BrowsingDataRemover(profile_, static_cast<BrowsingDataRemover::TimePeriod>(timePeriod_), base::Time()); remover_->AddObserver(observer_.get()); - remover_->Remove(removeMask); + remover_->Remove([self removeMask]); } // Called when the user clicks the cancel button. All we need to do is stop diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc index 1734499..b5a2905 100644 --- a/chrome/browser/history/expire_history_backend_unittest.cc +++ b/chrome/browser/history/expire_history_backend_unittest.cc @@ -107,6 +107,7 @@ class ExpireHistoryTest : public testing::Test, FilePath temp_dir; PathService::Get(base::DIR_TEMP, &temp_dir); dir_ = temp_dir.Append(kTestDir); +LOG(ERROR) << dir_.ToWStringHack(); file_util::Delete(dir_, true); file_util::CreateDirectory(dir_); |