OLD | NEW |
| (Empty) |
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 db_handle(0), | |
30 prompt_user_for_save_location(false), | |
31 is_dangerous_file(false), | |
32 is_dangerous_url(false), | |
33 is_extension_install(false) { | |
34 } | |
35 | |
36 DownloadCreateInfo::DownloadCreateInfo() | |
37 : path_uniquifier(0), | |
38 received_bytes(0), | |
39 total_bytes(0), | |
40 state(-1), | |
41 download_id(-1), | |
42 has_user_gesture(false), | |
43 db_handle(0), | |
44 prompt_user_for_save_location(false), | |
45 is_dangerous_file(false), | |
46 is_dangerous_url(false), | |
47 is_extension_install(false) { | |
48 } | |
49 | |
50 DownloadCreateInfo::~DownloadCreateInfo() { | |
51 } | |
52 | |
53 bool DownloadCreateInfo::IsDangerous() { | |
54 return is_dangerous_url || is_dangerous_file; | |
55 } | |
56 | |
57 std::string DownloadCreateInfo::DebugString() const { | |
58 return base::StringPrintf("{" | |
59 " download_id = %d" | |
60 " url = \"%s\"" | |
61 " path = \"%" PRFilePath "\"" | |
62 " received_bytes = %" PRId64 | |
63 " total_bytes = %" PRId64 | |
64 " child_id = %d" | |
65 " render_view_id = %d" | |
66 " request_id = %d" | |
67 " prompt_user_for_save_location = %c" | |
68 " }", | |
69 download_id, | |
70 url().spec().c_str(), | |
71 path.value().c_str(), | |
72 received_bytes, | |
73 total_bytes, | |
74 process_handle.child_id(), | |
75 process_handle.render_view_id(), | |
76 process_handle.request_id(), | |
77 prompt_user_for_save_location ? 'T' : 'F'); | |
78 } | |
79 | |
80 const GURL& DownloadCreateInfo::url() const { | |
81 return url_chain.empty() ? GURL::EmptyGURL() : url_chain.back(); | |
82 } | |
OLD | NEW |