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/search_engines/template_url_service.h" | 5 #include "chrome/browser/search_engines/template_url_service.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 DCHECK(!t_url->IsExtensionKeyword()); | 308 DCHECK(!t_url->IsExtensionKeyword()); |
309 | 309 |
310 const TemplateURLRef& search_ref = t_url->url_ref(); | 310 const TemplateURLRef& search_ref = t_url->url_ref(); |
311 if (!search_ref.IsValidUsingTermsData(search_terms_data)) | 311 if (!search_ref.IsValidUsingTermsData(search_terms_data)) |
312 return GURL(); | 312 return GURL(); |
313 | 313 |
314 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data)) | 314 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data)) |
315 return GURL(t_url->url()); | 315 return GURL(t_url->url()); |
316 | 316 |
317 return GURL(search_ref.ReplaceSearchTermsUsingTermsData( | 317 return GURL(search_ref.ReplaceSearchTermsUsingTermsData( |
318 ASCIIToUTF16(kReplacementTerm), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 318 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16(kReplacementTerm)), |
319 string16(), search_terms_data)); | 319 search_terms_data)); |
320 } | 320 } |
321 | 321 |
322 bool TemplateURLService::CanReplaceKeyword( | 322 bool TemplateURLService::CanReplaceKeyword( |
323 const string16& keyword, | 323 const string16& keyword, |
324 const GURL& url, | 324 const GURL& url, |
325 TemplateURL** template_url_to_replace) { | 325 TemplateURL** template_url_to_replace) { |
326 DCHECK(!keyword.empty()); // This should only be called for non-empty | 326 DCHECK(!keyword.empty()); // This should only be called for non-empty |
327 // keywords. If we need to support empty kewords | 327 // keywords. If we need to support empty kewords |
328 // the code needs to change slightly. | 328 // the code needs to change slightly. |
329 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); | 329 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2376 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2376 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2377 // should be persisted to disk and synced. | 2377 // should be persisted to disk and synced. |
2378 if (template_url->sync_guid().empty() && | 2378 if (template_url->sync_guid().empty() && |
2379 !template_url->IsExtensionKeyword()) { | 2379 !template_url->IsExtensionKeyword()) { |
2380 template_url->data_.sync_guid = base::GenerateGUID(); | 2380 template_url->data_.sync_guid = base::GenerateGUID(); |
2381 if (service_.get()) | 2381 if (service_.get()) |
2382 service_->UpdateKeyword(template_url->data()); | 2382 service_->UpdateKeyword(template_url->data()); |
2383 } | 2383 } |
2384 } | 2384 } |
2385 } | 2385 } |
OLD | NEW |