Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: chrome/browser/autocomplete/autocomplete.cc

Issue 7461075: Revert 94073 (broke a ton of tests) - Introduce a field trial for Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete.h" 5 #include "chrome/browser/autocomplete/autocomplete.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/i18n/number_formatting.h" 11 #include "base/i18n/number_formatting.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h" 16 #include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
17 #include "chrome/browser/autocomplete/autocomplete_match.h" 17 #include "chrome/browser/autocomplete/autocomplete_match.h"
18 #include "chrome/browser/autocomplete/builtin_provider.h" 18 #include "chrome/browser/autocomplete/builtin_provider.h"
19 #include "chrome/browser/autocomplete/extension_app_provider.h" 19 #include "chrome/browser/autocomplete/extension_app_provider.h"
20 #include "chrome/browser/autocomplete/history_contents_provider.h" 20 #include "chrome/browser/autocomplete/history_contents_provider.h"
21 #include "chrome/browser/autocomplete/history_quick_provider.h" 21 #include "chrome/browser/autocomplete/history_quick_provider.h"
22 #include "chrome/browser/autocomplete/history_url_provider.h" 22 #include "chrome/browser/autocomplete/history_url_provider.h"
23 #include "chrome/browser/autocomplete/keyword_provider.h" 23 #include "chrome/browser/autocomplete/keyword_provider.h"
24 #include "chrome/browser/autocomplete/search_provider.h" 24 #include "chrome/browser/autocomplete/search_provider.h"
25 #include "chrome/browser/autocomplete/shortcuts_provider.h" 25 #include "chrome/browser/autocomplete/shortcuts_provider.h"
26 #include "chrome/browser/bookmarks/bookmark_model.h" 26 #include "chrome/browser/bookmarks/bookmark_model.h"
27 #include "chrome/browser/external_protocol/external_protocol_handler.h" 27 #include "chrome/browser/external_protocol/external_protocol_handler.h"
28 #include "chrome/browser/instant/instant_field_trial.h"
29 #include "chrome/browser/net/url_fixer_upper.h" 28 #include "chrome/browser/net/url_fixer_upper.h"
30 #include "chrome/browser/prefs/pref_service.h" 29 #include "chrome/browser/prefs/pref_service.h"
31 #include "chrome/browser/profiles/profile.h" 30 #include "chrome/browser/profiles/profile.h"
32 #include "chrome/browser/profiles/profile_io_data.h" 31 #include "chrome/browser/profiles/profile_io_data.h"
33 #include "chrome/browser/ui/webui/history_ui.h" 32 #include "chrome/browser/ui/webui/history_ui.h"
34 #include "chrome/common/chrome_notification_types.h" 33 #include "chrome/common/chrome_notification_types.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 "chrome/common/url_constants.h" 36 #include "chrome/common/url_constants.h"
38 #include "content/common/notification_service.h" 37 #include "content/common/notification_service.h"
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // any copied entries. We do this from the time the user stopped typing as some 786 // any copied entries. We do this from the time the user stopped typing as some
788 // providers (such as SearchProvider) wait for the user to stop typing before 787 // providers (such as SearchProvider) wait for the user to stop typing before
789 // they initiate a query. 788 // they initiate a query.
790 static const int kExpireTimeMS = 500; 789 static const int kExpireTimeMS = 500;
791 790
792 AutocompleteController::AutocompleteController( 791 AutocompleteController::AutocompleteController(
793 Profile* profile, 792 Profile* profile,
794 AutocompleteControllerDelegate* delegate) 793 AutocompleteControllerDelegate* delegate)
795 : delegate_(delegate), 794 : delegate_(delegate),
796 done_(true), 795 done_(true),
797 in_start_(false), 796 in_start_(false) {
798 profile_(profile) {
799 search_provider_ = new SearchProvider(this, profile); 797 search_provider_ = new SearchProvider(this, profile);
800 providers_.push_back(search_provider_); 798 providers_.push_back(search_provider_);
801 // TODO(mrossetti): Remove the following and permanently modify the 799 // TODO(mrossetti): Remove the following and permanently modify the
802 // HistoryURLProvider to not search titles once HQP is turned on permanently. 800 // HistoryURLProvider to not search titles once HQP is turned on permanently.
803 bool hqp_enabled = !CommandLine::ForCurrentProcess()->HasSwitch( 801 bool hqp_enabled = !CommandLine::ForCurrentProcess()->HasSwitch(
804 switches::kDisableHistoryQuickProvider); 802 switches::kDisableHistoryQuickProvider);
805 if (hqp_enabled) 803 if (hqp_enabled)
806 providers_.push_back(new HistoryQuickProvider(this, profile)); 804 providers_.push_back(new HistoryQuickProvider(this, profile));
807 if (CommandLine::ForCurrentProcess()->HasSwitch( 805 if (CommandLine::ForCurrentProcess()->HasSwitch(
808 switches::kEnableShortcutsProvider)) 806 switches::kEnableShortcutsProvider))
(...skipping 25 matching lines...) Expand all
834 832
835 providers_.clear(); // Not really necessary. 833 providers_.clear(); // Not really necessary.
836 } 834 }
837 835
838 void AutocompleteController::SetProfile(Profile* profile) { 836 void AutocompleteController::SetProfile(Profile* profile) {
839 Stop(true); 837 Stop(true);
840 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i) 838 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); ++i)
841 (*i)->SetProfile(profile); 839 (*i)->SetProfile(profile);
842 input_.Clear(); // Ensure we don't try to do a "minimal_changes" query on a 840 input_.Clear(); // Ensure we don't try to do a "minimal_changes" query on a
843 // different profile. 841 // different profile.
844 profile_ = profile;
845 } 842 }
846 843
847 void AutocompleteController::Start( 844 void AutocompleteController::Start(
848 const string16& text, 845 const string16& text,
849 const string16& desired_tld, 846 const string16& desired_tld,
850 bool prevent_inline_autocomplete, 847 bool prevent_inline_autocomplete,
851 bool prefer_keyword, 848 bool prefer_keyword,
852 bool allow_exact_keyword_match, 849 bool allow_exact_keyword_match,
853 AutocompleteInput::MatchesRequested matches_requested) { 850 AutocompleteInput::MatchesRequested matches_requested) {
854 const string16 old_input_text(input_.text()); 851 const string16 old_input_text(input_.text());
(...skipping 21 matching lines...) Expand all
876 base::TimeTicks start_time = base::TimeTicks::Now(); 873 base::TimeTicks start_time = base::TimeTicks::Now();
877 for (ACProviders::iterator i(providers_.begin()); i != providers_.end(); 874 for (ACProviders::iterator i(providers_.begin()); i != providers_.end();
878 ++i) { 875 ++i) {
879 (*i)->Start(input_, minimal_changes); 876 (*i)->Start(input_, minimal_changes);
880 if (matches_requested != AutocompleteInput::ALL_MATCHES) 877 if (matches_requested != AutocompleteInput::ALL_MATCHES)
881 DCHECK((*i)->done()); 878 DCHECK((*i)->done());
882 } 879 }
883 if (matches_requested == AutocompleteInput::ALL_MATCHES && 880 if (matches_requested == AutocompleteInput::ALL_MATCHES &&
884 (text.length() < 6)) { 881 (text.length() < 6)) {
885 base::TimeTicks end_time = base::TimeTicks::Now(); 882 base::TimeTicks end_time = base::TimeTicks::Now();
886 std::string name = "Omnibox.QueryTime." + 883 std::string name = "Omnibox.QueryTime." + base::IntToString(text.length());
887 InstantFieldTrial::GetGroupName(profile_) +
888 base::IntToString(text.length());
889 base::Histogram* counter = base::Histogram::FactoryGet( 884 base::Histogram* counter = base::Histogram::FactoryGet(
890 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); 885 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag);
891 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); 886 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds()));
892 } 887 }
893 in_start_ = false; 888 in_start_ = false;
894 CheckIfDone(); 889 CheckIfDone();
895 UpdateResult(true); 890 UpdateResult(true);
896 891
897 if (!done_) 892 if (!done_)
898 StartExpireTimer(); 893 StartExpireTimer();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1028 }
1034 } 1029 }
1035 done_ = true; 1030 done_ = true;
1036 } 1031 }
1037 1032
1038 void AutocompleteController::StartExpireTimer() { 1033 void AutocompleteController::StartExpireTimer() {
1039 if (result_.HasCopiedMatches()) 1034 if (result_.HasCopiedMatches())
1040 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS), 1035 expire_timer_.Start(base::TimeDelta::FromMilliseconds(kExpireTimeMS),
1041 this, &AutocompleteController::ExpireCopiedEntries); 1036 this, &AutocompleteController::ExpireCopiedEntries);
1042 } 1037 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete.h ('k') | chrome/browser/autocomplete/autocomplete_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698