summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_edit.h
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 16:59:11 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 16:59:11 +0000
commitdf772cbfe7a1b17dd7bb179c1e25780201d0b0ce (patch)
treebb2c277deb1b3ef07d04b5908e362c0ef7556478 /chrome/browser/autocomplete/autocomplete_edit.h
parent8e0dca871966c15a08c23bfd890aad73ee3b8aa5 (diff)
downloadchromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.zip
chromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.tar.gz
chromium_src-df772cbfe7a1b17dd7bb179c1e25780201d0b0ce.tar.bz2
More work fixing miscellaneous issues in the autocomplete code, probably none of which will help my crasher :(
* Force the query to stop if the user deletes a match. This makes more sense from a UI perspective and allows some code to be simpler. * Prevent us from potentially doing a "minimal changes" match in a different profile (hard to trigger, likely no practical effects) * Remove unneeded Reset() call on a repeating timer (which will auto-reset itself) * Rename one of the notifications and move its listener to the edit, since that's who really cares about it anyway. * Make the controller's Stop(true) notify the popup via the normal observer pipeline rather than coding something special into the popup's StopAutocomplete(). * Rename |paste_and_go_controller| |synchronous_controller| and use it instead of using the main popup controller to do the synchronous query when calling URLsForDefaultMatch(). This makes things both simpler and safer. BUG=none TEST=Using the omnibox still works fine Review URL: http://codereview.chromium.org/178049 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/autocomplete_edit.h')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h
index efe5c9a..4d6c4a7 100644
--- a/chrome/browser/autocomplete/autocomplete_edit.h
+++ b/chrome/browser/autocomplete/autocomplete_edit.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_EDIT_H_
#include "chrome/browser/autocomplete/autocomplete.h"
+#include "chrome/common/notification_registrar.h"
#include "chrome/common/page_transition_types.h"
#include "googleurl/src/gurl.h"
#include "webkit/glue/window_open_disposition.h"
@@ -53,7 +54,7 @@ class AutocompleteEditController {
virtual std::wstring GetTitle() const = 0;
};
-class AutocompleteEditModel {
+class AutocompleteEditModel : public NotificationObserver {
public:
enum KeywordUIState {
// The user is typing normally.
@@ -96,9 +97,7 @@ class AutocompleteEditModel {
Profile* profile);
~AutocompleteEditModel();
- void set_popup_model(AutocompletePopupModel* popup_model) {
- popup_ = popup_model;
- }
+ void SetPopupModel(AutocompletePopupModel* popup_model);
// Invoked when the profile has changed.
void SetProfile(Profile* profile);
@@ -241,9 +240,9 @@ class AutocompleteEditModel {
// negative for moving up, positive for moving down.
void OnUpOrDownKeyPressed(int count);
- // Called back by the AutocompletePopupModel when any relevant data changes.
- // This rolls together several separate pieces of data into one call so we can
- // update all the UI efficiently:
+ // Called when any relevant data changes. This rolls together several
+ // separate pieces of data into one call so we can update all the UI
+ // efficiently:
// |text| is either the new temporary text (if |is_temporary_text| is true)
// from the user manually selecting a different match, or the inline
// autocomplete text (if |is_temporary_text| is false).
@@ -296,6 +295,11 @@ class AutocompleteEditModel {
// he intended to hit "ctrl-enter".
};
+ // NotificationObserver
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// Called whenever user_text_ should change.
void InternalSetUserText(const std::wstring& text);
@@ -314,7 +318,19 @@ class AutocompleteEditModel {
// not needed).
GURL GetURLForCurrentText(PageTransition::Type* transition,
bool* is_history_what_you_typed_match,
- GURL* alternate_nav_url);
+ GURL* alternate_nav_url) const;
+
+ // Performs a query for only the synchronously available matches for the
+ // current input, sets |transition|, |is_history_what_you_typed_match|, and
+ // |alternate_nav_url| (if applicable) based on the default match, and returns
+ // its url. |transition|, |is_history_what_you_typed_match| and/or
+ // |alternate_nav_url| may be null, in which case they are not updated.
+ //
+ // If there are no matches for the input, leaves the outparams unset and
+ // returns the empty string.
+ GURL URLsForDefaultMatch(PageTransition::Type* transition,
+ bool* is_history_what_you_typed_match,
+ GURL* alternate_nav_url) const;
AutocompleteEditView* view_;
@@ -322,6 +338,8 @@ class AutocompleteEditModel {
AutocompleteEditController* controller_;
+ NotificationRegistrar registrar_;
+
// Whether the edit has focus.
bool has_focus_;