OLD | NEW |
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 #include "chrome/browser/ui/app_list/search/omnibox_result.h" | 5 #include "chrome/browser/ui/app_list/search/omnibox_result.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 13 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
14 #include "chrome/browser/ui/app_list/search/search_util.h" | 14 #include "chrome/browser/ui/app_list/search/search_util.h" |
15 #include "chrome/grit/theme_resources.h" | |
16 #include "components/bookmarks/browser/bookmark_model.h" | 15 #include "components/bookmarks/browser/bookmark_model.h" |
17 #include "components/omnibox/browser/autocomplete_controller.h" | 16 #include "components/omnibox/browser/autocomplete_controller.h" |
18 #include "components/omnibox/browser/autocomplete_match_type.h" | 17 #include "components/omnibox/browser/autocomplete_match_type.h" |
19 #include "ui/app_list/app_list_constants.h" | 18 #include "ui/app_list/app_list_constants.h" |
20 #include "ui/base/material_design/material_design_controller.h" | |
21 #include "ui/base/resource/resource_bundle.h" | |
22 #include "ui/gfx/paint_vector_icon.h" | 19 #include "ui/gfx/paint_vector_icon.h" |
23 #include "ui/gfx/vector_icons_public.h" | 20 #include "ui/gfx/vector_icons_public.h" |
24 #include "url/gurl.h" | 21 #include "url/gurl.h" |
25 #include "url/url_canon.h" | 22 #include "url/url_canon.h" |
26 | 23 |
27 using bookmarks::BookmarkModel; | 24 using bookmarks::BookmarkModel; |
28 | 25 |
29 namespace app_list { | 26 namespace app_list { |
30 | 27 |
31 namespace { | 28 namespace { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 new OmniboxResult(profile_, list_controller_, autocomplete_controller_, | 161 new OmniboxResult(profile_, list_controller_, autocomplete_controller_, |
165 is_voice_query_, match_)); | 162 is_voice_query_, match_)); |
166 } | 163 } |
167 | 164 |
168 void OmniboxResult::UpdateIcon() { | 165 void OmniboxResult::UpdateIcon() { |
169 BookmarkModel* bookmark_model = | 166 BookmarkModel* bookmark_model = |
170 BookmarkModelFactory::GetForBrowserContext(profile_); | 167 BookmarkModelFactory::GetForBrowserContext(profile_); |
171 bool is_bookmarked = | 168 bool is_bookmarked = |
172 bookmark_model && bookmark_model->IsBookmarked(match_.destination_url); | 169 bookmark_model && bookmark_model->IsBookmarked(match_.destination_url); |
173 | 170 |
174 if (ui::MaterialDesignController::IsModeMaterial()) { | 171 gfx::VectorIconId icon_id = is_bookmarked ? |
175 gfx::VectorIconId icon_id = is_bookmarked ? | 172 gfx::VectorIconId::OMNIBOX_STAR : |
176 gfx::VectorIconId::OMNIBOX_STAR : | 173 AutocompleteMatch::TypeToVectorIcon(match_.type); |
177 AutocompleteMatch::TypeToVectorIcon(match_.type); | 174 SetIcon(gfx::CreateVectorIcon(icon_id, 16, app_list::kIconColor)); |
178 SetIcon(gfx::CreateVectorIcon(icon_id, 16, app_list::kIconColor)); | |
179 return; | |
180 } | |
181 | |
182 int resource_id = is_bookmarked ? IDR_OMNIBOX_STAR | |
183 : AutocompleteMatch::TypeToIcon(match_.type); | |
184 SetIcon( | |
185 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id)); | |
186 } | 175 } |
187 | 176 |
188 void OmniboxResult::UpdateTitleAndDetails() { | 177 void OmniboxResult::UpdateTitleAndDetails() { |
189 set_title(match_.contents); | 178 set_title(match_.contents); |
190 SearchResult::Tags title_tags; | 179 SearchResult::Tags title_tags; |
191 ACMatchClassificationsToTags(match_.contents, match_.contents_class, | 180 ACMatchClassificationsToTags(match_.contents, match_.contents_class, |
192 &title_tags); | 181 &title_tags); |
193 set_title_tags(title_tags); | 182 set_title_tags(title_tags); |
194 | 183 |
195 set_details(match_.description); | 184 set_details(match_.description); |
196 SearchResult::Tags details_tags; | 185 SearchResult::Tags details_tags; |
197 ACMatchClassificationsToTags(match_.description, match_.description_class, | 186 ACMatchClassificationsToTags(match_.description, match_.description_class, |
198 &details_tags); | 187 &details_tags); |
199 set_details_tags(details_tags); | 188 set_details_tags(details_tags); |
200 } | 189 } |
201 | 190 |
202 } // namespace app_list | 191 } // namespace app_list |
OLD | NEW |