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

Side by Side Diff: content/browser/download/download_item_impl.cc

Issue 10805020: Kill DownloadItem::IsOtr() (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: . Created 8 years, 4 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/download/download_item_impl.h" 5 #include "content/browser/download/download_item_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 start_time_(info.start_time), 162 start_time_(info.start_time),
163 end_time_(info.end_time), 163 end_time_(info.end_time),
164 db_handle_(info.db_handle), 164 db_handle_(info.db_handle),
165 delegate_(delegate), 165 delegate_(delegate),
166 is_paused_(false), 166 is_paused_(false),
167 open_when_complete_(false), 167 open_when_complete_(false),
168 file_externally_removed_(false), 168 file_externally_removed_(false),
169 safety_state_(SAFE), 169 safety_state_(SAFE),
170 auto_opened_(false), 170 auto_opened_(false),
171 is_persisted_(true), 171 is_persisted_(true),
172 is_otr_(false),
173 is_temporary_(false), 172 is_temporary_(false),
174 all_data_saved_(false), 173 all_data_saved_(false),
175 opened_(info.opened), 174 opened_(info.opened),
176 open_enabled_(true), 175 open_enabled_(true),
177 delegate_delayed_complete_(false), 176 delegate_delayed_complete_(false),
178 bound_net_log_(bound_net_log), 177 bound_net_log_(bound_net_log),
179 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 178 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
180 delegate_->Attach(); 179 delegate_->Attach();
181 if (IsInProgress()) 180 if (IsInProgress())
182 state_ = CANCELLED; 181 state_ = CANCELLED;
183 if (IsComplete()) 182 if (IsComplete())
184 all_data_saved_ = true; 183 all_data_saved_ = true;
185 Init(false /* not actively downloading */, 184 Init(false /* not actively downloading */,
186 download_net_logs::SRC_HISTORY_IMPORT); 185 download_net_logs::SRC_HISTORY_IMPORT);
187 } 186 }
188 187
189 // Constructing for a regular download: 188 // Constructing for a regular download:
190 DownloadItemImpl::DownloadItemImpl( 189 DownloadItemImpl::DownloadItemImpl(
191 DownloadItemImplDelegate* delegate, 190 DownloadItemImplDelegate* delegate,
192 const DownloadCreateInfo& info, 191 const DownloadCreateInfo& info,
193 scoped_ptr<DownloadRequestHandleInterface> request_handle, 192 scoped_ptr<DownloadRequestHandleInterface> request_handle,
194 bool is_otr,
195 const net::BoundNetLog& bound_net_log) 193 const net::BoundNetLog& bound_net_log)
196 : request_handle_(request_handle.Pass()), 194 : request_handle_(request_handle.Pass()),
197 download_id_(info.download_id), 195 download_id_(info.download_id),
198 target_disposition_( 196 target_disposition_(
199 (info.prompt_user_for_save_location) ? 197 (info.prompt_user_for_save_location) ?
200 TARGET_DISPOSITION_PROMPT : TARGET_DISPOSITION_OVERWRITE), 198 TARGET_DISPOSITION_PROMPT : TARGET_DISPOSITION_OVERWRITE),
201 url_chain_(info.url_chain), 199 url_chain_(info.url_chain),
202 referrer_url_(info.referrer_url), 200 referrer_url_(info.referrer_url),
203 suggested_filename_(UTF16ToUTF8(info.save_info.suggested_name)), 201 suggested_filename_(UTF16ToUTF8(info.save_info.suggested_name)),
204 forced_file_path_(info.save_info.file_path), 202 forced_file_path_(info.save_info.file_path),
(...skipping 13 matching lines...) Expand all
218 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 216 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
219 start_time_(info.start_time), 217 start_time_(info.start_time),
220 db_handle_(DownloadItem::kUninitializedHandle), 218 db_handle_(DownloadItem::kUninitializedHandle),
221 delegate_(delegate), 219 delegate_(delegate),
222 is_paused_(false), 220 is_paused_(false),
223 open_when_complete_(false), 221 open_when_complete_(false),
224 file_externally_removed_(false), 222 file_externally_removed_(false),
225 safety_state_(SAFE), 223 safety_state_(SAFE),
226 auto_opened_(false), 224 auto_opened_(false),
227 is_persisted_(false), 225 is_persisted_(false),
228 is_otr_(is_otr),
229 is_temporary_(!info.save_info.file_path.empty()), 226 is_temporary_(!info.save_info.file_path.empty()),
230 all_data_saved_(false), 227 all_data_saved_(false),
231 opened_(false), 228 opened_(false),
232 open_enabled_(true), 229 open_enabled_(true),
233 delegate_delayed_complete_(false), 230 delegate_delayed_complete_(false),
234 bound_net_log_(bound_net_log), 231 bound_net_log_(bound_net_log),
235 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 232 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
236 delegate_->Attach(); 233 delegate_->Attach();
237 Init(true /* actively downloading */, 234 Init(true /* actively downloading */,
238 download_net_logs::SRC_NEW_DOWNLOAD); 235 download_net_logs::SRC_NEW_DOWNLOAD);
239 236
240 // Link the event sources. 237 // Link the event sources.
241 bound_net_log_.AddEvent( 238 bound_net_log_.AddEvent(
242 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, 239 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST,
243 info.request_bound_net_log.source().ToEventParametersCallback()); 240 info.request_bound_net_log.source().ToEventParametersCallback());
244 241
245 info.request_bound_net_log.AddEvent( 242 info.request_bound_net_log.AddEvent(
246 net::NetLog::TYPE_DOWNLOAD_STARTED, 243 net::NetLog::TYPE_DOWNLOAD_STARTED,
247 bound_net_log_.source().ToEventParametersCallback()); 244 bound_net_log_.source().ToEventParametersCallback());
248 } 245 }
249 246
250 // Constructing for the "Save Page As..." feature: 247 // Constructing for the "Save Page As..." feature:
251 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate, 248 DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
252 const FilePath& path, 249 const FilePath& path,
253 const GURL& url, 250 const GURL& url,
254 bool is_otr,
255 DownloadId download_id, 251 DownloadId download_id,
256 const std::string& mime_type, 252 const std::string& mime_type,
257 const net::BoundNetLog& bound_net_log) 253 const net::BoundNetLog& bound_net_log)
258 : request_handle_(new NullDownloadRequestHandle()), 254 : request_handle_(new NullDownloadRequestHandle()),
259 download_id_(download_id), 255 download_id_(download_id),
260 current_path_(path), 256 current_path_(path),
261 target_path_(path), 257 target_path_(path),
262 target_disposition_(TARGET_DISPOSITION_OVERWRITE), 258 target_disposition_(TARGET_DISPOSITION_OVERWRITE),
263 url_chain_(1, url), 259 url_chain_(1, url),
264 referrer_url_(GURL()), 260 referrer_url_(GURL()),
(...skipping 10 matching lines...) Expand all
275 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS), 271 danger_type_(content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS),
276 start_time_(base::Time::Now()), 272 start_time_(base::Time::Now()),
277 db_handle_(DownloadItem::kUninitializedHandle), 273 db_handle_(DownloadItem::kUninitializedHandle),
278 delegate_(delegate), 274 delegate_(delegate),
279 is_paused_(false), 275 is_paused_(false),
280 open_when_complete_(false), 276 open_when_complete_(false),
281 file_externally_removed_(false), 277 file_externally_removed_(false),
282 safety_state_(SAFE), 278 safety_state_(SAFE),
283 auto_opened_(false), 279 auto_opened_(false),
284 is_persisted_(false), 280 is_persisted_(false),
285 is_otr_(is_otr),
286 is_temporary_(false), 281 is_temporary_(false),
287 all_data_saved_(false), 282 all_data_saved_(false),
288 opened_(false), 283 opened_(false),
289 open_enabled_(true), 284 open_enabled_(true),
290 delegate_delayed_complete_(false), 285 delegate_delayed_complete_(false),
291 bound_net_log_(bound_net_log), 286 bound_net_log_(bound_net_log),
292 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 287 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
293 delegate_->Attach(); 288 delegate_->Attach();
294 Init(true /* actively downloading */, 289 Init(true /* actively downloading */,
295 download_net_logs::SRC_SAVE_PAGE_AS); 290 download_net_logs::SRC_SAVE_PAGE_AS);
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 } 1028 }
1034 } 1029 }
1035 1030
1036 if (verbose) { 1031 if (verbose) {
1037 description += base::StringPrintf( 1032 description += base::StringPrintf(
1038 " db_handle = %" PRId64 1033 " db_handle = %" PRId64
1039 " total = %" PRId64 1034 " total = %" PRId64
1040 " received = %" PRId64 1035 " received = %" PRId64
1041 " reason = %s" 1036 " reason = %s"
1042 " paused = %c" 1037 " paused = %c"
1043 " otr = %c"
1044 " safety = %s" 1038 " safety = %s"
1045 " last_modified = '%s'" 1039 " last_modified = '%s'"
1046 " etag = '%s'" 1040 " etag = '%s'"
1047 " url_chain = \n\t\"%s\"\n\t" 1041 " url_chain = \n\t\"%s\"\n\t"
1048 " full_path = \"%" PRFilePath "\"" 1042 " full_path = \"%" PRFilePath "\""
1049 " target_path = \"%" PRFilePath "\"", 1043 " target_path = \"%" PRFilePath "\"",
1050 GetDbHandle(), 1044 GetDbHandle(),
1051 GetTotalBytes(), 1045 GetTotalBytes(),
1052 GetReceivedBytes(), 1046 GetReceivedBytes(),
1053 InterruptReasonDebugString(last_reason_).c_str(), 1047 InterruptReasonDebugString(last_reason_).c_str(),
1054 IsPaused() ? 'T' : 'F', 1048 IsPaused() ? 'T' : 'F',
1055 IsOtr() ? 'T' : 'F',
1056 DebugSafetyStateString(GetSafetyState()), 1049 DebugSafetyStateString(GetSafetyState()),
1057 GetLastModifiedTime().c_str(), 1050 GetLastModifiedTime().c_str(),
1058 GetETag().c_str(), 1051 GetETag().c_str(),
1059 url_list.c_str(), 1052 url_list.c_str(),
1060 GetFullPath().value().c_str(), 1053 GetFullPath().value().c_str(),
1061 GetTargetFilePath().value().c_str()); 1054 GetTargetFilePath().value().c_str());
1062 } else { 1055 } else {
1063 description += base::StringPrintf(" url = \"%s\"", url_list.c_str()); 1056 description += base::StringPrintf(" url = \"%s\"", url_list.c_str());
1064 } 1057 }
1065 1058
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 } 1125 }
1133 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 1126 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
1134 open_when_complete_ = open; 1127 open_when_complete_ = open;
1135 } 1128 }
1136 bool DownloadItemImpl::GetFileExternallyRemoved() const { 1129 bool DownloadItemImpl::GetFileExternallyRemoved() const {
1137 return file_externally_removed_; 1130 return file_externally_removed_;
1138 } 1131 }
1139 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const { 1132 DownloadItem::SafetyState DownloadItemImpl::GetSafetyState() const {
1140 return safety_state_; 1133 return safety_state_;
1141 } 1134 }
1142 bool DownloadItemImpl::IsOtr() const { return is_otr_; }
1143 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; } 1135 bool DownloadItemImpl::GetAutoOpened() { return auto_opened_; }
1144 FilePath DownloadItemImpl::GetTargetName() const { 1136 FilePath DownloadItemImpl::GetTargetName() const {
1145 return target_path_.BaseName(); 1137 return target_path_.BaseName();
1146 } 1138 }
1147 const FilePath& DownloadItemImpl::GetForcedFilePath() const { 1139 const FilePath& DownloadItemImpl::GetForcedFilePath() const {
1148 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just 1140 // TODO(asanka): Get rid of GetForcedFilePath(). We should instead just
1149 // require that clients respect GetTargetFilePath() if it is already set. 1141 // require that clients respect GetTargetFilePath() if it is already set.
1150 return forced_file_path_; 1142 return forced_file_path_;
1151 } 1143 }
1152 bool DownloadItemImpl::HasUserGesture() const { 1144 bool DownloadItemImpl::HasUserGesture() const {
1153 return has_user_gesture_; 1145 return has_user_gesture_;
1154 }; 1146 };
1155 content::PageTransition DownloadItemImpl::GetTransitionType() const { 1147 content::PageTransition DownloadItemImpl::GetTransitionType() const {
1156 return transition_type_; 1148 return transition_type_;
1157 }; 1149 };
1158 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; } 1150 bool DownloadItemImpl::IsTemporary() const { return is_temporary_; }
1159 void DownloadItemImpl::SetIsTemporary(bool temporary) { 1151 void DownloadItemImpl::SetIsTemporary(bool temporary) {
1160 is_temporary_ = temporary; 1152 is_temporary_ = temporary;
1161 } 1153 }
1162 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; } 1154 void DownloadItemImpl::SetOpened(bool opened) { opened_ = opened; }
1163 bool DownloadItemImpl::GetOpened() const { return opened_; } 1155 bool DownloadItemImpl::GetOpened() const { return opened_; }
1164 const std::string& DownloadItemImpl::GetLastModifiedTime() const { 1156 const std::string& DownloadItemImpl::GetLastModifiedTime() const {
1165 return last_modified_time_; 1157 return last_modified_time_;
1166 } 1158 }
1167 const std::string& DownloadItemImpl::GetETag() const { return etag_; } 1159 const std::string& DownloadItemImpl::GetETag() const { return etag_; }
1168 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const { 1160 content::DownloadInterruptReason DownloadItemImpl::GetLastReason() const {
1169 return last_reason_; 1161 return last_reason_;
1170 } 1162 }
1171 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; } 1163 void DownloadItemImpl::MockDownloadOpenForTesting() { open_enabled_ = false; }
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_item_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698