OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 ChromeView that implements one download on the Download shelf. | 5 // A ChromeView 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Returns the DownloadItem model object belonging to this item. | 69 // Returns the DownloadItem model object belonging to this item. |
70 content::DownloadItem* download() { return model_.download(); } | 70 content::DownloadItem* download() { return model_.download(); } |
71 | 71 |
72 // DownloadItem::Observer methods | 72 // DownloadItem::Observer methods |
73 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; | 73 virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE; |
74 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; | 74 virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE; |
75 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; | 75 virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE; |
76 | 76 |
77 // Overridden from views::View: | 77 // Overridden from views::View: |
78 virtual void Layout() OVERRIDE; | 78 virtual void Layout() OVERRIDE; |
79 virtual gfx::Size GetPreferredSize() OVERRIDE; | 79 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
80 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 80 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
81 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | 81 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; |
82 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 82 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
83 virtual void OnMouseCaptureLost() OVERRIDE; | 83 virtual void OnMouseCaptureLost() OVERRIDE; |
84 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; | 84 virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE; |
85 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 85 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
86 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 86 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
87 virtual bool GetTooltipText(const gfx::Point& p, | 87 virtual bool GetTooltipText(const gfx::Point& p, |
88 base::string16* tooltip) const OVERRIDE; | 88 base::string16* tooltip) const OVERRIDE; |
89 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; | 89 virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 // Reverts from dangerous mode to normal download mode. | 192 // Reverts from dangerous mode to normal download mode. |
193 void ClearWarningDialog(); | 193 void ClearWarningDialog(); |
194 | 194 |
195 // Start displaying the dangerous download warning or the malicious download | 195 // Start displaying the dangerous download warning or the malicious download |
196 // warning. | 196 // warning. |
197 void ShowWarningDialog(); | 197 void ShowWarningDialog(); |
198 | 198 |
199 // Sets |size| with the size of the Save and Discard buttons (they have the | 199 // Sets |size| with the size of the Save and Discard buttons (they have the |
200 // same size). | 200 // same size). |
201 gfx::Size GetButtonSize(); | 201 gfx::Size GetButtonSize() const; |
202 | 202 |
203 // Sizes the dangerous download label to a minimum width available using 2 | 203 // Sizes the dangerous download label to a minimum width available using 2 |
204 // lines. The size is computed only the first time this method is invoked | 204 // lines. The size is computed only the first time this method is invoked |
205 // and simply returned on subsequent calls. | 205 // and simply returned on subsequent calls. |
206 void SizeLabelToMinWidth(); | 206 void SizeLabelToMinWidth(); |
207 | 207 |
208 // Reenables the item after it has been disabled when a user clicked it to | 208 // Reenables the item after it has been disabled when a user clicked it to |
209 // open the downloaded file. | 209 // open the downloaded file. |
210 void Reenable(); | 210 void Reenable(); |
211 | 211 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 views::LabelButton* save_button_; | 306 views::LabelButton* save_button_; |
307 views::LabelButton* discard_button_; | 307 views::LabelButton* discard_button_; |
308 | 308 |
309 // Dangerous mode label. | 309 // Dangerous mode label. |
310 views::Label* dangerous_download_label_; | 310 views::Label* dangerous_download_label_; |
311 | 311 |
312 // Whether the dangerous mode label has been sized yet. | 312 // Whether the dangerous mode label has been sized yet. |
313 bool dangerous_download_label_sized_; | 313 bool dangerous_download_label_sized_; |
314 | 314 |
315 // The size of the buttons. Cached so animation works when hidden. | 315 // The size of the buttons. Cached so animation works when hidden. |
316 gfx::Size cached_button_size_; | 316 mutable gfx::Size cached_button_size_; |
317 | 317 |
318 // Whether we are currently disabled as part of opening the downloaded file. | 318 // Whether we are currently disabled as part of opening the downloaded file. |
319 bool disabled_while_opening_; | 319 bool disabled_while_opening_; |
320 | 320 |
321 // The time at which this view was created. | 321 // The time at which this view was created. |
322 base::Time creation_time_; | 322 base::Time creation_time_; |
323 | 323 |
324 // The time at which a dangerous download warning was displayed. | 324 // The time at which a dangerous download warning was displayed. |
325 base::Time time_download_warning_shown_; | 325 base::Time time_download_warning_shown_; |
326 | 326 |
327 // Method factory used to delay reenabling of the item when opening the | 327 // Method factory used to delay reenabling of the item when opening the |
328 // downloaded file. | 328 // downloaded file. |
329 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; | 329 base::WeakPtrFactory<DownloadItemView> weak_ptr_factory_; |
330 | 330 |
331 // The currently running download context menu. | 331 // The currently running download context menu. |
332 scoped_ptr<DownloadShelfContextMenuView> context_menu_; | 332 scoped_ptr<DownloadShelfContextMenuView> context_menu_; |
333 | 333 |
334 // The name of this view as reported to assistive technology. | 334 // The name of this view as reported to assistive technology. |
335 base::string16 accessible_name_; | 335 base::string16 accessible_name_; |
336 | 336 |
337 // The icon loaded in the download shelf is based on the file path of the | 337 // The icon loaded in the download shelf is based on the file path of the |
338 // item. Store the path used, so that we can detect a change in the path | 338 // item. Store the path used, so that we can detect a change in the path |
339 // and reload the icon. | 339 // and reload the icon. |
340 base::FilePath last_download_item_path_; | 340 base::FilePath last_download_item_path_; |
341 | 341 |
342 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); | 342 DISALLOW_COPY_AND_ASSIGN(DownloadItemView); |
343 }; | 343 }; |
344 | 344 |
345 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ | 345 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_ITEM_VIEW_H__ |
OLD | NEW |