OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 16 matching lines...) Expand all Loading... |
27 DCHECK(profile_); | 27 DCHECK(profile_); |
28 DCHECK(match.deletable); | 28 DCHECK(match.deletable); |
29 | 29 |
30 HistoryService* const history_service = | 30 HistoryService* const history_service = |
31 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); | 31 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); |
32 | 32 |
33 // Delete the match from the history DB. | 33 // Delete the match from the history DB. |
34 DCHECK(history_service); | 34 DCHECK(history_service); |
35 DCHECK(match.destination_url.is_valid()); | 35 DCHECK(match.destination_url.is_valid()); |
36 history_service->DeleteURL(match.destination_url); | 36 history_service->DeleteURL(match.destination_url); |
37 DeleteMatchFromMatches(match); | |
38 } | |
39 | 37 |
40 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { | 38 // Delete the match from the current set of matches. |
41 bool found = false; | 39 bool found = false; |
42 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 40 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
43 if (i->destination_url == match.destination_url && i->type == match.type) { | 41 if (i->destination_url == match.destination_url && i->type == match.type) { |
44 found = true; | 42 found = true; |
45 if (i->is_history_what_you_typed_match || i->starred) { | 43 if (i->is_history_what_you_typed_match || i->starred) { |
46 // We can't get rid of What-You-Typed or Bookmarked matches, | 44 // We can't get rid of What-You-Typed or Bookmarked matches, |
47 // but we can make them look like they have no backing data. | 45 // but we can make them look like they have no backing data. |
48 i->deletable = false; | 46 i->deletable = false; |
49 i->description.clear(); | 47 i->description.clear(); |
50 i->description_class.clear(); | 48 i->description_class.clear(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 return (scheme_pos == 0) ? prefix_end : 0; | 149 return (scheme_pos == 0) ? prefix_end : 0; |
152 } | 150 } |
153 | 151 |
154 // static | 152 // static |
155 bool HistoryProvider::PreventInlineAutocomplete( | 153 bool HistoryProvider::PreventInlineAutocomplete( |
156 const AutocompleteInput& input) { | 154 const AutocompleteInput& input) { |
157 return input.prevent_inline_autocomplete() || | 155 return input.prevent_inline_autocomplete() || |
158 (!input.text().empty() && | 156 (!input.text().empty() && |
159 IsWhitespace(input.text()[input.text().length() - 1])); | 157 IsWhitespace(input.text()[input.text().length() - 1])); |
160 } | 158 } |
OLD | NEW |