| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" | 5 #import "chrome/browser/cocoa/clear_browsing_data_controller.h" |
| 6 | 6 |
| 7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
| 10 #include "chrome/browser/browsing_data_remover.h" | 10 #include "chrome/browser/browsing_data_remover.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; | 32 typedef std::map<Profile*, ClearBrowsingDataController*> ProfileControllerMap; |
| 33 | 33 |
| 34 } // namespace | 34 } // namespace |
| 35 | 35 |
| 36 @implementation ClearBrowsingDataController | 36 @implementation ClearBrowsingDataController |
| 37 | 37 |
| 38 @synthesize clearBrowsingHistory = clearBrowsingHistory_; | 38 @synthesize clearBrowsingHistory = clearBrowsingHistory_; |
| 39 @synthesize clearDownloadHistory = clearDownloadHistory_; | 39 @synthesize clearDownloadHistory = clearDownloadHistory_; |
| 40 @synthesize emptyCache = emptyCache_; | 40 @synthesize emptyCache = emptyCache_; |
| 41 @synthesize deleteLocalStorage = deleteLocalStorage_; |
| 41 @synthesize deleteCookies = deleteCookies_; | 42 @synthesize deleteCookies = deleteCookies_; |
| 42 @synthesize clearSavedPasswords = clearSavedPasswords_; | 43 @synthesize clearSavedPasswords = clearSavedPasswords_; |
| 43 @synthesize clearFormData = clearFormData_; | 44 @synthesize clearFormData = clearFormData_; |
| 44 @synthesize timePeriod = timePeriod_; | 45 @synthesize timePeriod = timePeriod_; |
| 45 @synthesize isClearing = isClearing_; | 46 @synthesize isClearing = isClearing_; |
| 46 | 47 |
| 47 + (void)showClearBrowsingDialogForProfile:(Profile*)profile { | 48 + (void)showClearBrowsingDialogForProfile:(Profile*)profile { |
| 48 ClearBrowsingDataController* controller = | 49 ClearBrowsingDataController* controller = |
| 49 [ClearBrowsingDataController controllerForProfile:profile]; | 50 [ClearBrowsingDataController controllerForProfile:profile]; |
| 50 if (![controller isWindowLoaded]) { | 51 if (![controller isWindowLoaded]) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 106 } |
| 106 | 107 |
| 107 - (int)removeMask { | 108 - (int)removeMask { |
| 108 int removeMask = 0L; | 109 int removeMask = 0L; |
| 109 if (clearBrowsingHistory_) | 110 if (clearBrowsingHistory_) |
| 110 removeMask |= BrowsingDataRemover::REMOVE_HISTORY; | 111 removeMask |= BrowsingDataRemover::REMOVE_HISTORY; |
| 111 if (clearDownloadHistory_) | 112 if (clearDownloadHistory_) |
| 112 removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; | 113 removeMask |= BrowsingDataRemover::REMOVE_DOWNLOADS; |
| 113 if (emptyCache_) | 114 if (emptyCache_) |
| 114 removeMask |= BrowsingDataRemover::REMOVE_CACHE; | 115 removeMask |= BrowsingDataRemover::REMOVE_CACHE; |
| 116 if (deleteLocalStorage_) |
| 117 removeMask |= BrowsingDataRemover::REMOVE_LOCAL_STORAGE; |
| 115 if (deleteCookies_) | 118 if (deleteCookies_) |
| 116 removeMask |= BrowsingDataRemover::REMOVE_COOKIES; | 119 removeMask |= BrowsingDataRemover::REMOVE_COOKIES; |
| 117 if (clearSavedPasswords_) | 120 if (clearSavedPasswords_) |
| 118 removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; | 121 removeMask |= BrowsingDataRemover::REMOVE_PASSWORDS; |
| 119 if (clearFormData_) | 122 if (clearFormData_) |
| 120 removeMask |= BrowsingDataRemover::REMOVE_FORM_DATA; | 123 removeMask |= BrowsingDataRemover::REMOVE_FORM_DATA; |
| 121 return removeMask; | 124 return removeMask; |
| 122 } | 125 } |
| 123 | 126 |
| 124 // Called when the user clicks the "clear" button. Do the work and persist | 127 // Called when the user clicks the "clear" button. Do the work and persist |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 } | 160 } |
| 158 | 161 |
| 159 // Initialize the bools from prefs using the setters to be KVO-compliant. | 162 // Initialize the bools from prefs using the setters to be KVO-compliant. |
| 160 - (void)initFromPrefs { | 163 - (void)initFromPrefs { |
| 161 PrefService* prefs = profile_->GetPrefs(); | 164 PrefService* prefs = profile_->GetPrefs(); |
| 162 [self setClearBrowsingHistory: | 165 [self setClearBrowsingHistory: |
| 163 prefs->GetBoolean(prefs::kDeleteBrowsingHistory)]; | 166 prefs->GetBoolean(prefs::kDeleteBrowsingHistory)]; |
| 164 [self setClearDownloadHistory: | 167 [self setClearDownloadHistory: |
| 165 prefs->GetBoolean(prefs::kDeleteDownloadHistory)]; | 168 prefs->GetBoolean(prefs::kDeleteDownloadHistory)]; |
| 166 [self setEmptyCache:prefs->GetBoolean(prefs::kDeleteCache)]; | 169 [self setEmptyCache:prefs->GetBoolean(prefs::kDeleteCache)]; |
| 170 [self setDeleteLocalStorage:prefs->GetBoolean(prefs::kDeleteLocalStorage)]; |
| 167 [self setDeleteCookies:prefs->GetBoolean(prefs::kDeleteCookies)]; | 171 [self setDeleteCookies:prefs->GetBoolean(prefs::kDeleteCookies)]; |
| 168 [self setClearSavedPasswords:prefs->GetBoolean(prefs::kDeletePasswords)]; | 172 [self setClearSavedPasswords:prefs->GetBoolean(prefs::kDeletePasswords)]; |
| 169 [self setClearFormData:prefs->GetBoolean(prefs::kDeleteFormData)]; | 173 [self setClearFormData:prefs->GetBoolean(prefs::kDeleteFormData)]; |
| 170 [self setTimePeriod:prefs->GetInteger(prefs::kDeleteTimePeriod)]; | 174 [self setTimePeriod:prefs->GetInteger(prefs::kDeleteTimePeriod)]; |
| 171 } | 175 } |
| 172 | 176 |
| 173 // Save the checkbox values to the preferences. | 177 // Save the checkbox values to the preferences. |
| 174 - (void)persistToPrefs { | 178 - (void)persistToPrefs { |
| 175 PrefService* prefs = profile_->GetPrefs(); | 179 PrefService* prefs = profile_->GetPrefs(); |
| 176 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, | 180 prefs->SetBoolean(prefs::kDeleteBrowsingHistory, |
| 177 [self clearBrowsingHistory]); | 181 [self clearBrowsingHistory]); |
| 178 prefs->SetBoolean(prefs::kDeleteDownloadHistory, | 182 prefs->SetBoolean(prefs::kDeleteDownloadHistory, |
| 179 [self clearDownloadHistory]); | 183 [self clearDownloadHistory]); |
| 180 prefs->SetBoolean(prefs::kDeleteCache, [self emptyCache]); | 184 prefs->SetBoolean(prefs::kDeleteCache, [self emptyCache]); |
| 185 prefs->SetBoolean(prefs::kDeleteLocalStorage, [self deleteLocalStorage]); |
| 181 prefs->SetBoolean(prefs::kDeleteCookies, [self deleteCookies]); | 186 prefs->SetBoolean(prefs::kDeleteCookies, [self deleteCookies]); |
| 182 prefs->SetBoolean(prefs::kDeletePasswords, [self clearSavedPasswords]); | 187 prefs->SetBoolean(prefs::kDeletePasswords, [self clearSavedPasswords]); |
| 183 prefs->SetBoolean(prefs::kDeleteFormData, [self clearFormData]); | 188 prefs->SetBoolean(prefs::kDeleteFormData, [self clearFormData]); |
| 184 prefs->SetInteger(prefs::kDeleteTimePeriod, [self timePeriod]); | 189 prefs->SetInteger(prefs::kDeleteTimePeriod, [self timePeriod]); |
| 185 } | 190 } |
| 186 | 191 |
| 187 // Called when the data remover object is done with its work. Close the window. | 192 // Called when the data remover object is done with its work. Close the window. |
| 188 // The remover will delete itself. End the modal session at this point. | 193 // The remover will delete itself. End the modal session at this point. |
| 189 - (void)dataRemoverDidFinish { | 194 - (void)dataRemoverDidFinish { |
| 190 [self closeDialog]; | 195 [self closeDialog]; |
| 191 [[self window] orderOut:self]; | 196 [[self window] orderOut:self]; |
| 192 [self setIsClearing:NO]; | 197 [self setIsClearing:NO]; |
| 193 remover_ = NULL; | 198 remover_ = NULL; |
| 194 } | 199 } |
| 195 | 200 |
| 196 @end | 201 @end |
| OLD | NEW |