| 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 zero-suggest autocomplete provider. This experimental | 5 // This file contains the zero-suggest autocomplete provider. This experimental |
| 6 // provider is invoked when the user focuses in the omnibox prior to editing, | 6 // provider is invoked when the user focuses in the omnibox prior to editing, |
| 7 // and generates search query suggestions based on the current URL. To enable | 7 // and generates search query suggestions based on the current URL. To enable |
| 8 // this provider, point --experimental-zero-suggest-url-prefix at an | 8 // this provider, point --experimental-zero-suggest-url-prefix at an |
| 9 // appropriate suggestion service. | 9 // appropriate suggestion service. |
| 10 // | 10 // |
| 11 // HUGE DISCLAIMER: This is just here for experimenting and will probably be | 11 // HUGE DISCLAIMER: This is just here for experimenting and will probably be |
| 12 // deleted entirely as we revise how suggestions work with the omnibox. | 12 // deleted entirely as we revise how suggestions work with the omnibox. |
| 13 | 13 |
| 14 #ifndef CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 14 #ifndef CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| 15 #define CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 15 #define CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/compiler_specific.h" | 18 #include "base/compiler_specific.h" |
| 19 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 20 #include "chrome/browser/autocomplete/base_search_provider.h" | 20 #include "chrome/browser/autocomplete/base_search_provider.h" |
| 21 #include "chrome/browser/autocomplete/search_provider.h" | 21 #include "chrome/browser/autocomplete/search_provider.h" |
| 22 #include "components/metrics/proto/omnibox_event.pb.h" |
| 22 | 23 |
| 23 class TemplateURLService; | 24 class TemplateURLService; |
| 24 | 25 |
| 25 namespace base { | 26 namespace base { |
| 26 class ListValue; | 27 class ListValue; |
| 27 class Value; | 28 class Value; |
| 28 } | 29 } |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 class URLFetcher; | 32 class URLFetcher; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 void MaybeUseCachedSuggestions(); | 128 void MaybeUseCachedSuggestions(); |
| 128 | 129 |
| 129 // Used to build default search engine URLs for suggested queries. | 130 // Used to build default search engine URLs for suggested queries. |
| 130 TemplateURLService* template_url_service_; | 131 TemplateURLService* template_url_service_; |
| 131 | 132 |
| 132 // The URL for which a suggestion fetch is pending. | 133 // The URL for which a suggestion fetch is pending. |
| 133 std::string current_query_; | 134 std::string current_query_; |
| 134 | 135 |
| 135 // The type of page the user is viewing (a search results page doing search | 136 // The type of page the user is viewing (a search results page doing search |
| 136 // term replacement, an arbitrary URL, etc.). | 137 // term replacement, an arbitrary URL, etc.). |
| 137 AutocompleteInput::PageClassification current_page_classification_; | 138 metrics::OmniboxEventProto::PageClassification current_page_classification_; |
| 138 | 139 |
| 139 // Copy of OmniboxEditModel::permanent_text_. | 140 // Copy of OmniboxEditModel::permanent_text_. |
| 140 base::string16 permanent_text_; | 141 base::string16 permanent_text_; |
| 141 | 142 |
| 142 // Fetcher used to retrieve results. | 143 // Fetcher used to retrieve results. |
| 143 scoped_ptr<net::URLFetcher> fetcher_; | 144 scoped_ptr<net::URLFetcher> fetcher_; |
| 144 | 145 |
| 145 // Suggestion for the current URL. | 146 // Suggestion for the current URL. |
| 146 AutocompleteMatch current_url_match_; | 147 AutocompleteMatch current_url_match_; |
| 147 | 148 |
| 148 // Contains suggest and navigation results as well as relevance parsed from | 149 // Contains suggest and navigation results as well as relevance parsed from |
| 149 // the response for the most recent zero suggest input URL. | 150 // the response for the most recent zero suggest input URL. |
| 150 Results results_; | 151 Results results_; |
| 151 | 152 |
| 152 // Whether we are currently showing cached zero suggest results. | 153 // Whether we are currently showing cached zero suggest results. |
| 153 bool results_from_cache_; | 154 bool results_from_cache_; |
| 154 | 155 |
| 155 history::MostVisitedURLList most_visited_urls_; | 156 history::MostVisitedURLList most_visited_urls_; |
| 156 | 157 |
| 157 // For callbacks that may be run after destruction. | 158 // For callbacks that may be run after destruction. |
| 158 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; | 159 base::WeakPtrFactory<ZeroSuggestProvider> weak_ptr_factory_; |
| 159 | 160 |
| 160 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); | 161 DISALLOW_COPY_AND_ASSIGN(ZeroSuggestProvider); |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ | 164 #endif // CHROME_BROWSER_AUTOCOMPLETE_ZERO_SUGGEST_PROVIDER_H_ |
| OLD | NEW |