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

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: Added browser and unit tests. Renamed 'UserActed' to 'OpenedOrShown'. Created 4 years, 1 month 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (state_ != COMPLETE_INTERNAL || file_externally_removed_) 423 if (state_ != COMPLETE_INTERNAL || file_externally_removed_)
424 return; 424 return;
425 425
426 // Ideally, we want to detect errors in opening and report them, but we 426 // Ideally, we want to detect errors in opening and report them, but we
427 // don't generally have the proper interface for that to the external 427 // don't generally have the proper interface for that to the external
428 // program that opens the file. So instead we spawn a check to update 428 // program that opens the file. So instead we spawn a check to update
429 // the UI if the file has been deleted in parallel with the open. 429 // the UI if the file has been deleted in parallel with the open.
430 delegate_->CheckForFileRemoval(this); 430 delegate_->CheckForFileRemoval(this);
431 RecordOpen(GetEndTime(), !GetOpened()); 431 RecordOpen(GetEndTime(), !GetOpened());
432 opened_ = true; 432 opened_ = true;
433 delegate_->OpenDownload(this);
433 for (auto& observer : observers_) 434 for (auto& observer : observers_)
434 observer.OnDownloadOpened(this); 435 observer.OnDownloadOpened(this);
435 delegate_->OpenDownload(this);
436 } 436 }
437 437
438 void DownloadItemImpl::ShowDownloadInShell() { 438 void DownloadItemImpl::ShowDownloadInShell() {
439 DCHECK_CURRENTLY_ON(BrowserThread::UI); 439 DCHECK_CURRENTLY_ON(BrowserThread::UI);
440 440
441 delegate_->ShowDownloadInShell(this); 441 delegate_->ShowDownloadInShell(this);
442 for (auto& observer : observers_)
443 observer.OnDownloadShown(this);
442 } 444 }
443 445
444 uint32_t DownloadItemImpl::GetId() const { 446 uint32_t DownloadItemImpl::GetId() const {
445 return download_id_; 447 return download_id_;
446 } 448 }
447 449
448 const std::string& DownloadItemImpl::GetGuid() const { 450 const std::string& DownloadItemImpl::GetGuid() const {
449 return guid_; 451 return guid_;
450 } 452 }
451 453
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 DVLOG(20) << __func__ << "() danger_type=" << danger_type 768 DVLOG(20) << __func__ << "() danger_type=" << danger_type
767 << " download=" << DebugString(true); 769 << " download=" << DebugString(true);
768 SetDangerType(danger_type); 770 SetDangerType(danger_type);
769 UpdateObservers(); 771 UpdateObservers();
770 } 772 }
771 773
772 void DownloadItemImpl::SetOpenWhenComplete(bool open) { 774 void DownloadItemImpl::SetOpenWhenComplete(bool open) {
773 open_when_complete_ = open; 775 open_when_complete_ = open;
774 } 776 }
775 777
776 void DownloadItemImpl::SetOpened(bool opened) {
777 opened_ = opened;
778 }
779
780 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) { 778 void DownloadItemImpl::SetDisplayName(const base::FilePath& name) {
781 display_name_ = name; 779 display_name_ = name;
782 } 780 }
783 781
784 std::string DownloadItemImpl::DebugString(bool verbose) const { 782 std::string DownloadItemImpl::DebugString(bool verbose) const {
785 std::string description = 783 std::string description =
786 base::StringPrintf("{ id = %d" 784 base::StringPrintf("{ id = %d"
787 " state = %s", 785 " state = %s",
788 download_id_, 786 download_id_,
789 DebugDownloadStateString(state_)); 787 DebugDownloadStateString(state_));
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 case RESUME_MODE_USER_CONTINUE: 2091 case RESUME_MODE_USER_CONTINUE:
2094 return "USER_CONTINUE"; 2092 return "USER_CONTINUE";
2095 case RESUME_MODE_USER_RESTART: 2093 case RESUME_MODE_USER_RESTART:
2096 return "USER_RESTART"; 2094 return "USER_RESTART";
2097 } 2095 }
2098 NOTREACHED() << "Unknown resume mode " << mode; 2096 NOTREACHED() << "Unknown resume mode " << mode;
2099 return "unknown"; 2097 return "unknown";
2100 } 2098 }
2101 2099
2102 } // namespace content 2100 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_item_impl.h ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698