diff options
author | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 01:44:33 +0000 |
---|---|---|
committer | mpearson@chromium.org <mpearson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 01:44:33 +0000 |
commit | 8d833232befa72f89a04a06c586aa506aa8496cc (patch) | |
tree | 957f35fda4b35a7dedc3505deec114da28a8aedd /chrome/browser/search_engines | |
parent | 1e03f48bd12e8da7e48cc55d0dff713e9b41877d (diff) | |
download | chromium_src-8d833232befa72f89a04a06c586aa506aa8496cc.zip chromium_src-8d833232befa72f89a04a06c586aa506aa8496cc.tar.gz chromium_src-8d833232befa72f89a04a06c586aa506aa8496cc.tar.bz2 |
Add API key to omnibox's suggest requests
Mostly closed question:
* Is the api key constant over the length of the run? [pfelding guesses yes. working assumpting is yes. The code for the api keys makes it look like the keys are compiled into the binary. joi to answer for sure.]
Closed questions:
* Send to all google suggest base URLs or only certain ones? [ANSWERED by afeldman: might as well send to everything]
* Send on all protocols or just https? [ANSWERED by afeldman: all protocols]
* The way I formatted the suggest URL parameter puts the parameter last in the URL. I think this looks better for people looking at URL. However, given the standard structure in template_url.cc of the way replacement is done, that means we end up with an extra & at the end of the URL. Is that a problem? [RESOLVED by dcblack by moving sugkey parameter into template itself]
* Do I have to do anything to update users who already have their template URL instantiated? (I think the answer is no, but I'm asking to double-check.) [ANSWERED by pkasting: increment version number in the prepopulated template URL file]
BUG=
TEST=tested using wireshark
Review URL: https://codereview.chromium.org/10905292
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/search_engines')
-rw-r--r-- | chrome/browser/search_engines/template_url.cc | 7 | ||||
-rw-r--r-- | chrome/browser/search_engines/template_url_prepopulate_data.cc | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index ad96e0e..1612f5a 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -19,6 +19,7 @@ #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/common/url_constants.h" +#include "google_apis/google_api_keys.h" #include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" @@ -57,6 +58,7 @@ const char kGoogleRLZParameter[] = "google:RLZ"; // Same as kSearchTermsParameter, with no escaping. const char kGoogleSearchFieldtrialParameter[] = "google:searchFieldtrialParameter"; +const char kGoogleSuggestAPIKeyParameter[] = "google:suggestAPIKeyParameter"; const char kGoogleUnescapedSearchTermsParameter[] = "google:unescapedSearchTerms"; const char kGoogleUnescapedSearchTermsParameterFull[] = @@ -136,7 +138,7 @@ std::string TemplateURLRef::GetURL() const { case SEARCH: return owner_->url(); case SUGGEST: return owner_->suggestions_url(); case INSTANT: return owner_->instant_url(); - default: NOTREACHED(); return std::string(); + default: NOTREACHED(); return std::string(); // NOLINT } } @@ -462,6 +464,9 @@ bool TemplateURLRef::ParseParameter(size_t start, replacements->push_back(Replacement(GOOGLE_RLZ, start)); } else if (parameter == kGoogleSearchFieldtrialParameter) { replacements->push_back(Replacement(GOOGLE_SEARCH_FIELDTRIAL_GROUP, start)); + } else if (parameter == kGoogleSuggestAPIKeyParameter) { + url->insert(start, + net::EscapeQueryParamValue(google_apis::GetAPIKey(), false)); } else if (parameter == kGoogleUnescapedSearchTermsParameter) { replacements->push_back(Replacement(GOOGLE_UNESCAPED_SEARCH_TERMS, start)); } else if (!prepopulated_) { diff --git a/chrome/browser/search_engines/template_url_prepopulate_data.cc b/chrome/browser/search_engines/template_url_prepopulate_data.cc index 0fae1a5..c89a3f0 100644 --- a/chrome/browser/search_engines/template_url_prepopulate_data.cc +++ b/chrome/browser/search_engines/template_url_prepopulate_data.cc @@ -1097,7 +1097,8 @@ const PrepopulatedEngine google = { "sourceid=chrome&ie={inputEncoding}", "UTF-8", "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}" - "client=chrome&hl={language}&q={searchTerms}", + "client=chrome&hl={language}&q={searchTerms}&" + "sugkey={google:suggestAPIKeyParameter}", "{google:baseURL}webhp?sourceid=chrome-instant&{google:RLZ}" "{google:instantEnabledParameter}ie={inputEncoding}", SEARCH_ENGINE_GOOGLE, @@ -3328,7 +3329,7 @@ void RegisterUserPrefs(PrefService* prefs) { int GetDataVersion(PrefService* prefs) { // Increment this if you change the above data in ways that mean users with // existing data should get a new version. - const int kCurrentDataVersion = 42; + const int kCurrentDataVersion = 43; // Allow tests to override the local version. return (prefs && prefs->HasPrefPath(prefs::kSearchProviderOverridesVersion)) ? prefs->GetInteger(prefs::kSearchProviderOverridesVersion) : |