Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/search_engines/template_url_prepopulate_data.cc

Issue 10537154: A working implementation of AQS (Assisted Query Stats). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Removed SupportsAssistedQueryStats. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
6 6
7 #if defined(OS_POSIX) && !defined(OS_MACOSX) 7 #if defined(OS_POSIX) && !defined(OS_MACOSX)
8 #include <locale.h> 8 #include <locale.h>
9 #endif 9 #endif
10 10
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 SEARCH_ENGINE_GOO, 1084 SEARCH_ENGINE_GOO,
1085 23, 1085 23,
1086 }; 1086 };
1087 1087
1088 const PrepopulatedEngine google = { 1088 const PrepopulatedEngine google = {
1089 L"Google", 1089 L"Google",
1090 L"google.com", // This will be dynamically updated by the TemplateURL system. 1090 L"google.com", // This will be dynamically updated by the TemplateURL system.
1091 "http://www.google.com/favicon.ico", 1091 "http://www.google.com/favicon.ico",
1092 "{google:baseURL}search?q={searchTerms}&{google:RLZ}" 1092 "{google:baseURL}search?q={searchTerms}&{google:RLZ}"
1093 "{google:acceptedSuggestion}{google:originalQueryForSuggestion}" 1093 "{google:acceptedSuggestion}{google:originalQueryForSuggestion}"
1094 "{google:assistedQueryStats}"
Peter Kasting 2012/06/16 03:14:17 Nit: I'd probably wrap after the "search field tri
Bart N 2012/06/16 23:38:10 Done.
1094 "{google:searchFieldtrialParameter}sourceid=chrome&ie={inputEncoding}", 1095 "{google:searchFieldtrialParameter}sourceid=chrome&ie={inputEncoding}",
1095 "UTF-8", 1096 "UTF-8",
1096 "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}" 1097 "{google:baseSuggestURL}search?{google:searchFieldtrialParameter}"
1097 "client=chrome&hl={language}&q={searchTerms}", 1098 "client=chrome&hl={language}&q={searchTerms}",
1098 "{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&" 1099 "{google:baseURL}webhp?{google:RLZ}sourceid=chrome-instant&"
1099 "ie={inputEncoding}{google:instantEnabledParameter}{searchTerms}", 1100 "ie={inputEncoding}{google:instantEnabledParameter}{searchTerms}",
1100 SEARCH_ENGINE_GOOGLE, 1101 SEARCH_ENGINE_GOOGLE,
1101 1, 1102 1,
1102 }; 1103 };
1103 1104
(...skipping 2170 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 PrefService::UNSYNCABLE_PREF); 3275 PrefService::UNSYNCABLE_PREF);
3275 // Obsolete pref, for migration. 3276 // Obsolete pref, for migration.
3276 prefs->RegisterIntegerPref(prefs::kGeoIDAtInstall, 3277 prefs->RegisterIntegerPref(prefs::kGeoIDAtInstall,
3277 -1, 3278 -1,
3278 PrefService::UNSYNCABLE_PREF); 3279 PrefService::UNSYNCABLE_PREF);
3279 } 3280 }
3280 3281
3281 int GetDataVersion(PrefService* prefs) { 3282 int GetDataVersion(PrefService* prefs) {
3282 // Increment this if you change the above data in ways that mean users with 3283 // Increment this if you change the above data in ways that mean users with
3283 // existing data should get a new version. 3284 // existing data should get a new version.
3284 const int kCurrentDataVersion = 39; 3285 const int kCurrentDataVersion = 40;
3285 // Allow tests to override the local version. 3286 // Allow tests to override the local version.
3286 return (prefs && prefs->HasPrefPath(prefs::kSearchProviderOverridesVersion)) ? 3287 return (prefs && prefs->HasPrefPath(prefs::kSearchProviderOverridesVersion)) ?
3287 prefs->GetInteger(prefs::kSearchProviderOverridesVersion) : 3288 prefs->GetInteger(prefs::kSearchProviderOverridesVersion) :
3288 kCurrentDataVersion; 3289 kCurrentDataVersion;
3289 } 3290 }
3290 3291
3291 TemplateURL* MakePrepopulatedTemplateURL(Profile* profile, 3292 TemplateURL* MakePrepopulatedTemplateURL(Profile* profile,
3292 const string16& name, 3293 const string16& name,
3293 const string16& keyword, 3294 const string16& keyword,
3294 const base::StringPiece& search_url, 3295 const base::StringPiece& search_url,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 BrowserThread::CurrentlyOn(BrowserThread::UI)); 3409 BrowserThread::CurrentlyOn(BrowserThread::UI));
3409 3410
3410 // We may get a valid URL, or we may get the Google prepopulate URL which 3411 // We may get a valid URL, or we may get the Google prepopulate URL which
3411 // can't be converted directly to a GURL. To handle the latter, we first 3412 // can't be converted directly to a GURL. To handle the latter, we first
3412 // construct a TemplateURL from the provided |url|, then call 3413 // construct a TemplateURL from the provided |url|, then call
3413 // ReplaceSearchTerms(). This should return a valid URL even when the input 3414 // ReplaceSearchTerms(). This should return a valid URL even when the input
3414 // has Google base URLs. 3415 // has Google base URLs.
3415 TemplateURLData data; 3416 TemplateURLData data;
3416 data.SetURL(url); 3417 data.SetURL(url);
3417 TemplateURL turl(NULL, data); 3418 TemplateURL turl(NULL, data);
3418 GURL as_gurl(turl.url_ref().ReplaceSearchTerms(ASCIIToUTF16("x"), 3419 GURL as_gurl(turl.url_ref().ReplaceSearchTerms(
3419 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); 3420 SearchTermsArgs(ASCIIToUTF16("x"))));
3420 if (!as_gurl.is_valid()) 3421 if (!as_gurl.is_valid())
3421 return SEARCH_ENGINE_OTHER; 3422 return SEARCH_ENGINE_OTHER;
3422 3423
3423 // Check using origins, in order to more aggressively match search engine 3424 // Check using origins, in order to more aggressively match search engine
3424 // types for data imported from other browsers. 3425 // types for data imported from other browsers.
3425 // 3426 //
3426 // First special-case Google, because the prepopulate URL for it will not 3427 // First special-case Google, because the prepopulate URL for it will not
3427 // convert to a GURL and thus won't have an origin. Instead see if the 3428 // convert to a GURL and thus won't have an origin. Instead see if the
3428 // incoming URL's host is "[*.]google.<TLD>". 3429 // incoming URL's host is "[*.]google.<TLD>".
3429 if (google_util::IsGoogleHostname(as_gurl.host(), 3430 if (google_util::IsGoogleHostname(as_gurl.host(),
3430 google_util::DISALLOW_SUBDOMAIN)) 3431 google_util::DISALLOW_SUBDOMAIN))
3431 return google.type; 3432 return google.type;
3432 3433
3433 // Now check the rest of the prepopulate data. 3434 // Now check the rest of the prepopulate data.
3434 GURL origin(as_gurl.GetOrigin()); 3435 GURL origin(as_gurl.GetOrigin());
3435 for (size_t i = 0; i < arraysize(kAllEngines); ++i) { 3436 for (size_t i = 0; i < arraysize(kAllEngines); ++i) {
3436 GURL engine_url(kAllEngines[i]->search_url); 3437 GURL engine_url(kAllEngines[i]->search_url);
3437 if (engine_url.is_valid() && (origin == engine_url.GetOrigin())) 3438 if (engine_url.is_valid() && (origin == engine_url.GetOrigin()))
3438 return kAllEngines[i]->type; 3439 return kAllEngines[i]->type;
3439 } 3440 }
3440 3441
3441 return SEARCH_ENGINE_OTHER; 3442 return SEARCH_ENGINE_OTHER;
3442 } 3443 }
3443 3444
3444 } // namespace TemplateURLPrepopulateData 3445 } // namespace TemplateURLPrepopulateData
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698