| 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 25 matching lines...) Expand all Loading... |
| 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. |
| 42 bool found = false; | 42 bool found = false; |
| 43 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 43 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
| 44 if (i->destination_url == selected_url && i->type == match.type) { | 44 if (i->destination_url == selected_url && i->type == match.type) { |
| 45 found = true; | 45 found = true; |
| 46 if (i->is_history_what_you_typed_match) { | 46 if (i->is_history_what_you_typed_match || i->starred) { |
| 47 // We can't get rid of the What You Typed match, but we can make it | 47 // We can't get rid of What-You-Typed or Bookmarked matches, |
| 48 // look like it has no backing data. | 48 // but we can make them look like they have no backing data. |
| 49 i->deletable = false; | 49 i->deletable = false; |
| 50 i->description.clear(); | 50 i->description.clear(); |
| 51 i->description_class.clear(); | 51 i->description_class.clear(); |
| 52 } else { | 52 } else { |
| 53 matches_.erase(i); | 53 matches_.erase(i); |
| 54 } | 54 } |
| 55 break; | 55 break; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 DCHECK(found) << "Asked to delete a URL that isn't in our set of matches"; | 58 DCHECK(found) << "Asked to delete a URL that isn't in our set of matches"; |
| (...skipping 76 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 |