Commit a605b4f7 authored by Bret Sepulveda's avatar Bret Sepulveda Committed by Commit Bot

Fix unit tests that use OmniboxViewViews in Refresh.

Some tests would create an instance of OmniboxViewViews, but without a
location bar. Refresh tries to access the location bar to set the
placeholder text, and this would crash. This patch moves that code into
Init and guards it by checking that location_bar_view_ is defined.

Bug: 846410
Change-Id: I0a1aec21f515dcc441e52c92c0c1adc58163348f
Reviewed-on: https://chromium-review.googlesource.com/1098141Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566682}
parent eba62fae
...@@ -139,12 +139,6 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, ...@@ -139,12 +139,6 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
scoped_template_url_service_observer_(this) { scoped_template_url_service_observer_(this) {
set_id(VIEW_ID_OMNIBOX); set_id(VIEW_ID_OMNIBOX);
SetFontList(font_list); SetFontList(font_list);
if (ui::MaterialDesignController::IsNewerMaterialUi()) {
InstallPlaceholderText();
scoped_template_url_service_observer_.Add(
model()->client()->GetTemplateURLService());
}
} }
OmniboxViewViews::~OmniboxViewViews() { OmniboxViewViews::~OmniboxViewViews() {
...@@ -167,6 +161,11 @@ void OmniboxViewViews::Init() { ...@@ -167,6 +161,11 @@ void OmniboxViewViews::Init() {
SetReadOnly(true); SetReadOnly(true);
if (location_bar_view_) { if (location_bar_view_) {
if (ui::MaterialDesignController::IsNewerMaterialUi()) {
InstallPlaceholderText();
scoped_template_url_service_observer_.Add(
model()->client()->GetTemplateURLService());
}
// Initialize the popup view using the same font. // Initialize the popup view using the same font.
popup_view_.reset( popup_view_.reset(
new OmniboxPopupContentsView(this, model(), location_bar_view_)); new OmniboxPopupContentsView(this, model(), location_bar_view_));
......
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