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