Commit 49ff2930 authored by xdai's avatar xdai Committed by Commit bot

Fix the Crash in the launcher's start page on Chrome OS.

In Chrome OS launcher's start page, we recreate the app tile views
if we need to display different numbers of apps compared with the
previous time (e.g., install a new app or uninstall an existing app).
We need to make sure the number of the displayed apps is properly
updated. Otherwise, it might cause browser crash because of retrieving
a stale pointer in StartPageView::StartPageTilesContainer::GetTileItemView().

This simple CL is a temporary fix that meant to merge back to M56. It
will be reverted later on Tot and a better but more complicated fix
will be landed.

BUG=675150

Review-Url: https://codereview.chromium.org/2605463003
Cr-Commit-Position: refs/heads/master@{#441275}
parent bf713870
......@@ -48,6 +48,7 @@ class APP_LIST_EXPORT SearchResultContainerView : public views::View,
bool IsValidSelectionIndex(int index) const;
int num_results() const { return num_results_; }
void set_num_results(int num_results) { num_results_ = num_results; }
void set_container_score(double score) { container_score_ = score; }
double container_score() const { return container_score_; }
......
......@@ -190,7 +190,7 @@ int StartPageView::StartPageTilesContainer::Update() {
delete search_result_tile_views_[i];
search_result_tile_views_.clear();
RemoveChildView(all_apps_button_);
CreateAppsGrid(std::min(kNumStartPageTiles, display_results.size()));
CreateAppsGrid(display_results.size());
}
// Update the tile item results.
......@@ -211,10 +211,10 @@ int StartPageView::StartPageTilesContainer::Update() {
void StartPageView::StartPageTilesContainer::UpdateSelectedIndex(
int old_selected,
int new_selected) {
if (old_selected >= 0)
if (old_selected >= 0 && old_selected < num_results())
GetTileItemView(old_selected)->SetSelected(false);
if (new_selected >= 0)
if (new_selected >= 0 && new_selected < num_results())
GetTileItemView(new_selected)->SetSelected(true);
}
......@@ -360,8 +360,8 @@ void StartPageView::OnShown() {
custom_page_view->SetVisible(
app_list_main_view_->ShouldShowCustomLauncherPage());
}
tiles_container_->Update();
tiles_container_->ClearSelectedIndex();
tiles_container_->set_num_results(tiles_container_->Update());
custom_launcher_page_background_->SetSelected(false);
}
......
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