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

Side by Side Diff: chrome/browser/download/download_shelf.h

Issue 12995025: [Mac] DownloadShelf should be notified when autoclosing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: + NSTrackingInVisibleRect Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
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 #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 // 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,
28
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
33 };
34
22 DownloadShelf(); 35 DownloadShelf();
23 virtual ~DownloadShelf(); 36 virtual ~DownloadShelf();
24 37
25 // A new download has started. Add it to our shelf and show the download 38 // A new download has started. Add it to our shelf and show the download
26 // started animation. 39 // started animation.
27 // 40 //
28 // Some downloads are removed from the shelf on completion (See 41 // Some downloads are removed from the shelf on completion (See
29 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient 42 // DownloadItemModel::ShouldRemoveFromShelfWhenComplete()). These transient
30 // downloads are added to the shelf after a delay. If the download completes 43 // 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. 44 // before the delay duration, it will not be added to the shelf at all.
32 void AddDownload(content::DownloadItem* download); 45 void AddDownload(content::DownloadItem* download);
33 46
34 // The browser view needs to know when we are going away to properly return 47 // 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. 48 // 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 49 // 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. 50 // the beginning Show and false at the beginning of a Hide.
38 virtual bool IsShowing() const = 0; 51 virtual bool IsShowing() const = 0;
39 52
40 // Returns whether the download shelf is showing the close animation. 53 // Returns whether the download shelf is showing the close animation.
41 virtual bool IsClosing() const = 0; 54 virtual bool IsClosing() const = 0;
42 55
43 // Opens the shelf. 56 // Opens the shelf.
44 void Show(); 57 void Show();
45 58
46 // Closes the shelf. 59 // Closes the shelf.
47 void Close(); 60 void Close(CloseReason reason);
48 61
49 // Hides the shelf. This closes the shelf if it is currently showing. 62 // Hides the shelf. This closes the shelf if it is currently showing.
50 void Hide(); 63 void Hide();
51 64
52 // Unhides the shelf. This will cause the shelf to be opened if it was open 65 // 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. 66 // when it was hidden, or was shown while it was hidden.
54 void Unhide(); 67 void Unhide();
55 68
56 virtual Browser* browser() const = 0; 69 virtual Browser* browser() const = 0;
57 70
58 // Returns whether the download shelf is hidden. 71 // Returns whether the download shelf is hidden.
59 bool is_hidden() { return is_hidden_; } 72 bool is_hidden() { return is_hidden_; }
60 73
61 protected: 74 protected:
62 virtual void DoAddDownload(content::DownloadItem* download) = 0; 75 virtual void DoAddDownload(content::DownloadItem* download) = 0;
63 virtual void DoShow() = 0; 76 virtual void DoShow() = 0;
64 virtual void DoClose() = 0; 77 virtual void DoClose(CloseReason reason) = 0;
65 78
66 // Time delay to wait before adding a transient download to the shelf. 79 // Time delay to wait before adding a transient download to the shelf.
67 // Protected virtual for testing. 80 // Protected virtual for testing.
68 virtual base::TimeDelta GetTransientDownloadShowDelay(); 81 virtual base::TimeDelta GetTransientDownloadShowDelay();
69 82
70 // Returns the DownloadManager associated with this DownloadShelf. All 83 // Returns the DownloadManager associated with this DownloadShelf. All
71 // downloads that are shown on this shelf is expected to belong to this 84 // downloads that are shown on this shelf is expected to belong to this
72 // DownloadManager. Protected virtual for testing. 85 // DownloadManager. Protected virtual for testing.
73 virtual content::DownloadManager* GetDownloadManager(); 86 virtual content::DownloadManager* GetDownloadManager();
74 87
75 private: 88 private:
76 // Show the download on the shelf immediately. Also displayes the download 89 // Show the download on the shelf immediately. Also displayes the download
77 // started animation if necessary. 90 // started animation if necessary.
78 void ShowDownload(content::DownloadItem* download); 91 void ShowDownload(content::DownloadItem* download);
79 92
80 // Similar to ShowDownload() but refers to the download using an ID. This 93 // Similar to ShowDownload() but refers to the download using an ID. This
81 // download should belong to the DownloadManager returned by 94 // download should belong to the DownloadManager returned by
82 // GetDownloadManager(). 95 // GetDownloadManager().
83 void ShowDownloadById(int32 download_id); 96 void ShowDownloadById(int32 download_id);
84 97
85 bool should_show_on_unhide_; 98 bool should_show_on_unhide_;
86 bool is_hidden_; 99 bool is_hidden_;
87 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_; 100 base::WeakPtrFactory<DownloadShelf> weak_ptr_factory_;
88 }; 101 };
89 102
90 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_ 103 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_SHELF_H_
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/download/download_shelf.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698