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_url_provider.h" | 5 #include "chrome/browser/autocomplete/history_url_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 DCHECK(profile_); | 31 DCHECK(profile_); |
32 DCHECK(match.deletable); | 32 DCHECK(match.deletable); |
33 | 33 |
34 HistoryService* const history_service = | 34 HistoryService* const history_service = |
35 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 35 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
36 | 36 |
37 // Delete the match from the history DB. | 37 // Delete the match from the history DB. |
38 DCHECK(history_service); | 38 DCHECK(history_service); |
39 DCHECK(match.destination_url.is_valid()); | 39 DCHECK(match.destination_url.is_valid()); |
40 history_service->DeleteURL(match.destination_url); | 40 history_service->DeleteURL(match.destination_url); |
| 41 DeleteMatchFromMatches(match); |
| 42 } |
41 | 43 |
42 // Delete the match from the current set of matches. | 44 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { |
43 bool found = false; | 45 bool found = false; |
44 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 46 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
45 if (i->destination_url == match.destination_url && i->type == match.type) { | 47 if (i->destination_url == match.destination_url && i->type == match.type) { |
46 found = true; | 48 found = true; |
47 if (i->is_history_what_you_typed_match || i->starred) { | 49 if (i->is_history_what_you_typed_match || i->starred) { |
48 // We can't get rid of What-You-Typed or Bookmarked matches, | 50 // We can't get rid of What-You-Typed or Bookmarked matches, |
49 // but we can make them look like they have no backing data. | 51 // but we can make them look like they have no backing data. |
50 i->deletable = false; | 52 i->deletable = false; |
51 i->description.clear(); | 53 i->description.clear(); |
52 i->description_class.clear(); | 54 i->description_class.clear(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 } | 156 } |
155 | 157 |
156 // static | 158 // static |
157 bool HistoryProvider::PreventInlineAutocomplete( | 159 bool HistoryProvider::PreventInlineAutocomplete( |
158 const AutocompleteInput& input) { | 160 const AutocompleteInput& input) { |
159 return input.prevent_inline_autocomplete() || | 161 return input.prevent_inline_autocomplete() || |
160 always_prevent_inline_autocomplete_ || | 162 always_prevent_inline_autocomplete_ || |
161 (!input.text().empty() && | 163 (!input.text().empty() && |
162 IsWhitespace(input.text()[input.text().length() - 1])); | 164 IsWhitespace(input.text()[input.text().length() - 1])); |
163 } | 165 } |
OLD | NEW |