Index: chrome/browser/ui/omnibox/omnibox_edit_model.cc |
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
index 4dd44a5b0cf1028e11885ad581811604f1b49897..d4320ace263a204829d29b234f7591924a635f2d 100644 |
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc |
@@ -129,12 +129,7 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view, |
in_revert_(false), |
in_escape_handler_(false), |
allow_exact_keyword_match_(false) { |
- // Use a restricted subset of the autocomplete providers if we're using the |
- // Instant Extended API, as it doesn't support them all. |
- autocomplete_controller_.reset(new AutocompleteController(profile, this, |
- chrome::IsInstantExtendedAPIEnabled() ? |
- AutocompleteClassifier::kInstantExtendedOmniboxProviders : |
- AutocompleteClassifier::kDefaultOmniboxProviders)); |
+ omnibox_controller_.reset(new OmniboxController(this, profile)); |
delegate_.reset(new OmniboxCurrentPageDelegateImpl(controller, profile)); |
} |
@@ -233,7 +228,7 @@ void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, |
view_->OnAfterPossibleChange(); |
} else if (popup_->IsOpen()) { |
SearchProvider* search_provider = |
- autocomplete_controller_->search_provider(); |
+ autocomplete_controller()->search_provider(); |
// There may be no providers during testing; guard against that. |
if (search_provider) |
search_provider->FinalizeInstantQuery(input_text, suggestion); |
@@ -242,6 +237,7 @@ void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text, |
void OmniboxEditModel::SetInstantSuggestion( |
const InstantSuggestion& suggestion) { |
+ |
Mathieu
2013/04/23 15:26:07
nit: unnecessary new line
beaudoin
2013/04/23 18:04:02
Done.
|
switch (suggestion.behavior) { |
case INSTANT_COMPLETE_NOW: |
view_->SetInstantSuggestion(string16()); |
@@ -253,7 +249,7 @@ void OmniboxEditModel::SetInstantSuggestion( |
DCHECK_EQ(INSTANT_SUGGESTION_SEARCH, suggestion.type); |
view_->SetInstantSuggestion(suggestion.text); |
SearchProvider* search_provider = |
- autocomplete_controller_->search_provider(); |
+ autocomplete_controller()->search_provider(); |
if (search_provider) |
search_provider->ClearInstantSuggestion(); |
break; |
@@ -367,7 +363,7 @@ bool OmniboxEditModel::UseVerbatimInstant() { |
#if defined(OS_MACOSX) |
// TODO(suzhe): Fix Mac port to display Instant suggest in a separated NSView, |
// so that we can display Instant suggest along with composition text. |
- const AutocompleteInput& input = autocomplete_controller_->input(); |
+ const AutocompleteInput& input = autocomplete_controller()->input(); |
if (input.prevent_inline_autocomplete()) |
return true; |
#endif |
@@ -463,7 +459,7 @@ void OmniboxEditModel::SetInputInProgress(bool in_progress) { |
if (user_input_in_progress_) { |
time_user_first_modified_omnibox_ = base::TimeTicks::Now(); |
content::RecordAction(content::UserMetricsAction("OmniboxInputInProgress")); |
- autocomplete_controller_->ResetSession(); |
+ autocomplete_controller()->ResetSession(); |
} |
controller_->OnInputInProgress(in_progress); |
@@ -522,7 +518,7 @@ void OmniboxEditModel::StartAutocomplete( |
// We don't explicitly clear OmniboxPopupModel::manually_selected_match, as |
// Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it. |
- autocomplete_controller_->Start(AutocompleteInput( |
+ autocomplete_controller()->Start(AutocompleteInput( |
user_text_, cursor_position, string16(), GURL(), |
prevent_inline_autocomplete || just_deleted_text_ || |
(has_selected_text && inline_autocomplete_text_.empty()) || |
@@ -532,7 +528,7 @@ void OmniboxEditModel::StartAutocomplete( |
} |
void OmniboxEditModel::StopAutocomplete() { |
- autocomplete_controller_->Stop(true); |
+ autocomplete_controller()->Stop(true); |
} |
bool OmniboxEditModel::CanPasteAndGo(const string16& text) const { |
@@ -572,7 +568,7 @@ void OmniboxEditModel::AcceptInput(WindowOpenDisposition disposition, |
// that, then we use this. These matches are marked as generated by the |
// HistoryURLProvider so we only generate them if this provider is present. |
if (control_key_state_ == DOWN_WITHOUT_CHANGE && !KeywordIsSelected() && |
- autocomplete_controller_->history_url_provider()) { |
+ autocomplete_controller()->history_url_provider()) { |
// Generate a new AutocompleteInput, copying the latest one but using "com" |
// as the desired TLD. Then use this autocomplete input to generate a |
// URL_WHAT_YOU_TYPED AutocompleteMatch. Note that using the most recent |
@@ -581,14 +577,14 @@ void OmniboxEditModel::AcceptInput(WindowOpenDisposition disposition, |
// to "foodnetwork.com", ctrl-enter will navigate to "foo.com", not |
// "foodnetwork.com". At the time of writing, this behavior matches |
// Internet Explorer, but not Firefox. |
- const AutocompleteInput& old_input = autocomplete_controller_->input(); |
+ const AutocompleteInput& old_input = autocomplete_controller()->input(); |
AutocompleteInput input( |
old_input.text(), old_input.cursor_position(), ASCIIToUTF16("com"), |
GURL(), old_input.prevent_inline_autocomplete(), |
old_input.prefer_keyword(), old_input.allow_exact_keyword_match(), |
old_input.matches_requested()); |
AutocompleteMatch url_match = HistoryURLProvider::SuggestExactInput( |
- autocomplete_controller_->history_url_provider(), input, true); |
+ autocomplete_controller()->history_url_provider(), input, true); |
if (url_match.destination_url.is_valid()) { |
// We have a valid URL, we use this newly generated AutocompleteMatch. |
@@ -639,16 +635,16 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
const base::TimeTicks& now(base::TimeTicks::Now()); |
// TODO(sreeram): Handle is_temporary_text_set_by_instant_ correctly. |
AutocompleteLog log( |
- autocomplete_controller_->input().text(), |
+ autocomplete_controller()->input().text(), |
just_deleted_text_, |
- autocomplete_controller_->input().type(), |
+ autocomplete_controller()->input().type(), |
popup_->selected_line(), |
-1, // don't yet know tab ID; set later if appropriate |
delegate_->CurrentPageExists() ? ClassifyPage(delegate_->GetURL()) : |
metrics::OmniboxEventProto_PageClassification_OTHER, |
now - time_user_first_modified_omnibox_, |
string16::npos, // completed_length; possibly set later |
- now - autocomplete_controller_->last_time_default_match_changed(), |
+ now - autocomplete_controller()->last_time_default_match_changed(), |
result()); |
DCHECK(user_input_in_progress_ || |
match.provider->type() == AutocompleteProvider::TYPE_ZERO_SUGGEST) |
@@ -675,7 +671,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
// tab, we don't know the tab ID yet.) |
log.tab_id = delegate_->GetSessionID().id(); |
} |
- autocomplete_controller_->AddProvidersInfo(&log.providers_info); |
+ autocomplete_controller()->AddProvidersInfo(&log.providers_info); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
content::Source<Profile>(profile_), |
@@ -729,7 +725,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
} else { |
base::TimeDelta query_formulation_time = |
base::TimeTicks::Now() - time_user_first_modified_omnibox_; |
- const GURL destination_url = autocomplete_controller_-> |
+ const GURL destination_url = autocomplete_controller()-> |
GetDestinationURL(match, query_formulation_time); |
// If running with instant, notify the instant controller that a navigation |
@@ -757,7 +753,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match, |
bool OmniboxEditModel::AcceptKeyword() { |
DCHECK(is_keyword_hint_ && !keyword_.empty()); |
- autocomplete_controller_->Stop(false); |
+ autocomplete_controller()->Stop(false); |
is_keyword_hint_ = false; |
if (popup_->IsOpen()) |
@@ -780,7 +776,7 @@ bool OmniboxEditModel::AcceptKeyword() { |
} |
void OmniboxEditModel::ClearKeyword(const string16& visible_text) { |
- autocomplete_controller_->Stop(false); |
+ autocomplete_controller()->Stop(false); |
ClearPopupKeywordMode(); |
const string16 window_text(keyword_ + visible_text); |
@@ -805,7 +801,7 @@ void OmniboxEditModel::ClearKeyword(const string16& visible_text) { |
} |
const AutocompleteResult& OmniboxEditModel::result() const { |
- return autocomplete_controller_->result(); |
+ return autocomplete_controller()->result(); |
} |
void OmniboxEditModel::OnSetFocus(bool control_down) { |
@@ -822,8 +818,8 @@ void OmniboxEditModel::OnSetFocus(bool control_down) { |
// that we avoid PermanentURL() here because it's not guaranteed to give us |
// the actual underlying current URL, e.g. if we're on the NTP and the |
// |permanent_text_| is empty. |
- autocomplete_controller_->StartZeroSuggest(delegate_->GetURL(), |
- user_text_); |
+ autocomplete_controller()->StartZeroSuggest(delegate_->GetURL(), |
+ user_text_); |
} |
delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); |
@@ -846,7 +842,7 @@ void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) { |
} |
// TODO(jered): Rip this out along with StartZeroSuggest. |
- autocomplete_controller_->StopZeroSuggest(); |
+ autocomplete_controller()->StopZeroSuggest(); |
delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_); |
} |
@@ -943,7 +939,7 @@ void OmniboxEditModel::OnUpOrDownKeyPressed(int count) { |
// that it's stepping through. In that case, our popup model is |
// irrelevant, so don't process the key press ourselves. However, do stop |
// the autocomplete system from changing the results. |
- autocomplete_controller_->Stop(false); |
+ autocomplete_controller()->Stop(false); |
} else { |
// The popup is open, so the user should be able to interact with it |
// normally. |
@@ -1179,11 +1175,11 @@ void OmniboxEditModel::OnResultChanged(bool default_match_changed) { |
InstantController* instant = controller_->GetInstant(); |
if (instant && !in_revert_) |
- instant->HandleAutocompleteResults(*autocomplete_controller_->providers()); |
+ instant->HandleAutocompleteResults(*autocomplete_controller()->providers()); |
} |
bool OmniboxEditModel::query_in_progress() const { |
- return !autocomplete_controller_->done(); |
+ return !autocomplete_controller()->done(); |
} |
void OmniboxEditModel::InternalSetUserText(const string16& text) { |
@@ -1215,7 +1211,7 @@ void OmniboxEditModel::InfoForCurrentSelection(AutocompleteMatch* match, |
GURL* alternate_nav_url) const { |
DCHECK(match != NULL); |
const AutocompleteResult& result = this->result(); |
- if (!autocomplete_controller_->done()) { |
+ if (!autocomplete_controller()->done()) { |
// It's technically possible for |result| to be empty if no provider returns |
// a synchronous result but the query has not completed synchronously; |
// pratically, however, that should never actually happen. |
@@ -1319,8 +1315,8 @@ bool OmniboxEditModel::CreatedKeywordSearchByInsertingSpaceInMiddle( |
TrimWhitespace(new_text.substr(0, space_position), TRIM_LEADING, &keyword); |
// TODO(sreeram): Once the Instant extended API supports keywords properly, |
// keyword_provider() should never be NULL. Remove that clause. |
- return !keyword.empty() && autocomplete_controller_->keyword_provider() && |
- !autocomplete_controller_->keyword_provider()-> |
+ return !keyword.empty() && autocomplete_controller()->keyword_provider() && |
+ !autocomplete_controller()->keyword_provider()-> |
GetKeywordForText(keyword).empty(); |
} |
@@ -1342,9 +1338,9 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) { |
// Remove "?" if we're in forced query mode. |
AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
- autocomplete_controller_->input().type(), &user_text); |
+ autocomplete_controller()->input().type(), &user_text); |
AutocompleteInput::RemoveForcedQueryStringIfNecessary( |
- autocomplete_controller_->input().type(), &full_text); |
+ autocomplete_controller()->input().type(), &full_text); |
size_t start, end; |
view_->GetSelectionBounds(&start, &end); |