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 } | |
43 | 41 |
44 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { | 42 // Delete the match from the current set of matches. |
45 bool found = false; | 43 bool found = false; |
46 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 44 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
47 if (i->destination_url == match.destination_url && i->type == match.type) { | 45 if (i->destination_url == match.destination_url && i->type == match.type) { |
48 found = true; | 46 found = true; |
49 if (i->is_history_what_you_typed_match || i->starred) { | 47 if (i->is_history_what_you_typed_match || i->starred) { |
50 // We can't get rid of What-You-Typed or Bookmarked matches, | 48 // We can't get rid of What-You-Typed or Bookmarked matches, |
51 // but we can make them look like they have no backing data. | 49 // but we can make them look like they have no backing data. |
52 i->deletable = false; | 50 i->deletable = false; |
53 i->description.clear(); | 51 i->description.clear(); |
54 i->description_class.clear(); | 52 i->description_class.clear(); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 154 } |
157 | 155 |
158 // static | 156 // static |
159 bool HistoryProvider::PreventInlineAutocomplete( | 157 bool HistoryProvider::PreventInlineAutocomplete( |
160 const AutocompleteInput& input) { | 158 const AutocompleteInput& input) { |
161 return input.prevent_inline_autocomplete() || | 159 return input.prevent_inline_autocomplete() || |
162 always_prevent_inline_autocomplete_ || | 160 always_prevent_inline_autocomplete_ || |
163 (!input.text().empty() && | 161 (!input.text().empty() && |
164 IsWhitespace(input.text()[input.text().length() - 1])); | 162 IsWhitespace(input.text()[input.text().length() - 1])); |
165 } | 163 } |
OLD | NEW |