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 <queue> | 5 #include <queue> |
6 #include <set> | 6 #include <set> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 2434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadPermission) { | 2445 IN_PROC_BROWSER_TEST_P(WebViewTest, DownloadPermission) { |
2446 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 2446 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
2447 content::WebContents* guest_web_contents = | 2447 content::WebContents* guest_web_contents = |
2448 LoadGuest("/extensions/platform_apps/web_view/download/guest.html", | 2448 LoadGuest("/extensions/platform_apps/web_view/download/guest.html", |
2449 "web_view/download"); | 2449 "web_view/download"); |
2450 ASSERT_TRUE(guest_web_contents); | 2450 ASSERT_TRUE(guest_web_contents); |
2451 | 2451 |
2452 base::ScopedTempDir temporary_download_dir; | 2452 base::ScopedTempDir temporary_download_dir; |
2453 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); | 2453 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); |
2454 DownloadPrefs::FromBrowserContext(guest_web_contents->GetBrowserContext()) | 2454 DownloadPrefs::FromBrowserContext(guest_web_contents->GetBrowserContext()) |
2455 ->SetDownloadPath(temporary_download_dir.path()); | 2455 ->SetDownloadPath(temporary_download_dir.GetPath()); |
2456 | 2456 |
2457 std::unique_ptr<content::DownloadTestObserver> completion_observer( | 2457 std::unique_ptr<content::DownloadTestObserver> completion_observer( |
2458 new content::DownloadTestObserverTerminal( | 2458 new content::DownloadTestObserverTerminal( |
2459 content::BrowserContext::GetDownloadManager( | 2459 content::BrowserContext::GetDownloadManager( |
2460 guest_web_contents->GetBrowserContext()), | 2460 guest_web_contents->GetBrowserContext()), |
2461 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2461 1, content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
2462 | 2462 |
2463 // Replace WebContentsDelegate with mock version so we can intercept download | 2463 // Replace WebContentsDelegate with mock version so we can intercept download |
2464 // requests. | 2464 // requests. |
2465 content::WebContentsDelegate* delegate = guest_web_contents->GetDelegate(); | 2465 content::WebContentsDelegate* delegate = guest_web_contents->GetDelegate(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2602 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 2602 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
2603 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", | 2603 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", |
2604 "created-webviews"); | 2604 "created-webviews"); |
2605 | 2605 |
2606 content::WebContents* web_contents = GetFirstAppWindowWebContents(); | 2606 content::WebContents* web_contents = GetFirstAppWindowWebContents(); |
2607 ASSERT_TRUE(web_contents); | 2607 ASSERT_TRUE(web_contents); |
2608 | 2608 |
2609 base::ScopedTempDir temporary_download_dir; | 2609 base::ScopedTempDir temporary_download_dir; |
2610 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); | 2610 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); |
2611 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) | 2611 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) |
2612 ->SetDownloadPath(temporary_download_dir.path()); | 2612 ->SetDownloadPath(temporary_download_dir.GetPath()); |
2613 | 2613 |
2614 content::DownloadManager* download_manager = | 2614 content::DownloadManager* download_manager = |
2615 content::BrowserContext::GetDownloadManager( | 2615 content::BrowserContext::GetDownloadManager( |
2616 web_contents->GetBrowserContext()); | 2616 web_contents->GetBrowserContext()); |
2617 | 2617 |
2618 std::unique_ptr<content::DownloadTestObserver> interrupted_observer( | 2618 std::unique_ptr<content::DownloadTestObserver> interrupted_observer( |
2619 new content::DownloadTestObserverInterrupted( | 2619 new content::DownloadTestObserverInterrupted( |
2620 download_manager, 2, | 2620 download_manager, 2, |
2621 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2621 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
2622 | 2622 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 2687 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
2688 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", | 2688 LoadAndLaunchPlatformApp("web_view/download_cookie_isolation", |
2689 "created-webviews"); | 2689 "created-webviews"); |
2690 | 2690 |
2691 content::WebContents* web_contents = GetFirstAppWindowWebContents(); | 2691 content::WebContents* web_contents = GetFirstAppWindowWebContents(); |
2692 ASSERT_TRUE(web_contents); | 2692 ASSERT_TRUE(web_contents); |
2693 | 2693 |
2694 base::ScopedTempDir temporary_download_dir; | 2694 base::ScopedTempDir temporary_download_dir; |
2695 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); | 2695 ASSERT_TRUE(temporary_download_dir.CreateUniqueTempDir()); |
2696 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) | 2696 DownloadPrefs::FromBrowserContext(web_contents->GetBrowserContext()) |
2697 ->SetDownloadPath(temporary_download_dir.path()); | 2697 ->SetDownloadPath(temporary_download_dir.GetPath()); |
2698 | 2698 |
2699 content::DownloadManager* download_manager = | 2699 content::DownloadManager* download_manager = |
2700 content::BrowserContext::GetDownloadManager( | 2700 content::BrowserContext::GetDownloadManager( |
2701 web_contents->GetBrowserContext()); | 2701 web_contents->GetBrowserContext()); |
2702 | 2702 |
2703 DownloadHistoryWaiter history_waiter(web_contents->GetBrowserContext()); | 2703 DownloadHistoryWaiter history_waiter(web_contents->GetBrowserContext()); |
2704 | 2704 |
2705 std::unique_ptr<content::DownloadTestObserver> interrupted_observer( | 2705 std::unique_ptr<content::DownloadTestObserver> interrupted_observer( |
2706 new content::DownloadTestObserverInterrupted( | 2706 new content::DownloadTestObserverInterrupted( |
2707 download_manager, 2, | 2707 download_manager, 2, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2784 download->GetOpened())); | 2784 download->GetOpened())); |
2785 } | 2785 } |
2786 | 2786 |
2787 std::unique_ptr<content::DownloadTestObserver> completion_observer( | 2787 std::unique_ptr<content::DownloadTestObserver> completion_observer( |
2788 new content::DownloadTestObserverTerminal( | 2788 new content::DownloadTestObserverTerminal( |
2789 download_manager, 2, | 2789 download_manager, 2, |
2790 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2790 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
2791 | 2791 |
2792 for (auto* download : downloads) { | 2792 for (auto* download : downloads) { |
2793 ASSERT_TRUE(download->CanResume()); | 2793 ASSERT_TRUE(download->CanResume()); |
2794 ASSERT_TRUE( | 2794 ASSERT_TRUE(temporary_download_dir.GetPath().IsParent( |
2795 temporary_download_dir.path().IsParent(download->GetTargetFilePath())); | 2795 download->GetTargetFilePath())); |
2796 ASSERT_TRUE(download->GetFullPath().empty()); | 2796 ASSERT_TRUE(download->GetFullPath().empty()); |
2797 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, | 2797 EXPECT_EQ(content::DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, |
2798 download->GetLastReason()); | 2798 download->GetLastReason()); |
2799 download->Resume(); | 2799 download->Resume(); |
2800 } | 2800 } |
2801 | 2801 |
2802 completion_observer->WaitForFinished(); | 2802 completion_observer->WaitForFinished(); |
2803 | 2803 |
2804 // Of the two downloads, ?cookie=first will succeed and ?cookie=second will | 2804 // Of the two downloads, ?cookie=first will succeed and ?cookie=second will |
2805 // fail. The latter fails because the underlying storage partition was not | 2805 // fail. The latter fails because the underlying storage partition was not |
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3830 gfx::Point embedder_origin = | 3830 gfx::Point embedder_origin = |
3831 GetEmbedderWebContents()->GetContainerBounds().origin(); | 3831 GetEmbedderWebContents()->GetContainerBounds().origin(); |
3832 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); | 3832 guest_rect.Offset(-embedder_origin.x(), -embedder_origin.y()); |
3833 | 3833 |
3834 // Generate and send synthetic touch event. | 3834 // Generate and send synthetic touch event. |
3835 content::SimulateTouchPressAt(GetEmbedderWebContents(), | 3835 content::SimulateTouchPressAt(GetEmbedderWebContents(), |
3836 guest_rect.CenterPoint()); | 3836 guest_rect.CenterPoint()); |
3837 EXPECT_TRUE(aura_webview->HasFocus()); | 3837 EXPECT_TRUE(aura_webview->HasFocus()); |
3838 } | 3838 } |
3839 #endif | 3839 #endif |
OLD | NEW |