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

Side by Side Diff: athena/main/url_search_provider.cc

Issue 559973002: Add what-you-typed-match as a result when the input type is URL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "athena/main/url_search_provider.h" 5 #include "athena/main/url_search_provider.h"
6 6
7 #include "athena/activity/public/activity_factory.h" 7 #include "athena/activity/public/activity_factory.h"
8 #include "athena/activity/public/activity_manager.h" 8 #include "athena/activity/public/activity_manager.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "components/metrics/proto/omnibox_event.pb.h" 11 #include "components/metrics/proto/omnibox_event.pb.h"
12 #include "components/metrics/proto/omnibox_input_type.pb.h" 12 #include "components/metrics/proto/omnibox_input_type.pb.h"
13 #include "components/omnibox/autocomplete_input.h" 13 #include "components/omnibox/autocomplete_input.h"
14 #include "components/omnibox/autocomplete_provider_client.h" 14 #include "components/omnibox/autocomplete_provider_client.h"
15 #include "components/omnibox/autocomplete_scheme_classifier.h" 15 #include "components/omnibox/autocomplete_scheme_classifier.h"
16 #include "components/omnibox/search_provider.h" 16 #include "components/omnibox/search_provider.h"
17 #include "components/search_engines/search_terms_data.h" 17 #include "components/search_engines/search_terms_data.h"
18 #include "components/search_engines/template_url_service.h" 18 #include "components/search_engines/template_url_service.h"
19 #include "components/search_engines/template_url_service_client.h" 19 #include "components/search_engines/template_url_service_client.h"
20 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
21 #include "ui/app_list/search_result.h" 21 #include "ui/app_list/search_result.h"
22 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24
25 namespace athena { 25 namespace athena {
26 26
27 namespace { 27 namespace {
28 28
29 const int kScoreForWhatYouTypedResult = 1203;
Jun Mukai 2014/09/10 17:13:32 how it's determined? If you copy this value from
hashimoto 2014/09/11 02:37:14 This constant was copied from HistoryURLProvider.
30
29 // The SearchTermsData implementation for Athena. 31 // The SearchTermsData implementation for Athena.
30 class AthenaSearchTermsData : public SearchTermsData { 32 class AthenaSearchTermsData : public SearchTermsData {
31 public: 33 public:
32 // SearchTermsData: 34 // SearchTermsData:
33 virtual std::string GetSuggestClient() const OVERRIDE { 35 virtual std::string GetSuggestClient() const OVERRIDE {
34 return "chrome"; 36 return "chrome";
35 } 37 }
36 }; 38 };
37 39
38 // The AutocompleteSchemeClassifier implementation for Athena. 40 // The AutocompleteSchemeClassifier implementation for Athena.
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void UrlSearchProvider::Stop() { 261 void UrlSearchProvider::Stop() {
260 provider_->Stop(false); 262 provider_->Stop(false);
261 } 263 }
262 264
263 void UrlSearchProvider::OnProviderUpdate(bool updated_matches) { 265 void UrlSearchProvider::OnProviderUpdate(bool updated_matches) {
264 if (!updated_matches) 266 if (!updated_matches)
265 return; 267 return;
266 268
267 ClearResults(); 269 ClearResults();
268 270
271 if (input_.type() == metrics::OmniboxInputType::URL) {
272 // TODO(hashimoto): Componentize HistoryURLProvider and remove this code.
273 AutocompleteMatch what_you_typed_match(
274 NULL, 0, false, AutocompleteMatchType::URL_WHAT_YOU_TYPED);
275 what_you_typed_match.destination_url = input_.canonicalized_url();
276 what_you_typed_match.contents = input_.text();
277 what_you_typed_match.relevance = kScoreForWhatYouTypedResult;
278 Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult(
279 browser_context_, what_you_typed_match)));
280 }
281
269 const ACMatches& matches = provider_->matches(); 282 const ACMatches& matches = provider_->matches();
270 for (ACMatches::const_iterator it = matches.begin(); it != matches.end(); 283 for (ACMatches::const_iterator it = matches.begin(); it != matches.end();
271 ++it) { 284 ++it) {
272 if (!it->destination_url.is_valid()) 285 if (!it->destination_url.is_valid())
273 continue; 286 continue;
274 287
275 Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult( 288 Add(scoped_ptr<app_list::SearchResult>(new UrlSearchResult(
276 browser_context_, *it))); 289 browser_context_, *it)));
277 } 290 }
278 } 291 }
279 292
280 } // namespace athena 293 } // namespace athena
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698