Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: content/browser/download/download_item.h

Issue 8468020: Propagate the SafeBrowsing download protection verdict to the DownloadItem. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix typo Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Each download is represented by a DownloadItem, and all DownloadItems 5 // Each download is represented by a DownloadItem, and all DownloadItems
6 // are owned by the DownloadManager which maintains a global list of all 6 // are owned by the DownloadManager which maintains a global list of all
7 // downloads. DownloadItems are created when a user initiates a download, 7 // downloads. DownloadItems are created when a user initiates a download,
8 // and exist for the duration of the browser life time. 8 // and exist for the duration of the browser life time.
9 // 9 //
10 // Download observers: 10 // Download observers:
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // Maximum value. 68 // Maximum value.
69 MAX_DOWNLOAD_STATE 69 MAX_DOWNLOAD_STATE
70 }; 70 };
71 71
72 enum SafetyState { 72 enum SafetyState {
73 SAFE = 0, 73 SAFE = 0,
74 DANGEROUS, 74 DANGEROUS,
75 DANGEROUS_BUT_VALIDATED // Dangerous but the user confirmed the download. 75 DANGEROUS_BUT_VALIDATED // Dangerous but the user confirmed the download.
76 }; 76 };
77 77
78 // This enum is used by histograms. Do not change the ordering or remove
79 // items.
80 enum DangerType {
81 NOT_DANGEROUS = 0,
82
83 // A dangerous file to the system (e.g.: an executable or extension from
84 // places other than gallery).
85 DANGEROUS_FILE,
86
87 // Safebrowsing service shows this URL leads to malicious file download.
88 DANGEROUS_URL,
89
90 // Memory space for histograms is determined by the max.
91 // ALWAYS ADD NEW VALUES BEFORE THIS ONE.
92 DANGEROUS_TYPE_MAX
93 };
94
95 // Reason for deleting the download. Passed to Delete(). 78 // Reason for deleting the download. Passed to Delete().
96 enum DeleteReason { 79 enum DeleteReason {
97 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0, 80 DELETE_DUE_TO_BROWSER_SHUTDOWN = 0,
98 DELETE_DUE_TO_USER_DISCARD 81 DELETE_DUE_TO_USER_DISCARD
99 }; 82 };
100 83
101 // A fake download table ID which represents a download that has started, 84 // A fake download table ID which represents a download that has started,
102 // but is not yet in the table. 85 // but is not yet in the table.
103 static const int kUninitializedHandle; 86 static const int kUninitializedHandle;
104 87
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 base::Time end_time() const { return end_time_; } 273 base::Time end_time() const { return end_time_; }
291 void set_db_handle(int64 handle) { db_handle_ = handle; } 274 void set_db_handle(int64 handle) { db_handle_ = handle; }
292 int64 db_handle() const { return db_handle_; } 275 int64 db_handle() const { return db_handle_; }
293 DownloadManager* download_manager() { return download_manager_; } 276 DownloadManager* download_manager() { return download_manager_; }
294 bool is_paused() const { return is_paused_; } 277 bool is_paused() const { return is_paused_; }
295 bool open_when_complete() const { return open_when_complete_; } 278 bool open_when_complete() const { return open_when_complete_; }
296 void set_open_when_complete(bool open) { open_when_complete_ = open; } 279 void set_open_when_complete(bool open) { open_when_complete_ = open; }
297 bool file_externally_removed() const { return file_externally_removed_; } 280 bool file_externally_removed() const { return file_externally_removed_; }
298 SafetyState safety_state() const { return safety_state_; } 281 SafetyState safety_state() const { return safety_state_; }
299 // Why |safety_state_| is not SAFE. 282 // Why |safety_state_| is not SAFE.
300 DangerType GetDangerType() const; 283 DownloadStateInfo::DangerType GetDangerType() const;
301 bool IsDangerous() const; 284 bool IsDangerous() const;
302 void MarkFileDangerous(); 285 void MarkFileDangerous();
303 void MarkUrlDangerous(); 286 void MarkUrlDangerous();
287 void MarkContentDangerous();
304 288
305 bool auto_opened() { return auto_opened_; } 289 bool auto_opened() { return auto_opened_; }
306 const FilePath& target_name() const { return state_info_.target_name; } 290 const FilePath& target_name() const { return state_info_.target_name; }
307 bool prompt_user_for_save_location() const { 291 bool prompt_user_for_save_location() const {
308 return state_info_.prompt_user_for_save_location; 292 return state_info_.prompt_user_for_save_location;
309 } 293 }
310 bool is_otr() const { return is_otr_; } 294 bool is_otr() const { return is_otr_; }
311 const FilePath& suggested_path() const { return state_info_.suggested_path; } 295 const FilePath& suggested_path() const { return state_info_.suggested_path; }
312 bool is_temporary() const { return is_temporary_; } 296 bool is_temporary() const { return is_temporary_; }
313 void set_opened(bool opened) { opened_ = opened; } 297 void set_opened(bool opened) { opened_ = opened; }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // Internal helper for maintaining consistent received and total sizes. 341 // Internal helper for maintaining consistent received and total sizes.
358 void UpdateSize(int64 size); 342 void UpdateSize(int64 size);
359 343
360 // Called when the entire download operation (including renaming etc) 344 // Called when the entire download operation (including renaming etc)
361 // is completed. 345 // is completed.
362 void Completed(); 346 void Completed();
363 347
364 // Call to transition state; all state transitions should go through this. 348 // Call to transition state; all state transitions should go through this.
365 void TransitionTo(DownloadState new_state); 349 void TransitionTo(DownloadState new_state);
366 350
367 // Called when safety_state_ should be recomputed from is_dangerous_file 351 // Called when safety_state_ should be recomputed from the DangerType of the
368 // and is_dangerous_url. 352 // state info.
369 void UpdateSafetyState(); 353 void UpdateSafetyState();
370 354
371 // Helper function to recompute |state_info_.target_name| when 355 // Helper function to recompute |state_info_.target_name| when
372 // it may have changed. (If it's non-null it should be left alone, 356 // it may have changed. (If it's non-null it should be left alone,
373 // otherwise updated from |full_path_|.) 357 // otherwise updated from |full_path_|.)
374 void UpdateTarget(); 358 void UpdateTarget();
375 359
376 // State information used by the download manager. 360 // State information used by the download manager.
377 DownloadStateInfo state_info_; 361 DownloadStateInfo state_info_;
378 362
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 // only. 473 // only.
490 bool open_enabled_; 474 bool open_enabled_;
491 475
492 // Did the delegate delay calling Complete on this download? 476 // Did the delegate delay calling Complete on this download?
493 bool delegate_delayed_complete_; 477 bool delegate_delayed_complete_;
494 478
495 DISALLOW_COPY_AND_ASSIGN(DownloadItem); 479 DISALLOW_COPY_AND_ASSIGN(DownloadItem);
496 }; 480 };
497 481
498 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_ 482 #endif // CONTENT_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698