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

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

Issue 209613002: Download shelf autohides on showing in shell, just same as regular open Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implement a separate callbacks flow for 'shown in shell' event to not mix with 'opened' Created 6 years, 7 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
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 as 5 // File method ordering: Methods in this file are in the same order as
6 // in download_item_impl.h, with the following exception: The public 6 // in download_item_impl.h, with the following exception: The public
7 // interface Start is placed in chronological order with the other 7 // interface Start is placed in chronological order with the other
8 // (private) routines that together define a DownloadItem's state 8 // (private) routines that together define a DownloadItem's state
9 // transitions as the download progresses. See "Download progression 9 // transitions as the download progresses. See "Download progression
10 // cascade" later in this file. 10 // cascade" later in this file.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 delegate_(delegate), 147 delegate_(delegate),
148 is_paused_(false), 148 is_paused_(false),
149 auto_resume_count_(0), 149 auto_resume_count_(0),
150 open_when_complete_(false), 150 open_when_complete_(false),
151 file_externally_removed_(false), 151 file_externally_removed_(false),
152 auto_opened_(false), 152 auto_opened_(false),
153 is_temporary_(false), 153 is_temporary_(false),
154 all_data_saved_(state == COMPLETE), 154 all_data_saved_(state == COMPLETE),
155 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 155 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
156 opened_(opened), 156 opened_(opened),
157 shownWhenComplete_(false),
asanka 2014/05/14 18:40:59 Nit: Use hacker_style_.
DukeXar 2014/06/06 15:07:13 Removed
157 delegate_delayed_complete_(false), 158 delegate_delayed_complete_(false),
158 bound_net_log_(bound_net_log), 159 bound_net_log_(bound_net_log),
159 weak_ptr_factory_(this) { 160 weak_ptr_factory_(this) {
160 delegate_->Attach(); 161 delegate_->Attach();
161 DCHECK_NE(IN_PROGRESS_INTERNAL, state_); 162 DCHECK_NE(IN_PROGRESS_INTERNAL, state_);
162 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT); 163 Init(false /* not actively downloading */, SRC_HISTORY_IMPORT);
163 } 164 }
164 165
165 // Constructing for a regular download: 166 // Constructing for a regular download:
166 DownloadItemImpl::DownloadItemImpl( 167 DownloadItemImpl::DownloadItemImpl(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 delegate_(delegate), 199 delegate_(delegate),
199 is_paused_(false), 200 is_paused_(false),
200 auto_resume_count_(0), 201 auto_resume_count_(0),
201 open_when_complete_(false), 202 open_when_complete_(false),
202 file_externally_removed_(false), 203 file_externally_removed_(false),
203 auto_opened_(false), 204 auto_opened_(false),
204 is_temporary_(!info.save_info->file_path.empty()), 205 is_temporary_(!info.save_info->file_path.empty()),
205 all_data_saved_(false), 206 all_data_saved_(false),
206 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 207 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
207 opened_(false), 208 opened_(false),
209 shownWhenComplete_(false),
208 delegate_delayed_complete_(false), 210 delegate_delayed_complete_(false),
209 bound_net_log_(bound_net_log), 211 bound_net_log_(bound_net_log),
210 weak_ptr_factory_(this) { 212 weak_ptr_factory_(this) {
211 delegate_->Attach(); 213 delegate_->Attach();
212 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD); 214 Init(true /* actively downloading */, SRC_ACTIVE_DOWNLOAD);
213 215
214 // Link the event sources. 216 // Link the event sources.
215 bound_net_log_.AddEvent( 217 bound_net_log_.AddEvent(
216 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST, 218 net::NetLog::TYPE_DOWNLOAD_URL_REQUEST,
217 info.request_bound_net_log.source().ToEventParametersCallback()); 219 info.request_bound_net_log.source().ToEventParametersCallback());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 delegate_(delegate), 255 delegate_(delegate),
254 is_paused_(false), 256 is_paused_(false),
255 auto_resume_count_(0), 257 auto_resume_count_(0),
256 open_when_complete_(false), 258 open_when_complete_(false),
257 file_externally_removed_(false), 259 file_externally_removed_(false),
258 auto_opened_(false), 260 auto_opened_(false),
259 is_temporary_(false), 261 is_temporary_(false),
260 all_data_saved_(false), 262 all_data_saved_(false),
261 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE), 263 destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
262 opened_(false), 264 opened_(false),
265 shownWhenComplete_(false),
263 delegate_delayed_complete_(false), 266 delegate_delayed_complete_(false),
264 bound_net_log_(bound_net_log), 267 bound_net_log_(bound_net_log),
265 weak_ptr_factory_(this) { 268 weak_ptr_factory_(this) {
266 delegate_->Attach(); 269 delegate_->Attach();
267 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS); 270 Init(true /* actively downloading */, SRC_SAVE_PAGE_AS);
268 } 271 }
269 272
270 DownloadItemImpl::~DownloadItemImpl() { 273 DownloadItemImpl::~DownloadItemImpl() {
271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
272 275
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 delegate_->CheckForFileRemoval(this); 466 delegate_->CheckForFileRemoval(this);
464 RecordOpen(GetEndTime(), !GetOpened()); 467 RecordOpen(GetEndTime(), !GetOpened());
465 opened_ = true; 468 opened_ = true;
466 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this)); 469 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadOpened(this));
467 delegate_->OpenDownload(this); 470 delegate_->OpenDownload(this);
468 } 471 }
469 472
470 void DownloadItemImpl::ShowDownloadInShell() { 473 void DownloadItemImpl::ShowDownloadInShell() {
471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 474 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
472 475
476 if (!CanShowInFolder())
477 return;
478
479 // Marking the download as shown if it is complete and user opened it
480 // in shell
481 if (state_ == COMPLETE_INTERNAL)
482 shownWhenComplete_ = true;
483
484 delegate_->CheckForFileRemoval(this);
485 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadShown(this));
473 delegate_->ShowDownloadInShell(this); 486 delegate_->ShowDownloadInShell(this);
474 } 487 }
475 488
476 uint32 DownloadItemImpl::GetId() const { 489 uint32 DownloadItemImpl::GetId() const {
477 return download_id_; 490 return download_id_;
478 } 491 }
479 492
480 DownloadItem::DownloadState DownloadItemImpl::GetState() const { 493 DownloadItem::DownloadState DownloadItemImpl::GetState() const {
481 return InternalToExternalState(state_); 494 return InternalToExternalState(state_);
482 } 495 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 } 766 }
754 767
755 bool DownloadItemImpl::GetAutoOpened() { 768 bool DownloadItemImpl::GetAutoOpened() {
756 return auto_opened_; 769 return auto_opened_;
757 } 770 }
758 771
759 bool DownloadItemImpl::GetOpened() const { 772 bool DownloadItemImpl::GetOpened() const {
760 return opened_; 773 return opened_;
761 } 774 }
762 775
776 bool DownloadItemImpl::GetShownWhenComplete() const {
777 return shownWhenComplete_;
778 }
779
763 BrowserContext* DownloadItemImpl::GetBrowserContext() const { 780 BrowserContext* DownloadItemImpl::GetBrowserContext() const {
764 return delegate_->GetBrowserContext(); 781 return delegate_->GetBrowserContext();
765 } 782 }
766 783
767 WebContents* DownloadItemImpl::GetWebContents() const { 784 WebContents* DownloadItemImpl::GetWebContents() const {
768 // TODO(rdsmith): Remove null check after removing GetWebContents() from 785 // TODO(rdsmith): Remove null check after removing GetWebContents() from
769 // paths that might be used by DownloadItems created from history import. 786 // paths that might be used by DownloadItems created from history import.
770 // Currently such items have null request_handle_s, where other items 787 // Currently such items have null request_handle_s, where other items
771 // (regular and SavePackage downloads) have actual objects off the pointer. 788 // (regular and SavePackage downloads) have actual objects off the pointer.
772 if (request_handle_) 789 if (request_handle_)
(...skipping 15 matching lines...) Expand all
788 } 805 }
789 806
790 void DownloadItemImpl::SetIsTemporary(bool temporary) { 807 void DownloadItemImpl::SetIsTemporary(bool temporary) {
791 is_temporary_ = temporary; 808 is_temporary_ = temporary;
792 } 809 }
793 810
794 void DownloadItemImpl::SetOpened(bool opened) { 811 void DownloadItemImpl::SetOpened(bool opened) {
795 opened_ = opened; 812 opened_ = opened;
796 } 813 }
797 814
815 void DownloadItemImpl::SetShownWhenComplete(bool shown) {
816 shownWhenComplete_ = shown;
817 }
818
798 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { 819 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) {
799 display_name_ = name; 820 display_name_ = name;
800 } 821 }
801 822
802 std::string DownloadItemImpl::DebugString(bool verbose) const { 823 std::string DownloadItemImpl::DebugString(bool verbose) const {
803 std::string description = 824 std::string description =
804 base::StringPrintf("{ id = %d" 825 base::StringPrintf("{ id = %d"
805 " state = %s", 826 " state = %s",
806 download_id_, 827 download_id_,
807 DebugDownloadStateString(state_)); 828 DebugDownloadStateString(state_));
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 case RESUME_MODE_USER_CONTINUE: 1817 case RESUME_MODE_USER_CONTINUE:
1797 return "USER_CONTINUE"; 1818 return "USER_CONTINUE";
1798 case RESUME_MODE_USER_RESTART: 1819 case RESUME_MODE_USER_RESTART:
1799 return "USER_RESTART"; 1820 return "USER_RESTART";
1800 } 1821 }
1801 NOTREACHED() << "Unknown resume mode " << mode; 1822 NOTREACHED() << "Unknown resume mode " << mode;
1802 return "unknown"; 1823 return "unknown";
1803 } 1824 }
1804 1825
1805 } // namespace content 1826 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698