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

Side by Side Diff: chrome/browser/importer/profile_writer.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/profile_writer.h" 5 #include "chrome/browser/importer/profile_writer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 // If |try_url_if_invalid| is true, and |t_url| isn't valid, a string is built 248 // If |try_url_if_invalid| is true, and |t_url| isn't valid, a string is built
249 // from the raw TemplateURL string. Use a value of true for |try_url_if_invalid| 249 // from the raw TemplateURL string. Use a value of true for |try_url_if_invalid|
250 // when checking imported URLs as the imported URL may not be valid yet may 250 // when checking imported URLs as the imported URL may not be valid yet may
251 // match the host+path of one of the default URLs. This is used to catch the 251 // match the host+path of one of the default URLs. This is used to catch the
252 // case of IE using an invalid OSDD URL for Live Search, yet the host+path 252 // case of IE using an invalid OSDD URL for Live Search, yet the host+path
253 // matches our prepopulate data. IE's URL for Live Search is something like 253 // matches our prepopulate data. IE's URL for Live Search is something like
254 // 'http://...{Language}...'. As {Language} is not a valid OSDD parameter value 254 // 'http://...{Language}...'. As {Language} is not a valid OSDD parameter value
255 // the TemplateURL is invalid. 255 // the TemplateURL is invalid.
256 static std::string BuildHostPathKey(const TemplateURL* t_url, 256 static std::string BuildHostPathKey(const TemplateURL* t_url,
257 bool try_url_if_invalid) { 257 bool try_url_if_invalid) {
258 if (t_url->url()) { 258 if (!t_url->url().empty()) {
259 if (try_url_if_invalid && !t_url->url()->IsValid()) 259 if (try_url_if_invalid && !t_url->url_ref().IsValid())
260 return HostPathKeyForURL(GURL(t_url->url()->url())); 260 return HostPathKeyForURL(GURL(t_url->url()));
261 261
262 if (t_url->url()->SupportsReplacement()) { 262 if (t_url->url_ref().SupportsReplacement()) {
263 return HostPathKeyForURL(GURL( 263 return HostPathKeyForURL(GURL(
264 t_url->url()->ReplaceSearchTerms(ASCIIToUTF16("x"), 264 t_url->url_ref().ReplaceSearchTerms(ASCIIToUTF16("x"),
265 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16()))); 265 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())));
266 } 266 }
267 } 267 }
268 return std::string(); 268 return std::string();
269 } 269 }
270 270
271 // Builds a set that contains an entry of the host+path for each TemplateURL in 271 // Builds a set that contains an entry of the host+path for each TemplateURL in
272 // the TemplateURLService that has a valid search url. 272 // the TemplateURLService that has a valid search url.
273 static void BuildHostPathMap(TemplateURLService* model, 273 static void BuildHostPathMap(TemplateURLService* model,
274 HostPathMap* host_path_map) { 274 HostPathMap* host_path_map) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // For search engines if there is already a keyword with the same 310 // For search engines if there is already a keyword with the same
311 // host+path, we don't import it. This is done to avoid both duplicate 311 // host+path, we don't import it. This is done to avoid both duplicate
312 // search providers (such as two Googles, or two Yahoos) as well as making 312 // search providers (such as two Googles, or two Yahoos) as well as making
313 // sure the search engines we provide aren't replaced by those from the 313 // sure the search engines we provide aren't replaced by those from the
314 // imported browser. 314 // imported browser.
315 if (unique_on_host_and_path && 315 if (unique_on_host_and_path &&
316 (host_path_map.find(BuildHostPathKey(*i, true)) != host_path_map.end())) 316 (host_path_map.find(BuildHostPathKey(*i, true)) != host_path_map.end()))
317 continue; 317 continue;
318 318
319 // Only add valid TemplateURLs to the model. 319 // Only add valid TemplateURLs to the model.
320 if ((*i)->url() && (*i)->url()->IsValid()) { 320 if (!(*i)->url().empty() && (*i)->url_ref().IsValid()) {
321 model->Add(*i); // Takes ownership. 321 model->Add(*i); // Takes ownership.
322 *i = NULL; // Prevent the vector from deleting *i later. 322 *i = NULL; // Prevent the vector from deleting *i later.
323 } 323 }
324 } 324 }
325 } 325 }
326 326
327 ProfileWriter::~ProfileWriter() {} 327 ProfileWriter::~ProfileWriter() {}
OLDNEW
« no previous file with comments | « chrome/browser/importer/profile_import_process_messages.h ('k') | chrome/browser/instant/instant_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698