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

Unified Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 10836031: Remove Instant v1 API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update history, title, favicon Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 131ee220f3452f182e9fa35e129002f7e3b34feb..bf5901d5c47ac8eb5291de1fbe61987dff7a69fa 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -97,8 +97,7 @@ OmniboxEditModel::OmniboxEditModel(OmniboxView* view,
is_keyword_hint_(false),
profile_(profile),
in_revert_(false),
- allow_exact_keyword_match_(false),
- instant_complete_behavior_(INSTANT_COMPLETE_DELAYED) {
+ allow_exact_keyword_match_(false) {
}
OmniboxEditModel::~OmniboxEditModel() {
@@ -186,8 +185,7 @@ void OmniboxEditModel::FinalizeInstantQuery(const string16& input_text,
void OmniboxEditModel::SetSuggestedText(const string16& text,
InstantCompleteBehavior behavior) {
- instant_complete_behavior_ = behavior;
- if (instant_complete_behavior_ == INSTANT_COMPLETE_NOW) {
+ if (behavior == INSTANT_COMPLETE_NOW) {
if (!text.empty())
FinalizeInstantQuery(view_->GetText(), text, false);
else
@@ -213,7 +211,8 @@ bool OmniboxEditModel::CommitSuggestedText(bool skip_inline_autocomplete) {
bool OmniboxEditModel::AcceptCurrentInstantPreview() {
InstantController* instant = controller_->GetInstant();
- return instant && instant->CommitIfCurrent();
+ return instant && instant->IsCurrent() &&
+ instant->CommitCurrentPreview(INSTANT_COMMIT_PRESSED_ENTER);
}
void OmniboxEditModel::OnChanged() {
@@ -243,10 +242,12 @@ void OmniboxEditModel::OnChanged() {
UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action",
recommended_action,
AutocompleteActionPredictor::LAST_PREDICT_ACTION);
+
string16 suggested_text;
+ InstantCompleteBehavior complete_behavior = INSTANT_COMPLETE_NOW;
- if (DoInstant(current_match, &suggested_text)) {
- SetSuggestedText(suggested_text, instant_complete_behavior_);
+ if (DoInstant(current_match, &suggested_text, &complete_behavior)) {
+ SetSuggestedText(suggested_text, complete_behavior);
} else {
switch (recommended_action) {
case AutocompleteActionPredictor::ACTION_PRERENDER:
@@ -442,7 +443,7 @@ void OmniboxEditModel::StopAutocomplete() {
if (popup_->IsOpen() && !in_revert_) {
InstantController* instant = controller_->GetInstant();
if (instant && !instant->commit_on_pointer_release())
- instant->DestroyPreviewContents();
+ instant->Hide();
}
autocomplete_controller_->Stop(true);
@@ -630,7 +631,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match,
InstantController* instant = controller_->GetInstant();
if (instant && !popup_->IsOpen())
- instant->DestroyPreviewContents();
+ instant->Hide();
in_revert_ = false;
}
@@ -700,8 +701,7 @@ void OmniboxEditModel::OnSetFocus(bool control_down) {
void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
SetSuggestedText(string16(), INSTANT_COMPLETE_NOW);
- InstantController* instant = controller_->GetInstant();
- if (instant)
+ if (InstantController* instant = controller_->GetInstant())
instant->OnAutocompleteLostFocus(view_gaining_focus);
NotifySearchTabHelper();
@@ -1104,9 +1104,12 @@ void OmniboxEditModel::NotifySearchTabHelper() {
}
}
-bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match,
- string16* suggested_text) {
+bool OmniboxEditModel::DoInstant(
+ const AutocompleteMatch& match,
+ string16* suggested_text,
+ InstantCompleteBehavior* complete_behavior) {
DCHECK(suggested_text);
+ DCHECK(complete_behavior);
if (in_revert_)
return false;
@@ -1117,8 +1120,19 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match,
return false;
if (user_input_in_progress_ && popup_->IsOpen()) {
- return instant->Update(match, view_->GetText(), UseVerbatimInstant(),
- suggested_text);
+ string16 text = view_->GetText();
+ AutocompleteInput::RemoveForcedQueryStringIfNecessary(
+ autocomplete_controller_->input().type(), &text);
+
+ // If there's any inline autocompletion, split it out from |text|.
+ if (!inline_autocomplete_text_.empty()) {
+ DCHECK_GE(text.size(), inline_autocomplete_text_.size());
+ text.resize(text.size() - inline_autocomplete_text_.size());
+ *suggested_text = inline_autocomplete_text_;
+ }
+
+ return instant->Update(match, text, UseVerbatimInstant(), suggested_text,
+ complete_behavior);
}
// It's possible DoInstant() was called due to an OnChanged() event from the
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698