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 12 matching lines...) Expand all Loading... |
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 virtual ~TestAutofillExternalDelegate() {} |
32 | 32 |
33 virtual void OnPopupShown() OVERRIDE { | 33 virtual 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 virtual 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 virtual 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 virtual void WebContentsDestroyed() override { |
92 autofill_external_delegate_.reset(); | 92 autofill_external_delegate_.reset(); |
93 } | 93 } |
94 | 94 |
95 protected: | 95 protected: |
96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; | 96 scoped_ptr<TestAutofillExternalDelegate> autofill_external_delegate_; |
97 }; | 97 }; |
98 | 98 |
99 // Autofill UI isn't currently hidden on window move on Mac. | 99 // Autofill UI isn't currently hidden on window move on Mac. |
100 // http://crbug.com/180566 | 100 // http://crbug.com/180566 |
101 #if !defined(OS_MACOSX) | 101 #if !defined(OS_MACOSX) |
(...skipping 26 matching lines...) Expand all Loading... |
128 MAYBE_DeleteDelegateBeforePopupHidden){ | 128 MAYBE_DeleteDelegateBeforePopupHidden){ |
129 GenerateTestAutofillPopup(autofill_external_delegate_.get()); | 129 GenerateTestAutofillPopup(autofill_external_delegate_.get()); |
130 | 130 |
131 // Delete the external delegate here so that is gets deleted before popup is | 131 // 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 | 132 // hidden. This can happen if the web_contents are destroyed before the popup |
133 // is hidden. See http://crbug.com/232475 | 133 // is hidden. See http://crbug.com/232475 |
134 autofill_external_delegate_.reset(); | 134 autofill_external_delegate_.reset(); |
135 } | 135 } |
136 | 136 |
137 } // namespace autofill | 137 } // namespace autofill |
OLD | NEW |