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

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

Issue 1365763002: Downloads bar for MD: work on sizing, text appearance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: height instead of baseline Created 5 years, 2 months 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/download/download_item_view_md.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 private: 119 private:
120 enum State { NORMAL = 0, HOT, PUSHED }; 120 enum State { NORMAL = 0, HOT, PUSHED };
121 121
122 enum Mode { 122 enum Mode {
123 NORMAL_MODE = 0, // Showing download item. 123 NORMAL_MODE = 0, // Showing download item.
124 DANGEROUS_MODE, // Displaying the dangerous download warning. 124 DANGEROUS_MODE, // Displaying the dangerous download warning.
125 MALICIOUS_MODE // Displaying the malicious download warning. 125 MALICIOUS_MODE // Displaying the malicious download warning.
126 }; 126 };
127 127
128 // The image set associated with the part containing the icon and text.
129 // TODO(estade): these are not drawn, they're just used for vestigial sizing
130 // logic. Remove them.
131 struct BodyImageSet {
132 gfx::ImageSkia* top_left;
133 gfx::ImageSkia* left;
134 gfx::ImageSkia* bottom_left;
135 gfx::ImageSkia* top;
136 gfx::ImageSkia* center;
137 gfx::ImageSkia* bottom;
138 gfx::ImageSkia* top_right;
139 gfx::ImageSkia* right;
140 gfx::ImageSkia* bottom_right;
141 };
142
143 // The image set associated with the drop-down button on the right.
144 struct DropdownImageSet {
145 gfx::ImageSkia* top;
146 gfx::ImageSkia* center;
147 gfx::ImageSkia* bottom;
148 };
149
150 void OpenDownload(); 128 void OpenDownload();
151 129
152 // Submits the downloaded file to the safebrowsing download feedback service. 130 // Submits the downloaded file to the safebrowsing download feedback service.
153 // Returns whether submission was successful. On successful submission, 131 // Returns whether submission was successful. On successful submission,
154 // |this| and the DownloadItem will have been deleted. 132 // |this| and the DownloadItem will have been deleted.
155 bool SubmitDownloadToFeedbackService(); 133 bool SubmitDownloadToFeedbackService();
156 134
157 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService. 135 // If the user has |enabled| uploading, calls SubmitDownloadToFeedbackService.
158 // Otherwise, it simply removes the DownloadItem without uploading. 136 // Otherwise, it simply removes the DownloadItem without uploading.
159 void PossiblySubmitDownloadToFeedbackService(bool enabled); 137 void PossiblySubmitDownloadToFeedbackService(bool enabled);
160 138
139 // This function calculates the vertical coordinate to draw the file name text
140 // relative to local bounds.
141 int GetYForFilenameText() const;
142
161 // Painting of various download item bits. 143 // Painting of various download item bits.
162 void DrawStatusText(gfx::Canvas* canvas); 144 void DrawStatusText(gfx::Canvas* canvas);
163 void DrawFilename(gfx::Canvas* canvas); 145 void DrawFilename(gfx::Canvas* canvas);
164 void DrawIcon(gfx::Canvas* canvas); 146 void DrawIcon(gfx::Canvas* canvas);
165 147
166 void LoadIcon(); 148 void LoadIcon();
167 void LoadIconIfItemPathChanged(); 149 void LoadIconIfItemPathChanged();
168 150
169 // Update the button colors based on the current theme. 151 // Update the button colors based on the current theme.
170 void UpdateColorsFromTheme(); 152 void UpdateColorsFromTheme();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 // so that screenreaders can access the filename, status text, and 195 // so that screenreaders can access the filename, status text, and
214 // dangerous download warning message (if any). 196 // dangerous download warning message (if any).
215 void UpdateAccessibleName(); 197 void UpdateAccessibleName();
216 198
217 // Show/Hide/Reset |animation| based on the state transition specified by 199 // Show/Hide/Reset |animation| based on the state transition specified by
218 // |from| and |to|. 200 // |from| and |to|.
219 void AnimateStateTransition(State from, 201 void AnimateStateTransition(State from,
220 State to, 202 State to,
221 gfx::SlideAnimation* animation); 203 gfx::SlideAnimation* animation);
222 204
223 // The different images used for the background.
224 BodyImageSet normal_body_image_set_;
225 BodyImageSet hot_body_image_set_;
226 BodyImageSet pushed_body_image_set_;
227 BodyImageSet dangerous_mode_body_image_set_;
228 BodyImageSet malicious_mode_body_image_set_;
229 DropdownImageSet normal_dropdown_image_set_;
230 DropdownImageSet hot_dropdown_image_set_;
231 DropdownImageSet pushed_dropdown_image_set_;
232
233 // The warning icon showns for dangerous downloads. 205 // The warning icon showns for dangerous downloads.
234 const gfx::ImageSkia* warning_icon_; 206 const gfx::ImageSkia* warning_icon_;
235 207
236 // The download shelf that owns us. 208 // The download shelf that owns us.
237 DownloadShelfView* shelf_; 209 DownloadShelfView* shelf_;
238 210
239 // Elements of our particular download 211 // Elements of our particular download
240 base::string16 status_text_; 212 base::string16 status_text_;
241 213
242 // The font list used to print the file name and status. 214 // The font list used to print the file name and warning text.
243 gfx::FontList font_list_; 215 gfx::FontList font_list_;
244 216
217 // The font list used to print the status text below the file name.
218 gfx::FontList status_font_list_;
219
245 // The tooltip. Only displayed when not showing a warning dialog. 220 // The tooltip. Only displayed when not showing a warning dialog.
246 base::string16 tooltip_text_; 221 base::string16 tooltip_text_;
247 222
248 // The current state (normal, hot or pushed) of the body and drop-down. 223 // The current state (normal, hot or pushed) of the body and drop-down.
249 State dropdown_state_; 224 State dropdown_state_;
250 225
251 // Mode of the download item view. 226 // Mode of the download item view.
252 Mode mode_; 227 Mode mode_;
253 228
254 // When download progress last began animating (pausing and resuming will 229 // When download progress last began animating (pausing and resuming will
255 // update this). Used for downloads of unknown size. 230 // update this). Used for downloads of unknown size.
256 base::TimeTicks progress_start_time_; 231 base::TimeTicks progress_start_time_;
257 232
258 // Keeps the amount of time spent already animating. Used to keep track of 233 // Keeps the amount of time spent already animating. Used to keep track of
259 // total active time for downloads of unknown size. 234 // total active time for downloads of unknown size.
260 base::TimeDelta previous_progress_elapsed_; 235 base::TimeDelta previous_progress_elapsed_;
261 236
262 // The height of the box formed by the background images and its labels.
263 int box_height_;
264
265 // The y coordinate of the box formed by the background images and its labels.
266 int box_y_;
267
268 // Whether we are dragging the download button. 237 // Whether we are dragging the download button.
269 bool dragging_; 238 bool dragging_;
270 239
271 // Whether we are tracking a possible drag. 240 // Whether we are tracking a possible drag.
272 bool starting_drag_; 241 bool starting_drag_;
273 242
274 // Position that a possible drag started at. 243 // Position that a possible drag started at.
275 gfx::Point drag_start_point_; 244 gfx::Point drag_start_point_;
276 245
277 // For canceling an in progress icon request. 246 // For canceling an in progress icon request.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 300 scoped_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
332 301
333 // Method factory used to delay reenabling of the item when opening the 302 // Method factory used to delay reenabling of the item when opening the
334 // downloaded file. 303 // downloaded file.
335 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_; 304 base::WeakPtrFactory<DownloadItemViewMd> weak_ptr_factory_;
336 305
337 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd); 306 DISALLOW_COPY_AND_ASSIGN(DownloadItemViewMd);
338 }; 307 };
339 308
340 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_ 309 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_MD_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/download/download_item_view_md.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698