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 3 // found in the LICENSE file. 4 // 5 // Download creation struct used for querying the history service. 6 7 #ifndef CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ 8 #define CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ 9 #pragma once 10 11 #include <string> 12 #include <vector> 13 14 #include "base/basictypes.h" 15 #include "base/file_path.h" 16 #include "base/time.h" 17 #include "chrome/browser/download/download_file.h" 18 #include "googleurl/src/gurl.h" 19 20 // Used for informing the download database of a new download, where we don't 21 // want to pass DownloadItems between threads. The history service also uses a 22 // vector of these structs for passing us the state of all downloads at 23 // initialization time (see DownloadQueryInfo below). 24 struct DownloadCreateInfo { 25 DownloadCreateInfo(const FilePath& path, 26 const GURL& url, 27 base::Time start_time, 28 int64 received_bytes, 29 int64 total_bytes, 30 int32 state, 31 int32 download_id, 32 bool has_user_gesture); 33 DownloadCreateInfo(); 34 ~DownloadCreateInfo(); 35 36 // Indicates if the download is dangerous. 37 bool IsDangerous(); 38 39 std::string DebugString() const; 40 41 // The URL from which we are downloading. This is the final URL after any 42 // redirection by the server for |url_chain|. 43 const GURL& url() const; 44 45 // DownloadItem fields 46 FilePath path; 47 // The chain of redirects that leading up to and including the final URL. 48 std::vector<GURL> url_chain; 49 GURL referrer_url; 50 FilePath suggested_path; 51 // A number that should be added to the suggested path to make it unique. 52 // 0 means no number should be appended. Not actually stored in the db. 53 int path_uniquifier; 54 base::Time start_time; 55 int64 received_bytes; 56 int64 total_bytes; 57 int32 state; 58 int32 download_id; 59 bool has_user_gesture; 60 int child_id; 61 int render_view_id; 62 int request_id; 63 int64 db_handle; 64 std::string content_disposition; 65 std::string mime_type; 66 // The value of the content type header sent with the downloaded item. It 67 // may be different from |mime_type|, which may be set based on heuristics 68 // which may look at the file extension and first few bytes of the file. 69 std::string original_mime_type; 70 71 // True if we should display the 'save as...' UI and prompt the user 72 // for the download location. 73 // False if the UI should be supressed and the download performed to the 74 // default location. 75 bool prompt_user_for_save_location; 76 // Whether this download file is potentially dangerous (ex: exe, dll, ...). 77 bool is_dangerous_file; 78 // If safebrowsing believes this URL leads to malware. 79 bool is_dangerous_url; 80 // The original name for a dangerous download. 81 FilePath original_name; 82 // Whether this download is for extension install or not. 83 bool is_extension_install; 84 // The charset of the referring page where the download request comes from. 85 // It's used to construct a suggested filename. 86 std::string referrer_charset; 87 // The download file save info. 88 DownloadSaveInfo save_info; 89 }; 90 91 #endif // CHROME_BROWSER_HISTORY_DOWNLOAD_CREATE_INFO_H_ 92