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

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

Issue 8120004: HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months 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 13 matching lines...) Expand all
24 24
25 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { 25 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) {
26 DCHECK(done_); 26 DCHECK(done_);
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 GURL selected_url(match.destination_url); 34 DCHECK(history_service && match.destination_url.is_valid());
Peter Kasting 2011/10/05 00:11:42 Nit: I'd use two DCHECKs.
mrossetti 2011/10/07 17:04:14 Done.
35 if (!history_service || !selected_url.is_valid()) { 35 history_service->DeleteURL(match.destination_url);
36 NOTREACHED() << "Can't delete requested URL"; 36 DeleteMatchFromMatches(match);
37 return; 37 }
38 }
39 history_service->DeleteURL(selected_url);
40 38
41 // Delete the match from the current set of matches. 39 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) {
42 bool found = false; 40 bool found = false;
43 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { 41 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
44 if (i->destination_url == selected_url && i->type == match.type) { 42 if (i->destination_url == match.destination_url && i->type == match.type) {
45 found = true; 43 found = true;
46 if (i->is_history_what_you_typed_match || i->starred) { 44 if (i->is_history_what_you_typed_match || i->starred) {
47 // We can't get rid of What-You-Typed or Bookmarked matches, 45 // We can't get rid of What-You-Typed or Bookmarked matches,
48 // but we can make them look like they have no backing data. 46 // but we can make them look like they have no backing data.
49 i->deletable = false; 47 i->deletable = false;
50 i->description.clear(); 48 i->description.clear();
51 i->description_class.clear(); 49 i->description_class.clear();
52 } else { 50 } else {
53 matches_.erase(i); 51 matches_.erase(i);
54 } 52 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return (scheme_pos == 0) ? prefix_end : 0; 150 return (scheme_pos == 0) ? prefix_end : 0;
153 } 151 }
154 152
155 // static 153 // static
156 bool HistoryProvider::PreventInlineAutocomplete( 154 bool HistoryProvider::PreventInlineAutocomplete(
157 const AutocompleteInput& input) { 155 const AutocompleteInput& input) {
158 return input.prevent_inline_autocomplete() || 156 return input.prevent_inline_autocomplete() ||
159 (!input.text().empty() && 157 (!input.text().empty() &&
160 IsWhitespace(input.text()[input.text().length() - 1])); 158 IsWhitespace(input.text()[input.text().length() - 1]));
161 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698