Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/browser/chromeos/login/login_manager_test.h" | 8 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 9 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h" | 9 #include "chrome/browser/chromeos/login/ui/captive_portal_view.h" |
| 10 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h" | 10 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h" |
| 11 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 11 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 12 #include "chrome/browser/chromeos/login/ui/simple_web_view_dialog.h" | 12 #include "chrome/browser/chromeos/login/ui/simple_web_view_dialog.h" |
| 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 13 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 14 #include "components/password_manager/content/browser/content_password_manager_d river.h" | |
| 14 #include "content/public/browser/interstitial_page.h" | 15 #include "content/public/browser/interstitial_page.h" |
| 15 #include "content/public/browser/interstitial_page_delegate.h" | 16 #include "content/public/browser/interstitial_page_delegate.h" |
| 16 #include "ui/views/controls/webview/webview.h" | 17 #include "ui/views/controls/webview/webview.h" |
| 17 | 18 |
| 18 namespace chromeos { | 19 namespace chromeos { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 class StubDelegate : public CaptivePortalWindowProxyDelegate { | 23 class StubDelegate : public CaptivePortalWindowProxyDelegate { |
| 23 public: | 24 public: |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 47 }; | 48 }; |
| 48 | 49 |
| 49 } // namespace | 50 } // namespace |
| 50 | 51 |
| 51 class SimpleWebViewDialogTest : public LoginManagerTest { | 52 class SimpleWebViewDialogTest : public LoginManagerTest { |
| 52 public: | 53 public: |
| 53 SimpleWebViewDialogTest(): LoginManagerTest(false) {} | 54 SimpleWebViewDialogTest(): LoginManagerTest(false) {} |
| 54 ~SimpleWebViewDialogTest() override {} | 55 ~SimpleWebViewDialogTest() override {} |
| 55 | 56 |
| 56 InterstitialPageDelegate* CreateDelegate(CaptivePortalWindowProxy* proxy) { | 57 InterstitialPageDelegate* CreateDelegate(CaptivePortalWindowProxy* proxy) { |
| 57 SimpleWebViewDialog* dialog = proxy->captive_portal_view_for_testing(); | 58 SimpleWebViewDialog* dialog = GetSimpleWebViewDialog(proxy); |
| 58 CHECK(dialog) << "CaptivePortalView is not initialized"; | 59 CHECK(dialog) << "CaptivePortalView is not initialized"; |
| 59 return new InterstitialPageDelegate(dialog->web_view_->web_contents()); | 60 return new InterstitialPageDelegate(dialog->web_view_->web_contents()); |
| 60 } | 61 } |
| 61 | 62 |
| 63 protected: | |
| 64 SimpleWebViewDialog* GetSimpleWebViewDialog(CaptivePortalWindowProxy* proxy) { | |
|
meacer
2017/03/04 05:54:14
const method
| |
| 65 return proxy->captive_portal_view_for_testing(); | |
| 66 } | |
| 67 | |
| 68 content::WebContents* GetSimpleWebViewDialogWebContents( | |
| 69 SimpleWebViewDialog* dialog) { | |
|
meacer
2017/03/04 05:54:14
const method
| |
| 70 return dialog->web_view_->GetWebContents(); | |
| 71 } | |
| 72 | |
| 62 private: | 73 private: |
| 63 DISALLOW_COPY_AND_ASSIGN(SimpleWebViewDialogTest); | 74 DISALLOW_COPY_AND_ASSIGN(SimpleWebViewDialogTest); |
| 64 }; | 75 }; |
| 65 | 76 |
| 66 IN_PROC_BROWSER_TEST_F(SimpleWebViewDialogTest, Interstitial) { | 77 IN_PROC_BROWSER_TEST_F(SimpleWebViewDialogTest, Interstitial) { |
| 67 content::WebContents* web_contents = | 78 content::WebContents* web_contents = |
| 68 LoginDisplayHost::default_host()->GetWebUILoginView()->GetWebContents(); | 79 LoginDisplayHost::default_host()->GetWebUILoginView()->GetWebContents(); |
| 69 StubDelegate delegate; | 80 StubDelegate delegate; |
| 70 CaptivePortalWindowProxy proxy(&delegate, web_contents); | 81 CaptivePortalWindowProxy proxy(&delegate, web_contents); |
| 71 proxy.Show(); | 82 proxy.Show(); |
| 72 | 83 |
| 73 // Delegate creates a page and passes himself to it. Page owns the | 84 // Delegate creates a page and passes himself to it. Page owns the |
| 74 // delegate and will be destroyed by the end of the test. | 85 // delegate and will be destroyed by the end of the test. |
| 75 CreateDelegate(&proxy); | 86 CreateDelegate(&proxy); |
| 76 } | 87 } |
| 77 | 88 |
| 89 // Regression test for https://crbug.com/698438 | |
| 90 IN_PROC_BROWSER_TEST_F(SimpleWebViewDialogTest, AutofillClientGetsCreated) { | |
| 91 content::WebContents* web_contents = | |
| 92 LoginDisplayHost::default_host()->GetWebUILoginView()->GetWebContents(); | |
| 93 StubDelegate delegate; | |
| 94 CaptivePortalWindowProxy proxy(&delegate, web_contents); | |
| 95 proxy.Show(); | |
| 96 SimpleWebViewDialog* dialog = GetSimpleWebViewDialog(&proxy); | |
| 97 | |
| 98 dialog->StartLoad(GURL("http://example.test")); | |
| 99 password_manager::ContentPasswordManagerDriver* driver = | |
| 100 password_manager::ContentPasswordManagerDriver::GetForRenderFrameHost( | |
| 101 GetSimpleWebViewDialogWebContents(dialog)->GetMainFrame()); | |
| 102 ASSERT_TRUE(driver); | |
| 103 // This call would crash if a ChromeAutofillManager hadn't been created | |
| 104 // properly. | |
| 105 driver->ShowNotSecureWarning(base::i18n::LEFT_TO_RIGHT, gfx::RectF(0, 0)); | |
|
meacer
2017/03/04 05:54:14
Would it make sense to change this test or add a n
| |
| 106 } | |
| 107 | |
| 78 } // namespace chromeos | 108 } // namespace chromeos |
| OLD | NEW |