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" |
11 #include "chrome/test/base/in_process_browser_test.h" | 11 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "components/autofill/content/browser/content_autofill_driver.h" | 12 #include "components/autofill/content/browser/content_autofill_driver.h" |
13 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 13 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
14 #include "components/autofill/core/browser/autofill_manager.h" | 14 #include "components/autofill/core/browser/autofill_manager.h" |
15 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 15 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
| 16 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
18 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
19 #include "ui/gfx/geometry/rect.h" | 20 #include "ui/gfx/geometry/rect.h" |
20 #include "ui/gfx/geometry/vector2d.h" | 21 #include "ui/gfx/geometry/vector2d.h" |
21 | 22 |
22 namespace autofill { | 23 namespace autofill { |
23 namespace { | 24 namespace { |
24 | 25 |
25 class TestAutofillExternalDelegate : public AutofillExternalDelegate { | 26 class TestAutofillExternalDelegate : public AutofillExternalDelegate { |
26 public: | 27 public: |
27 TestAutofillExternalDelegate(content::WebContents* web_contents, | 28 TestAutofillExternalDelegate(content::WebContents* web_contents, |
28 AutofillManager* autofill_manager, | 29 AutofillManager* autofill_manager, |
29 AutofillDriver* autofill_driver) | 30 AutofillDriver* autofill_driver) |
30 : AutofillExternalDelegate(autofill_manager, autofill_driver), | 31 : AutofillExternalDelegate(autofill_manager, autofill_driver), |
31 popup_hidden_(true) {} | 32 popup_hidden_(true) {} |
32 ~TestAutofillExternalDelegate() override {} | 33 ~TestAutofillExternalDelegate() override {} |
33 | 34 |
34 void OnPopupShown() override { | 35 void OnPopupShown() override { |
35 popup_hidden_ = false; | 36 popup_hidden_ = false; |
36 | 37 |
37 AutofillExternalDelegate::OnPopupShown(); | 38 AutofillExternalDelegate::OnPopupShown(); |
38 } | 39 } |
39 | 40 |
40 void OnPopupHidden() override { | 41 void OnPopupHidden() override { |
41 popup_hidden_ = true; | 42 popup_hidden_ = true; |
42 | 43 |
43 if (message_loop_runner_.get()) | 44 if (message_loop_runner_.get()) |
44 message_loop_runner_->Quit(); | 45 message_loop_runner_->Quit(); |
45 | |
46 AutofillExternalDelegate::OnPopupHidden(); | |
47 } | 46 } |
48 | 47 |
49 void WaitForPopupHidden() { | 48 void WaitForPopupHidden() { |
50 if (popup_hidden_) | 49 if (popup_hidden_) |
51 return; | 50 return; |
52 | 51 |
53 message_loop_runner_ = new content::MessageLoopRunner; | 52 message_loop_runner_ = new content::MessageLoopRunner; |
54 message_loop_runner_->Run(); | 53 message_loop_runner_->Run(); |
55 } | 54 } |
56 | 55 |
(...skipping 26 matching lines...) Expand all Loading... |
83 ->DriverForFrame(web_contents->GetMainFrame()); | 82 ->DriverForFrame(web_contents->GetMainFrame()); |
84 autofill_external_delegate_.reset( | 83 autofill_external_delegate_.reset( |
85 new TestAutofillExternalDelegate( | 84 new TestAutofillExternalDelegate( |
86 web_contents, | 85 web_contents, |
87 driver->autofill_manager(), | 86 driver->autofill_manager(), |
88 driver)); | 87 driver)); |
89 } | 88 } |
90 | 89 |
91 // Normally the WebContents will automatically delete the delegate, but here | 90 // Normally the WebContents will automatically delete the delegate, but here |
92 // the delegate is owned by this test, so we have to manually destroy. | 91 // the delegate is owned by this test, so we have to manually destroy. |
93 void WebContentsDestroyed() override { autofill_external_delegate_.reset(); } | 92 void RenderFrameDeleted(content::RenderFrameHost* rfh) override { |
| 93 if (!rfh->GetParent()) |
| 94 autofill_external_delegate_.reset(); |
| 95 } |
94 | 96 |
95 protected: | 97 protected: |
96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; | 98 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; |
97 }; | 99 }; |
98 | 100 |
99 #if defined(OS_MACOSX) | 101 #if defined(OS_MACOSX) |
100 // Fails on Mac OS, see crbug/453256 | 102 // Fails on Mac OS, see crbug/453256 |
101 #define MAYBE_DoNotHidePopupOnWindowMove DISABLED_DoNotHidePopupOnWindowMove | 103 #define MAYBE_DoNotHidePopupOnWindowMove DISABLED_DoNotHidePopupOnWindowMove |
102 #else | 104 #else |
103 #define MAYBE_DoNotHidePopupOnWindowMove DoNotHidePopupOnWindowMove | 105 #define MAYBE_DoNotHidePopupOnWindowMove DoNotHidePopupOnWindowMove |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 DeleteDelegateBeforePopupHidden){ | 138 DeleteDelegateBeforePopupHidden){ |
137 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 139 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
138 | 140 |
139 // Delete the external delegate here so that is gets deleted before popup is | 141 // Delete the external delegate here so that is gets deleted before popup is |
140 // hidden. This can happen if the web_contents are destroyed before the popup | 142 // hidden. This can happen if the web_contents are destroyed before the popup |
141 // is hidden. See http://crbug.com/232475 | 143 // is hidden. See http://crbug.com/232475 |
142 autofill_external_delegate_.reset(); | 144 autofill_external_delegate_.reset(); |
143 } | 145 } |
144 | 146 |
145 } // namespace autofill | 147 } // namespace autofill |
OLD | NEW |