| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/template_url_model.h" | 5 #include "chrome/browser/search_engines/template_url_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extensions_service.h" | 10 #include "chrome/browser/extensions/extensions_service.h" |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // loading. Now that we've loaded we can nuke it. | 593 // loading. Now that we've loaded we can nuke it. |
| 594 prefs_default_search_provider_.reset(); | 594 prefs_default_search_provider_.reset(); |
| 595 | 595 |
| 596 // Compiler won't implicitly convert std::vector<TemplateURL*> to | 596 // Compiler won't implicitly convert std::vector<TemplateURL*> to |
| 597 // std::vector<const TemplateURL*>, and reinterpret_cast is unsafe, | 597 // std::vector<const TemplateURL*>, and reinterpret_cast is unsafe, |
| 598 // so we just copy it. | 598 // so we just copy it. |
| 599 std::vector<const TemplateURL*> template_urls(keyword_result.keywords.begin(), | 599 std::vector<const TemplateURL*> template_urls(keyword_result.keywords.begin(), |
| 600 keyword_result.keywords.end()); | 600 keyword_result.keywords.end()); |
| 601 | 601 |
| 602 const int resource_keyword_version = | 602 const int resource_keyword_version = |
| 603 TemplateURLPrepopulateData::GetDataVersion(); | 603 TemplateURLPrepopulateData::GetDataVersion(GetPrefs()); |
| 604 if (keyword_result.builtin_keyword_version != resource_keyword_version) { | 604 if (keyword_result.builtin_keyword_version != resource_keyword_version) { |
| 605 // There should never be duplicate TemplateURLs. We had a bug such that | 605 // There should never be duplicate TemplateURLs. We had a bug such that |
| 606 // duplicate TemplateURLs existed for one locale. As such we invoke | 606 // duplicate TemplateURLs existed for one locale. As such we invoke |
| 607 // RemoveDuplicatePrepopulateIDs to nuke the duplicates. | 607 // RemoveDuplicatePrepopulateIDs to nuke the duplicates. |
| 608 RemoveDuplicatePrepopulateIDs(&template_urls); | 608 RemoveDuplicatePrepopulateIDs(&template_urls); |
| 609 } | 609 } |
| 610 SetTemplateURLs(template_urls); | 610 SetTemplateURLs(template_urls); |
| 611 | 611 |
| 612 if (keyword_result.default_search_provider_id) { | 612 if (keyword_result.default_search_provider_id) { |
| 613 // See if we can find the default search provider. | 613 // See if we can find the default search provider. |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 const TemplateURL* TemplateURLModel::GetTemplateURLForExtension( | 1099 const TemplateURL* TemplateURLModel::GetTemplateURLForExtension( |
| 1100 Extension* extension) const { | 1100 Extension* extension) const { |
| 1101 for (TemplateURLVector::const_iterator i = template_urls_.begin(); | 1101 for (TemplateURLVector::const_iterator i = template_urls_.begin(); |
| 1102 i != template_urls_.end(); ++i) { | 1102 i != template_urls_.end(); ++i) { |
| 1103 if ((*i)->IsExtensionKeyword() && (*i)->url()->GetHost() == extension->id()) | 1103 if ((*i)->IsExtensionKeyword() && (*i)->url()->GetHost() == extension->id()) |
| 1104 return *i; | 1104 return *i; |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 return NULL; | 1107 return NULL; |
| 1108 } | 1108 } |
| OLD | NEW |