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

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

Issue 184663002: Omnibox: Make URLs of Bookmarks Searchable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | 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/bookmarks/bookmark_utils.h"
21 #include "chrome/browser/omnibox/omnibox_field_trial.h" 22 #include "chrome/browser/omnibox/omnibox_field_trial.h"
22 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 25
25 namespace history { 26 namespace history {
26 27
27 // ScoredHistoryMatch ---------------------------------------------------------- 28 // ScoredHistoryMatch ----------------------------------------------------------
28 29
29 // static 30 // static
30 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10; 31 const size_t ScoredHistoryMatch::kMaxVisitsToScore = 10;
(...skipping 27 matching lines...) Expand all
58 raw_score_(0), 59 raw_score_(0),
59 can_inline_(false) { 60 can_inline_(false) {
60 Init(); 61 Init();
61 62
62 GURL gurl = row.url(); 63 GURL gurl = row.url();
63 if (!gurl.is_valid()) 64 if (!gurl.is_valid())
64 return; 65 return;
65 66
66 // Figure out where each search term appears in the URL and/or page title 67 // Figure out where each search term appears in the URL and/or page title
67 // so that we can score as well as provide autocomplete highlighting. 68 // so that we can score as well as provide autocomplete highlighting.
68 base::string16 url = CleanUpUrlForMatching(gurl, languages); 69 base::string16 url = bookmark_utils::CleanUpUrlForMatching(gurl, languages);
69 base::string16 title = CleanUpTitleForMatching(row.title()); 70 base::string16 title = bookmark_utils::CleanUpTitleForMatching(row.title());
70 int term_num = 0; 71 int term_num = 0;
71 for (String16Vector::const_iterator iter = terms.begin(); iter != terms.end(); 72 for (String16Vector::const_iterator iter = terms.begin(); iter != terms.end();
72 ++iter, ++term_num) { 73 ++iter, ++term_num) {
73 base::string16 term = *iter; 74 base::string16 term = *iter;
74 TermMatches url_term_matches = MatchTermInString(term, url, term_num); 75 TermMatches url_term_matches = MatchTermInString(term, url, term_num);
75 TermMatches title_term_matches = MatchTermInString(term, title, term_num); 76 TermMatches title_term_matches = MatchTermInString(term, title, term_num);
76 if (url_term_matches.empty() && title_term_matches.empty()) 77 if (url_term_matches.empty() && title_term_matches.empty())
77 return; // A term was not found in either URL or title - reject. 78 return; // A term was not found in either URL or title - reject.
78 url_matches_.insert(url_matches_.end(), url_term_matches.begin(), 79 url_matches_.insert(url_matches_.end(), url_term_matches.begin(),
79 url_term_matches.end()); 80 url_term_matches.end());
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 587 }
587 bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue(); 588 bookmark_value_ = OmniboxFieldTrial::HQPBookmarkValue();
588 discount_frecency_when_few_visits_ = 589 discount_frecency_when_few_visits_ =
589 OmniboxFieldTrial::HQPDiscountFrecencyWhenFewVisits(); 590 OmniboxFieldTrial::HQPDiscountFrecencyWhenFewVisits();
590 allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue(); 591 allow_tld_matches_ = OmniboxFieldTrial::HQPAllowMatchInTLDValue();
591 allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue(); 592 allow_scheme_matches_ = OmniboxFieldTrial::HQPAllowMatchInSchemeValue();
592 initialized_ = true; 593 initialized_ = true;
593 } 594 }
594 595
595 } // namespace history 596 } // namespace history
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698