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 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 ContentAutofillDriver* driver = | 82 ContentAutofillDriver* driver = |
82 ContentAutofillDriverFactory::FromWebContents(web_contents) | 83 ContentAutofillDriverFactory::FromWebContents(web_contents) |
83 ->DriverForFrame(web_contents->GetMainFrame()); | 84 ->DriverForFrame(web_contents->GetMainFrame()); |
84 autofill_external_delegate_.reset( | 85 autofill_external_delegate_.reset( |
85 new TestAutofillExternalDelegate( | 86 new TestAutofillExternalDelegate( |
86 web_contents, | 87 web_contents, |
87 driver->autofill_manager(), | 88 driver->autofill_manager(), |
88 driver)); | 89 driver)); |
89 } | 90 } |
90 | 91 |
91 // Normally the WebContents will automatically delete the delegate, but here | 92 // The delegate lifetime is tied to the lifetime of the main frame, so |
92 // the delegate is owned by this test, so we have to manually destroy. | 93 // destroy it when the frame is deleted. |
Evan Stade
2015/02/13 22:09:20
nit: I sorta liked the old comment better
nasko
2015/02/13 22:11:49
Reverted.
| |
93 void WebContentsDestroyed() override { autofill_external_delegate_.reset(); } | 94 void RenderFrameDeleted(content::RenderFrameHost* rfh) override { |
95 if (!rfh->GetParent()) | |
96 autofill_external_delegate_.reset(); | |
97 } | |
94 | 98 |
95 protected: | 99 protected: |
96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; | 100 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; |
97 }; | 101 }; |
98 | 102 |
99 #if defined(OS_MACOSX) | 103 #if defined(OS_MACOSX) |
100 // Fails on Mac OS, see crbug/453256 | 104 // Fails on Mac OS, see crbug/453256 |
101 #define MAYBE_DoNotHidePopupOnWindowMove DISABLED_DoNotHidePopupOnWindowMove | 105 #define MAYBE_DoNotHidePopupOnWindowMove DISABLED_DoNotHidePopupOnWindowMove |
102 #else | 106 #else |
103 #define MAYBE_DoNotHidePopupOnWindowMove DoNotHidePopupOnWindowMove | 107 #define MAYBE_DoNotHidePopupOnWindowMove DoNotHidePopupOnWindowMove |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 DeleteDelegateBeforePopupHidden){ | 140 DeleteDelegateBeforePopupHidden){ |
137 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 141 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
138 | 142 |
139 // Delete the external delegate here so that is gets deleted before popup is | 143 // 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 | 144 // hidden. This can happen if the web_contents are destroyed before the popup |
141 // is hidden. See http://crbug.com/232475 | 145 // is hidden. See http://crbug.com/232475 |
142 autofill_external_delegate_.reset(); | 146 autofill_external_delegate_.reset(); |
143 } | 147 } |
144 | 148 |
145 } // namespace autofill | 149 } // namespace autofill |
OLD | NEW |