Commit 4bbe66b0 authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

Omnibox UI Refresh: Fix placeholder text if no default search provider

During unit tests, or if the default search provider is disabled by
policy, there may not be any default search provider.

Previously, we would attempt to dereference a nullptr in that case, and
would intermittently crash. This CL fixes that by simply clearing the
placeholder text when there is no default search provider.

This is fine - as before Material Refresh there was no placeholder text
at all.

Bug: 852630
Change-Id: Id7933f7972de20a41252f8d4f0f7bb16ce623037
Reviewed-on: https://chromium-review.googlesource.com/1101710Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Tommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567709}
parent 616ef937
......@@ -224,16 +224,18 @@ void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) {
}
void OmniboxViewViews::InstallPlaceholderText() {
base::string16 search_provider_name = model()
->client()
->GetTemplateURLService()
->GetDefaultSearchProvider()
->short_name();
set_placeholder_text(l10n_util::GetStringFUTF16(IDS_OMNIBOX_PLACEHOLDER_TEXT,
search_provider_name));
set_placeholder_text_color(
location_bar_view_->GetColor(OmniboxPart::LOCATION_BAR_TEXT_DIMMED));
set_placeholder_text_hidden_on_focus(true);
const TemplateURL* const default_provider =
model()->client()->GetTemplateURLService()->GetDefaultSearchProvider();
if (default_provider) {
set_placeholder_text(l10n_util::GetStringFUTF16(
IDS_OMNIBOX_PLACEHOLDER_TEXT, default_provider->short_name()));
} else {
set_placeholder_text(base::string16());
}
}
void OmniboxViewViews::UpdateTextIndent() {
......
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