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

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

Issue 10980002: Mac Web Intents Part 1: Show extension download progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added test Created 8 years, 2 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 // File method ordering: Methods in this file are in the same order 5 // File method ordering: Methods in this file are in the same order
6 // as in download_item_impl.h, with the following exception: The public 6 // as in download_item_impl.h, with the following exception: The public
7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and 7 // interfaces DelayedDownloadOpened, OnDownloadTargetDetermined, and
8 // OnDownloadCompleting are placed in chronological order with the other 8 // OnDownloadCompleting are placed in chronological order with the other
9 // (private) routines that together define a DownloadItem's state transitions 9 // (private) routines that together define a DownloadItem's state transitions
10 // as the download progresses. See "Download progression cascade" later in 10 // as the download progresses. See "Download progression cascade" later in
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 file_externally_removed_(false), 153 file_externally_removed_(false),
154 safety_state_(SAFE), 154 safety_state_(SAFE),
155 auto_opened_(false), 155 auto_opened_(false),
156 is_persisted_(true), 156 is_persisted_(true),
157 is_temporary_(false), 157 is_temporary_(false),
158 all_data_saved_(false), 158 all_data_saved_(false),
159 opened_(info.opened), 159 opened_(info.opened),
160 open_enabled_(true), 160 open_enabled_(true),
161 delegate_delayed_complete_(false), 161 delegate_delayed_complete_(false),
162 bound_net_log_(bound_net_log), 162 bound_net_log_(bound_net_log),
163 is_hidden_download_(false),
163 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 164 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
164 delegate_->Attach(); 165 delegate_->Attach();
165 if (state_ == IN_PROGRESS_INTERNAL) 166 if (state_ == IN_PROGRESS_INTERNAL)
166 state_ = CANCELLED_INTERNAL; 167 state_ = CANCELLED_INTERNAL;
167 if (state_ == COMPLETE_INTERNAL) 168 if (state_ == COMPLETE_INTERNAL)
168 all_data_saved_ = true; 169 all_data_saved_ = true;
169 Init(false /* not actively downloading */, 170 Init(false /* not actively downloading */,
170 download_net_logs::SRC_HISTORY_IMPORT); 171 download_net_logs::SRC_HISTORY_IMPORT);
171 } 172 }
172 173
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 file_externally_removed_(false), 208 file_externally_removed_(false),
208 safety_state_(SAFE), 209 safety_state_(SAFE),
209 auto_opened_(false), 210 auto_opened_(false),
210 is_persisted_(false), 211 is_persisted_(false),
211 is_temporary_(!info.save_info.file_path.empty()), 212 is_temporary_(!info.save_info.file_path.empty()),
212 all_data_saved_(false), 213 all_data_saved_(false),
213 opened_(false), 214 opened_(false),
214 open_enabled_(true), 215 open_enabled_(true),
215 delegate_delayed_complete_(false), 216 delegate_delayed_complete_(false),
216 bound_net_log_(bound_net_log), 217 bound_net_log_(bound_net_log),
218 is_hidden_download_(false),
217 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 219 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
218 delegate_->Attach(); 220 delegate_->Attach();
219 Init(true /* actively downloading */, 221 Init(true /* actively downloading */,
220 download_net_logs::SRC_NEW_DOWNLOAD); 222 download_net_logs::SRC_NEW_DOWNLOAD);
221 223
222 // Link the event sources. 224 // Link the event sources.
223 bound_net_log_.AddEvent( 225 bound_net_log_.AddEvent(
224 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, 226 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST,
225 info.request_bound_net_log.source().ToEventParametersCallback()); 227 info.request_bound_net_log.source().ToEventParametersCallback());
226 228
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 file_externally_removed_(false), 264 file_externally_removed_(false),
263 safety_state_(SAFE), 265 safety_state_(SAFE),
264 auto_opened_(false), 266 auto_opened_(false),
265 is_persisted_(false), 267 is_persisted_(false),
266 is_temporary_(false), 268 is_temporary_(false),
267 all_data_saved_(false), 269 all_data_saved_(false),
268 opened_(false), 270 opened_(false),
269 open_enabled_(true), 271 open_enabled_(true),
270 delegate_delayed_complete_(false), 272 delegate_delayed_complete_(false),
271 bound_net_log_(bound_net_log), 273 bound_net_log_(bound_net_log),
274 is_hidden_download_(false),
272 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 275 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
273 delegate_->Attach(); 276 delegate_->Attach();
274 Init(true /* actively downloading */, 277 Init(true /* actively downloading */,
275 download_net_logs::SRC_SAVE_PAGE_AS); 278 download_net_logs::SRC_SAVE_PAGE_AS);
276 } 279 }
277 280
278 DownloadItemImpl::~DownloadItemImpl() { 281 DownloadItemImpl::~DownloadItemImpl() {
279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
280 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadDestroyed(this)); 283 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadDestroyed(this));
281 delegate_->AssertStateConsistent(this); 284 delegate_->AssertStateConsistent(this);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 WebContents* DownloadItemImpl::GetWebContents() const { 705 WebContents* DownloadItemImpl::GetWebContents() const {
703 // TODO(rdsmith): Remove null check after removing GetWebContents() from 706 // TODO(rdsmith): Remove null check after removing GetWebContents() from
704 // paths that might be used by DownloadItems created from history import. 707 // paths that might be used by DownloadItems created from history import.
705 // Currently such items have null request_handle_s, where other items 708 // Currently such items have null request_handle_s, where other items
706 // (regular and SavePackage downloads) have actual objects off the pointer. 709 // (regular and SavePackage downloads) have actual objects off the pointer.
707 if (request_handle_.get()) 710 if (request_handle_.get())
708 return request_handle_->GetWebContents(); 711 return request_handle_->GetWebContents();
709 return NULL; 712 return NULL;
710 } 713 }
711 714
715 void DownloadItemImpl::SetIsHiddenDownload(bool is_hidden) {
716 is_hidden_download_ = is_hidden;
717 }
718
719 bool DownloadItemImpl::IsHiddenDownload() const {
720 return is_hidden_download_;
721 }
722
712 void DownloadItemImpl::OnContentCheckCompleted( 723 void DownloadItemImpl::OnContentCheckCompleted(
713 content::DownloadDangerType danger_type) { 724 content::DownloadDangerType danger_type) {
714 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
715 DCHECK(AllDataSaved()); 726 DCHECK(AllDataSaved());
716 SetDangerType(danger_type); 727 SetDangerType(danger_type);
717 UpdateObservers(); 728 UpdateObservers();
718 } 729 }
719 730
720 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 731 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
721 open_when_complete_ = open; 732 open_when_complete_ = open;
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 return "COMPLETE"; 1292 return "COMPLETE";
1282 case CANCELLED_INTERNAL: 1293 case CANCELLED_INTERNAL:
1283 return "CANCELLED"; 1294 return "CANCELLED";
1284 case INTERRUPTED_INTERNAL: 1295 case INTERRUPTED_INTERNAL:
1285 return "INTERRUPTED"; 1296 return "INTERRUPTED";
1286 default: 1297 default:
1287 NOTREACHED() << "Unknown download state " << state; 1298 NOTREACHED() << "Unknown download state " << state;
1288 return "unknown"; 1299 return "unknown";
1289 }; 1300 };
1290 } 1301 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698