| 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 TemplateURLService* template_url_service = | 180 TemplateURL* template_url = match.GetTemplateURL(profile_, false); |
| 181 TemplateURLServiceFactory::GetForProfile(profile_); | |
| 182 TemplateURL* template_url = match.GetTemplateURL(template_url_service, false); | |
| 183 // This may be NULL if the template corresponding to the keyword has been | 181 // This may be NULL if the template corresponding to the keyword has been |
| 184 // deleted or there is no keyword set. | 182 // deleted or there is no keyword set. |
| 185 if (template_url != NULL) { | 183 if (template_url != NULL) { |
| 186 history_service->DeleteMatchingURLsForKeyword(template_url->id(), | 184 history_service->DeleteMatchingURLsForKeyword(template_url->id(), |
| 187 match.contents); | 185 match.contents); |
| 188 } | 186 } |
| 189 | 187 |
| 190 // Immediately update the list of matches to show the match was deleted, | 188 // Immediately update the list of matches to show the match was deleted, |
| 191 // regardless of whether the server request actually succeeds. | 189 // regardless of whether the server request actually succeeds. |
| 192 DeleteMatchFromMatches(match); | 190 DeleteMatchFromMatches(match); |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 } | 1009 } |
| 1012 | 1010 |
| 1013 void BaseSearchProvider::OnDeletionComplete( | 1011 void BaseSearchProvider::OnDeletionComplete( |
| 1014 bool success, SuggestionDeletionHandler* handler) { | 1012 bool success, SuggestionDeletionHandler* handler) { |
| 1015 RecordDeletionResult(success); | 1013 RecordDeletionResult(success); |
| 1016 SuggestionDeletionHandlers::iterator it = std::find( | 1014 SuggestionDeletionHandlers::iterator it = std::find( |
| 1017 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 1015 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
| 1018 DCHECK(it != deletion_handlers_.end()); | 1016 DCHECK(it != deletion_handlers_.end()); |
| 1019 deletion_handlers_.erase(it); | 1017 deletion_handlers_.erase(it); |
| 1020 } | 1018 } |
| OLD | NEW |