Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ |
| 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 class DownloadItem; | 12 class DownloadItem; |
| 13 class DownloadManager; | 13 class DownloadManager; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class Browser; | 16 class Browser; |
| 17 | 17 |
| 18 // This is an abstract base class for platform specific download shelf | 18 // This is an abstract base class for platform specific download shelf |
| 19 // implementations. | 19 // implementations. |
| 20 class DownloadShelf { | 20 class DownloadShelf { |
| 21 public: | 21 public: |
| 22 enum CloseReason { | |
| 23 AUTOMATIC, | |
|
Nico
2013/03/22 20:24:11
Maybe you can add a comment that explains when AUT
asanka
2013/03/22 21:22:13
Done.
| |
| 24 USER_ACTION | |
| 25 }; | |
| 26 | |
| 22 DownloadShelf(); | 27 DownloadShelf(); |
| 23 virtual ~DownloadShelf(); | 28 virtual ~DownloadShelf(); |
| 24 | 29 |
| 25 // A new download has started. Add it to our shelf and show the download | 30 // A new download has started. Add it to our shelf and show the download |
| 26 // started animation. | 31 // started animation. |
| 27 // | 32 // |
| 28 // Some downloads are removed from the shelf on completion (See | 33 // Some downloads are removed from the shelf on completion (See |
| 29 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient | 34 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient |
| 30 // downloads are added to the shelf after a delay. If the download completes | 35 // downloads are added to the shelf after a delay. If the download completes |
| 31 // before the delay duration, it will not be added to the shelf at all. | 36 // before the delay duration, it will not be added to the shelf at all. |
| 32 void AddDownload(content::DownloadItem* download); | 37 void AddDownload(content::DownloadItem* download); |
| 33 | 38 |
| 34 // The browser view needs to know when we are going away to properly return | 39 // The browser view needs to know when we are going away to properly return |
| 35 // the resize corner size to WebKit so that we don't draw on top of it. | 40 // the resize corner size to WebKit so that we don't draw on top of it. |
| 36 // This returns the showing state of our animation which is set to true at | 41 // This returns the showing state of our animation which is set to true at |
| 37 // the beginning Show and false at the beginning of a Hide. | 42 // the beginning Show and false at the beginning of a Hide. |
| 38 virtual bool IsShowing() const = 0; | 43 virtual bool IsShowing() const = 0; |
| 39 | 44 |
| 40 // Returns whether the download shelf is showing the close animation. | 45 // Returns whether the download shelf is showing the close animation. |
| 41 virtual bool IsClosing() const = 0; | 46 virtual bool IsClosing() const = 0; |
| 42 | 47 |
| 43 // Opens the shelf. | 48 // Opens the shelf. |
| 44 void Show(); | 49 void Show(); |
| 45 | 50 |
| 46 // Closes the shelf. | 51 // Closes the shelf. |
| 47 void Close(); | 52 void Close(CloseReason reason); |
| 48 | 53 |
| 49 // Hides the shelf. This closes the shelf if it is currently showing. | 54 // Hides the shelf. This closes the shelf if it is currently showing. |
| 50 void Hide(); | 55 void Hide(); |
| 51 | 56 |
| 52 // Unhides the shelf. This will cause the shelf to be opened if it was open | 57 // Unhides the shelf. This will cause the shelf to be opened if it was open |
| 53 // when it was hidden, or was shown while it was hidden. | 58 // when it was hidden, or was shown while it was hidden. |
| 54 void Unhide(); | 59 void Unhide(); |
| 55 | 60 |
| 56 virtual Browser* browser() const = 0; | 61 virtual Browser* browser() const = 0; |
| 57 | 62 |
| 58 // Returns whether the download shelf is hidden. | 63 // Returns whether the download shelf is hidden. |
| 59 bool is_hidden() { return is_hidden_; } | 64 bool is_hidden() { return is_hidden_; } |
| 60 | 65 |
| 61 protected: | 66 protected: |
| 62 virtual void DoAddDownload(content::DownloadItem* download) = 0; | 67 virtual void DoAddDownload(content::DownloadItem* download) = 0; |
| 63 virtual void DoShow() = 0; | 68 virtual void DoShow() = 0; |
| 64 virtual void DoClose() = 0; | 69 virtual void DoClose(CloseReason reason) = 0; |
| 65 | 70 |
| 66 // Time delay to wait before adding a transient download to the shelf. | 71 // Time delay to wait before adding a transient download to the shelf. |
| 67 // Protected virtual for testing. | 72 // Protected virtual for testing. |
| 68 virtual base::TimeDelta GetTransientDownloadShowDelay(); | 73 virtual base::TimeDelta GetTransientDownloadShowDelay(); |
| 69 | 74 |
| 70 // Returns the DownloadManager associated with this DownloadShelf. All | 75 // Returns the DownloadManager associated with this DownloadShelf. All |
| 71 // downloads that are shown on this shelf is expected to belong to this | 76 // downloads that are shown on this shelf is expected to belong to this |
| 72 // DownloadManager. Protected virtual for testing. | 77 // DownloadManager. Protected virtual for testing. |
| 73 virtual content::DownloadManager* GetDownloadManager(); | 78 virtual content::DownloadManager* GetDownloadManager(); |
| 74 | 79 |
| 75 private: | 80 private: |
| 76 // Show the download on the shelf immediately. Also displayes the download | 81 // Show the download on the shelf immediately. Also displayes the download |
| 77 // started animation if necessary. | 82 // started animation if necessary. |
| 78 void ShowDownload(content::DownloadItem* download); | 83 void ShowDownload(content::DownloadItem* download); |
| 79 | 84 |
| 80 // Similar to ShowDownload() but refers to the download using an ID. This | 85 // Similar to ShowDownload() but refers to the download using an ID. This |
| 81 // download should belong to the DownloadManager returned by | 86 // download should belong to the DownloadManager returned by |
| 82 // GetDownloadManager(). | 87 // GetDownloadManager(). |
| 83 void ShowDownloadById(int32 download_id); | 88 void ShowDownloadById(int32 download_id); |
| 84 | 89 |
| 85 bool should_show_on_unhide_; | 90 bool should_show_on_unhide_; |
| 86 bool is_hidden_; | 91 bool is_hidden_; |
| 87 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; | 92 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; |
| 88 }; | 93 }; |
| 89 | 94 |
| 90 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ | 95 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ |
| OLD | NEW |