| 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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 HistoryProvider::~HistoryProvider() {} | 57 HistoryProvider::~HistoryProvider() {} |
| 58 | 58 |
| 59 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { | 59 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { |
| 60 bool found = false; | 60 bool found = false; |
| 61 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_); | 61 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_); |
| 62 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { | 62 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { |
| 63 if (i->destination_url == match.destination_url && i->type == match.type) { | 63 if (i->destination_url == match.destination_url && i->type == match.type) { |
| 64 found = true; | 64 found = true; |
| 65 if (i->is_history_what_you_typed_match || | 65 if ((i->type == AutocompleteMatchType::URL_WHAT_YOU_TYPED) || |
| 66 (bookmark_model && | 66 (bookmark_model && |
| 67 bookmark_model->IsBookmarked(i->destination_url))) { | 67 bookmark_model->IsBookmarked(i->destination_url))) { |
| 68 // We can't get rid of What-You-Typed or Bookmarked matches, | 68 // We can't get rid of What-You-Typed or Bookmarked matches, |
| 69 // but we can make them look like they have no backing data. | 69 // but we can make them look like they have no backing data. |
| 70 i->deletable = false; | 70 i->deletable = false; |
| 71 i->description.clear(); | 71 i->description.clear(); |
| 72 i->description_class.clear(); | 72 i->description_class.clear(); |
| 73 } else { | 73 } else { |
| 74 matches_.erase(i); | 74 matches_.erase(i); |
| 75 } | 75 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 103 do { | 103 do { |
| 104 offset += matches[i].length; | 104 offset += matches[i].length; |
| 105 ++i; | 105 ++i; |
| 106 } while ((i < match_count) && (offset == matches[i].offset)); | 106 } while ((i < match_count) && (offset == matches[i].offset)); |
| 107 if (offset < text_length) | 107 if (offset < text_length) |
| 108 spans.push_back(ACMatchClassification(offset, url_style)); | 108 spans.push_back(ACMatchClassification(offset, url_style)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 return spans; | 111 return spans; |
| 112 } | 112 } |
| OLD | NEW |