| 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 "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 8 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
| 9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" | 10 #include "chrome/browser/ui/search_engines/search_engine_tab_helper_delegate.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (current_url) { | 207 if (current_url) { |
| 208 if (current_url->originating_url().is_valid()) { | 208 if (current_url->originating_url().is_valid()) { |
| 209 // The existing keyword was generated from an OpenSearch description | 209 // The existing keyword was generated from an OpenSearch description |
| 210 // document, don't regenerate. | 210 // document, don't regenerate. |
| 211 return; | 211 return; |
| 212 } | 212 } |
| 213 url_service->Remove(current_url); | 213 url_service->Remove(current_url); |
| 214 } | 214 } |
| 215 | 215 |
| 216 TemplateURLData data; | 216 TemplateURLData data; |
| 217 data.short_name = keyword; | 217 data.SetShortName(keyword); |
| 218 data.SetKeyword(keyword); | 218 data.SetKeyword(keyword); |
| 219 data.SetURL(url.spec()); | 219 data.SetURL(url.spec()); |
| 220 DCHECK(controller.GetLastCommittedEntry()); | 220 DCHECK(controller.GetLastCommittedEntry()); |
| 221 const GURL& current_favicon = | 221 const GURL& current_favicon = |
| 222 controller.GetLastCommittedEntry()->GetFavicon().url; | 222 controller.GetLastCommittedEntry()->GetFavicon().url; |
| 223 // If the favicon url isn't valid, it means there really isn't a favicon, or | 223 // If the favicon url isn't valid, it means there really isn't a favicon, or |
| 224 // the favicon url wasn't obtained before the load started. This assumes the | 224 // the favicon url wasn't obtained before the load started. This assumes the |
| 225 // latter. | 225 // latter. |
| 226 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 226 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
| 227 // its url. | 227 // its url. |
| 228 data.favicon_url = current_favicon.is_valid() ? | 228 data.favicon_url = current_favicon.is_valid() ? |
| 229 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 229 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
| 230 data.safe_for_autoreplace = true; | 230 data.safe_for_autoreplace = true; |
| 231 data.input_encodings.push_back(params.searchable_form_encoding); | 231 data.input_encodings.push_back(params.searchable_form_encoding); |
| 232 url_service->Add(new TemplateURL(data)); | 232 url_service->Add(new TemplateURL(data)); |
| 233 } | 233 } |
| OLD | NEW |