summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r--chrome/browser/automation/automation_provider.cc31
-rw-r--r--chrome/browser/automation/automation_provider.h25
-rw-r--r--chrome/browser/automation/automation_provider_gtk.cc5
-rw-r--r--chrome/browser/automation/automation_provider_mac.mm5
-rw-r--r--chrome/browser/automation/automation_provider_views.cc152
-rw-r--r--chrome/browser/automation/automation_provider_win.cc13
-rw-r--r--chrome/browser/automation/ui_controls_win.cc15
7 files changed, 24 insertions, 222 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 226f89c..dfb84ba 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -140,8 +140,7 @@ class ClickTask : public Task {
AutomationProvider::AutomationProvider(Profile* profile)
: redirect_query_(0),
profile_(profile),
- reply_message_(NULL),
- popup_menu_waiter_(NULL) {
+ reply_message_(NULL) {
browser_tracker_.reset(new AutomationBrowserTracker(this));
tab_tracker_.reset(new AutomationTabTracker(this));
window_tracker_.reset(new AutomationWindowTracker(this));
@@ -499,14 +498,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_LoginWithUserAndPass,
LoginWithUserAndPass)
#endif
-#if defined(TOOLKIT_VIEWS)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForFocusedViewIDToChange,
- WaitForFocusedViewIDToChange)
- IPC_MESSAGE_HANDLER(AutomationMsg_StartTrackingPopupMenus,
- StartTrackingPopupMenus)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WaitForPopupMenuToOpen,
- WaitForPopupMenuToOpen)
-#endif
IPC_MESSAGE_HANDLER(AutomationMsg_RemoveBrowsingData, RemoveBrowsingData)
IPC_END_MESSAGE_MAP()
}
@@ -2548,23 +2539,3 @@ void AutomationProvider::SetContentSetting(
*success = true;
}
}
-
-#if !defined(TOOLKIT_VIEWS)
-void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
- NOTIMPLEMENTED();
-};
-
-void AutomationProvider::WaitForFocusedViewIDToChange(
- int handle, int previous_view_id, IPC::Message* reply_message) {
- NOTIMPLEMENTED();
-}
-
-void AutomationProvider::StartTrackingPopupMenus(
- int browser_handle, bool* success) {
- NOTIMPLEMENTED();
-}
-
-void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) {
- NOTIMPLEMENTED();
-}
-#endif // !defined(TOOLKIT_VIEWS)
diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h
index 2d680b1..6da47e2 100644
--- a/chrome/browser/automation/automation_provider.h
+++ b/chrome/browser/automation/automation_provider.h
@@ -35,7 +35,6 @@
#endif // defined(OS_WIN)
struct AutomationMsg_Find_Params;
-class PopupMenuWaiter;
namespace IPC {
struct Reposition_Params;
@@ -134,7 +133,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
protected:
friend class base::RefCounted<AutomationProvider>;
- friend class PopupMenuWaiter;
virtual ~AutomationProvider();
private:
@@ -584,22 +582,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
// Returns NULL on failure.
RenderViewHost* GetViewForTab(int tab_handle);
- // Block until the focused view ID changes to something other than
- // previous_view_id.
- void WaitForFocusedViewIDToChange(int handle,
- int previous_view_id,
- IPC::Message* reply_message);
-
- // Start tracking popup menus. Must be called before executing the
- // command that might open the popup menu; then call WaitForPopupMenuToOpen.
- void StartTrackingPopupMenus(int browser_handle, bool* success);
-
- // Wait until a popup menu has opened.
- void WaitForPopupMenuToOpen(IPC::Message* reply_message);
-
- // Method called by the popup menu tracker when a popup menu is opened.
- void NotifyPopupMenuOpened();
-
typedef ObserverList<NotificationObserver> NotificationObserverList;
typedef std::map<NavigationController*, LoginHandler*> LoginHandlerMap;
typedef std::map<int, ExtensionPortContainer*> PortContainerMap;
@@ -635,13 +617,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>,
IPC::Message* reply_message_;
- // Keep track of whether a popup menu has been opened since the last time
- // that StartTrackingPopupMenus has been called.
- bool popup_menu_opened_;
-
- // A temporary object that receives a notification when a popup menu opens.
- PopupMenuWaiter* popup_menu_waiter_;
-
DISALLOW_COPY_AND_ASSIGN(AutomationProvider);
};
diff --git a/chrome/browser/automation/automation_provider_gtk.cc b/chrome/browser/automation/automation_provider_gtk.cc
index 62b378f..601e81a 100644
--- a/chrome/browser/automation/automation_provider_gtk.cc
+++ b/chrome/browser/automation/automation_provider_gtk.cc
@@ -79,6 +79,10 @@ void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized,
NOTIMPLEMENTED();
}
+void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
+ NOTIMPLEMENTED();
+}
+
void AutomationProvider::PrintAsync(int tab_handle) {
NOTIMPLEMENTED();
}
@@ -223,3 +227,4 @@ void AutomationProvider::GetWindowTitle(int handle, string16* text) {
const gchar* title = gtk_window_get_title(window);
text->assign(UTF8ToUTF16(title));
}
+
diff --git a/chrome/browser/automation/automation_provider_mac.mm b/chrome/browser/automation/automation_provider_mac.mm
index 2d3f3c5..f58b7a8 100644
--- a/chrome/browser/automation/automation_provider_mac.mm
+++ b/chrome/browser/automation/automation_provider_mac.mm
@@ -66,6 +66,10 @@ void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized,
NOTIMPLEMENTED();
}
+void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
+ NOTIMPLEMENTED();
+}
+
void AutomationProvider::PrintAsync(int tab_handle) {
NOTIMPLEMENTED();
}
@@ -154,3 +158,4 @@ void AutomationProvider::GetWindowTitle(int handle, string16* text) {
text->assign(base::SysNSStringToUTF16(title));
}
+
diff --git a/chrome/browser/automation/automation_provider_views.cc b/chrome/browser/automation/automation_provider_views.cc
index f7a461c..f161105 100644
--- a/chrome/browser/automation/automation_provider_views.cc
+++ b/chrome/browser/automation/automation_provider_views.cc
@@ -4,12 +4,7 @@
#include "chrome/browser/automation/automation_provider.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/toolbar_view.h"
-#include "chrome/test/automation/automation_messages.h"
#include "gfx/point.h"
-#include "views/controls/menu/menu_wrapper.h"
-#include "views/focus/focus_manager.h"
#include "views/view.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
@@ -39,150 +34,3 @@ void AutomationProvider::WindowGetViewBounds(int handle, int view_id,
}
}
-void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
- *view_id = -1;
- if (window_tracker_->ContainsHandle(handle)) {
- gfx::NativeWindow window = window_tracker_->GetResource(handle);
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManagerForNativeWindow(window);
- DCHECK(focus_manager);
- views::View* focused_view = focus_manager->GetFocusedView();
- if (focused_view)
- *view_id = focused_view->GetID();
- }
-}
-
-// Helper class that waits until the focus has changed to a view other
-// than the one with the provided view id.
-class ViewFocusChangeWaiter : public views::FocusChangeListener {
- public:
- ViewFocusChangeWaiter(views::FocusManager* focus_manager,
- int previous_view_id,
- AutomationProvider* automation,
- IPC::Message* reply_message)
- : focus_manager_(focus_manager),
- previous_view_id_(previous_view_id),
- automation_(automation),
- reply_message_(reply_message),
- ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
- focus_manager_->AddFocusChangeListener(this);
- // Call the focus change notification once in case the focus has
- // already changed.
- FocusWillChange(NULL, focus_manager_->GetFocusedView());
- }
-
- ~ViewFocusChangeWaiter() {
- focus_manager_->RemoveFocusChangeListener(this);
- }
-
- // Inherited from FocusChangeListener
- virtual void FocusWillChange(views::View* focused_before,
- views::View* focused_now) {
- // This listener is called before focus actually changes. Post a task
- // that will get run after focus changes.
- MessageLoop::current()->PostTask(
- FROM_HERE,
- method_factory_.NewRunnableMethod(
- &ViewFocusChangeWaiter::FocusChanged,
- focused_before,
- focused_now));
- }
-
- private:
- void FocusChanged(views::View* focused_before,
- views::View* focused_now) {
- if (focused_now && focused_now->GetID() != previous_view_id_) {
- AutomationMsg_WaitForFocusedViewIDToChange::WriteReplyParams(
- reply_message_, true, focused_now->GetID());
-
- automation_->Send(reply_message_);
- delete this;
- }
- }
-
- views::FocusManager* focus_manager_;
- int previous_view_id_;
- AutomationProvider* automation_;
- IPC::Message* reply_message_;
- ScopedRunnableMethodFactory<ViewFocusChangeWaiter> method_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(ViewFocusChangeWaiter);
-};
-
-void AutomationProvider::WaitForFocusedViewIDToChange(
- int handle, int previous_view_id, IPC::Message* reply_message) {
- if (!window_tracker_->ContainsHandle(handle))
- return;
- gfx::NativeWindow window = window_tracker_->GetResource(handle);
- views::FocusManager* focus_manager =
- views::FocusManager::GetFocusManagerForNativeWindow(window);
-
- // The waiter will respond to the IPC and delete itself when done.
- new ViewFocusChangeWaiter(focus_manager,
- previous_view_id,
- this,
- reply_message);
-}
-
-class PopupMenuWaiter : public views::MenuListener {
- public:
- PopupMenuWaiter(ToolbarView* toolbar_view,
- AutomationProvider* automation)
- : toolbar_view_(toolbar_view),
- automation_(automation),
- reply_message_(NULL) {
- toolbar_view_->AddMenuListener(this);
- }
-
- // Implementation of views::MenuListener
- virtual void OnMenuOpened() {
- toolbar_view_->RemoveMenuListener(this);
- automation_->popup_menu_opened_ = true;
- automation_->popup_menu_waiter_ = NULL;
- if (reply_message_) {
- AutomationMsg_WaitForPopupMenuToOpen::WriteReplyParams(
- reply_message_, true);
- automation_->Send(reply_message_);
- }
- delete this;
- }
-
- void set_reply_message(IPC::Message* reply_message) {
- reply_message_ = reply_message;
- }
-
- private:
- ToolbarView* toolbar_view_;
- AutomationProvider* automation_;
- IPC::Message* reply_message_;
-
- DISALLOW_COPY_AND_ASSIGN(PopupMenuWaiter);
-};
-
-void AutomationProvider::StartTrackingPopupMenus(
- int browser_handle, bool* success) {
- if (browser_tracker_->ContainsHandle(browser_handle)) {
- Browser* browser = browser_tracker_->GetResource(browser_handle);
- BrowserView* browser_view = reinterpret_cast<BrowserView*>(
- browser->window());
- ToolbarView* toolbar_view = browser_view->GetToolbarView();
- popup_menu_opened_ = false;
- popup_menu_waiter_ = new PopupMenuWaiter(toolbar_view, this);
- *success = true;
- }
-}
-
-void AutomationProvider::WaitForPopupMenuToOpen(IPC::Message* reply_message) {
- // See if the menu already opened and return true if so.
- if (popup_menu_opened_) {
- AutomationMsg_WaitForPopupMenuToOpen::WriteReplyParams(
- reply_message, true);
- Send(reply_message);
- return;
- }
-
- // Otherwise, register this reply message with the waiter,
- // which will handle responding to this IPC when the popup
- // menu opens.
- popup_menu_waiter_->set_reply_message(reply_message);
-}
diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc
index 2139420..9539498 100644
--- a/chrome/browser/automation/automation_provider_win.cc
+++ b/chrome/browser/automation/automation_provider_win.cc
@@ -231,6 +231,19 @@ void AutomationProvider::WindowSimulateDrag(int handle,
}
}
+void AutomationProvider::GetFocusedViewID(int handle, int* view_id) {
+ *view_id = -1;
+ if (window_tracker_->ContainsHandle(handle)) {
+ HWND hwnd = window_tracker_->GetResource(handle);
+ views::FocusManager* focus_manager =
+ views::FocusManager::GetFocusManagerForNativeView(hwnd);
+ DCHECK(focus_manager);
+ views::View* focused_view = focus_manager->GetFocusedView();
+ if (focused_view)
+ *view_id = focused_view->GetID();
+ }
+}
+
void AutomationProvider::GetWindowBounds(int handle, gfx::Rect* bounds,
bool* success) {
*success = false;
diff --git a/chrome/browser/automation/ui_controls_win.cc b/chrome/browser/automation/ui_controls_win.cc
index aba7248..3ff1a5c 100644
--- a/chrome/browser/automation/ui_controls_win.cc
+++ b/chrome/browser/automation/ui_controls_win.cc
@@ -166,21 +166,6 @@ bool SendKeyPressImpl(base::KeyboardCode key,
scoped_refptr<InputDispatcher> dispatcher(
task ? new InputDispatcher(task, WM_KEYUP) : NULL);
- // If a pop-up menu is open, it won't receive events sent using SendInput.
- // Check for a pop-up menu using its window class (#32768) and if one
- // exists, send the key event directly there.
- HWND popup_menu = ::FindWindow(L"#32768", 0);
- if (popup_menu != NULL) {
- WPARAM w_param = win_util::KeyboardCodeToWin(key);
- LPARAM l_param = 0;
- ::SendMessage(popup_menu, WM_KEYDOWN, w_param, l_param);
- ::SendMessage(popup_menu, WM_KEYUP, w_param, l_param);
-
- if (dispatcher.get())
- dispatcher->AddRef();
- return true;
- }
-
INPUT input[8] = { 0 }; // 8, assuming all the modifiers are activated
int i = 0;