Chromium Code Reviews| 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/base64.h" | 10 #include "base/base64.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/i18n/break_iterator.h" | 13 #include "base/i18n/break_iterator.h" |
| 14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
| 15 #include "base/json/json_string_value_serializer.h" | 15 #include "base/json/json_string_value_serializer.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 19 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 22 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 23 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 23 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
| 24 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 24 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 25 #include "chrome/browser/autocomplete/autocomplete_result.h" | 25 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 26 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 26 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 27 #include "chrome/browser/autocomplete/keyword_provider.h" | 27 #include "chrome/browser/autocomplete/keyword_provider.h" |
| 28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | |
| 29 #include "chrome/browser/history/history_service.h" | 28 #include "chrome/browser/history/history_service.h" |
| 30 #include "chrome/browser/history/history_service_factory.h" | 29 #include "chrome/browser/history/history_service_factory.h" |
| 31 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 30 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/browser/search_engines/template_url_service_factory.h" | 32 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 34 #include "chrome/browser/ui/search/instant_controller.h" | 33 #include "chrome/browser/ui/search/instant_controller.h" |
| 35 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 37 #include "components/autocomplete/url_prefix.h" | 36 #include "components/autocomplete/url_prefix.h" |
| 38 #include "components/google/core/browser/google_util.h" | 37 #include "components/google/core/browser/google_util.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 if ((keyword_url != NULL) && HasKeywordDefaultMatchInKeywordMode()) { | 412 if ((keyword_url != NULL) && HasKeywordDefaultMatchInKeywordMode()) { |
| 414 // If there is a keyword match that is allowed to be the default match, | 413 // If there is a keyword match that is allowed to be the default match, |
| 415 // then prohibit default provider matches from being the default match lest | 414 // then prohibit default provider matches from being the default match lest |
| 416 // such matches cause the user to break out of keyword mode. | 415 // such matches cause the user to break out of keyword mode. |
| 417 for (ACMatches::iterator it = matches_.begin(); it != matches_.end(); | 416 for (ACMatches::iterator it = matches_.begin(); it != matches_.end(); |
| 418 ++it) { | 417 ++it) { |
| 419 if (it->keyword != keyword_url->keyword()) | 418 if (it->keyword != keyword_url->keyword()) |
| 420 it->allowed_to_be_default_match = false; | 419 it->allowed_to_be_default_match = false; |
| 421 } | 420 } |
| 422 } | 421 } |
| 423 | |
| 424 base::TimeTicks update_starred_start_time(base::TimeTicks::Now()); | |
| 425 UpdateStarredStateOfMatches(BookmarkModelFactory::GetForProfile(profile_)); | |
| 426 UMA_HISTOGRAM_TIMES("Omnibox.SearchProvider.UpdateStarredTime", | |
|
Peter Kasting
2014/07/24 18:51:34
Make sure this historgram gets properly marked as
hashimoto
2014/07/25 08:36:12
There is no line in histograms.xml which correspon
| |
| 427 base::TimeTicks::Now() - update_starred_start_time); | |
| 428 UpdateDone(); | 422 UpdateDone(); |
| 429 } | 423 } |
| 430 | 424 |
| 431 void SearchProvider::Run() { | 425 void SearchProvider::Run() { |
| 432 // Start a new request with the current input. | 426 // Start a new request with the current input. |
| 433 suggest_results_pending_ = 0; | 427 suggest_results_pending_ = 0; |
| 434 time_suggest_request_sent_ = base::TimeTicks::Now(); | 428 time_suggest_request_sent_ = base::TimeTicks::Now(); |
| 435 | 429 |
| 436 default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID, | 430 default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID, |
| 437 providers_.GetDefaultProviderURL(), input_)); | 431 providers_.GetDefaultProviderURL(), input_)); |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1181 // Make the base64 encoded value URL and filename safe(see RFC 3548). | 1175 // Make the base64 encoded value URL and filename safe(see RFC 3548). |
| 1182 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); | 1176 std::replace(current_token_.begin(), current_token_.end(), '+', '-'); |
| 1183 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); | 1177 std::replace(current_token_.begin(), current_token_.end(), '/', '_'); |
| 1184 } | 1178 } |
| 1185 | 1179 |
| 1186 // Extend expiration time another 60 seconds. | 1180 // Extend expiration time another 60 seconds. |
| 1187 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); | 1181 token_expiration_time_ = current_time + base::TimeDelta::FromSeconds(60); |
| 1188 | 1182 |
| 1189 return current_token_; | 1183 return current_token_; |
| 1190 } | 1184 } |
| OLD | NEW |