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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 14
15 class SavePackage; 15 class SavePackage;
16 16
17 namespace content { 17 namespace content {
18 class DownloadItem; 18 class DownloadItem;
19 } 19 }
20 20
21 // This class provides an interface for functions which have different behaviors 21 namespace gfx {
22 // depending on the type of download. 22 class Font;
23 }
24
25 // This class is an abstraction for common UI tasks associated with a download.
23 class BaseDownloadItemModel { 26 class BaseDownloadItemModel {
24 public: 27 public:
25 explicit BaseDownloadItemModel(content::DownloadItem* download) 28 explicit BaseDownloadItemModel(content::DownloadItem* download)
26 : download_(download) { } 29 : download_(download) { }
27 virtual ~BaseDownloadItemModel() { } 30 virtual ~BaseDownloadItemModel() { }
28 31
29 // Cancel the task corresponding to the item. 32 // Cancel the task corresponding to the item.
30 virtual void CancelTask() = 0; 33 virtual void CancelTask() = 0;
31 34
32 // Get the status text to display. 35 // Get the status text to display.
33 virtual string16 GetStatusText() = 0; 36 virtual string16 GetStatusText() = 0;
34 37
38 // Get the warning text to display for a dangerous download. The |base_width|
39 // is the maximum width of an embedded filename (if there is one). The metrics
40 // for the filename will be based on |font|. Should only be called if
41 // IsDangerous() is true.
42 virtual string16 GetWarningText(const gfx::Font& font, int base_width) = 0;
43
44 // Get the caption text for a button for confirming a dangerous download
45 // warning.
46 virtual string16 GetWarningConfirmButtonText() = 0;
47
48 // Is this considered a malicious download? Implies IsDangerous().
49 virtual bool IsMalicious() = 0;
50
51 // Is this considered a dangerous download?
52 virtual bool IsDangerous() = 0;
53
35 content::DownloadItem* download() { return download_; } 54 content::DownloadItem* download() { return download_; }
36 55
37 protected: 56 protected:
38 content::DownloadItem* download_; 57 content::DownloadItem* download_;
39 }; 58 };
40 59
41 // This class is a model class for DownloadItemView. It provides functionality 60 // Concrete implementation of BaseDownloadItemModel.
42 // for canceling the downloading, and also the text for displaying downloading
43 // status.
44 class DownloadItemModel : public BaseDownloadItemModel { 61 class DownloadItemModel : public BaseDownloadItemModel {
45 public: 62 public:
46 explicit DownloadItemModel(content::DownloadItem* download); 63 explicit DownloadItemModel(content::DownloadItem* download);
47 virtual ~DownloadItemModel() { } 64 virtual ~DownloadItemModel() { }
48 65
49 // Cancel the downloading. 66 // BaseDownloadItemModel
50 virtual void CancelTask() OVERRIDE; 67 virtual void CancelTask() OVERRIDE;
51
52 // Get downloading status text.
53 virtual string16 GetStatusText() OVERRIDE; 68 virtual string16 GetStatusText() OVERRIDE;
69 virtual string16 GetWarningText(const gfx::Font& font,
70 int base_width) OVERRIDE;
71 virtual string16 GetWarningConfirmButtonText() OVERRIDE;
72 virtual bool IsMalicious() OVERRIDE;
73 virtual bool IsDangerous() OVERRIDE;
54 74
55 private: 75 private:
56 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel); 76 DISALLOW_COPY_AND_ASSIGN(DownloadItemModel);
57 }; 77 };
58 78
59 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_ 79 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_ITEM_MODEL_H_
OLDNEW
« 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