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

Unified Diff: chrome/browser/download/download_test_file_chooser_observer.cc

Issue 12047039: download: Remove DownloadManager::MockDownloadOpenForTesting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and comment fix Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_test_file_chooser_observer.cc
diff --git a/chrome/browser/download/download_test_file_chooser_observer.cc b/chrome/browser/download/download_test_file_chooser_observer.cc
deleted file mode 100644
index 3a0ddf29dbdb91bd45eb4a166192aa40267f2e17..0000000000000000000000000000000000000000
--- a/chrome/browser/download/download_test_file_chooser_observer.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/download/download_test_file_chooser_observer.h"
-
-#include "base/bind.h"
-#include "base/message_loop.h"
-#include "chrome/browser/download/chrome_download_manager_delegate.h"
-#include "chrome/browser/download/download_service.h"
-#include "chrome/browser/download/download_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-
-namespace content {
-class DownloadItem;
-}
-
-namespace internal {
-
-// Test ChromeDownloadManagerDelegate that controls whether how file chooser
-// dialogs are handled. By default, file chooser dialogs are disabled.
-class MockFileChooserDownloadManagerDelegate
- : public ChromeDownloadManagerDelegate {
- public:
- explicit MockFileChooserDownloadManagerDelegate(Profile* profile)
- : ChromeDownloadManagerDelegate(profile),
- file_chooser_enabled_(false),
- file_chooser_displayed_(false) {}
-
- void EnableFileChooser(bool enable) {
- file_chooser_enabled_ = enable;
- }
-
- bool TestAndResetDidShowFileChooser() {
- bool did_show = file_chooser_displayed_;
- file_chooser_displayed_ = false;
- return did_show;
- }
-
- protected:
-
- virtual void ChooseDownloadPath(content::DownloadItem* item,
- const FilePath& suggested_path,
- const FileSelectedCallback&
- callback) OVERRIDE {
- file_chooser_displayed_ = true;
- MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(callback,
- (file_chooser_enabled_ ? suggested_path : FilePath())));
- }
-
- private:
- virtual ~MockFileChooserDownloadManagerDelegate() {}
-
- bool file_chooser_enabled_;
- bool file_chooser_displayed_;
-};
-
-} // namespace internal
-
-DownloadTestFileChooserObserver::DownloadTestFileChooserObserver(
- Profile* profile) {
- test_delegate_ =
- new internal::MockFileChooserDownloadManagerDelegate(profile);
- DownloadServiceFactory::GetForProfile(profile)->
- SetDownloadManagerDelegateForTesting(test_delegate_.get());
-}
-
-DownloadTestFileChooserObserver::~DownloadTestFileChooserObserver() {
-}
-
-void DownloadTestFileChooserObserver::EnableFileChooser(bool enable) {
- test_delegate_->EnableFileChooser(enable);
-}
-
-bool DownloadTestFileChooserObserver::TestAndResetDidShowFileChooser() {
- return test_delegate_->TestAndResetDidShowFileChooser();
-}
-

Powered by Google App Engine
This is Rietveld 408576698