| Index: ui/app_list/views/search_result_tile_item_view.cc
|
| diff --git a/ui/app_list/views/search_result_tile_item_view.cc b/ui/app_list/views/search_result_tile_item_view.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..59507d7916e95181037abe6a4534168f49e848c4
|
| --- /dev/null
|
| +++ b/ui/app_list/views/search_result_tile_item_view.cc
|
| @@ -0,0 +1,58 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/app_list/views/search_result_tile_item_view.h"
|
| +
|
| +#include "ui/app_list/search_result.h"
|
| +
|
| +namespace app_list {
|
| +
|
| +SearchResultTileItemView::SearchResultTileItemView() : item_(NULL) {
|
| +}
|
| +
|
| +SearchResultTileItemView::~SearchResultTileItemView() {
|
| + if (item_)
|
| + item_->RemoveObserver(this);
|
| +}
|
| +
|
| +void SearchResultTileItemView::SetSearchResult(SearchResult* item) {
|
| + SetVisible(item != NULL);
|
| +
|
| + SearchResult* old_item = item_;
|
| + if (old_item)
|
| + old_item->RemoveObserver(this);
|
| +
|
| + item_ = item;
|
| +
|
| + if (!item)
|
| + return;
|
| +
|
| + item_->AddObserver(this);
|
| +
|
| + SetTitle(item_->title());
|
| +
|
| + // Only refresh the icon if it's different from the old one. This prevents
|
| + // flickering.
|
| + if (old_item == NULL ||
|
| + !item->icon().BackedBySameObjectAs(old_item->icon())) {
|
| + OnIconChanged();
|
| + }
|
| +}
|
| +
|
| +void SearchResultTileItemView::ButtonPressed(views::Button* sender,
|
| + const ui::Event& event) {
|
| + item_->Open(event.flags());
|
| +}
|
| +
|
| +void SearchResultTileItemView::OnIconChanged() {
|
| + SetIcon(item_->icon());
|
| +}
|
| +
|
| +void SearchResultTileItemView::OnResultDestroying() {
|
| + if (item_)
|
| + item_->RemoveObserver(this);
|
| + item_ = NULL;
|
| +}
|
| +
|
| +} // namespace app_list
|
|
|