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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "chrome/browser/download/download_shelf.h" | 14 #include "chrome/browser/download/download_shelf.h" |
15 #include "ui/gfx/animation/animation_delegate.h" | 15 #include "ui/gfx/animation/animation_delegate.h" |
16 #include "ui/gfx/animation/slide_animation.h" | 16 #include "ui/gfx/animation/slide_animation.h" |
17 #include "ui/views/accessible_pane_view.h" | 17 #include "ui/views/accessible_pane_view.h" |
18 #include "ui/views/controls/button/vector_icon_button_delegate.h" | 18 #include "ui/views/controls/button/vector_icon_button_delegate.h" |
19 #include "ui/views/controls/link_listener.h" | 19 #include "ui/views/controls/link_listener.h" |
20 #include "ui/views/mouse_watcher.h" | 20 #include "ui/views/mouse_watcher.h" |
21 | 21 |
22 class Browser; | 22 class Browser; |
23 class BrowserView; | 23 class BrowserView; |
| 24 class DownloadItemView; |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 class DownloadItem; | 27 class DownloadItem; |
27 class PageNavigator; | 28 class PageNavigator; |
28 } | 29 } |
29 | 30 |
30 namespace views { | 31 namespace views { |
31 class ImageButton; | 32 class ImageButton; |
32 class ImageView; | 33 class ImageView; |
33 class MdTextButton; | 34 class MdTextButton; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 void DoShow() override; | 97 void DoShow() override; |
97 void DoClose(CloseReason reason) override; | 98 void DoClose(CloseReason reason) override; |
98 | 99 |
99 // From AccessiblePaneView | 100 // From AccessiblePaneView |
100 views::View* GetDefaultFocusableChild() override; | 101 views::View* GetDefaultFocusableChild() override; |
101 | 102 |
102 private: | 103 private: |
103 // Adds a View representing a download to this DownloadShelfView. | 104 // Adds a View representing a download to this DownloadShelfView. |
104 // DownloadShelfView takes ownership of the View, and will delete it as | 105 // DownloadShelfView takes ownership of the View, and will delete it as |
105 // necessary. | 106 // necessary. |
106 void AddDownloadView(views::View* view); | 107 void AddDownloadView(DownloadItemView* view); |
107 | 108 |
108 // Paints the border. | 109 // Paints the border. |
109 void OnPaintBorder(gfx::Canvas* canvas) override; | 110 void OnPaintBorder(gfx::Canvas* canvas) override; |
110 | 111 |
111 // Returns true if the shelf is wide enough to show the first download item. | 112 // Returns true if the shelf is wide enough to show the first download item. |
112 bool CanFitFirstDownloadItem(); | 113 bool CanFitFirstDownloadItem(); |
113 | 114 |
114 // Called on theme change. | 115 // Called on theme change. |
115 void UpdateColorsFromTheme(); | 116 void UpdateColorsFromTheme(); |
116 | 117 |
117 // Overridden from views::View. | 118 // Overridden from views::View. |
118 void OnThemeChanged() override; | 119 void OnThemeChanged() override; |
119 | 120 |
120 // Called when the "close shelf" animation ended. | 121 // Called when the "close shelf" animation ended. |
121 void Closed(); | 122 void Closed(); |
122 | 123 |
123 // Returns true if we can auto close. We can auto-close if all the items on | 124 // Returns true if we can auto close. We can auto-close if all the items on |
124 // the shelf have been opened. | 125 // the shelf have been opened. |
125 bool CanAutoClose(); | 126 bool CanAutoClose(); |
126 | 127 |
127 // Gets the |DownloadItem| for the i^th download view. TODO(estade): this | |
128 // shouldn't be necessary after we only have one type of DownloadItemView. | |
129 content::DownloadItem* GetDownloadItemForView(size_t i); | |
130 | |
131 // Returns the color of text for the shelf (used for deriving icon color). | 128 // Returns the color of text for the shelf (used for deriving icon color). |
132 SkColor GetTextColorForIconMd(); | 129 SkColor GetTextColorForIconMd(); |
133 | 130 |
134 // The browser for this shelf. | 131 // The browser for this shelf. |
135 Browser* browser_; | 132 Browser* browser_; |
136 | 133 |
137 // The animation for adding new items to the shelf. | 134 // The animation for adding new items to the shelf. |
138 gfx::SlideAnimation new_item_animation_; | 135 gfx::SlideAnimation new_item_animation_; |
139 | 136 |
140 // The show/hide animation for the shelf itself. | 137 // The show/hide animation for the shelf itself. |
141 gfx::SlideAnimation shelf_animation_; | 138 gfx::SlideAnimation shelf_animation_; |
142 | 139 |
143 // The download views. These are also child Views, and deleted when | 140 // The download views. These are also child Views, and deleted when |
144 // the DownloadShelfView is deleted. | 141 // the DownloadShelfView is deleted. |
145 std::vector<views::View*> download_views_; | 142 std::vector<DownloadItemView*> download_views_; |
146 | 143 |
147 // An image displayed on the right of the "Show all downloads..." link. | 144 // Button for showing all downloads (chrome://downloads). |
148 // TODO(estade): not shown in MD; remove. | 145 views::MdTextButton* show_all_view_; |
149 views::ImageView* arrow_image_; | |
150 | |
151 // Link for showing all downloads. For MD this is a system style button. | |
152 views::View* show_all_view_; | |
153 | |
154 // This is the same as |show_all_view_|, but only valid in MD mode. | |
155 views::MdTextButton* show_all_view_md_; | |
156 | 146 |
157 // Button for closing the downloads. This is contained as a child, and | 147 // Button for closing the downloads. This is contained as a child, and |
158 // deleted by View. | 148 // deleted by View. |
159 views::ImageButton* close_button_; | 149 views::ImageButton* close_button_; |
160 | 150 |
161 // The window this shelf belongs to. | 151 // The window this shelf belongs to. |
162 BrowserView* parent_; | 152 BrowserView* parent_; |
163 | 153 |
164 views::MouseWatcher mouse_watcher_; | 154 views::MouseWatcher mouse_watcher_; |
165 | 155 |
166 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); | 156 DISALLOW_COPY_AND_ASSIGN(DownloadShelfView); |
167 }; | 157 }; |
168 | 158 |
169 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ | 159 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_SHELF_VIEW_H_ |
OLD | NEW |