| 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 "content/public/test/download_test_observer.h" | 5 #include "content/public/test/download_test_observer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // Stop observing. Do not do anything with it, as it is about to be gone. | 131 // Stop observing. Do not do anything with it, as it is about to be gone. |
| 132 DownloadSet::iterator it = downloads_observed_.find(download); | 132 DownloadSet::iterator it = downloads_observed_.find(download); |
| 133 ASSERT_TRUE(it != downloads_observed_.end()); | 133 ASSERT_TRUE(it != downloads_observed_.end()); |
| 134 downloads_observed_.erase(it); | 134 downloads_observed_.erase(it); |
| 135 download->RemoveObserver(this); | 135 download->RemoveObserver(this); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DownloadTestObserver::OnDownloadUpdated(DownloadItem* download) { | 138 void DownloadTestObserver::OnDownloadUpdated(DownloadItem* download) { |
| 139 // Real UI code gets the user's response after returning from the observer. | 139 // Real UI code gets the user's response after returning from the observer. |
| 140 if (download->IsDangerous() && | 140 if (download->IsDangerous() && |
| 141 !ContainsKey(dangerous_downloads_seen_, download->GetId())) { | 141 !base::ContainsKey(dangerous_downloads_seen_, download->GetId())) { |
| 142 dangerous_downloads_seen_.insert(download->GetId()); | 142 dangerous_downloads_seen_.insert(download->GetId()); |
| 143 | 143 |
| 144 // Calling ValidateDangerousDownload() at this point will | 144 // Calling ValidateDangerousDownload() at this point will |
| 145 // cause the download to be completed twice. Do what the real UI | 145 // cause the download to be completed twice. Do what the real UI |
| 146 // code does: make the call as a delayed task. | 146 // code does: make the call as a delayed task. |
| 147 switch (dangerous_download_action_) { | 147 switch (dangerous_download_action_) { |
| 148 case ON_DANGEROUS_DOWNLOAD_ACCEPT: | 148 case ON_DANGEROUS_DOWNLOAD_ACCEPT: |
| 149 // Fake user click on "Accept". Delay the actual click, as the | 149 // Fake user click on "Accept". Delay the actual click, as the |
| 150 // real UI would. | 150 // real UI would. |
| 151 BrowserThread::PostTask( | 151 BrowserThread::PostTask( |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 base::MessageLoopForUI::current()->QuitWhenIdle(); | 446 base::MessageLoopForUI::current()->QuitWhenIdle(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 const DownloadUrlParameters::OnStartedCallback | 449 const DownloadUrlParameters::OnStartedCallback |
| 450 DownloadTestItemCreationObserver::callback() { | 450 DownloadTestItemCreationObserver::callback() { |
| 451 return base::Bind( | 451 return base::Bind( |
| 452 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); | 452 &DownloadTestItemCreationObserver::DownloadItemCreationCallback, this); |
| 453 } | 453 } |
| 454 | 454 |
| 455 } // namespace content | 455 } // namespace content |
| OLD | NEW |