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 CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" | |
11 #include "components/omnibox/autocomplete_match.h" | 12 #include "components/omnibox/autocomplete_match.h" |
12 #include "third_party/skia/include/core/SkColor.h" | 13 #include "third_party/skia/include/core/SkColor.h" |
13 #include "ui/gfx/animation/animation_delegate.h" | 14 #include "ui/gfx/animation/animation_delegate.h" |
14 #include "ui/gfx/animation/slide_animation.h" | 15 #include "ui/gfx/animation/slide_animation.h" |
15 #include "ui/gfx/font_list.h" | 16 #include "ui/gfx/font_list.h" |
16 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/views/controls/image_view.h" | 18 #include "ui/views/controls/image_view.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
19 | 20 |
20 class LocationBarView; | 21 class LocationBarView; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 | 69 |
69 ResultViewState GetState() const; | 70 ResultViewState GetState() const; |
70 | 71 |
71 // Returns the height of the text portion of the result view. In the base | 72 // Returns the height of the text portion of the result view. In the base |
72 // class, this is the height of one line of text. | 73 // class, this is the height of one line of text. |
73 virtual int GetTextHeight() const; | 74 virtual int GetTextHeight() const; |
74 | 75 |
75 // Returns the display width required for the match contents. | 76 // Returns the display width required for the match contents. |
76 int GetMatchContentsWidth() const; | 77 int GetMatchContentsWidth() const; |
77 | 78 |
79 // Store the image in a local data member and schedule a repaint. | |
Peter Kasting
2015/03/05 00:33:43
Nit: Stores/schedules
dschuyler
2015/03/05 18:31:04
Done.
| |
80 void SetAnswerImage(gfx::ImageSkia image); | |
Peter Kasting
2015/03/05 00:33:43
const &?
dschuyler
2015/03/05 18:31:04
Both by-value and by-reference are used for ImageS
| |
81 | |
78 protected: | 82 protected: |
79 // Paints the given |match| using the RenderText instances |contents| and | 83 // Paints the given |match| using the RenderText instances |contents| and |
80 // |description| at offset |x| in the bounds of this view. | 84 // |description| at offset |x| in the bounds of this view. |
81 virtual void PaintMatch(const AutocompleteMatch& match, | 85 virtual void PaintMatch(const AutocompleteMatch& match, |
82 gfx::RenderText* contents, | 86 gfx::RenderText* contents, |
83 gfx::RenderText* description, | 87 gfx::RenderText* description, |
84 gfx::Canvas* canvas, | 88 gfx::Canvas* canvas, |
85 int x) const; | 89 int x) const; |
86 | 90 |
87 // Draws given |render_text| on |canvas| at given location (|x|, |y|). | 91 // Draws given |render_text| on |canvas| at given location (|x|, |y|). |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 // Default values cached here, may be overridden using the setters above. | 160 // Default values cached here, may be overridden using the setters above. |
157 int edge_item_padding_; | 161 int edge_item_padding_; |
158 int item_padding_; | 162 int item_padding_; |
159 int minimum_text_vertical_padding_; | 163 int minimum_text_vertical_padding_; |
160 | 164 |
161 // This row's model and model index. | 165 // This row's model and model index. |
162 OmniboxPopupContentsView* model_; | 166 OmniboxPopupContentsView* model_; |
163 size_t model_index_; | 167 size_t model_index_; |
164 | 168 |
165 LocationBarView* location_bar_view_; | 169 LocationBarView* location_bar_view_; |
170 BitmapFetcherService* image_service_; | |
Peter Kasting
2015/03/05 00:33:43
Nit: May want to comment that this can be null whi
dschuyler
2015/03/05 18:31:04
Done.
| |
166 | 171 |
167 const gfx::FontList font_list_; | 172 const gfx::FontList font_list_; |
168 int font_height_; | 173 int font_height_; |
169 | 174 |
170 // A context used for mirroring regions. | 175 // A context used for mirroring regions. |
171 class MirroringContext; | 176 class MirroringContext; |
172 scoped_ptr<MirroringContext> mirroring_context_; | 177 scoped_ptr<MirroringContext> mirroring_context_; |
173 | 178 |
174 AutocompleteMatch match_; | 179 AutocompleteMatch match_; |
175 | 180 |
176 gfx::Rect text_bounds_; | 181 gfx::Rect text_bounds_; |
177 gfx::Rect icon_bounds_; | 182 gfx::Rect icon_bounds_; |
178 | 183 |
179 gfx::Rect keyword_text_bounds_; | 184 gfx::Rect keyword_text_bounds_; |
180 scoped_ptr<views::ImageView> keyword_icon_; | 185 scoped_ptr<views::ImageView> keyword_icon_; |
181 | 186 |
182 scoped_ptr<gfx::SlideAnimation> animation_; | 187 scoped_ptr<gfx::SlideAnimation> animation_; |
183 | 188 |
189 // If the answer has an icon, these control the fetching and updating | |
190 // of the icon. | |
191 BitmapFetcherService::RequestId request_id_; | |
192 gfx::ImageSkia answer_image_; | |
193 | |
184 // We preserve these RenderTexts so that we won't recreate them on every call | 194 // We preserve these RenderTexts so that we won't recreate them on every call |
185 // to GetMatchContentsWidth() or OnPaint(). | 195 // to GetMatchContentsWidth() or OnPaint(). |
186 mutable scoped_ptr<gfx::RenderText> contents_rendertext_; | 196 mutable scoped_ptr<gfx::RenderText> contents_rendertext_; |
187 mutable scoped_ptr<gfx::RenderText> description_rendertext_; | 197 mutable scoped_ptr<gfx::RenderText> description_rendertext_; |
188 mutable scoped_ptr<gfx::RenderText> separator_rendertext_; | 198 mutable scoped_ptr<gfx::RenderText> separator_rendertext_; |
189 mutable scoped_ptr<gfx::RenderText> keyword_contents_rendertext_; | 199 mutable scoped_ptr<gfx::RenderText> keyword_contents_rendertext_; |
190 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_; | 200 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_; |
191 | 201 |
192 mutable int separator_width_; | 202 mutable int separator_width_; |
193 | 203 |
204 base::WeakPtrFactory<OmniboxResultView> weak_ptr_factory_; | |
205 | |
194 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); | 206 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); |
195 }; | 207 }; |
196 | 208 |
197 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ | 209 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ |
OLD | NEW |