OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 10 matching lines...) Expand all Loading... |
21 const char* name) | 21 const char* name) |
22 : AutocompleteProvider(listener, profile, name) { | 22 : AutocompleteProvider(listener, profile, name) { |
23 } | 23 } |
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 GURL selected_url(match.destination_url); |
35 if (!history_service || !selected_url.is_valid()) { | 35 if (!history_service || !selected_url.is_valid()) { |
36 NOTREACHED() << "Can't delete requested URL"; | 36 NOTREACHED() << "Can't delete requested URL"; |
37 return; | 37 return; |
38 } | 38 } |
39 history_service->DeleteURL(selected_url); | 39 history_service->DeleteURL(selected_url); |
40 | 40 |
41 // Delete the match from the current set of matches. | 41 // Delete the match from the current set of matches. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 DCHECK(scheme_pos != std::wstring::npos); | 135 DCHECK(scheme_pos != std::wstring::npos); |
136 | 136 |
137 // Erase scheme plus up to two slashes. | 137 // Erase scheme plus up to two slashes. |
138 size_t prefix_end = scheme_pos + strlen(chrome::kHttpScheme) + 1; | 138 size_t prefix_end = scheme_pos + strlen(chrome::kHttpScheme) + 1; |
139 const size_t after_slashes = std::min(url->length(), prefix_end + 2); | 139 const size_t after_slashes = std::min(url->length(), prefix_end + 2); |
140 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == L'/')) | 140 while ((prefix_end < after_slashes) && ((*url)[prefix_end] == L'/')) |
141 ++prefix_end; | 141 ++prefix_end; |
142 url->erase(scheme_pos, prefix_end - scheme_pos); | 142 url->erase(scheme_pos, prefix_end - scheme_pos); |
143 return (scheme_pos == 0) ? prefix_end : 0; | 143 return (scheme_pos == 0) ? prefix_end : 0; |
144 } | 144 } |
OLD | NEW |