summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/omnibox
diff options
context:
space:
mode:
authorbeaudoin@chromium.org <beaudoin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-29 21:20:36 +0000
committerbeaudoin@chromium.org <beaudoin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-29 21:20:36 +0000
commitb5d2e470bfe52d927490edcad78a55e10a6c633a (patch)
tree24fae262cf25ab825248d02915e35d4b4ffddf36 /chrome/browser/ui/omnibox
parentbb7e03b8ab6af206f37d14f3f99c0725d9e3664e (diff)
downloadchromium_src-b5d2e470bfe52d927490edcad78a55e10a6c633a.zip
chromium_src-b5d2e470bfe52d927490edcad78a55e10a6c633a.tar.gz
chromium_src-b5d2e470bfe52d927490edcad78a55e10a6c633a.tar.bz2
Omnibox refactor.
Follow up on: https://codereview.chromium.org/14358005/ BUG=234733 Review URL: https://chromiumcodereview.appspot.com/15003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/omnibox')
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller.cc96
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller.h32
-rw-r--r--chrome/browser/ui/omnibox/omnibox_controller_unittest.cc5
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.cc152
-rw-r--r--chrome/browser/ui/omnibox/omnibox_edit_model.h34
5 files changed, 178 insertions, 141 deletions
diff --git a/chrome/browser/ui/omnibox/omnibox_controller.cc b/chrome/browser/ui/omnibox/omnibox_controller.cc
index 48171c6..8d04055 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller.cc
+++ b/chrome/browser/ui/omnibox/omnibox_controller.cc
@@ -7,6 +7,7 @@
#include "base/metrics/histogram.h"
#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
+#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/net/predictor.h"
#include "chrome/browser/predictors/autocomplete_action_predictor.h"
#include "chrome/browser/prerender/prerender_field_trial.h"
@@ -38,6 +39,36 @@ OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model,
OmniboxController::~OmniboxController() {
}
+void OmniboxController::StartAutocomplete(
+ string16 user_text,
+ size_t cursor_position,
+ bool prevent_inline_autocomplete,
+ bool prefer_keyword,
+ bool allow_exact_keyword_match) const {
+ ClearPopupKeywordMode();
+ popup_->SetHoveredLine(OmniboxPopupModel::kNoMatch);
+
+ InstantController* instant_controller = GetInstantController();
+ if (instant_controller) {
+ instant_controller->OnAutocompleteStart();
+ // If the embedded page for InstantExtended is fetching its own suggestions,
+ // suppress search suggestions from SearchProvider. We still need
+ // SearchProvider to run for FinalizeInstantQuery.
+ // TODO(dcblack): Once we are done refactoring the omnibox so we don't need
+ // to use FinalizeInstantQuery anymore, we can take out this check and
+ // remove this provider from kInstantExtendedOmniboxProviders.
+ if (instant_controller->WillFetchCompletions())
+ autocomplete_controller_->search_provider()->SuppressSearchSuggestions();
+ }
+
+ // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as
+ // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it.
+ autocomplete_controller_->Start(AutocompleteInput(
+ user_text, cursor_position, string16(), GURL(),
+ prevent_inline_autocomplete, prefer_keyword, allow_exact_keyword_match,
+ AutocompleteInput::ALL_MATCHES));
+}
+
void OmniboxController::OnResultChanged(bool default_match_changed) {
// TODO(beaudoin): There should be no need to access the popup when using
// instant extended, remove this reference.
@@ -79,12 +110,11 @@ void OmniboxController::OnResultChanged(bool default_match_changed) {
// The popup size may have changed, let instant know.
OnPopupBoundsChanged(popup_->view()->GetTargetBounds());
- InstantController* instant =
- omnibox_edit_model_->controller()->GetInstant();
- if (instant && !omnibox_edit_model_->in_revert()) {
- instant->HandleAutocompleteResults(
- *autocomplete_controller()->providers(),
- autocomplete_controller()->result());
+ InstantController* instant_controller = GetInstantController();
+ if (instant_controller && !omnibox_edit_model_->in_revert()) {
+ instant_controller->HandleAutocompleteResults(
+ *autocomplete_controller_->providers(),
+ autocomplete_controller_->result());
}
} else if (was_open) {
// Accept the temporary text as the user text, because it makes little sense
@@ -95,6 +125,30 @@ void OmniboxController::OnResultChanged(bool default_match_changed) {
}
}
+bool OmniboxController::DoInstant(const AutocompleteMatch& match,
+ string16 user_text,
+ string16 full_text,
+ size_t selection_start,
+ size_t selection_end,
+ bool user_input_in_progress,
+ bool in_escape_handler,
+ bool just_deleted_text,
+ bool keyword_is_selected) {
+ InstantController* instant_controller = GetInstantController();
+ if (!instant_controller)
+ return false;
+
+ // Remove "?" if we're in forced query mode.
+ AutocompleteInput::RemoveForcedQueryStringIfNecessary(
+ autocomplete_controller_->input().type(), &user_text);
+ AutocompleteInput::RemoveForcedQueryStringIfNecessary(
+ autocomplete_controller_->input().type(), &full_text);
+ return instant_controller->Update(
+ match, user_text, full_text, selection_start, selection_end,
+ UseVerbatimInstant(just_deleted_text), user_input_in_progress,
+ popup_->IsOpen(), in_escape_handler, keyword_is_selected);
+}
+
void OmniboxController::ClearPopupKeywordMode() const {
if (popup_->IsOpen() &&
popup_->selected_line_state() == OmniboxPopupModel::KEYWORD)
@@ -118,7 +172,31 @@ void OmniboxController::DoPreconnect(const AutocompleteMatch& match) {
}
void OmniboxController::OnPopupBoundsChanged(const gfx::Rect& bounds) {
- InstantController* instant = omnibox_edit_model_->controller()->GetInstant();
- if (instant)
- instant->SetPopupBounds(bounds);
+ InstantController* instant_controller = GetInstantController();
+ if (instant_controller)
+ instant_controller->SetPopupBounds(bounds);
+}
+
+bool OmniboxController::UseVerbatimInstant(bool just_deleted_text) const {
+#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();
+ if (input.prevent_inline_autocomplete())
+ return true;
+#endif
+
+ // The value of input.prevent_inline_autocomplete() is determined by the
+ // following conditions:
+ // 1. If the caret is at the end of the text.
+ // 2. If it's in IME composition mode.
+ // We send the caret position to Instant (so it can determine #1 itself), and
+ // we use a separated widget for displaying the Instant suggest (so it doesn't
+ // interfere with #2). So, we don't need to care about the value of
+ // input.prevent_inline_autocomplete() here.
+ return just_deleted_text || popup_->selected_line() != 0;
+}
+
+InstantController* OmniboxController::GetInstantController() const {
+ return omnibox_edit_model_->GetInstantController();
}
diff --git a/chrome/browser/ui/omnibox/omnibox_controller.h b/chrome/browser/ui/omnibox/omnibox_controller.h
index caa1efc..e210090 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller.h
+++ b/chrome/browser/ui/omnibox/omnibox_controller.h
@@ -8,12 +8,14 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "base/string16.h"
#include "chrome/browser/autocomplete/autocomplete_controller.h"
#include "chrome/browser/autocomplete/autocomplete_controller_delegate.h"
struct AutocompleteMatch;
class AutocompleteResult;
class GURL;
+class InstantController;
class OmniboxEditModel;
class OmniboxPopupModel;
class Profile;
@@ -33,9 +35,16 @@ class Rect;
class OmniboxController : public AutocompleteControllerDelegate {
public:
- OmniboxController(OmniboxEditModel* omnibox_edit_model, Profile* profile);
+ OmniboxController(OmniboxEditModel* omnibox_edit_model,
+ Profile* profile);
virtual ~OmniboxController();
+ void StartAutocomplete(string16 user_text,
+ size_t cursor_position,
+ bool prevent_inline_autocomplete,
+ bool prefer_keyword,
+ bool allow_exact_keyword_match) const;
+
// AutocompleteControllerDelegate:
virtual void OnResultChanged(bool default_match_changed) OVERRIDE;
@@ -43,6 +52,16 @@ class OmniboxController : public AutocompleteControllerDelegate {
return autocomplete_controller_.get();
}
+ bool DoInstant(const AutocompleteMatch& match,
+ string16 user_text,
+ string16 full_text,
+ size_t selection_start,
+ size_t selection_end,
+ bool user_input_in_progress,
+ bool in_escape_handler,
+ bool just_deleted_text,
+ bool keyword_is_selected);
+
void set_popup_model(OmniboxPopupModel* popup_model) {
popup_ = popup_model;
}
@@ -67,6 +86,17 @@ class OmniboxController : public AutocompleteControllerDelegate {
void OnPopupBoundsChanged(const gfx::Rect& bounds);
private:
+
+ // Returns true if a verbatim query should be used for Instant. A verbatim
+ // query is forced in certain situations, such as pressing delete at the end
+ // of the edit.
+ bool UseVerbatimInstant(bool just_deleted_text) const;
+
+ // Access the instant controller from the OmniboxEditModel. We need to do this
+ // because the only valid pointer to InstantController is kept in Browser,
+ // which OmniboxEditModel has some ways of reaching.
+ InstantController* GetInstantController() const;
+
// Weak, it owns us.
// TODO(beaudoin): Consider defining a delegate to ease unit testing.
OmniboxEditModel* omnibox_edit_model_;
diff --git a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
index 5f25c92..744ec95 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_controller_unittest.cc
@@ -11,8 +11,6 @@
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
-
class OmniboxControllerTest : public testing::Test {
protected:
OmniboxControllerTest();
@@ -91,7 +89,4 @@ TEST_F(OmniboxControllerTest, CheckDefaultAutocompleteProviders) {
chrome::EnableInstantExtendedAPIForTesting();
CreateController();
AssertProviders(providers_with_instant_extended);
-
}
-
-} // namespace
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.cc b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
index 903cf2c..455bcc2 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -227,16 +227,10 @@ void OmniboxEditModel::SetUserText(const string16& text) {
is_instant_temporary_text_a_search_query_ = false;
}
-void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text,
- const InstantSuggestion& suggestion,
- bool skip_inline_autocomplete) {
- if (skip_inline_autocomplete) {
- const string16 final_text = input_text + suggestion.text;
- view_->OnBeforePossibleChange();
- view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false,
- false);
- view_->OnAfterPossibleChange();
- } else if (popup_model()->IsOpen()) {
+void OmniboxEditModel::FinalizeInstantQuery(
+ const string16& input_text,
+ const InstantSuggestion& suggestion) {
+ if (popup_model()->IsOpen()) {
SearchProvider* search_provider =
autocomplete_controller()->search_provider();
// There may be no providers during testing; guard against that.
@@ -251,7 +245,7 @@ void OmniboxEditModel::SetInstantSuggestion(
case INSTANT_COMPLETE_NOW:
view_->SetInstantSuggestion(string16());
if (!suggestion.text.empty())
- FinalizeInstantQuery(view_->GetText(), suggestion, false);
+ FinalizeInstantQuery(view_->GetText(), suggestion);
break;
case INSTANT_COMPLETE_NEVER: {
@@ -280,22 +274,17 @@ void OmniboxEditModel::SetInstantSuggestion(
}
}
-bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) {
- if (!controller_->GetInstant())
- return false;
-
+bool OmniboxEditModel::CommitSuggestedText() {
const string16 suggestion = view_->GetInstantSuggestion();
if (suggestion.empty())
return false;
// Assume that the gray text we are committing is a search suggestion.
- FinalizeInstantQuery(view_->GetText(),
- InstantSuggestion(suggestion,
- INSTANT_COMPLETE_NOW,
- INSTANT_SUGGESTION_SEARCH,
- string16(),
- OmniboxPopupModel::kNoMatch),
- skip_inline_autocomplete);
+ const string16 final_text = view_->GetText() + suggestion;
+ view_->OnBeforePossibleChange();
+ view_->SetWindowTextAndCaretPos(final_text, final_text.length(), false,
+ false);
+ view_->OnAfterPossibleChange();
return true;
}
@@ -327,12 +316,26 @@ void OmniboxEditModel::OnChanged() {
recommended_action,
AutocompleteActionPredictor::LAST_PREDICT_ACTION);
- if (!DoInstant(current_match)) {
+ // Do not perform instant if we're currently reverting or the change is the
+ // result of an INSTANT_COMPLETE_REPLACE instant suggestion.
+ bool performed_instant = false;
+ if (!in_revert_ && !is_temporary_text_set_by_instant_) {
+ size_t start, end;
+ view_->GetSelectionBounds(&start, &end);
+ string16 user_text = DisplayTextFromUserText(user_text_);
+ performed_instant = omnibox_controller_->DoInstant(
+ current_match, user_text, view_->GetText(), start, end,
+ user_input_in_progress_, in_escape_handler_,
+ view_->DeleteAtEndPressed() || just_deleted_text_,
+ KeywordIsSelected());
+ }
+
+ if (!performed_instant) {
// Hide any suggestions we might be showing.
view_->SetInstantSuggestion(string16());
// No need to wait any longer for Instant.
- FinalizeInstantQuery(string16(), InstantSuggestion(), false);
+ FinalizeInstantQuery(string16(), InstantSuggestion());
}
switch (recommended_action) {
@@ -370,27 +373,6 @@ void OmniboxEditModel::GetDataForURLExport(GURL* url,
}
}
-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();
- if (input.prevent_inline_autocomplete())
- return true;
-#endif
-
- // The value of input.prevent_inline_autocomplete() is determined by the
- // following conditions:
- // 1. If the caret is at the end of the text.
- // 2. If it's in IME composition mode.
- // We send the caret position to Instant (so it can determine #1 itself), and
- // we use a separated widget for displaying the Instant suggest (so it doesn't
- // interfere with #2). So, we don't need to care about the value of
- // input.prevent_inline_autocomplete() here.
- return view_->DeleteAtEndPressed() || popup_model()->selected_line() != 0 ||
- just_deleted_text_;
-}
-
bool OmniboxEditModel::CurrentTextIsURL() const {
if (view_->toolbar_model()->GetSearchTermsType() !=
ToolbarModel::NO_SEARCH_TERMS)
@@ -502,11 +484,6 @@ void OmniboxEditModel::Revert() {
void OmniboxEditModel::StartAutocomplete(
bool has_selected_text,
bool prevent_inline_autocomplete) const {
- omnibox_controller_->ClearPopupKeywordMode();
-
- bool keyword_is_selected = KeywordIsSelected();
- popup_model()->SetHoveredLine(OmniboxPopupModel::kNoMatch);
-
size_t cursor_position;
if (inline_autocomplete_text_.empty()) {
// Cursor position is equivalent to the current selection's end.
@@ -532,28 +509,15 @@ void OmniboxEditModel::StartAutocomplete(
cursor_position = user_text_.length();
}
- InstantController* instant = controller_->GetInstant();
- if (instant) {
- instant->OnAutocompleteStart();
- // If the embedded page for InstantExtended is fetching its own suggestions,
- // suppress search suggestions from SearchProvider. We still need
- // SearchProvider to run for FinalizeInstantQuery.
- // TODO(dcblack): Once we are done refactoring the omnibox so we don't need
- // to use FinalizeInstantQuery anymore, we can take out this check and
- // remove this provider from kInstantExtendedOmniboxProviders.
- if (instant->WillFetchCompletions())
- autocomplete_controller()->search_provider()->SuppressSearchSuggestions();
- }
-
- // We don't explicitly clear OmniboxPopupModel::manually_selected_match, as
- // Start ends up invoking OmniboxPopupModel::OnResultChanged which clears it.
- autocomplete_controller()->Start(AutocompleteInput(
- user_text_, cursor_position, string16(), GURL(),
+ bool keyword_is_selected = KeywordIsSelected();
+ omnibox_controller_->StartAutocomplete(
+ user_text_,
+ cursor_position,
prevent_inline_autocomplete || just_deleted_text_ ||
(has_selected_text && inline_autocomplete_text_.empty()) ||
- (paste_state_ != NONE), keyword_is_selected,
- keyword_is_selected || allow_exact_keyword_match_,
- AutocompleteInput::ALL_MATCHES));
+ (paste_state_ != NONE),
+ keyword_is_selected,
+ keyword_is_selected || allow_exact_keyword_match_);
}
void OmniboxEditModel::StopAutocomplete() {
@@ -765,7 +729,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match,
// is the same heuristic used by BrowserInstantController::OpenInstant
if (match.transition == content::PAGE_TRANSITION_TYPED &&
disposition == CURRENT_TAB) {
- InstantController* instant = controller_->GetInstant();
+ InstantController* instant = GetInstantController();
if (instant)
instant->OmniboxNavigateToURL();
}
@@ -877,7 +841,7 @@ void OmniboxEditModel::SetCaretVisibility(bool visible) {
}
void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
- InstantController* instant = controller_->GetInstant();
+ InstantController* instant = GetInstantController();
if (instant) {
instant->OmniboxFocusChanged(OMNIBOX_FOCUS_NONE,
OMNIBOX_FOCUS_CHANGE_EXPLICIT,
@@ -979,7 +943,7 @@ void OmniboxEditModel::OnUpOrDownKeyPressed(int count) {
// should force it to open immediately.
}
} else {
- InstantController* instant = controller_->GetInstant();
+ InstantController* instant = GetInstantController();
if (instant && instant->OnUpOrDownKeyPressed(count)) {
// If Instant handles the key press, it's showing a list of suggestions
// that it's stepping through. In that case, our popup model is
@@ -1180,6 +1144,10 @@ bool OmniboxEditModel::OnAfterPossibleChange(const string16& old_text,
void OmniboxEditModel::OnResultChanged(bool default_match_changed) {
}
+InstantController* OmniboxEditModel::GetInstantController() const {
+ return controller_->GetInstant();
+}
+
bool OmniboxEditModel::query_in_progress() const {
return !autocomplete_controller()->done();
}
@@ -1194,6 +1162,10 @@ bool OmniboxEditModel::KeywordIsSelected() const {
return !is_keyword_hint_ && !keyword_.empty();
}
+void OmniboxEditModel::ClearPopupKeywordMode() const {
+ omnibox_controller_->ClearPopupKeywordMode();
+}
+
string16 OmniboxEditModel::DisplayTextFromUserText(const string16& text) const {
return KeywordIsSelected() ?
KeywordProvider::SplitReplacementStringFromInput(text, false) : text;
@@ -1308,7 +1280,7 @@ void OmniboxEditModel::RevertTemporaryText(bool revert_popup) {
selected_instant_autocomplete_match_index_ = OmniboxPopupModel::kNoMatch;
is_instant_temporary_text_a_search_query_ = false;
- InstantController* instant = controller_->GetInstant();
+ InstantController* instant = GetInstantController();
if (instant && notify_instant) {
// Normally, popup_->ResetToDefaultMatch() will cause the view text to be
// updated. In Instant Extended mode however, the popup_ is not used, so it
@@ -1372,36 +1344,6 @@ bool OmniboxEditModel::CreatedKeywordSearchByInsertingSpaceInMiddle(
GetKeywordForText(keyword).empty();
}
-bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match) {
- InstantController* instant = controller_->GetInstant();
- if (!instant || in_revert_)
- return false;
-
- // Don't call Update() if the change is the result of an
- // INSTANT_COMPLETE_REPLACE instant suggestion.
- if (is_temporary_text_set_by_instant_)
- return false;
-
- // The two pieces of text we want to send Instant, viz., what the user has
- // typed, and the full omnibox text including any inline autocompletion.
- string16 user_text = has_temporary_text_ ?
- match.fill_into_edit : DisplayTextFromUserText(user_text_);
- string16 full_text = view_->GetText();
-
- // Remove "?" if we're in forced query mode.
- AutocompleteInput::RemoveForcedQueryStringIfNecessary(
- autocomplete_controller()->input().type(), &user_text);
- AutocompleteInput::RemoveForcedQueryStringIfNecessary(
- autocomplete_controller()->input().type(), &full_text);
-
- size_t start, end;
- view_->GetSelectionBounds(&start, &end);
-
- return instant->Update(match, user_text, full_text, start, end,
- UseVerbatimInstant(), user_input_in_progress_, popup_model()->IsOpen(),
- in_escape_handler_, KeywordIsSelected());
-}
-
// static
bool OmniboxEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) {
switch (c) {
@@ -1441,7 +1383,7 @@ void OmniboxEditModel::SetFocusState(OmniboxFocusState state,
if (state == focus_state_)
return;
- InstantController* instant = controller_->GetInstant();
+ InstantController* instant = GetInstantController();
if (instant)
instant->OmniboxFocusChanged(state, reason, NULL);
diff --git a/chrome/browser/ui/omnibox/omnibox_edit_model.h b/chrome/browser/ui/omnibox/omnibox_edit_model.h
index 0592df7..479facc 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.h
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.h
@@ -75,7 +75,7 @@ class OmniboxEditModel {
void set_popup_model(OmniboxPopupModel* popup_model) {
omnibox_controller_->set_popup_model(popup_model);
- }
+ }
// TODO: The edit and popup should be siblings owned by the LocationBarView,
// making this accessor unnecessary.
@@ -102,11 +102,6 @@ class OmniboxEditModel {
// Sets the url, and if known, the title and favicon.
void GetDataForURLExport(GURL* url, string16* title, gfx::Image* favicon);
- // Returns true if a verbatim query should be used for Instant. A verbatim
- // query is forced in certain situations, such as pressing delete at the end
- // of the edit.
- bool UseVerbatimInstant();
-
// Returns true if the current edit contents will be treated as a
// URL/navigation, as opposed to a search.
bool CurrentTextIsURL() const;
@@ -144,21 +139,16 @@ class OmniboxEditModel {
void SetUserText(const string16& text);
// Calls through to SearchProvider::FinalizeInstantQuery.
- // If |skip_inline_autocomplete| is true then the |suggestion| text will be
- // turned into final text instead of inline autocomplete suggest.
void FinalizeInstantQuery(const string16& input_text,
- const InstantSuggestion& suggestion,
- bool skip_inline_autocomplete);
+ const InstantSuggestion& suggestion);
// Sets the suggestion text.
void SetInstantSuggestion(const InstantSuggestion& suggestion);
- // Commits the suggested text. If |skip_inline_autocomplete| is true then the
- // suggested text will be committed as final text as if it's inputted by the
- // user, rather than as inline autocomplete suggest.
+ // Commits the gray suggested text as if it's been input by the user.
// Returns true if the text was committed.
// TODO: can the return type be void?
- bool CommitSuggestedText(bool skip_inline_autocomplete);
+ bool CommitSuggestedText();
// Invoked any time the text may have changed in the edit. Updates Instant and
// notifies the controller.
@@ -320,6 +310,12 @@ class OmniboxEditModel {
// Called when the results have changed in the OmniboxController.
void OnResultChanged(bool default_match_changed);
+ // TODO(beaudoin): We need this to allow OmniboxController access the
+ // InstantController via OmniboxEditController, because the only valid pointer
+ // to InstantController is kept in Browser. We should try to get rid of this,
+ // maybe by ensuring InstantController lives as long as Browser.
+ InstantController* GetInstantController() const;
+
private:
friend class InstantTestBase;
friend class OmniboxControllerTest;
@@ -361,6 +357,9 @@ class OmniboxEditModel {
// Returns true if a keyword is selected.
bool KeywordIsSelected() const;
+ // Turns off keyword mode for the current match.
+ void ClearPopupKeywordMode() const;
+
// Conversion between user text and display text. User text is the text the
// user has input. Display text is the text being shown in the edit. The
// two are different if a keyword is selected.
@@ -392,13 +391,6 @@ class OmniboxEditModel {
const string16& new_text,
size_t caret_position) const;
- // Tries to start an Instant preview for |match|. Returns true if Instant
- // processed the match.
- bool DoInstant(const AutocompleteMatch& match);
-
- // Starts a DNS prefetch for the given |match|.
- void DoPreconnect(const AutocompleteMatch& match);
-
// Checks if a given character is a valid space character for accepting
// keyword.
static bool IsSpaceCharForAcceptingKeyword(wchar_t c);