| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 DCHECK(t_url); | 310 DCHECK(t_url); |
| 311 DCHECK(!t_url->IsExtensionKeyword()); | 311 DCHECK(!t_url->IsExtensionKeyword()); |
| 312 | 312 |
| 313 const TemplateURLRef& search_ref = t_url->url_ref(); | 313 const TemplateURLRef& search_ref = t_url->url_ref(); |
| 314 if (!search_ref.IsValidUsingTermsData(search_terms_data)) | 314 if (!search_ref.IsValidUsingTermsData(search_terms_data)) |
| 315 return GURL(); | 315 return GURL(); |
| 316 | 316 |
| 317 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data)) | 317 if (!search_ref.SupportsReplacementUsingTermsData(search_terms_data)) |
| 318 return GURL(t_url->url()); | 318 return GURL(t_url->url()); |
| 319 | 319 |
| 320 return GURL(search_ref.ReplaceSearchTermsUsingTermsData( | 320 GURL search_url(search_ref.ReplaceSearchTermsUsingTermsData( |
| 321 ASCIIToUTF16(kReplacementTerm), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 321 ASCIIToUTF16(kReplacementTerm), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
| 322 string16(), search_terms_data)); | 322 string16(), search_terms_data)); |
| 323 return search_url.is_valid() ? search_url : GURL(); |
| 323 } | 324 } |
| 324 | 325 |
| 325 bool TemplateURLService::CanReplaceKeyword( | 326 bool TemplateURLService::CanReplaceKeyword( |
| 326 const string16& keyword, | 327 const string16& keyword, |
| 327 const GURL& url, | 328 const GURL& url, |
| 328 TemplateURL** template_url_to_replace) { | 329 TemplateURL** template_url_to_replace) { |
| 329 DCHECK(!keyword.empty()); // This should only be called for non-empty | 330 DCHECK(!keyword.empty()); // This should only be called for non-empty |
| 330 // keywords. If we need to support empty kewords | 331 // keywords. If we need to support empty kewords |
| 331 // the code needs to change slightly. | 332 // the code needs to change slightly. |
| 332 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); | 333 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); |
| (...skipping 2048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2381 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2382 // TODO(mpcomplete): If we allow editing extension keywords, then those |
| 2382 // should be persisted to disk and synced. | 2383 // should be persisted to disk and synced. |
| 2383 if (template_url->sync_guid().empty() && | 2384 if (template_url->sync_guid().empty() && |
| 2384 !template_url->IsExtensionKeyword()) { | 2385 !template_url->IsExtensionKeyword()) { |
| 2385 template_url->data_.sync_guid = base::GenerateGUID(); | 2386 template_url->data_.sync_guid = base::GenerateGUID(); |
| 2386 if (service_.get()) | 2387 if (service_.get()) |
| 2387 service_->UpdateKeyword(template_url->data()); | 2388 service_->UpdateKeyword(template_url->data()); |
| 2388 } | 2389 } |
| 2389 } | 2390 } |
| 2390 } | 2391 } |
| OLD | NEW |