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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
8 #include "base/memory/weak_ptr.h"
13 class DownloadManager
;
18 // This is an abstract base class for platform specific download shelf
22 // Reason for closing download shelf.
24 // Closing the shelf automatically. E.g.: all remaining downloads in the
25 // shelf have been opened, last download in shelf was removed, or the
26 // browser is switching to full-screen mode.
29 // Closing shelf due to a user selection. E.g.: the user clicked on the
30 // 'close' button on the download shelf, or the shelf is being closed as a
31 // side-effect of the user opening the downloads page.
36 virtual ~DownloadShelf();
38 // A new download has started. Add it to our shelf and show the download
41 // Some downloads are removed from the shelf on completion (See
42 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient
43 // downloads are added to the shelf after a delay. If the download completes
44 // before the delay duration, it will not be added to the shelf at all.
45 void AddDownload(content::DownloadItem
* download
);
47 // The browser view needs to know when we are going away to properly return
48 // the resize corner size to WebKit so that we don't draw on top of it.
49 // This returns the showing state of our animation which is set to true at
50 // the beginning Show and false at the beginning of a Hide.
51 virtual bool IsShowing() const = 0;
53 // Returns whether the download shelf is showing the close animation.
54 virtual bool IsClosing() const = 0;
60 void Close(CloseReason reason
);
62 // Hides the shelf. This closes the shelf if it is currently showing.
65 // Unhides the shelf. This will cause the shelf to be opened if it was open
66 // when it was hidden, or was shown while it was hidden.
69 virtual Browser
* browser() const = 0;
71 // Returns whether the download shelf is hidden.
72 bool is_hidden() { return is_hidden_
; }
75 virtual void DoAddDownload(content::DownloadItem
* download
) = 0;
76 virtual void DoShow() = 0;
77 virtual void DoClose(CloseReason reason
) = 0;
79 // Time delay to wait before adding a transient download to the shelf.
80 // Protected virtual for testing.
81 virtual base::TimeDelta
GetTransientDownloadShowDelay();
83 // Returns the DownloadManager associated with this DownloadShelf. All
84 // downloads that are shown on this shelf is expected to belong to this
85 // DownloadManager. Protected virtual for testing.
86 virtual content::DownloadManager
* GetDownloadManager();
89 // Show the download on the shelf immediately. Also displayes the download
90 // started animation if necessary.
91 void ShowDownload(content::DownloadItem
* download
);
93 // Similar to ShowDownload() but refers to the download using an ID. This
94 // download should belong to the DownloadManager returned by
95 // GetDownloadManager().
96 void ShowDownloadById(int32 download_id
);
98 bool should_show_on_unhide_
;
100 base::WeakPtrFactory
<DownloadShelf
> weak_ptr_factory_
;
103 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_