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

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

Issue 10732002: Upstream rewrite of Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: First round of comments Created 8 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 side-by-side diff with in-line comments
Download patch
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 51282acd5b1248c8b6b3cc489a8f065853135e50..096af3a466c07317d462130eddd2e89ba2af069f 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -211,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() {
@@ -241,10 +242,12 @@ void OmniboxEditModel::OnChanged() {
UMA_HISTOGRAM_ENUMERATION("AutocompleteActionPredictor.Action",
recommended_action,
AutocompleteActionPredictor::LAST_PREDICT_ACTION);
- string16 suggested_text;
- if (DoInstant(current_match, &suggested_text)) {
- SetSuggestedText(suggested_text, instant_complete_behavior_);
+ string16 suggested_text = inline_autocomplete_text_;
+ InstantCompleteBehavior complete_behavior = INSTANT_COMPLETE_NOW;
+
+ if (DoInstant(current_match, &suggested_text, &complete_behavior)) {
+ SetSuggestedText(suggested_text, complete_behavior);
} else {
switch (recommended_action) {
case AutocompleteActionPredictor::ACTION_PRERENDER:
@@ -440,7 +443,7 @@ void OmniboxEditModel::StopAutocomplete() {
if (popup_->IsOpen() && !in_revert_) {
InstantController* instant = controller_->GetInstant();
if (instant && !instant->commit_on_mouse_up())
- instant->DestroyPreviewContents();
+ instant->Hide();
}
autocomplete_controller_->Stop(true);
@@ -612,7 +615,7 @@ void OmniboxEditModel::OpenMatch(const AutocompleteMatch& match,
InstantController* instant = controller_->GetInstant();
if (instant && !popup_->IsOpen())
- instant->DestroyPreviewContents();
+ instant->Hide();
in_revert_ = false;
}
@@ -679,12 +682,11 @@ void OmniboxEditModel::OnSetFocus(bool control_down) {
NotifySearchTabHelper();
}
-void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
+void OmniboxEditModel::OnWillKillFocus() {
SetSuggestedText(string16(), INSTANT_COMPLETE_NOW);
- InstantController* instant = controller_->GetInstant();
- if (instant)
- instant->OnAutocompleteLostFocus(view_gaining_focus);
+ if (InstantController* instant = controller_->GetInstant())
+ instant->OnAutocompleteLostFocus();
NotifySearchTabHelper();
}
@@ -1086,9 +1088,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;
@@ -1099,8 +1104,8 @@ bool OmniboxEditModel::DoInstant(const AutocompleteMatch& match,
return false;
if (user_input_in_progress_ && popup_->IsOpen()) {
- return instant->Update(match, view_->GetText(), UseVerbatimInstant(),
- suggested_text);
+ return instant->Update(match, DisplayTextFromUserText(user_text_),
+ UseVerbatimInstant(), suggested_text, complete_behavior);
}
// It's possible DoInstant() was called due to an OnChanged() event from the

Powered by Google App Engine
This is Rietveld 408576698