Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: chrome/browser/android/browsing_data/browsing_data_bridge.cc

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: change element.$.someId to element.$$(#someId) Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/android/chrome_feature_list.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/browsing_data/browsing_data_bridge.cc
diff --git a/chrome/browser/android/browsing_data/browsing_data_bridge.cc b/chrome/browser/android/browsing_data/browsing_data_bridge.cc
index c690af16b478fed98df20e2a2f395322de6561cf..dabd5b4b222db0e76b326c0f660082427c06d19c 100644
--- a/chrome/browser/android/browsing_data/browsing_data_bridge.cc
+++ b/chrome/browser/android/browsing_data/browsing_data_bridge.cc
@@ -19,6 +19,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/scoped_observer.h"
#include "base/values.h"
+#include "chrome/browser/browsing_data/browsing_data_important_sites_util.h"
#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
#include "chrome/browser/engagement/important_sites_util.h"
#include "chrome/browser/history/web_history_service_factory.h"
@@ -48,44 +49,15 @@ Profile* GetOriginalProfile() {
return ProfileManager::GetActiveUserProfile()->GetOriginalProfile();
}
-// Merges |task_count| BrowsingDataRemover completion callbacks and redirects
-// them back into Java.
-class ClearBrowsingDataObserver : public BrowsingDataRemover::Observer {
- public:
- // |obj| is expected to be the object passed into ClearBrowsingData(); e.g. a
- // ChromePreference.
- ClearBrowsingDataObserver(JNIEnv* env,
- jobject obj,
- BrowsingDataRemover* browsing_data_remover,
- int task_count)
- : task_count_(task_count),
- weak_chrome_native_preferences_(env, obj),
- observer_(this) {
- DCHECK_GT(task_count, 0);
- observer_.Add(browsing_data_remover);
- }
-
- void OnBrowsingDataRemoverDone() override {
- DCHECK(task_count_);
- if (--task_count_)
- return;
-
- // We delete ourselves when done.
- std::unique_ptr<ClearBrowsingDataObserver> auto_delete(this);
-
- JNIEnv* env = AttachCurrentThread();
- if (weak_chrome_native_preferences_.get(env).is_null())
- return;
-
- Java_BrowsingDataBridge_browsingDataCleared(
- env, weak_chrome_native_preferences_.get(env));
- }
+void OnBrowsingDataRemoverDone(
+ JavaObjectWeakGlobalRef weak_chrome_native_preferences) {
+ JNIEnv* env = AttachCurrentThread();
+ if (weak_chrome_native_preferences.get(env).is_null())
+ return;
- private:
- int task_count_;
- JavaObjectWeakGlobalRef weak_chrome_native_preferences_;
- ScopedObserver<BrowsingDataRemover, BrowsingDataRemover::Observer> observer_;
-};
+ Java_BrowsingDataBridge_browsingDataCleared(
+ env, weak_chrome_native_preferences.get(env));
+}
} // namespace
@@ -164,44 +136,15 @@ static void ClearBrowsingData(
ignoring_domains, ignoring_domain_reasons);
}
- // Delete the types protected by Important Sites with a filter,
- // and the rest completely.
- int filterable_mask =
- remove_mask &
- ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
- int nonfilterable_mask =
- remove_mask &
- ~ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
-
- // ClearBrowsingDataObserver deletes itself when |browsing_data_remover| is
- // done with both removal tasks.
- ClearBrowsingDataObserver* observer = new ClearBrowsingDataObserver(
- env, obj, browsing_data_remover, 2 /* tasks_count */);
+ base::OnceClosure callback = base::BindOnce(
+ &OnBrowsingDataRemoverDone, JavaObjectWeakGlobalRef(env, obj));
browsing_data::TimePeriod period =
static_cast<browsing_data::TimePeriod>(time_period);
- browsing_data::RecordDeletionForPeriod(period);
- if (filterable_mask) {
- browsing_data_remover->RemoveWithFilterAndReply(
- browsing_data::CalculateBeginDeleteTime(period),
- browsing_data::CalculateEndDeleteTime(period), filterable_mask,
- BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
- std::move(filter_builder), observer);
- } else {
- // Make sure |observer| doesn't wait for the filtered task.
- observer->OnBrowsingDataRemoverDone();
- }
-
- if (nonfilterable_mask) {
- browsing_data_remover->RemoveAndReply(
- browsing_data::CalculateBeginDeleteTime(period),
- browsing_data::CalculateEndDeleteTime(period), nonfilterable_mask,
- BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, observer);
- } else {
- // Make sure |observer| doesn't wait for the non-filtered task.
- observer->OnBrowsingDataRemoverDone();
- }
+ browsing_data_important_sites_util::Remove(
+ remove_mask, BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, period,
+ std::move(filter_builder), browsing_data_remover, std::move(callback));
}
static void ShowNoticeAboutOtherFormsOfBrowsingHistory(
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | chrome/browser/android/chrome_feature_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698