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

Side by Side Diff: chrome/browser/android/browsing_data/browsing_data_bridge.cc

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: add using declaration Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/android/browsing_data/browsing_data_bridge.h" 5 #include "chrome/browser/android/browsing_data/browsing_data_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/android/jni_android.h" 15 #include "base/android/jni_android.h"
16 #include "base/android/jni_array.h" 16 #include "base/android/jni_array.h"
17 #include "base/android/jni_string.h" 17 #include "base/android/jni_string.h"
18 #include "base/android/jni_weak_ref.h" 18 #include "base/android/jni_weak_ref.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "base/scoped_observer.h" 20 #include "base/scoped_observer.h"
21 #include "base/values.h" 21 #include "base/values.h"
22 #include "chrome/browser/browsing_data/browsing_data_important_sites_util.h"
22 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" 23 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
23 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" 24 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
24 #include "chrome/browser/engagement/important_sites_util.h" 25 #include "chrome/browser/engagement/important_sites_util.h"
25 #include "chrome/browser/history/web_history_service_factory.h" 26 #include "chrome/browser/history/web_history_service_factory.h"
26 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
27 #include "chrome/browser/sync/profile_sync_service_factory.h" 28 #include "chrome/browser/sync/profile_sync_service_factory.h"
28 #include "chrome/common/channel_info.h" 29 #include "chrome/common/channel_info.h"
29 #include "components/browser_sync/profile_sync_service.h" 30 #include "components/browser_sync/profile_sync_service.h"
30 #include "components/browsing_data/core/history_notice_utils.h" 31 #include "components/browsing_data/core/history_notice_utils.h"
31 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 for (const std::string& domain : excluding_domains) { 152 for (const std::string& domain : excluding_domains) {
152 filter_builder->AddRegisterableDomain(domain); 153 filter_builder->AddRegisterableDomain(domain);
153 } 154 }
154 155
155 if (!excluding_domains.empty() || !ignoring_domains.empty()) { 156 if (!excluding_domains.empty() || !ignoring_domains.empty()) {
156 ImportantSitesUtil::RecordBlacklistedAndIgnoredImportantSites( 157 ImportantSitesUtil::RecordBlacklistedAndIgnoredImportantSites(
157 GetOriginalProfile(), excluding_domains, excluding_domain_reasons, 158 GetOriginalProfile(), excluding_domains, excluding_domain_reasons,
158 ignoring_domains, ignoring_domain_reasons); 159 ignoring_domains, ignoring_domain_reasons);
159 } 160 }
160 161
161 // Delete the types protected by Important Sites with a filter,
162 // and the rest completely.
163 int filterable_mask =
164 remove_mask &
165 ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
166 int nonfilterable_mask =
167 remove_mask &
168 ~ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
169
170 // ClearBrowsingDataObserver deletes itself when |browsing_data_remover| is 162 // ClearBrowsingDataObserver deletes itself when |browsing_data_remover| is
171 // done with both removal tasks. 163 // done with both removal tasks.
172 ClearBrowsingDataObserver* observer = new ClearBrowsingDataObserver( 164 ClearBrowsingDataObserver* observer = new ClearBrowsingDataObserver(
173 env, obj, browsing_data_remover, 2 /* tasks_count */); 165 env, obj, browsing_data_remover, 2 /* tasks_count */);
174 166
175 browsing_data::TimePeriod period = 167 browsing_data::TimePeriod period =
176 static_cast<browsing_data::TimePeriod>(time_period); 168 static_cast<browsing_data::TimePeriod>(time_period);
177 browsing_data::RecordDeletionForPeriod(period);
178 169
179 if (filterable_mask) { 170 browsing_data_important_sites_util::Remove(
180 browsing_data_remover->RemoveWithFilterAndReply( 171 remove_mask, BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, period,
181 browsing_data::CalculateBeginDeleteTime(period), 172 std::move(filter_builder), browsing_data_remover, observer);
182 browsing_data::CalculateEndDeleteTime(period), filterable_mask,
183 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
184 std::move(filter_builder), observer);
185 } else {
186 // Make sure |observer| doesn't wait for the filtered task.
187 observer->OnBrowsingDataRemoverDone();
188 }
189
190 if (nonfilterable_mask) {
191 browsing_data_remover->RemoveAndReply(
192 browsing_data::CalculateBeginDeleteTime(period),
193 browsing_data::CalculateEndDeleteTime(period), nonfilterable_mask,
194 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, observer);
195 } else {
196 // Make sure |observer| doesn't wait for the non-filtered task.
197 observer->OnBrowsingDataRemoverDone();
198 }
199 } 173 }
200 174
201 static void ShowNoticeAboutOtherFormsOfBrowsingHistory( 175 static void ShowNoticeAboutOtherFormsOfBrowsingHistory(
202 const JavaRef<jobject>& listener, 176 const JavaRef<jobject>& listener,
203 bool show) { 177 bool show) {
204 JNIEnv* env = AttachCurrentThread(); 178 JNIEnv* env = AttachCurrentThread();
205 UMA_HISTOGRAM_BOOLEAN( 179 UMA_HISTOGRAM_BOOLEAN(
206 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", show); 180 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", show);
207 if (!show) 181 if (!show)
208 return; 182 return;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 252
279 static void MarkOriginAsImportantForTesting( 253 static void MarkOriginAsImportantForTesting(
280 JNIEnv* env, 254 JNIEnv* env,
281 const JavaParamRef<jclass>& clazz, 255 const JavaParamRef<jclass>& clazz,
282 const JavaParamRef<jstring>& jorigin) { 256 const JavaParamRef<jstring>& jorigin) {
283 GURL origin(base::android::ConvertJavaStringToUTF8(jorigin)); 257 GURL origin(base::android::ConvertJavaStringToUTF8(jorigin));
284 CHECK(origin.is_valid()); 258 CHECK(origin.is_valid());
285 ImportantSitesUtil::MarkOriginAsImportantForTesting(GetOriginalProfile(), 259 ImportantSitesUtil::MarkOriginAsImportantForTesting(GetOriginalProfile(),
286 origin); 260 origin);
287 } 261 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698