Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/settings/settings_clear_browsing_data_handler. h" | 5 #include "chrome/browser/ui/webui/settings/settings_clear_browsing_data_handler. h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 int checked_other_types = std::count_if( | 155 int checked_other_types = std::count_if( |
| 156 other_types, other_types + num_other_types, | 156 other_types, other_types + num_other_types, |
| 157 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); | 157 [prefs](const std::string& pref) { return prefs->GetBoolean(pref); }); |
| 158 UMA_HISTOGRAM_SPARSE_SLOWLY( | 158 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 159 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", | 159 "History.ClearBrowsingData.PasswordsDeletion.AdditionalDatatypesCount", |
| 160 checked_other_types); | 160 checked_other_types); |
| 161 } | 161 } |
| 162 | 162 |
| 163 int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod); | 163 int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod); |
| 164 remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile_); | 164 remover_ = BrowsingDataRemoverFactory::GetForBrowserContext(profile_); |
| 165 remover_->AddObserver(this); | 165 remover_->AddObserver(this); |
|
Dan Beam
2016/07/06 22:13:06
so we already are observing things globally (i.e.
dschuyler
2016/07/07 01:25:33
I called it OnBrowserDataRemoving(bool is_removing
| |
| 166 remover_->Remove( | 166 remover_->Remove( |
| 167 BrowsingDataRemover::Period( | 167 BrowsingDataRemover::Period( |
| 168 static_cast<BrowsingDataRemover::TimePeriod>(period_selected)), | 168 static_cast<BrowsingDataRemover::TimePeriod>(period_selected)), |
| 169 remove_mask, origin_mask); | 169 remove_mask, origin_mask); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() { | 172 void ClearBrowsingDataHandler::OnBrowsingDataRemoverDone() { |
| 173 remover_->RemoveObserver(this); | 173 remover_->RemoveObserver(this); |
| 174 remover_ = nullptr; | 174 remover_ = nullptr; |
| 175 | 175 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 206 CallJavascriptFunction( | 206 CallJavascriptFunction( |
| 207 "cr.webUIListenerCallback", | 207 "cr.webUIListenerCallback", |
| 208 base::StringValue("browsing-history-pref-changed"), | 208 base::StringValue("browsing-history-pref-changed"), |
| 209 base::FundamentalValue( | 209 base::FundamentalValue( |
| 210 profile_->GetPrefs()->GetBoolean( | 210 profile_->GetPrefs()->GetBoolean( |
| 211 prefs::kAllowDeletingBrowserHistory))); | 211 prefs::kAllowDeletingBrowserHistory))); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { | 214 void ClearBrowsingDataHandler::HandleInitialize(const base::ListValue* args) { |
| 215 AllowJavascript(); | 215 AllowJavascript(); |
| 216 const base::Value* callback_id; | |
| 217 CHECK(args->Get(0, &callback_id)); | |
| 216 | 218 |
| 217 // TODO(msramek): Simplify this using a factory. | 219 // TODO(msramek): Simplify this using a factory. |
| 218 AddCounter(base::WrapUnique(new AutofillCounter())); | 220 AddCounter(base::WrapUnique(new AutofillCounter())); |
| 219 AddCounter(base::WrapUnique(new CacheCounter())); | 221 AddCounter(base::WrapUnique(new CacheCounter())); |
| 220 AddCounter(base::WrapUnique(new DownloadsCounter())); | 222 AddCounter(base::WrapUnique(new DownloadsCounter())); |
| 221 AddCounter(base::WrapUnique(new HistoryCounter())); | 223 AddCounter(base::WrapUnique(new HistoryCounter())); |
| 222 AddCounter(base::WrapUnique(new HostedAppsCounter())); | 224 AddCounter(base::WrapUnique(new HostedAppsCounter())); |
| 223 AddCounter(base::WrapUnique(new PasswordsCounter())); | 225 AddCounter(base::WrapUnique(new PasswordsCounter())); |
| 224 AddCounter(base::WrapUnique(new MediaLicensesCounter())); | 226 AddCounter(base::WrapUnique(new MediaLicensesCounter())); |
| 225 | 227 |
| 226 OnStateChanged(); | 228 OnStateChanged(); |
| 227 RefreshHistoryNotice(); | 229 RefreshHistoryNotice(); |
| 230 | |
| 231 ResolveJavascriptCallback(*callback_id, base::FundamentalValue(!!remover_)); | |
| 228 } | 232 } |
| 229 | 233 |
| 230 void ClearBrowsingDataHandler::OnStateChanged() { | 234 void ClearBrowsingDataHandler::OnStateChanged() { |
| 231 CallJavascriptFunction( | 235 CallJavascriptFunction( |
| 232 "cr.webUIListenerCallback", | 236 "cr.webUIListenerCallback", |
| 233 base::StringValue("update-footer"), | 237 base::StringValue("update-footer"), |
| 234 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), | 238 base::FundamentalValue(sync_service_ && sync_service_->IsSyncActive()), |
| 235 base::FundamentalValue(show_history_footer_)); | 239 base::FundamentalValue(show_history_footer_)); |
| 236 } | 240 } |
| 237 | 241 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 void ClearBrowsingDataHandler::UpdateCounterText( | 289 void ClearBrowsingDataHandler::UpdateCounterText( |
| 286 std::unique_ptr<BrowsingDataCounter::Result> result) { | 290 std::unique_ptr<BrowsingDataCounter::Result> result) { |
| 287 CallJavascriptFunction( | 291 CallJavascriptFunction( |
| 288 "cr.webUIListenerCallback", | 292 "cr.webUIListenerCallback", |
| 289 base::StringValue("update-counter-text"), | 293 base::StringValue("update-counter-text"), |
| 290 base::StringValue(result->source()->GetPrefName()), | 294 base::StringValue(result->source()->GetPrefName()), |
| 291 base::StringValue(GetCounterTextFromResult(result.get()))); | 295 base::StringValue(GetCounterTextFromResult(result.get()))); |
| 292 } | 296 } |
| 293 | 297 |
| 294 } // namespace settings | 298 } // namespace settings |
| OLD | NEW |