Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/importer/firefox_importer_utils.cc

Issue 9968016: Move the URL string from TemplateURLRef onto the owning TemplateURL. This will make it easier to m… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(), &param_filter); 204 content.length(), &param_filter);
205 if (template_url) { 205 if (template_url) {
206 std::string url = template_url->url()->url(); 206 SearchEnginesMap::iterator iter =
207 SearchEnginesMap::iterator iter = search_engine_for_url.find(url); 207 search_engine_for_url.find(template_url->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(template_url->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;
217 iter->second = template_url; 217 iter->second = template_url;
218 } 218 }
219 iter->second->set_show_in_default_list(true); 219 iter->second->set_show_in_default_list(true);
220 if (default_turl == search_engine_for_url.end()) 220 if (default_turl == search_engine_for_url.end())
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox_importer_unittest.cc ('k') | chrome/browser/importer/profile_import_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698