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

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

Issue 2696973002: Allow Safe Browsing backend to select downloads to upload. (Closed)
Patch Set: Switch histogram to use enum, per isherman Created 3 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_feedback_service.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 "chrome/browser/download/download_browsertest.h" 5 #include "chrome/browser/download/download_browsertest.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <sstream> 8 #include <sstream>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after
3418 std::string ping_request( 3418 std::string ping_request(
3419 fake_metadata.download_request().SerializeAsString()); 3419 fake_metadata.download_request().SerializeAsString());
3420 std::string ping_response( 3420 std::string ping_response(
3421 fake_metadata.download_response().SerializeAsString()); 3421 fake_metadata.download_response().SerializeAsString());
3422 safe_browsing::SafeBrowsingService* sb_service = 3422 safe_browsing::SafeBrowsingService* sb_service =
3423 g_browser_process->safe_browsing_service(); 3423 g_browser_process->safe_browsing_service();
3424 safe_browsing::DownloadProtectionService* download_protection_service = 3424 safe_browsing::DownloadProtectionService* download_protection_service =
3425 sb_service->download_protection_service(); 3425 sb_service->download_protection_service();
3426 download_protection_service->feedback_service()->MaybeStorePingsForDownload( 3426 download_protection_service->feedback_service()->MaybeStorePingsForDownload(
3427 safe_browsing::DownloadProtectionService::UNCOMMON, 3427 safe_browsing::DownloadProtectionService::UNCOMMON,
3428 downloads[0], 3428 true /* upload_requested */, downloads[0], ping_request, ping_response);
3429 ping_request,
3430 ping_response);
3431 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload( 3429 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload(
3432 *(downloads[0]))); 3430 *(downloads[0])));
3433 3431
3434 // Begin feedback and check that the file is "stolen". 3432 // Begin feedback and check that the file is "stolen".
3435 download_protection_service->feedback_service()->BeginFeedbackForDownload( 3433 download_protection_service->feedback_service()->BeginFeedbackForDownload(
3436 downloads[0], DownloadCommands::DISCARD); 3434 downloads[0], DownloadCommands::DISCARD);
3437 std::vector<DownloadItem*> updated_downloads; 3435 std::vector<DownloadItem*> updated_downloads;
3438 GetDownloads(browser(), &updated_downloads); 3436 GetDownloads(browser(), &updated_downloads);
3439 ASSERT_TRUE(updated_downloads.empty()); 3437 ASSERT_TRUE(updated_downloads.empty());
3440 } 3438 }
(...skipping 30 matching lines...) Expand all
3471 safe_browsing::ClientDownloadResponse::UNCOMMON); 3469 safe_browsing::ClientDownloadResponse::UNCOMMON);
3472 std::string ping_request( 3470 std::string ping_request(
3473 fake_metadata.download_request().SerializeAsString()); 3471 fake_metadata.download_request().SerializeAsString());
3474 std::string ping_response( 3472 std::string ping_response(
3475 fake_metadata.download_response().SerializeAsString()); 3473 fake_metadata.download_response().SerializeAsString());
3476 safe_browsing::SafeBrowsingService* sb_service = 3474 safe_browsing::SafeBrowsingService* sb_service =
3477 g_browser_process->safe_browsing_service(); 3475 g_browser_process->safe_browsing_service();
3478 safe_browsing::DownloadProtectionService* download_protection_service = 3476 safe_browsing::DownloadProtectionService* download_protection_service =
3479 sb_service->download_protection_service(); 3477 sb_service->download_protection_service();
3480 download_protection_service->feedback_service()->MaybeStorePingsForDownload( 3478 download_protection_service->feedback_service()->MaybeStorePingsForDownload(
3481 safe_browsing::DownloadProtectionService::UNCOMMON, downloads[0], 3479 safe_browsing::DownloadProtectionService::UNCOMMON,
3482 ping_request, ping_response); 3480 true /* upload_requested */, downloads[0], ping_request, ping_response);
3483 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload( 3481 ASSERT_TRUE(safe_browsing::DownloadFeedbackService::IsEnabledForDownload(
3484 *(downloads[0]))); 3482 *(downloads[0])));
3485 3483
3486 // Begin feedback and check that file is still there. 3484 // Begin feedback and check that file is still there.
3487 download_protection_service->feedback_service()->BeginFeedbackForDownload( 3485 download_protection_service->feedback_service()->BeginFeedbackForDownload(
3488 downloads[0], DownloadCommands::KEEP); 3486 downloads[0], DownloadCommands::KEEP);
3489 3487
3490 std::vector<DownloadItem*> updated_downloads; 3488 std::vector<DownloadItem*> updated_downloads;
3491 GetDownloads(browser(), &updated_downloads); 3489 GetDownloads(browser(), &updated_downloads);
3492 ASSERT_EQ(std::size_t(1), updated_downloads.size()); 3490 ASSERT_EQ(std::size_t(1), updated_downloads.size());
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3800 browser(), 1, 3798 browser(), 1,
3801 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3799 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3802 ui_test_utils::NavigateToURL(browser(), extension_url); 3800 ui_test_utils::NavigateToURL(browser(), extension_url);
3803 3801
3804 observer->WaitForFinished(); 3802 observer->WaitForFinished();
3805 3803
3806 // Download shelf should close. 3804 // Download shelf should close.
3807 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3805 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3808 } 3806 }
3809 #endif // defined(OS_CHROMEOS) 3807 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_feedback_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698