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

Side by Side Diff: chrome/browser/history/scored_history_match.cc

Issue 67553002: Omnibox Field Trial: Make HQP Score Bookmarks More Highly (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | Annotate | Revision Log
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 #include "chrome/browser/history/scored_history_match.h" 5 #include "chrome/browser/history/scored_history_match.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <iterator> 9 #include <iterator>
10 #include <numeric> 10 #include <numeric>
11 #include <set> 11 #include <set>
12 12
13 #include <math.h> 13 #include <math.h>
14 14
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/autocomplete/history_url_provider.h" 18 #include "chrome/browser/autocomplete/history_url_provider.h"
19 #include "chrome/browser/autocomplete/url_prefix.h" 19 #include "chrome/browser/autocomplete/url_prefix.h"
20 #include "chrome/browser/bookmarks/bookmark_service.h" 20 #include "chrome/browser/bookmarks/bookmark_service.h"
21 #include "chrome/browser/omnibox/omnibox_field_trial.h"
21 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 24
24 namespace history { 25 namespace history {
25 26
26 // ScoredHistoryMatch ---------------------------------------------------------- 27 // ScoredHistoryMatch ----------------------------------------------------------
27 28
28 bool ScoredHistoryMatch::initialized_ = false; 29 bool ScoredHistoryMatch::initialized_ = false;
30 int ScoredHistoryMatch::bookmark_value = -1;
Peter Kasting 2013/11/09 00:44:55 Maybe this should be 1.
Mark P 2013/11/25 21:11:57 Right you are. Done.
29 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10u; 31 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10u;
30 bool ScoredHistoryMatch::also_do_hup_like_scoring = false; 32 bool ScoredHistoryMatch::also_do_hup_like_scoring = false;
31 int ScoredHistoryMatch::max_assigned_score_for_non_inlineable_matches = -1; 33 int ScoredHistoryMatch::max_assigned_score_for_non_inlineable_matches = -1;
32 34
33 ScoredHistoryMatch::ScoredHistoryMatch() 35 ScoredHistoryMatch::ScoredHistoryMatch()
34 : raw_score(0), 36 : raw_score(0),
35 can_inline(false) { 37 can_inline(false) {
36 if (!initialized_) { 38 if (!initialized_) {
37 InitializeAlsoDoHUPLikeScoringFieldAndMaxScoreField(); 39 InitializeAlsoDoHUPLikeScoringFieldAndMaxScoreField();
40 InitializeBookmarkValue();
38 initialized_ = true; 41 initialized_ = true;
39 } 42 }
40 } 43 }
41 44
42 ScoredHistoryMatch::ScoredHistoryMatch(const URLRow& row, 45 ScoredHistoryMatch::ScoredHistoryMatch(const URLRow& row,
43 const VisitInfoVector& visits, 46 const VisitInfoVector& visits,
44 const std::string& languages, 47 const std::string& languages,
45 const string16& lower_string, 48 const string16& lower_string,
46 const String16Vector& terms, 49 const String16Vector& terms,
47 const RowWordStarts& word_starts, 50 const RowWordStarts& word_starts,
48 const base::Time now, 51 const base::Time now,
49 BookmarkService* bookmark_service) 52 BookmarkService* bookmark_service)
50 : HistoryMatch(row, 0, false, false), 53 : HistoryMatch(row, 0, false, false),
51 raw_score(0), 54 raw_score(0),
52 can_inline(false) { 55 can_inline(false) {
53 if (!initialized_) { 56 if (!initialized_) {
54 InitializeAlsoDoHUPLikeScoringFieldAndMaxScoreField(); 57 InitializeAlsoDoHUPLikeScoringFieldAndMaxScoreField();
58 InitializeBookmarkValue();
55 initialized_ = true; 59 initialized_ = true;
56 } 60 }
57 61
58 GURL gurl = row.url(); 62 GURL gurl = row.url();
59 if (!gurl.is_valid()) 63 if (!gurl.is_valid())
60 return; 64 return;
61 65
62 // Figure out where each search term appears in the URL and/or page title 66 // Figure out where each search term appears in the URL and/or page title
63 // so that we can score as well as provide autocomplete highlighting. 67 // so that we can score as well as provide autocomplete highlighting.
64 string16 url = CleanUpUrlForMatching(gurl, languages); 68 string16 url = CleanUpUrlForMatching(gurl, languages);
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // HUP-like-scoring, these results would actually come from the HUP 527 // HUP-like-scoring, these results would actually come from the HUP
524 // and not be demoted, thus outscoring the demoted HQP results. 528 // and not be demoted, thus outscoring the demoted HQP results.
525 // When the HQP provides these, we need to clamp the non-inlineable 529 // When the HQP provides these, we need to clamp the non-inlineable
526 // results to preserve this behavior. 530 // results to preserve this behavior.
527 if (also_do_hup_like_scoring) { 531 if (also_do_hup_like_scoring) {
528 max_assigned_score_for_non_inlineable_matches = 532 max_assigned_score_for_non_inlineable_matches =
529 HistoryURLProvider::kScoreForBestInlineableResult - 1; 533 HistoryURLProvider::kScoreForBestInlineableResult - 1;
530 } 534 }
531 } 535 }
532 536
537 void ScoredHistoryMatch::InitializeBookmarkValue() {
538 bookmark_value = OmniboxFieldTrial::HQPBookmarkValue();
539 }
540
533 } // namespace history 541 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698