| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_provider.h" | 5 #include "chrome/browser/autocomplete/history_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/autocomplete/autocomplete_input.h" | 11 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_match.h" | 12 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 14 #include "chrome/browser/history/history_service.h" | 14 #include "chrome/browser/history/history_service.h" |
| 15 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 16 #include "chrome/browser/history/in_memory_url_index_types.h" | 16 #include "chrome/browser/history/in_memory_url_index_types.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 19 #include "url/url_util.h" | 19 #include "url/url_util.h" |
| 20 | 20 |
| 21 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { | 21 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { |
| 22 DCHECK(done_); | 22 DCHECK(done_); |
| 23 DCHECK(profile_); | 23 DCHECK(profile_); |
| 24 DCHECK(match.deletable); | 24 DCHECK(match.deletable); |
| 25 | 25 |
| 26 HistoryService* const history_service = | 26 HistoryService* const history_service = |
| 27 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 27 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 28 | 28 |
| 29 // Delete the match from the history DB. | 29 // Delete the underlying URL along with all its visits from the history DB. |
| 30 // The resulting HISTORY_URLS_DELETED notification will also cause all caches |
| 31 // and indices to drop any data they might have stored pertaining to the URL. |
| 30 DCHECK(history_service); | 32 DCHECK(history_service); |
| 31 DCHECK(match.destination_url.is_valid()); | 33 DCHECK(match.destination_url.is_valid()); |
| 32 history_service->DeleteURL(match.destination_url); | 34 history_service->DeleteURL(match.destination_url); |
| 35 |
| 33 DeleteMatchFromMatches(match); | 36 DeleteMatchFromMatches(match); |
| 34 } | 37 } |
| 35 | 38 |
| 36 // static | 39 // static |
| 37 bool HistoryProvider::PreventInlineAutocomplete( | 40 bool HistoryProvider::PreventInlineAutocomplete( |
| 38 const AutocompleteInput& input) { | 41 const AutocompleteInput& input) { |
| 39 return input.prevent_inline_autocomplete() || | 42 return input.prevent_inline_autocomplete() || |
| 40 (!input.text().empty() && | 43 (!input.text().empty() && |
| 41 IsWhitespace(input.text()[input.text().length() - 1])); | 44 IsWhitespace(input.text()[input.text().length() - 1])); |
| 42 } | 45 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 do { | 96 do { |
| 94 offset += matches[i].length; | 97 offset += matches[i].length; |
| 95 ++i; | 98 ++i; |
| 96 } while ((i < match_count) && (offset == matches[i].offset)); | 99 } while ((i < match_count) && (offset == matches[i].offset)); |
| 97 if (offset < text_length) | 100 if (offset < text_length) |
| 98 spans.push_back(ACMatchClassification(offset, url_style)); | 101 spans.push_back(ACMatchClassification(offset, url_style)); |
| 99 } | 102 } |
| 100 | 103 |
| 101 return spans; | 104 return spans; |
| 102 } | 105 } |
| OLD | NEW |