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

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

Issue 2556573002: Fix SizeLabelToMinWidth() function such that no unnecessary space (Closed)
Patch Set: change to ViewsTestBase Created 4 years 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.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 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
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_TEST_ALL_PREFIXES(DownloadItemViewDangerousDownloadLabelTest,
140 AdjustTextAndGetSize);
141
139 enum State { NORMAL = 0, HOT, PUSHED }; 142 enum State { NORMAL = 0, HOT, PUSHED };
140 class DropDownButton; 143 class DropDownButton;
141 144
142 enum Mode { 145 enum Mode {
143 NORMAL_MODE = 0, // Showing download item. 146 NORMAL_MODE = 0, // Showing download item.
144 DANGEROUS_MODE, // Displaying the dangerous download warning. 147 DANGEROUS_MODE, // Displaying the dangerous download warning.
145 MALICIOUS_MODE // Displaying the malicious download warning. 148 MALICIOUS_MODE // Displaying the malicious download warning.
146 }; 149 };
147 150
148 void OpenDownload(); 151 void OpenDownload();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bool IsShowingWarningDialog() const { 193 bool IsShowingWarningDialog() const {
191 return mode_ == DANGEROUS_MODE || mode_ == MALICIOUS_MODE; 194 return mode_ == DANGEROUS_MODE || mode_ == MALICIOUS_MODE;
192 } 195 }
193 196
194 // Clears or shows the warning dialog as per the state of |model_|. 197 // Clears or shows the warning dialog as per the state of |model_|.
195 void ToggleWarningDialog(); 198 void ToggleWarningDialog();
196 199
197 // Reverts from dangerous mode to normal download mode. 200 // Reverts from dangerous mode to normal download mode.
198 void ClearWarningDialog(); 201 void ClearWarningDialog();
199 202
200 // Start displaying the dangerous download warning or the malicious download 203 // Starts displaying the dangerous download warning or the malicious download
201 // warning. 204 // warning.
202 void ShowWarningDialog(); 205 void ShowWarningDialog();
203 206
204 // Returns the current warning icon (should only be called when the view is 207 // Returns the current warning icon (should only be called when the view is
205 // actually showing a warning). 208 // actually showing a warning).
206 gfx::ImageSkia GetWarningIcon(); 209 gfx::ImageSkia GetWarningIcon();
207 210
208 // Sets |size| with the size of the Save and Discard buttons (they have the 211 // Sets |size| with the size of the Save and Discard buttons (they have the
209 // same size). 212 // same size).
210 gfx::Size GetButtonSize() const; 213 gfx::Size GetButtonSize() const;
211 214
212 // Sizes the dangerous download label to a minimum width available using 2 215 // 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 216 // lines. The size is computed only the first time this method is invoked
214 // and simply returned on subsequent calls. 217 // and simply returned on subsequent calls.
215 void SizeLabelToMinWidth(); 218 void SizeLabelToMinWidth();
216 219
220 // Given a multiline |label|, decides whether it should be displayed on one
221 // line (if short), or broken across two lines. In the latter case,
222 // linebreaks near the middle of the string and sets the label's text
223 // accordingly. Returns the preferred size for the label.
224 static gfx::Size AdjustTextAndGetSize(views::Label* label);
225
217 // Reenables the item after it has been disabled when a user clicked it to 226 // Reenables the item after it has been disabled when a user clicked it to
218 // open the downloaded file. 227 // open the downloaded file.
219 void Reenable(); 228 void Reenable();
220 229
221 // Releases drop down button after showing a context menu. 230 // Releases drop down button after showing a context menu.
222 void ReleaseDropdown(); 231 void ReleaseDropdown();
223 232
224 // Update the accessible name to reflect the current state of the control, 233 // Update the accessible name to reflect the current state of the control,
225 // so that screenreaders can access the filename, status text, and 234 // so that screenreaders can access the filename, status text, and
226 // dangerous download warning message (if any). 235 // dangerous download warning message (if any).
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_; 338 std::unique_ptr<extensions::ExperienceSamplingEvent> sampling_event_;
330 339
331 // Method factory used to delay reenabling of the item when opening the 340 // Method factory used to delay reenabling of the item when opening the
332 // downloaded file. 341 // downloaded file.
333 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; 342 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_;
334 343
335 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); 344 DISALLOW_COPY_AND_ASSIGN(DownloadItemView);
336 }; 345 };
337 346
338 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_ 347 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698