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