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 // A ChromeView that implements one download on the Download shelf. | 5 // A ChromeView that implements one download on the Download shelf. |
6 // Each DownloadItemView contains an application icon, a text label | 6 // Each DownloadItemView 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 class LabelButton; | 53 class LabelButton; |
54 } | 54 } |
55 | 55 |
56 class DownloadItemView : public views::ButtonListener, | 56 class DownloadItemView : public views::ButtonListener, |
57 public views::View, | 57 public views::View, |
58 public views::ContextMenuController, | 58 public views::ContextMenuController, |
59 public content::DownloadItem::Observer, | 59 public content::DownloadItem::Observer, |
60 public gfx::AnimationDelegate { | 60 public gfx::AnimationDelegate { |
61 public: | 61 public: |
62 DownloadItemView(content::DownloadItem* download, DownloadShelfView* parent); | 62 DownloadItemView(content::DownloadItem* download, DownloadShelfView* parent); |
63 virtual ~DownloadItemView(); | 63 ~DownloadItemView() override; |
64 | 64 |
65 // Timer callback for handling animations | 65 // Timer callback for handling animations |
66 void UpdateDownloadProgress(); | 66 void UpdateDownloadProgress(); |
67 void StartDownloadProgress(); | 67 void StartDownloadProgress(); |
68 void StopDownloadProgress(); | 68 void StopDownloadProgress(); |
69 | 69 |
70 // IconManager::Client interface. | 70 // IconManager::Client interface. |
71 void OnExtractIconComplete(gfx::Image* icon); | 71 void OnExtractIconComplete(gfx::Image* icon); |
72 | 72 |
73 // Returns the DownloadItem model object belonging to this item. | 73 // Returns the DownloadItem model object belonging to this item. |
74 content::DownloadItem* download() { return model_.download(); } | 74 content::DownloadItem* download() { return model_.download(); } |
75 | 75 |
76 // DownloadItem::Observer methods | 76 // DownloadItem::Observer methods |
77 virtual void OnDownloadUpdated(content::DownloadItem* download) override; | 77 void OnDownloadUpdated(content::DownloadItem* download) override; |
78 virtual void OnDownloadOpened(content::DownloadItem* download) override; | 78 void OnDownloadOpened(content::DownloadItem* download) override; |
79 virtual void OnDownloadDestroyed(content::DownloadItem* download) override; | 79 void OnDownloadDestroyed(content::DownloadItem* download) override; |
80 | 80 |
81 // Overridden from views::View: | 81 // Overridden from views::View: |
82 virtual void Layout() override; | 82 void Layout() override; |
83 virtual gfx::Size GetPreferredSize() const override; | 83 gfx::Size GetPreferredSize() const override; |
84 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 84 bool OnMousePressed(const ui::MouseEvent& event) override; |
85 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; | 85 bool OnMouseDragged(const ui::MouseEvent& event) override; |
86 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 86 void OnMouseReleased(const ui::MouseEvent& event) override; |
87 virtual void OnMouseCaptureLost() override; | 87 void OnMouseCaptureLost() override; |
88 virtual void OnMouseMoved(const ui::MouseEvent& event) override; | 88 void OnMouseMoved(const ui::MouseEvent& event) override; |
89 virtual void OnMouseExited(const ui::MouseEvent& event) override; | 89 void OnMouseExited(const ui::MouseEvent& event) override; |
90 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 90 bool OnKeyPressed(const ui::KeyEvent& event) override; |
91 virtual bool GetTooltipText(const gfx::Point& p, | 91 bool GetTooltipText(const gfx::Point& p, |
92 base::string16* tooltip) const override; | 92 base::string16* tooltip) const override; |
93 virtual void GetAccessibleState(ui::AXViewState* state) override; | 93 void GetAccessibleState(ui::AXViewState* state) override; |
94 virtual void OnThemeChanged() override; | 94 void OnThemeChanged() override; |
95 | 95 |
96 // Overridden from ui::EventHandler: | 96 // Overridden from ui::EventHandler: |
97 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 97 void OnGestureEvent(ui::GestureEvent* event) override; |
98 | 98 |
99 // Overridden from views::ContextMenuController. | 99 // Overridden from views::ContextMenuController. |
100 virtual void ShowContextMenuForView(View* source, | 100 void ShowContextMenuForView(View* source, |
101 const gfx::Point& point, | 101 const gfx::Point& point, |
102 ui::MenuSourceType source_type) override; | 102 ui::MenuSourceType source_type) override; |
103 | 103 |
104 // ButtonListener implementation. | 104 // ButtonListener implementation. |
105 virtual void ButtonPressed(views::Button* sender, | 105 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
106 const ui::Event& event) override; | |
107 | 106 |
108 // gfx::AnimationDelegate implementation. | 107 // gfx::AnimationDelegate implementation. |
109 virtual void AnimationProgressed(const gfx::Animation* animation) override; | 108 void AnimationProgressed(const gfx::Animation* animation) override; |
110 | 109 |
111 protected: | 110 protected: |
112 // Overridden from views::View: | 111 // Overridden from views::View: |
113 virtual void OnPaint(gfx::Canvas* canvas) override; | 112 void OnPaint(gfx::Canvas* canvas) override; |
114 virtual void OnPaintBackground(gfx::Canvas* canvas) override; | 113 void OnPaintBackground(gfx::Canvas* canvas) override; |
115 virtual void OnFocus() override; | 114 void OnFocus() override; |
116 virtual void OnBlur() override; | 115 void OnBlur() override; |
117 | 116 |
118 private: | 117 private: |
119 enum State { | 118 enum State { |
120 NORMAL = 0, | 119 NORMAL = 0, |
121 HOT, | 120 HOT, |
122 PUSHED | 121 PUSHED |
123 }; | 122 }; |
124 | 123 |
125 enum Mode { | 124 enum Mode { |
126 NORMAL_MODE = 0, // Showing download item. | 125 NORMAL_MODE = 0, // Showing download item. |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; | 343 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; |
345 | 344 |
346 // Method factory used to delay reenabling of the item when opening the | 345 // Method factory used to delay reenabling of the item when opening the |
347 // downloaded file. | 346 // downloaded file. |
348 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; | 347 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; |
349 | 348 |
350 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); | 349 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); |
351 }; | 350 }; |
352 | 351 |
353 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ | 352 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ |
OLD | NEW |