| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/search_engines/template_url.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 | 554 |
| 555 void TemplateURL::SetURL(const std::string& url, | 555 void TemplateURL::SetURL(const std::string& url, |
| 556 int index_offset, | 556 int index_offset, |
| 557 int page_offset) { | 557 int page_offset) { |
| 558 url_.Set(url, index_offset, page_offset); | 558 url_.Set(url, index_offset, page_offset); |
| 559 } | 559 } |
| 560 | 560 |
| 561 void TemplateURL::set_keyword(const std::wstring& keyword) { | 561 void TemplateURL::set_keyword(const std::wstring& keyword) { |
| 562 // Case sensitive keyword matching is confusing. As such, we force all | 562 // Case sensitive keyword matching is confusing. As such, we force all |
| 563 // keywords to be lower case. | 563 // keywords to be lower case. |
| 564 keyword_ = l10n_util::ToLower(keyword); | 564 keyword_ = UTF16ToWide(l10n_util::ToLower(WideToUTF16(keyword))); |
| 565 autogenerate_keyword_ = false; | 565 autogenerate_keyword_ = false; |
| 566 } | 566 } |
| 567 | 567 |
| 568 const std::wstring& TemplateURL::keyword() const { | 568 const std::wstring& TemplateURL::keyword() const { |
| 569 if (autogenerate_keyword_ && !keyword_generated_) { | 569 if (autogenerate_keyword_ && !keyword_generated_) { |
| 570 // Generate a keyword and cache it. | 570 // Generate a keyword and cache it. |
| 571 keyword_ = TemplateURLModel::GenerateKeyword( | 571 keyword_ = TemplateURLModel::GenerateKeyword( |
| 572 TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); | 572 TemplateURLModel::GenerateSearchURL(this).GetWithEmptyPath(), true); |
| 573 keyword_generated_ = true; | 573 keyword_generated_ = true; |
| 574 } | 574 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 } | 620 } |
| 621 | 621 |
| 622 std::string TemplateURL::GetExtensionId() const { | 622 std::string TemplateURL::GetExtensionId() const { |
| 623 DCHECK(IsExtensionKeyword()); | 623 DCHECK(IsExtensionKeyword()); |
| 624 return GURL(url_.url()).host(); | 624 return GURL(url_.url()).host(); |
| 625 } | 625 } |
| 626 | 626 |
| 627 bool TemplateURL::IsExtensionKeyword() const { | 627 bool TemplateURL::IsExtensionKeyword() const { |
| 628 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); | 628 return GURL(url_.url()).SchemeIs(chrome::kExtensionScheme); |
| 629 } | 629 } |
| OLD | NEW |