| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_VIEWS_DOWNLOAD_SHELF_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ |
| 7 | 7 |
| 8 #include "app/slide_animation.h" | 8 #include "app/slide_animation.h" |
| 9 #include "chrome/browser/download/download_shelf.h" | 9 #include "chrome/browser/download/download_shelf.h" |
| 10 #include "views/controls/button/button.h" | 10 #include "views/controls/button/button.h" |
| 11 #include "views/controls/link.h" | 11 #include "views/controls/link.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 class ImageButton; | 14 class ImageButton; |
| 15 class ImageView; | 15 class ImageView; |
| 16 } | 16 } |
| 17 | 17 |
| 18 class BaseDownloadItemModel; | 18 class BaseDownloadItemModel; |
| 19 class TabContents; | 19 class Browser; |
| 20 class BrowserView; |
| 20 | 21 |
| 21 class DownloadAnimation; | 22 class DownloadAnimation; |
| 22 | 23 |
| 23 // DownloadShelfView is a view that contains individual views for each download, | 24 // DownloadShelfView is a view that contains individual views for each download, |
| 24 // as well as a close button and a link to show all downloads. | 25 // as well as a close button and a link to show all downloads. |
| 25 // | 26 // |
| 26 // To add a view representing a download to DownloadShelfView, invoke | 27 // To add a view representing a download to DownloadShelfView, invoke |
| 27 // AddDownloadView. AddDownloadView takes ownership of the passed in View. | 28 // AddDownloadView. AddDownloadView takes ownership of the passed in View. |
| 28 // DownloadShelfView does not hold an infinite number of download views, rather | 29 // DownloadShelfView does not hold an infinite number of download views, rather |
| 29 // it'll automatically remove views once a certain point is reached. | 30 // it'll automatically remove views once a certain point is reached. |
| 30 class DownloadShelfView : public DownloadShelf, | 31 class DownloadShelfView : public DownloadShelf, |
| 31 public views::View, | 32 public views::View, |
| 32 public views::ButtonListener, | 33 public views::ButtonListener, |
| 33 public views::LinkController, | 34 public views::LinkController, |
| 34 public AnimationDelegate { | 35 public AnimationDelegate { |
| 35 public: | 36 public: |
| 36 explicit DownloadShelfView(TabContents* tab_contents); | 37 explicit DownloadShelfView(Browser* browser, BrowserView* parent); |
| 37 | 38 |
| 38 // Implementation of View. | 39 // Implementation of View. |
| 39 virtual gfx::Size GetPreferredSize(); | 40 virtual gfx::Size GetPreferredSize(); |
| 40 virtual void Layout(); | 41 virtual void Layout(); |
| 41 virtual void Paint(gfx::Canvas* canvas); | 42 virtual void Paint(gfx::Canvas* canvas); |
| 42 | 43 |
| 43 // Implementation of AnimationDelegate. | 44 // Implementation of AnimationDelegate. |
| 44 virtual void AnimationProgressed(const Animation* animation); | 45 virtual void AnimationProgressed(const Animation* animation); |
| 45 virtual void AnimationEnded(const Animation* animation); | 46 virtual void AnimationEnded(const Animation* animation); |
| 46 | 47 |
| 47 // Implementation of LinkController. | 48 // Implementation of LinkController. |
| 48 // Invoked when the user clicks the 'show all downloads' link button. | 49 // Invoked when the user clicks the 'show all downloads' link button. |
| 49 virtual void LinkActivated(views::Link* source, int event_flags); | 50 virtual void LinkActivated(views::Link* source, int event_flags); |
| 50 | 51 |
| 51 // Implementation of ButtonListener. | 52 // Implementation of ButtonListener. |
| 52 // Invoked when the user clicks the close button. Asks the browser to | 53 // Invoked when the user clicks the close button. Asks the browser to |
| 53 // hide the download shelf. | 54 // hide the download shelf. |
| 54 virtual void ButtonPressed(views::Button* button); | 55 virtual void ButtonPressed(views::Button* button); |
| 55 | 56 |
| 56 // Implementation of DownloadShelf. | 57 // Implementation of DownloadShelf. |
| 57 virtual void AddDownload(BaseDownloadItemModel* download_model); | 58 virtual void AddDownload(BaseDownloadItemModel* download_model); |
| 58 virtual bool IsShowing() const; | 59 virtual bool IsShowing() const; |
| 59 virtual bool IsClosing() const; | 60 virtual bool IsClosing() const; |
| 61 virtual void Show(); |
| 62 virtual void Close(); |
| 60 | 63 |
| 61 // Removes a specified download view. The supplied view is deleted after | 64 // Removes a specified download view. The supplied view is deleted after |
| 62 // it's removed. | 65 // it's removed. |
| 63 void RemoveDownloadView(views::View* view); | 66 void RemoveDownloadView(views::View* view); |
| 64 | 67 |
| 65 private: | 68 private: |
| 66 void Init(); | 69 void Init(); |
| 67 | 70 |
| 68 // Adds a View representing a download to this DownloadShelfView. | 71 // Adds a View representing a download to this DownloadShelfView. |
| 69 // DownloadShelfView takes ownership of the View, and will delete it as | 72 // DownloadShelfView takes ownership of the View, and will delete it as |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 views::ImageView* arrow_image_; | 93 views::ImageView* arrow_image_; |
| 91 | 94 |
| 92 // Link for showing all downloads. This is contained as a child, and deleted | 95 // Link for showing all downloads. This is contained as a child, and deleted |
| 93 // by View. | 96 // by View. |
| 94 views::Link* show_all_view_; | 97 views::Link* show_all_view_; |
| 95 | 98 |
| 96 // Button for closing the downloads. This is contained as a child, and | 99 // Button for closing the downloads. This is contained as a child, and |
| 97 // deleted by View. | 100 // deleted by View. |
| 98 views::ImageButton* close_button_; | 101 views::ImageButton* close_button_; |
| 99 | 102 |
| 103 // The window this shelf belongs to. |
| 104 BrowserView* parent_; |
| 105 |
| 100 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); | 106 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); |
| 101 }; | 107 }; |
| 102 | 108 |
| 103 #endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ | 109 #endif // CHROME_BROWSER_VIEWS_DOWNLOAD_SHELF_VIEW_H_ |
| OLD | NEW |