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

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

Issue 338363004: Remove Profile* from TemplateURL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/search_provider_install_data.h" 5 #include "chrome/browser/search_engines/search_provider_install_data.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 27 matching lines...) Expand all
38 ScopedVector<TemplateURL> template_url_copies; 38 ScopedVector<TemplateURL> template_url_copies;
39 TemplateURL* default_provider_copy = NULL; 39 TemplateURL* default_provider_copy = NULL;
40 TemplateURLService::TemplateURLVector original_template_urls = 40 TemplateURLService::TemplateURLVector original_template_urls =
41 template_url_service->GetTemplateURLs(); 41 template_url_service->GetTemplateURLs();
42 TemplateURL* original_default_provider = 42 TemplateURL* original_default_provider =
43 template_url_service->GetDefaultSearchProvider(); 43 template_url_service->GetDefaultSearchProvider();
44 for (TemplateURLService::TemplateURLVector::const_iterator it = 44 for (TemplateURLService::TemplateURLVector::const_iterator it =
45 original_template_urls.begin(); 45 original_template_urls.begin();
46 it != original_template_urls.end(); 46 it != original_template_urls.end();
47 ++it) { 47 ++it) {
48 template_url_copies.push_back(new TemplateURL(NULL, (*it)->data())); 48 template_url_copies.push_back(new TemplateURL((*it)->data()));
49 if (*it == original_default_provider) 49 if (*it == original_default_provider)
50 default_provider_copy = template_url_copies.back(); 50 default_provider_copy = template_url_copies.back();
51 } 51 }
52 BrowserThread::PostTask(BrowserThread::IO, 52 BrowserThread::PostTask(BrowserThread::IO,
53 FROM_HERE, 53 FROM_HERE,
54 base::Bind(callback, 54 base::Bind(callback,
55 base::Passed(template_url_copies.Pass()), 55 base::Passed(template_url_copies.Pass()),
56 base::Unretained(default_provider_copy))); 56 base::Unretained(default_provider_copy)));
57 } 57 }
58 58
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 // Indicates if the two inputs have the same security origin. 173 // Indicates if the two inputs have the same security origin.
174 // |requested_origin| should only be a security origin (no path, etc.). 174 // |requested_origin| should only be a security origin (no path, etc.).
175 // It is ok if |template_url| is NULL. 175 // It is ok if |template_url| is NULL.
176 static bool IsSameOrigin(const GURL& requested_origin, 176 static bool IsSameOrigin(const GURL& requested_origin,
177 TemplateURL* template_url, 177 TemplateURL* template_url,
178 const SearchTermsData& search_terms_data) { 178 const SearchTermsData& search_terms_data) {
179 DCHECK(requested_origin == requested_origin.GetOrigin()); 179 DCHECK(requested_origin == requested_origin.GetOrigin());
180 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); 180 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION);
181 return requested_origin == 181 return requested_origin ==
182 TemplateURLService::GenerateSearchURLUsingTermsData(template_url, 182 TemplateURLService::GenerateSearchURL(template_url,
183 search_terms_data).GetOrigin(); 183 search_terms_data).GetOrigin();
184 } 184 }
185 185
186 } // namespace 186 } // namespace
187 187
188 SearchProviderInstallData::SearchProviderInstallData( 188 SearchProviderInstallData::SearchProviderInstallData(
189 Profile* profile, 189 Profile* profile,
190 content::RenderProcessHost* host) 190 content::RenderProcessHost* host)
191 : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)), 191 : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)),
192 google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()), 192 google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()),
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
278 278
279 if (!template_url) { 279 if (!template_url) {
280 default_search_origin_.clear(); 280 default_search_origin_.clear();
281 return; 281 return;
282 } 282 }
283 283
284 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); 284 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION);
285 285
286 IOThreadSearchTermsData search_terms_data(google_base_url_); 286 IOThreadSearchTermsData search_terms_data(google_base_url_);
287 const GURL url(TemplateURLService::GenerateSearchURLUsingTermsData( 287 const GURL url(TemplateURLService::GenerateSearchURL(
288 template_url, search_terms_data)); 288 template_url, search_terms_data));
289 if (!url.is_valid() || !url.has_host()) { 289 if (!url.is_valid() || !url.has_host()) {
290 default_search_origin_.clear(); 290 default_search_origin_.clear();
291 return; 291 return;
292 } 292 }
293 default_search_origin_ = url.GetOrigin().spec(); 293 default_search_origin_ = url.GetOrigin().spec();
294 } 294 }
295 295
296 void SearchProviderInstallData::OnLoadFailed() { 296 void SearchProviderInstallData::OnLoadFailed() {
297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
(...skipping 13 matching lines...) Expand all
311 311
312 std::for_each(closure_queue.begin(), 312 std::for_each(closure_queue.begin(),
313 closure_queue.end(), 313 closure_queue.end(),
314 std::mem_fun_ref(&base::Closure::Run)); 314 std::mem_fun_ref(&base::Closure::Run));
315 315
316 // Since we expect this request to be rare, clear out the information. This 316 // Since we expect this request to be rare, clear out the information. This
317 // also keeps the responses current as the search providers change. 317 // also keeps the responses current as the search providers change.
318 provider_map_.reset(); 318 provider_map_.reset();
319 SetDefault(NULL); 319 SetDefault(NULL);
320 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698