Commit 8accdedd authored by Balazs Engedy's avatar Balazs Engedy Committed by Commit Bot

Document invariants in SearchGeolocationDisclosureTabHelper.

TemplateURLService::GetDefaultSearchProvider() will return nullptr when
the `DefaultSearchProviderEnabled` policy is set to `false`.

SearchGeolocationDisclosureTabHelper::MaybeShowDisclosureForValidUrl()
can, however, assume that the return value of GetDefaultSearchProvider()
will be non-null, because the former method will only ever be called if
a DSE is enabled. Document this in the code in the form of a DCHECK.

Bug: 1011910
Change-Id: Ie8763e9b0e6e030347eb956125aeea7e25e17458
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1855819
Auto-Submit: Balazs Engedy <engedy@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705487}
parent 2f0fc46c
......@@ -160,6 +160,10 @@ void SearchGeolocationDisclosureTabHelper::MaybeShowDisclosureForValidUrl(
TemplateURLServiceFactory::GetForProfile(GetProfile());
const TemplateURL* template_url =
template_url_service->GetDefaultSearchProvider();
// ShouldShowDisclosureForNavigation() checked explicitly that the default
// search |template_url| was non-null, and ShouldShowDisclosureForAPIAccess()
// would have also seen an empty DSE origin if it were.
DCHECK(template_url);
base::string16 search_engine_name = template_url->short_name();
SearchGeolocationDisclosureInfoBarDelegate::Create(web_contents(), gurl,
search_engine_name);
......
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