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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 data.SetKeyword(keyword); | 207 data.SetKeyword(keyword); |
208 data.SetURL(url.spec()); | 208 data.SetURL(url.spec()); |
209 DCHECK(controller.GetLastCommittedEntry()); | 209 DCHECK(controller.GetLastCommittedEntry()); |
210 const GURL& current_favicon = | 210 const GURL& current_favicon = |
211 controller.GetLastCommittedEntry()->GetFavicon().url; | 211 controller.GetLastCommittedEntry()->GetFavicon().url; |
212 // If the favicon url isn't valid, it means there really isn't a favicon, or | 212 // If the favicon url isn't valid, it means there really isn't a favicon, or |
213 // the favicon url wasn't obtained before the load started. This assumes the | 213 // the favicon url wasn't obtained before the load started. This assumes the |
214 // latter. | 214 // latter. |
215 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 215 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
216 // its url. | 216 // its url. |
217 data.favicon_url = | 217 if (current_favicon.is_valid()) { |
218 current_favicon.is_valid() | 218 data.favicon_url = current_favicon; |
219 ? current_favicon | 219 } else if (handle->GetReferrer().url.is_valid()) { |
220 : TemplateURL::GenerateFaviconURL(handle->GetReferrer().url); | 220 data.favicon_url = |
| 221 TemplateURL::GenerateFaviconURL(handle->GetReferrer().url); |
| 222 } |
221 data.safe_for_autoreplace = true; | 223 data.safe_for_autoreplace = true; |
222 data.input_encodings.push_back(handle->GetSearchableFormEncoding()); | 224 data.input_encodings.push_back(handle->GetSearchableFormEncoding()); |
223 url_service->Add(base::MakeUnique<TemplateURL>(data)); | 225 url_service->Add(base::MakeUnique<TemplateURL>(data)); |
224 } | 226 } |
OLD | NEW |