OLD | NEW |
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/autocomplete/history_provider.h" | 5 #include "chrome/browser/autocomplete/history_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
12 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | |
13 #include "chrome/browser/history/history_service.h" | 12 #include "chrome/browser/history/history_service.h" |
14 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
15 #include "chrome/browser/history/in_memory_url_index_types.h" | 14 #include "chrome/browser/history/in_memory_url_index_types.h" |
16 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
18 #include "components/autocomplete/autocomplete_input.h" | 17 #include "components/autocomplete/autocomplete_input.h" |
19 #include "url/url_util.h" | 18 #include "url/url_util.h" |
20 | 19 |
21 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { | 20 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { |
22 DCHECK(done_); | 21 DCHECK(done_); |
(...skipping 14 matching lines...) Expand all Loading... |
37 } | 36 } |
38 | 37 |
39 // static | 38 // static |
40 bool HistoryProvider::PreventInlineAutocomplete( | 39 bool HistoryProvider::PreventInlineAutocomplete( |
41 const AutocompleteInput& input) { | 40 const AutocompleteInput& input) { |
42 return input.prevent_inline_autocomplete() || | 41 return input.prevent_inline_autocomplete() || |
43 (!input.text().empty() && | 42 (!input.text().empty() && |
44 IsWhitespace(input.text()[input.text().length() - 1])); | 43 IsWhitespace(input.text()[input.text().length() - 1])); |
45 } | 44 } |
46 | 45 |
47 HistoryProvider::HistoryProvider(AutocompleteProviderListener* listener, | 46 HistoryProvider::HistoryProvider(Profile* profile, |
48 Profile* profile, | |
49 AutocompleteProvider::Type type) | 47 AutocompleteProvider::Type type) |
50 : AutocompleteProvider(listener, type), | 48 : AutocompleteProvider(type), |
51 profile_(profile) { | 49 profile_(profile) { |
52 } | 50 } |
53 | 51 |
54 HistoryProvider::~HistoryProvider() {} | 52 HistoryProvider::~HistoryProvider() {} |
55 | 53 |
56 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { | 54 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { |
57 bool found = false; | 55 bool found = false; |
58 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 56 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
59 if (i->destination_url == match.destination_url && i->type == match.type) { | 57 if (i->destination_url == match.destination_url && i->type == match.type) { |
60 found = true; | 58 found = true; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 do { | 95 do { |
98 offset += matches[i].length; | 96 offset += matches[i].length; |
99 ++i; | 97 ++i; |
100 } while ((i < match_count) && (offset == matches[i].offset)); | 98 } while ((i < match_count) && (offset == matches[i].offset)); |
101 if (offset < text_length) | 99 if (offset < text_length) |
102 spans.push_back(ACMatchClassification(offset, url_style)); | 100 spans.push_back(ACMatchClassification(offset, url_style)); |
103 } | 101 } |
104 | 102 |
105 return spans; | 103 return spans; |
106 } | 104 } |
OLD | NEW |