diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-10 18:50:32 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-10 18:50:32 +0000 |
commit | 9ccbb370aa45f477941e0599d4ce7c89fac64101 (patch) | |
tree | 8b21818fa95d05ff00dfe5b9986d1d39eb4be722 /chrome/browser/views/download_item_view.h | |
parent | a9acde54584ff37bcc5fad73cf25dce5d85348bc (diff) | |
download | chromium_src-9ccbb370aa45f477941e0599d4ce7c89fac64101.zip chromium_src-9ccbb370aa45f477941e0599d4ce7c89fac64101.tar.gz chromium_src-9ccbb370aa45f477941e0599d4ce7c89fac64101.tar.bz2 |
This CL adds prompting for dangerous types of files (executable) when they are automatically downloaded.
The file is saved with a temporary name (dangerous_download_xxxx.download) in the download directory and the user is presented (in the download shelf and the download tab if opened) with a warning message and buttons to save/discard the download.
If discarded the download is removed (and its file deleted).
If saved, download goes as usual.
Dangerous downloads not confirmed by the user are deleted on shutdown.
TEST=Download a small exe file, try using the save/discard button from the download shelf and from the download tab (the intent is that the file has been entirely downloaded by the time you take action). Try again with a slow/big download (that time the download is expected not to be finished when approved/discarded).
Review URL: http://codereview.chromium.org/6043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/download_item_view.h')
-rw-r--r-- | chrome/browser/views/download_item_view.h | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h index 69adcc4..c29a154 100644 --- a/chrome/browser/views/download_item_view.h +++ b/chrome/browser/views/download_item_view.h @@ -26,13 +26,17 @@ #include "chrome/browser/download/download_manager.h" #include "chrome/browser/icon_manager.h" #include "chrome/views/event.h" +#include "chrome/views/native_button.h" #include "chrome/views/view.h" -#include "chrome/views/label.h" +namespace ChromeViews { + class Label; +} class DownloadShelfView; class SkBitmap; -class DownloadItemView : public ChromeViews::View, +class DownloadItemView : public ChromeViews::NativeButton::Listener, + public ChromeViews::View, public DownloadItem::Observer, public AnimationDelegate { public: @@ -56,6 +60,7 @@ class DownloadItemView : public ChromeViews::View, virtual void OnDownloadUpdated(DownloadItem* download); // View overrides + virtual void Layout(); virtual void Paint(ChromeCanvas* canvas); virtual void GetPreferredSize(CSize *out); virtual void OnMouseExited(const ChromeViews::MouseEvent& event); @@ -64,6 +69,10 @@ class DownloadItemView : public ChromeViews::View, virtual void OnMouseReleased(const ChromeViews::MouseEvent& event, bool canceled); virtual bool OnMouseDragged(const ChromeViews::MouseEvent& event); + virtual void DidChangeBounds(const CRect& previous, const CRect& current); + + // NativeButton::Listener implementation. + virtual void ButtonPressed(ChromeViews::NativeButton* sender); // AnimationDelegate implementation. virtual void AnimationProgressed(const Animation* animation); @@ -81,6 +90,7 @@ class DownloadItemView : public ChromeViews::View, NORMAL = 0, HOT, PUSHED, + DANGEROUS }; // The image set associated with the part containing the icon and text. @@ -121,14 +131,33 @@ class DownloadItemView : public ChromeViews::View, // Sets the state and triggers a repaint. void SetState(State body_state, State drop_down_state); + // Whether we are in the dangerous mode. + bool IsDangerousMode() { return body_state_ == DANGEROUS; } + + // Reverts from dangerous mode to normal download mode. + void ClearDangerousMode(); + + // Sets |size| with the size of the Save and Discard buttons (they have the + // same size). + void GetButtonSize(CSize* size); + + // Sizes the dangerous download label to a minimum width available using 2 + // lines. The size is computed only the first time this method is invoked + // and simply returned on subsequent calls. + void SizeLabelToMinWidth(); + // The different images used for the background. BodyImageSet normal_body_image_set_; BodyImageSet hot_body_image_set_; BodyImageSet pushed_body_image_set_; + BodyImageSet dangerous_mode_body_image_set_; DropDownImageSet normal_drop_down_image_set_; DropDownImageSet hot_drop_down_image_set_; DropDownImageSet pushed_drop_down_image_set_; + // The warning icon showns for dangerous downloads. + SkBitmap* warning_icon_; + // The model we query for display information DownloadItem* download_; @@ -136,7 +165,6 @@ class DownloadItemView : public ChromeViews::View, DownloadShelfView* parent_; // Elements of our particular download - std::wstring file_name_; std::wstring status_text_; bool show_status_text_; @@ -189,6 +217,19 @@ class DownloadItemView : public ChromeViews::View, // Progress animation base::RepeatingTimer<DownloadItemView> progress_timer_; + // Dangerous mode buttons. + ChromeViews::NativeButton* save_button_; + ChromeViews::NativeButton* discard_button_; + + // Dangerous mode label. + ChromeViews::Label* dangerous_download_label_; + + // Whether the dangerous mode label has been sized yet. + bool dangerous_download_label_sized_; + + // The size of the buttons. Cached so animation works when hidden. + CSize cached_button_size_; + DISALLOW_EVIL_CONSTRUCTORS(DownloadItemView); }; |