Commit 316bd1dd authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Refactor DownloadItemView state transitions, part 3.

This adds a helper, UpdateLabels(), to set all labels' visibility, text,
and style based on the current mode; this replaces the scattered pieces
throughout other functions.

The file name label's style changes based not on the mode but on the
enabled state of the whole view; update that in the functions that set
the view's enabled state.

The above two changes mean that UpdateColorsFromTheme() now only deals
with colors, and thus no longer need be called outside OnThemeChanged().

Renames |dangerous_download_label_| to the more accurate (and shorter!)
|warning_label_|.

For some reason UpdateMode() was also sometimes setting the file name
label's Y coordinate.  This is done in layout, and there's no reason to
do it here.

Bug: none
Change-Id: Ib7b9b77cc8ba11af609d9e25328f9207da66f6d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2299141
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788914}
parent 79692251
......@@ -134,6 +134,9 @@ class DownloadItemView : public views::View,
// Sets the current mode to |mode| and updates UI appropriately.
void UpdateMode(Mode mode);
// Updates the visibility, text, size, etc. of all labels.
void UpdateLabels();
// Updates the visible and enabled state of all buttons.
void UpdateButtons();
......@@ -145,10 +148,6 @@ class DownloadItemView : public views::View,
bool SubmitDownloadToFeedbackService(
DownloadCommands::Command download_command);
// This function calculates the vertical coordinate to draw the file name text
// relative to local bounds.
int GetYForFilenameText() const;
void DrawIcon(gfx::Canvas* canvas);
void LoadIcon();
......@@ -228,8 +227,8 @@ class DownloadItemView : public views::View,
// Callback for |progress_timer_|.
void ProgressTimerFired();
// Returns the status text to show in the notification.
base::string16 GetStatusText() const;
// Returns the text and style to use for the status label.
std::pair<base::string16, int> GetStatusTextAndStyle() const;
// Returns the file name to report to user. It might be elided to fit into
// the text width.
......@@ -307,7 +306,7 @@ class DownloadItemView : public views::View,
views::Label* file_name_label_;
views::Label* status_label_;
views::StyledLabel* dangerous_download_label_;
views::StyledLabel* warning_label_;
views::StyledLabel* deep_scanning_label_;
views::MdTextButton* open_now_button_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment