summaryrefslogtreecommitdiffstats
path: root/chrome/browser/search_engines/template_url.cc
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 06:23:57 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 06:23:57 +0000
commit6506f2aee4619a49f4ac32e729f7a01e34b9d8e8 (patch)
tree60904021b970035586afd0fbe47ae18c652d396d /chrome/browser/search_engines/template_url.cc
parent33bb14c339d53c34ca1da327f983d7abb8b6fd5a (diff)
downloadchromium_src-6506f2aee4619a49f4ac32e729f7a01e34b9d8e8.zip
chromium_src-6506f2aee4619a49f4ac32e729f7a01e34b9d8e8.tar.gz
chromium_src-6506f2aee4619a49f4ac32e729f7a01e34b9d8e8.tar.bz2
Need to ensure that the autogenerated keyword is generated on the UI thread.
This was broken by r57563. BUG=53557 TEST=unit_test --gtest_filter=TemplateURLModelTest.LoadDoesAutoKeywordUpdate Review URL: http://codereview.chromium.org/3243001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57641 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines/template_url.cc')
-rw-r--r--chrome/browser/search_engines/template_url.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 29276a6..4c32797 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -11,6 +11,7 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/google_url_tracker.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/common/url_constants.h"
@@ -246,6 +247,12 @@ std::string TemplateURLRef::ReplaceSearchTerms(
const std::wstring& terms,
int accepted_suggestion,
const std::wstring& original_query_for_suggestion) const {
+ // GoogleBaseURLValue() enforces this, but this assert helps us catch bad
+ // behavior more frequently (instead of only when there is a GoogleBaseURL
+ // component in the passed in host).
+ DCHECK(!ChromeThread::IsWellKnownThread(ChromeThread::UI) ||
+ ChromeThread::CurrentlyOn(ChromeThread::UI));
+
ParseIfNecessary();
if (!valid_)
return std::string();
@@ -481,6 +488,11 @@ void TemplateURLRef::InvalidateCachedValues() const {
// Returns the value to use for replacements of type GOOGLE_BASE_URL.
// static
std::string TemplateURLRef::GoogleBaseURLValue() {
+ // Normally GoogleURLTracker::GoogleURL() enforces this, but this
+ // assert helps us catch bad behavior at unit tests time.
+ DCHECK(!ChromeThread::IsWellKnownThread(ChromeThread::UI) ||
+ ChromeThread::CurrentlyOn(ChromeThread::UI));
+
return google_base_url_ ?
(*google_base_url_) : GoogleURLTracker::GoogleURL().spec();
}
@@ -488,6 +500,11 @@ std::string TemplateURLRef::GoogleBaseURLValue() {
// Returns the value to use for replacements of type GOOGLE_BASE_SUGGEST_URL.
// static
std::string TemplateURLRef::GoogleBaseSuggestURLValue() {
+ // Normally GoogleURLTracker::GoogleURL() enforces this, but this
+ // assert helps us catch bad behavior at unit tests time.
+ DCHECK(!ChromeThread::IsWellKnownThread(ChromeThread::UI) ||
+ ChromeThread::CurrentlyOn(ChromeThread::UI));
+
// The suggest base URL we want at the end is something like
// "http://clients1.google.TLD/complete/". The key bit we want from the
// original Google base URL is the TLD.