OLD | NEW |
---|---|
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 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 // gfx::AnimationDelegate implementation. | 129 // gfx::AnimationDelegate implementation. |
130 void AnimationProgressed(const gfx::Animation* animation) override; | 130 void AnimationProgressed(const gfx::Animation* animation) override; |
131 | 131 |
132 protected: | 132 protected: |
133 // Overridden from views::View: | 133 // Overridden from views::View: |
134 void OnPaint(gfx::Canvas* canvas) override; | 134 void OnPaint(gfx::Canvas* canvas) override; |
135 void OnFocus() override; | 135 void OnFocus() override; |
136 void OnBlur() override; | 136 void OnBlur() override; |
137 | 137 |
138 private: | 138 private: |
139 friend class DownloadItemViewTest; | |
140 | |
139 enum State { NORMAL = 0, HOT, PUSHED }; | 141 enum State { NORMAL = 0, HOT, PUSHED }; |
140 class DropDownButton; | 142 class DropDownButton; |
141 | 143 |
142 enum Mode { | 144 enum Mode { |
143 NORMAL_MODE = 0, // Showing download item. | 145 NORMAL_MODE = 0, // Showing download item. |
144 DANGEROUS_MODE, // Displaying the dangerous download warning. | 146 DANGEROUS_MODE, // Displaying the dangerous download warning. |
145 MALICIOUS_MODE // Displaying the malicious download warning. | 147 MALICIOUS_MODE // Displaying the malicious download warning. |
146 }; | 148 }; |
147 | 149 |
148 void OpenDownload(); | 150 void OpenDownload(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 | 209 |
208 // Sets |size| with the size of the Save and Discard buttons (they have the | 210 // Sets |size| with the size of the Save and Discard buttons (they have the |
209 // same size). | 211 // same size). |
210 gfx::Size GetButtonSize() const; | 212 gfx::Size GetButtonSize() const; |
211 | 213 |
212 // Sizes the dangerous download label to a minimum width available using 2 | 214 // Sizes the dangerous download label to a minimum width available using 2 |
213 // lines. The size is computed only the first time this method is invoked | 215 // lines. The size is computed only the first time this method is invoked |
214 // and simply returned on subsequent calls. | 216 // and simply returned on subsequent calls. |
215 void SizeLabelToMinWidth(); | 217 void SizeLabelToMinWidth(); |
216 | 218 |
219 // Called by SizeLabelToMinWidth() to compute the optimal size of dangerous | |
Peter Kasting
2016/12/08 05:10:23
Nit: of -> of the, or "of |dangerous_download_labe
Jialiu Lin
2016/12/08 07:47:40
Done.
| |
220 // download label and set the text accordingly. | |
221 gfx::Size GetLabelSize(); | |
Peter Kasting
2016/12/08 05:10:23
Nit: Seems like this should be named SetLabelTextA
Jialiu Lin
2016/12/08 07:47:40
Done.
| |
222 | |
217 // Reenables the item after it has been disabled when a user clicked it to | 223 // Reenables the item after it has been disabled when a user clicked it to |
218 // open the downloaded file. | 224 // open the downloaded file. |
219 void Reenable(); | 225 void Reenable(); |
220 | 226 |
221 // Releases drop down button after showing a context menu. | 227 // Releases drop down button after showing a context menu. |
222 void ReleaseDropdown(); | 228 void ReleaseDropdown(); |
223 | 229 |
224 // Update the accessible name to reflect the current state of the control, | 230 // Update the accessible name to reflect the current state of the control, |
225 // so that screenreaders can access the filename, status text, and | 231 // so that screenreaders can access the filename, status text, and |
226 // dangerous download warning message (if any). | 232 // dangerous download warning message (if any). |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
329 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; | 335 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; |
330 | 336 |
331 // Method factory used to delay reenabling of the item when opening the | 337 // Method factory used to delay reenabling of the item when opening the |
332 // downloaded file. | 338 // downloaded file. |
333 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; | 339 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; |
334 | 340 |
335 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); | 341 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); |
336 }; | 342 }; |
337 | 343 |
338 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ | 344 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ |
OLD | NEW |