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 #include "chrome/browser/ntp_snippets/fake_download_item.h" | |
6 | |
7 #include "base/bind.h" | |
8 | |
9 using content::DownloadItem; | |
10 | |
11 namespace test { | |
12 | |
13 FakeDownloadItem::FakeDownloadItem() = default; | |
14 | |
15 FakeDownloadItem::~FakeDownloadItem() { | |
16 NotifyDownloadRemoved(); | |
17 NotifyDownloadDestroyed(); | |
18 } | |
19 | |
20 void FakeDownloadItem::AddObserver(Observer* observer) { | |
21 observers_.AddObserver(observer); | |
22 } | |
23 | |
24 void FakeDownloadItem::RemoveObserver(Observer* observer) { | |
25 observers_.RemoveObserver(observer); | |
26 } | |
27 | |
28 void FakeDownloadItem::NotifyDownloadDestroyed() { | |
29 for (auto& observer : observers_) { | |
30 observer.OnDownloadDestroyed(this); | |
31 } | |
32 } | |
33 | |
34 void FakeDownloadItem::NotifyDownloadRemoved() { | |
35 for (auto& observer : observers_) { | |
36 observer.OnDownloadRemoved(this); | |
37 } | |
38 } | |
39 | |
40 void FakeDownloadItem::NotifyDownloadUpdated() { | |
41 UpdateObservers(); | |
42 } | |
43 | |
44 void FakeDownloadItem::UpdateObservers() { | |
45 for (auto& observer : observers_) { | |
46 observer.OnDownloadUpdated(this); | |
47 } | |
48 } | |
49 | |
50 void FakeDownloadItem::SetId(uint32_t id) { | |
51 id_ = id; | |
52 } | |
53 | |
54 uint32_t FakeDownloadItem::GetId() const { | |
55 return id_; | |
56 } | |
57 | |
58 void FakeDownloadItem::SetGuid(const std::string& guid) { | |
59 guid_ = guid; | |
60 } | |
61 | |
62 const std::string& FakeDownloadItem::GetGuid() const { | |
63 return guid_; | |
64 } | |
65 | |
66 void FakeDownloadItem::SetURL(const GURL& url) { | |
67 url_ = url; | |
68 } | |
69 | |
70 const GURL& FakeDownloadItem::GetURL() const { | |
71 return url_; | |
72 } | |
73 | |
74 void FakeDownloadItem::SetTargetFilePath(const base::FilePath& file_path) { | |
75 file_path_ = file_path; | |
76 } | |
77 | |
78 const base::FilePath& FakeDownloadItem::GetTargetFilePath() const { | |
79 return file_path_; | |
80 } | |
81 | |
82 void FakeDownloadItem::SetFileExternallyRemoved( | |
83 bool is_file_externally_removed) { | |
84 is_file_externally_removed_ = is_file_externally_removed; | |
85 } | |
86 | |
87 bool FakeDownloadItem::GetFileExternallyRemoved() const { | |
88 return is_file_externally_removed_; | |
89 } | |
90 | |
91 void FakeDownloadItem::SetStartTime(base::Time start_time) { | |
92 start_time_ = start_time; | |
93 } | |
94 | |
95 base::Time FakeDownloadItem::GetStartTime() const { | |
96 return start_time_; | |
97 } | |
98 | |
99 void FakeDownloadItem::SetEndTime(base::Time end_time) { | |
100 end_time_ = end_time; | |
101 } | |
102 | |
103 base::Time FakeDownloadItem::GetEndTime() const { | |
104 return end_time_; | |
105 } | |
106 | |
107 void FakeDownloadItem::SetState(const DownloadState& state) { | |
108 download_state_ = state; | |
109 } | |
110 | |
111 DownloadItem::DownloadState FakeDownloadItem::GetState() const { | |
112 return download_state_; | |
113 } | |
114 | |
115 void FakeDownloadItem::SetMimeType(const std::string& mime_type) { | |
116 mime_type_ = mime_type; | |
117 } | |
118 | |
119 std::string FakeDownloadItem::GetMimeType() const { | |
120 return mime_type_; | |
121 } | |
122 | |
123 void FakeDownloadItem::SetOriginalUrl(const GURL& url) { | |
124 original_url_ = url; | |
125 } | |
126 | |
127 const GURL& FakeDownloadItem::GetOriginalUrl() const { | |
128 return original_url_; | |
129 } | |
130 | |
131 // The methods below are not supported and are not expected to be called. | |
132 void FakeDownloadItem::ValidateDangerousDownload() { | |
133 NOTREACHED(); | |
134 } | |
135 | |
136 void FakeDownloadItem::StealDangerousDownload( | |
137 bool delete_file_afterward, | |
138 const AcquireFileCallback& callback) { | |
139 NOTREACHED(); | |
140 callback.Run(base::FilePath()); | |
141 } | |
142 | |
143 void FakeDownloadItem::Pause() { | |
144 NOTREACHED(); | |
145 } | |
146 | |
147 void FakeDownloadItem::Resume() { | |
148 NOTREACHED(); | |
149 } | |
150 | |
151 void FakeDownloadItem::Cancel(bool user_cancel) { | |
152 NOTREACHED(); | |
153 } | |
154 | |
155 void FakeDownloadItem::Remove() { | |
156 NOTREACHED(); | |
157 } | |
158 | |
159 void FakeDownloadItem::OpenDownload() { | |
160 NOTREACHED(); | |
161 } | |
162 | |
163 void FakeDownloadItem::ShowDownloadInShell() { | |
164 NOTREACHED(); | |
165 } | |
166 | |
167 content::DownloadInterruptReason FakeDownloadItem::GetLastReason() const { | |
168 NOTREACHED(); | |
169 return content::DownloadInterruptReason(); | |
170 } | |
171 | |
172 bool FakeDownloadItem::IsPaused() const { | |
173 NOTREACHED(); | |
174 return false; | |
175 } | |
176 | |
177 bool FakeDownloadItem::IsTemporary() const { | |
178 NOTREACHED(); | |
179 return false; | |
180 } | |
181 | |
182 bool FakeDownloadItem::CanResume() const { | |
183 NOTREACHED(); | |
184 return false; | |
185 } | |
186 | |
187 bool FakeDownloadItem::IsDone() const { | |
188 NOTREACHED(); | |
189 return true; | |
190 } | |
191 | |
192 const std::vector<GURL>& FakeDownloadItem::GetUrlChain() const { | |
193 NOTREACHED(); | |
194 return dummy_url_vector; | |
195 } | |
196 | |
197 const GURL& FakeDownloadItem::GetReferrerUrl() const { | |
198 NOTREACHED(); | |
199 return dummy_url; | |
200 } | |
201 | |
202 const GURL& FakeDownloadItem::GetSiteUrl() const { | |
203 NOTREACHED(); | |
204 return dummy_url; | |
205 } | |
206 | |
207 const GURL& FakeDownloadItem::GetTabUrl() const { | |
208 NOTREACHED(); | |
209 return dummy_url; | |
210 } | |
211 | |
212 const GURL& FakeDownloadItem::GetTabReferrerUrl() const { | |
213 NOTREACHED(); | |
214 return dummy_url; | |
215 } | |
216 | |
217 std::string FakeDownloadItem::GetSuggestedFilename() const { | |
218 NOTREACHED(); | |
219 return std::string(); | |
220 } | |
221 | |
222 std::string FakeDownloadItem::GetContentDisposition() const { | |
223 NOTREACHED(); | |
224 return std::string(); | |
225 } | |
226 | |
227 std::string FakeDownloadItem::GetOriginalMimeType() const { | |
228 NOTREACHED(); | |
229 return std::string(); | |
230 } | |
231 | |
232 std::string FakeDownloadItem::GetRemoteAddress() const { | |
233 NOTREACHED(); | |
234 return std::string(); | |
235 } | |
236 | |
237 bool FakeDownloadItem::HasUserGesture() const { | |
238 NOTREACHED(); | |
239 return false; | |
240 } | |
241 | |
242 ui::PageTransition FakeDownloadItem::GetTransitionType() const { | |
243 NOTREACHED(); | |
244 return ui::PageTransition(); | |
245 } | |
246 | |
247 const std::string& FakeDownloadItem::GetLastModifiedTime() const { | |
248 NOTREACHED(); | |
249 return dummy_string; | |
250 } | |
251 | |
252 const std::string& FakeDownloadItem::GetETag() const { | |
253 NOTREACHED(); | |
254 return dummy_string; | |
255 } | |
256 | |
257 bool FakeDownloadItem::IsSavePackageDownload() const { | |
258 NOTREACHED(); | |
259 return false; | |
260 } | |
261 | |
262 const base::FilePath& FakeDownloadItem::GetFullPath() const { | |
263 NOTREACHED(); | |
264 return dummy_file_path; | |
265 } | |
266 | |
267 const base::FilePath& FakeDownloadItem::GetForcedFilePath() const { | |
268 NOTREACHED(); | |
269 return dummy_file_path; | |
270 } | |
271 | |
272 base::FilePath FakeDownloadItem::GetFileNameToReportUser() const { | |
273 NOTREACHED(); | |
274 return base::FilePath(); | |
275 } | |
276 | |
277 DownloadItem::TargetDisposition FakeDownloadItem::GetTargetDisposition() const { | |
278 NOTREACHED(); | |
279 return TargetDisposition(); | |
280 } | |
281 | |
282 const std::string& FakeDownloadItem::GetHash() const { | |
283 NOTREACHED(); | |
284 return dummy_string; | |
285 } | |
286 | |
287 void FakeDownloadItem::DeleteFile(const base::Callback<void(bool)>& callback) { | |
288 NOTREACHED(); | |
289 callback.Run(false); | |
290 } | |
291 | |
292 bool FakeDownloadItem::IsDangerous() const { | |
293 NOTREACHED(); | |
294 return false; | |
295 } | |
296 | |
297 content::DownloadDangerType FakeDownloadItem::GetDangerType() const { | |
298 NOTREACHED(); | |
299 return content::DownloadDangerType(); | |
300 } | |
301 | |
302 bool FakeDownloadItem::TimeRemaining(base::TimeDelta* remaining) const { | |
303 NOTREACHED(); | |
304 return false; | |
305 } | |
306 | |
307 int64_t FakeDownloadItem::CurrentSpeed() const { | |
308 NOTREACHED(); | |
309 return 1; | |
310 } | |
311 | |
312 int FakeDownloadItem::PercentComplete() const { | |
313 NOTREACHED(); | |
314 return 1; | |
315 } | |
316 | |
317 bool FakeDownloadItem::AllDataSaved() const { | |
318 NOTREACHED(); | |
319 return true; | |
320 } | |
321 | |
322 int64_t FakeDownloadItem::GetTotalBytes() const { | |
323 NOTREACHED(); | |
324 return 1; | |
325 } | |
326 | |
327 int64_t FakeDownloadItem::GetReceivedBytes() const { | |
328 NOTREACHED(); | |
329 return 1; | |
330 } | |
331 | |
332 const std::vector<DownloadItem::ReceivedSlice>& | |
333 FakeDownloadItem::GetReceivedSlices() const { | |
334 NOTREACHED(); | |
335 static const std::vector<DownloadItem::ReceivedSlice> slices; | |
336 return slices; | |
337 } | |
338 | |
339 bool FakeDownloadItem::CanShowInFolder() { | |
340 NOTREACHED(); | |
341 return true; | |
342 } | |
343 | |
344 bool FakeDownloadItem::CanOpenDownload() { | |
345 NOTREACHED(); | |
346 return true; | |
347 } | |
348 | |
349 bool FakeDownloadItem::ShouldOpenFileBasedOnExtension() { | |
350 NOTREACHED(); | |
351 return true; | |
352 } | |
353 | |
354 bool FakeDownloadItem::GetOpenWhenComplete() const { | |
355 NOTREACHED(); | |
356 return false; | |
357 } | |
358 | |
359 bool FakeDownloadItem::GetAutoOpened() { | |
360 NOTREACHED(); | |
361 return false; | |
362 } | |
363 | |
364 bool FakeDownloadItem::GetOpened() const { | |
365 NOTREACHED(); | |
366 return false; | |
367 } | |
368 | |
369 base::Time FakeDownloadItem::GetLastAccessTime() const { | |
370 NOTREACHED(); | |
371 return base::Time(); | |
372 } | |
373 | |
374 content::BrowserContext* FakeDownloadItem::GetBrowserContext() const { | |
375 NOTREACHED(); | |
376 return nullptr; | |
377 } | |
378 | |
379 content::WebContents* FakeDownloadItem::GetWebContents() const { | |
380 NOTREACHED(); | |
381 return nullptr; | |
382 } | |
383 | |
384 void FakeDownloadItem::OnContentCheckCompleted( | |
385 content::DownloadDangerType danger_type) { | |
386 NOTREACHED(); | |
387 } | |
388 | |
389 void FakeDownloadItem::SetOpenWhenComplete(bool open) { | |
390 NOTREACHED(); | |
391 } | |
392 | |
393 void FakeDownloadItem::SetOpened(bool opened) { | |
394 NOTREACHED(); | |
395 } | |
396 | |
397 void FakeDownloadItem::SetLastAccessTime(base::Time time) { | |
398 NOTREACHED(); | |
399 } | |
400 | |
401 void FakeDownloadItem::SetDisplayName(const base::FilePath& name) { | |
402 NOTREACHED(); | |
403 } | |
404 | |
405 std::string FakeDownloadItem::DebugString(bool verbose) const { | |
406 NOTREACHED(); | |
407 return std::string(); | |
408 } | |
409 | |
410 } // namespace test | |
OLD | NEW |