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

Side by Side Diff: chrome/browser/ui/views/download/download_item_view_md.h

Issue 1408223008: [MD] Share button code between find bar and download shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more place Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // A view that implements one download on the Download shelf. 5 // A view that implements one download on the Download shelf.
6 // Each DownloadItemViewMd contains an application icon, a text label 6 // Each DownloadItemViewMd contains an application icon, a text label
7 // indicating the download's file name, a text label indicating the 7 // indicating the download's file name, a text label indicating the
8 // download's status (such as the number of bytes downloaded so far) 8 // download's status (such as the number of bytes downloaded so far)
9 // and a button for canceling an in progress download, or opening 9 // and a button for canceling an in progress download, or opening
10 // the completed download. 10 // the completed download.
(...skipping 17 matching lines...) Expand all
28 #include "chrome/browser/download/download_item_model.h" 28 #include "chrome/browser/download/download_item_model.h"
29 #include "chrome/browser/icon_manager.h" 29 #include "chrome/browser/icon_manager.h"
30 #include "content/public/browser/download_item.h" 30 #include "content/public/browser/download_item.h"
31 #include "content/public/browser/download_manager.h" 31 #include "content/public/browser/download_manager.h"
32 #include "ui/gfx/animation/animation_delegate.h" 32 #include "ui/gfx/animation/animation_delegate.h"
33 #include "ui/gfx/font_list.h" 33 #include "ui/gfx/font_list.h"
34 #include "ui/views/context_menu_controller.h" 34 #include "ui/views/context_menu_controller.h"
35 #include "ui/views/controls/button/button.h" 35 #include "ui/views/controls/button/button.h"
36 #include "ui/views/view.h" 36 #include "ui/views/view.h"
37 37
38 class BarControlButton;
38 class DownloadShelfView; 39 class DownloadShelfView;
39 class DownloadShelfContextMenuView; 40 class DownloadShelfContextMenuView;
40 41
41 namespace extensions { 42 namespace extensions {
42 class ExperienceSamplingEvent; 43 class ExperienceSamplingEvent;
43 } 44 }
44 45
45 namespace gfx { 46 namespace gfx {
46 class Image; 47 class Image;
47 class ImageSkia; 48 class ImageSkia;
48 class SlideAnimation; 49 class SlideAnimation;
49 } 50 }
50 51
52 namespace ui {
53 class ThemeProvider;
54 }
55
51 namespace views { 56 namespace views {
52 class ImageButton; 57 class ImageButton;
53 class Label; 58 class Label;
54 class LabelButton; 59 class LabelButton;
55 } 60 }
56 61
57 // The DownloadItemView in MD style. This is copied from DownloadItemView, 62 // The DownloadItemView in MD style. This is copied from DownloadItemView,
58 // which it should eventually replace. 63 // which it should eventually replace.
59 class DownloadItemViewMd : public views::ButtonListener, 64 class DownloadItemViewMd : public views::ButtonListener,
60 public views::View, 65 public views::View,
61 public views::ContextMenuController, 66 public views::ContextMenuController,
62 public content::DownloadItem::Observer, 67 public content::DownloadItem::Observer,
63 public gfx::AnimationDelegate { 68 public gfx::AnimationDelegate {
64 public: 69 public:
65 DownloadItemViewMd(content::DownloadItem* download, 70 DownloadItemViewMd(content::DownloadItem* download,
66 DownloadShelfView* parent); 71 DownloadShelfView* parent);
67 ~DownloadItemViewMd() override; 72 ~DownloadItemViewMd() override;
68 73
69 // Timer callback for handling animations 74 // Timer callback for handling animations
70 void UpdateDownloadProgress(); 75 void UpdateDownloadProgress();
71 void StartDownloadProgress(); 76 void StartDownloadProgress();
72 void StopDownloadProgress(); 77 void StopDownloadProgress();
73 78
79 // Returns the base color for text on this download item, based on |theme|.
80 static SkColor GetTextColorForThemeProvider(ui::ThemeProvider* theme);
81
74 // IconManager::Client interface. 82 // IconManager::Client interface.
75 void OnExtractIconComplete(gfx::Image* icon); 83 void OnExtractIconComplete(gfx::Image* icon);
76 84
77 // Returns the DownloadItem model object belonging to this item. 85 // Returns the DownloadItem model object belonging to this item.
78 content::DownloadItem* download() { return model_.download(); } 86 content::DownloadItem* download() { return model_.download(); }
79 87
80 // DownloadItem::Observer methods 88 // DownloadItem::Observer methods
81 void OnDownloadUpdated(content::DownloadItem* download) override; 89 void OnDownloadUpdated(content::DownloadItem* download) override;
82 void OnDownloadOpened(content::DownloadItem* download) override; 90 void OnDownloadOpened(content::DownloadItem* download) override;
83 void OnDownloadDestroyed(content::DownloadItem* download) override; 91 void OnDownloadDestroyed(content::DownloadItem* download) override;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // so that screenreaders can access the filename, status text, and 206 // so that screenreaders can access the filename, status text, and
199 // dangerous download warning message (if any). 207 // dangerous download warning message (if any).
200 void UpdateAccessibleName(); 208 void UpdateAccessibleName();
201 209
202 // Show/Hide/Reset |animation| based on the state transition specified by 210 // Show/Hide/Reset |animation| based on the state transition specified by
203 // |from| and |to|. 211 // |from| and |to|.
204 void AnimateStateTransition(State from, 212 void AnimateStateTransition(State from,
205 State to, 213 State to,
206 gfx::SlideAnimation* animation); 214 gfx::SlideAnimation* animation);
207 215
216 // Returns the base text color.
217 SkColor GetTextColor();
218
219 // Returns a slightly dimmed version of the base text color.
220 SkColor GetDimmedTextColor();
221
208 // The download shelf that owns us. 222 // The download shelf that owns us.
209 DownloadShelfView* shelf_; 223 DownloadShelfView* shelf_;
210 224
211 // Elements of our particular download 225 // Elements of our particular download
212 base::string16 status_text_; 226 base::string16 status_text_;
213 227
214 // The font list used to print the file name and warning text. 228 // The font list used to print the file name and warning text.
215 gfx::FontList font_list_; 229 gfx::FontList font_list_;
216 230
217 // The font list used to print the status text below the file name. 231 // The font list used to print the status text below the file name.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 scoped_ptr<gfx::SlideAnimation> complete_animation_; 271 scoped_ptr<gfx::SlideAnimation> complete_animation_;
258 272
259 // Progress animation 273 // Progress animation
260 base::RepeatingTimer progress_timer_; 274 base::RepeatingTimer progress_timer_;
261 275
262 // Dangerous mode buttons. 276 // Dangerous mode buttons.
263 views::LabelButton* save_button_; 277 views::LabelButton* save_button_;
264 views::LabelButton* discard_button_; 278 views::LabelButton* discard_button_;
265 279
266 // The drop down button. 280 // The drop down button.
267 views::ImageButton* dropdown_button_; 281 BarControlButton* dropdown_button_;
268 282
269 // Dangerous mode label. 283 // Dangerous mode label.
270 views::Label* dangerous_download_label_; 284 views::Label* dangerous_download_label_;
271 285
272 // Whether the dangerous mode label has been sized yet. 286 // Whether the dangerous mode label has been sized yet.
273 bool dangerous_download_label_sized_; 287 bool dangerous_download_label_sized_;
274 288
275 // The size of the buttons. Cached so animation works when hidden. 289 // The size of the buttons. Cached so animation works when hidden.
276 mutable gfx::Size cached_button_size_; 290 mutable gfx::Size cached_button_size_;
277 291
(...skipping 22 matching lines...) Expand all
300 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 314 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
301 315
302 // Method factory used to delay reenabling of the item when opening the 316 // Method factory used to delay reenabling of the item when opening the
303 // downloaded file. 317 // downloaded file.
304 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_; 318 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_;
305 319
306 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd); 320 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd);
307 }; 321 };
308 322
309 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ 323 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698