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/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/history/history_service_factory.h" | 30 #include "chrome/browser/history/history_service_factory.h" |
31 #include "chrome/browser/history/in_memory_database.h" | 31 #include "chrome/browser/history/in_memory_database.h" |
32 #include "chrome/browser/instant/instant_controller.h" | 32 #include "chrome/browser/instant/instant_controller.h" |
33 #include "chrome/browser/net/url_fixer_upper.h" | 33 #include "chrome/browser/net/url_fixer_upper.h" |
34 #include "chrome/browser/prefs/pref_service.h" | 34 #include "chrome/browser/prefs/pref_service.h" |
35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
36 #include "chrome/browser/search_engines/search_engine_type.h" | 36 #include "chrome/browser/search_engines/search_engine_type.h" |
37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
38 #include "chrome/browser/search_engines/template_url_service.h" | 38 #include "chrome/browser/search_engines/template_url_service.h" |
39 #include "chrome/browser/search_engines/template_url_service_factory.h" | 39 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 40 #include "chrome/browser/ui/search/search.h" |
40 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
41 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
42 #include "googleurl/src/url_util.h" | 43 #include "googleurl/src/url_util.h" |
43 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
44 #include "net/base/escape.h" | 45 #include "net/base/escape.h" |
45 #include "net/base/load_flags.h" | 46 #include "net/base/load_flags.h" |
46 #include "net/base/net_util.h" | 47 #include "net/base/net_util.h" |
47 #include "net/http/http_response_headers.h" | 48 #include "net/http/http_response_headers.h" |
48 #include "net/url_request/url_fetcher.h" | 49 #include "net/url_request/url_fetcher.h" |
49 #include "net/url_request/url_request_status.h" | 50 #include "net/url_request/url_request_status.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 ACMatchClassification(0, ACMatchClassification::NONE)); | 267 ACMatchClassification(0, ACMatchClassification::NONE)); |
267 match.keyword = providers_.default_provider(); | 268 match.keyword = providers_.default_provider(); |
268 matches_.push_back(match); | 269 matches_.push_back(match); |
269 } | 270 } |
270 Stop(false); | 271 Stop(false); |
271 return; | 272 return; |
272 } | 273 } |
273 | 274 |
274 input_ = input; | 275 input_ = input; |
275 | 276 |
276 DoHistoryQuery(minimal_changes); | 277 // Don't run the normal provider flow when the Instant Extended API is |
277 StartOrStopSuggestQuery(minimal_changes); | 278 // enabled. (When the Extended API is enabled, the embedded page will handle |
| 279 // all search suggestions itself.) |
| 280 // TODO(dcblack): once we are done refactoring the omnibox so we don't need to |
| 281 // use FinalizeInstantQuery anymore, we can take out this check and remove |
| 282 // this provider from kInstantExtendedOmniboxProviders. |
| 283 if (!chrome::search::IsInstantExtendedAPIEnabled(profile_)) { |
| 284 DoHistoryQuery(minimal_changes); |
| 285 StartOrStopSuggestQuery(minimal_changes); |
| 286 } |
278 ConvertResultsToAutocompleteMatches(); | 287 ConvertResultsToAutocompleteMatches(); |
279 } | 288 } |
280 | 289 |
281 SearchProvider::Result::Result(int relevance) : relevance_(relevance) {} | 290 SearchProvider::Result::Result(int relevance) : relevance_(relevance) {} |
282 SearchProvider::Result::~Result() {} | 291 SearchProvider::Result::~Result() {} |
283 | 292 |
284 SearchProvider::SuggestResult::SuggestResult(const string16& suggestion, | 293 SearchProvider::SuggestResult::SuggestResult(const string16& suggestion, |
285 int relevance) | 294 int relevance) |
286 : Result(relevance), | 295 : Result(relevance), |
287 suggestion_(suggestion) { | 296 suggestion_(suggestion) { |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 return match; | 1242 return match; |
1234 } | 1243 } |
1235 | 1244 |
1236 void SearchProvider::UpdateDone() { | 1245 void SearchProvider::UpdateDone() { |
1237 // We're done when the timer isn't running, there are no suggest queries | 1246 // We're done when the timer isn't running, there are no suggest queries |
1238 // pending, and we're not waiting on instant. | 1247 // pending, and we're not waiting on instant. |
1239 done_ = (!timer_.IsRunning() && (suggest_results_pending_ == 0) && | 1248 done_ = (!timer_.IsRunning() && (suggest_results_pending_ == 0) && |
1240 (instant_finalized_ || | 1249 (instant_finalized_ || |
1241 !InstantController::IsSuggestEnabled(profile_))); | 1250 !InstantController::IsSuggestEnabled(profile_))); |
1242 } | 1251 } |
OLD | NEW |