| 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/util.h" | 5 #include "chrome/browser/search_engines/util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 std::vector<std::string> deduped_encodings; | 302 std::vector<std::string> deduped_encodings; |
| 303 std::set<std::string> encoding_set; | 303 std::set<std::string> encoding_set; |
| 304 for (std::vector<std::string>::const_iterator i(encodings->begin()); | 304 for (std::vector<std::string>::const_iterator i(encodings->begin()); |
| 305 i != encodings->end(); ++i) { | 305 i != encodings->end(); ++i) { |
| 306 if (encoding_set.insert(*i).second) | 306 if (encoding_set.insert(*i).second) |
| 307 deduped_encodings.push_back(*i); | 307 deduped_encodings.push_back(*i); |
| 308 } | 308 } |
| 309 encodings->swap(deduped_encodings); | 309 encodings->swap(deduped_encodings); |
| 310 return encodings->size() != deduped_encodings.size(); | 310 return encodings->size() != deduped_encodings.size(); |
| 311 } | 311 } |
| 312 | |
| 313 bool DidDefaultSearchProviderChange( | |
| 314 const WDTypedResult& result, | |
| 315 Profile* profile, | |
| 316 scoped_ptr<TemplateURL>* backup_default_search_provider) { | |
| 317 DCHECK(backup_default_search_provider); | |
| 318 DCHECK(!backup_default_search_provider->get()); | |
| 319 DCHECK_EQ(result.GetType(), KEYWORDS_RESULT); | |
| 320 | |
| 321 WDKeywordsResult keyword_result = reinterpret_cast< | |
| 322 const WDResult<WDKeywordsResult>*>(&result)->GetValue(); | |
| 323 | |
| 324 if (!keyword_result.did_default_search_provider_change) | |
| 325 return false; | |
| 326 | |
| 327 if (keyword_result.backup_valid) { | |
| 328 backup_default_search_provider->reset(new TemplateURL(profile, | |
| 329 keyword_result.default_search_provider_backup)); | |
| 330 } | |
| 331 return true; | |
| 332 } | |
| OLD | NEW |