diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 07:25:03 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 07:25:03 +0000 |
commit | 66789d6149575a97b65694c3f40c66414c7f39c9 (patch) | |
tree | 81cb0b0bc5f7235fefb61695dfd0c171c6d25156 | |
parent | 161d45fe28d44c8238b10d60dcc011188678dbf9 (diff) | |
download | chromium_src-66789d6149575a97b65694c3f40c66414c7f39c9.zip chromium_src-66789d6149575a97b65694c3f40c66414c7f39c9.tar.gz chromium_src-66789d6149575a97b65694c3f40c66414c7f39c9.tar.bz2 |
Only attempt once to autogenerate a keyword for search engines.
BUG=none
TEST=Add a search engine provider for which no keyword can be generated
Review URL: http://codereview.chromium.org/2008017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47249 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/search_engines/template_url.cc | 7 | ||||
-rw-r--r-- | chrome/browser/search_engines/template_url.h | 8 |
2 files changed, 12 insertions, 3 deletions
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index 43dae52..d91bce9 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -569,10 +569,11 @@ void TemplateURL::set_keyword(const std::wstring& keyword) { } const std::wstring& TemplateURL::keyword() const { - if (autogenerate_keyword_ && keyword_.empty()) { + if (autogenerate_keyword_ && !keyword_generated_) { // Generate a keyword and cache it. keyword_ = TemplateURLModel::GenerateKeyword( TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); + keyword_generated_ = true; } return keyword_; } @@ -615,6 +616,8 @@ GURL TemplateURL::GetFavIconURL() const { void TemplateURL::InvalidateCachedValues() const { url_.InvalidateCachedValues(); suggestions_url_.InvalidateCachedValues(); - if (autogenerate_keyword_) + if (autogenerate_keyword_) { keyword_.clear(); + keyword_generated_ = false; + } } diff --git a/chrome/browser/search_engines/template_url.h b/chrome/browser/search_engines/template_url.h index 5a5c67f..1a7d779 100644 --- a/chrome/browser/search_engines/template_url.h +++ b/chrome/browser/search_engines/template_url.h @@ -267,6 +267,7 @@ class TemplateURL { TemplateURL() : autogenerate_keyword_(false), + keyword_generated_(false), show_in_default_list_(false), safe_for_autoreplace_(false), id_(0), @@ -334,8 +335,10 @@ class TemplateURL { // keywords are mutually exclusive. void set_autogenerate_keyword(bool autogenerate_keyword) { autogenerate_keyword_ = autogenerate_keyword; - if (autogenerate_keyword_) + if (autogenerate_keyword_) { keyword_.clear(); + keyword_generated_ = false; + } } bool autogenerate_keyword() const { return autogenerate_keyword_; @@ -437,6 +440,9 @@ class TemplateURL { mutable std::wstring keyword_; bool autogenerate_keyword_; // If this is set, |keyword_| holds the cached // generated keyword if available. + mutable bool keyword_generated_; // True if the keyword was generated. This + // is used to avoid multiple attempts if + // generating a keyword failed. bool show_in_default_list_; bool safe_for_autoreplace_; std::vector<ImageRef> image_refs_; |