summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 04:49:34 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 04:49:34 +0000
commit4ab4c7c5fd8008de223d1bb7f2361cd80bac9778 (patch)
tree54e963ae4e745d8f9370bf759d171feb99c5af97
parent4030ced8df93134f9da566dddd5fcb7e1882307f (diff)
downloadchromium_src-4ab4c7c5fd8008de223d1bb7f2361cd80bac9778.zip
chromium_src-4ab4c7c5fd8008de223d1bb7f2361cd80bac9778.tar.gz
chromium_src-4ab4c7c5fd8008de223d1bb7f2361cd80bac9778.tar.bz2
Makes committing the suggested text only update the default search
provider and nothing else. BUG=none TEST=none Review URL: http://codereview.chromium.org/5270001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67218 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc3
-rw-r--r--chrome/browser/autocomplete/autocomplete.h6
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.cc4
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h3
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_unittest.cc1
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view.h3
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc22
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_gtk.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_mac.mm12
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.cc14
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_win.h2
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.h3
-rw-r--r--chrome/browser/autocomplete/search_provider.cc60
-rw-r--r--chrome/browser/autocomplete/search_provider.h11
-rw-r--r--chrome/browser/cocoa/location_bar/location_bar_view_mac.mm6
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc3
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc15
19 files changed, 114 insertions, 66 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index 6dafeaf..01d36fa 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -634,7 +634,8 @@ AutocompleteController::AutocompleteController(Profile* profile)
delay_interval_has_passed_(false),
have_committed_during_this_query_(false),
done_(true) {
- providers_.push_back(new SearchProvider(this, profile));
+ search_provider_ = new SearchProvider(this, profile);
+ providers_.push_back(search_provider_);
if (!CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableHistoryQuickProvider))
providers_.push_back(new HistoryQuickProvider(this, profile));
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index 02dac74..dbf5c0e 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -154,6 +154,7 @@ class AutocompleteResult;
class AutocompleteController;
class HistoryContentsProvider;
class Profile;
+class SearchProvider;
class TemplateURL;
typedef std::vector<AutocompleteMatch> ACMatches;
@@ -537,6 +538,7 @@ class AutocompleteController : public ACProviderListener {
explicit AutocompleteController(const ACProviders& providers)
: providers_(providers),
history_contents_provider_(NULL),
+ search_provider_(NULL),
updated_latest_result_(false),
delay_interval_has_passed_(false),
have_committed_during_this_query_(false),
@@ -603,6 +605,8 @@ class AutocompleteController : public ACProviderListener {
// This is used by the popup to ensure it's not showing an out-of-date query.
void CommitIfQueryHasNeverBeenCommitted();
+ SearchProvider* search_provider() const { return search_provider_; }
+
// Getters
const AutocompleteInput& input() const { return input_; }
const AutocompleteResult& result() const { return result_; }
@@ -650,6 +654,8 @@ class AutocompleteController : public ACProviderListener {
HistoryContentsProvider* history_contents_provider_;
+ SearchProvider* search_provider_;
+
// Input passed to Start.
AutocompleteInput input_;
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc
index d64a231..82a03f6 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit.cc
@@ -158,6 +158,10 @@ void AutocompleteEditModel::SetUserText(const std::wstring& text) {
has_temporary_text_ = false;
}
+void AutocompleteEditModel::FinalizeInstantQuery(const std::wstring& text) {
+ popup_->FinalizeInstantQuery(text);
+}
+
void AutocompleteEditModel::GetDataForURLExport(GURL* url,
std::wstring* title,
SkBitmap* favicon) {
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index 7123b36..90fc643 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -209,6 +209,9 @@ class AutocompleteEditModel : public NotificationObserver {
// Sets the user_text_ to |text|. Only the View should call this.
void SetUserText(const std::wstring& text);
+ // Calls through to SearchProvider::FinalizeInstantQuery.
+ void FinalizeInstantQuery(const std::wstring& text);
+
// Reverts the edit model back to its unedited state (permanent text showing,
// no user input in progress).
void Revert();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
index d8a503b..d70d07f 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc
@@ -33,7 +33,6 @@ class TestingAutocompleteEditView : public AutocompleteEditView {
bool update_popup) {}
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos) {}
- virtual void ReplaceSelection(const string16& text) {}
virtual void SetForcedQuery() {}
virtual bool IsSelectAll() { return false; }
virtual bool DeleteAtEndPressed() { return false; }
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view.h b/chrome/browser/autocomplete/autocomplete_edit_view.h
index dc35912..439b2ed 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view.h
@@ -80,9 +80,6 @@ class AutocompleteEditView {
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos) = 0;
- // Replaces the selection with the specified text and selects it.
- virtual void ReplaceSelection(const string16& text) = 0;
-
// Sets the edit to forced query mode. Practically speaking, this means that
// if the edit is not in forced query mode, its text is set to "?" with the
// cursor at the end, and if the edit is in forced query mode (its first
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
index 6a0396a..e9ffe3d 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc
@@ -547,24 +547,6 @@ void AutocompleteEditViewGtk::SetWindowTextAndCaretPos(const std::wstring& text,
SetTextAndSelectedRange(text, range);
}
-void AutocompleteEditViewGtk::ReplaceSelection(const string16& text) {
- CharRange selection = GetSelection();
- if (selection.selection_min() == selection.selection_max() &&
- text.empty()) {
- return;
- }
- std::wstring current_text(GetText());
- std::wstring result = current_text.substr(0, selection.selection_min()) +
- UTF16ToWide(text) + current_text.substr(selection.selection_max());
- selection.cp_min = selection.selection_min();
- selection.cp_max = UTF16ToWide(text).size() + selection.cp_min;
- StartUpdatingHighlightedText();
- OnBeforePossibleChange();
- SetTextAndSelectedRange(result, selection);
- OnAfterPossibleChange();
- FinishUpdatingHighlightedText();
-}
-
void AutocompleteEditViewGtk::SetForcedQuery() {
const std::wstring current_text(GetText());
const size_t start = current_text.find_first_not_of(kWhitespaceWide);
@@ -1711,9 +1693,7 @@ bool AutocompleteEditViewGtk::CommitInstantSuggestion() {
if (!suggestion || !*suggestion)
return false;
- OnBeforePossibleChange();
- SetUserText(GetText() + UTF8ToWide(suggestion));
- OnAfterPossibleChange();
+ model()->FinalizeInstantQuery(GetText() + UTF8ToWide(suggestion));
return true;
}
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
index c2ade1b..78c8302 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.h
@@ -117,8 +117,6 @@ class AutocompleteEditViewGtk : public AutocompleteEditView,
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
- virtual void ReplaceSelection(const string16& text);
-
virtual void SetForcedQuery();
virtual bool IsSelectAll();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
index b02bafc..094712c 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.h
@@ -58,8 +58,6 @@ class AutocompleteEditViewMac : public AutocompleteEditView,
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
- virtual void ReplaceSelection(const string16& text);
-
virtual void SetForcedQuery();
virtual bool IsSelectAll();
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
index b91d3a5..1d98032 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_mac.mm
@@ -354,10 +354,6 @@ void AutocompleteEditViewMac::SetWindowTextAndCaretPos(const std::wstring& text,
SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos));
}
-void AutocompleteEditViewMac::ReplaceSelection(const string16& text) {
- NOTIMPLEMENTED();
-}
-
void AutocompleteEditViewMac::SetForcedQuery() {
// We need to do this first, else |SetSelectedRange()| won't work.
FocusLocation(true);
@@ -478,10 +474,12 @@ void AutocompleteEditViewMac::SetSuggestText(const string16& suggest_text) {
}
bool AutocompleteEditViewMac::CommitSuggestText() {
- bool success = (suggest_text_length_ > 0);
+ if (suggest_text_length_ == 0)
+ return false;
+
suggest_text_length_ = 0;
- SetText(GetText());
- return success;
+ model()->FinalizeInstantQuery(GetText());
+ return true;
}
void AutocompleteEditViewMac::SetText(const std::wstring& display_text) {
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
index 05d149e..7571e35 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc
@@ -653,20 +653,6 @@ void AutocompleteEditViewWin::SetWindowTextAndCaretPos(const std::wstring& text,
PlaceCaretAt(caret_pos);
}
-void AutocompleteEditViewWin::ReplaceSelection(const string16& text) {
- CHARRANGE selection;
- GetSel(selection);
- if (selection.cpMin == selection.cpMax && text.empty())
- return;
-
- const std::wstring w_text(UTF16ToWide(text));
- ScopedFreeze freeze(this, GetTextObjectModel());
- OnBeforePossibleChange();
- ReplaceSel(w_text.c_str(), TRUE);
- SetSelection(selection.cpMin, selection.cpMin + w_text.size());
- OnAfterPossibleChange();
-}
-
void AutocompleteEditViewWin::SetForcedQuery() {
const std::wstring current_text(GetText());
const size_t start = current_text.find_first_not_of(kWhitespaceWide);
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
index c78565f..3a9c0b2 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h
@@ -114,8 +114,6 @@ class AutocompleteEditViewWin
virtual void SetWindowTextAndCaretPos(const std::wstring& text,
size_t caret_pos);
- virtual void ReplaceSelection(const string16& text);
-
virtual void SetForcedQuery();
virtual bool IsSelectAll();
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index a857b3c..1a094fc 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/autocomplete_popup_view.h"
+#include "chrome/browser/autocomplete/search_provider.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/search_engines/template_url.h"
@@ -234,6 +235,13 @@ bool AutocompletePopupModel::GetKeywordForMatch(const AutocompleteMatch& match,
return true;
}
+void AutocompletePopupModel::FinalizeInstantQuery(const std::wstring& text) {
+ if (IsOpen()) {
+ SearchProvider* search_provider = controller_->search_provider();
+ search_provider->FinalizeInstantQuery(text);
+ }
+}
+
AutocompleteLog* AutocompletePopupModel::GetAutocompleteLog() {
return new AutocompleteLog(controller_->input().text(),
controller_->input().type(), selected_line_, 0, controller_->result());
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.h b/chrome/browser/autocomplete/autocomplete_popup_model.h
index 5d42a72..19bfae1 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.h
@@ -99,6 +99,9 @@ class AutocompletePopupModel : public NotificationObserver {
bool GetKeywordForMatch(const AutocompleteMatch& match,
std::wstring* keyword) const;
+ // Calls through to SearchProvider::FinalizeInstantQuery.
+ void FinalizeInstantQuery(const std::wstring& text);
+
// Returns a pointer to a heap-allocated AutocompleteLog containing the
// current input text, selected match, and result set. The caller is
// responsible for deleting the object.
diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index a18a5ea..afd0558 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
@@ -59,13 +60,59 @@ void SearchProvider::Providers::Set(const TemplateURL* default_provider,
SearchProvider::SearchProvider(ACProviderListener* listener, Profile* profile)
: AutocompleteProvider(listener, profile, "Search"),
suggest_results_pending_(0),
- have_suggest_results_(false) {
+ instant_finalized_(false) {
+}
+
+void SearchProvider::FinalizeInstantQuery(const std::wstring& text) {
+ if (done_ || instant_finalized_)
+ return;
+
+ instant_finalized_ = true;
+ UpdateDone();
+
+ if (text.empty()) {
+ // We only need to update the listener if we're actually done.
+ if (done_)
+ listener_->OnProviderUpdate(false);
+ return;
+ }
+
+ // Remove any matches that are identical to |text|. We don't use the
+ // destination_url for comparison as it varies depending upon the index passed
+ // to TemplateURL::ReplaceSearchTerms.
+ for (ACMatches::iterator i = matches_.begin(); i != matches_.end();) {
+ if (((i->type == AutocompleteMatch::SEARCH_HISTORY) ||
+ (i->type == AutocompleteMatch::SEARCH_SUGGEST)) &&
+ (i->fill_into_edit == text)) {
+ ACMatches::iterator to_erase = i;
+ ++i;
+ matches_.erase(to_erase);
+ } else {
+ ++i;
+ }
+ }
+
+ // Add the new suggest result. We give it a rank higher than
+ // SEARCH_WHAT_YOU_TYPED so that it gets autocompleted.
+ int did_not_accept_default_suggestion = default_suggest_results_.empty() ?
+ TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
+ TemplateURLRef::NO_SUGGESTION_CHOSEN;
+ MatchMap match_map;
+ AddMatchToMap(text, CalculateRelevanceForWhatYouTyped() + 1,
+ AutocompleteMatch::SEARCH_SUGGEST,
+ did_not_accept_default_suggestion, false, &match_map);
+ DCHECK_EQ(1u, match_map.size());
+ matches_.push_back(match_map.begin()->second);
+
+ listener_->OnProviderUpdate(true);
}
void SearchProvider::Start(const AutocompleteInput& input,
bool minimal_changes) {
matches_.clear();
+ instant_finalized_ = input.synchronous_only();
+
// Can't return search/suggest results for bogus input or without a profile.
if (!profile_ || (input.type() == AutocompleteInput::INVALID)) {
Stop();
@@ -494,9 +541,7 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() {
UpdateStarredStateOfMatches();
- // We're done when there are no more suggest queries pending (this is set to 1
- // when the timer is started).
- done_ = suggest_results_pending_ == 0;
+ UpdateDone();
}
void SearchProvider::AddNavigationResultsToMatches(
@@ -761,3 +806,10 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
return match;
}
+
+void SearchProvider::UpdateDone() {
+ // We're done when there are no more suggest queries pending (this is set to 1
+ // when the timer is started) and we're not waiting on instant.
+ done_ = ((suggest_results_pending_ == 0) &&
+ (instant_finalized_ || !InstantController::IsEnabled(profile_)));
+}
diff --git a/chrome/browser/autocomplete/search_provider.h b/chrome/browser/autocomplete/search_provider.h
index f1d5ffd..6667f1e 100644
--- a/chrome/browser/autocomplete/search_provider.h
+++ b/chrome/browser/autocomplete/search_provider.h
@@ -52,6 +52,11 @@ class SearchProvider : public AutocompleteProvider,
}
#endif
+ // Marks the instant query as done. If |text| is non-empty this changes the
+ // 'search what you typed' results text to |text|. This also marks the search
+ // provider as no longer needing to wait for the instant result.
+ void FinalizeInstantQuery(const std::wstring& text);
+
// AutocompleteProvider
virtual void Start(const AutocompleteInput& input,
bool minimal_changes);
@@ -252,6 +257,9 @@ class SearchProvider : public AutocompleteProvider,
int relevance,
bool is_keyword);
+ // Updates the value of |done_| from the internal state.
+ void UpdateDone();
+
// Should we query for suggest results immediately? This is normally false,
// but may be set to true during testing.
static bool query_suggest_immediately_;
@@ -295,6 +303,9 @@ class SearchProvider : public AutocompleteProvider,
// Whether suggest_results_ is valid.
bool have_suggest_results_;
+ // Has FinalizeInstantQuery been invoked since the last |Start|?
+ bool instant_finalized_;
+
DISALLOW_COPY_AND_ASSIGN(SearchProvider);
};
diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm
index e4b2ce1..2f106ab 100644
--- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm
+++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm
@@ -324,9 +324,11 @@ void LocationBarViewMac::OnChanged() {
WideToUTF16(edit_view_->GetText()),
edit_view_->model()->UseVerbatimInstant(),
&suggested_text);
+ if (!instant->IsShowingInstant())
+ edit_view_->model()->FinalizeInstantQuery(std::wstring());
} else {
- if (instant->is_active())
- instant->DestroyPreviewContents();
+ instant->DestroyPreviewContents();
+ edit_view_->model()->FinalizeInstantQuery(std::wstring());
}
}
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index dcd5925..ac56c15 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -542,8 +542,11 @@ void LocationBarViewGtk::OnChanged() {
WideToUTF16(location_entry_->GetText()),
location_entry_->model()->UseVerbatimInstant(),
&suggested_text);
+ if (!instant->IsShowingInstant())
+ location_entry_->model()->FinalizeInstantQuery(std::wstring());
} else {
instant->DestroyPreviewContents();
+ location_entry_->model()->FinalizeInstantQuery(std::wstring());
}
}
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index bfcb980..4a23cbc 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -412,10 +412,7 @@ void LocationBarView::OnCommitSuggestedText() {
InstantController* instant = delegate_->GetInstant();
DCHECK(instant);
DCHECK(suggested_text_view_);
- location_entry_->ReplaceSelection(
- WideToUTF16(suggested_text_view_->GetText()));
- // TODO(sky): We need to route the suggestion through InstantController so it
- // doesn't fetch suggestions.
+ OnCommitSuggestedText(location_entry_->GetText());
}
gfx::Size LocationBarView::GetPreferredSize() {
@@ -783,9 +780,8 @@ bool LocationBarView::OnCommitSuggestedText(const std::wstring& typed_text) {
suggested_text_view_->GetText().empty()) {
return false;
}
- // TODO(sky): I may need to route this through InstantController so that we
- // don't fetch suggestions for the new combined text.
- location_entry_->SetUserText(typed_text + suggested_text_view_->GetText());
+ location_entry_->model()->FinalizeInstantQuery(
+ typed_text + suggested_text_view_->GetText());
return true;
}
@@ -846,6 +842,8 @@ void LocationBarView::OnChanged() {
Layout();
SchedulePaint();
+ // TODO(sky): code for updating instant is nearly identical on all platforms.
+ // It sould be pushed to a common place.
InstantController* instant = delegate_->GetInstant();
string16 suggested_text;
if (update_instant_ && instant && GetTabContentsWrapper()) {
@@ -856,8 +854,11 @@ void LocationBarView::OnChanged() {
WideToUTF16(location_entry_->GetText()),
location_entry_->model()->UseVerbatimInstant(),
&suggested_text);
+ if (!instant->IsShowingInstant())
+ location_entry_->model()->FinalizeInstantQuery(std::wstring());
} else {
instant->DestroyPreviewContents();
+ location_entry_->model()->FinalizeInstantQuery(std::wstring());
}
}