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/search_engines/template_url_fetcher.h" | 5 #include "components/search_engines/template_url_fetcher.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 TemplateURLData data(template_url_->data()); | 161 TemplateURLData data(template_url_->data()); |
162 data.SetKeyword(keyword_); | 162 data.SetKeyword(keyword_); |
163 data.originating_url = osdd_url_; | 163 data.originating_url = osdd_url_; |
164 | 164 |
165 // The page may have specified a URL to use for favicons, if not, set it. | 165 // The page may have specified a URL to use for favicons, if not, set it. |
166 if (!data.favicon_url.is_valid()) | 166 if (!data.favicon_url.is_valid()) |
167 data.favicon_url = favicon_url_; | 167 data.favicon_url = favicon_url_; |
168 | 168 |
169 // Mark the keyword as replaceable so it can be removed if necessary. | 169 // Mark the keyword as replaceable so it can be removed if necessary. |
170 data.safe_for_autoreplace = true; | 170 data.safe_for_autoreplace = true; |
171 model->Add(new TemplateURL(data)); | 171 model->Add(base::MakeUnique<TemplateURL>(data)); |
172 | 172 |
173 fetcher_->RequestCompleted(this); | 173 fetcher_->RequestCompleted(this); |
174 // WARNING: RequestCompleted deletes us. | 174 // WARNING: RequestCompleted deletes us. |
175 } | 175 } |
176 | 176 |
177 // TemplateURLFetcher --------------------------------------------------------- | 177 // TemplateURLFetcher --------------------------------------------------------- |
178 | 178 |
179 TemplateURLFetcher::TemplateURLFetcher( | 179 TemplateURLFetcher::TemplateURLFetcher( |
180 TemplateURLService* template_url_service, | 180 TemplateURLService* template_url_service, |
181 net::URLRequestContextGetter* request_context) | 181 net::URLRequestContextGetter* request_context) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 this, keyword, osdd_url, favicon_url, url_fetcher_customize_callback)); | 217 this, keyword, osdd_url, favicon_url, url_fetcher_customize_callback)); |
218 } | 218 } |
219 | 219 |
220 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { | 220 void TemplateURLFetcher::RequestCompleted(RequestDelegate* request) { |
221 Requests::iterator i = | 221 Requests::iterator i = |
222 std::find(requests_.begin(), requests_.end(), request); | 222 std::find(requests_.begin(), requests_.end(), request); |
223 DCHECK(i != requests_.end()); | 223 DCHECK(i != requests_.end()); |
224 requests_.weak_erase(i); | 224 requests_.weak_erase(i); |
225 delete request; | 225 delete request; |
226 } | 226 } |
OLD | NEW |