diff options
author | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-17 23:22:12 +0000 |
---|---|---|
committer | nirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-17 23:22:12 +0000 |
commit | c16548359bbab8ca1adaca4653f092fba4dbcee0 (patch) | |
tree | e76ec5ff9f1a308a488011989a710fcf161a1384 /chrome | |
parent | b112298f642b44d190d201a64cdc60963266551a (diff) | |
download | chromium_src-c16548359bbab8ca1adaca4653f092fba4dbcee0.zip chromium_src-c16548359bbab8ca1adaca4653f092fba4dbcee0.tar.gz chromium_src-c16548359bbab8ca1adaca4653f092fba4dbcee0.tar.bz2 |
Omnibox automation should wait for page load after selecting a popup item.
TEST=python chrome/test/functional/omnibox.py omnibox.OmniboxTest.testSelect
Review URL: http://codereview.chromium.org/2136010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 12 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 1 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.cc | 33 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_observers.h | 22 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyauto.py | 1 |
5 files changed, 63 insertions, 6 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index e146f1b..8815104 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1970,14 +1970,14 @@ void AutomationProvider::OmniboxMovePopupSelection( void AutomationProvider::OmniboxAcceptInput(Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { - std::string json_return = "{}"; - bool reply_return = true; + NavigationController& tab = + browser->GetOrCloneNavigationControllerForDisposition(CURRENT_TAB); + // Setup observer to wait until the selected item loads. + NotificationObserver* observer = + new OmniboxAcceptNotificationObserver(&tab, this, reply_message); + notification_observer_list_.AddObserver(observer); browser->window()->GetLocationBar()->AcceptInput(); - - AutomationMsg_SendJSONRequest::WriteReplyParams( - reply_message, json_return, reply_return); - Send(reply_message); } // Sample json input: { "command": "GetPluginsInfo" } diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 0b5e425..61f0f0f 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -418,6 +418,7 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // Accept the current string of text in the omnibox. // This is equivalent to clicking or hiting enter on a popup selection. + // Blocks until the page loads. // Uses the JSON interface for input/output. void OmniboxAcceptInput(Browser* browser, DictionaryValue* args, diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc index 3ca82e6..ce1750e 100644 --- a/chrome/browser/automation/automation_provider_observers.cc +++ b/chrome/browser/automation/automation_provider_observers.cc @@ -969,3 +969,36 @@ void AutomationProviderHistoryObserver::HistoryQueryComplete( provider_->Send(reply_message_); delete this; } + +OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( + NavigationController* controller, + AutomationProvider* automation, + IPC::Message* reply_message) + : automation_(automation), + reply_message_(reply_message), + controller_(controller) { + Source<NavigationController> source(controller_); + registrar_.Add(this, NotificationType::LOAD_STOP, source); + // Pages requiring auth don't send LOAD_STOP. + registrar_.Add(this, NotificationType::AUTH_NEEDED, source); +} + +OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { + automation_->RemoveNavigationStatusListener(this); +} + +void OmniboxAcceptNotificationObserver::Observe( + NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::LOAD_STOP || + type == NotificationType::AUTH_NEEDED) { + AutomationMsg_SendJSONRequest::WriteReplyParams( + reply_message_, std::string("{}"), false); + automation_->Send(reply_message_); + delete this; + } else { + NOTREACHED(); + } +} + diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h index efb01e0..6481005 100644 --- a/chrome/browser/automation/automation_provider_observers.h +++ b/chrome/browser/automation/automation_provider_observers.h @@ -598,4 +598,26 @@ class AutomationProviderHistoryObserver { IPC::Message* reply_message_; }; +// Allows automation provider to wait until page load after selecting an item +// in the omnibox popup. +class OmniboxAcceptNotificationObserver : public NotificationObserver { + public: + OmniboxAcceptNotificationObserver(NavigationController* controller, + AutomationProvider* automation, + IPC::Message* reply_message); + ~OmniboxAcceptNotificationObserver(); + + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + private: + NotificationRegistrar registrar_; + AutomationProvider* automation_; + IPC::Message* reply_message_; + NavigationController* controller_; + + DISALLOW_COPY_AND_ASSIGN(OmniboxAcceptNotificationObserver); +}; + #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py index a2b7166..fb23190 100644 --- a/chrome/test/pyautolib/pyauto.py +++ b/chrome/test/pyautolib/pyauto.py @@ -319,6 +319,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): """Accepts the current string of text in the omnibox. This is equivalent to clicking or hiting enter on a popup selection. + Blocks until the page loads. Args: windex: the index of the browser window to work on. |