| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/automation/testing_automation_provider.h" | 5 #include "chrome/browser/automation/testing_automation_provider.h" |
| 6 | 6 |
| 7 #include "chrome/browser/automation/automation_browser_tracker.h" | 7 #include "chrome/browser/automation/automation_browser_tracker.h" |
| 8 #include "chrome/browser/automation/automation_window_tracker.h" | 8 #include "chrome/browser/automation/automation_window_tracker.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 previous_view_id_(previous_view_id), | 30 previous_view_id_(previous_view_id), |
| 31 automation_(automation), | 31 automation_(automation), |
| 32 reply_message_(reply_message), | 32 reply_message_(reply_message), |
| 33 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { | 33 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { |
| 34 focus_manager_->AddFocusChangeListener(this); | 34 focus_manager_->AddFocusChangeListener(this); |
| 35 // Call the focus change notification once in case the focus has | 35 // Call the focus change notification once in case the focus has |
| 36 // already changed. | 36 // already changed. |
| 37 FocusWillChange(NULL, focus_manager_->GetFocusedView()); | 37 FocusWillChange(NULL, focus_manager_->GetFocusedView()); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ~ViewFocusChangeWaiter() { | 40 virtual ~ViewFocusChangeWaiter() { |
| 41 focus_manager_->RemoveFocusChangeListener(this); | 41 focus_manager_->RemoveFocusChangeListener(this); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Inherited from FocusChangeListener | 44 // Inherited from FocusChangeListener |
| 45 virtual void FocusWillChange(views::View* focused_before, | 45 virtual void FocusWillChange(views::View* focused_before, |
| 46 views::View* focused_now) { | 46 views::View* focused_now) { |
| 47 // This listener is called before focus actually changes. Post a task | 47 // This listener is called before focus actually changes. Post a task |
| 48 // that will get run after focus changes. | 48 // that will get run after focus changes. |
| 49 MessageLoop::current()->PostTask( | 49 MessageLoop::current()->PostTask( |
| 50 FROM_HERE, | 50 FROM_HERE, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 80 class TestingAutomationProvider::PopupMenuWaiter : public views::MenuListener { | 80 class TestingAutomationProvider::PopupMenuWaiter : public views::MenuListener { |
| 81 public: | 81 public: |
| 82 PopupMenuWaiter(ToolbarView* toolbar_view, | 82 PopupMenuWaiter(ToolbarView* toolbar_view, |
| 83 TestingAutomationProvider* automation) | 83 TestingAutomationProvider* automation) |
| 84 : toolbar_view_(toolbar_view), | 84 : toolbar_view_(toolbar_view), |
| 85 automation_(automation), | 85 automation_(automation), |
| 86 reply_message_(NULL) { | 86 reply_message_(NULL) { |
| 87 toolbar_view_->AddMenuListener(this); | 87 toolbar_view_->AddMenuListener(this); |
| 88 } | 88 } |
| 89 | 89 |
| 90 virtual ~PopupMenuWaiter() {} |
| 91 |
| 90 // Implementation of views::MenuListener | 92 // Implementation of views::MenuListener |
| 91 virtual void OnMenuOpened() { | 93 virtual void OnMenuOpened() { |
| 92 toolbar_view_->RemoveMenuListener(this); | 94 toolbar_view_->RemoveMenuListener(this); |
| 93 automation_->popup_menu_opened_ = true; | 95 automation_->popup_menu_opened_ = true; |
| 94 automation_->popup_menu_waiter_ = NULL; | 96 automation_->popup_menu_waiter_ = NULL; |
| 95 if (reply_message_) { | 97 if (reply_message_) { |
| 96 AutomationMsg_WaitForPopupMenuToOpen::WriteReplyParams( | 98 AutomationMsg_WaitForPopupMenuToOpen::WriteReplyParams( |
| 97 reply_message_, true); | 99 reply_message_, true); |
| 98 automation_->Send(reply_message_); | 100 automation_->Send(reply_message_); |
| 99 } | 101 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 reply_message, true); | 191 reply_message, true); |
| 190 Send(reply_message); | 192 Send(reply_message); |
| 191 return; | 193 return; |
| 192 } | 194 } |
| 193 | 195 |
| 194 // Otherwise, register this reply message with the waiter, | 196 // Otherwise, register this reply message with the waiter, |
| 195 // which will handle responding to this IPC when the popup | 197 // which will handle responding to this IPC when the popup |
| 196 // menu opens. | 198 // menu opens. |
| 197 popup_menu_waiter_->set_reply_message(reply_message); | 199 popup_menu_waiter_->set_reply_message(reply_message); |
| 198 } | 200 } |
| OLD | NEW |