OLD | NEW |
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::GenerateSearchURL(template_url, | 182 template_url->GenerateSearchURL(search_terms_data).GetOrigin(); |
183 search_terms_data).GetOrigin(); | |
184 } | 183 } |
185 | 184 |
186 } // namespace | 185 } // namespace |
187 | 186 |
188 SearchProviderInstallData::SearchProviderInstallData( | 187 SearchProviderInstallData::SearchProviderInstallData( |
189 Profile* profile, | 188 Profile* profile, |
190 content::RenderProcessHost* host) | 189 content::RenderProcessHost* host) |
191 : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)), | 190 : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)), |
192 google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()), | 191 google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()), |
193 weak_factory_(this) { | 192 weak_factory_(this) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
278 | 277 |
279 if (!template_url) { | 278 if (!template_url) { |
280 default_search_origin_.clear(); | 279 default_search_origin_.clear(); |
281 return; | 280 return; |
282 } | 281 } |
283 | 282 |
284 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); | 283 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); |
285 | 284 |
286 IOThreadSearchTermsData search_terms_data(google_base_url_); | 285 IOThreadSearchTermsData search_terms_data(google_base_url_); |
287 const GURL url(TemplateURLService::GenerateSearchURL( | 286 const GURL url(template_url->GenerateSearchURL(search_terms_data)); |
288 template_url, search_terms_data)); | |
289 if (!url.is_valid() || !url.has_host()) { | 287 if (!url.is_valid() || !url.has_host()) { |
290 default_search_origin_.clear(); | 288 default_search_origin_.clear(); |
291 return; | 289 return; |
292 } | 290 } |
293 default_search_origin_ = url.GetOrigin().spec(); | 291 default_search_origin_ = url.GetOrigin().spec(); |
294 } | 292 } |
295 | 293 |
296 void SearchProviderInstallData::OnLoadFailed() { | 294 void SearchProviderInstallData::OnLoadFailed() { |
297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
298 | 296 |
(...skipping 12 matching lines...) Expand all Loading... |
311 | 309 |
312 std::for_each(closure_queue.begin(), | 310 std::for_each(closure_queue.begin(), |
313 closure_queue.end(), | 311 closure_queue.end(), |
314 std::mem_fun_ref(&base::Closure::Run)); | 312 std::mem_fun_ref(&base::Closure::Run)); |
315 | 313 |
316 // Since we expect this request to be rare, clear out the information. This | 314 // Since we expect this request to be rare, clear out the information. This |
317 // also keeps the responses current as the search providers change. | 315 // also keeps the responses current as the search providers change. |
318 provider_map_.reset(); | 316 provider_map_.reset(); |
319 SetDefault(NULL); | 317 SetDefault(NULL); |
320 } | 318 } |
OLD | NEW |