Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: chrome/browser/autocomplete/history_provider.cc

Issue 8384024: HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 }
37 39
38 // Delete the match from the current set of matches. 40 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) {
39 bool found = false; 41 bool found = false;
40 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { 42 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
41 if (i->destination_url == match.destination_url && i->type == match.type) { 43 if (i->destination_url == match.destination_url && i->type == match.type) {
42 found = true; 44 found = true;
43 if (i->is_history_what_you_typed_match || i->starred) { 45 if (i->is_history_what_you_typed_match || i->starred) {
44 // We can't get rid of What-You-Typed or Bookmarked matches, 46 // We can't get rid of What-You-Typed or Bookmarked matches,
45 // but we can make them look like they have no backing data. 47 // but we can make them look like they have no backing data.
46 i->deletable = false; 48 i->deletable = false;
47 i->description.clear(); 49 i->description.clear();
48 i->description_class.clear(); 50 i->description_class.clear();
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return (scheme_pos == 0) ? prefix_end : 0; 151 return (scheme_pos == 0) ? prefix_end : 0;
150 } 152 }
151 153
152 // static 154 // static
153 bool HistoryProvider::PreventInlineAutocomplete( 155 bool HistoryProvider::PreventInlineAutocomplete(
154 const AutocompleteInput& input) { 156 const AutocompleteInput& input) {
155 return input.prevent_inline_autocomplete() || 157 return input.prevent_inline_autocomplete() ||
156 (!input.text().empty() && 158 (!input.text().empty() &&
157 IsWhitespace(input.text()[input.text().length() - 1])); 159 IsWhitespace(input.text()[input.text().length() - 1]));
158 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_provider.h ('k') | chrome/browser/autocomplete/history_quick_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698