| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_provider.h" | 5 #include "chrome/browser/ui/app_list/search/omnibox_provider.h" |
| 6 | 6 |
| 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 7 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 8 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 8 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_match.h" | 9 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 10 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 11 #include "chrome/browser/search_engines/template_url_service_factory.h" | 12 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 12 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" | 13 #include "chrome/browser/ui/app_list/search/chrome_search_result.h" |
| 13 #include "chrome/browser/ui/browser_navigator.h" | 14 #include "chrome/browser/ui/browser_navigator.h" |
| 14 #include "components/autocomplete/autocomplete_input.h" | 15 #include "components/autocomplete/autocomplete_input.h" |
| 16 #include "components/bookmarks/browser/bookmark_model.h" |
| 15 #include "components/metrics/proto/omnibox_event.pb.h" | 17 #include "components/metrics/proto/omnibox_event.pb.h" |
| 16 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 18 | 20 |
| 19 namespace app_list { | 21 namespace app_list { |
| 20 | 22 |
| 21 namespace { | 23 namespace { |
| 22 | 24 |
| 23 int ACMatchStyleToTagStyle(int styles) { | 25 int ACMatchStyleToTagStyle(int styles) { |
| 24 int tag_styles = 0; | 26 int tag_styles = 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 return scoped_ptr<ChromeSearchResult>( | 105 return scoped_ptr<ChromeSearchResult>( |
| 104 new OmniboxResult(profile_, autocomplete_controller_, match_)).Pass(); | 106 new OmniboxResult(profile_, autocomplete_controller_, match_)).Pass(); |
| 105 } | 107 } |
| 106 | 108 |
| 107 virtual ChromeSearchResultType GetType() OVERRIDE { | 109 virtual ChromeSearchResultType GetType() OVERRIDE { |
| 108 return OMNIBOX_SEARCH_RESULT; | 110 return OMNIBOX_SEARCH_RESULT; |
| 109 } | 111 } |
| 110 | 112 |
| 111 private: | 113 private: |
| 112 void UpdateIcon() { | 114 void UpdateIcon() { |
| 113 int resource_id = match_.starred ? | 115 BookmarkModel* bookmark_model = |
| 116 BookmarkModelFactory::GetForProfile(profile_); |
| 117 bool is_bookmarked = |
| 118 bookmark_model && bookmark_model->IsBookmarked(match_.destination_url); |
| 119 int resource_id = is_bookmarked ? |
| 114 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type); | 120 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match_.type); |
| 115 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 121 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 116 resource_id)); | 122 resource_id)); |
| 117 } | 123 } |
| 118 | 124 |
| 119 void UpdateTitleAndDetails() { | 125 void UpdateTitleAndDetails() { |
| 120 set_title(match_.contents); | 126 set_title(match_.contents); |
| 121 SearchResult::Tags title_tags; | 127 SearchResult::Tags title_tags; |
| 122 ACMatchClassificationsToTags(match_.contents, | 128 ACMatchClassificationsToTags(match_.contents, |
| 123 match_.contents_class, | 129 match_.contents_class, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 new OmniboxResult(profile_, controller_.get(), *it))); | 182 new OmniboxResult(profile_, controller_.get(), *it))); |
| 177 } | 183 } |
| 178 } | 184 } |
| 179 | 185 |
| 180 void OmniboxProvider::OnResultChanged(bool default_match_changed) { | 186 void OmniboxProvider::OnResultChanged(bool default_match_changed) { |
| 181 const AutocompleteResult& result = controller_->result(); | 187 const AutocompleteResult& result = controller_->result(); |
| 182 PopulateFromACResult(result); | 188 PopulateFromACResult(result); |
| 183 } | 189 } |
| 184 | 190 |
| 185 } // namespace app_list | 191 } // namespace app_list |
| OLD | NEW |