OLD | NEW |
---|---|
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/search_engines/search_provider_install_data.h" | 5 #include "chrome/browser/search_engines/search_provider_install_data.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 // the destructor. | 242 // the destructor. |
243 load_handle_ = 0; | 243 load_handle_ = 0; |
244 | 244 |
245 if (!result) { | 245 if (!result) { |
246 // Results are null if the database went away or (most likely) wasn't | 246 // Results are null if the database went away or (most likely) wasn't |
247 // loaded. | 247 // loaded. |
248 OnLoadFailed(); | 248 OnLoadFailed(); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
252 TemplateURL* default_search_provider = NULL; | |
253 int new_resource_keyword_version = 0; | 252 int new_resource_keyword_version = 0; |
254 std::vector<TemplateURL*> extracted_template_urls; | 253 std::vector<TemplateURL*> extracted_template_urls; |
255 GetSearchProvidersUsingKeywordResult(*result, NULL, NULL, | 254 GetSearchProvidersUsingKeywordResult(*result, |
256 &extracted_template_urls, &default_search_provider, | 255 NULL, |
257 &new_resource_keyword_version, NULL); | 256 NULL, |
257 &extracted_template_urls, | |
258 NULL, | |
259 &new_resource_keyword_version, | |
260 NULL); | |
258 template_urls_.get().insert(template_urls_.get().begin(), | 261 template_urls_.get().insert(template_urls_.get().begin(), |
259 extracted_template_urls.begin(), | 262 extracted_template_urls.begin(), |
260 extracted_template_urls.end()); | 263 extracted_template_urls.end()); |
261 IOThreadSearchTermsData search_terms_data(google_base_url_); | 264 IOThreadSearchTermsData search_terms_data(google_base_url_); |
262 provider_map_.reset(new SearchHostToURLsMap()); | 265 provider_map_.reset(new SearchHostToURLsMap()); |
263 provider_map_->Init(template_urls_.get(), search_terms_data); | 266 provider_map_->Init(template_urls_.get(), search_terms_data); |
264 SetDefault(default_search_provider); | 267 // TODO(erikwright): This needs to be based on prefs now... |
268 SetDefault(NULL); | |
Peter Kasting
2014/05/03 00:28:18
Um, what is the effect of not getting this right t
erikwright (departed)
2014/05/05 01:49:38
I intend to resolve this TODO before committing.
| |
265 NotifyLoaded(); | 269 NotifyLoaded(); |
266 } | 270 } |
267 | 271 |
268 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) { | 272 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) { |
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 273 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
270 | 274 |
271 if (!template_url) { | 275 if (!template_url) { |
272 default_search_origin_.clear(); | 276 default_search_origin_.clear(); |
273 return; | 277 return; |
274 } | 278 } |
(...skipping 28 matching lines...) Expand all Loading... | |
303 | 307 |
304 std::for_each(closure_queue.begin(), | 308 std::for_each(closure_queue.begin(), |
305 closure_queue.end(), | 309 closure_queue.end(), |
306 std::mem_fun_ref(&base::Closure::Run)); | 310 std::mem_fun_ref(&base::Closure::Run)); |
307 | 311 |
308 // Since we expect this request to be rare, clear out the information. This | 312 // Since we expect this request to be rare, clear out the information. This |
309 // also keeps the responses current as the search providers change. | 313 // also keeps the responses current as the search providers change. |
310 provider_map_.reset(); | 314 provider_map_.reset(); |
311 SetDefault(NULL); | 315 SetDefault(NULL); |
312 } | 316 } |
OLD | NEW |