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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
642 // |encoded_original_query|. |encoded_terms| may be escaped as path or query | 642 // |encoded_original_query|. |encoded_terms| may be escaped as path or query |
643 // depending on |is_in_query|; |encoded_original_query| is always escaped as | 643 // depending on |is_in_query|; |encoded_original_query| is always escaped as |
644 // query. | 644 // query. |
645 void EncodeSearchTerms( | 645 void EncodeSearchTerms( |
646 const TemplateURLRef::SearchTermsArgs& search_terms_args, | 646 const TemplateURLRef::SearchTermsArgs& search_terms_args, |
647 bool is_in_query, | 647 bool is_in_query, |
648 std::string* input_encoding, | 648 std::string* input_encoding, |
649 base::string16* encoded_terms, | 649 base::string16* encoded_terms, |
650 base::string16* encoded_original_query) const; | 650 base::string16* encoded_original_query) const; |
651 | 651 |
652 // Generates a suitable keyword for the specified url, which must be valid. | |
653 // This is guaranteed not to return an empty string, since TemplateURLs should | |
654 // never have an empty keyword. | |
655 static base::string16 GenerateKeyword(const GURL& url); | |
Peter Kasting
2014/06/19 00:17:49
Nit: Place this with the other static methods abov
hashimoto
2014/06/19 01:11:45
Moved to below GenerateFaviconURL() which is someh
| |
656 | |
657 // Returns the search url for this template URL. | |
658 // Returns an empty GURL if this template URL has no url(). | |
659 GURL GenerateSearchURL(const SearchTermsData& search_terms_data) const; | |
660 | |
652 private: | 661 private: |
653 friend class TemplateURLService; | 662 friend class TemplateURLService; |
654 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ReflectsBookmarkBarPinned); | 663 FRIEND_TEST_ALL_PREFIXES(TemplateURLTest, ReflectsBookmarkBarPinned); |
655 | 664 |
656 void CopyFrom(const TemplateURL& other); | 665 void CopyFrom(const TemplateURL& other); |
657 | 666 |
658 void SetURL(const std::string& url); | 667 void SetURL(const std::string& url); |
659 void SetPrepopulateId(int id); | 668 void SetPrepopulateId(int id); |
660 | 669 |
661 // Resets the keyword if IsGoogleSearchURLWithReplaceableKeyword() or |force|. | 670 // Resets the keyword if IsGoogleSearchURLWithReplaceableKeyword() or |force|. |
662 // The |force| parameter is useful when the existing keyword is known to be | 671 // The |force| parameter is useful when the existing keyword is known to be |
663 // a placeholder. The resulting keyword is generated using | 672 // a placeholder. The resulting keyword is generated using |
664 // TemplateURLService::GenerateSearchURL() and | 673 // GenerateSearchURL() and GenerateKeyword(). |
665 // TemplateURLService::GenerateKeyword(). | |
666 void ResetKeywordIfNecessary(const SearchTermsData& search_terms_data, | 674 void ResetKeywordIfNecessary(const SearchTermsData& search_terms_data, |
667 bool force); | 675 bool force); |
668 | 676 |
669 // Uses the alternate URLs and the search URL to match the provided |url| | 677 // Uses the alternate URLs and the search URL to match the provided |url| |
670 // and extract |search_terms| from it as well as the |search_terms_component| | 678 // and extract |search_terms| from it as well as the |search_terms_component| |
671 // (either REF or QUERY) and |search_terms_component| at which the | 679 // (either REF or QUERY) and |search_terms_component| at which the |
672 // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL(). | 680 // |search_terms| are found in |url|. See also ExtractSearchTermsFromURL(). |
673 bool FindSearchTermsInURL(const GURL& url, | 681 bool FindSearchTermsInURL(const GURL& url, |
674 const SearchTermsData& search_terms_data, | 682 const SearchTermsData& search_terms_data, |
675 base::string16* search_terms, | 683 base::string16* search_terms, |
676 url::Parsed::ComponentType* search_terms_component, | 684 url::Parsed::ComponentType* search_terms_component, |
677 url::Component* search_terms_position); | 685 url::Component* search_terms_position); |
678 | 686 |
679 TemplateURLData data_; | 687 TemplateURLData data_; |
680 TemplateURLRef url_ref_; | 688 TemplateURLRef url_ref_; |
681 TemplateURLRef suggestions_url_ref_; | 689 TemplateURLRef suggestions_url_ref_; |
682 TemplateURLRef instant_url_ref_; | 690 TemplateURLRef instant_url_ref_; |
683 TemplateURLRef image_url_ref_; | 691 TemplateURLRef image_url_ref_; |
684 TemplateURLRef new_tab_url_ref_; | 692 TemplateURLRef new_tab_url_ref_; |
685 TemplateURLRef contextual_search_url_ref_; | 693 TemplateURLRef contextual_search_url_ref_; |
686 scoped_ptr<AssociatedExtensionInfo> extension_info_; | 694 scoped_ptr<AssociatedExtensionInfo> extension_info_; |
687 | 695 |
688 // TODO(sky): Add date last parsed OSD file. | 696 // TODO(sky): Add date last parsed OSD file. |
689 | 697 |
690 DISALLOW_COPY_AND_ASSIGN(TemplateURL); | 698 DISALLOW_COPY_AND_ASSIGN(TemplateURL); |
691 }; | 699 }; |
692 | 700 |
693 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ | 701 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_H_ |
OLD | NEW |