OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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" |
11 #include "base/i18n/break_iterator.h" | 11 #include "base/i18n/break_iterator.h" |
12 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
13 #include "base/i18n/icu_string_conversions.h" | 13 #include "base/i18n/icu_string_conversions.h" |
14 #include "base/json/json_string_value_serializer.h" | 14 #include "base/json/json_string_value_serializer.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/string16.h" | 17 #include "base/string16.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 20 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
21 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 21 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
22 #include "chrome/browser/autocomplete/autocomplete_match.h" | 22 #include "chrome/browser/autocomplete/autocomplete_match.h" |
23 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 23 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
24 #include "chrome/browser/autocomplete/autocomplete_result.h" | 24 #include "chrome/browser/autocomplete/autocomplete_result.h" |
25 #include "chrome/browser/autocomplete/history_url_provider.h" | 25 #include "chrome/browser/autocomplete/history_url_provider.h" |
26 #include "chrome/browser/autocomplete/keyword_provider.h" | 26 #include "chrome/browser/autocomplete/keyword_provider.h" |
27 #include "chrome/browser/autocomplete/url_prefix.h" | 27 #include "chrome/browser/autocomplete/url_prefix.h" |
| 28 #include "chrome/browser/chrome_metrics_helper.h" |
28 #include "chrome/browser/history/history.h" | 29 #include "chrome/browser/history/history.h" |
29 #include "chrome/browser/history/history_service_factory.h" | 30 #include "chrome/browser/history/history_service_factory.h" |
30 #include "chrome/browser/history/in_memory_database.h" | 31 #include "chrome/browser/history/in_memory_database.h" |
31 #include "chrome/browser/net/url_fixer_upper.h" | 32 #include "chrome/browser/net/url_fixer_upper.h" |
32 #include "chrome/browser/prefs/pref_service.h" | 33 #include "chrome/browser/prefs/pref_service.h" |
33 #include "chrome/browser/profiles/profile.h" | 34 #include "chrome/browser/profiles/profile.h" |
34 #include "chrome/browser/search_engines/search_engine_type.h" | 35 #include "chrome/browser/search_engines/search_engine_type.h" |
35 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 36 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
36 #include "chrome/browser/search_engines/template_url_service.h" | 37 #include "chrome/browser/search_engines/template_url_service.h" |
37 #include "chrome/browser/search_engines/template_url_service_factory.h" | 38 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 if (!suggest_url.is_valid()) | 624 if (!suggest_url.is_valid()) |
624 return NULL; | 625 return NULL; |
625 | 626 |
626 suggest_results_pending_++; | 627 suggest_results_pending_++; |
627 LogOmniboxSuggestRequest(REQUEST_SENT); | 628 LogOmniboxSuggestRequest(REQUEST_SENT); |
628 | 629 |
629 net::URLFetcher* fetcher = | 630 net::URLFetcher* fetcher = |
630 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); | 631 net::URLFetcher::Create(id, suggest_url, net::URLFetcher::GET, this); |
631 fetcher->SetRequestContext(profile_->GetRequestContext()); | 632 fetcher->SetRequestContext(profile_->GetRequestContext()); |
632 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); | 633 fetcher->SetLoadFlags(net::LOAD_DO_NOT_SAVE_COOKIES); |
| 634 ChromeMetricsHelper::GetInstance()->AppendHeadersToFetcher(fetcher, profile_); |
633 fetcher->Start(); | 635 fetcher->Start(); |
634 return fetcher; | 636 return fetcher; |
635 } | 637 } |
636 | 638 |
637 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { | 639 bool SearchProvider::ParseSuggestResults(Value* root_val, bool is_keyword) { |
638 // TODO(pkasting): Fix |have_suggest_results_|; see http://crbug.com/130631 | 640 // TODO(pkasting): Fix |have_suggest_results_|; see http://crbug.com/130631 |
639 have_suggest_results_ = false; | 641 have_suggest_results_ = false; |
640 | 642 |
641 string16 query; | 643 string16 query; |
642 ListValue* root_list = NULL; | 644 ListValue* root_list = NULL; |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 } | 1223 } |
1222 | 1224 |
1223 void SearchProvider::UpdateDone() { | 1225 void SearchProvider::UpdateDone() { |
1224 // We're done when the timer isn't running, there are no suggest queries | 1226 // We're done when the timer isn't running, there are no suggest queries |
1225 // pending, and we're not waiting on instant. | 1227 // pending, and we're not waiting on instant. |
1226 done_ = (!timer_.IsRunning() && (suggest_results_pending_ == 0) && | 1228 done_ = (!timer_.IsRunning() && (suggest_results_pending_ == 0) && |
1227 (instant_finalized_ || | 1229 (instant_finalized_ || |
1228 (!chrome::BrowserInstantController::IsInstantEnabled(profile_) && | 1230 (!chrome::BrowserInstantController::IsInstantEnabled(profile_) && |
1229 !chrome::search::IsInstantExtendedAPIEnabled(profile_)))); | 1231 !chrome::search::IsInstantExtendedAPIEnabled(profile_)))); |
1230 } | 1232 } |
OLD | NEW |