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.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/browser/search_engines/template_url_fetcher.h" | 9 #include "chrome/browser/search_engines/template_url_fetcher.h" |
10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 10 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 if (current_url) { | 165 if (current_url) { |
166 if (current_url->originating_url().is_valid()) { | 166 if (current_url->originating_url().is_valid()) { |
167 // The existing keyword was generated from an OpenSearch description | 167 // The existing keyword was generated from an OpenSearch description |
168 // document, don't regenerate. | 168 // document, don't regenerate. |
169 return; | 169 return; |
170 } | 170 } |
171 url_service->Remove(current_url); | 171 url_service->Remove(current_url); |
172 } | 172 } |
173 | 173 |
174 TemplateURL* new_url = new TemplateURL(); | 174 TemplateURLData data; |
175 new_url->set_short_name(keyword); | 175 data.short_name = keyword; |
176 new_url->set_keyword(keyword); | 176 data.SetKeyword(keyword); |
177 new_url->set_safe_for_autoreplace(true); | 177 data.SetURL(url.spec()); |
178 new_url->add_input_encoding(params.searchable_form_encoding); | |
179 DCHECK(controller.GetLastCommittedEntry()); | 178 DCHECK(controller.GetLastCommittedEntry()); |
180 const GURL& current_favicon = | 179 const GURL& current_favicon = |
181 controller.GetLastCommittedEntry()->GetFavicon().url; | 180 controller.GetLastCommittedEntry()->GetFavicon().url; |
182 // If the favicon url isn't valid, it means there really isn't a favicon, or | 181 // If the favicon url isn't valid, it means there really isn't a favicon, or |
183 // the favicon url wasn't obtained before the load started. This assumes the | 182 // the favicon url wasn't obtained before the load started. This assumes the |
184 // latter. | 183 // latter. |
185 // TODO(sky): Need a way to set the favicon that doesn't involve generating | 184 // TODO(sky): Need a way to set the favicon that doesn't involve generating |
186 // its url. | 185 // its url. |
187 const GURL& favicon_url = current_favicon.is_valid() ? | 186 data.favicon_url = current_favicon.is_valid() ? |
188 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); | 187 current_favicon : TemplateURL::GenerateFaviconURL(params.referrer.url); |
189 new_url->SetURL(url.spec()); | 188 data.safe_for_autoreplace = true; |
190 new_url->set_favicon_url(favicon_url); | 189 data.input_encodings.push_back(params.searchable_form_encoding); |
191 url_service->Add(new_url); | 190 url_service->Add(new TemplateURL(data)); |
192 } | 191 } |
OLD | NEW |