Chromium Code Reviews| 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/importer/firefox_importer_utils.h" | 5 #include "chrome/browser/importer/firefox_importer_utils.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 // The first XML file represents the default search engine in Firefox 3, so we | 196 // The first XML file represents the default search engine in Firefox 3, so we |
| 197 // need to keep it on top of the list. | 197 // need to keep it on top of the list. |
| 198 SearchEnginesMap::const_iterator default_turl = search_engine_for_url.end(); | 198 SearchEnginesMap::const_iterator default_turl = search_engine_for_url.end(); |
| 199 for (std::vector<FilePath>::const_iterator file_iter = xml_files.begin(); | 199 for (std::vector<FilePath>::const_iterator file_iter = xml_files.begin(); |
| 200 file_iter != xml_files.end(); ++file_iter) { | 200 file_iter != xml_files.end(); ++file_iter) { |
| 201 file_util::ReadFileToString(*file_iter, &content); | 201 file_util::ReadFileToString(*file_iter, &content); |
| 202 FirefoxURLParameterFilter param_filter; | 202 FirefoxURLParameterFilter param_filter; |
| 203 TemplateURL* template_url = TemplateURLParser::Parse(NULL, content.data(), | 203 TemplateURL* template_url = TemplateURLParser::Parse(NULL, content.data(), |
| 204 content.length(), ¶m_filter); | 204 content.length(), ¶m_filter); |
| 205 if (template_url) { | 205 if (template_url) { |
| 206 std::string url = template_url->url()->url(); | 206 std::string url(template_url->url()); |
|
sky
2012/03/30 16:45:14
const std::string&
| |
| 207 SearchEnginesMap::iterator iter = search_engine_for_url.find(url); | 207 SearchEnginesMap::iterator iter = search_engine_for_url.find(url); |
| 208 if (iter == search_engine_for_url.end()) { | 208 if (iter == search_engine_for_url.end()) { |
| 209 iter = search_engine_for_url.insert( | 209 iter = search_engine_for_url.insert( |
| 210 std::make_pair(url, template_url)).first; | 210 std::make_pair(url, template_url)).first; |
| 211 } else { | 211 } else { |
| 212 // We have already found a search engine with the same URL. We give | 212 // We have already found a search engine with the same URL. We give |
| 213 // priority to the latest one found, as GetSearchEnginesXMLFiles() | 213 // priority to the latest one found, as GetSearchEnginesXMLFiles() |
| 214 // returns a vector with first Firefox default search engines and then | 214 // returns a vector with first Firefox default search engines and then |
| 215 // the user's ones. We want to give priority to the user ones. | 215 // the user's ones. We want to give priority to the user ones. |
| 216 delete iter->second; | 216 delete iter->second; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 } | 411 } |
| 412 | 412 |
| 413 // String values have double quotes we don't need to return to the caller. | 413 // String values have double quotes we don't need to return to the caller. |
| 414 if (content[start] == '\"' && content[stop - 1] == '\"') { | 414 if (content[start] == '\"' && content[stop - 1] == '\"') { |
| 415 ++start; | 415 ++start; |
| 416 --stop; | 416 --stop; |
| 417 } | 417 } |
| 418 | 418 |
| 419 return content.substr(start, stop - start); | 419 return content.substr(start, stop - start); |
| 420 } | 420 } |
| OLD | NEW |