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/autocomplete_match.h" | 5 #include "chrome/browser/autocomplete/autocomplete_match.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
12 #include "chrome/browser/search_engines/template_url_service.h" | 12 #include "chrome/browser/search_engines/template_url_service.h" |
13 #include "chrome/browser/search_engines/template_url_service_factory.h" | 13 #include "chrome/browser/search_engines/template_url_service_factory.h" |
14 #include "grit/theme_resources.h" | 14 #include "grit/theme_resources.h" |
15 | 15 |
16 // AutocompleteMatch ---------------------------------------------------------- | 16 // AutocompleteMatch ---------------------------------------------------------- |
17 | 17 |
18 // static | 18 // static |
19 const char16 AutocompleteMatch::kInvalidChars[] = { | 19 const char16 AutocompleteMatch::kInvalidChars[] = { |
20 '\n', '\r', '\t', | 20 '\n', '\r', '\t', |
21 0x2028, // Line separator | 21 0x2028, // Line separator |
22 0x2029, // Paragraph separator | 22 0x2029, // Paragraph separator |
23 0 | 23 0 |
24 }; | 24 }; |
25 | 25 |
26 AutocompleteMatch::AutocompleteMatch() | 26 AutocompleteMatch::AutocompleteMatch() |
27 : provider(NULL), | 27 : provider(NULL), |
28 relevance(0), | 28 relevance(0), |
| 29 typed_count(-1), |
29 deletable(false), | 30 deletable(false), |
30 inline_autocomplete_offset(string16::npos), | 31 inline_autocomplete_offset(string16::npos), |
31 transition(content::PAGE_TRANSITION_GENERATED), | 32 transition(content::PAGE_TRANSITION_GENERATED), |
32 is_history_what_you_typed_match(false), | 33 is_history_what_you_typed_match(false), |
33 type(SEARCH_WHAT_YOU_TYPED), | 34 type(SEARCH_WHAT_YOU_TYPED), |
34 starred(false), | 35 starred(false), |
35 from_previous(false) { | 36 from_previous(false) { |
36 } | 37 } |
37 | 38 |
38 AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider, | 39 AutocompleteMatch::AutocompleteMatch(AutocompleteProvider* provider, |
39 int relevance, | 40 int relevance, |
40 bool deletable, | 41 bool deletable, |
41 Type type) | 42 Type type) |
42 : provider(provider), | 43 : provider(provider), |
43 relevance(relevance), | 44 relevance(relevance), |
| 45 typed_count(-1), |
44 deletable(deletable), | 46 deletable(deletable), |
45 inline_autocomplete_offset(string16::npos), | 47 inline_autocomplete_offset(string16::npos), |
46 transition(content::PAGE_TRANSITION_TYPED), | 48 transition(content::PAGE_TRANSITION_TYPED), |
47 is_history_what_you_typed_match(false), | 49 is_history_what_you_typed_match(false), |
48 type(type), | 50 type(type), |
49 starred(false), | 51 starred(false), |
50 from_previous(false) { | 52 from_previous(false) { |
51 } | 53 } |
52 | 54 |
53 AutocompleteMatch::AutocompleteMatch(const AutocompleteMatch& match) | 55 AutocompleteMatch::AutocompleteMatch(const AutocompleteMatch& match) |
54 : provider(match.provider), | 56 : provider(match.provider), |
55 relevance(match.relevance), | 57 relevance(match.relevance), |
| 58 typed_count(match.typed_count), |
56 deletable(match.deletable), | 59 deletable(match.deletable), |
57 fill_into_edit(match.fill_into_edit), | 60 fill_into_edit(match.fill_into_edit), |
58 inline_autocomplete_offset(match.inline_autocomplete_offset), | 61 inline_autocomplete_offset(match.inline_autocomplete_offset), |
59 destination_url(match.destination_url), | 62 destination_url(match.destination_url), |
60 stripped_destination_url(match.stripped_destination_url), | 63 stripped_destination_url(match.stripped_destination_url), |
61 contents(match.contents), | 64 contents(match.contents), |
62 contents_class(match.contents_class), | 65 contents_class(match.contents_class), |
63 description(match.description), | 66 description(match.description), |
64 description_class(match.description_class), | 67 description_class(match.description_class), |
65 transition(match.transition), | 68 transition(match.transition), |
66 is_history_what_you_typed_match(match.is_history_what_you_typed_match), | 69 is_history_what_you_typed_match(match.is_history_what_you_typed_match), |
67 type(match.type), | 70 type(match.type), |
68 keyword(match.keyword), | 71 keyword(match.keyword), |
69 starred(match.starred), | 72 starred(match.starred), |
70 from_previous(match.from_previous) { | 73 from_previous(match.from_previous) { |
71 if (match.associated_keyword.get()) | 74 if (match.associated_keyword.get()) |
72 associated_keyword.reset(new AutocompleteMatch(*match.associated_keyword)); | 75 associated_keyword.reset(new AutocompleteMatch(*match.associated_keyword)); |
73 } | 76 } |
74 | 77 |
75 AutocompleteMatch::~AutocompleteMatch() { | 78 AutocompleteMatch::~AutocompleteMatch() { |
76 } | 79 } |
77 | 80 |
78 AutocompleteMatch& AutocompleteMatch::operator=( | 81 AutocompleteMatch& AutocompleteMatch::operator=( |
79 const AutocompleteMatch& match) { | 82 const AutocompleteMatch& match) { |
80 if (this == &match) | 83 if (this == &match) |
81 return *this; | 84 return *this; |
82 | 85 |
83 provider = match.provider; | 86 provider = match.provider; |
84 relevance = match.relevance; | 87 relevance = match.relevance; |
| 88 typed_count = match.typed_count; |
85 deletable = match.deletable; | 89 deletable = match.deletable; |
86 fill_into_edit = match.fill_into_edit; | 90 fill_into_edit = match.fill_into_edit; |
87 inline_autocomplete_offset = match.inline_autocomplete_offset; | 91 inline_autocomplete_offset = match.inline_autocomplete_offset; |
88 destination_url = match.destination_url; | 92 destination_url = match.destination_url; |
89 stripped_destination_url = match.stripped_destination_url; | 93 stripped_destination_url = match.stripped_destination_url; |
90 contents = match.contents; | 94 contents = match.contents; |
91 contents_class = match.contents_class; | 95 contents_class = match.contents_class; |
92 description = match.description; | 96 description = match.description; |
93 description_class = match.description_class; | 97 description_class = match.description_class; |
94 transition = match.transition; | 98 transition = match.transition; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 << " is unsorted in relation to last offset of " << last_offset | 345 << " is unsorted in relation to last offset of " << last_offset |
342 << ". Provider: " << (provider ? provider->name() : "None") << "."; | 346 << ". Provider: " << (provider ? provider->name() : "None") << "."; |
343 DCHECK_LT(i->offset, text.length()) | 347 DCHECK_LT(i->offset, text.length()) |
344 << " Classification of [" << i->offset << "," << text.length() | 348 << " Classification of [" << i->offset << "," << text.length() |
345 << "] is out of bounds for \"" << text << "\". Provider: " | 349 << "] is out of bounds for \"" << text << "\". Provider: " |
346 << (provider ? provider->name() : "None") << "."; | 350 << (provider ? provider->name() : "None") << "."; |
347 last_offset = i->offset; | 351 last_offset = i->offset; |
348 } | 352 } |
349 } | 353 } |
350 #endif | 354 #endif |
OLD | NEW |