diff options
author | pkasting@google.com <pkasting@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-01 17:38:56 +0000 |
---|---|---|
committer | pkasting@google.com <pkasting@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-01 17:38:56 +0000 |
commit | fab288ae66e4e45b792d929aa44210fd8104f5e7 (patch) | |
tree | b737518357c503bce66334bcc59309cdcc4e509c /chrome/browser/template_url.cc | |
parent | 1fcb8b01fe855dde2485b82d620cdaecb580a3bd (diff) | |
download | chromium_src-fab288ae66e4e45b792d929aa44210fd8104f5e7.zip chromium_src-fab288ae66e4e45b792d929aa44210fd8104f5e7.tar.gz chromium_src-fab288ae66e4e45b792d929aa44210fd8104f5e7.tar.bz2 |
Add the ability to dynamically generate keywords. Mark the Google engine as needing this. This ensures that users in countries where the Google base URL is not "google.com" will see the appropriate keyword for their local country (and can trigger it for tab-to-search, etc.).
BUG=1301290
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/template_url.cc')
-rw-r--r-- | chrome/browser/template_url.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/browser/template_url.cc b/chrome/browser/template_url.cc index 67f42e3c..aab5221 100644 --- a/chrome/browser/template_url.cc +++ b/chrome/browser/template_url.cc @@ -34,6 +34,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/rlz/rlz.h" #include "chrome/browser/google_url_tracker.h" +#include "chrome/browser/template_url_model.h" #include "chrome/common/gfx/favicon_size.h" #include "net/base/escape.h" @@ -527,6 +528,15 @@ void TemplateURL::SetURL(const std::wstring& url, url_.Set(url, index_offset, page_offset); } +const std::wstring& TemplateURL::keyword() const { + if (autogenerate_keyword_ && keyword_.empty()) { + // Generate a keyword and cache it. + keyword_ = TemplateURLModel::GenerateKeyword( + TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); + } + return keyword_; +} + bool TemplateURL::ShowInDefaultList() const { return show_in_default_list() && url() && url()->SupportsReplacement(); } @@ -561,3 +571,10 @@ GURL TemplateURL::GetFavIconURL() const { } return GURL(); } + +void TemplateURL::InvalidateCachedValues() const { + url_.InvalidateCachedValues(); + suggestions_url_.InvalidateCachedValues(); + if (autogenerate_keyword_) + keyword_.clear(); +} |