Index: chrome/browser/browsing_data/browsing_data_counter_factory.cc |
diff --git a/chrome/browser/browsing_data/browsing_data_counter_factory.cc b/chrome/browser/browsing_data/browsing_data_counter_factory.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8205577f31113e1a155ba1f7f85c8086d63bf8d5 |
--- /dev/null |
+++ b/chrome/browser/browsing_data/browsing_data_counter_factory.cc |
@@ -0,0 +1,54 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/browsing_data/browsing_data_counter_factory.h" |
+ |
+#include "chrome/browser/browsing_data/autofill_counter.h" |
+#include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
+#include "chrome/browser/browsing_data/cache_counter.h" |
+#include "chrome/browser/browsing_data/downloads_counter.h" |
+#include "chrome/browser/browsing_data/history_counter.h" |
+#include "chrome/browser/browsing_data/media_licenses_counter.h" |
+#include "chrome/browser/browsing_data/passwords_counter.h" |
+#include "chrome/browser/profiles/profile.h" |
+#include "chrome/common/pref_names.h" |
+#include "components/browsing_data/counters/browsing_data_counter.h" |
+ |
+#if defined(ENABLE_EXTENSIONS) |
+#include "chrome/browser/browsing_data/hosted_apps_counter.h" |
+#endif |
+ |
+// static |
+std::unique_ptr<browsing_data::BrowsingDataCounter> |
+BrowsingDataCounterFactory::GetForProfileAndPref(Profile* profile, |
+ const std::string& pref_name) { |
+ if (!AreCountersEnabled()) |
+ return nullptr; |
+ |
+ if (pref_name == prefs::kDeleteBrowsingHistory) |
Bernhard Bauer
2016/07/11 10:57:02
These need braces, as they are more than one line.
ioanap
2016/07/11 13:34:15
Done.
|
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new HistoryCounter(profile)); |
Bernhard Bauer
2016/07/11 10:57:02
Would base::WrapUnique or even base::MakeUnique wo
ioanap
2016/07/11 13:34:15
base::MakeUnique looks good! Thank you!
Done.
|
+ if (pref_name == prefs::kDeleteCache) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new CacheCounter(profile)); |
+ if (pref_name == prefs::kDeletePasswords) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new PasswordsCounter(profile)); |
+ if (pref_name == prefs::kDeleteFormData) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new AutofillCounter(profile)); |
+ if (pref_name == prefs::kDeleteDownloadHistory) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new DownloadsCounter(profile)); |
+ if (pref_name == prefs::kDeleteMediaLicenses) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new MediaLicensesCounter(profile)); |
+#if defined(ENABLE_EXTENSIONS) |
+ if (pref_name == prefs::kDeleteHostedAppsData) |
+ return std::unique_ptr<browsing_data::BrowsingDataCounter>( |
+ new HostedAppsCounter(profile)); |
+#endif |
+ |
+ return nullptr; |
+} |