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

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

Issue 2716333002: Implement important sites dialog for desktop. (Closed)
Patch Set: fix comments 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 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/chrome_browsing_data_remover_delegate.h" 23 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
23 #include "chrome/browser/engagement/important_sites_util.h" 24 #include "chrome/browser/engagement/important_sites_util.h"
24 #include "chrome/browser/history/web_history_service_factory.h" 25 #include "chrome/browser/history/web_history_service_factory.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/sync/profile_sync_service_factory.h" 27 #include "chrome/browser/sync/profile_sync_service_factory.h"
27 #include "chrome/common/channel_info.h" 28 #include "chrome/common/channel_info.h"
28 #include "components/browser_sync/profile_sync_service.h" 29 #include "components/browser_sync/profile_sync_service.h"
29 #include "components/browsing_data/core/history_notice_utils.h" 30 #include "components/browsing_data/core/history_notice_utils.h"
30 #include "components/prefs/pref_service.h" 31 #include "components/prefs/pref_service.h"
31 #include "content/public/browser/browser_context.h" 32 #include "content/public/browser/browser_context.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 for (const std::string& domain : excluding_domains) { 154 for (const std::string& domain : excluding_domains) {
154 filter_builder->AddRegisterableDomain(domain); 155 filter_builder->AddRegisterableDomain(domain);
155 } 156 }
156 157
157 if (!excluding_domains.empty() || !ignoring_domains.empty()) { 158 if (!excluding_domains.empty() || !ignoring_domains.empty()) {
158 ImportantSitesUtil::RecordBlacklistedAndIgnoredImportantSites( 159 ImportantSitesUtil::RecordBlacklistedAndIgnoredImportantSites(
159 GetOriginalProfile(), excluding_domains, excluding_domain_reasons, 160 GetOriginalProfile(), excluding_domains, excluding_domain_reasons,
160 ignoring_domains, ignoring_domain_reasons); 161 ignoring_domains, ignoring_domain_reasons);
161 } 162 }
162 163
163 // Delete the types protected by Important Sites with a filter,
164 // and the rest completely.
165 int filterable_mask =
166 remove_mask &
167 ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
168 int nonfilterable_mask =
169 remove_mask &
170 ~ChromeBrowsingDataRemoverDelegate::IMPORTANT_SITES_DATA_TYPES;
171
172 // ClearBrowsingDataObserver deletes itself when |browsing_data_remover| is 164 // ClearBrowsingDataObserver deletes itself when |browsing_data_remover| is
173 // done with both removal tasks. 165 // done with both removal tasks.
174 ClearBrowsingDataObserver* observer = new ClearBrowsingDataObserver( 166 ClearBrowsingDataObserver* observer = new ClearBrowsingDataObserver(
175 env, obj, browsing_data_remover, 2 /* tasks_count */); 167 env, obj, browsing_data_remover, 2 /* tasks_count */);
176 168
177 browsing_data::TimePeriod period = 169 browsing_data::TimePeriod period =
178 static_cast<browsing_data::TimePeriod>(time_period); 170 static_cast<browsing_data::TimePeriod>(time_period);
179 browsing_data::RecordDeletionForPeriod(period);
180 171
181 if (filterable_mask) { 172 browsing_data_important_sites_util::Remove(
182 browsing_data_remover->RemoveWithFilterAndReply( 173 remove_mask, BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, period,
183 browsing_data::CalculateBeginDeleteTime(period), 174 std::move(filter_builder), browsing_data_remover, observer);
184 browsing_data::CalculateEndDeleteTime(period), filterable_mask,
185 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB,
186 std::move(filter_builder), observer);
187 } else {
188 // Make sure |observer| doesn't wait for the filtered task.
189 observer->OnBrowsingDataRemoverDone();
190 }
191
192 if (nonfilterable_mask) {
193 browsing_data_remover->RemoveAndReply(
194 browsing_data::CalculateBeginDeleteTime(period),
195 browsing_data::CalculateEndDeleteTime(period), nonfilterable_mask,
196 BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB, observer);
197 } else {
198 // Make sure |observer| doesn't wait for the non-filtered task.
199 observer->OnBrowsingDataRemoverDone();
200 }
201 } 175 }
202 176
203 static void ShowNoticeAboutOtherFormsOfBrowsingHistory( 177 static void ShowNoticeAboutOtherFormsOfBrowsingHistory(
204 const JavaRef<jobject>& listener, 178 const JavaRef<jobject>& listener,
205 bool show) { 179 bool show) {
206 JNIEnv* env = AttachCurrentThread(); 180 JNIEnv* env = AttachCurrentThread();
207 UMA_HISTOGRAM_BOOLEAN( 181 UMA_HISTOGRAM_BOOLEAN(
208 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", show); 182 "History.ClearBrowsingData.HistoryNoticeShownInFooterWhenUpdated", show);
209 if (!show) 183 if (!show)
210 return; 184 return;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 254
281 static void MarkOriginAsImportantForTesting( 255 static void MarkOriginAsImportantForTesting(
282 JNIEnv* env, 256 JNIEnv* env,
283 const JavaParamRef<jclass>& clazz, 257 const JavaParamRef<jclass>& clazz,
284 const JavaParamRef<jstring>& jorigin) { 258 const JavaParamRef<jstring>& jorigin) {
285 GURL origin(base::android::ConvertJavaStringToUTF8(jorigin)); 259 GURL origin(base::android::ConvertJavaStringToUTF8(jorigin));
286 CHECK(origin.is_valid()); 260 CHECK(origin.is_valid());
287 ImportantSitesUtil::MarkOriginAsImportantForTesting(GetOriginalProfile(), 261 ImportantSitesUtil::MarkOriginAsImportantForTesting(GetOriginalProfile(),
288 origin); 262 origin);
289 } 263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698