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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 return GURL(search_ref.ReplaceSearchTermsUsingTermsData( |
321 ASCIIToUTF16(kReplacementTerm), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 321 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16(kReplacementTerm)), |
322 string16(), search_terms_data)); | 322 search_terms_data)); |
323 } | 323 } |
324 | 324 |
325 bool TemplateURLService::CanReplaceKeyword( | 325 bool TemplateURLService::CanReplaceKeyword( |
326 const string16& keyword, | 326 const string16& keyword, |
327 const GURL& url, | 327 const GURL& url, |
328 TemplateURL** template_url_to_replace) { | 328 TemplateURL** template_url_to_replace) { |
329 DCHECK(!keyword.empty()); // This should only be called for non-empty | 329 DCHECK(!keyword.empty()); // This should only be called for non-empty |
330 // keywords. If we need to support empty kewords | 330 // keywords. If we need to support empty kewords |
331 // the code needs to change slightly. | 331 // the code needs to change slightly. |
332 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); | 332 TemplateURL* existing_url = GetTemplateURLForKeyword(keyword); |
(...skipping 2053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 // TODO(mpcomplete): If we allow editing extension keywords, then those | 2386 // TODO(mpcomplete): If we allow editing extension keywords, then those |
2387 // should be persisted to disk and synced. | 2387 // should be persisted to disk and synced. |
2388 if (template_url->sync_guid().empty() && | 2388 if (template_url->sync_guid().empty() && |
2389 !template_url->IsExtensionKeyword()) { | 2389 !template_url->IsExtensionKeyword()) { |
2390 template_url->data_.sync_guid = base::GenerateGUID(); | 2390 template_url->data_.sync_guid = base::GenerateGUID(); |
2391 if (service_.get()) | 2391 if (service_.get()) |
2392 service_->UpdateKeyword(template_url->data()); | 2392 service_->UpdateKeyword(template_url->data()); |
2393 } | 2393 } |
2394 } | 2394 } |
2395 } | 2395 } |
OLD | NEW |