OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/template_url_model.h" | 5 #include "chrome/browser/search_engines/template_url_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // static | 189 // static |
190 GURL TemplateURLModel::GenerateSearchURL(const TemplateURL* t_url) { | 190 GURL TemplateURLModel::GenerateSearchURL(const TemplateURL* t_url) { |
191 DCHECK(t_url); | 191 DCHECK(t_url); |
192 const TemplateURLRef* search_ref = t_url->url(); | 192 const TemplateURLRef* search_ref = t_url->url(); |
193 if (!search_ref || !search_ref->IsValid()) | 193 if (!search_ref || !search_ref->IsValid()) |
194 return GURL(); | 194 return GURL(); |
195 | 195 |
196 if (!search_ref->SupportsReplacement()) | 196 if (!search_ref->SupportsReplacement()) |
197 return GURL(WideToUTF8(search_ref->url())); | 197 return GURL(WideToUTF8(search_ref->url())); |
198 | 198 |
199 return search_ref->ReplaceSearchTerms( | 199 return GURL(WideToUTF8(search_ref->ReplaceSearchTerms( |
200 *t_url, | 200 *t_url, kReplacementTerm, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
201 kReplacementTerm, | 201 std::wstring()))); |
202 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()); | |
203 } | 202 } |
204 | 203 |
205 bool TemplateURLModel::CanReplaceKeyword( | 204 bool TemplateURLModel::CanReplaceKeyword( |
206 const std::wstring& keyword, | 205 const std::wstring& keyword, |
207 const std::wstring& url, | 206 const std::wstring& url, |
208 const TemplateURL** template_url_to_replace) { | 207 const TemplateURL** template_url_to_replace) { |
209 DCHECK(!keyword.empty()); // This should only be called for non-empty | 208 DCHECK(!keyword.empty()); // This should only be called for non-empty |
210 // keywords. If we need to support empty kewords | 209 // keywords. If we need to support empty kewords |
211 // the code needs to change slightly. | 210 // the code needs to change slightly. |
212 const TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); | 211 const TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1002 AddToMaps(t_url); | 1001 AddToMaps(t_url); |
1003 something_changed = true; | 1002 something_changed = true; |
1004 } | 1003 } |
1005 } | 1004 } |
1006 | 1005 |
1007 if (something_changed && loaded_) { | 1006 if (something_changed && loaded_) { |
1008 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, | 1007 FOR_EACH_OBSERVER(TemplateURLModelObserver, model_observers_, |
1009 OnTemplateURLModelChanged()); | 1008 OnTemplateURLModelChanged()); |
1010 } | 1009 } |
1011 } | 1010 } |
OLD | NEW |