Commit c364f026 authored by gab@chromium.org's avatar gab@chromium.org

Do not use a UIThreadSearchTermsData when validating a TemplateURL for which the Profile is NULL.

This was otherwise firing a DCHECK (see https://code.google.com/p/chromium/issues/detail?id=231710#c3) that blocked new (yet to be committed) tests for issue 219419).

BUG=231710, 219419
TEST=Fixes yet to be committed tests for issue 219419.

Review URL: https://chromiumcodereview.appspot.com/14232019

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194949 0039d316-1c4b-4281-b951-d872f2087c98
parent f7625281
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/string_util.h" #include "base/string_util.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
...@@ -309,10 +310,15 @@ TemplateURL* TemplateURLParsingContext::GetTemplateURL( ...@@ -309,10 +310,15 @@ TemplateURL* TemplateURLParsingContext::GetTemplateURL(
// Bail if the search URL is empty or if either TemplateURLRef is invalid. // Bail if the search URL is empty or if either TemplateURLRef is invalid.
scoped_ptr<TemplateURL> template_url(new TemplateURL(profile, data_)); scoped_ptr<TemplateURL> template_url(new TemplateURL(profile, data_));
if (template_url->url().empty() || !template_url->url_ref().IsValid() || scoped_ptr<SearchTermsData> search_terms_data(profile ?
new UIThreadSearchTermsData(profile) : new SearchTermsData());
if (template_url->url().empty() ||
!template_url->url_ref().IsValidUsingTermsData(*search_terms_data) ||
(!template_url->suggestions_url().empty() && (!template_url->suggestions_url().empty() &&
!template_url->suggestions_url_ref().IsValid())) !template_url->suggestions_url_ref().
IsValidUsingTermsData(*search_terms_data))) {
return NULL; return NULL;
}
return template_url.release(); return template_url.release();
} }
......
...@@ -28,13 +28,15 @@ class TemplateURLParser { ...@@ -28,13 +28,15 @@ class TemplateURLParser {
}; };
// Decodes the chunk of data representing a TemplateURL, creates the // Decodes the chunk of data representing a TemplateURL, creates the
// TemplateURL, and returns it. The caller owns the returned object. Returns // TemplateURL, and returns it. The caller owns the returned object.
// NULL if data does not describe a valid TemplateURL, the URLs referenced do // |profile| should only be non-NULL if this function is called on the UI
// not point to valid http/https resources, or for some other reason we do not // thread. Returns NULL if data does not describe a valid TemplateURL, the
// support the described TemplateURL. |parameter_filter| can be used if you // URLs referenced do not point to valid http/https resources, or for some
// want to filter some parameters out of the URL. For example, when importing // other reason we do not support the described TemplateURL.
// from another browser, we remove any parameter identifying that browser. If // |parameter_filter| can be used if you want to filter some parameters out of
// set to NULL, the URL is not modified. // the URL. For example, when importing from another browser, we remove any
// parameter identifying that browser. If set to NULL, the URL is not
// modified.
static TemplateURL* Parse(Profile* profile, static TemplateURL* Parse(Profile* profile,
bool show_in_default_list, bool show_in_default_list,
const char* data, const char* data,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment