Chromium Code Reviews| 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 // This file contains the keyword autocomplete provider. The keyword provider | 5 // This file contains the keyword autocomplete provider. The keyword provider |
| 6 // is responsible for remembering/suggesting user "search keyword queries" | 6 // is responsible for remembering/suggesting user "search keyword queries" |
| 7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An | 7 // (e.g. "imdb Godzilla") and then fixing them up into valid URLs. An |
| 8 // instance of it gets created and managed by the autocomplete controller. | 8 // instance of it gets created and managed by the autocomplete controller. |
| 9 // KeywordProvider uses a TemplateURLService to find the set of keywords. | 9 // KeywordProvider uses a TemplateURLService to find the set of keywords. |
| 10 | 10 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 static const TemplateURL* GetSubstitutingTemplateURLForInput( | 77 static const TemplateURL* GetSubstitutingTemplateURLForInput( |
| 78 TemplateURLService* model, | 78 TemplateURLService* model, |
| 79 AutocompleteInput* input); | 79 AutocompleteInput* input); |
| 80 | 80 |
| 81 // If |text| corresponds (in the sense of | 81 // If |text| corresponds (in the sense of |
| 82 // TemplateURLModel::CleanUserInputKeyword()) to an enabled, substituting | 82 // TemplateURLModel::CleanUserInputKeyword()) to an enabled, substituting |
| 83 // keyword, returns that keyword; returns the empty string otherwise. | 83 // keyword, returns that keyword; returns the empty string otherwise. |
| 84 string16 GetKeywordForText(const string16& text) const; | 84 string16 GetKeywordForText(const string16& text) const; |
| 85 | 85 |
| 86 // Creates a fully marked-up AutocompleteMatch for a specific keyword. | 86 // Creates a fully marked-up AutocompleteMatch for a specific keyword. |
| 87 AutocompleteMatch CreateAutocompleteMatch(const string16& text, | 87 AutocompleteMatch CreateWhatYouTypedMatch(const string16& text, |
|
msw
2013/08/10 17:32:18
nit: I'll always favor Verbatim over WhatYouTyped,
Mark P
2013/08/11 03:22:48
Done.
| |
| 88 const string16& keyword, | 88 const string16& keyword, |
| 89 const AutocompleteInput& input); | 89 const AutocompleteInput& input); |
| 90 | 90 |
| 91 // AutocompleteProvider: | 91 // AutocompleteProvider: |
| 92 virtual void Start(const AutocompleteInput& input, | 92 virtual void Start(const AutocompleteInput& input, |
| 93 bool minimal_changes) OVERRIDE; | 93 bool minimal_changes) OVERRIDE; |
| 94 virtual void Stop(bool clear_cached_results) OVERRIDE; | 94 virtual void Stop(bool clear_cached_results) OVERRIDE; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 class ScopedEndExtensionKeywordMode; | 97 class ScopedEndExtensionKeywordMode; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 120 bool support_replacement, | 120 bool support_replacement, |
| 121 bool prefer_keyword, | 121 bool prefer_keyword, |
| 122 bool allow_exact_keyword_match); | 122 bool allow_exact_keyword_match); |
| 123 | 123 |
| 124 // Creates a fully marked-up AutocompleteMatch from the user's input. | 124 // Creates a fully marked-up AutocompleteMatch from the user's input. |
| 125 // If |relevance| is negative, calculate a relevance based on heuristics. | 125 // If |relevance| is negative, calculate a relevance based on heuristics. |
| 126 AutocompleteMatch CreateAutocompleteMatch(const TemplateURL* template_url, | 126 AutocompleteMatch CreateAutocompleteMatch(const TemplateURL* template_url, |
| 127 const AutocompleteInput& input, | 127 const AutocompleteInput& input, |
| 128 size_t prefix_length, | 128 size_t prefix_length, |
| 129 const string16& remaining_input, | 129 const string16& remaining_input, |
| 130 bool allowed_to_be_default_match, | |
| 130 int relevance); | 131 int relevance); |
| 131 | 132 |
| 132 // Fills in the "destination_url" and "contents" fields of |match| with the | 133 // Fills in the "destination_url" and "contents" fields of |match| with the |
| 133 // provided user input and keyword data. | 134 // provided user input and keyword data. |
| 134 void FillInURLAndContents(const string16& remaining_input, | 135 void FillInURLAndContents(const string16& remaining_input, |
| 135 const TemplateURL* element, | 136 const TemplateURL* element, |
| 136 AutocompleteMatch* match) const; | 137 AutocompleteMatch* match) const; |
| 137 | 138 |
| 138 void EnterExtensionKeywordMode(const std::string& extension_id); | 139 void EnterExtensionKeywordMode(const std::string& extension_id); |
| 139 void MaybeEndExtensionKeywordMode(); | 140 void MaybeEndExtensionKeywordMode(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 165 // If non-empty, holds the ID of the extension whose keyword is currently in | 166 // If non-empty, holds the ID of the extension whose keyword is currently in |
| 166 // the URL bar while the autocomplete popup is open. | 167 // the URL bar while the autocomplete popup is open. |
| 167 std::string current_keyword_extension_id_; | 168 std::string current_keyword_extension_id_; |
| 168 | 169 |
| 169 content::NotificationRegistrar registrar_; | 170 content::NotificationRegistrar registrar_; |
| 170 | 171 |
| 171 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); | 172 DISALLOW_COPY_AND_ASSIGN(KeywordProvider); |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ | 175 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_PROVIDER_H_ |
| OLD | NEW |