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

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_result_view.h

Issue 917333004: Answers in Suggest icon downloading (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: setting image service in constructor Created 5 years, 9 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 (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
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 void SetAnswerImage(gfx::ImageSkia image);
Peter Kasting 2015/03/03 01:32:37 Nit: Write a comment about what this does
dschuyler 2015/03/03 21:13:57 Done.
80
81 base::WeakPtr<OmniboxResultView> GetWeakPtr() {
Peter Kasting 2015/03/03 01:32:37 You shouldn't inline functions that aren't simple
dschuyler 2015/03/03 21:13:57 Done.
82 return weak_ptr_factory_.GetWeakPtr();
83 }
84
78 protected: 85 protected:
79 // Paints the given |match| using the RenderText instances |contents| and 86 // Paints the given |match| using the RenderText instances |contents| and
80 // |description| at offset |x| in the bounds of this view. 87 // |description| at offset |x| in the bounds of this view.
81 virtual void PaintMatch(const AutocompleteMatch& match, 88 virtual void PaintMatch(const AutocompleteMatch& match,
82 gfx::RenderText* contents, 89 gfx::RenderText* contents,
83 gfx::RenderText* description, 90 gfx::RenderText* description,
84 gfx::Canvas* canvas, 91 gfx::Canvas* canvas,
85 int x) const; 92 int x) const;
86 93
87 // Draws given |render_text| on |canvas| at given location (|x|, |y|). 94 // Draws given |render_text| on |canvas| at given location (|x|, |y|).
(...skipping 26 matching lines...) Expand all
114 void set_edge_item_padding(int value) { edge_item_padding_ = value; } 121 void set_edge_item_padding(int value) { edge_item_padding_ = value; }
115 void set_item_padding(int value) { item_padding_ = value; } 122 void set_item_padding(int value) { item_padding_ = value; }
116 void set_minimum_text_vertical_padding(int value) { 123 void set_minimum_text_vertical_padding(int value) {
117 minimum_text_vertical_padding_ = value; 124 minimum_text_vertical_padding_ = value;
118 } 125 }
119 126
120 private: 127 private:
121 // views::View: 128 // views::View:
122 const char* GetClassName() const override; 129 const char* GetClassName() const override;
123 130
131 void GetAnswerIcon();
124 gfx::ImageSkia GetIcon() const; 132 gfx::ImageSkia GetIcon() const;
125 const gfx::ImageSkia* GetKeywordIcon() const; 133 const gfx::ImageSkia* GetKeywordIcon() const;
126 134
127 // Whether to render only the keyword match. Returns true if |match_| has an 135 // Whether to render only the keyword match. Returns true if |match_| has an
128 // associated keyword match that has been animated so close to the start that 136 // associated keyword match that has been animated so close to the start that
129 // the keyword match will hide even the icon of the regular match. 137 // the keyword match will hide even the icon of the regular match.
130 bool ShowOnlyKeywordMatch() const; 138 bool ShowOnlyKeywordMatch() const;
131 139
132 // Resets all RenderTexts for contents and description of the |match_| and its 140 // Resets all RenderTexts for contents and description of the |match_| and its
133 // associated keyword match. 141 // associated keyword match.
(...skipping 12 matching lines...) Expand all
146 154
147 // Returns the offset at which the contents of the |match| should be displayed 155 // Returns the offset at which the contents of the |match| should be displayed
148 // within the text bounds. The directionality of UI and match contents is used 156 // within the text bounds. The directionality of UI and match contents is used
149 // to determine the offset relative to the correct edge. 157 // to determine the offset relative to the correct edge.
150 int GetDisplayOffset(const AutocompleteMatch& match, 158 int GetDisplayOffset(const AutocompleteMatch& match,
151 bool is_ui_rtl, 159 bool is_ui_rtl,
152 bool is_match_contents_rtl) const; 160 bool is_match_contents_rtl) const;
153 161
154 static int default_icon_size_; 162 static int default_icon_size_;
155 163
164 // If the answer has an icon, these control the fetching and updating
Peter Kasting 2015/03/03 01:32:37 Nit: Since the |image_service_| is initted uncondi
dschuyler 2015/03/03 21:13:57 Done.
165 // of the icon.
166 BitmapFetcherService* image_service_;
167 BitmapFetcherService::RequestId request_id_;
168 gfx::ImageSkia answer_image_;
169
156 // Default values cached here, may be overridden using the setters above. 170 // Default values cached here, may be overridden using the setters above.
157 int edge_item_padding_; 171 int edge_item_padding_;
158 int item_padding_; 172 int item_padding_;
159 int minimum_text_vertical_padding_; 173 int minimum_text_vertical_padding_;
160 174
161 // This row's model and model index. 175 // This row's model and model index.
162 OmniboxPopupContentsView* model_; 176 OmniboxPopupContentsView* model_;
163 size_t model_index_; 177 size_t model_index_;
164 178
165 LocationBarView* location_bar_view_; 179 LocationBarView* location_bar_view_;
(...skipping 18 matching lines...) Expand all
184 // We preserve these RenderTexts so that we won't recreate them on every call 198 // We preserve these RenderTexts so that we won't recreate them on every call
185 // to GetMatchContentsWidth() or OnPaint(). 199 // to GetMatchContentsWidth() or OnPaint().
186 mutable scoped_ptr<gfx::RenderText> contents_rendertext_; 200 mutable scoped_ptr<gfx::RenderText> contents_rendertext_;
187 mutable scoped_ptr<gfx::RenderText> description_rendertext_; 201 mutable scoped_ptr<gfx::RenderText> description_rendertext_;
188 mutable scoped_ptr<gfx::RenderText> separator_rendertext_; 202 mutable scoped_ptr<gfx::RenderText> separator_rendertext_;
189 mutable scoped_ptr<gfx::RenderText> keyword_contents_rendertext_; 203 mutable scoped_ptr<gfx::RenderText> keyword_contents_rendertext_;
190 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_; 204 mutable scoped_ptr<gfx::RenderText> keyword_description_rendertext_;
191 205
192 mutable int separator_width_; 206 mutable int separator_width_;
193 207
208 base::WeakPtrFactory<OmniboxResultView> weak_ptr_factory_;
209
194 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView); 210 DISALLOW_COPY_AND_ASSIGN(OmniboxResultView);
195 }; 211 };
196 212
197 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_ 213 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_RESULT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698