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 #include "chrome/browser/history/download_create_info.h" 6 7 #include <string> 8 9 #include "base/format_macros.h" 10 #include "base/stringprintf.h" 11 12 DownloadCreateInfo::DownloadCreateInfo(const FilePath& path, 13 const GURL& url, 14 base::Time start_time, 15 int64 received_bytes, 16 int64 total_bytes, 17 int32 state, 18 int32 download_id, 19 bool has_user_gesture) 20 : path(path), 21 url_chain(1, url), 22 path_uniquifier(0), 23 start_time(start_time), 24 received_bytes(received_bytes), 25 total_bytes(total_bytes), 26 state(state), 27 download_id(download_id), 28 has_user_gesture(has_user_gesture), 29 child_id(-1), 30 render_view_id(-1), 31 request_id(-1), 32 db_handle(0), 33 prompt_user_for_save_location(false), 34 is_dangerous_file(false), 35 is_dangerous_url(false), 36 is_extension_install(false) { 37 } 38 39 DownloadCreateInfo::DownloadCreateInfo() 40 : path_uniquifier(0), 41 received_bytes(0), 42 total_bytes(0), 43 state(-1), 44 download_id(-1), 45 has_user_gesture(false), 46 child_id(-1), 47 render_view_id(-1), 48 request_id(-1), 49 db_handle(0), 50 prompt_user_for_save_location(false), 51 is_dangerous_file(false), 52 is_dangerous_url(false), 53 is_extension_install(false) { 54 } 55 56 DownloadCreateInfo::~DownloadCreateInfo() { 57 } 58 59 bool DownloadCreateInfo::IsDangerous() { 60 return is_dangerous_url || is_dangerous_file; 61 } 62 63 std::string DownloadCreateInfo::DebugString() const { 64 return base::StringPrintf("{" 65 " url_ = \"%s\"" 66 " path = \"%" PRFilePath "\"" 67 " received_bytes = %" PRId64 68 " total_bytes = %" PRId64 69 " child_id = %d" 70 " render_view_id = %d" 71 " request_id = %d" 72 " download_id = %d" 73 " prompt_user_for_save_location = %c" 74 " }", 75 url().spec().c_str(), 76 path.value().c_str(), 77 received_bytes, 78 total_bytes, 79 child_id, 80 render_view_id, 81 request_id, 82 download_id, 83 prompt_user_for_save_location ? 'T' : 'F'); 84 } 85 86 const GURL& DownloadCreateInfo::url() const { 87 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); 88 } 89