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 SetGuid(const std::string& guid); | |
43 const std::string& GetGuid() const override; | |
44 | |
45 void SetURL(const GURL& url); | |
46 const GURL& GetURL() const override; | |
47 | |
48 void SetTargetFilePath(const base::FilePath& file_path); | |
49 const base::FilePath& GetTargetFilePath() const override; | |
50 | |
51 void SetFileExternallyRemoved(bool is_file_externally_removed); | |
52 bool GetFileExternallyRemoved() const override; | |
53 | |
54 void SetStartTime(base::Time start_time); | |
55 base::Time GetStartTime() const override; | |
56 | |
57 void SetEndTime(base::Time end_time); | |
58 base::Time GetEndTime() const override; | |
59 | |
60 void SetState(const DownloadState& state); | |
61 DownloadState GetState() const override; | |
62 | |
63 void SetMimeType(const std::string& mime_type); | |
64 std::string GetMimeType() const override; | |
65 | |
66 void SetOriginalUrl(const GURL& url); | |
67 const GURL& GetOriginalUrl() const override; | |
68 | |
69 // The methods below are not supported and are not expected to be called. | |
70 void ValidateDangerousDownload() override; | |
71 void StealDangerousDownload(bool delete_file_afterward, | |
72 const AcquireFileCallback& callback) override; | |
73 void Pause() override; | |
74 void Resume() override; | |
75 void Cancel(bool user_cancel) override; | |
76 void Remove() override; | |
77 void OpenDownload() override; | |
78 void ShowDownloadInShell() override; | |
79 content::DownloadInterruptReason GetLastReason() const override; | |
80 bool IsPaused() const override; | |
81 bool IsTemporary() const override; | |
82 bool CanResume() const override; | |
83 bool IsDone() const override; | |
84 const std::vector<GURL>& GetUrlChain() const override; | |
85 const GURL& GetReferrerUrl() const override; | |
86 const GURL& GetSiteUrl() const override; | |
87 const GURL& GetTabUrl() const override; | |
88 const GURL& GetTabReferrerUrl() const override; | |
89 std::string GetSuggestedFilename() const override; | |
90 std::string GetContentDisposition() const override; | |
91 std::string GetOriginalMimeType() const override; | |
92 std::string GetRemoteAddress() const override; | |
93 bool HasUserGesture() const override; | |
94 ui::PageTransition GetTransitionType() const override; | |
95 const std::string& GetLastModifiedTime() const override; | |
96 const std::string& GetETag() const override; | |
97 bool IsSavePackageDownload() const override; | |
98 const base::FilePath& GetFullPath() const override; | |
99 const base::FilePath& GetForcedFilePath() const override; | |
100 base::FilePath GetFileNameToReportUser() const override; | |
101 TargetDisposition GetTargetDisposition() const override; | |
102 const std::string& GetHash() const override; | |
103 void DeleteFile(const base::Callback<void(bool)>& callback) override; | |
104 bool IsDangerous() const override; | |
105 content::DownloadDangerType GetDangerType() const override; | |
106 bool TimeRemaining(base::TimeDelta* remaining) const override; | |
107 int64_t CurrentSpeed() const override; | |
108 int PercentComplete() const override; | |
109 bool AllDataSaved() const override; | |
110 int64_t GetTotalBytes() const override; | |
111 int64_t GetReceivedBytes() const override; | |
112 const std::vector<DownloadItem::ReceivedSlice>& GetReceivedSlices() | |
113 const override; | |
114 bool CanShowInFolder() override; | |
115 bool CanOpenDownload() override; | |
116 bool ShouldOpenFileBasedOnExtension() override; | |
117 bool GetOpenWhenComplete() const override; | |
118 bool GetAutoOpened() override; | |
119 bool GetOpened() const override; | |
120 base::Time GetLastAccessTime() const override; | |
121 content::BrowserContext* GetBrowserContext() const override; | |
122 content::WebContents* GetWebContents() const override; | |
123 void OnContentCheckCompleted( | |
124 content::DownloadDangerType danger_type) override; | |
125 void SetOpenWhenComplete(bool open) override; | |
126 void SetOpened(bool opened) override; | |
127 void SetLastAccessTime(base::Time time) override; | |
128 void SetDisplayName(const base::FilePath& name) override; | |
129 std::string DebugString(bool verbose) const override; | |
130 | |
131 private: | |
132 base::ObserverList<Observer> observers_; | |
133 uint32_t id_; | |
134 std::string guid_; | |
135 GURL url_; | |
136 base::FilePath file_path_; | |
137 bool is_file_externally_removed_; | |
138 base::Time start_time_; | |
139 base::Time end_time_; | |
140 DownloadState download_state_; | |
141 std::string mime_type_; | |
142 GURL original_url_; | |
143 | |
144 // The members below are to be returned by methods, which return by reference. | |
145 std::string dummy_string; | |
146 std::vector<GURL> dummy_url_vector; | |
147 GURL dummy_url; | |
148 base::FilePath dummy_file_path; | |
149 | |
150 DISALLOW_COPY_AND_ASSIGN(FakeDownloadItem); | |
151 }; | |
152 | |
153 } // namespace test | |
154 | |
155 #endif // CHROME_BROWSER_NTP_SNIPPETS_FAKE_DOWNLOAD_ITEM_H_ | |
OLD | NEW |