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

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

Issue 8291005: HQP Refactoring (in Preparation for SQLite Cache) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Rattle those Bots Senseless 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);
35 if (!history_service || !selected_url.is_valid()) { 35 DCHECK(match.destination_url.is_valid());
36 NOTREACHED() << "Can't delete requested URL"; 36 history_service->DeleteURL(match.destination_url);
37 return; 37 DeleteMatchFromMatches(match);
38 } 38 }
39 history_service->DeleteURL(selected_url);
40 39
41 // Delete the match from the current set of matches. 40 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) {
42 bool found = false; 41 bool found = false;
43 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { 42 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
44 if (i->destination_url == selected_url && i->type == match.type) { 43 if (i->destination_url == match.destination_url && i->type == match.type) {
45 found = true; 44 found = true;
46 if (i->is_history_what_you_typed_match || i->starred) { 45 if (i->is_history_what_you_typed_match || i->starred) {
47 // 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,
48 // 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.
49 i->deletable = false; 48 i->deletable = false;
50 i->description.clear(); 49 i->description.clear();
51 i->description_class.clear(); 50 i->description_class.clear();
52 } else { 51 } else {
53 matches_.erase(i); 52 matches_.erase(i);
54 } 53 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 return (scheme_pos == 0) ? prefix_end : 0; 151 return (scheme_pos == 0) ? prefix_end : 0;
153 } 152 }
154 153
155 // static 154 // static
156 bool HistoryProvider::PreventInlineAutocomplete( 155 bool HistoryProvider::PreventInlineAutocomplete(
157 const AutocompleteInput& input) { 156 const AutocompleteInput& input) {
158 return input.prevent_inline_autocomplete() || 157 return input.prevent_inline_autocomplete() ||
159 (!input.text().empty() && 158 (!input.text().empty() &&
160 IsWhitespace(input.text()[input.text().length() - 1])); 159 IsWhitespace(input.text()[input.text().length() - 1]));
161 } 160 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_provider.h ('k') | chrome/browser/autocomplete/history_quick_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698