blob: 736b9fd005ce26219a8d63b898f90a499dc655eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// 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.
#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TEST_FILE_ACTIVITY_OBSERVER_H_
#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TEST_FILE_ACTIVITY_OBSERVER_H_
#include "base/memory/ref_counted.h"
class Profile;
// Observes and overrides file chooser dialog and open activity for a profile.
// By default, once attached to a profile, this class overrides the default file
// related activity by replacing the ChromeDownloadManagerDelegate associated
// with |profile|.
// NOTE: Again, this overrides the ChromeDownloadManagerDelegate for |profile|.
class DownloadTestFileActivityObserver {
public:
// Attaches to |profile|. By default file chooser dialogs will be disabled
// once attached. Call EnableFileChooser() to re-enable.
explicit DownloadTestFileActivityObserver(Profile* profile);
~DownloadTestFileActivityObserver();
// Sets whether the file chooser dialog is enabled. If |enable| is false, any
// attempt to display a file chooser dialog will cause the download to be
// canceled. Otherwise, attempting to display a file chooser dialog will
// result in the download continuing with the suggested path.
void EnableFileChooser(bool enable);
// Returns true if a file chooser dialog was displayed since the last time
// this method was called.
bool TestAndResetDidShowFileChooser();
private:
class MockDownloadManagerDelegate;
scoped_refptr<MockDownloadManagerDelegate> test_delegate_;
};
#endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_TEST_FILE_ACTIVITY_OBSERVER_H_
|