| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/browser/ui/autofill/autofill_popup_view.h" | 7 #include "chrome/browser/ui/autofill/autofill_popup_view.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 namespace autofill { | 21 namespace autofill { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class TestAutofillExternalDelegate : public AutofillExternalDelegate { | 24 class TestAutofillExternalDelegate : public AutofillExternalDelegate { |
| 25 public: | 25 public: |
| 26 TestAutofillExternalDelegate(content::WebContents* web_contents, | 26 TestAutofillExternalDelegate(content::WebContents* web_contents, |
| 27 AutofillManager* autofill_manager, | 27 AutofillManager* autofill_manager, |
| 28 AutofillDriver* autofill_driver) | 28 AutofillDriver* autofill_driver) |
| 29 : AutofillExternalDelegate(autofill_manager, autofill_driver), | 29 : AutofillExternalDelegate(autofill_manager, autofill_driver), |
| 30 popup_hidden_(true) {} | 30 popup_hidden_(true) {} |
| 31 virtual ~TestAutofillExternalDelegate() {} | 31 ~TestAutofillExternalDelegate() override {} |
| 32 | 32 |
| 33 virtual void OnPopupShown() override { | 33 void OnPopupShown() override { |
| 34 popup_hidden_ = false; | 34 popup_hidden_ = false; |
| 35 | 35 |
| 36 AutofillExternalDelegate::OnPopupShown(); | 36 AutofillExternalDelegate::OnPopupShown(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 virtual void OnPopupHidden() override { | 39 void OnPopupHidden() override { |
| 40 popup_hidden_ = true; | 40 popup_hidden_ = true; |
| 41 | 41 |
| 42 if (message_loop_runner_.get()) | 42 if (message_loop_runner_.get()) |
| 43 message_loop_runner_->Quit(); | 43 message_loop_runner_->Quit(); |
| 44 | 44 |
| 45 AutofillExternalDelegate::OnPopupHidden(); | 45 AutofillExternalDelegate::OnPopupHidden(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void WaitForPopupHidden() { | 48 void WaitForPopupHidden() { |
| 49 if (popup_hidden_) | 49 if (popup_hidden_) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 64 | 64 |
| 65 } // namespace | 65 } // namespace |
| 66 | 66 |
| 67 class AutofillPopupControllerBrowserTest | 67 class AutofillPopupControllerBrowserTest |
| 68 : public InProcessBrowserTest, | 68 : public InProcessBrowserTest, |
| 69 public content::WebContentsObserver { | 69 public content::WebContentsObserver { |
| 70 public: | 70 public: |
| 71 AutofillPopupControllerBrowserTest() {} | 71 AutofillPopupControllerBrowserTest() {} |
| 72 virtual ~AutofillPopupControllerBrowserTest() {} | 72 virtual ~AutofillPopupControllerBrowserTest() {} |
| 73 | 73 |
| 74 virtual void SetUpOnMainThread() override { | 74 void SetUpOnMainThread() override { |
| 75 content::WebContents* web_contents = | 75 content::WebContents* web_contents = |
| 76 browser()->tab_strip_model()->GetActiveWebContents(); | 76 browser()->tab_strip_model()->GetActiveWebContents(); |
| 77 ASSERT_TRUE(web_contents != NULL); | 77 ASSERT_TRUE(web_contents != NULL); |
| 78 Observe(web_contents); | 78 Observe(web_contents); |
| 79 | 79 |
| 80 ContentAutofillDriver* driver = | 80 ContentAutofillDriver* driver = |
| 81 ContentAutofillDriver::FromWebContents(web_contents); | 81 ContentAutofillDriver::FromWebContents(web_contents); |
| 82 autofill_external_delegate_.reset( | 82 autofill_external_delegate_.reset( |
| 83 new TestAutofillExternalDelegate( | 83 new TestAutofillExternalDelegate( |
| 84 web_contents, | 84 web_contents, |
| 85 driver->autofill_manager(), | 85 driver->autofill_manager(), |
| 86 driver)); | 86 driver)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Normally the WebContents will automatically delete the delegate, but here | 89 // Normally the WebContents will automatically delete the delegate, but here |
| 90 // the delegate is owned by this test, so we have to manually destroy. | 90 // the delegate is owned by this test, so we have to manually destroy. |
| 91 virtual void WebContentsDestroyed() override { | 91 void WebContentsDestroyed() override { autofill_external_delegate_.reset(); } |
| 92 autofill_external_delegate_.reset(); | |
| 93 } | |
| 94 | 92 |
| 95 protected: | 93 protected: |
| 96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; | 94 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; |
| 97 }; | 95 }; |
| 98 | 96 |
| 99 // Autofill UI isn't currently hidden on window move on Mac. | 97 // Autofill UI isn't currently hidden on window move on Mac. |
| 100 // http://crbug.com/180566 | 98 // http://crbug.com/180566 |
| 101 #if !defined(OS_MACOSX) | 99 #if !defined(OS_MACOSX) |
| 102 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, | 100 IN_PROC_BROWSER_TEST_F(AutofillPopupControllerBrowserTest, |
| 103 HidePopupOnWindowConfiguration) { | 101 HidePopupOnWindowConfiguration) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 128 MAYBE_DeleteDelegateBeforePopupHidden){ | 126 MAYBE_DeleteDelegateBeforePopupHidden){ |
| 129 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 127 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
| 130 | 128 |
| 131 // Delete the external delegate here so that is gets deleted before popup is | 129 // Delete the external delegate here so that is gets deleted before popup is |
| 132 // hidden. This can happen if the web_contents are destroyed before the popup | 130 // hidden. This can happen if the web_contents are destroyed before the popup |
| 133 // is hidden. See http://crbug.com/232475 | 131 // is hidden. See http://crbug.com/232475 |
| 134 autofill_external_delegate_.reset(); | 132 autofill_external_delegate_.reset(); |
| 135 } | 133 } |
| 136 | 134 |
| 137 } // namespace autofill | 135 } // namespace autofill |
| OLD | NEW |