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

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

Issue 2949733002: Show Play Store rating and price in app list (Closed)
Patch Set: Apply fix to patch set 5 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 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_ 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_ 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/app_list/search_result_observer.h" 9 #include "ui/app_list/search_result_observer.h"
10 #include "ui/app_list/views/tile_item_view.h" 10 #include "ui/app_list/views/tile_item_view.h"
11 #include "ui/views/context_menu_controller.h" 11 #include "ui/views/context_menu_controller.h"
12 12
13 namespace views { 13 namespace views {
14 class MenuRunner; 14 class MenuRunner;
15 class Label;
15 } 16 }
16 17
17 namespace app_list { 18 namespace app_list {
18 19
19 class AppListViewDelegate; 20 class AppListViewDelegate;
20 class SearchResult; 21 class SearchResult;
21 class SearchResultContainerView; 22 class SearchResultContainerView;
22 23
23 // A TileItemView that displays a search result. 24 // A TileItemView that displays a search result.
24 class APP_LIST_EXPORT SearchResultTileItemView 25 class APP_LIST_EXPORT SearchResultTileItemView
25 : public TileItemView, 26 : public TileItemView,
26 public views::ContextMenuController, 27 public views::ContextMenuController,
27 public SearchResultObserver { 28 public SearchResultObserver {
28 public: 29 public:
29 explicit SearchResultTileItemView(SearchResultContainerView* result_container, 30 explicit SearchResultTileItemView(SearchResultContainerView* result_container,
30 AppListViewDelegate* view_delegate); 31 AppListViewDelegate* view_delegate);
31 ~SearchResultTileItemView() override; 32 ~SearchResultTileItemView() override;
32 33
33 SearchResult* result() { return item_; } 34 SearchResult* result() { return item_; }
34 void SetSearchResult(SearchResult* item); 35 void SetSearchResult(SearchResult* item);
35 36
36 // Overridden from TileItemView: 37 // Overridden from TileItemView:
37 void ButtonPressed(views::Button* sender, const ui::Event& event) override; 38 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
38 bool OnKeyPressed(const ui::KeyEvent& event) override; 39 bool OnKeyPressed(const ui::KeyEvent& event) override;
39 40
40 // Overridden from SearchResultObserver: 41 // Overridden from SearchResultObserver:
41 void OnIconChanged() override; 42 void OnIconChanged() override;
42 void OnBadgeIconChanged() override; 43 void OnBadgeIconChanged() override;
44 void OnRatingChanged() override;
45 void OnFormattedPriceChanged() override;
43 void OnResultDestroying() override; 46 void OnResultDestroying() override;
44 47
45 // views::ContextMenuController overrides: 48 // views::ContextMenuController overrides:
46 void ShowContextMenuForView(views::View* source, 49 void ShowContextMenuForView(views::View* source,
47 const gfx::Point& point, 50 const gfx::Point& point,
48 ui::MenuSourceType source_type) override; 51 ui::MenuSourceType source_type) override;
49 52
50 private: 53 private:
54 // Shows rating in proper format if |rating| is not negative. Otherwise, hides
55 // the rating label.
56 void SetRating(float rating);
57
58 // Shows price if |price| is not empty. Otherwise, hides the price label.
59 void SetPrice(const base::string16& price);
60
51 // Overridden from views::View: 61 // Overridden from views::View:
52 void Layout() override; 62 void Layout() override;
53 gfx::Size CalculatePreferredSize() const override; 63 gfx::Size CalculatePreferredSize() const override;
54 64
55 SearchResultContainerView* result_container_; // Parent view 65 SearchResultContainerView* result_container_; // Parent view
56 66
57 // Owned by the model provided by the AppListViewDelegate. 67 // Owned by the model provided by the AppListViewDelegate.
58 SearchResult* item_; 68 SearchResult* item_ = nullptr;
69
70 views::Label* rating_ = nullptr; // Owned by views hierarchy.
71 views::Label* price_ = nullptr; // Owned by views hierarchy.
59 72
60 AppListViewDelegate* view_delegate_; 73 AppListViewDelegate* view_delegate_;
61 74
62 const bool is_fullscreen_app_list_enabled_; 75 const bool is_fullscreen_app_list_enabled_;
63 76
64 std::unique_ptr<views::MenuRunner> context_menu_runner_; 77 std::unique_ptr<views::MenuRunner> context_menu_runner_;
65 78
66 DISALLOW_COPY_AND_ASSIGN(SearchResultTileItemView); 79 DISALLOW_COPY_AND_ASSIGN(SearchResultTileItemView);
67 }; 80 };
68 81
69 } // namespace app_list 82 } // namespace app_list
70 83
71 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_ 84 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_VIEW_H_
OLDNEW
« no previous file with comments | « ui/app_list/views/search_result_tile_item_list_view.cc ('k') | ui/app_list/views/search_result_tile_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698