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

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

Issue 415053002: Remove AutocompleteMatch::is_starred (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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) 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_match.h" 11 #include "chrome/browser/autocomplete/autocomplete_match.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/history/history_service.h" 13 #include "chrome/browser/history/history_service.h"
13 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/history/in_memory_url_index_types.h" 15 #include "chrome/browser/history/in_memory_url_index_types.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
17 #include "components/autocomplete/autocomplete_input.h" 18 #include "components/autocomplete/autocomplete_input.h"
19 #include "components/bookmarks/browser/bookmark_model.h"
18 #include "url/url_util.h" 20 #include "url/url_util.h"
19 21
20 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { 22 void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) {
21 DCHECK(done_); 23 DCHECK(done_);
22 DCHECK(profile_); 24 DCHECK(profile_);
23 DCHECK(match.deletable); 25 DCHECK(match.deletable);
24 26
25 HistoryService* const history_service = 27 HistoryService* const history_service =
26 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 28 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
27 29
(...skipping 18 matching lines...) Expand all
46 HistoryProvider::HistoryProvider(Profile* profile, 48 HistoryProvider::HistoryProvider(Profile* profile,
47 AutocompleteProvider::Type type) 49 AutocompleteProvider::Type type)
48 : AutocompleteProvider(type), 50 : AutocompleteProvider(type),
49 profile_(profile) { 51 profile_(profile) {
50 } 52 }
51 53
52 HistoryProvider::~HistoryProvider() {} 54 HistoryProvider::~HistoryProvider() {}
53 55
54 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) { 56 void HistoryProvider::DeleteMatchFromMatches(const AutocompleteMatch& match) {
55 bool found = false; 57 bool found = false;
58 BookmarkModel* bookmark_model = BookmarkModelFactory::GetForProfile(profile_);
56 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) { 59 for (ACMatches::iterator i(matches_.begin()); i != matches_.end(); ++i) {
57 if (i->destination_url == match.destination_url && i->type == match.type) { 60 if (i->destination_url == match.destination_url && i->type == match.type) {
58 found = true; 61 found = true;
59 if (i->is_history_what_you_typed_match || i->starred) { 62 if (i->is_history_what_you_typed_match ||
63 (bookmark_model &&
64 bookmark_model->IsBookmarked(i->destination_url))) {
60 // We can't get rid of What-You-Typed or Bookmarked matches, 65 // We can't get rid of What-You-Typed or Bookmarked matches,
61 // but we can make them look like they have no backing data. 66 // but we can make them look like they have no backing data.
62 i->deletable = false; 67 i->deletable = false;
63 i->description.clear(); 68 i->description.clear();
64 i->description_class.clear(); 69 i->description_class.clear();
65 } else { 70 } else {
66 matches_.erase(i); 71 matches_.erase(i);
67 } 72 }
68 break; 73 break;
69 } 74 }
(...skipping 25 matching lines...) Expand all
95 do { 100 do {
96 offset += matches[i].length; 101 offset += matches[i].length;
97 ++i; 102 ++i;
98 } while ((i < match_count) && (offset == matches[i].offset)); 103 } while ((i < match_count) && (offset == matches[i].offset));
99 if (offset < text_length) 104 if (offset < text_length)
100 spans.push_back(ACMatchClassification(offset, url_style)); 105 spans.push_back(ACMatchClassification(offset, url_style));
101 } 106 }
102 107
103 return spans; 108 return spans;
104 } 109 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/bookmark_provider.cc ('k') | chrome/browser/autocomplete/history_quick_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698