summaryrefslogtreecommitdiffstats
path: root/chrome/browser/search_engines
diff options
context:
space:
mode:
authorlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 22:55:56 +0000
committerlevin@chromium.org <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-27 22:55:56 +0000
commit774ef485a6f050b3ab9a8d360ff2de419a82d510 (patch)
treedb0b7f1d4ab943239186531f345e9016c9339db4 /chrome/browser/search_engines
parent192b9a0cc09f62b26b1435d1ce88a257d36fb992 (diff)
downloadchromium_src-774ef485a6f050b3ab9a8d360ff2de419a82d510.zip
chromium_src-774ef485a6f050b3ab9a8d360ff2de419a82d510.tar.gz
chromium_src-774ef485a6f050b3ab9a8d360ff2de419a82d510.tar.bz2
Address feedback regarding r57641.
BUG=53557 TEST=unit_tests --gtest_filter=TemplateURLModelTest.LoadDoesAutoKeywordUpdate Review URL: http://codereview.chromium.org/3237002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57743 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines')
-rw-r--r--chrome/browser/search_engines/template_url.cc6
-rw-r--r--chrome/browser/search_engines/template_url.h5
-rw-r--r--chrome/browser/search_engines/template_url_model_unittest.cc9
3 files changed, 13 insertions, 7 deletions
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index 4c32797..a289826f 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -583,13 +583,17 @@ void TemplateURL::set_keyword(const std::wstring& keyword) {
}
const std::wstring& TemplateURL::keyword() const {
+ EnsureKeyword();
+ return keyword_;
+}
+
+void TemplateURL::EnsureKeyword() const {
if (autogenerate_keyword_ && !keyword_generated_) {
// Generate a keyword and cache it.
keyword_ = TemplateURLModel::GenerateKeyword(
TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true);
keyword_generated_ = true;
}
- return keyword_;
}
bool TemplateURL::ShowInDefaultList() const {
diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h
index 64a6510..584626b 100644
--- a/chrome/browser/search_engines/template_url.h
+++ b/chrome/browser/search_engines/template_url.h
@@ -351,6 +351,11 @@ class TemplateURL {
return autogenerate_keyword_;
}
+ // Ensures that the keyword is generated. Most consumers should not need this
+ // because it is done automatically. Use this method on the UI thread, so
+ // the keyword may be accessed on another thread.
+ void EnsureKeyword() const;
+
// Whether this keyword is shown in the default list of search providers. This
// is just a property and does not indicate whether this TemplateURL has
// a TemplateURLRef that supports replacement. Use ShowInDefaultList to
diff --git a/chrome/browser/search_engines/template_url_model_unittest.cc b/chrome/browser/search_engines/template_url_model_unittest.cc
index 0320098..4d1487f 100644
--- a/chrome/browser/search_engines/template_url_model_unittest.cc
+++ b/chrome/browser/search_engines/template_url_model_unittest.cc
@@ -5,7 +5,7 @@
#include "base/callback.h"
#include "base/file_util.h"
#include "base/path_service.h"
-#include "base/stl_util-inl.h"
+#include "base/scoped_vector.h"
#include "base/string_util.h"
#include "base/thread.h"
#include "chrome/browser/chrome_thread.h"
@@ -266,11 +266,11 @@ TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
size_t index_offset_from_default,
std::wstring* prepopulated_display_url) {
TemplateURL* t_url = CreatePreloadedTemplateURL();
- std::vector<TemplateURL*> prepopulated_urls;
+ ScopedVector<TemplateURL> prepopulated_urls;
size_t default_search_provider_index = 0;
TemplateURLPrepopulateData::GetPrepopulatedEngines(
profile_->GetPrefs(),
- &prepopulated_urls,
+ &prepopulated_urls.get(),
&default_search_provider_index);
EXPECT_LT(index_offset_from_default, prepopulated_urls.size());
size_t prepopulated_index =
@@ -280,9 +280,6 @@ TemplateURL* TemplateURLModelTest::CreateReplaceablePreloadedTemplateURL(
prepopulated_urls[prepopulated_index]->prepopulate_id());
*prepopulated_display_url =
prepopulated_urls[prepopulated_index]->url()->DisplayURL();
- STLDeleteElements(&prepopulated_urls);
- prepopulated_urls.clear();
-
return t_url;
}