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

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

Issue 7558014: Add a URL param to indicate group selection in Instant field trial. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_service.h" 5 #include "chrome/browser/search_engines/template_url_service.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 // Remove leading "www.". 183 // Remove leading "www.".
184 result = net::StripWWW(result); 184 result = net::StripWWW(result);
185 185
186 // Remove trailing "/". 186 // Remove trailing "/".
187 return (result.length() > 0 && result[result.length() - 1] == '/') ? 187 return (result.length() > 0 && result[result.length() - 1] == '/') ?
188 result.substr(0, result.length() - 1) : result; 188 result.substr(0, result.length() - 1) : result;
189 } 189 }
190 190
191 // static 191 // static
192 GURL TemplateURLService::GenerateSearchURL(const TemplateURL* t_url) { 192 GURL TemplateURLService::GenerateSearchURL(Profile* profile,
193 const TemplateURL* t_url) {
193 DCHECK(t_url); 194 DCHECK(t_url);
194 UIThreadSearchTermsData search_terms_data; 195 UIThreadSearchTermsData search_terms_data;
195 return GenerateSearchURLUsingTermsData(t_url, search_terms_data); 196 return GenerateSearchURLUsingTermsData(profile, t_url, search_terms_data);
196 } 197 }
197 198
198 // static 199 // static
199 GURL TemplateURLService::GenerateSearchURLUsingTermsData( 200 GURL TemplateURLService::GenerateSearchURLUsingTermsData(
201 Profile* profile,
200 const TemplateURL* t_url, 202 const TemplateURL* t_url,
201 const SearchTermsData& search_terms_data) { 203 const SearchTermsData& search_terms_data) {
202 DCHECK(t_url); 204 DCHECK(t_url);
203 const TemplateURLRef* search_ref = t_url->url(); 205 const TemplateURLRef* search_ref = t_url->url();
204 // Extension keywords don't have host-based search URLs. 206 // Extension keywords don't have host-based search URLs.
205 if (!search_ref || !search_ref->IsValidUsingTermsData(search_terms_data) || 207 if (!search_ref || !search_ref->IsValidUsingTermsData(search_terms_data) ||
206 t_url->IsExtensionKeyword()) 208 t_url->IsExtensionKeyword())
207 return GURL(); 209 return GURL();
208 210
209 if (!search_ref->SupportsReplacementUsingTermsData(search_terms_data)) 211 if (!search_ref->SupportsReplacementUsingTermsData(search_terms_data))
210 return GURL(search_ref->url()); 212 return GURL(search_ref->url());
211 213
212 return GURL(search_ref->ReplaceSearchTermsUsingTermsData( 214 return GURL(search_ref->ReplaceSearchTermsUsingTermsData(
213 *t_url, ASCIIToUTF16(kReplacementTerm), 215 profile, *t_url, ASCIIToUTF16(kReplacementTerm),
214 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, 216 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE,
215 string16(), search_terms_data)); 217 string16(), search_terms_data));
216 } 218 }
217 219
218 bool TemplateURLService::CanReplaceKeyword( 220 bool TemplateURLService::CanReplaceKeyword(
219 const string16& keyword, 221 const string16& keyword,
220 const GURL& url, 222 const GURL& url,
221 const TemplateURL** template_url_to_replace) { 223 const TemplateURL** template_url_to_replace) {
222 DCHECK(!keyword.empty()); // This should only be called for non-empty 224 DCHECK(!keyword.empty()); // This should only be called for non-empty
223 // keywords. If we need to support empty kewords 225 // keywords. If we need to support empty kewords
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 1325
1324 i = template_urls->erase(i); 1326 i = template_urls->erase(i);
1325 if (service_.get()) 1327 if (service_.get())
1326 service_->RemoveKeyword(*template_url); 1328 service_->RemoveKeyword(*template_url);
1327 delete template_url; 1329 delete template_url;
1328 } else { 1330 } else {
1329 ++i; 1331 ++i;
1330 } 1332 }
1331 } 1333 }
1332 } 1334 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698