| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/download/download_request_infobar_delegate.h" | 9 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 void Close() { | 35 void Close() { |
| 36 if (delegate_) | 36 if (delegate_) |
| 37 delegate_->Closing(); | 37 delegate_->Closing(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // PermissionBubbleView: | 40 // PermissionBubbleView: |
| 41 void SetDelegate(Delegate* delegate) override { delegate_ = delegate; } | 41 void SetDelegate(Delegate* delegate) override { delegate_ = delegate; } |
| 42 | 42 |
| 43 void Show(const std::vector<PermissionBubbleRequest*>& requests, | 43 void Show(const std::vector<PermissionBubbleRequest*>& requests, |
| 44 const std::vector<bool>& accept_state, | 44 const std::vector<bool>& accept_state) override; |
| 45 bool customization_mode) override; | |
| 46 | 45 |
| 47 bool CanAcceptRequestUpdate() override { return false; } | 46 bool CanAcceptRequestUpdate() override { return false; } |
| 48 | 47 |
| 49 void Hide() override {} | 48 void Hide() override {} |
| 50 bool IsVisible() override { return false; } | 49 bool IsVisible() override { return false; } |
| 51 | 50 |
| 52 private: | 51 private: |
| 53 DownloadRequestLimiterTest* test_; | 52 DownloadRequestLimiterTest* test_; |
| 54 Delegate* delegate_; | 53 Delegate* delegate_; |
| 55 }; | 54 }; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 scoped_refptr<HostContentSettingsMap> content_settings_; | 198 scoped_refptr<HostContentSettingsMap> content_settings_; |
| 200 | 199 |
| 201 private: | 200 private: |
| 202 DownloadRequestInfoBarDelegate::FakeCreateCallback fake_create_callback_; | 201 DownloadRequestInfoBarDelegate::FakeCreateCallback fake_create_callback_; |
| 203 TestingProfile profile_; | 202 TestingProfile profile_; |
| 204 scoped_ptr<FakePermissionBubbleView> view_; | 203 scoped_ptr<FakePermissionBubbleView> view_; |
| 205 }; | 204 }; |
| 206 | 205 |
| 207 void FakePermissionBubbleView::Show( | 206 void FakePermissionBubbleView::Show( |
| 208 const std::vector<PermissionBubbleRequest*>& requests, | 207 const std::vector<PermissionBubbleRequest*>& requests, |
| 209 const std::vector<bool>& accept_state, | 208 const std::vector<bool>& accept_state) { |
| 210 bool customization_mode) { | |
| 211 test_->AskAllow(); | 209 test_->AskAllow(); |
| 212 int action = test_->GetAction(); | 210 int action = test_->GetAction(); |
| 213 if (action == DownloadRequestLimiterTest::ACCEPT) { | 211 if (action == DownloadRequestLimiterTest::ACCEPT) { |
| 214 delegate_->Accept(); | 212 delegate_->Accept(); |
| 215 } else if (action == DownloadRequestLimiterTest::CANCEL) { | 213 } else if (action == DownloadRequestLimiterTest::CANCEL) { |
| 216 delegate_->Deny(); | 214 delegate_->Deny(); |
| 217 } else if (action == DownloadRequestLimiterTest::WAIT) { | 215 } else if (action == DownloadRequestLimiterTest::WAIT) { |
| 218 // do nothing. | 216 // do nothing. |
| 219 } else { | 217 } else { |
| 220 delegate_->Closing(); | 218 delegate_->Closing(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 CanDownload(); | 453 CanDownload(); |
| 456 ExpectAndResetCounts(0, 1, 0, __LINE__); | 454 ExpectAndResetCounts(0, 1, 0, __LINE__); |
| 457 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 455 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 458 download_request_limiter_->GetDownloadStatus(web_contents())); | 456 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 459 | 457 |
| 460 CanDownload(); | 458 CanDownload(); |
| 461 ExpectAndResetCounts(0, 1, 0, __LINE__); | 459 ExpectAndResetCounts(0, 1, 0, __LINE__); |
| 462 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 460 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 463 download_request_limiter_->GetDownloadStatus(web_contents())); | 461 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 464 } | 462 } |
| OLD | NEW |