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

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

Issue 12792013: Instant extended: Remove suggest commit on lost focus (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/search/instant_controller.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 ff3e0fdf807670f05da05cea814aaf65656a3fdb..ea333289fd304a75704a4457a59cdeede09981ea 100644
--- a/chrome/browser/ui/omnibox/omnibox_edit_model.cc
+++ b/chrome/browser/ui/omnibox/omnibox_edit_model.cc
@@ -93,11 +93,13 @@ enum UserTextClearedType {
OmniboxEditModel::State::State(bool user_input_in_progress,
const string16& user_text,
+ const string16& instant_suggestion,
const string16& keyword,
bool is_keyword_hint,
OmniboxFocusState focus_state)
: user_input_in_progress(user_input_in_progress),
user_text(user_text),
+ instant_suggestion(instant_suggestion),
keyword(keyword),
is_keyword_hint(is_keyword_hint),
focus_state(focus_state) {
@@ -156,7 +158,11 @@ const OmniboxEditModel::State OmniboxEditModel::GetStateForTabSwitch() {
}
}
- return State(user_input_in_progress_, user_text_, keyword_, is_keyword_hint_,
+ return State(user_input_in_progress_,
+ user_text_,
+ view_->GetInstantSuggestion(),
+ keyword_,
+ is_keyword_hint_,
focus_state_);
}
@@ -170,6 +176,7 @@ void OmniboxEditModel::RestoreState(const State& state) {
is_keyword_hint_ = state.is_keyword_hint;
view_->SetUserText(state.user_text,
DisplayTextFromUserText(state.user_text), false);
+ view_->SetInstantSuggestion(state.instant_suggestion);
}
}
@@ -184,9 +191,19 @@ bool OmniboxEditModel::UpdatePermanentText(const string16& new_permanent_text) {
// doesn't have focus, we want to revert the edit to show the new URL. (The
// common case where the edit doesn't have focus is when the user has started
// an edit and then abandoned it and clicked a link on the page.)
+ //
+ // If the page is auto-committing an instant suggestion, however, we generally
+ // don't want to make any change to the edit. While auto-commits modify the
+ // underlying permanent URL, they're intended to have no effect on the user's
+ // editing process -- before and after the auto-commit, the omnibox should
+ // show the same user text and the same instant suggestion, even if the
+ // auto-commit happens while the edit doesn't have focus.
+ string16 instant_suggestion = view_->GetInstantSuggestion();
const bool visibly_changed_permanent_text =
(permanent_text_ != new_permanent_text) &&
- (!user_input_in_progress_ || !has_focus());
+ (!user_input_in_progress_ || !has_focus()) &&
+ (instant_suggestion.empty() ||
+ new_permanent_text != user_text_ + instant_suggestion);
permanent_text_ = new_permanent_text;
return visibly_changed_permanent_text;
@@ -814,8 +831,6 @@ void OmniboxEditModel::OnWillKillFocus(gfx::NativeView view_gaining_focus) {
view_gaining_focus);
}
- SetInstantSuggestion(InstantSuggestion());
-
// TODO(jered): Rip this out along with StartZeroSuggest.
autocomplete_controller_->StopZeroSuggest();
delegate_->NotifySearchTabHelper(user_input_in_progress_, !in_revert_);
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_edit_model.h ('k') | chrome/browser/ui/search/instant_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698