Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: ui/app_list/views/search_result_tile_item_view.cc

Issue 665233002: Experimental app list: Added "All apps" button on start page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/app-list-factor-folderimagesource
Patch Set: Rebase. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/search_result_tile_item_view.h ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « ui/app_list/views/search_result_tile_item_view.h ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698