| 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/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 set_id(match_.destination_url.spec()); | 84 set_id(match_.destination_url.spec()); |
| 85 | 85 |
| 86 // Derive relevance from omnibox relevance and normalize it to [0, 1]. | 86 // Derive relevance from omnibox relevance and normalize it to [0, 1]. |
| 87 // The magic number 1500 is the highest score of an omnibox result. | 87 // The magic number 1500 is the highest score of an omnibox result. |
| 88 // See comments in autocomplete_provider.h. | 88 // See comments in autocomplete_provider.h. |
| 89 set_relevance(match_.relevance / 1500.0); | 89 set_relevance(match_.relevance / 1500.0); |
| 90 | 90 |
| 91 UpdateIcon(); | 91 UpdateIcon(); |
| 92 UpdateTitleAndDetails(); | 92 UpdateTitleAndDetails(); |
| 93 } | 93 } |
| 94 virtual ~OmniboxResult() {} | 94 ~OmniboxResult() override {} |
| 95 | 95 |
| 96 // SearchResult overrides: | 96 // SearchResult overrides: |
| 97 virtual void Open(int event_flags) override { | 97 void Open(int event_flags) override { |
| 98 RecordHistogram(OMNIBOX_SEARCH_RESULT); | 98 RecordHistogram(OMNIBOX_SEARCH_RESULT); |
| 99 list_controller_->OpenURL(profile_, | 99 list_controller_->OpenURL(profile_, |
| 100 match_.destination_url, | 100 match_.destination_url, |
| 101 match_.transition, | 101 match_.transition, |
| 102 ui::DispositionFromEventFlags(event_flags)); | 102 ui::DispositionFromEventFlags(event_flags)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual scoped_ptr<SearchResult> Duplicate() override { | 105 scoped_ptr<SearchResult> Duplicate() override { |
| 106 return scoped_ptr<SearchResult>(new OmniboxResult( | 106 return scoped_ptr<SearchResult>(new OmniboxResult( |
| 107 profile_, list_controller_, autocomplete_controller_, match_)); | 107 profile_, list_controller_, autocomplete_controller_, match_)); |
| 108 } | 108 } |
| 109 | 109 |
| 110 private: | 110 private: |
| 111 void UpdateIcon() { | 111 void UpdateIcon() { |
| 112 BookmarkModel* bookmark_model = | 112 BookmarkModel* bookmark_model = |
| 113 BookmarkModelFactory::GetForProfile(profile_); | 113 BookmarkModelFactory::GetForProfile(profile_); |
| 114 bool is_bookmarked = | 114 bool is_bookmarked = |
| 115 bookmark_model && bookmark_model->IsBookmarked(match_.destination_url); | 115 bookmark_model && bookmark_model->IsBookmarked(match_.destination_url); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 new OmniboxResult(profile_, list_controller_, controller_.get(), *it))); | 182 new OmniboxResult(profile_, list_controller_, controller_.get(), *it))); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | 185 |
| 186 void OmniboxProvider::OnResultChanged(bool default_match_changed) { | 186 void OmniboxProvider::OnResultChanged(bool default_match_changed) { |
| 187 const AutocompleteResult& result = controller_->result(); | 187 const AutocompleteResult& result = controller_->result(); |
| 188 PopulateFromACResult(result); | 188 PopulateFromACResult(result); |
| 189 } | 189 } |
| 190 | 190 |
| 191 } // namespace app_list | 191 } // namespace app_list |
| OLD | NEW |