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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/sequenced_task_runner_helpers.h" | 16 #include "base/sequenced_task_runner_helpers.h" |
17 #include "chrome/browser/google/google_url_tracker_factory.h" | |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | |
19 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | |
20 #include "components/google/core/browser/google_url_tracker.h" | 17 #include "components/google/core/browser/google_url_tracker.h" |
21 #include "components/search_engines/search_host_to_urls_map.h" | 18 #include "components/search_engines/search_host_to_urls_map.h" |
| 19 #include "components/search_engines/search_terms_data.h" |
22 #include "components/search_engines/template_url.h" | 20 #include "components/search_engines/template_url.h" |
23 #include "components/search_engines/template_url_service.h" | 21 #include "components/search_engines/template_url_service.h" |
24 #include "components/search_engines/util.h" | 22 #include "components/search_engines/util.h" |
25 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
27 #include "content/public/browser/render_process_host_observer.h" | 25 #include "content/public/browser/render_process_host_observer.h" |
28 | 26 |
29 using content::BrowserThread; | 27 using content::BrowserThread; |
30 | 28 |
31 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; | 29 typedef SearchHostToURLsMap::TemplateURLSet TemplateURLSet; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 const SearchTermsData& search_terms_data) { | 172 const SearchTermsData& search_terms_data) { |
175 DCHECK(requested_origin == requested_origin.GetOrigin()); | 173 DCHECK(requested_origin == requested_origin.GetOrigin()); |
176 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); | 174 DCHECK(template_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION); |
177 return requested_origin == | 175 return requested_origin == |
178 template_url->GenerateSearchURL(search_terms_data).GetOrigin(); | 176 template_url->GenerateSearchURL(search_terms_data).GetOrigin(); |
179 } | 177 } |
180 | 178 |
181 } // namespace | 179 } // namespace |
182 | 180 |
183 SearchProviderInstallData::SearchProviderInstallData( | 181 SearchProviderInstallData::SearchProviderInstallData( |
184 Profile* profile, | 182 TemplateURLService* template_url_service, |
| 183 const std::string& google_base_url, |
| 184 GoogleURLTracker* google_url_tracker, |
185 content::RenderProcessHost* host) | 185 content::RenderProcessHost* host) |
186 : template_url_service_(TemplateURLServiceFactory::GetForProfile(profile)), | 186 : template_url_service_(template_url_service), |
187 google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()), | 187 google_base_url_(google_base_url), |
188 weak_factory_(this) { | 188 weak_factory_(this) { |
189 // GoogleURLTracker is not created in tests. | 189 // GoogleURLTracker is not created in tests. |
190 GoogleURLTracker* google_url_tracker = | |
191 GoogleURLTrackerFactory::GetForProfile(profile); | |
192 if (google_url_tracker) { | 190 if (google_url_tracker) { |
193 // GoogleURLObserver is responsible for killing itself when | 191 // GoogleURLObserver is responsible for killing itself when |
194 // the given notification occurs. | 192 // the given notification occurs. |
195 new GoogleURLObserver( | 193 new GoogleURLObserver( |
196 google_url_tracker, | 194 google_url_tracker, |
197 new GoogleURLChangeNotifier(weak_factory_.GetWeakPtr()), | 195 new GoogleURLChangeNotifier(weak_factory_.GetWeakPtr()), |
198 host); | 196 host); |
199 } | 197 } |
200 } | 198 } |
201 | 199 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |