Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_NTP_SNIPPETS_FAKE_DOWNLOAD_ITEM_H_ | |
| 6 #define CHROME_BROWSER_NTP_SNIPPETS_FAKE_DOWNLOAD_ITEM_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "base/files/file_path.h" | |
| 13 #include "base/observer_list.h" | |
| 14 #include "content/public/browser/download_danger_type.h" | |
| 15 #include "content/public/browser/download_interrupt_reasons.h" | |
| 16 #include "content/public/browser/download_item.h" | |
| 17 #include "ui/base/page_transition_types.h" | |
| 18 #include "url/gurl.h" | |
| 19 | |
| 20 namespace test { | |
| 21 | |
| 22 class FakeDownloadItem : public content::DownloadItem { | |
| 23 public: | |
| 24 FakeDownloadItem(); | |
| 25 ~FakeDownloadItem() override; | |
| 26 | |
| 27 void AddObserver(Observer* observer) override; | |
| 28 | |
| 29 void RemoveObserver(Observer* observer) override; | |
| 30 | |
| 31 void NotifyDownloadDestroyed(); | |
| 32 | |
| 33 void NotifyDownloadRemoved(); | |
| 34 | |
| 35 void NotifyDownloadUpdated(); | |
| 36 | |
| 37 void UpdateObservers() override; | |
| 38 | |
| 39 void SetId(uint32_t id); | |
| 40 uint32_t GetId() const override; | |
| 41 | |
| 42 void SetURL(GURL url); | |
| 43 const GURL& GetURL() const override; | |
| 44 | |
| 45 void SetTargetFilePath(const base::FilePath& file_path); | |
| 46 const base::FilePath& GetTargetFilePath() const override; | |
| 47 | |
| 48 void SetFileExternallyRemoved(bool is_file_externally_removed); | |
| 49 bool GetFileExternallyRemoved() const override; | |
| 50 | |
| 51 void SetEndTime(const base::Time& end_time); | |
| 52 base::Time GetEndTime() const override; | |
| 53 | |
| 54 void SetState(const DownloadState& state); | |
| 55 DownloadState GetState() const override; | |
| 56 | |
| 57 // The methods below are not supported and are not expected to be called. | |
| 58 void ValidateDangerousDownload() override; | |
| 59 void StealDangerousDownload(const AcquireFileCallback& callback) override; | |
| 60 void Pause() override; | |
| 61 void Resume() override; | |
| 62 void Cancel(bool user_cancel) override; | |
| 63 void Remove() override; | |
| 64 void OpenDownload() override; | |
| 65 void ShowDownloadInShell() override; | |
| 66 const std::string& GetGuid() const override; | |
| 67 content::DownloadInterruptReason GetLastReason() const override; | |
| 68 bool IsPaused() const override; | |
| 69 bool IsTemporary() const override; | |
| 70 bool CanResume() const override; | |
| 71 bool IsDone() const override; | |
| 72 const std::vector<GURL>& GetUrlChain() const override; | |
| 73 const GURL& GetOriginalUrl() const override; | |
| 74 const GURL& GetReferrerUrl() const override; | |
| 75 const GURL& GetSiteUrl() const override; | |
| 76 const GURL& GetTabUrl() const override; | |
| 77 const GURL& GetTabReferrerUrl() const override; | |
| 78 std::string GetSuggestedFilename() const override; | |
| 79 std::string GetContentDisposition() const override; | |
| 80 std::string GetMimeType() const override; | |
| 81 std::string GetOriginalMimeType() const override; | |
| 82 std::string GetRemoteAddress() const override; | |
| 83 bool HasUserGesture() const override; | |
| 84 ui::PageTransition GetTransitionType() const override; | |
| 85 const std::string& GetLastModifiedTime() const override; | |
| 86 const std::string& GetETag() const override; | |
| 87 bool IsSavePackageDownload() const override; | |
| 88 const base::FilePath& GetFullPath() const override; | |
| 89 const base::FilePath& GetForcedFilePath() const override; | |
| 90 base::FilePath GetFileNameToReportUser() const override; | |
| 91 TargetDisposition GetTargetDisposition() const override; | |
| 92 const std::string& GetHash() const override; | |
| 93 void DeleteFile(const base::Callback<void(bool)>& callback) override; | |
| 94 bool IsDangerous() const override; | |
| 95 content::DownloadDangerType GetDangerType() const override; | |
| 96 bool TimeRemaining(base::TimeDelta* remaining) const override; | |
| 97 int64_t CurrentSpeed() const override; | |
| 98 int PercentComplete() const override; | |
| 99 bool AllDataSaved() const override; | |
| 100 int64_t GetTotalBytes() const override; | |
| 101 int64_t GetReceivedBytes() const override; | |
| 102 base::Time GetStartTime() const override; | |
| 103 bool CanShowInFolder() override; | |
| 104 bool CanOpenDownload() override; | |
| 105 bool ShouldOpenFileBasedOnExtension() override; | |
| 106 bool GetOpenWhenComplete() const override; | |
| 107 bool GetAutoOpened() override; | |
| 108 bool GetOpened() const override; | |
| 109 content::BrowserContext* GetBrowserContext() const override; | |
| 110 content::WebContents* GetWebContents() const override; | |
| 111 void OnContentCheckCompleted( | |
| 112 content::DownloadDangerType danger_type) override; | |
| 113 void SetOpenWhenComplete(bool open) override; | |
| 114 void SetOpened(bool opened) override; | |
| 115 void SetDisplayName(const base::FilePath& name) override; | |
| 116 std::string DebugString(bool verbose) const override; | |
| 117 | |
| 118 private: | |
| 119 base::ObserverList<Observer> observers_; | |
| 120 uint32_t id_; | |
| 121 GURL url_; | |
| 122 base::FilePath file_path_; | |
| 123 bool is_file_externally_removed_; | |
| 124 base::Time end_time_; | |
| 125 DownloadState download_state_; | |
| 126 | |
| 127 // The members below are to be returned by methods, which return by reference. | |
| 128 std::string dummy_string; | |
| 129 std::vector<GURL> dummy_url_vector; | |
| 130 GURL dummy_url; | |
| 131 base::FilePath dummy_file_path; | |
|
Bernhard Bauer
2016/10/26 10:19:33
DISALLOW_COPY_AND_ASSIGN
vitaliii
2016/10/27 15:49:20
Done.
| |
| 132 }; | |
| 133 | |
| 134 } // namespace test | |
| 135 | |
| 136 #endif // CHROME_BROWSER_NTP_SNIPPETS_FAKE_DOWNLOAD_ITEM_H_ | |
| OLD | NEW |