diff options
author | Garrett Casto <gcasto@chromium.org> | 2015-01-06 14:00:24 -0800 |
---|---|---|
committer | Garrett Casto <gcasto@chromium.org> | 2015-01-06 22:03:24 +0000 |
commit | 3a1ebba4426fd0206d63988b0d037b5d746bb5d6 (patch) | |
tree | 2263b420c32b534189175db1bc422737cca2686f | |
parent | 9cf3ff79a7779820bc6c77a4d378d7bd98b5fadb (diff) | |
download | chromium_src-3a1ebba4426fd0206d63988b0d037b5d746bb5d6.zip chromium_src-3a1ebba4426fd0206d63988b0d037b5d746bb5d6.tar.gz chromium_src-3a1ebba4426fd0206d63988b0d037b5d746bb5d6.tar.bz2 |
Merge to branch 2214 [Password Generation] Hide popup if view can not be created.
Fixes a crash.
BUG=439618
Review URL: https://codereview.chromium.org/811563004
Cr-Commit-Position: refs/heads/master@{#309323}
(cherry picked from commit 978e1ba2dcd2e4b7667b8831b2784b466ea28c87)
Review URL: https://codereview.chromium.org/842503002
Cr-Commit-Position: refs/branch-heads/2214@{#390}
Cr-Branched-From: 03655fd3f6d72165dc3c9bd2c89807305316fe6c-refs/heads/master@{#303346}
-rw-r--r-- | chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/autofill/password_generation_popup_view_browsertest.cc | 22 |
2 files changed, 23 insertions, 6 deletions
diff --git a/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc b/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc index 05f7f98..07d6da0 100644 --- a/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc +++ b/chrome/browser/ui/autofill/password_generation_popup_controller_impl.cc @@ -182,6 +182,13 @@ void PasswordGenerationPopupControllerImpl::Show(bool display_password) { if (!view_) { view_ = PasswordGenerationPopupView::Create(this); + + // Treat popup as being hidden if creation fails. + if (!view_) { + Hide(); + return; + } + CalculateBounds(); view_->Show(); } else { diff --git a/chrome/browser/ui/autofill/password_generation_popup_view_browsertest.cc b/chrome/browser/ui/autofill/password_generation_popup_view_browsertest.cc index 67bcc37..21c74ad 100644 --- a/chrome/browser/ui/autofill/password_generation_popup_view_browsertest.cc +++ b/chrome/browser/ui/autofill/password_generation_popup_view_browsertest.cc @@ -39,13 +39,12 @@ class TestPasswordGenerationPopupController : class PasswordGenerationPopupViewTest : public InProcessBrowserTest { public: - void SetUpOnMainThread() override { - gfx::NativeView native_view = - browser()->tab_strip_model()->GetActiveWebContents()->GetNativeView(); + content::WebContents* GetWebContents() { + return browser()->tab_strip_model()->GetActiveWebContents(); + } - controller_ = - new TestPasswordGenerationPopupController( - browser()->tab_strip_model()->GetActiveWebContents(), native_view); + gfx::NativeView GetNativeView() { + return GetWebContents()->GetNativeView(); } scoped_ptr<PasswordGenerationPopupViewTester> GetViewTester() { @@ -62,6 +61,8 @@ class PasswordGenerationPopupViewTest : public InProcessBrowserTest { // editing dialog doesn't crash. IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, MouseMovementInEditingPopup) { + controller_ = new autofill::TestPasswordGenerationPopupController( + GetWebContents(), GetNativeView()); controller_->Show(false /* display_password */); gfx::Point center_point = @@ -72,6 +73,15 @@ IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, // Deletes |controller_|. controller_->HideAndDestroy(); } + +// Verify that we calling Show() with an invalid container does not crash. +// Regression test for crbug.com/439618. +IN_PROC_BROWSER_TEST_F(PasswordGenerationPopupViewTest, + InvalidContainerView) { + controller_ = new autofill::TestPasswordGenerationPopupController( + GetWebContents(), NULL); + controller_->Show(true /* display password */); +} #endif } // namespace autofill |