| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This functionality currently works on Windows and on Linux when | 5 // This functionality currently works on Windows and on Linux when |
| 6 // toolkit_views is defined (i.e. for Chrome OS). It's not needed | 6 // toolkit_views is defined (i.e. for Chrome OS). It's not needed |
| 7 // on the Mac, and it's not yet implemented on Linux. | 7 // on the Mac, and it's not yet implemented on Linux. |
| 8 | 8 |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 focus_manager_->RemoveFocusChangeListener(this); | 55 focus_manager_->RemoveFocusChangeListener(this); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void Wait() { | 58 void Wait() { |
| 59 content::RunMessageLoop(); | 59 content::RunMessageLoop(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // Inherited from FocusChangeListener | 63 // Inherited from FocusChangeListener |
| 64 virtual void OnWillChangeFocus(views::View* focused_before, | 64 virtual void OnWillChangeFocus(views::View* focused_before, |
| 65 views::View* focused_now) OVERRIDE { | 65 views::View* focused_now) override { |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void OnDidChangeFocus(views::View* focused_before, | 68 virtual void OnDidChangeFocus(views::View* focused_before, |
| 69 views::View* focused_now) OVERRIDE { | 69 views::View* focused_now) override { |
| 70 if (focused_now && focused_now->id() != previous_view_id_) { | 70 if (focused_now && focused_now->id() != previous_view_id_) { |
| 71 base::MessageLoop::current()->PostTask(FROM_HERE, | 71 base::MessageLoop::current()->PostTask(FROM_HERE, |
| 72 base::MessageLoop::QuitClosure()); | 72 base::MessageLoop::QuitClosure()); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 views::FocusManager* focus_manager_; | 76 views::FocusManager* focus_manager_; |
| 77 int previous_view_id_; | 77 int previous_view_id_; |
| 78 base::WeakPtrFactory<ViewFocusChangeWaiter> weak_factory_; | 78 base::WeakPtrFactory<ViewFocusChangeWaiter> weak_factory_; |
| 79 | 79 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 94 if (test_dismiss_menu_) | 94 if (test_dismiss_menu_) |
| 95 toolbar_view_->RemoveMenuListener(this); | 95 toolbar_view_->RemoveMenuListener(this); |
| 96 } | 96 } |
| 97 | 97 |
| 98 int menu_open_count() const { | 98 int menu_open_count() const { |
| 99 return menu_open_count_; | 99 return menu_open_count_; |
| 100 } | 100 } |
| 101 | 101 |
| 102 private: | 102 private: |
| 103 // Overridden from views::MenuListener: | 103 // Overridden from views::MenuListener: |
| 104 virtual void OnMenuOpened() OVERRIDE { | 104 virtual void OnMenuOpened() override { |
| 105 menu_open_count_++; | 105 menu_open_count_++; |
| 106 if (!test_dismiss_menu_) { | 106 if (!test_dismiss_menu_) { |
| 107 toolbar_view_->RemoveMenuListener(this); | 107 toolbar_view_->RemoveMenuListener(this); |
| 108 // Press DOWN to select the first item, then RETURN to select it. | 108 // Press DOWN to select the first item, then RETURN to select it. |
| 109 SendKeyPress(browser_, ui::VKEY_DOWN); | 109 SendKeyPress(browser_, ui::VKEY_DOWN); |
| 110 SendKeyPress(browser_, ui::VKEY_RETURN); | 110 SendKeyPress(browser_, ui::VKEY_RETURN); |
| 111 } else { | 111 } else { |
| 112 SendKeyPress(browser_, ui::VKEY_ESCAPE); | 112 SendKeyPress(browser_, ui::VKEY_ESCAPE); |
| 113 base::MessageLoop::current()->PostDelayedTask( | 113 base::MessageLoop::current()->PostDelayedTask( |
| 114 FROM_HERE, | 114 FROM_HERE, |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 browser(), ui::VKEY_BROWSER_FORWARD, false, false, false, false)); | 433 browser(), ui::VKEY_BROWSER_FORWARD, false, false, false, false)); |
| 434 | 434 |
| 435 base::string16 after_forward; | 435 base::string16 after_forward; |
| 436 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &after_forward)); | 436 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &after_forward)); |
| 437 | 437 |
| 438 EXPECT_EQ(before_back, after_forward); | 438 EXPECT_EQ(before_back, after_forward); |
| 439 } | 439 } |
| 440 #endif | 440 #endif |
| 441 | 441 |
| 442 } // namespace | 442 } // namespace |
| OLD | NEW |