diff options
author | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 02:49:12 +0000 |
---|---|---|
committer | asanka@chromium.org <asanka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 02:49:12 +0000 |
commit | 9ffabfb5e3e3e3de923d60a4ad4d1337b6895345 (patch) | |
tree | 275a04d47b5af436751e52935d37d280817c28ee /chrome/browser/download/download_shelf_context_menu.cc | |
parent | d5fbd900ab784c2fcc73e62b5496106487da2909 (diff) | |
download | chromium_src-9ffabfb5e3e3e3de923d60a4ad4d1337b6895345.zip chromium_src-9ffabfb5e3e3e3de923d60a4ad4d1337b6895345.tar.gz chromium_src-9ffabfb5e3e3e3de923d60a4ad4d1337b6895345.tar.bz2 |
Refactor dangerous download warning text generation into DownloadItemModel.
Previously, we had multiple copies of the logic for generating warning text for a dangerous or malicious download. Move all of these into DownloadModel. As an additional benefit, we no longer require UI code to interpret DownloadItem::GetDangerType().
BUG=116551
TEST=Start a dangerous, malicious, and extension download. Check whether the warning text is correct, and any embedded filename is elided if necessary.
Review URL: http://codereview.chromium.org/9569011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/download/download_shelf_context_menu.cc')
-rw-r--r-- | chrome/browser/download/download_shelf_context_menu.cc | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc index 7456b82..dd220f3 100644 --- a/chrome/browser/download/download_shelf_context_menu.cc +++ b/chrome/browser/download/download_shelf_context_menu.cc @@ -28,21 +28,16 @@ DownloadShelfContextMenu::DownloadShelfContextMenu( ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() { ui::SimpleMenuModel* model = NULL; + // We shouldn't be opening a context menu for a dangerous download, unless it + // is a malicious download. + DCHECK(!download_model_->IsDangerous() || download_model_->IsMalicious()); - if (download_item_->GetSafetyState() == DownloadItem::DANGEROUS) { - if (download_item_->GetDangerType() == - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || - download_item_->GetDangerType() == - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT) { - model = GetMaliciousMenuModel(); - } else { - NOTREACHED(); - } - } else if (download_item_->IsComplete()) { + if (download_model_->IsMalicious()) + model = GetMaliciousMenuModel(); + else if (download_item_->IsComplete()) model = GetFinishedMenuModel(); - } else { + else model = GetInProgressMenuModel(); - } return model; } |