Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_SEARCH_RESULT_H_ | 5 #ifndef UI_APP_LIST_SEARCH_RESULT_H_ |
| 6 #define UI_APP_LIST_SEARCH_RESULT_H_ | 6 #define UI_APP_LIST_SEARCH_RESULT_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 14 #include "ui/gfx/image/image_skia.h" | 14 #include "ui/gfx/image/image_skia.h" |
| 15 #include "ui/gfx/range/range.h" | 15 #include "ui/gfx/range/range.h" |
| 16 | 16 |
| 17 namespace ui { | 17 namespace ui { |
| 18 class MenuModel; | 18 class MenuModel; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace app_list { | 21 namespace app_list { |
| 22 | 22 |
| 23 class SearchResultObserver; | 23 class SearchResultObserver; |
| 24 | 24 |
| 25 // The type of the search result. This is used for logging so do not change the | |
| 26 // order of this enum. | |
| 27 enum SearchResultType { | |
|
xiyuan
2014/10/02 20:47:08
This is chrome specific and probably should not li
Jun Mukai
2014/10/03 01:24:23
Thinking about this, I think it's better not to do
tapted
2014/10/03 02:59:17
looks nice :)
| |
| 28 // A result that forwards an omnibox search result. | |
| 29 OMNIBOX_SEARCH_RESULT, | |
| 30 // An app result. | |
| 31 APP_SEARCH_RESULT, | |
| 32 // A search result from the webstore. | |
| 33 WEBSTORE_SEARCH_RESULT, | |
| 34 // A result that opens a webstore search. | |
| 35 SEARCH_WEBSTORE_SEARCH_RESULT, | |
| 36 // A result that opens a people search. | |
| 37 SEARCH_PEOPLE_SEARCH_RESULT, | |
| 38 SEARCH_RESULT_TYPE_BOUNDARY | |
| 39 }; | |
| 40 | |
| 25 // SearchResult consists of an icon, title text and details text. Title and | 41 // SearchResult consists of an icon, title text and details text. Title and |
| 26 // details text can have tagged ranges that are displayed differently from | 42 // details text can have tagged ranges that are displayed differently from |
| 27 // default style. | 43 // default style. |
| 28 class APP_LIST_EXPORT SearchResult { | 44 class APP_LIST_EXPORT SearchResult { |
| 29 public: | 45 public: |
| 30 // How the result should be displayed. | 46 // How the result should be displayed. |
| 31 enum DisplayType { | 47 enum DisplayType { |
| 32 DISPLAY_LIST, | 48 DISPLAY_LIST, |
| 33 DISPLAY_TILE, | 49 DISPLAY_TILE, |
| 34 }; | 50 }; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 | 127 |
| 112 // Returns the dimension at which this result's icon should be displayed. | 128 // Returns the dimension at which this result's icon should be displayed. |
| 113 int GetPreferredIconDimension() const; | 129 int GetPreferredIconDimension() const; |
| 114 | 130 |
| 115 void NotifyItemInstalled(); | 131 void NotifyItemInstalled(); |
| 116 void NotifyItemUninstalled(); | 132 void NotifyItemUninstalled(); |
| 117 | 133 |
| 118 void AddObserver(SearchResultObserver* observer); | 134 void AddObserver(SearchResultObserver* observer); |
| 119 void RemoveObserver(SearchResultObserver* observer); | 135 void RemoveObserver(SearchResultObserver* observer); |
| 120 | 136 |
| 137 // TODO(mukai): Remove this method and really simplify the ownership of | |
| 138 // SearchResult. Ideally, SearchResult will be copyable. | |
| 139 virtual scoped_ptr<SearchResult> Duplicate(); | |
|
tapted
2014/10/02 07:19:21
Can these be pure virtual? I think I'd prefer the
Jun Mukai
2014/10/03 01:24:23
Done.
| |
| 140 | |
| 141 // Returns the type of the search for logging. By default it returns | |
| 142 // SEARCH_RESULT_TYPE_BOUNDARY which is okay for tests but will cause problems | |
| 143 // in production. | |
| 144 virtual SearchResultType GetType(); | |
| 145 | |
| 121 // Opens the result. | 146 // Opens the result. |
| 122 virtual void Open(int event_flags); | 147 virtual void Open(int event_flags); |
| 123 | 148 |
| 124 // Invokes a custom action on the result. | 149 // Invokes a custom action on the result. It does nothing by default. |
| 125 virtual void InvokeAction(int action_index, int event_flags); | 150 virtual void InvokeAction(int action_index, int event_flags); |
| 126 | 151 |
| 127 // Returns the context menu model for this item, or NULL if there is currently | 152 // Returns the context menu model for this item, or NULL if there is currently |
| 128 // no menu for the item (e.g. during install). | 153 // no menu for the item (e.g. during install). |
| 129 // Note the returned menu model is owned by this item. | 154 // Note the returned menu model is owned by this item. |
| 130 virtual ui::MenuModel* GetContextMenuModel(); | 155 virtual ui::MenuModel* GetContextMenuModel(); |
| 131 | 156 |
| 132 protected: | 157 protected: |
| 133 void set_id(const std::string& id) { id_ = id; } | 158 void set_id(const std::string& id) { id_ = id; } |
| 134 void set_relevance(double relevance) { relevance_ = relevance; } | 159 void set_relevance(double relevance) { relevance_ = relevance; } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 155 int percent_downloaded_; | 180 int percent_downloaded_; |
| 156 | 181 |
| 157 ObserverList<SearchResultObserver> observers_; | 182 ObserverList<SearchResultObserver> observers_; |
| 158 | 183 |
| 159 DISALLOW_COPY_AND_ASSIGN(SearchResult); | 184 DISALLOW_COPY_AND_ASSIGN(SearchResult); |
| 160 }; | 185 }; |
| 161 | 186 |
| 162 } // namespace app_list | 187 } // namespace app_list |
| 163 | 188 |
| 164 #endif // UI_APP_LIST_SEARCH_RESULT_H_ | 189 #endif // UI_APP_LIST_SEARCH_RESULT_H_ |
| OLD | NEW |