Commit 3ac2b20f authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

NTP: Avoid supervised user URL filter checks for non-SUs

These checks can be fairly expensive, and they're called on the critical
path for all navigations. No reason to pay the cost for non-SUs.

Bug: 786035
Change-Id: Id47d0b2fe4c86371fd4c277e363a4f7fcfd49194
Reviewed-on: https://chromium-review.googlesource.com/775959Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517413}
parent c8da62b1
......@@ -95,6 +95,10 @@ bool IsNTPOrServiceWorkerURL(const GURL& url, Profile* profile) {
bool IsURLAllowedForSupervisedUser(const GURL& url, Profile* profile) {
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
// If this isn't a supervised user, skip the URL filter check, since it can be
// fairly expensive.
if (!profile->IsSupervised())
return true;
SupervisedUserService* supervised_user_service =
SupervisedUserServiceFactory::GetForProfile(profile);
SupervisedUserURLFilter* url_filter = supervised_user_service->GetURLFilter();
......
......@@ -350,6 +350,8 @@ TEST_F(SearchTest, UseLocalNTPIfNTPURLIsNotSet) {
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
TEST_F(SearchTest, UseLocalNTPIfNTPURLIsBlockedForSupervisedUser) {
// Mark the profile as supervised, otherwise the URL filter won't be checked.
profile()->SetSupervisedUserId("supervised");
// Block access to foo.com in the URL filter.
SupervisedUserService* supervised_user_service =
SupervisedUserServiceFactory::GetForProfile(profile());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment