Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 9834039: Remove resource_request_info_impl.h dependency from chrome. This also makes blob/file system urls w… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/net/view_blob_internals_job_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 #include "content/public/browser/render_view_host.h" 53 #include "content/public/browser/render_view_host.h"
54 #include "content/public/browser/resource_context.h" 54 #include "content/public/browser/resource_context.h"
55 #include "content/public/browser/web_contents.h" 55 #include "content/public/browser/web_contents.h"
56 #include "content/public/common/context_menu_params.h" 56 #include "content/public/common/context_menu_params.h"
57 #include "content/public/common/page_transition_types.h" 57 #include "content/public/common/page_transition_types.h"
58 #include "content/test/net/url_request_mock_http_job.h" 58 #include "content/test/net/url_request_mock_http_job.h"
59 #include "content/test/net/url_request_slow_download_job.h" 59 #include "content/test/net/url_request_slow_download_job.h"
60 #include "content/test/test_file_error_injector.h" 60 #include "content/test/test_file_error_injector.h"
61 #include "content/test/test_navigation_observer.h" 61 #include "content/test/test_navigation_observer.h"
62 #include "net/base/net_util.h" 62 #include "net/base/net_util.h"
63 #include "net/test/test_server.h"
63 #include "testing/gtest/include/gtest/gtest.h" 64 #include "testing/gtest/include/gtest/gtest.h"
64 #include "webkit/blob/blob_data.h"
65 #include "webkit/blob/blob_storage_controller.h"
66 65
67 using content::BrowserThread; 66 using content::BrowserThread;
68 using content::DownloadItem; 67 using content::DownloadItem;
69 using content::DownloadManager; 68 using content::DownloadManager;
70 using content::DownloadPersistentStoreInfo; 69 using content::DownloadPersistentStoreInfo;
71 using content::WebContents; 70 using content::WebContents;
72 71
73 namespace { 72 namespace {
74 73
75 // IDs and paths of CRX files used in tests. 74 // IDs and paths of CRX files used in tests.
(...skipping 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2425 } 2424 }
2426 }; 2425 };
2427 2426
2428 DownloadFilesToReadonlyFolder(ARRAYSIZE_UNSAFE(download_info), download_info); 2427 DownloadFilesToReadonlyFolder(ARRAYSIZE_UNSAFE(download_info), download_info);
2429 } 2428 }
2430 2429
2431 // Test that we show a dangerous downloads warning for a dangerous file 2430 // Test that we show a dangerous downloads warning for a dangerous file
2432 // downloaded through a blob: URL. 2431 // downloaded through a blob: URL.
2433 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDangerousBlobData) { 2432 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadDangerousBlobData) {
2434 ASSERT_TRUE(InitialSetup(false)); 2433 ASSERT_TRUE(InitialSetup(false));
2435 const char kBlobUrl[] = "blob:test-download-url"; 2434
2436 GURL blob_url(kBlobUrl);
2437 #if defined(OS_WIN) 2435 #if defined(OS_WIN)
2438 // On Windows, if SafeBrowsing is enabled, certain file types (.exe, .cab, 2436 // On Windows, if SafeBrowsing is enabled, certain file types (.exe, .cab,
2439 // .msi) will be handled by the DownloadProtectionService. However, if the URL 2437 // .msi) will be handled by the DownloadProtectionService. However, if the URL
2440 // is non-standard (e.g. blob:) then those files won't be handled by the 2438 // is non-standard (e.g. blob:) then those files won't be handled by the
2441 // DPS. We should be showing the dangerous download warning for any file 2439 // DPS. We should be showing the dangerous download warning for any file
2442 // considered dangerous and isn't handled by the DPS. 2440 // considered dangerous and isn't handled by the DPS.
2443 const char kFilename[] = "foo.exe"; 2441 const char kFilename[] = "foo.exe";
2444 #else 2442 #else
2445 const char kFilename[] = "foo.jar"; 2443 const char kFilename[] = "foo.jar";
2446 #endif 2444 #endif
2447 std::string content_disposition = "attachment; filename=";
2448 content_disposition += kFilename;
2449 2445
2450 webkit_blob::BlobStorageController* blob_controller = 2446 std::string path("files/downloads/download-dangerous-blob.html?filename=");
2451 content::ResourceContext::GetBlobStorageController( 2447 path += kFilename;
2452 DownloadManagerForBrowser(browser())->GetBrowserContext()-> 2448
2453 GetResourceContext()); 2449 // Need to use http urls because the blob js doesn't work on file urls for
2454 scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData()); 2450 // security reasons.
2455 blob_data->AppendData("foo"); 2451 ASSERT_TRUE(test_server()->Start());
2456 blob_controller->AddFinishedBlob(blob_url, blob_data.get()); 2452 GURL url(test_server()->GetURL(path));
2457 blob_data = blob_controller->GetBlobDataFromUrl(blob_url);
2458 blob_data->set_content_type("application/octet-stream");
2459 blob_data->set_content_disposition(content_disposition);
2460 2453
2461 DownloadTestObserver* observer(DangerousDownloadWaiter( 2454 DownloadTestObserver* observer(DangerousDownloadWaiter(
2462 browser(), 1, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); 2455 browser(), 1, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT));
2463 ui_test_utils::NavigateToURL(browser(), blob_url); 2456 ui_test_utils::NavigateToURL(browser(), url);
2464 observer->WaitForFinished(); 2457 observer->WaitForFinished();
2465 blob_controller->RemoveBlob(blob_url);
2466 2458
2467 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2459 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2468 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen()); 2460 EXPECT_EQ(1u, observer->NumDangerousDownloadsSeen());
2469 } 2461 }
OLDNEW
« no previous file with comments | « chrome/browser/DEPS ('k') | chrome/browser/net/view_blob_internals_job_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698