summaryrefslogtreecommitdiffstats
path: root/chrome/browser/template_url.cc
diff options
context:
space:
mode:
authorpkasting@google.com <pkasting@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 17:38:56 +0000
committerpkasting@google.com <pkasting@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-01 17:38:56 +0000
commitfab288ae66e4e45b792d929aa44210fd8104f5e7 (patch)
treeb737518357c503bce66334bcc59309cdcc4e509c /chrome/browser/template_url.cc
parent1fcb8b01fe855dde2485b82d620cdaecb580a3bd (diff)
downloadchromium_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.cc17
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();
+}