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

Unified Diff: chrome/browser/download/download_item_model.h

Issue 9569011: Refactor dangerous download warning text generation into DownloadItemModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyright headers Created 8 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_item_model.h
diff --git a/chrome/browser/download/download_item_model.h b/chrome/browser/download/download_item_model.h
index db81467280090dfde8fba954539d169c24d26d5d..2eb9375552228fbc3bdbafe861f8ee9cf7b8501f 100644
--- a/chrome/browser/download/download_item_model.h
+++ b/chrome/browser/download/download_item_model.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,8 +18,11 @@ namespace content {
class DownloadItem;
}
-// This class provides an interface for functions which have different behaviors
-// depending on the type of download.
+namespace gfx {
+class Font;
+}
+
+// This class is an abstraction for common UI tasks associated with a download.
class BaseDownloadItemModel {
public:
explicit BaseDownloadItemModel(content::DownloadItem* download)
@@ -32,25 +35,42 @@ class BaseDownloadItemModel {
// Get the status text to display.
virtual string16 GetStatusText() = 0;
+ // Get the warning text to display for a dangerous download. The |base_width|
+ // is the maximum width of an embedded filename (if there is one). The metrics
+ // for the filename will be based on |font|. Should only be called if
+ // IsDangerous() is true.
+ virtual string16 GetWarningText(const gfx::Font& font, int base_width) = 0;
+
+ // Get the caption text for a button for confirming a dangerous download
+ // warning.
+ virtual string16 GetWarningConfirmButtonText() = 0;
+
+ // Is this considered a malicious download? Implies IsDangerous().
+ virtual bool IsMalicious() = 0;
+
+ // Is this considered a dangerous download?
+ virtual bool IsDangerous() = 0;
+
content::DownloadItem* download() { return download_; }
protected:
content::DownloadItem* download_;
};
-// This class is a model class for DownloadItemView. It provides functionality
-// for canceling the downloading, and also the text for displaying downloading
-// status.
+// Concrete implementation of BaseDownloadItemModel.
class DownloadItemModel : public BaseDownloadItemModel {
public:
explicit DownloadItemModel(content::DownloadItem* download);
virtual ~DownloadItemModel() { }
- // Cancel the downloading.
+ // BaseDownloadItemModel
virtual void CancelTask() OVERRIDE;
-
- // Get downloading status text.
virtual string16 GetStatusText() OVERRIDE;
+ virtual string16 GetWarningText(const gfx::Font& font,
+ int base_width) OVERRIDE;
+ virtual string16 GetWarningConfirmButtonText() OVERRIDE;
+ virtual bool IsMalicious() OVERRIDE;
+ virtual bool IsDangerous() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(DownloadItemModel);
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698