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

Side by Side Diff: ui/app_list/views/search_result_tile_item_view.cc

Issue 2949733002: Show Play Store rating and price in app list (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/search_result_tile_item_view.h" 5 #include "ui/app_list/views/search_result_tile_item_view.h"
6 6
7 #include "ui/app_list/app_list_view_delegate.h" 7 #include "ui/app_list/app_list_view_delegate.h"
8 #include "ui/app_list/search_result.h" 8 #include "ui/app_list/search_result.h"
9 #include "ui/app_list/views/search_result_container_view.h" 9 #include "ui/app_list/views/search_result_container_view.h"
10 #include "ui/views/controls/menu/menu_runner.h" 10 #include "ui/views/controls/menu/menu_runner.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 item_ = item; 43 item_ = item;
44 44
45 if (!item) 45 if (!item)
46 return; 46 return;
47 47
48 item_->AddObserver(this); 48 item_->AddObserver(this);
49 49
50 SetTitle(item_->title()); 50 SetTitle(item_->title());
51 51
52 // Todo(weidongg) add condition: instant or play store app.
xiyuan 2017/06/20 22:19:22 nit: TODO style is wrong. // TODO(weidongg): Only
weidongg 2017/06/22 00:59:16 Done.
53
xiyuan 2017/06/20 22:19:22 nit: strip extra empty lines here and Line 55.
weidongg 2017/06/22 00:59:16 Done.
54 SetPrice(item_->GetPriceString());
55
56 SetRating(item_->GetRatingString());
57
52 // Only refresh the icon if it's different from the old one. This prevents 58 // Only refresh the icon if it's different from the old one. This prevents
53 // flickering. 59 // flickering.
54 if (old_item == NULL || 60 if (old_item == NULL ||
55 !item->icon().BackedBySameObjectAs(old_item->icon())) { 61 !item->icon().BackedBySameObjectAs(old_item->icon())) {
56 OnIconChanged(); 62 OnIconChanged();
57 } 63 }
58 } 64 }
59 65
60 void SearchResultTileItemView::ButtonPressed(views::Button* sender, 66 void SearchResultTileItemView::ButtonPressed(views::Button* sender,
61 const ui::Event& event) { 67 const ui::Event& event) {
(...skipping 10 matching lines...) Expand all
72 } 78 }
73 79
74 void SearchResultTileItemView::OnIconChanged() { 80 void SearchResultTileItemView::OnIconChanged() {
75 SetIcon(item_->icon()); 81 SetIcon(item_->icon());
76 } 82 }
77 83
78 void SearchResultTileItemView::OnBadgeIconChanged() { 84 void SearchResultTileItemView::OnBadgeIconChanged() {
79 SetBadgeIcon(item_->badge_icon()); 85 SetBadgeIcon(item_->badge_icon());
80 } 86 }
81 87
88 void SearchResultTileItemView::OnPriceChanged() {
89 SetPrice(item_->GetPriceString());
90 }
91
92 void SearchResultTileItemView::OnRatingChanged() {
93 SetRating(item_->GetRatingString());
94 }
95
82 void SearchResultTileItemView::OnResultDestroying() { 96 void SearchResultTileItemView::OnResultDestroying() {
83 // The menu comes from |item_|. If we're showing a menu we need to cancel it. 97 // The menu comes from |item_|. If we're showing a menu we need to cancel it.
84 context_menu_runner_.reset(); 98 context_menu_runner_.reset();
85 99
86 if (item_) 100 if (item_)
87 item_->RemoveObserver(this); 101 item_->RemoveObserver(this);
88 102
89 SetSearchResult(nullptr); 103 SetSearchResult(nullptr);
90 } 104 }
91 105
(...skipping 13 matching lines...) Expand all
105 result_container_->ClearSelectedIndex(); 119 result_container_->ClearSelectedIndex();
106 120
107 context_menu_runner_.reset( 121 context_menu_runner_.reset(
108 new views::MenuRunner(menu_model, views::MenuRunner::HAS_MNEMONICS)); 122 new views::MenuRunner(menu_model, views::MenuRunner::HAS_MNEMONICS));
109 context_menu_runner_->RunMenuAt(GetWidget(), nullptr, 123 context_menu_runner_->RunMenuAt(GetWidget(), nullptr,
110 gfx::Rect(point, gfx::Size()), 124 gfx::Rect(point, gfx::Size()),
111 views::MENU_ANCHOR_TOPLEFT, source_type); 125 views::MENU_ANCHOR_TOPLEFT, source_type);
112 } 126 }
113 127
114 } // namespace app_list 128 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698