| 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_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // DownloadShelfView does not hold an infinite number of download views, rather | 40 // DownloadShelfView does not hold an infinite number of download views, rather |
| 41 // it'll automatically remove views once a certain point is reached. | 41 // it'll automatically remove views once a certain point is reached. |
| 42 class DownloadShelfView : public views::AccessiblePaneView, | 42 class DownloadShelfView : public views::AccessiblePaneView, |
| 43 public gfx::AnimationDelegate, | 43 public gfx::AnimationDelegate, |
| 44 public DownloadShelf, | 44 public DownloadShelf, |
| 45 public views::ButtonListener, | 45 public views::ButtonListener, |
| 46 public views::LinkListener, | 46 public views::LinkListener, |
| 47 public views::MouseWatcherListener { | 47 public views::MouseWatcherListener { |
| 48 public: | 48 public: |
| 49 DownloadShelfView(Browser* browser, BrowserView* parent); | 49 DownloadShelfView(Browser* browser, BrowserView* parent); |
| 50 virtual ~DownloadShelfView(); | 50 ~DownloadShelfView() override; |
| 51 | 51 |
| 52 // Sent from the DownloadItemView when the user opens an item. | 52 // Sent from the DownloadItemView when the user opens an item. |
| 53 void OpenedDownload(DownloadItemView* view); | 53 void OpenedDownload(DownloadItemView* view); |
| 54 | 54 |
| 55 // Returns the relevant containing object that can load pages. | 55 // Returns the relevant containing object that can load pages. |
| 56 // i.e. the |browser_|. | 56 // i.e. the |browser_|. |
| 57 content::PageNavigator* GetNavigator(); | 57 content::PageNavigator* GetNavigator(); |
| 58 | 58 |
| 59 // Returns the parent_. | 59 // Returns the parent_. |
| 60 BrowserView* get_parent() { return parent_; } | 60 BrowserView* get_parent() { return parent_; } |
| 61 | 61 |
| 62 // Implementation of View. | 62 // Implementation of View. |
| 63 virtual gfx::Size GetPreferredSize() const override; | 63 gfx::Size GetPreferredSize() const override; |
| 64 virtual void Layout() override; | 64 void Layout() override; |
| 65 virtual void ViewHierarchyChanged( | 65 void ViewHierarchyChanged( |
| 66 const ViewHierarchyChangedDetails& details) override; | 66 const ViewHierarchyChangedDetails& details) override; |
| 67 | 67 |
| 68 // Implementation of gfx::AnimationDelegate. | 68 // Implementation of gfx::AnimationDelegate. |
| 69 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 69 void AnimationProgressed(const gfx::Animation* animation) override; |
| 70 virtual void AnimationEnded(const gfx::Animation* animation) override; | 70 void AnimationEnded(const gfx::Animation* animation) override; |
| 71 | 71 |
| 72 // Implementation of views::LinkListener. | 72 // Implementation of views::LinkListener. |
| 73 // Invoked when the user clicks the 'show all downloads' link button. | 73 // Invoked when the user clicks the 'show all downloads' link button. |
| 74 virtual void LinkClicked(views::Link* source, int event_flags) override; | 74 void LinkClicked(views::Link* source, int event_flags) override; |
| 75 | 75 |
| 76 // Implementation of ButtonListener. | 76 // Implementation of ButtonListener. |
| 77 // Invoked when the user clicks the close button. Asks the browser to | 77 // Invoked when the user clicks the close button. Asks the browser to |
| 78 // hide the download shelf. | 78 // hide the download shelf. |
| 79 virtual void ButtonPressed(views::Button* button, | 79 void ButtonPressed(views::Button* button, const ui::Event& event) override; |
| 80 const ui::Event& event) override; | |
| 81 | 80 |
| 82 // Implementation of DownloadShelf. | 81 // Implementation of DownloadShelf. |
| 83 virtual bool IsShowing() const override; | 82 bool IsShowing() const override; |
| 84 virtual bool IsClosing() const override; | 83 bool IsClosing() const override; |
| 85 virtual Browser* browser() const override; | 84 Browser* browser() const override; |
| 86 | 85 |
| 87 // Implementation of MouseWatcherListener override. | 86 // Implementation of MouseWatcherListener override. |
| 88 virtual void MouseMovedOutOfHost() override; | 87 void MouseMovedOutOfHost() override; |
| 89 | 88 |
| 90 // Removes a specified download view. The supplied view is deleted after | 89 // Removes a specified download view. The supplied view is deleted after |
| 91 // it's removed. | 90 // it's removed. |
| 92 void RemoveDownloadView(views::View* view); | 91 void RemoveDownloadView(views::View* view); |
| 93 | 92 |
| 94 protected: | 93 protected: |
| 95 // Implementation of DownloadShelf. | 94 // Implementation of DownloadShelf. |
| 96 virtual void DoAddDownload(content::DownloadItem* download) override; | 95 void DoAddDownload(content::DownloadItem* download) override; |
| 97 virtual void DoShow() override; | 96 void DoShow() override; |
| 98 virtual void DoClose(CloseReason reason) override; | 97 void DoClose(CloseReason reason) override; |
| 99 | 98 |
| 100 // From AccessiblePaneView | 99 // From AccessiblePaneView |
| 101 virtual views::View* GetDefaultFocusableChild() override; | 100 views::View* GetDefaultFocusableChild() override; |
| 102 | 101 |
| 103 private: | 102 private: |
| 104 // Adds a View representing a download to this DownloadShelfView. | 103 // Adds a View representing a download to this DownloadShelfView. |
| 105 // DownloadShelfView takes ownership of the View, and will delete it as | 104 // DownloadShelfView takes ownership of the View, and will delete it as |
| 106 // necessary. | 105 // necessary. |
| 107 void AddDownloadView(DownloadItemView* view); | 106 void AddDownloadView(DownloadItemView* view); |
| 108 | 107 |
| 109 // Paints the border. | 108 // Paints the border. |
| 110 virtual void OnPaintBorder(gfx::Canvas* canvas) override; | 109 void OnPaintBorder(gfx::Canvas* canvas) override; |
| 111 | 110 |
| 112 // Returns true if the shelf is wide enough to show the first download item. | 111 // Returns true if the shelf is wide enough to show the first download item. |
| 113 bool CanFitFirstDownloadItem(); | 112 bool CanFitFirstDownloadItem(); |
| 114 | 113 |
| 115 // Called on theme change. | 114 // Called on theme change. |
| 116 void UpdateColorsFromTheme(); | 115 void UpdateColorsFromTheme(); |
| 117 | 116 |
| 118 // Overridden from views::View. | 117 // Overridden from views::View. |
| 119 virtual void OnThemeChanged() override; | 118 void OnThemeChanged() override; |
| 120 | 119 |
| 121 // Called when the "close shelf" animation ended. | 120 // Called when the "close shelf" animation ended. |
| 122 void Closed(); | 121 void Closed(); |
| 123 | 122 |
| 124 // Returns true if we can auto close. We can auto-close if all the items on | 123 // Returns true if we can auto close. We can auto-close if all the items on |
| 125 // the shelf have been opened. | 124 // the shelf have been opened. |
| 126 bool CanAutoClose(); | 125 bool CanAutoClose(); |
| 127 | 126 |
| 128 // The browser for this shelf. | 127 // The browser for this shelf. |
| 129 Browser* browser_; | 128 Browser* browser_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 151 | 150 |
| 152 // The window this shelf belongs to. | 151 // The window this shelf belongs to. |
| 153 BrowserView* parent_; | 152 BrowserView* parent_; |
| 154 | 153 |
| 155 views::MouseWatcher mouse_watcher_; | 154 views::MouseWatcher mouse_watcher_; |
| 156 | 155 |
| 157 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); | 156 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); |
| 158 }; | 157 }; |
| 159 | 158 |
| 160 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 159 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
| OLD | NEW |