Chromium Code Reviews| 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 "components/omnibox/browser/base_search_provider.h" | 5 #include "components/omnibox/browser/base_search_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 std::string(), from_keyword_provider, 0, false, false, base::string16()); | 118 std::string(), from_keyword_provider, 0, false, false, base::string16()); |
| 119 suggest_result.set_received_after_last_keystroke(false); | 119 suggest_result.set_received_after_last_keystroke(false); |
| 120 return CreateSearchSuggestion( | 120 return CreateSearchSuggestion( |
| 121 NULL, AutocompleteInput(), from_keyword_provider, suggest_result, | 121 NULL, AutocompleteInput(), from_keyword_provider, suggest_result, |
| 122 template_url, search_terms_data, 0, false); | 122 template_url, search_terms_data, 0, false); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) { | 125 void BaseSearchProvider::DeleteMatch(const AutocompleteMatch& match) { |
| 126 DCHECK(match.deletable); | 126 DCHECK(match.deletable); |
| 127 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { | 127 if (!match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey).empty()) { |
| 128 deletion_handlers_.push_back(new SuggestionDeletionHandler( | 128 deletion_handlers_.push_back(make_scoped_ptr(new SuggestionDeletionHandler( |
| 129 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey), | 129 match.GetAdditionalInfo(BaseSearchProvider::kDeletionUrlKey), |
| 130 client_->GetRequestContext(), | 130 client_->GetRequestContext(), |
| 131 base::Bind(&BaseSearchProvider::OnDeletionComplete, | 131 base::Bind(&BaseSearchProvider::OnDeletionComplete, |
| 132 base::Unretained(this)))); | 132 base::Unretained(this))))); |
| 133 } | 133 } |
| 134 | 134 |
| 135 TemplateURL* template_url = | 135 TemplateURL* template_url = |
| 136 match.GetTemplateURL(client_->GetTemplateURLService(), false); | 136 match.GetTemplateURL(client_->GetTemplateURLService(), false); |
| 137 // This may be NULL if the template corresponding to the keyword has been | 137 // This may be NULL if the template corresponding to the keyword has been |
| 138 // deleted or there is no keyword set. | 138 // deleted or there is no keyword set. |
| 139 if (template_url != NULL) { | 139 if (template_url != NULL) { |
| 140 client_->DeleteMatchingURLsForKeywordFromHistory(template_url->id(), | 140 client_->DeleteMatchingURLsForKeywordFromHistory(template_url->id(), |
| 141 match.contents); | 141 match.contents); |
| 142 } | 142 } |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 if (i->contents == match.contents && i->type == match.type) { | 475 if (i->contents == match.contents && i->type == match.type) { |
| 476 matches_.erase(i); | 476 matches_.erase(i); |
| 477 break; | 477 break; |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 void BaseSearchProvider::OnDeletionComplete( | 482 void BaseSearchProvider::OnDeletionComplete( |
| 483 bool success, SuggestionDeletionHandler* handler) { | 483 bool success, SuggestionDeletionHandler* handler) { |
| 484 RecordDeletionResult(success); | 484 RecordDeletionResult(success); |
| 485 SuggestionDeletionHandlers::iterator it = std::find( | 485 deletion_handlers_.erase(std::remove_if( |
| 486 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 486 deletion_handlers_.begin(), deletion_handlers_.end(), |
| 487 DCHECK(it != deletion_handlers_.end()); | 487 [handler](const scoped_ptr<SuggestionDeletionHandler>& elem) { |
|
Mark P
2016/02/05 19:19:21
Ah, how the language evolves.
| |
| 488 deletion_handlers_.erase(it); | 488 return elem.get() == handler; |
| 489 })); | |
| 489 } | 490 } |
| OLD | NEW |