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

Side by Side Diff: chrome/browser/search_engines/search_provider_install_data.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/search_provider_install_data.h" 5 #include "chrome/browser/search_engines/search_provider_install_data.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // Indicates if the two inputs have the same security origin. 148 // Indicates if the two inputs have the same security origin.
149 // |requested_origin| should only be a security origin (no path, etc.). 149 // |requested_origin| should only be a security origin (no path, etc.).
150 // It is ok if |template_url| is NULL. 150 // It is ok if |template_url| is NULL.
151 static bool IsSameOrigin(const GURL& requested_origin, 151 static bool IsSameOrigin(const GURL& requested_origin,
152 const TemplateURL* template_url, 152 const TemplateURL* template_url,
153 const SearchTermsData& search_terms_data) { 153 const SearchTermsData& search_terms_data) {
154 DCHECK(requested_origin == requested_origin.GetOrigin()); 154 DCHECK(requested_origin == requested_origin.GetOrigin());
155 return template_url && requested_origin == 155 return template_url && requested_origin ==
156 TemplateURLService::GenerateSearchURLUsingTermsData( 156 TemplateURLService::GenerateSearchURLUsingTermsData(
157 NULL,
157 template_url, 158 template_url,
158 search_terms_data).GetOrigin(); 159 search_terms_data).GetOrigin();
159 } 160 }
160 161
161 } // namespace 162 } // namespace
162 163
163 SearchProviderInstallData::SearchProviderInstallData( 164 SearchProviderInstallData::SearchProviderInstallData(
164 WebDataService* web_service, 165 WebDataService* web_service,
165 int ui_death_notification, 166 int ui_death_notification,
166 const NotificationSource& ui_death_source) 167 const NotificationSource& ui_death_source)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) { 271 void SearchProviderInstallData::SetDefault(const TemplateURL* template_url) {
271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
272 273
273 if (!template_url) { 274 if (!template_url) {
274 default_search_origin_.clear(); 275 default_search_origin_.clear();
275 return; 276 return;
276 } 277 }
277 278
278 IOThreadSearchTermsData search_terms_data(google_base_url_); 279 IOThreadSearchTermsData search_terms_data(google_base_url_);
279 const GURL url(TemplateURLService::GenerateSearchURLUsingTermsData( 280 const GURL url(TemplateURLService::GenerateSearchURLUsingTermsData(
280 template_url, search_terms_data)); 281 NULL, template_url, search_terms_data));
281 if (!url.is_valid() || !url.has_host()) { 282 if (!url.is_valid() || !url.has_host()) {
282 default_search_origin_.clear(); 283 default_search_origin_.clear();
283 return; 284 return;
284 } 285 }
285 default_search_origin_ = url.GetOrigin().spec(); 286 default_search_origin_ = url.GetOrigin().spec();
286 } 287 }
287 288
288 void SearchProviderInstallData::OnLoadFailed() { 289 void SearchProviderInstallData::OnLoadFailed() {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 290 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
290 291
291 provider_map_.reset(new SearchHostToURLsMap()); 292 provider_map_.reset(new SearchHostToURLsMap());
292 IOThreadSearchTermsData search_terms_data(google_base_url_); 293 IOThreadSearchTermsData search_terms_data(google_base_url_);
293 provider_map_->Init(template_urls_.get(), search_terms_data); 294 provider_map_->Init(template_urls_.get(), search_terms_data);
294 SetDefault(NULL); 295 SetDefault(NULL);
295 NotifyLoaded(); 296 NotifyLoaded();
296 } 297 }
297 298
298 void SearchProviderInstallData::NotifyLoaded() { 299 void SearchProviderInstallData::NotifyLoaded() {
299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 300 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
300 301
301 task_queue_.Run(); 302 task_queue_.Run();
302 303
303 // Since we expect this request to be rare, clear out the information. This 304 // Since we expect this request to be rare, clear out the information. This
304 // also keeps the responses current as the search providers change. 305 // also keeps the responses current as the search providers change.
305 provider_map_.reset(); 306 provider_map_.reset();
306 SetDefault(NULL); 307 SetDefault(NULL);
307 } 308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698