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/ui/search_engines/search_engine_tab_helper.h" | 5 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 9 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 // new keyword will be created when done. | 170 // new keyword will be created when done. |
171 TemplateURLFetcherFactory::GetForProfile(profile)->ScheduleDownload( | 171 TemplateURLFetcherFactory::GetForProfile(profile)->ScheduleDownload( |
172 keyword, osdd_url, entry->GetFavicon().url, | 172 keyword, osdd_url, entry->GetFavicon().url, |
173 base::Bind(&AssociateURLFetcherWithWebContents, web_contents()), | 173 base::Bind(&AssociateURLFetcherWithWebContents, web_contents()), |
174 base::Bind(&SearchEngineTabHelper::OnDownloadedOSDD, | 174 base::Bind(&SearchEngineTabHelper::OnDownloadedOSDD, |
175 weak_ptr_factory_.GetWeakPtr()), | 175 weak_ptr_factory_.GetWeakPtr()), |
176 provider_type); | 176 provider_type); |
177 } | 177 } |
178 | 178 |
179 void SearchEngineTabHelper::OnDownloadedOSDD( | 179 void SearchEngineTabHelper::OnDownloadedOSDD( |
180 scoped_ptr<TemplateURL> template_url) { | 180 std::unique_ptr<TemplateURL> template_url) { |
181 Profile* profile = | 181 Profile* profile = |
182 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 182 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
183 delegate_->ConfirmAddSearchProvider(template_url.release(), profile); | 183 delegate_->ConfirmAddSearchProvider(template_url.release(), profile); |
184 } | 184 } |
185 | 185 |
186 void SearchEngineTabHelper::GenerateKeywordIfNecessary( | 186 void SearchEngineTabHelper::GenerateKeywordIfNecessary( |
187 const content::FrameNavigateParams& params) { | 187 const content::FrameNavigateParams& params) { |
188 if (!params.searchable_form_url.is_valid()) | 188 if (!params.searchable_form_url.is_valid()) |
189 return; | 189 return; |
190 | 190 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // the favicon url wasn't obtained before the load started. This assumes the | 242 // the favicon url wasn't obtained before the load started. This assumes the |
243 // latter. | 243 // latter. |
244 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 244 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
245 // its url. | 245 // its url. |
246 data.favicon_url = current_favicon.is_valid() ? | 246 data.favicon_url = current_favicon.is_valid() ? |
247 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 247 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
248 data.safe_for_autoreplace = true; | 248 data.safe_for_autoreplace = true; |
249 data.input_encodings.push_back(params.searchable_form_encoding); | 249 data.input_encodings.push_back(params.searchable_form_encoding); |
250 url_service->Add(new TemplateURL(data)); | 250 url_service->Add(new TemplateURL(data)); |
251 } | 251 } |
OLD | NEW |