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

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

Issue 2029903002: Add token field to ClientSafeBrowsingReportReqeust (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak comments Created 4 years, 6 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
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 using content::DownloadManager; 120 using content::DownloadManager;
121 using content::DownloadUrlParameters; 121 using content::DownloadUrlParameters;
122 using content::WebContents; 122 using content::WebContents;
123 using extensions::Extension; 123 using extensions::Extension;
124 using extensions::FeatureSwitch; 124 using extensions::FeatureSwitch;
125 using net::URLRequestMockHTTPJob; 125 using net::URLRequestMockHTTPJob;
126 126
127 namespace { 127 namespace {
128 128
129 const char kDownloadTest1Path[] = "download-test1.lib"; 129 const char kDownloadTest1Path[] = "download-test1.lib";
130 const char kDownloadResponseToken[] = "download_token";
130 131
131 class CreatedObserver : public content::DownloadManager::Observer { 132 class CreatedObserver : public content::DownloadManager::Observer {
132 public: 133 public:
133 explicit CreatedObserver(content::DownloadManager* manager) 134 explicit CreatedObserver(content::DownloadManager* manager)
134 : manager_(manager), 135 : manager_(manager),
135 waiting_(false) { 136 waiting_(false) {
136 manager->AddObserver(this); 137 manager->AddObserver(this);
137 } 138 }
138 ~CreatedObserver() override { 139 ~CreatedObserver() override {
139 if (manager_) 140 if (manager_)
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 1077
1077 namespace { 1078 namespace {
1078 1079
1079 class FakeDownloadProtectionService 1080 class FakeDownloadProtectionService
1080 : public safe_browsing::DownloadProtectionService { 1081 : public safe_browsing::DownloadProtectionService {
1081 public: 1082 public:
1082 FakeDownloadProtectionService() 1083 FakeDownloadProtectionService()
1083 : safe_browsing::DownloadProtectionService(nullptr) {} 1084 : safe_browsing::DownloadProtectionService(nullptr) {}
1084 1085
1085 void CheckClientDownload(DownloadItem* download_item, 1086 void CheckClientDownload(DownloadItem* download_item,
1086 const CheckDownloadCallback& callback) override { 1087 const CheckDownloadContentCallback& callback) override {
1087 callback.Run( 1088 callback.Run(
1088 safe_browsing::DownloadProtectionService::UNCOMMON); 1089 safe_browsing::DownloadProtectionService::UNCOMMON,
1090 kDownloadResponseToken);
1089 } 1091 }
1090 }; 1092 };
1091 1093
1092 class FakeSafeBrowsingService 1094 class FakeSafeBrowsingService
1093 : public safe_browsing::TestSafeBrowsingService, 1095 : public safe_browsing::TestSafeBrowsingService,
1094 public safe_browsing::ServicesDelegate::ServicesCreator { 1096 public safe_browsing::ServicesDelegate::ServicesCreator {
1095 public: 1097 public:
1096 FakeSafeBrowsingService() { 1098 FakeSafeBrowsingService() {
1097 services_delegate_ = 1099 services_delegate_ =
1098 safe_browsing::ServicesDelegate::CreateForTest(this, this); 1100 safe_browsing::ServicesDelegate::CreateForTest(this, this);
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after
3380 actual_report.ParseFromString( 3382 actual_report.ParseFromString(
3381 test_safe_browsing_factory_->fake_safe_browsing_service() 3383 test_safe_browsing_factory_->fake_safe_browsing_service()
3382 ->serilized_download_report()); 3384 ->serilized_download_report());
3383 EXPECT_EQ(safe_browsing::ClientSafeBrowsingReportRequest:: 3385 EXPECT_EQ(safe_browsing::ClientSafeBrowsingReportRequest::
3384 DANGEROUS_DOWNLOAD_WARNING, 3386 DANGEROUS_DOWNLOAD_WARNING,
3385 actual_report.type()); 3387 actual_report.type());
3386 EXPECT_EQ(safe_browsing::ClientDownloadResponse::UNCOMMON, 3388 EXPECT_EQ(safe_browsing::ClientDownloadResponse::UNCOMMON,
3387 actual_report.download_verdict()); 3389 actual_report.download_verdict());
3388 EXPECT_EQ(download_url.spec(), actual_report.url()); 3390 EXPECT_EQ(download_url.spec(), actual_report.url());
3389 EXPECT_TRUE(actual_report.did_proceed()); 3391 EXPECT_TRUE(actual_report.did_proceed());
3392 EXPECT_EQ(kDownloadResponseToken, actual_report.token());
3390 3393
3391 download->Cancel(true); 3394 download->Cancel(true);
3392 } 3395 }
3393 3396
3394 IN_PROC_BROWSER_TEST_F( 3397 IN_PROC_BROWSER_TEST_F(
3395 DownloadTestWithFakeSafeBrowsing, 3398 DownloadTestWithFakeSafeBrowsing,
3396 NoUncommonDownloadReportWithoutUserProceed) { 3399 NoUncommonDownloadReportWithoutUserProceed) {
3397 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled, 3400 browser()->profile()->GetPrefs()->SetBoolean(prefs::kSafeBrowsingEnabled,
3398 true); 3401 true);
3399 // Make a dangerous file. 3402 // Make a dangerous file.
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
3674 DangerousDownloadWaiter( 3677 DangerousDownloadWaiter(
3675 browser(), 1, 3678 browser(), 1,
3676 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); 3679 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY));
3677 ui_test_utils::NavigateToURL(browser(), extension_url); 3680 ui_test_utils::NavigateToURL(browser(), extension_url);
3678 3681
3679 observer->WaitForFinished(); 3682 observer->WaitForFinished();
3680 3683
3681 // Download shelf should close. 3684 // Download shelf should close.
3682 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 3685 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
3683 } 3686 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698