disable two ClientCertStoreChromeOSTest.* unit_tests on Valgrind bots
[chromium-blink-merge.git] / ui / app_list / views / search_result_view.h
blob1167cc26015219e99cdb22c5f40237fe5353f932
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/strings/string16.h"
15 #include "ui/app_list/search_result_observer.h"
16 #include "ui/app_list/views/search_result_actions_view_delegate.h"
17 #include "ui/views/context_menu_controller.h"
18 #include "ui/views/controls/button/custom_button.h"
20 namespace gfx {
21 class RenderText;
24 namespace views {
25 class ImageButton;
26 class ImageView;
27 class MenuRunner;
30 namespace app_list {
31 namespace test {
32 class SearchResultListViewTest;
33 } // namespace test
35 class ProgressBarView;
36 class SearchResult;
37 class SearchResultListView;
38 class SearchResultViewDelegate;
39 class SearchResultActionsView;
41 // SearchResultView displays a SearchResult.
42 class APP_LIST_EXPORT SearchResultView
43 : public views::CustomButton,
44 public views::ButtonListener,
45 public views::ContextMenuController,
46 public SearchResultObserver,
47 NON_EXPORTED_BASE(public SearchResultActionsViewDelegate) {
48 public:
49 // Internal class name.
50 static const char kViewClassName[];
52 explicit SearchResultView(SearchResultListView* list_view);
53 ~SearchResultView() override;
55 // Sets/gets SearchResult displayed by this view.
56 void SetResult(SearchResult* result);
57 SearchResult* result() { return result_; }
59 // Clears reference to SearchResult but don't schedule repaint.
60 void ClearResultNoRepaint();
62 // Clears the selected action.
63 void ClearSelectedAction();
65 // Computes the button's spoken feedback name.
66 base::string16 ComputeAccessibleName() const;
68 void set_is_last_result(bool is_last) { is_last_result_ = is_last; }
70 private:
71 friend class app_list::test::SearchResultListViewTest;
73 void UpdateTitleText();
74 void UpdateDetailsText();
75 void UpdateAccessibleName();
77 // views::View overrides:
78 const char* GetClassName() const override;
79 gfx::Size GetPreferredSize() const override;
80 void Layout() override;
81 bool OnKeyPressed(const ui::KeyEvent& event) override;
82 void ChildPreferredSizeChanged(views::View* child) override;
83 void OnPaint(gfx::Canvas* canvas) override;
85 // views::ButtonListener overrides:
86 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
88 // views::ContextMenuController overrides:
89 void ShowContextMenuForView(views::View* source,
90 const gfx::Point& point,
91 ui::MenuSourceType source_type) override;
93 // SearchResultObserver overrides:
94 void OnIconChanged() override;
95 void OnBadgeIconChanged() override;
96 void OnActionsChanged() override;
97 void OnIsInstallingChanged() override;
98 void OnPercentDownloadedChanged() override;
99 void OnItemInstalled() override;
101 void SetIconImage(const gfx::ImageSkia& source,
102 views::ImageView* const icon,
103 const int icon_dimension);
105 // SearchResultActionsViewDelegate overrides:
106 void OnSearchResultActionActivated(size_t index, int event_flags) override;
108 SearchResult* result_; // Owned by AppListModel::SearchResults.
110 bool is_last_result_;
112 // Parent list view. Owned by views hierarchy.
113 SearchResultListView* list_view_;
115 views::ImageView* icon_; // Owned by views hierarchy.
116 views::ImageView* badge_icon_; // Owned by views hierarchy.
117 scoped_ptr<gfx::RenderText> title_text_;
118 scoped_ptr<gfx::RenderText> details_text_;
119 SearchResultActionsView* actions_view_; // Owned by the views hierarchy.
120 ProgressBarView* progress_bar_; // Owned by views hierarchy.
122 scoped_ptr<views::MenuRunner> context_menu_runner_;
124 DISALLOW_COPY_AND_ASSIGN(SearchResultView);
127 } // namespace app_list
129 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_VIEW_H_