summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 23:07:35 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 23:07:35 +0000
commit052212838598dff1ae487e654016da0771b9d975 (patch)
tree21bbec60dec8c7e316a0e99ea9f387ba2e99075e /chrome/browser/autocomplete
parent3828a755146e0102b934281129fdd6425ca19a0f (diff)
downloadchromium_src-052212838598dff1ae487e654016da0771b9d975.zip
chromium_src-052212838598dff1ae487e654016da0771b9d975.tar.gz
chromium_src-052212838598dff1ae487e654016da0771b9d975.tar.bz2
Fix crash due to AutocompletePopup trying to draw the old results when they were no longer available.I introduced this regression when moving |result_| to the AutocompleteController; the specific problem was the "result_.CopyFrom(latest_result_);" line I added when handling the synchronous messages being available. This was done so the popup could get at the new results to update the edit with them.Instead, go back to the old method (of not updating the results until the first coalesced update came in), and pass the appropriate result set as a Details<> in the notification, so the popup can get at it without having to know how the controller works under-the-hood.BUG=11742
Review URL: http://codereview.chromium.org/119116 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17562 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc7
-rw-r--r--chrome/browser/autocomplete/autocomplete.h10
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_model.cc15
-rw-r--r--chrome/browser/autocomplete/autocomplete_unittest.cc2
4 files changed, 19 insertions, 15 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index ca78d7b..95e9956 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -765,10 +765,10 @@ void AutocompleteController::UpdateLatestResult(bool is_synchronous_pass) {
this, &AutocompleteController::CommitResult);
}
- result_.CopyFrom(latest_result_);
NotificationService::current()->Notify(
NotificationType::AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE,
- Source<AutocompleteController>(this), NotificationService::NoDetails());
+ Source<AutocompleteController>(this),
+ Details<const AutocompleteResult>(&latest_result_));
}
if (done_) {
@@ -796,7 +796,8 @@ void AutocompleteController::CommitResult() {
result_.CopyFrom(latest_result_);
NotificationService::current()->Notify(
NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED,
- Source<AutocompleteController>(this), NotificationService::NoDetails());
+ Source<AutocompleteController>(this),
+ Details<const AutocompleteResult>(&result_));
}
ACMatches AutocompleteController::GetMatchesNotInLatestResult(
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index c2b8edd..44664fc 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -736,10 +736,12 @@ class AutocompleteController : public ACProviderListener {
// all providers will be done immediately.
//
// The controller will fire
- // NOTIFY_AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_RESULTS_AVAILABLE from inside
- // this call, and unless the query is stopped, will fire at least one (and
- // prehaps more) NOTIFY_AUTOCOMPLETE_CONTROLLER_RESULTS_UPDATED later as more
- // results come in (even if the query completes synchronously).
+ // AUTOCOMPLETE_CONTROLLER_SYNCHRONOUS_MATCHES_AVAILABLE from inside this
+ // call, and unless the query is stopped, will fire at least one (and perhaps
+ // more) AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED later as more results come in
+ // (even if the query completes synchronously). Listeners should use the
+ // result set provided in the accompanying Details object to update
+ // themselves.
void Start(const std::wstring& text,
const std::wstring& desired_tld,
bool prevent_inline_autocomplete,
diff --git a/chrome/browser/autocomplete/autocomplete_popup_model.cc b/chrome/browser/autocomplete/autocomplete_popup_model.cc
index 0186240..0964781 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_model.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_model.cc
@@ -250,7 +250,7 @@ void AutocompletePopupModel::Move(int count) {
if (IsOpen() && !controller_->done()) {
Observe(NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED,
Source<AutocompleteController>(controller_.get()),
- NotificationService::NoDetails());
+ Details<const AutocompleteResult>(&controller_->result()));
}
const AutocompleteResult& result = controller_->result();
@@ -296,15 +296,16 @@ void AutocompletePopupModel::Observe(NotificationType type,
if (inside_synchronous_query_)
return;
- const AutocompleteResult& result = controller_->result();
+ const AutocompleteResult* result =
+ Details<const AutocompleteResult>(details).ptr();
switch (type.value) {
case NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_UPDATED: {
- selected_line_ = (result.default_match() == result.end()) ?
- kNoMatch : (result.default_match() - result.begin());
+ selected_line_ = (result->default_match() == result->end()) ?
+ kNoMatch : (result->default_match() - result->begin());
// If we're going to trim the window size to no longer include the hovered
// line, turn hover off. Practically, this shouldn't happen, but it
// doesn't hurt to be defensive.
- if ((hovered_line_ != kNoMatch) && (result.size() <= hovered_line_))
+ if ((hovered_line_ != kNoMatch) && (result->size() <= hovered_line_))
SetHoveredLine(kNoMatch);
view_->UpdatePopupAppearance();
@@ -321,8 +322,8 @@ void AutocompletePopupModel::Observe(NotificationType type,
std::wstring keyword;
bool is_keyword_hint = false;
AutocompleteMatch::Type type = AutocompleteMatch::SEARCH_WHAT_YOU_TYPED;
- const AutocompleteResult::const_iterator match(result.default_match());
- if (match != result.end()) {
+ const AutocompleteResult::const_iterator match(result->default_match());
+ if (match != result->end()) {
if ((match->inline_autocomplete_offset != std::wstring::npos) &&
(match->inline_autocomplete_offset <
match->fill_into_edit.length())) {
diff --git a/chrome/browser/autocomplete/autocomplete_unittest.cc b/chrome/browser/autocomplete/autocomplete_unittest.cc
index e7fdd4c..500d79d3 100644
--- a/chrome/browser/autocomplete/autocomplete_unittest.cc
+++ b/chrome/browser/autocomplete/autocomplete_unittest.cc
@@ -162,7 +162,7 @@ void AutocompleteProviderTest::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
if (controller_->done()) {
- result_.CopyFrom(controller_->result());
+ result_.CopyFrom(*(Details<const AutocompleteResult>(details).ptr()));
MessageLoop::current()->Quit();
}
}