OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/base_search_provider.h" | 5 #include "chrome/browser/autocomplete/base_search_provider.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { | 170 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { |
171 deletion_handlers_.push_back(new SuggestionDeletionHandler( | 171 deletion_handlers_.push_back(new SuggestionDeletionHandler( |
172 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey), | 172 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey), |
173 profile_, | 173 profile_, |
174 base::Bind(&BaseSearchProvider::OnDeletionComplete, | 174 base::Bind(&BaseSearchProvider::OnDeletionComplete, |
175 base::Unretained(this)))); | 175 base::Unretained(this)))); |
176 } | 176 } |
177 | 177 |
178 HistoryService* const history_service = | 178 HistoryService* const history_service = |
179 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 179 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
180 TemplateURL* template_url = match.GetTemplateURL(profile_, false); | 180 TemplateURLService* template_url_service = |
| 181 TemplateURLServiceFactory::GetForProfile(profile_); |
| 182 TemplateURL* template_url = match.GetTemplateURL(template_url_service, false); |
181 // This may be NULL if the template corresponding to the keyword has been | 183 // This may be NULL if the template corresponding to the keyword has been |
182 // deleted or there is no keyword set. | 184 // deleted or there is no keyword set. |
183 if (template_url != NULL) { | 185 if (template_url != NULL) { |
184 history_service->DeleteMatchingURLsForKeyword(template_url->id(), | 186 history_service->DeleteMatchingURLsForKeyword(template_url->id(), |
185 match.contents); | 187 match.contents); |
186 } | 188 } |
187 | 189 |
188 // Immediately update the list of matches to show the match was deleted, | 190 // Immediately update the list of matches to show the match was deleted, |
189 // regardless of whether the server request actually succeeds. | 191 // regardless of whether the server request actually succeeds. |
190 DeleteMatchFromMatches(match); | 192 DeleteMatchFromMatches(match); |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 } | 1011 } |
1010 | 1012 |
1011 void BaseSearchProvider::OnDeletionComplete( | 1013 void BaseSearchProvider::OnDeletionComplete( |
1012 bool success, SuggestionDeletionHandler* handler) { | 1014 bool success, SuggestionDeletionHandler* handler) { |
1013 RecordDeletionResult(success); | 1015 RecordDeletionResult(success); |
1014 SuggestionDeletionHandlers::iterator it = std::find( | 1016 SuggestionDeletionHandlers::iterator it = std::find( |
1015 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 1017 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
1016 DCHECK(it != deletion_handlers_.end()); | 1018 DCHECK(it != deletion_handlers_.end()); |
1017 deletion_handlers_.erase(it); | 1019 deletion_handlers_.erase(it); |
1018 } | 1020 } |
OLD | NEW |