| OLD | NEW |
| 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_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 OnUserInteraction(blink::WebInputEvent::MouseDown); | 489 OnUserInteraction(blink::WebInputEvent::MouseDown); |
| 490 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 490 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
| 491 download_request_limiter_->GetDownloadStatus(web_contents())); | 491 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 492 | 492 |
| 493 // Do one download, which should change to prompt before download. | 493 // Do one download, which should change to prompt before download. |
| 494 CanDownload(); | 494 CanDownload(); |
| 495 ExpectAndResetCounts(1, 0, 0, __LINE__); | 495 ExpectAndResetCounts(1, 0, 0, __LINE__); |
| 496 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 496 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 497 download_request_limiter_->GetDownloadStatus(web_contents())); | 497 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 498 | 498 |
| 499 // Do a user gesture with gesture tap, which should reset back to allow one. | 499 // Do a touch event, which should reset back to allow one. |
| 500 OnUserInteraction(blink::WebInputEvent::GestureTapDown); | 500 OnUserInteraction(blink::WebInputEvent::TouchStart); |
| 501 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 501 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
| 502 download_request_limiter_->GetDownloadStatus(web_contents())); | 502 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 503 | 503 |
| 504 // Do one download, which should change to prompt before download. | 504 // Do one download, which should change to prompt before download. |
| 505 CanDownload(); | 505 CanDownload(); |
| 506 ExpectAndResetCounts(1, 0, 0, __LINE__); | 506 ExpectAndResetCounts(1, 0, 0, __LINE__); |
| 507 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 507 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 508 download_request_limiter_->GetDownloadStatus(web_contents())); | 508 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 509 | 509 |
| 510 // Do a user gesture with keyboard down, which should reset back to allow one. | 510 // Do a user gesture with keyboard down, which should reset back to allow one. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 testing_delegate_.UnsetInfobarDelegate(); | 604 testing_delegate_.UnsetInfobarDelegate(); |
| 605 ExpectAndResetCounts(0, 0, 0, __LINE__); | 605 ExpectAndResetCounts(0, 0, 0, __LINE__); |
| 606 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 606 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
| 607 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 607 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| 608 // You get one freebie. | 608 // You get one freebie. |
| 609 CanDownloadFor(web_contents.get()); | 609 CanDownloadFor(web_contents.get()); |
| 610 ExpectAndResetCounts(1, 0, 0, __LINE__); | 610 ExpectAndResetCounts(1, 0, 0, __LINE__); |
| 611 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 611 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 612 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 612 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| 613 OnUserInteractionFor(web_contents.get(), | 613 OnUserInteractionFor(web_contents.get(), |
| 614 blink::WebInputEvent::GestureTapDown); | 614 blink::WebInputEvent::TouchStart); |
| 615 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, | 615 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
| 616 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 616 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| 617 CanDownloadFor(web_contents.get()); | 617 CanDownloadFor(web_contents.get()); |
| 618 ExpectAndResetCounts(1, 0, 0, __LINE__); | 618 ExpectAndResetCounts(1, 0, 0, __LINE__); |
| 619 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 619 EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 620 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 620 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| 621 CanDownloadFor(web_contents.get()); | 621 CanDownloadFor(web_contents.get()); |
| 622 ExpectAndResetCounts(0, 1, 0, __LINE__); | 622 ExpectAndResetCounts(0, 1, 0, __LINE__); |
| 623 EXPECT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, | 623 EXPECT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
| 624 download_request_limiter_->GetDownloadStatus(web_contents.get())); | 624 download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 // changing the content setting). | 709 // changing the content setting). |
| 710 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK); | 710 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK); |
| 711 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 711 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 712 download_request_limiter_->GetDownloadStatus(web_contents())); | 712 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 713 UpdateExpectations(WAIT); | 713 UpdateExpectations(WAIT); |
| 714 CanDownload(); | 714 CanDownload(); |
| 715 ExpectAndResetCounts(0, 0, 1, __LINE__); | 715 ExpectAndResetCounts(0, 0, 1, __LINE__); |
| 716 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 716 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 717 download_request_limiter_->GetDownloadStatus(web_contents())); | 717 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 718 } | 718 } |
| OLD | NEW |