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

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

Issue 320713002: Revert of Omnibox: Combine Two Input Type Enums into One (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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) 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/history_quick_provider.h" 5 #include "chrome/browser/autocomplete/history_quick_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/search/search.h" 30 #include "chrome/browser/search/search.h"
31 #include "chrome/browser/search_engines/template_url.h" 31 #include "chrome/browser/search_engines/template_url.h"
32 #include "chrome/browser/search_engines/template_url_service.h" 32 #include "chrome/browser/search_engines/template_url_service.h"
33 #include "chrome/browser/search_engines/template_url_service_factory.h" 33 #include "chrome/browser/search_engines/template_url_service_factory.h"
34 #include "chrome/common/autocomplete_match_type.h" 34 #include "chrome/common/autocomplete_match_type.h"
35 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
36 #include "chrome/common/net/url_fixer_upper.h" 36 #include "chrome/common/net/url_fixer_upper.h"
37 #include "chrome/common/pref_names.h" 37 #include "chrome/common/pref_names.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "components/metrics/proto/omnibox_input_type.pb.h"
40 #include "content/public/browser/notification_source.h" 39 #include "content/public/browser/notification_source.h"
41 #include "content/public/browser/notification_types.h" 40 #include "content/public/browser/notification_types.h"
42 #include "net/base/escape.h" 41 #include "net/base/escape.h"
43 #include "net/base/net_util.h" 42 #include "net/base/net_util.h"
44 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
45 #include "url/url_parse.h" 44 #include "url/url_parse.h"
46 #include "url/url_util.h" 45 #include "url/url_util.h"
47 46
48 using history::InMemoryURLIndex; 47 using history::InMemoryURLIndex;
49 using history::ScoredHistoryMatch; 48 using history::ScoredHistoryMatch;
50 using history::ScoredHistoryMatches; 49 using history::ScoredHistoryMatches;
51 50
52 bool HistoryQuickProvider::disabled_ = false; 51 bool HistoryQuickProvider::disabled_ = false;
53 52
54 HistoryQuickProvider::HistoryQuickProvider( 53 HistoryQuickProvider::HistoryQuickProvider(
55 AutocompleteProviderListener* listener, 54 AutocompleteProviderListener* listener,
56 Profile* profile) 55 Profile* profile)
57 : HistoryProvider(listener, profile, 56 : HistoryProvider(listener, profile,
58 AutocompleteProvider::TYPE_HISTORY_QUICK), 57 AutocompleteProvider::TYPE_HISTORY_QUICK),
59 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) { 58 languages_(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) {
60 } 59 }
61 60
62 void HistoryQuickProvider::Start(const AutocompleteInput& input, 61 void HistoryQuickProvider::Start(const AutocompleteInput& input,
63 bool minimal_changes) { 62 bool minimal_changes) {
64 matches_.clear(); 63 matches_.clear();
65 if (disabled_) 64 if (disabled_)
66 return; 65 return;
67 66
68 // Don't bother with INVALID and FORCED_QUERY. 67 // Don't bother with INVALID and FORCED_QUERY.
69 if ((input.type() == metrics::OmniboxInputType::INVALID) || 68 if ((input.type() == AutocompleteInput::INVALID) ||
70 (input.type() == metrics::OmniboxInputType::FORCED_QUERY)) 69 (input.type() == AutocompleteInput::FORCED_QUERY))
71 return; 70 return;
72 71
73 autocomplete_input_ = input; 72 autocomplete_input_ = input;
74 73
75 // TODO(pkasting): We should just block here until this loads. Any time 74 // TODO(pkasting): We should just block here until this loads. Any time
76 // someone unloads the history backend, we'll get inconsistent inline 75 // someone unloads the history backend, we'll get inconsistent inline
77 // autocomplete behavior here. 76 // autocomplete behavior here.
78 if (GetIndex()) { 77 if (GetIndex()) {
79 base::TimeTicks start_time = base::TimeTicks::Now(); 78 base::TimeTicks start_time = base::TimeTicks::Now();
80 DoAutocomplete(); 79 DoAutocomplete();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 int url_what_you_typed_match_score = -1; // undefined 114 int url_what_you_typed_match_score = -1; // undefined
116 // These are necessary (but not sufficient) conditions for the omnibox 115 // These are necessary (but not sufficient) conditions for the omnibox
117 // input to be a URL-what-you-typed match. The username test checks that 116 // input to be a URL-what-you-typed match. The username test checks that
118 // either the username does not exist (a regular URL such as http://site/) 117 // either the username does not exist (a regular URL such as http://site/)
119 // or, if the username exists (http://user@site/), there must be either 118 // or, if the username exists (http://user@site/), there must be either
120 // a password or a port. Together these exclude pure username@site 119 // a password or a port. Together these exclude pure username@site
121 // inputs because these are likely to be an e-mail address. HistoryURL 120 // inputs because these are likely to be an e-mail address. HistoryURL
122 // provider won't promote the URL-what-you-typed match to first 121 // provider won't promote the URL-what-you-typed match to first
123 // for these inputs. 122 // for these inputs.
124 const bool can_have_url_what_you_typed_match_first = 123 const bool can_have_url_what_you_typed_match_first =
125 (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) && 124 (autocomplete_input_.type() != AutocompleteInput::QUERY) &&
126 (!autocomplete_input_.parts().username.is_nonempty() || 125 (!autocomplete_input_.parts().username.is_nonempty() ||
127 autocomplete_input_.parts().password.is_nonempty() || 126 autocomplete_input_.parts().password.is_nonempty() ||
128 autocomplete_input_.parts().path.is_nonempty()); 127 autocomplete_input_.parts().path.is_nonempty());
129 if (can_have_url_what_you_typed_match_first) { 128 if (can_have_url_what_you_typed_match_first) {
130 HistoryService* const history_service = 129 HistoryService* const history_service =
131 HistoryServiceFactory::GetForProfile(profile_, 130 HistoryServiceFactory::GetForProfile(profile_,
132 Profile::EXPLICIT_ACCESS); 131 Profile::EXPLICIT_ACCESS);
133 // We expect HistoryService to be available. In case it's not, 132 // We expect HistoryService to be available. In case it's not,
134 // (e.g., due to Profile corruption) we let HistoryQuick provider 133 // (e.g., due to Profile corruption) we let HistoryQuick provider
135 // completions (which may be available because it's a different 134 // completions (which may be available because it's a different
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (index_for_testing_.get()) 298 if (index_for_testing_.get())
300 return index_for_testing_.get(); 299 return index_for_testing_.get();
301 300
302 HistoryService* const history_service = 301 HistoryService* const history_service =
303 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 302 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
304 if (!history_service) 303 if (!history_service)
305 return NULL; 304 return NULL;
306 305
307 return history_service->InMemoryIndex(); 306 return history_service->InMemoryIndex();
308 } 307 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider.cc ('k') | chrome/browser/autocomplete/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698