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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/download/download_item_impl.cc
diff --git a/content/browser/download/download_item_impl.cc b/content/browser/download/download_item_impl.cc
index 0fbd270da05ce3e4bd8dc147d627c55afa3e127d..3bf4648ce85284fb71bafaa3d98fcb4d705b2254 100644
--- a/content/browser/download/download_item_impl.cc
+++ b/content/browser/download/download_item_impl.cc
@@ -154,6 +154,7 @@ DownloadItemImpl::DownloadItemImpl(DownloadItemImplDelegate* delegate,
all_data_saved_(state == COMPLETE),
destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
opened_(opened),
+ shownWhenComplete_(false),
asanka 2014/05/14 18:40:59 Nit: Use hacker_style_.
DukeXar 2014/06/06 15:07:13 Removed
delegate_delayed_complete_(false),
bound_net_log_(bound_net_log),
weak_ptr_factory_(this) {
@@ -205,6 +206,7 @@ DownloadItemImpl::DownloadItemImpl(
all_data_saved_(false),
destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
opened_(false),
+ shownWhenComplete_(false),
delegate_delayed_complete_(false),
bound_net_log_(bound_net_log),
weak_ptr_factory_(this) {
@@ -260,6 +262,7 @@ DownloadItemImpl::DownloadItemImpl(
all_data_saved_(false),
destination_error_(content::DOWNLOAD_INTERRUPT_REASON_NONE),
opened_(false),
+ shownWhenComplete_(false),
delegate_delayed_complete_(false),
bound_net_log_(bound_net_log),
weak_ptr_factory_(this) {
@@ -470,6 +473,16 @@ void DownloadItemImpl::OpenDownload() {
void DownloadItemImpl::ShowDownloadInShell() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!CanShowInFolder())
+ return;
+
+ // Marking the download as shown if it is complete and user opened it
+ // in shell
+ if (state_ == COMPLETE_INTERNAL)
+ shownWhenComplete_ = true;
+
+ delegate_->CheckForFileRemoval(this);
+ FOR_EACH_OBSERVER(Observer, observers_, OnDownloadShown(this));
delegate_->ShowDownloadInShell(this);
}
@@ -760,6 +773,10 @@ bool DownloadItemImpl::GetOpened() const {
return opened_;
}
+bool DownloadItemImpl::GetShownWhenComplete() const {
+ return shownWhenComplete_;
+}
+
BrowserContext* DownloadItemImpl::GetBrowserContext() const {
return delegate_->GetBrowserContext();
}
@@ -795,6 +812,10 @@ void DownloadItemImpl::SetOpened(bool opened) {
opened_ = opened;
}
+void DownloadItemImpl::SetShownWhenComplete(bool shown) {
+ shownWhenComplete_ = shown;
+}
+
void DownloadItemImpl::SetDisplayName(const base::FilePath& name) {
display_name_ = name;
}

Powered by Google App Engine
This is Rietveld 408576698