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

Unified Diff: components/history/core/browser/top_sites_impl.cc

Issue 1100763002: Inject CanAddURLToHistory into TopSitesImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs
Patch Set: Fix error introduced during rebase Created 5 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/top_sites_impl.cc
diff --git a/chrome/browser/history/top_sites_impl.cc b/components/history/core/browser/top_sites_impl.cc
similarity index 98%
rename from chrome/browser/history/top_sites_impl.cc
rename to components/history/core/browser/top_sites_impl.cc
index cc9948aba708a7a8f284aca768632363e5baca52..c5b18735c541c2a66d74703e6ee2c7cf130b8c6c 100644
--- a/chrome/browser/history/top_sites_impl.cc
+++ b/components/history/core/browser/top_sites_impl.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/history/top_sites_impl.h"
+#include "components/history/core/browser/top_sites_impl.h"
#include <algorithm>
#include <set>
@@ -21,7 +21,6 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task_runner.h"
#include "base/values.h"
-#include "chrome/browser/history/history_utils.h"
#include "components/history/core/browser/history_backend.h"
#include "components/history/core/browser/history_db_task.h"
#include "components/history/core/browser/page_usage_data.h"
@@ -89,7 +88,8 @@ bool TopSitesImpl::histogram_recorded_ = false;
TopSitesImpl::TopSitesImpl(PrefService* pref_service,
HistoryService* history_service,
const char* blacklist_pref_name,
- const PrepopulatedPageList& prepopulated_pages)
+ const PrepopulatedPageList& prepopulated_pages,
+ const CanAddURLToHistoryFn& can_add_url_to_history)
: backend_(nullptr),
cache_(new TopSitesCache()),
thread_safe_cache_(new TopSitesCache()),
@@ -98,10 +98,12 @@ TopSitesImpl::TopSitesImpl(PrefService* pref_service,
pref_service_(pref_service),
blacklist_pref_name_(blacklist_pref_name),
history_service_(history_service),
+ can_add_url_to_history_(can_add_url_to_history),
loaded_(false),
history_service_observer_(this) {
DCHECK(pref_service_);
DCHECK(blacklist_pref_name_);
+ DCHECK(!can_add_url_to_history_.is_null());
}
void TopSitesImpl::Init(
@@ -137,7 +139,7 @@ bool TopSitesImpl::SetPageThumbnail(const GURL& url,
}
}
- if (!CanAddURLToHistory(url))
+ if (!can_add_url_to_history_.Run(url))
return false; // It's not a real webpage.
scoped_refptr<base::RefCountedBytes> thumbnail_data;
@@ -176,7 +178,7 @@ bool TopSitesImpl::SetPageThumbnailToJPEGBytes(
}
}
- if (!CanAddURLToHistory(url))
+ if (!can_add_url_to_history_.Run(url))
return false; // It's not a real webpage.
if (add_temp_thumbnail) {
@@ -611,7 +613,7 @@ void TopSitesImpl::OnNavigationCommitted(const GURL& url) {
if (!loaded_ || IsNonForcedFull())
return;
- if (!cache_->IsKnownURL(url) && CanAddURLToHistory(url)) {
+ if (!cache_->IsKnownURL(url) && can_add_url_to_history_.Run(url)) {
// To avoid slamming history we throttle requests when the url updates. To
// do otherwise negatively impacts perf tests.
RestartQueryForTopSitesTimer(GetUpdateDelay());
« no previous file with comments | « components/history/core/browser/top_sites_impl.h ('k') | components/history/core/test/database_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698