Override server-side simple-cache trial with commandline switches.
[chromium-blink-merge.git] / chrome / browser / download / download_shelf.h
blob9498a86be3b1b60871ab752722bf6b0872ff3407
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"
9 #include "base/time.h"
11 namespace content {
12 class DownloadItem;
13 class DownloadManager;
16 class Browser;
18 // This is an abstract base class for platform specific download shelf
19 // implementations.
20 class DownloadShelf {
21 public:
22 // Reason for closing download shelf.
23 enum CloseReason {
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.
27 AUTOMATIC,
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.
32 USER_ACTION
35 DownloadShelf();
36 virtual ~DownloadShelf();
38 // A new download has started. Add it to our shelf and show the download
39 // started animation.
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;
56 // Opens the shelf.
57 void Show();
59 // Closes the shelf.
60 void Close(CloseReason reason);
62 // Hides the shelf. This closes the shelf if it is currently showing.
63 void Hide();
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.
67 void Unhide();
69 virtual Browser* browser() const = 0;
71 // Returns whether the download shelf is hidden.
72 bool is_hidden() { return is_hidden_; }
74 protected:
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();
88 private:
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_;
99 bool is_hidden_;
100 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_;
103 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_