diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 16:04:33 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 16:04:33 +0000 |
commit | 45fb1467431370f35763e3077c1db2df7539f42c (patch) | |
tree | 34060cf748228b83e95d9a088f5aeee611243437 /chrome/browser/autocomplete | |
parent | 371cc8b150c13f3ddc1c8e23d8d879f836f02e2f (diff) | |
download | chromium_src-45fb1467431370f35763e3077c1db2df7539f42c.zip chromium_src-45fb1467431370f35763e3077c1db2df7539f42c.tar.gz chromium_src-45fb1467431370f35763e3077c1db2df7539f42c.tar.bz2 |
Adds some additional AutocompleteEditController methods. They are
currently views only, but that will change once everything is working.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3272009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
5 files changed, 45 insertions, 5 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index f63c2b8..0c9eb75 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -129,9 +129,10 @@ void AutocompleteEditModel::RestoreState(const State& state) { } } -GURL AutocompleteEditModel::CurrentURL() { +GURL AutocompleteEditModel::CurrentURL(PageTransition::Type* transition_type) { AutocompleteMatch match; GetInfoForCurrentText(&match, NULL); + *transition_type = match.transition; return match.destination_url; } @@ -403,6 +404,9 @@ void AutocompleteEditModel::OpenURL(const GURL& url, // search engine, if applicable; see comments in template_url.h. } +#if defined(TOOLKIT_VIEWS) + controller_->OnAutocompleteWillAccept(); +#endif if (disposition != NEW_BACKGROUND_TAB) view_->RevertAll(); // Revert the box to its unedited state controller_->OnAutocompleteAccept(url, disposition, transition, diff --git a/chrome/browser/autocomplete/autocomplete_edit.h b/chrome/browser/autocomplete/autocomplete_edit.h index 38804999..8376cb5 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.h +++ b/chrome/browser/autocomplete/autocomplete_edit.h @@ -10,6 +10,7 @@ #include "chrome/common/notification_observer.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/page_transition_types.h" +#include "gfx/native_widget_types.h" #include "googleurl/src/gurl.h" #include "webkit/glue/window_open_disposition.h" @@ -28,6 +29,21 @@ class AutocompleteEditView; // Embedders of an AutocompleteEdit widget must implement this class. class AutocompleteEditController { public: +#if defined(TOOLKIT_VIEWS) + // Sent when the autocomplete popup is about to close. + virtual void OnAutocompleteWillClosePopup() = 0; + + // Sent when the edit is losing focus. |view_gaining_focus| is the view + // gaining focus and may be null. + virtual void OnAutocompleteLosingFocus( + gfx::NativeView view_gaining_focus) = 0; + + // Sent prior to OnAutoCompleteAccept and before the model has been reverted. + virtual void OnAutocompleteWillAccept() = 0; +#else + // TODO: port. +#endif + // When the user presses enter or selects a line with the mouse, this // function will get called synchronously with the url to open and // disposition and transition to use when opening it. @@ -118,10 +134,10 @@ class AutocompleteEditModel : public NotificationObserver { // Restores local state from the saved |state|. void RestoreState(const State& state); - // Returns the url for the current text. If the user has not edited the text - // this is the permanent url, otherwise it is the url the user would navigate - // to if they accept the current edit. - GURL CurrentURL(); + // Returns the url and transition type for the current text. If the user has + // not edited the text this is the permanent url, otherwise it is the url the + // user would navigate to if they accept the current edit. + GURL CurrentURL(PageTransition::Type* transition_type); // Called when the user wants to export the entire current text as a URL. // Sets the url, and if known, the title and favicon. diff --git a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc index bd48602..0cbec9e 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_unittest.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_unittest.cc @@ -59,6 +59,9 @@ class TestingAutocompleteEditView : public AutocompleteEditView { class TestingAutocompleteEditController : public AutocompleteEditController { public: TestingAutocompleteEditController() {} + virtual void OnAutocompleteWillClosePopup() {} + virtual void OnAutocompleteLosingFocus(gfx::NativeView view_gaining_focus) {} + virtual void OnAutocompleteWillAccept() {} virtual void OnAutocompleteAccept(const GURL& url, WindowOpenDisposition disposition, PageTransition::Type transition, diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc index e3508f4..ec86e2e 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_gtk.cc @@ -484,6 +484,11 @@ void AutocompleteEditViewGtk::UpdatePopup() { } void AutocompleteEditViewGtk::ClosePopup() { +#if defined(TOOLKIT_VIEWS) + if (popup_view_->GetModel()->IsOpen()) + controller_->OnAutocompleteWillClosePopup(); +#endif + popup_view_->GetModel()->StopAutocomplete(); } @@ -914,6 +919,12 @@ gboolean AutocompleteEditViewGtk::HandleViewFocusIn(GtkWidget* sender, gboolean AutocompleteEditViewGtk::HandleViewFocusOut(GtkWidget* sender, GdkEventFocus* event) { +#if defined(TOOLKIT_VIEWS) + // This must be invoked before ClosePopup. + // TODO: figure out who is getting focus. + controller_->OnAutocompleteLosingFocus(NULL); +#endif + // Close the popup. ClosePopup(); // Tell the model to reset itself. diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 802e54d..0230fb3 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -696,6 +696,9 @@ void AutocompleteEditViewWin::UpdatePopup() { } void AutocompleteEditViewWin::ClosePopup() { + if (popup_view_->GetModel()->IsOpen()) + controller_->OnAutocompleteWillClosePopup(); + popup_view_->GetModel()->StopAutocomplete(); } @@ -1352,6 +1355,9 @@ void AutocompleteEditViewWin::OnKillFocus(HWND focus_wnd) { return; } + // This must be invoked before ClosePopup. + controller_->OnAutocompleteLosingFocus(focus_wnd); + // Close the popup. ClosePopup(); |